Skip to content

Commit 4545536

Browse files
committed
Test jwt.get_unverified_claims()
Make sure claims of type `str` and `list` raise an error while JSON objects pass through.
1 parent 00c51d7 commit 4545536

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_jwt.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,17 @@ def test_jti_invalid(self, key):
402402
token = jwt.encode(claims, key)
403403
with pytest.raises(JWTError):
404404
jwt.decode(token, key)
405+
406+
def test_unverified_claims_string(self):
407+
token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.aW52YWxpZCBjbGFpbQ.iOJ5SiNfaNO_pa2J4Umtb3b3zmk5C18-mhTCVNsjnck'
408+
with pytest.raises(JWTError):
409+
jwt.get_unverified_claims(token)
410+
411+
def test_unverified_claims_list(self):
412+
token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.WyJpbnZhbGlkIiwgImNsYWltcyJd.nZvw_Rt1FfUPb5OiVbrSYZGtWSE5c-gdJ6nQnTTBkYo'
413+
with pytest.raises(JWTError):
414+
jwt.get_unverified_claims(token)
415+
416+
def test_unverified_claims_object(self, claims, key):
417+
token = jwt.encode(claims, key)
418+
assert jwt.get_unverified_claims(token) == claims

0 commit comments

Comments
 (0)