diff --git a/e2e/tests/oauth/test_client_credentials.py b/e2e/tests/oauth/test_client_credentials.py index 1a91af54..ee43caef 100644 --- a/e2e/tests/oauth/test_client_credentials.py +++ b/e2e/tests/oauth/test_client_credentials.py @@ -1,8 +1,10 @@ import pytest import requests +import jwt from time import time + from e2e.tests.utils.helpers import ( change_jwks_url, create_client_assertion, @@ -48,9 +50,14 @@ def test_incorrect_jwt_algorithm( token_data_client_credentials, algorithm, ): - token_data_client_credentials["client_assertion"] = create_client_assertion( - claims, _jwt_keys["private_key_pem"], algorithm=algorithm - ) + if algorithm.startswith("HS"): + # Use symmetric key for HS algorithms + token_data_client_credentials["client_assertion"] = jwt.encode({"some": "payload"}, "test-secret", algorithm="HS256") + else: + # Use asymmetric key for other algorithms + token_data_client_credentials["client_assertion"] = create_client_assertion( + claims, _jwt_keys["private_key_pem"], algorithm=algorithm + ) resp = requests.post( nhsd_apim_proxy_url + "/token",