@@ -52,7 +52,8 @@ groups() ->
5252 [
5353 {run_with_broker , [], [
5454 {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
5657 ]}
5758 ]},
5859 {verify_multi_resource_and_provider , [], [
@@ -693,7 +694,8 @@ end_per_group(verify_introspection_endpoint, Config) ->
693694end_per_group (_ , Config ) ->
694695 Config .
695696
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 ->
697699 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
698700 [rabbitmq_auth_backend_oauth2 , introspection_endpoint ,
699701 ? config (authorization_server_url , Config )]),
@@ -706,9 +708,10 @@ init_per_testcase(introspect_opaque_token_returns_active_jwt_token, Config) ->
706708 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , set_env ,
707709 [rabbitmq_auth_backend_oauth2 , key_config , [{cacertfile , CaCertFile }]]),
708710
709- rabbit_ct_helpers :testcase_started (Config , introspect_opaque_token_returns_active_jwt_token ).
711+ rabbit_ct_helpers :testcase_started (Config , Testcase ).
710712
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 ->
712715 ok = rabbit_ct_broker_helpers :rpc (Config , 0 , application , unset_env ,
713716 [rabbitmq_auth_backend_oauth2 , introspection_endpoint ]),
714717 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) ->
941944 Config , a , oauth_token_endpoint_params , token_params_1 ).
942945
943946introspect_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" , [
945948 {" authorization" , " bearer active" }], []),
946949 JSON = rabbit_json :decode (rabbit_data_coercion :to_binary (ResBody )),
947950 ? assertEqual (true , maps :get (<<" active" >>, JSON )),
948951 ? assertEqual (" rabbitmq.tag:administrator" , maps :get (<<" scope" >>, JSON )).
949952
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+
950960
951961
952962% % -------------------------------------------------------------------
0 commit comments