mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
Add a test for JWT helpers
This commit is contained in:
@@ -26,9 +26,10 @@ ignore_missing_imports = True
|
||||
|
||||
[tool:pytest]
|
||||
addopts = --ignore=test_build.py
|
||||
markers =
|
||||
markers =
|
||||
authentication
|
||||
db
|
||||
fastapi_users
|
||||
jwt
|
||||
oauth
|
||||
router
|
||||
|
||||
15
tests/test_jwt.py
Normal file
15
tests/test_jwt.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import pytest
|
||||
|
||||
from fastapi_users.jwt import SecretType, generate_jwt, decode_jwt
|
||||
|
||||
|
||||
@pytest.mark.jwt
|
||||
def test_generate_decode_jwt(secret: SecretType):
|
||||
audience = "TEST_AUDIENCE"
|
||||
data = {"foo": "bar", "aud": audience}
|
||||
|
||||
jwt = generate_jwt(data, secret, 3600)
|
||||
decoded = decode_jwt(jwt, secret, [audience])
|
||||
|
||||
assert decoded["foo"] == "bar"
|
||||
assert decoded["aud"] == audience
|
||||
Reference in New Issue
Block a user