11
11
-include_lib (" eunit/include/eunit.hrl" ).
12
12
-import (application , [set_env /3 , unset_env /2 ]).
13
13
-import (rabbit_mgmt_wm_auth , [authSettings /0 ]).
14
+ -import (rabbit_mgmt_test_util , [req /5 ]).
14
15
-compile (export_all ).
15
16
16
17
all () ->
@@ -27,12 +28,17 @@ all() ->
27
28
{group , verify_oauth_initiated_logon_type_for_idp_initiated },
28
29
{group , verify_oauth_disable_basic_auth },
29
30
{group , verify_oauth_scopes },
30
- {group , verify_extra_endpoint_params }
31
+ {group , verify_extra_endpoint_params },
32
+ {group , run_with_broker }
31
33
].
32
34
33
35
groups () ->
34
36
[
35
-
37
+ {run_with_broker , [], [
38
+ {verify_introspection_endpoint , [], [
39
+ introspect_opaque_token_returns_active_jwt_token
40
+ ]}
41
+ ]},
36
42
{verify_multi_resource_and_provider , [], [
37
43
{with_oauth_enabled , [], [
38
44
{with_oauth_providers_idp1_idp2 , [], [
@@ -510,6 +516,26 @@ init_per_group(with_mgt_resource_server_a_with_token_endpoint_params_1, Config)
510
516
? config (a , Config ), oauth_token_endpoint_params , ? config (token_params_1 , Config )),
511
517
Config ;
512
518
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 ;
513
539
514
540
init_per_group (_ , Config ) ->
515
541
Config .
@@ -632,11 +658,44 @@ end_per_group(with_mgt_resource_server_a_with_token_endpoint_params_1, Config) -
632
658
? config (a , Config ), oauth_token_endpoint_params ),
633
659
Config ;
634
660
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 ;
635
672
636
673
end_per_group (_ , Config ) ->
637
674
Config .
638
675
639
676
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
+
640
699
% % -------------------------------------------------------------------
641
700
% % Test cases.
642
701
% % -------------------------------------------------------------------
@@ -838,6 +897,10 @@ should_return_mgt_oauth_resource_a_with_token_endpoint_params_1(Config) ->
838
897
assertEqual_on_attribute_for_oauth_resource_server (authSettings (),
839
898
Config , a , oauth_token_endpoint_params , token_params_1 ).
840
899
900
+ introspect_opaque_token_returns_active_jwt_token (Config ) ->
901
+ _Result = req (Config , 0 , post , " /introspect" , [{" Authorization" , " Bearer active" }]).
902
+
903
+
841
904
% % -------------------------------------------------------------------
842
905
% % Utility/helper functions
843
906
% % -------------------------------------------------------------------
0 commit comments