Skip to content

Commit

Permalink
Test with and without oauth2 keyconfig.cacertfile
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcialRosales committed Jun 13, 2023
1 parent 48cbc36 commit 1d428c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deps/rabbitmq_auth_backend_oauth2/src/uaa_jwks.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-module(uaa_jwks).
-export([get/1]).
-export([get/1, ssl_options/0]).

-spec get(string() | binary()) -> {ok, term()} | {error, term()}.
get(JwksUrl) ->
Expand Down
31 changes: 29 additions & 2 deletions deps/rabbitmq_auth_backend_oauth2/test/unit_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ all() ->
test_unsuccessful_access_with_a_token_that_uses_missing_scope_alias_in_scope_field,
test_successful_access_with_a_token_that_uses_single_scope_alias_in_extra_scope_source_field,
test_successful_access_with_a_token_that_uses_multiple_scope_aliases_in_extra_scope_source_field,
test_unsuccessful_access_with_a_token_that_uses_missing_scope_alias_in_extra_scope_source_field
test_unsuccessful_access_with_a_token_that_uses_missing_scope_alias_in_extra_scope_source_field,
test_default_ssl_options,
test_default_ssl_options_with_cacertfile
].

init_per_suite(Config) ->
Expand Down Expand Up @@ -88,6 +90,10 @@ init_per_testcase(test_post_process_payload_rich_auth_request_using_regular_expr
application:set_env(rabbitmq_auth_backend_oauth2, resource_server_id, <<"rabbitmq-test">>),
Config;

init_per_testcase(test_default_ssl_options_with_cacertfile, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, key_config, [{ cacertfile, filename:join(["testca", "cacert.pem"]) }] ),
Config;

init_per_testcase(_, Config) ->
Config.

Expand All @@ -96,6 +102,10 @@ end_per_testcase(test_post_process_token_payload_complex_claims, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, resource_server_id, undefined),
Config;

end_per_testcase(test_default_ssl_options_with_cacertfile, Config) ->
application:set_env(rabbitmq_auth_backend_oauth2, key_config, undefined),
Config;

end_per_testcase(_, Config) ->
Config.

Expand Down Expand Up @@ -1344,7 +1354,24 @@ test_validate_payload_when_verify_aud_false(_) ->
<<"scope">> => [<<"bar">>, <<"other.third">>]}},
rabbit_auth_backend_oauth2:validate_payload(WithAudWithUnknownResourceId, ?RESOURCE_SERVER_ID, ?DEFAULT_SCOPE_PREFIX)).


test_default_ssl_options(_) ->
?assertEqual([
{verify, verify_none},
{depth, 10},
{fail_if_no_peer_cert, false},
{crl_check, false},
{crl_cache, {ssl_crl_cache, {internal, [{http, 10000}]}}}
], uaa_jwks:ssl_options()).

test_default_ssl_options_with_cacertfile(_) ->
?assertEqual([
{verify, verify_none},
{depth, 10},
{fail_if_no_peer_cert, false},
{crl_check, false},
{crl_cache, {ssl_crl_cache, {internal, [{http, 10000}]}}},
{cacertfile, filename:join(["testca", "cacert.pem"])}
], uaa_jwks:ssl_options()).

%%
%% Helpers
Expand Down

0 comments on commit 1d428c4

Please sign in to comment.