
== credentials and anonymous requests
PASS: wrong password -> 401 with Basic challenge
PASS: unknown user -> 401
PASS: no Authorization -> 401 with Bearer challenge
PASS: X-User-Id alone gives no access
PASS: Basic is not accepted on business endpoints
PASS: unknown Bearer token -> 401

== logout and Valkey session cache
PASS: no cache entry before first use
PASS: fresh token works (cache miss -> PostgreSQL)
PASS: session is cached in Valkey under sha256(token)
PASS: second request works (cache hit)
PASS: logout -> 204
PASS: revoked token -> 401 right after logout
PASS: revoked token stays 401 (cache tombstone)
PASS: second logout with same token -> 401
PASS: another session of the user is unaffected

== expiry with SESSION_TTL_SECONDS=3 (api_short_ttl)
PASS: login on short-TTL instance
PASS: token valid before expiry (now cached)
PASS: token rejected after expiry, cache too
PASS: logout of expired token -> 401

== registration race: 20 parallel requests, one username
statuses: {201: 1, 409: 19}
PASS: exactly one registration wins
PASS: all others get 409, no 500

== Valkey stop: cache is bypassed, PostgreSQL decides
PASS: token cached before outage
PASS: login works without Valkey
PASS: Bearer request works without Valkey
PASS: write works without Valkey
PASS: forged token still 401 without Valkey
PASS: anonymous still 401 without Valkey
PASS: logout works without Valkey
PASS: token revoked during outage -> 401
PASS: bounded latency during outage (max 0.26s)
PASS: token revoked during outage stays 401 after Valkey returns (stale cache flushed)
PASS: live session works after recovery

== Valkey pause: cache is bypassed, PostgreSQL decides
PASS: token cached before outage
PASS: login works without Valkey
PASS: Bearer request works without Valkey
PASS: write works without Valkey
PASS: forged token still 401 without Valkey
PASS: anonymous still 401 without Valkey
PASS: logout works without Valkey
PASS: token revoked during outage -> 401
PASS: bounded latency during outage (max 0.26s)
PASS: token revoked during outage stays 401 after Valkey returns (stale cache flushed)
PASS: live session works after recovery

== logout while Valkey hangs, API restart, Valkey returns
PASS: token cached before outage
PASS: positive cache entry exists in Valkey
PASS: logout committed in PostgreSQL, tombstone not written
PASS: API restarted while Valkey is unreachable
PASS: revoked token -> 401 after API restart (got 401)
PASS: revoked token cannot send messages (got 401)

== PostgreSQL stop: limited 503, anonymous is never trusted
PASS: token cached before outage
PASS: write -> 503 unavailable with request id (3.01s)
PASS: 503 is returned within the configured timeouts
PASS: /health/ready -> 503
PASS: /health/live -> 200
PASS: login -> 503
PASS: anonymous -> 401 without touching the DB
PASS: unverifiable token -> 503, never 2xx
PASS: X-User-Id -> 401 during outage
PASS: cached valid session still identifies the user
PASS: API ready again after PostgreSQL start
PASS: writes work again with the old session

PASS: level 4 checks
