Skip to content

Commit 95fb84a

Browse files
committed
Improve test coverage
1 parent 11ccb5a commit 95fb84a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

jose/jwt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def _validate_at_hash(claims, access_token, algorithm):
425425
try:
426426
expected_hash = calculate_at_hash(access_token,
427427
ALGORITHMS.HASHES[algorithm])
428-
except TypeError:
428+
except (TypeError, ValueError):
429429
msg = 'Unable to calculate at_hash to verify against token claims.'
430430
raise JWTClaimsError(msg)
431431

tests/test_jwt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ def test_at_hash_missing_claim(self, claims, key):
449449
with pytest.raises(JWTError):
450450
jwt.decode(token, key, access_token='<ACCESS_TOKEN>')
451451

452+
def test_at_hash_unable_to_calculate(self, claims, key):
453+
token = jwt.encode(claims, key, access_token='<ACCESS_TOKEN>')
454+
with pytest.raises(JWTError):
455+
jwt.decode(token, key, access_token='\xe2')
456+
452457
def test_unverified_claims_string(self):
453458
token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.aW52YWxpZCBjbGFpbQ.iOJ5SiNfaNO_pa2J4Umtb3b3zmk5C18-mhTCVNsjnck'
454459
with pytest.raises(JWTError):

0 commit comments

Comments
 (0)