1111-include_lib (" eunit/include/eunit.hrl" ).
1212-import (application , [set_env /3 , unset_env /2 ]).
1313-import (rabbit_mgmt_wm_auth , [authSettings /0 ]).
14+ -import (rabbit_mgmt_test_util , [req /5 ]).
1415-compile (export_all ).
1516
1617all () ->
@@ -27,12 +28,17 @@ all() ->
2728 {group , verify_oauth_initiated_logon_type_for_idp_initiated },
2829 {group , verify_oauth_disable_basic_auth },
2930 {group , verify_oauth_scopes },
30- {group , verify_extra_endpoint_params }
31+ {group , verify_extra_endpoint_params },
32+ {group , run_with_broker }
3133 ].
3234
3335groups () ->
3436 [
35-
37+ {run_with_broker , [], [
38+ {verify_introspection_endpoint , [], [
39+ introspect_opaque_token_returns_active_jwt_token
40+ ]}
41+ ]},
3642 {verify_multi_resource_and_provider , [], [
3743 {with_oauth_enabled , [], [
3844 {with_oauth_providers_idp1_idp2 , [], [
@@ -510,6 +516,26 @@ init_per_group(with_mgt_resource_server_a_with_token_endpoint_params_1, Config)
510516 ? config (a , Config ), oauth_token_endpoint_params , ? config (token_params_1 , Config )),
511517 Config ;
512518
519+ init_per_group (run_with_broker , Config ) ->
520+ Config1 = finish_init (run_with_broker , Config ),
521+ start_broker (Config1 );
522+
523+ init_per_group (verify_introspection_endpoint , Config ) ->
524+ {ok , _ } = application :ensure_all_started (ssl ),
525+ {ok , _ } = application :ensure_all_started (cowboy ),
526+
527+ PortBase = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_ports_base ),
528+ Port = PortBase + 100 ,
529+
530+ CertsDir = ? config (rmq_certsdir , Config ),
531+ Endpoints = [ {" /introspect" , introspect_endpoint , []}],
532+ Dispatch = cowboy_router :compile ([{'_' , Endpoints }]),
533+ {ok , _ } = cowboy :start_tls (introspection_http_listener ,
534+ [{port , Port },
535+ {certfile , filename :join ([CertsDir , " server" , " cert.pem" ])},
536+ {keyfile , filename :join ([CertsDir , " server" , " key.pem" ])}],
537+ #{env => #{dispatch => Dispatch }}),
538+ Config ;
513539
514540init_per_group (_ , Config ) ->
515541 Config .
@@ -632,11 +658,44 @@ end_per_group(with_mgt_resource_server_a_with_token_endpoint_params_1, Config) -
632658 ? config (a , Config ), oauth_token_endpoint_params ),
633659 Config ;
634660
661+ end_per_group (run_with_broker , Config ) ->
662+ Teardown0 = rabbit_ct_client_helpers :teardown_steps (),
663+ Teardown1 = rabbit_ct_broker_helpers :teardown_steps (),
664+ Steps = Teardown0 ++ Teardown1 ,
665+ rabbit_ct_helpers :run_teardown_steps (Config , Steps ),
666+ Config ;
667+
668+ end_per_group (verify_introspection_endpoint , Config ) ->
669+ ok = cowboy :stop_listener (introspection_http_listener ),
670+ inets :stop (),
671+ Config ;
635672
636673end_per_group (_ , Config ) ->
637674 Config .
638675
639676
677+ start_broker (Config ) ->
678+ Setup0 = rabbit_ct_broker_helpers :setup_steps (),
679+ Setup1 = rabbit_ct_client_helpers :setup_steps (),
680+ Steps = Setup0 ++ Setup1 ,
681+ case rabbit_ct_helpers :run_setup_steps (Config , Steps ) of
682+ {skip , _ } = Skip ->
683+ Skip ;
684+ Config1 ->
685+ Ret = rabbit_ct_broker_helpers :enable_feature_flag (
686+ Config1 , 'rabbitmq_4.0.0' ),
687+ case Ret of
688+ ok -> Config1 ;
689+ _ -> Ret
690+ end
691+ end .
692+ finish_init (Group , Config ) ->
693+ rabbit_ct_helpers :log_environment (),
694+ inets :start (),
695+ NodeConf = [{rmq_nodename_suffix , Group }],
696+ rabbit_ct_helpers :set_config (Config , NodeConf ).
697+
698+
640699% % -------------------------------------------------------------------
641700% % Test cases.
642701% % -------------------------------------------------------------------
@@ -838,6 +897,10 @@ should_return_mgt_oauth_resource_a_with_token_endpoint_params_1(Config) ->
838897 assertEqual_on_attribute_for_oauth_resource_server (authSettings (),
839898 Config , a , oauth_token_endpoint_params , token_params_1 ).
840899
900+ introspect_opaque_token_returns_active_jwt_token (Config ) ->
901+ _Result = req (Config , 0 , post , " /introspect" , [{" Authorization" , " Bearer active" }]).
902+
903+
841904% % -------------------------------------------------------------------
842905% % Utility/helper functions
843906% % -------------------------------------------------------------------
0 commit comments