summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRémy HUBSCHER <hubscher.remy@gmail.com>2021-02-15 17:40:09 +0100
committerGitHub <noreply@github.com>2021-02-15 11:40:09 -0500
commit373d4d8a45ce7071e8677d4835a46bd762fa1210 (patch)
tree540ce87b12e097ae4d62de78c577f65cb28889ef /tests
parentcda3ef147a6e7c12a63b761631b3f169a6827df0 (diff)
downloadpyjwt-373d4d8a45ce7071e8677d4835a46bd762fa1210.tar.gz
Validate claims if configured and verify_signature is not. (#608)
* Validate claims if configured. * Remove secret and algorithm since we don't validate the signature. * Add changelog.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_api_jwt.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py
index f161763..05cb714 100644
--- a/tests/test_api_jwt.py
+++ b/tests/test_api_jwt.py
@@ -579,6 +579,22 @@ class TestJWT:
options={"verify_exp": True},
)
+ def test_decode_with_verify_exp_option_and_signature_off(self, jwt, payload):
+ payload["exp"] = utc_timestamp() - 1
+ secret = "secret"
+ jwt_message = jwt.encode(payload, secret)
+
+ jwt.decode(
+ jwt_message,
+ options={"verify_signature": False},
+ )
+
+ with pytest.raises(ExpiredSignatureError):
+ jwt.decode(
+ jwt_message,
+ options={"verify_signature": False, "verify_exp": True},
+ )
+
def test_decode_with_optional_algorithms(self, jwt, payload):
secret = "secret"
jwt_message = jwt.encode(payload, secret)