File: test_jwt.py

package info (click to toggle)
pyjwt 2.10.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 708 kB
  • sloc: python: 4,592; makefile: 141
file content (19 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import jwt

from .utils import utc_timestamp


def test_encode_decode():
    """
    This test exists primarily to ensure that calls to jwt.encode and
    jwt.decode don't explode. Most functionality is tested by the PyJWT class
    tests. This is primarily a sanity check to make sure we don't break the
    public global functions.
    """
    payload = {"iss": "jeff", "exp": utc_timestamp() + 15, "claim": "insanity"}

    secret = "secret"
    jwt_message = jwt.encode(payload, secret, algorithm="HS256")
    decoded_payload = jwt.decode(jwt_message, secret, algorithms=["HS256"])

    assert decoded_payload == payload