Skip to content

Commit

Permalink
APM-5429 use symmetric key when testing HS algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
sophieclayton12-nhs committed Aug 12, 2024
1 parent cdcff24 commit 409bd4e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions e2e/tests/oauth/test_client_credentials.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 409bd4e

Please sign in to comment.