@@ -49,10 +49,13 @@ groups() ->
49
49
cannot_introspect_due_to_missing_configuration ,
50
50
{https , [], [
51
51
{with_introspection_basic_client_credentials , [], [
52
- can_introspect_token
52
+ can_introspect_token
53
53
]},
54
54
{with_introspection_request_param_client_credentials , [], [
55
55
can_introspect_token
56
+ ]},
57
+ {introspection_endpoint_returns_non_active_tokens , [], [
58
+ introspected_token_is_not_active
56
59
]}
57
60
]}
58
61
]},
@@ -215,6 +218,25 @@ init_per_group(with_introspection_basic_client_credentials, Config) ->
215
218
with_introspection_basic_client_credentials , Config )}
216
219
217
220
]} | Config ];
221
+ init_per_group (introspection_endpoint_returns_non_active_tokens , Config ) ->
222
+ application :set_env (rabbitmq_auth_backend_oauth2 , introspection_client_id ,
223
+ " some-client-id" ),
224
+ application :set_env (rabbitmq_auth_backend_oauth2 , introspection_client_secret ,
225
+ " some-client-secret" ),
226
+ application :set_env (rabbitmq_auth_backend_oauth2 , introspection_client_auth_method ,
227
+ basic ),
228
+ [{introspected_token_is_not_active , [
229
+ {introspection_endpoint , build_http_mock_behaviour (
230
+ build_introspection_token_request (? MOCK_OPAQUE_TOKEN , basic , <<" some-client-id" >>,
231
+ <<" some-client-secret" >>),
232
+ build_http_200_introspection_token_response ([
233
+ {active , false },
234
+ {scope , <<" openid" >>}
235
+ ]))},
236
+ {get_openid_configuration , get_openid_configuration_http_expectation (
237
+ with_introspection_basic_client_credentials , Config )}
238
+
239
+ ]} | Config ];
218
240
219
241
init_per_group (with_introspection_request_param_client_credentials , Config ) ->
220
242
application :set_env (rabbitmq_auth_backend_oauth2 , introspection_client_id ,
@@ -723,6 +745,9 @@ cannot_introspect_due_to_missing_configuration(_Config)->
723
745
can_introspect_token (_Config ) ->
724
746
{ok , _ } = oauth2_client :introspect_token (? MOCK_OPAQUE_TOKEN ).
725
747
748
+ introspected_token_is_not_active (_Config ) ->
749
+ {error , introspected_token_not_valid } = oauth2_client :introspect_token (? MOCK_OPAQUE_TOKEN ).
750
+
726
751
% %% HELPERS
727
752
728
753
build_issuer (Scheme ) ->
@@ -959,13 +984,15 @@ build_introspection_token_request(Token, request_param, ClientId, ClientSecret)
959
984
{? REQUEST_CLIENT_SECRET , ClientSecret }
960
985
]).
961
986
build_http_200_introspection_token_response () ->
987
+ build_http_200_introspection_token_response ([
988
+ {active , true },
989
+ {scope , <<" openid" >>}
990
+ ]).
991
+ build_http_200_introspection_token_response (PayloodList ) ->
962
992
[
963
993
{code , 200 },
964
994
{content_type , ? CONTENT_JSON },
965
- {payload , [
966
- {active , true },
967
- {scope , <<" openid" >>}
968
- ]}
995
+ {payload , PayloodList }
969
996
].
970
997
auth_server_error_when_access_token_request_expectation () ->
971
998
build_http_mock_behaviour (build_http_request (
0 commit comments