@@ -337,7 +337,7 @@ def test_construct_oidc_client_succ(self, monkeypatch):
337337 )
338338
339339 def test_token_introspect_succ (self , monkeypatch , rsa_keys ):
340- """Verify .token_introspect_offline () success path"""
340+ """Verify .token_introspect () success path"""
341341 client_id = "us"
342342 token , expected_payload = gen_rsa_token (client_id , rsa_keys ["private_key" ])
343343
@@ -364,7 +364,7 @@ def test_token_introspect_succ(self, monkeypatch, rsa_keys):
364364 assert response == expected_payload
365365
366366 def test_token_introspect_exp (self , monkeypatch , rsa_keys ):
367- """Verify .token_introspect_offline () failure via expiration"""
367+ """Verify .token_introspect () failure via expiration"""
368368 client_id = "us"
369369 token , expected_payload = gen_rsa_token (
370370 client_id , rsa_keys ["private_key" ], exp = 42
@@ -383,7 +383,7 @@ def test_token_introspect_exp(self, monkeypatch, rsa_keys):
383383 ), f"{ exc .value .__cause__ } "
384384
385385 def test_token_introspect_aud (self , monkeypatch , rsa_keys ):
386- """Verify .token_introspect_offline () failure via audience error"""
386+ """Verify .token_introspect () failure via audience error"""
387387 client_id = "us"
388388 token , expected_payload = gen_rsa_token (client_id , rsa_keys ["private_key" ])
389389
@@ -397,7 +397,7 @@ def test_token_introspect_aud(self, monkeypatch, rsa_keys):
397397 assert str (exc .value .__cause__ ) == "Invalid audience" , f"{ exc .value .__cause__ } "
398398
399399 def test_token_introspect_sig (self , monkeypatch , rsa_keys ):
400- """Verify .token_introspect_offline () failure via signature error"""
400+ """Verify .token_introspect () failure via signature error"""
401401 client_id = "us"
402402 token , expected_payload = gen_rsa_token (client_id , rsa_keys ["private_key" ])
403403
@@ -415,6 +415,25 @@ def test_token_introspect_sig(self, monkeypatch, rsa_keys):
415415 str (exc .value .__cause__ ) == "Signature verification failed"
416416 ), f"{ exc .value .__cause__ } "
417417
418+ def test_token_introspect_alg (self , monkeypatch , rsa_keys ):
419+ """Verify .token_introspect() failure via algorithm error"""
420+ client_id = "us"
421+
422+ # Make the algorithm invalid.
423+ generated_api_key = jwt .encode (
424+ {"some_key" : "some_value" }, "my_secret" , algorithm = "HS256"
425+ )
426+ config = mock_connection (
427+ monkeypatch , client_id , public_key = rsa_keys ["public_key" ]
428+ )
429+ oidc_client = OpenIDClient .construct_oidc_client (config )
430+
431+ with pytest .raises (OpenIDTokenInvalid ) as exc :
432+ oidc_client .token_introspect (generated_api_key )
433+ assert (
434+ str (exc .value .__cause__ ) == "The specified alg value is not allowed"
435+ ), f"{ exc .value .__cause__ } "
436+
418437
419438@dataclass
420439class MockRequest :
0 commit comments