Merge pull request #697 from christianlouis/test-api-tokens-hash-token-18108337743020909528

🧪 Add unit test for hash_token function
This commit is contained in:
Christian Krakau-Louis
2026-03-16 10:58:44 +01:00
committed by GitHub
+10
View File
@@ -667,3 +667,13 @@ class TestTokenUtils:
# All characters should be valid lowercase hex digits.
int(h, 16)
assert h == h.lower()
@pytest.mark.unit
def test_hash_token_known_value(self):
"""hash_token should return the exact expected PBKDF2 digest for a known input."""
from app.api.api_tokens import hash_token
# PBKDF2-HMAC-SHA256 with 100,000 iterations and salt b"api-token-v1"
token = "de_test_token_value"
expected_hash = "9b89d9adf2f390c75bf2fd0ff2bb5622ef5a9dce438354cce6e39f2f5401129e"
assert hash_token(token) == expected_hash