From 9cb9401cc579f11dbb17181e8713f061f8e40ed4 Mon Sep 17 00:00:00 2001 From: Sriharan Manogaran Date: Sat, 15 Oct 2022 13:17:14 +0530 Subject: Handling 'ImmatureSignatureError' for issued_at time (#794) * Handling 'ImmatureSignatureError' for issued_at time when it is a future time * adding changelog and test cases --- tests/test_api_jwt.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py index bebe7d2..d74973d 100644 --- a/tests/test_api_jwt.py +++ b/tests/test_api_jwt.py @@ -219,6 +219,14 @@ class TestJWT: with pytest.raises(InvalidIssuedAtError): jwt.decode(example_jwt, "secret", algorithms=["HS256"]) + def test_decode_raises_exception_if_iat_is_greater_than_now(self, jwt, payload): + payload["iat"] = utc_timestamp() + 10 + secret = "secret" + jwt_message = jwt.encode(payload, secret) + + with pytest.raises(ImmatureSignatureError): + jwt.decode(jwt_message, secret, algorithms=["HS256"]) + def test_decode_raises_exception_if_nbf_is_not_int(self, jwt): # >>> jwt.encode({'nbf': 'not-an-int'}, 'secret') example_jwt = ( -- cgit v1.2.1