Skip to content

Commit ad023f6

Browse files
Verify multi providers + end_session_endpoint
1 parent 9fef822 commit ad023f6

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

deps/rabbitmq_management/test/rabbit_mgmt_wm_auth_SUITE.erl

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ all() ->
2020
{group, verify_mgt_oauth_provider_url_with_single_resource},
2121
{group, verify_mgt_oauth_provider_url_with_single_resource_and_another_resource},
2222
{group, verify_end_session_endpoint_with_single_resource},
23+
{group, verify_end_session_endpoint_with_single_resource_and_another_resource},
2324
{group, verify_oauth_initiated_logon_type_for_sp_initiated},
2425
{group, verify_oauth_initiated_logon_type_for_idp_initiated},
2526
{group, verify_oauth_disable_basic_auth},
@@ -129,6 +130,38 @@ groups() ->
129130
]}
130131
]}
131132
]},
133+
{verify_end_session_endpoint_with_single_resource_and_another_resource, [], [
134+
{with_resource_server_id_rabbit, [], [
135+
{with_resource_server_a, [], [
136+
{with_root_issuer_url1, [], [
137+
{with_oauth_enabled, [], [
138+
should_return_disabled_auth_settings,
139+
{with_mgt_oauth_client_id_z, [], [
140+
should_not_return_end_session_endpoint,
141+
should_return_oauth_resource_server_a_without_end_session_endpoint,
142+
{with_root_end_session_endpoint_0, [], [
143+
should_return_end_session_endpoint_0,
144+
should_return_oauth_resource_server_a_with_end_session_endpoint_0
145+
]},
146+
{with_oauth_providers_idp1_idp2, [], [
147+
{with_default_oauth_provider_idp1, [], [
148+
{with_end_session_endpoint_for_idp1_1, [], [
149+
should_return_end_session_endpoint_1,
150+
should_return_oauth_resource_server_a_with_end_session_endpoint_1,
151+
{with_oauth_provider_idp2_for_resource_server_a, [], [
152+
{with_end_session_endpoint_for_idp2_2, [], [
153+
should_return_oauth_resource_server_a_with_end_session_endpoint_2
154+
]}
155+
]}
156+
]}
157+
]}
158+
]}
159+
]}
160+
]}
161+
]}
162+
]}
163+
]}
164+
]},
132165
{verify_mgt_oauth_provider_url_with_single_resource_and_another_resource, [], [
133166
{with_resource_server_id_rabbit, [], [
134167
{with_resource_server_a, [], [
@@ -272,6 +305,7 @@ init_per_suite(Config) ->
272305
{url1, <<"https://url1">>},
273306
{logout_url_0, <<"https://logout_0">>},
274307
{logout_url_1, <<"https://logout_1">>},
308+
{logout_url_2, <<"https://logout_2">>},
275309
{a, <<"a">>},
276310
{b, <<"b">>},
277311
{q, <<"q">>},
@@ -371,6 +405,15 @@ init_per_group(with_end_session_endpoint_for_idp1_1, Config) ->
371405
set_attribute_in_entry_for_env_variable(rabbitmq_auth_backend_oauth2, oauth_providers,
372406
?config(idp1, Config), end_session_endpoint, ?config(logout_url_1, Config)),
373407
Config;
408+
init_per_group(with_end_session_endpoint_for_idp2_2, Config) ->
409+
set_attribute_in_entry_for_env_variable(rabbitmq_auth_backend_oauth2, oauth_providers,
410+
?config(idp2, Config), end_session_endpoint, ?config(logout_url_2, Config)),
411+
Config;
412+
413+
init_per_group(with_oauth_provider_idp2_for_resource_server_a, Config) ->
414+
set_attribute_in_entry_for_env_variable(rabbitmq_auth_backend_oauth2, resource_servers,
415+
?config(a, Config), oauth_provider_id, ?config(idp2, Config)),
416+
Config;
374417

375418
init_per_group(_, Config) ->
376419
Config.
@@ -459,6 +502,15 @@ end_per_group(with_end_session_endpoint_for_idp1_1, Config) ->
459502
remove_attribute_from_entry_from_env_variable(rabbitmq_auth_backend_oauth2, oauth_providers,
460503
?config(idp1, Config), end_session_endpoint),
461504
Config;
505+
end_per_group(with_end_session_endpoint_for_idp2_2, Config) ->
506+
remove_attribute_from_entry_from_env_variable(rabbitmq_auth_backend_oauth2, oauth_providers,
507+
?config(idp2, Config), end_session_endpoint),
508+
Config;
509+
end_per_group(with_oauth_provider_idp2_for_resource_server_a, Config) ->
510+
remove_attribute_from_entry_from_env_variable(rabbitmq_auth_backend_oauth2, resource_servers,
511+
?config(a, Config), oauth_provider_id),
512+
Config;
513+
462514
end_per_group(_, Config) ->
463515
Config.
464516

@@ -589,15 +641,28 @@ should_not_return_end_session_endpoint(Config) ->
589641
Config, rabbit, end_session_endpoint).
590642

591643
should_return_end_session_endpoint_0(Config) ->
592-
ct:log("settings: ~p", [rabbit_mgmt_wm_auth:authSettings()]),
593644
assertEqual_on_attribute_for_oauth_resource_server(rabbit_mgmt_wm_auth:authSettings(),
594645
Config, rabbit, end_session_endpoint, ?config(logout_url_0, Config)).
595646

596647
should_return_end_session_endpoint_1(Config) ->
597-
ct:log("settings: ~p", [rabbit_mgmt_wm_auth:authSettings()]),
598648
assertEqual_on_attribute_for_oauth_resource_server(rabbit_mgmt_wm_auth:authSettings(),
599649
Config, rabbit, end_session_endpoint, ?config(logout_url_1, Config)).
600650

651+
should_return_oauth_resource_server_a_without_end_session_endpoint(Config) ->
652+
assert_attribute_not_defined_for_oauth_resource_server(rabbit_mgmt_wm_auth:authSettings(),
653+
Config, a, end_session_endpoint).
654+
655+
should_return_oauth_resource_server_a_with_end_session_endpoint_0(Config) ->
656+
assertEqual_on_attribute_for_oauth_resource_server(rabbit_mgmt_wm_auth:authSettings(),
657+
Config, a, end_session_endpoint, ?config(logout_url_0, Config)).
658+
659+
should_return_oauth_resource_server_a_with_end_session_endpoint_1(Config) ->
660+
assertEqual_on_attribute_for_oauth_resource_server(rabbit_mgmt_wm_auth:authSettings(),
661+
Config, a, end_session_endpoint, ?config(logout_url_1, Config)).
662+
663+
should_return_oauth_resource_server_a_with_end_session_endpoint_2(Config) ->
664+
assertEqual_on_attribute_for_oauth_resource_server(rabbit_mgmt_wm_auth:authSettings(),
665+
Config, a, end_session_endpoint, ?config(logout_url_2, Config)).
601666

602667
%% -------------------------------------------------------------------
603668
%% Utility/helper functions
@@ -647,7 +712,9 @@ assert_not_defined_oauth_resource_server(Actual, Config, ConfigKey) ->
647712

648713
set_attribute_in_entry_for_env_variable(Application, EnvVar, Key, Attribute, Value) ->
649714
Map = application:get_env(Application, EnvVar, #{}),
715+
ct:log("set_attribute_in_entry_for_env_variable before ~p", [Map]),
650716
Map1 = maps:put(Key, [ { Attribute, Value} | maps:get(Key, Map, []) ], Map),
717+
ct:log("set_attribute_in_entry_for_env_variable after ~p", [Map1]),
651718
application:set_env(Application, EnvVar, Map1).
652719

653720
log(AuthSettings) ->

0 commit comments

Comments
 (0)