Skip to content

Commit

Permalink
Test jwt.get_unverified_claims()
Browse files Browse the repository at this point in the history
Make sure claims of type `str` and `list` raise an error while JSON
objects pass through.
  • Loading branch information
0x64746b committed Apr 27, 2016
1 parent 00c51d7 commit 4545536
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,17 @@ def test_jti_invalid(self, key):
token = jwt.encode(claims, key)
with pytest.raises(JWTError):
jwt.decode(token, key)

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

def test_unverified_claims_list(self):
token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.WyJpbnZhbGlkIiwgImNsYWltcyJd.nZvw_Rt1FfUPb5OiVbrSYZGtWSE5c-gdJ6nQnTTBkYo'
with pytest.raises(JWTError):
jwt.get_unverified_claims(token)

def test_unverified_claims_object(self, claims, key):
token = jwt.encode(claims, key)
assert jwt.get_unverified_claims(token) == claims

0 comments on commit 4545536

Please sign in to comment.