Stabilize runtime auth and E2E coverage
This commit is contained in:
parent
6a3e3b541c
commit
188e899394
133 changed files with 55987 additions and 6775 deletions
33
apps/api/app/runtime_policy.py
Normal file
33
apps/api/app/runtime_policy.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
"""Runtime fallback policy shared by auth/session routes.
|
||||
|
||||
The in-process stores exist only to keep local development usable when Docker or
|
||||
NAS PostgreSQL is offline. Staging/prod must fail loudly instead of becoming a
|
||||
second source of truth.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import NoReturn
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from .config import settings
|
||||
|
||||
|
||||
def runtime_fallback_allowed() -> bool:
|
||||
return settings.environment == "dev"
|
||||
|
||||
|
||||
def raise_runtime_fallback_disabled(feature: str) -> NoReturn:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail=(
|
||||
f"{feature} persistence unavailable; runtime fallback is disabled "
|
||||
f"in {settings.environment}"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def require_runtime_fallback_allowed(feature: str) -> None:
|
||||
if not runtime_fallback_allowed():
|
||||
raise_runtime_fallback_disabled(feature)
|
||||
Loading…
Add table
Add a link
Reference in a new issue