18 lines
508 B
Python
18 lines
508 B
Python
from __future__ import annotations
|
|
|
|
from services.common.auth import create_token, decode_token, hash_password, verify_password
|
|
|
|
|
|
def test_password_hash_roundtrip() -> None:
|
|
secret = "dragon"
|
|
hashed = hash_password(secret)
|
|
assert verify_password(secret, hashed)
|
|
assert not verify_password("wrong", hashed)
|
|
|
|
|
|
def test_token_roundtrip() -> None:
|
|
token = create_token(42, "alice")
|
|
payload = decode_token(token)
|
|
assert payload["sub"] == "42"
|
|
assert payload["username"] == "alice"
|