rebuild(stage-3): establish accounts permissions and secure settings
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user