Skip to content

Commit 1ca4d28

Browse files
committed
fixes the tests
1 parent b25fd76 commit 1ca4d28

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

tests/unit/test_session_service.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
ExpiredSignatureError,
1010
ImmatureSignatureError,
1111
InvalidSignatureError,
12+
InvalidAlgorithmError,
1213
PyJWKClientError,
1314
encode,
1415
)
@@ -182,9 +183,9 @@ def _provide_jwts(self):
182183
# Disallowed algorithm "none"
183184
(
184185
False,
185-
self._generate_jwt(iss="https://auth.acme.com", exp=int(time()) + 100, nbf=int(time()) - 100, algorithm="none"),
186-
PyJWKClientError,
187-
'Unable to find a signing key that matches: "None"',
186+
"eyJhbGciOiAibm9uZSIsICJ0eXAiOiAiSldUIiwgImtpZCI6ICJraWQxMjMifQ.eyJpc3MiOiAiaHR0cHM6Ly9hdXRoLmFjbWUuY29tIiwgInN1YiI6ICIxMjM0NSIsICJpYXQiOiAxNzQ5NzI2NjIxLCAiZXhwIjogMTc0OTczMDIyMSwgIm5iZiI6IDE3NDk3MjY2MjF9.",
187+
InvalidAlgorithmError,
188+
'The specified alg value is not allowed',
188189
),
189190
# Success with old Frontend API URL in config (2)
190191
(
@@ -209,7 +210,6 @@ def _generate_jwt(
209210
exp: int,
210211
nbf: int,
211212
valid_key: bool = True,
212-
algorithm: str = "RS256",
213213
) -> str:
214214
payload = {
215215
"iss": iss,
@@ -222,20 +222,11 @@ def _generate_jwt(
222222

223223
key_to_use = cls.private_key if valid_key else cls.invalid_private_key
224224

225-
# unsecured JWT (“none”)
226-
if algorithm.lower() == "none":
227-
# key must be None for alg=none
228-
return encode(
229-
payload,
230-
key=None,
231-
headers={"alg": "none", "typ": "JWT"},
232-
)
233-
234225
# signed JWT (RS256 by default)
235226
return encode(
236227
payload,
237228
key=key_to_use,
238-
algorithm=algorithm,
229+
algorithm="RS256",
239230
headers={"kid": "kid123"},
240231
)
241232

0 commit comments

Comments
 (0)