@@ -87,7 +87,10 @@ groups() ->
87
87
]},
88
88
{with_introspection_endpoint , [], [
89
89
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
91
94
]}
92
95
].
93
96
@@ -303,7 +306,11 @@ init_per_testcase(multiple_resource_server_ids, Config) ->
303
306
rabbit_ct_helpers :testcase_started (Config , multiple_resource_server_ids ),
304
307
Config ;
305
308
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" >>),
307
314
rabbit_ct_helpers :testcase_started (
308
315
setup_introspection_configuration (Config ), Testcase );
309
316
@@ -372,7 +379,10 @@ end_per_testcase(multiple_resource_server_ids, Config) ->
372
379
rabbit_ct_helpers :testcase_started (Config , multiple_resource_server_ids ),
373
380
Config ;
374
381
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 ->
376
386
teardown_introspection_configuration (Config );
377
387
378
388
end_per_testcase (Testcase , Config ) ->
@@ -524,6 +534,47 @@ test_unsuccessful_connection_with_invalid_opaque_token(Config) ->
524
534
{error , Error } = open_unmanaged_connection (Config , 0 , <<" username" >>, <<" inactive" >>),
525
535
ct :log (" Error : ~p " , [Error ]).
526
536
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" >>)).
527
578
528
579
mqtt (Config ) ->
529
580
Topic = <<" test/topic" >>,
0 commit comments