@@ -87,7 +87,10 @@ groups() ->
8787 ]},
8888 {with_introspection_endpoint , [], [
8989 test_successful_connection_with_valid_opaque_token ,
90- test_unsuccessful_connection_with_invalid_opaque_token
90+ test_unsuccessful_connection_with_invalid_opaque_token ,
91+ test_successful_opaque_token_refresh ,
92+ test_successful_opaque_token_refresh_with_more_restrictive_token ,
93+ test_unsuccessful_opaque_token_refresh_with_inactive_token
9194 ]}
9295 ].
9396
@@ -303,7 +306,11 @@ init_per_testcase(multiple_resource_server_ids, Config) ->
303306 rabbit_ct_helpers :testcase_started (Config , multiple_resource_server_ids ),
304307 Config ;
305308
306- init_per_testcase (Testcase , Config ) when Testcase =:= test_successful_connection_with_valid_opaque_token ->
309+ init_per_testcase (Testcase , Config ) when Testcase =:= test_successful_connection_with_valid_opaque_token orelse
310+ Testcase =:= test_successful_opaque_token_refresh orelse
311+ Testcase =:= test_successful_opaque_token_refresh_with_more_restrictive_token orelse
312+ Testcase =:= test_unsuccessful_opaque_token_refresh_with_inactive_token ->
313+ rabbit_ct_broker_helpers :add_vhost (Config , <<" vhost1" >>),
307314 rabbit_ct_helpers :testcase_started (
308315 setup_introspection_configuration (Config ), Testcase );
309316
@@ -372,7 +379,10 @@ end_per_testcase(multiple_resource_server_ids, Config) ->
372379 rabbit_ct_helpers :testcase_started (Config , multiple_resource_server_ids ),
373380 Config ;
374381
375- end_per_testcase (Testcase , Config ) when Testcase =:= test_successful_connection_with_valid_opaque_token ->
382+ end_per_testcase (Testcase , Config ) when Testcase =:= test_successful_connection_with_valid_opaque_token orelse
383+ Testcase =:= test_successful_opaque_token_refresh orelse
384+ Testcase =:= test_successful_opaque_token_refresh_with_more_restrictive_token orelse
385+ Testcase =:= test_unsuccessful_opaque_token_refresh_with_inactive_token ->
376386 teardown_introspection_configuration (Config );
377387
378388end_per_testcase (Testcase , Config ) ->
@@ -524,6 +534,47 @@ test_unsuccessful_connection_with_invalid_opaque_token(Config) ->
524534 {error , Error } = open_unmanaged_connection (Config , 0 , <<" username" >>, <<" inactive" >>),
525535 ct :log (" Error : ~p " , [Error ]).
526536
537+ test_successful_opaque_token_refresh (Config ) ->
538+ Conn = open_unmanaged_connection (Config , 0 , <<" vhost1" >>, <<" username" >>, <<" active" >>),
539+ {ok , Ch } = amqp_connection :open_channel (Conn ),
540+
541+ # 'queue.declare_ok' {queue = _ } =
542+ amqp_channel :call (Ch , # 'queue.declare' {exclusive = true }),
543+
544+ ? assertEqual (ok , amqp_connection :update_secret (Conn , <<" active" >>, <<" token refresh" >>)),
545+
546+ {ok , Ch2 } = amqp_connection :open_channel (Conn ),
547+
548+ # 'queue.declare_ok' {queue = _ } =
549+ amqp_channel :call (Ch2 , # 'queue.declare' {exclusive = true }),
550+
551+ close_connection_and_channel (Conn , Ch ).
552+
553+ test_successful_opaque_token_refresh_with_more_restrictive_token (Config ) ->
554+ Conn = open_unmanaged_connection (Config , 0 , <<" vhost1" >>, <<" username" >>, <<" active" >>),
555+ {ok , Ch } = amqp_connection :open_channel (Conn ),
556+
557+ # 'queue.declare_ok' {queue = _ } =
558+ amqp_channel :call (Ch , # 'queue.declare' {exclusive = true }),
559+
560+ ? assertEqual (ok , amqp_connection :update_secret (Conn , <<" active-2" >>, <<" token refresh" >>)),
561+
562+ {ok , Ch2 } = amqp_connection :open_channel (Conn ),
563+
564+ ? assertExit ({{shutdown , {server_initiated_close , 403 , _ }}, _ },
565+ amqp_channel :call (Ch2 , # 'queue.declare' {queue = <<" a.q" >>, exclusive = true })),
566+
567+ catch close_connection (Conn ).
568+
569+ test_unsuccessful_opaque_token_refresh_with_inactive_token (Config ) ->
570+ Conn = open_unmanaged_connection (Config , 0 , <<" vhost1" >>, <<" username" >>, <<" active" >>),
571+ {ok , Ch } = amqp_connection :open_channel (Conn ),
572+
573+ # 'queue.declare_ok' {queue = _ } =
574+ amqp_channel :call (Ch , # 'queue.declare' {exclusive = true }),
575+
576+ ? assertException (exit , {{nodedown ,not_allowed },_ },
577+ amqp_connection :update_secret (Conn , <<" inactive" >>, <<" token refresh" >>)).
527578
528579mqtt (Config ) ->
529580 Topic = <<" test/topic" >>,
0 commit comments