Debian Codegraph @

tests/test_jwt.py

raw
1 import jwt
2
3 from .utils import utc_timestamp
4
5
6 def test_encode_decode() -> None:
7 """
8 This test exists primarily to ensure that calls to jwt.encode and
9 jwt.decode don't explode. Most functionality is tested by the PyJWT class
10 tests. This is primarily a sanity check to make sure we don't break the
11 public global functions.
12 """
13 payload = {"iss": "jeff", "exp": utc_timestamp() + 15, "claim": "insanity"}
14
15 secret = "secret"
16 jwt_message = jwt.encode(payload, secret, algorithm="HS256")
17 decoded_payload = jwt.decode(jwt_message, secret, algorithms=["HS256"])
18
19 assert decoded_payload == payload