Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bjmc committed Jul 18, 2016
1 parent 11ccb5a commit 95fb84a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jose/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def _validate_at_hash(claims, access_token, algorithm):
try:
expected_hash = calculate_at_hash(access_token,
ALGORITHMS.HASHES[algorithm])
except TypeError:
except (TypeError, ValueError):
msg = 'Unable to calculate at_hash to verify against token claims.'
raise JWTClaimsError(msg)

Expand Down
5 changes: 5 additions & 0 deletions tests/test_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ def test_at_hash_missing_claim(self, claims, key):
with pytest.raises(JWTError):
jwt.decode(token, key, access_token='<ACCESS_TOKEN>')

def test_at_hash_unable_to_calculate(self, claims, key):
token = jwt.encode(claims, key, access_token='<ACCESS_TOKEN>')
with pytest.raises(JWTError):
jwt.decode(token, key, access_token='\xe2')

def test_unverified_claims_string(self):
token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.aW52YWxpZCBjbGFpbQ.iOJ5SiNfaNO_pa2J4Umtb3b3zmk5C18-mhTCVNsjnck'
with pytest.raises(JWTError):
Expand Down

0 comments on commit 95fb84a

Please sign in to comment.