SumakaClone / backend /tests /unit /test_security.py
raghava0450's picture
Deploy SumakaClone Space configuration
92d8b0d verified
Raw
History Blame Contribute Delete
734 Bytes
from datetime import timedelta
from app.configs.settings import Settings
from app.utils.security import create_token, decode_token, hash_password, verify_password
def test_password_hash_round_trip() -> None:
password = "super-secret-password"
hashed = hash_password(password)
assert hashed != password
assert verify_password(password, hashed) is True
def test_token_round_trip() -> None:
settings = Settings(security={"jwt_secret": "unit-test-secret"})
token = create_token(settings, subject="user-1", token_type="access", expires_delta=timedelta(minutes=5))
claims = decode_token(settings, token, expected_type="access")
assert claims["sub"] == "user-1"
assert claims["type"] == "access"