test(proxy): clear failed-login TTLs when resetting the throttle between tests
Some checks failed
LiteLLM Rust / rustfmt, clippy, test (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled

This commit is contained in:
Yucheng Zhu 2026-08-26 10:24:32 -07:00
parent 52f3ff13f0
commit a39efb1a1d

View file

@ -527,10 +527,17 @@ def reset_login_throttle(monkeypatch):
def _drop_throttle_keys() -> None:
in_memory = getattr(_FAILED_LOGIN_CACHE, "in_memory_cache", None)
cache_dict = getattr(in_memory, "cache_dict", None)
if isinstance(cache_dict, dict):
for key in [k for k in cache_dict if str(k).startswith(_CACHE_KEY_PREFIX)]:
cache_dict.pop(key, None)
if in_memory is None:
return
tracked = tuple(
key
for store in (getattr(in_memory, "cache_dict", None), getattr(in_memory, "ttl_dict", None))
if isinstance(store, dict)
for key in tuple(store)
if str(key).startswith(_CACHE_KEY_PREFIX)
)
for key in tracked:
in_memory.delete_cache(key)
monkeypatch.setattr(ps, "redis_usage_cache", None)
_drop_throttle_keys()