remove legacy in-memory search state fallback

This commit is contained in:
Justin Visser 2026-02-19 22:31:26 +01:00
parent d7404abf18
commit 1ce85304e3
17 changed files with 766 additions and 248 deletions

View file

@ -32,3 +32,22 @@ def test_rate_limiter_enforces_windowed_attempt_budget() -> None:
clock["now"] = 11.0
assert limiter.check(key).allowed
def test_rate_limiter_check_does_not_create_or_retain_empty_keys() -> None:
clock = {"now": 0.0}
limiter = SlidingWindowRateLimiter(
max_attempts=2,
window_seconds=10,
now=lambda: clock["now"],
)
key = "127.0.0.1:never-failed@example.com"
assert limiter.check(key).allowed
assert key not in limiter._attempts
limiter.record_failure(key)
assert key in limiter._attempts
clock["now"] = 11.0
assert limiter.check(key).allowed
assert key not in limiter._attempts