authentification version0

This commit is contained in:
M.Ayed committed 2026-10-16 16:04:38 +02:00
commit 979f12bc3d
22 files changed
+1639

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
import jwt
from src.auth_project.core.config import settings
from src.auth_project.core.security import (
create_access_token,
hash_password,
verify_password,
)
def test_password_hashing() -> None:
password = "UnMotDePasseLong123!"
hashed = hash_password(password)
assert hashed != password
assert verify_password(password, hashed)
assert not verify_password("MauvaisMotDePasse", hashed)
def test_create_access_token() -> None:
token = create_access_token(user_id=42, role="user")
payload = jwt.decode(
token,
settings.jwt_secret_key,
algorithms=[settings.jwt_algorithm],
)
assert payload["sub"] == "42"
assert payload["role"] == "user"
assert "exp" in payload