fix: Redis-Lockout-Keys in Test-Setup bereinigen
Login/PIN/TOTP-Lockout- und burned_token-Keys aus vorherigen Test-Runs werden beim Session-Setup gelöscht, damit Tests nicht durch Zustand aus früheren Runs fehlschlagen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,17 @@ async def _apply_rls(conn) -> None:
|
|||||||
|
|
||||||
@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)
|
@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)
|
||||||
async def setup_db():
|
async def setup_db():
|
||||||
|
# Redis-Test-Keys bereinigen (Login/PIN/TOTP-Lockouts von vorherigen Runs)
|
||||||
|
import redis.asyncio as aioredis
|
||||||
|
from app.core.config import settings
|
||||||
|
async with aioredis.from_url(settings.redis_url) as r:
|
||||||
|
patterns = ["login_fails:*", "login_lockout:*", "pin_fails:*", "pin_lockout:*",
|
||||||
|
"totp_fails:*", "totp_lockout:*", "burned_token:*"]
|
||||||
|
for pattern in patterns:
|
||||||
|
keys = await r.keys(pattern)
|
||||||
|
if keys:
|
||||||
|
await r.delete(*keys)
|
||||||
|
|
||||||
async with test_engine.begin() as conn:
|
async with test_engine.begin() as conn:
|
||||||
# Schema komplett neu anlegen – löst circular dependency departments↔users
|
# Schema komplett neu anlegen – löst circular dependency departments↔users
|
||||||
await conn.execute(text("DROP SCHEMA public CASCADE"))
|
await conn.execute(text("DROP SCHEMA public CASCADE"))
|
||||||
|
|||||||
Reference in New Issue
Block a user