# Path: jose/jws.py
# def sign(payload, key, headers=None, algorithm=ALGORITHMS.HS256):
# def verify(token, key, algorithms, verify=True):
# def get_unverified_header(token):
# def get_unverified_headers(token):
# def get_unverified_claims(token):
# def _encode_header(algorithm, additional_headers=None):
# def _encode_payload(payload):
# def _sign_header_and_claims(encoded_header, encoded_claims, algorithm, key):
# def _load(jwt):
# def _sig_matches_keys(keys, signing_input, signature, alg):
# def _get_keys(key):
# def _verify_signature(signing_input, header, signature, key="", algorithms=None):
# 
# Path: jose/jwt.py
# def encode(claims, key, algorithm=ALGORITHMS.HS256, headers=None, access_token=None):
# def decode(token, key, algorithms=None, options=None, audience=None, issuer=None, subject=None, access_token=None):
# def get_unverified_header(token):
# def get_unverified_headers(token):
# def get_unverified_claims(token):
# def _validate_iat(claims):
# def _validate_nbf(claims, leeway=0):
# def _validate_exp(claims, leeway=0):
# def _validate_aud(claims, audience=None):
# def _validate_iss(claims, issuer=None):
# def _validate_sub(claims, subject=None):
# def _validate_jti(claims):
# def _validate_at_hash(claims, access_token, algorithm):
# def _validate_claims(claims, audience=None, issuer=None, subject=None, algorithm=None, access_token=None, options=None):
# 
# Path: jose/exceptions.py
# class JWTError(JOSEError):
#     pass


import base64
import json
import pytest
from datetime import datetime, timedelta
from jose import jws, jwt
from jose.exceptions import JWTError
        from collections import OrderedDict
        from jose.utils import base64url_decode
            (
                "1234567890",
                "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCJ9.aNBlulVhiYSCzvsh1rTzXZC2eWJmNrMBjINT-0wQz4k",
            ),
            (
                "123456789.0",
                "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCJ9.D8WLFPMi3yKgua2jm3BKThFsParXpgxhIbsUc39zJDw",
            ),
        ],
    )
    def test_numeric_key(self, key, token):
        token_info = jwt.decode(token, key)
        assert token_info == {"name": "test"}

    def test_invalid_claims_json(self):
        old_jws_verify = jws.verify
        try:
            token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8"

            def return_invalid_json(token, key, algorithms, verify=True):
                return b'["a", "b"}'

            jws.verify = return_invalid_json

            with pytest.raises(JWTError, match="Invalid payload string: "):
                jwt.decode(token, "secret", ["HS256"])
        finally:
            jws.verify = old_jws_verify

    def test_invalid_claims(self):

# Path: jose/jws.py
# def sign(payload, key, headers=None, algorithm=ALGORITHMS.HS256):
# def verify(token, key, algorithms, verify=True):
# def get_unverified_header(token):
# def get_unverified_headers(token):
# def get_unverified_claims(token):
# def _encode_header(algorithm, additional_headers=None):
# def _encode_payload(payload):
# def _sign_header_and_claims(encoded_header, encoded_claims, algorithm, key):
# def _load(jwt):
# def _sig_matches_keys(keys, signing_input, signature, alg):
# def _get_keys(key):
# def _verify_signature(signing_input, header, signature, key="", algorithms=None):
# 
# Path: jose/jwt.py
# def encode(claims, key, algorithm=ALGORITHMS.HS256, headers=None, access_token=None):
# def decode(token, key, algorithms=None, options=None, audience=None, issuer=None, subject=None, access_token=None):
# def get_unverified_header(token):
# def get_unverified_headers(token):
# def get_unverified_claims(token):
# def _validate_iat(claims):
# def _validate_nbf(claims, leeway=0):
# def _validate_exp(claims, leeway=0):
# def _validate_aud(claims, audience=None):
# def _validate_iss(claims, issuer=None):
# def _validate_sub(claims, subject=None):
# def _validate_jti(claims):
# def _validate_at_hash(claims, access_token, algorithm):
# def _validate_claims(claims, audience=None, issuer=None, subject=None, algorithm=None, access_token=None, options=None):
# 
# Path: jose/exceptions.py
# class JWTError(JOSEError):
#     pass


# Path: tests/test_jwt.py
import base64
import json
import pytest
from datetime import datetime, timedelta
from jose import jws, jwt
from jose.exceptions import JWTError
        from collections import OrderedDict
        from jose.utils import base64url_decode

            (
                "1234567890",
                "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCJ9.aNBlulVhiYSCzvsh1rTzXZC2eWJmNrMBjINT-0wQz4k",
            ),
            (
                "123456789.0",
                "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCJ9.D8WLFPMi3yKgua2jm3BKThFsParXpgxhIbsUc39zJDw",
            ),
        ],
    )
    def test_numeric_key(self, key, token):
        token_info = jwt.decode(token, key)
        assert token_info == {"name": "test"}

    def test_invalid_claims_json(self):
        old_jws_verify = jws.verify
        try:
            token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8"

            def return_invalid_json(token, key, algorithms, verify=True):
                return b'["a", "b"}'

            jws.verify = return_invalid_json

            with pytest.raises(JWTError, match="Invalid payload string: "):
                jwt.decode(token, "secret", ["HS256"])
        finally:
            jws.verify = old_jws_verify

    def test_invalid_claims(self):

        old_jws_verify = jws.verify