27 lines
702 B
Python
27 lines
702 B
Python
from app.core.security import (
|
|
create_access_token,
|
|
decode_access_token,
|
|
generate_refresh_token,
|
|
hash_password,
|
|
hash_refresh_token,
|
|
verify_password,
|
|
)
|
|
|
|
|
|
def test_password_hashing_roundtrip():
|
|
hashed = hash_password("Strong123")
|
|
assert verify_password("Strong123", hashed) is True
|
|
|
|
|
|
def test_access_token_encode_decode():
|
|
token = create_access_token("u1", "user", False)
|
|
payload = decode_access_token(token)
|
|
assert payload["sub"] == "u1"
|
|
assert payload["role"] == "user"
|
|
assert payload["is_superuser"] is False
|
|
|
|
|
|
def test_refresh_token_hashing():
|
|
token = generate_refresh_token()
|
|
assert hash_refresh_token(token) == hash_refresh_token(token)
|