Skip to content

Commit 9770637

Browse files
Fix schema test cases
1 parent b800d3c commit 9770637

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

deps/oauth2_client/src/oauth2_client.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,14 @@ get_opaque_token_signing_key() ->
423423

424424
-spec get_opaque_token_signing_key(string()|binary()) -> {ok, signing_key()} | {error, any()}.
425425
get_opaque_token_signing_key(KeyId) ->
426-
List = get_env(opaque_token_signing_key),
427-
case proplists:get_value(id, List, undefined) of
426+
case get_env(opaque_token_signing_key) of
428427
undefined -> {error, missing_opaque_token_signing_key};
429-
KeyId -> parse_signing_key_configuration(List);
430-
_ -> {error, missing_opaque_token_signing_key}
428+
List ->
429+
case proplists:get_value(id, List, undefined) of
430+
undefined -> {error, missing_opaque_token_signing_key};
431+
KeyId -> parse_signing_key_configuration(List);
432+
_ -> {error, missing_opaque_token_signing_key}
433+
end
431434
end.
432435

433436
parse_signing_key_configuration(List) ->

deps/rabbitmq_auth_backend_oauth2/priv/schema/rabbitmq_auth_backend_oauth2.schema

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@
183183
"rabbitmq_auth_backend_oauth2.key_config.opaque_token_signing_key.cert_pem_file",
184184
[{datatype, file}, {validators, ["file_accessible"]}]}.
185185

186-
{translation,
187-
"rabbitmq_auth_backend_oauth2.opaque_token_signing_key",
188-
fun(Conf) ->
189-
rabbit_oauth2_schema:translate_opaque_token_signing_key(Conf)
190-
end}.
186+
%%{translation,
187+
%% "rabbitmq_auth_backend_oauth2.opaque_token_signing_key",
188+
%% fun(Conf) ->
189+
%% rabbit_oauth2_schema:translate_opaque_token_signing_key(Conf)
190+
%% end}.
191191

192192
%% ID of the default signing key
193193
%%

deps/rabbitmq_auth_backend_oauth2/src/rabbit_oauth2_provider.erl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,17 @@ get_signing_keys(OauthProviderId) ->
146146
end.
147147

148148
get_signing_key(KeyId) ->
149+
get_signing_key(KeyId, root).
150+
151+
get_signing_key(KeyId, OAuthProviderId) ->
149152
case maps:get(KeyId, get_signing_keys(root), undefined) of
150-
undefined -> oauth2_client:get_opaque_token_signing_key(KeyId);
153+
undefined ->
154+
case oauth2_client:get_opaque_token_signing_key(KeyId) of
155+
{error, _} -> undefined;
156+
{ok, SK} -> SK
157+
end;
151158
V -> V
152159
end.
153-
get_signing_key(KeyId, OAuthProviderId) ->
154-
case maps:get(KeyId, get_signing_keys(OAuthProviderId), undefined) of
155-
undefined -> oauth2_client:get_opaque_token_signing_key(KeyId);
156-
V -> V
157-
end.
158160

159161
-spec get_default_key(oauth_provider_id()) -> binary() | undefined.
160162
get_default_key(root) ->

deps/rabbitmq_auth_backend_oauth2/test/config_schema_SUITE_data/rabbitmq_auth_backend_oauth2.snippets

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<<"id2">> => {pem, <<"I'm not a certificate">>}
4747
}
4848
},
49+
{opaque_token_signing_key,[]},
4950
{jwks_url, "https://my-jwt-issuer/jwks.json"},
5051
{cacertfile, "test/config_schema_SUITE_data/certs/cacert.pem"},
5152
{peer_verification, verify_none},
@@ -363,5 +364,22 @@
363364
}}
364365
]}
365366
], []
367+
},
368+
{opaque_token_signing_key,
369+
"auth_oauth2.resource_server_id = new_resource_server_id
370+
auth_oauth2.opaque_token_signing_key.id = opaque-id
371+
auth_oauth2.opaque_token_signing_key.type = hs256
372+
auth_oauth2.opaque_token_signing_key.key = opaque-signing-key-value",
373+
[
374+
{rabbitmq_auth_backend_oauth2, [
375+
{resource_server_id, <<"new_resource_server_id">>},
376+
{opaque_token_signing_key, [
377+
{id, <<"opaque-id">>},
378+
{type, hs256},
379+
{key, <<"opaque-signing-key-value">>}
380+
]}
381+
]}
382+
], []
366383
}
384+
367385
].

0 commit comments

Comments
 (0)