rebuild(stage-3): establish accounts permissions and secure settings

This commit is contained in:
leefer
2026-07-30 01:33:19 +08:00
parent 2ff35eb6df
commit f69972c3c0
31 changed files with 2742 additions and 18 deletions
+20
View File
@@ -0,0 +1,20 @@
import pytest
from backend.security import PasswordHasher, PasswordPolicyError
@pytest.mark.parametrize("password", ["onlyletters", "12345678", "short1!"])
def test_password_policy_rejects_weak_values(password: str) -> None:
with pytest.raises(PasswordPolicyError):
PasswordHasher().hash(password)
def test_password_hash_uses_independent_salts_and_verifies() -> None:
hasher = PasswordHasher()
first = hasher.hash("Valid-password-123!")
second = hasher.hash("Valid-password-123!")
assert first != second
assert "Valid-password-123!" not in first
assert hasher.verify("Valid-password-123!", first)
assert not hasher.verify("Wrong-password-123!", first)