@@ -52,7 +52,8 @@ groups() ->
52
52
[
53
53
{run_with_broker , [], [
54
54
{verify_introspection_endpoint , [], [
55
- introspect_opaque_token_returns_active_jwt_token
55
+ introspect_opaque_token_returns_active_jwt_token ,
56
+ introspect_opaque_token_returns_inactive_jwt_token
56
57
]}
57
58
]},
58
59
{verify_multi_resource_and_provider , [], [
@@ -693,7 +694,8 @@ end_per_group(verify_introspection_endpoint, Config) ->
693
694
end_per_group (_ , Config ) ->
694
695
Config .
695
696
696
- init_per_testcase (introspect_opaque_token_returns_active_jwt_token , Config ) ->
697
+ init_per_testcase (Testcase , Config ) when Testcase =:= introspect_opaque_token_returns_active_jwt_token orelse
698
+ Testcase =:= introspect_opaque_token_returns_inactive_jwt_token ->
697
699
ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
698
700
[rabbitmq_auth_backend_oauth2 , introspection_endpoint ,
699
701
? config (authorization_server_url , Config )]),
@@ -706,9 +708,10 @@ init_per_testcase(introspect_opaque_token_returns_active_jwt_token, Config) ->
706
708
ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
707
709
[rabbitmq_auth_backend_oauth2 , key_config , [{cacertfile , CaCertFile }]]),
708
710
709
- rabbit_ct_helpers :testcase_started (Config , introspect_opaque_token_returns_active_jwt_token ).
711
+ rabbit_ct_helpers :testcase_started (Config , Testcase ).
710
712
711
- end_per_testcase (introspect_opaque_token_returns_active_jwt_token , Config ) ->
713
+ end_per_testcase (Testcase , Config ) when Testcase =:= introspect_opaque_token_returns_active_jwt_token orelse
714
+ Testcase =:= introspect_opaque_token_returns_inactive_jwt_token ->
712
715
ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , unset_env ,
713
716
[rabbitmq_auth_backend_oauth2 , introspection_endpoint ]),
714
717
ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , unset_env ,
@@ -941,12 +944,19 @@ should_return_mgt_oauth_resource_a_with_token_endpoint_params_1(Config) ->
941
944
Config , a , oauth_token_endpoint_params , token_params_1 ).
942
945
943
946
introspect_opaque_token_returns_active_jwt_token (Config ) ->
944
- {ok , {{_HTTP , _ , _ }, _Headers , ResBody }} = req (Config , 0 , post , " /auth/introspect" , [
947
+ {ok , {{_HTTP , 200 , _ }, _Headers , ResBody }} = req (Config , 0 , post , " /auth/introspect" , [
945
948
{" authorization" , " bearer active" }], []),
946
949
JSON = rabbit_json :decode (rabbit_data_coercion :to_binary (ResBody )),
947
950
? assertEqual (true , maps :get (<<" active" >>, JSON )),
948
951
? assertEqual (" rabbitmq.tag:administrator" , maps :get (<<" scope" >>, JSON )).
949
952
953
+ introspect_opaque_token_returns_inactive_jwt_token (Config ) ->
954
+ {ok , {{_HTTP , 401 , _ }, _Headers , ResBody }} = req (Config , 0 , post , " /auth/introspect" , [
955
+ {" authorization" , " bearer inactive" }], []),
956
+ JSON = rabbit_json :decode (rabbit_data_coercion :to_binary (ResBody )),
957
+ ? assertEqual (<<" not_authorised" >>, maps :get (<<" error" >>, JSON )),
958
+ ? assertEqual (<<" Introspected token is not active" >>, maps :get (<<" reason" >>, JSON )).
959
+
950
960
951
961
952
962
% % -------------------------------------------------------------------
0 commit comments