forked from mtusi2026/mtusi2026lab7
fix(auth): reject excess login concurrency before Argon2 work
This commit is contained in:
@@ -216,3 +216,28 @@ def test_operator_token_cache_is_invalidated_when_client_certificate_changes(
|
||||
assert len(calls) == 1
|
||||
finally:
|
||||
second.close()
|
||||
|
||||
|
||||
def test_busy_login_is_rejected_before_password_verification(monkeypatch):
|
||||
from src.password import Passwords
|
||||
|
||||
passwords = Passwords()
|
||||
calls = []
|
||||
from types import SimpleNamespace
|
||||
|
||||
monkeypatch.setattr(
|
||||
passwords,
|
||||
"hasher",
|
||||
SimpleNamespace(verify=lambda *args: calls.append(args)),
|
||||
)
|
||||
assert passwords.slots.acquire(blocking=False)
|
||||
assert passwords.slots.acquire(blocking=False)
|
||||
try:
|
||||
with pytest.raises(DomainError) as rejected:
|
||||
passwords.verify(password="Synthetic-password", encoded=None)
|
||||
assert rejected.value.status == 429
|
||||
assert rejected.value.headers["Retry-After"] == "1"
|
||||
assert not calls
|
||||
finally:
|
||||
passwords.slots.release()
|
||||
passwords.slots.release()
|
||||
|
||||
Reference in New Issue
Block a user