MCPcopy
hub / github.com/authlib/authlib / test_authenticate_token

Function test_authenticate_token

tests/core/test_oauth2/test_rfc7523_validator.py:31–45  ·  view source on GitHub ↗
(oct_key)

Source from the content-addressed store, hash-verified

29
30
31def test_authenticate_token(oct_key):
32 validator = JWTBearerTokenValidator(oct_key, issuer="foo")
33 claims = {
34 "iss": "bar",
35 "exp": int(time.time() + 3600),
36 "client_id": "client-id",
37 "grant_type": "client_credentials",
38 }
39 token_string = jwt.encode({"alg": "HS256"}, claims, oct_key)
40 token = validator.authenticate_token(token_string)
41 assert token is None
42
43 token_string = jwt.encode({"alg": "HS256"}, {**claims, "iss": "foo"}, oct_key)
44 token = validator.authenticate_token(token_string)
45 assert token is not None
46
47
48def test_expired_token(oct_key):

Callers

nothing calls this directly

Calls 3

authenticate_tokenMethod · 0.95
encodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…