feat: sincronizar scaffold completo del shape web-backend/python
Sincroniza el scaffold canónico desde templates/web-backend-python/ del repo IDP. Reemplaza el placeholder mínimo previo (.gitea/workflows/ci.yaml, README.md, .gitignore, catalog-info.yaml) por el scaffold completo documentado en ADR-053 §3: - code/ — FastAPI app con /health (db check), /metrics, /demo estático, middleware correlation_id, settings Pydantic, db.py con SQLAlchemy - code/alembic/ — migración inicial vacía + env.py usando MIGRATION_DATABASE_URL - code/tests/ — pytest + httpx TestClient (test_health, test_demo) - helm/APP_NAME/ — chart con Deployment, Service, IngressRoute Traefik, NetworkPolicy, ServiceMonitor, Job alembic-upgrade como hook pre-upgrade,pre-install (backoffLimit: 0) - coralware-shape.yaml — manifiesto v1alpha1 del contrato del shape - claim-mariadb.yaml — AddonClaim declarativo (uso futuro ADR-052) - catalog-info.yaml — entidad Backstage actualizada - .gitea/workflows/APP_NAME-build.yaml — invoca reusable workflow ADR-038 + job helm-deploy con KUBECONFIG_TENANT_B64 Placeholders __APP_NAME__, __TIER__, __TENANT_ID__, __TENANT_ID_NODASHES__ serán sustituidos server-side por repo-provisioner cuando materialice el template para un tenant (pendiente — ADR-053 §11.5). El openspec/ del golden path NO se sincroniza al repo Gitea (gobernanza interna de Coralware). Refs: ADR-052, ADR-053, poc-nexobms.md (PoC NexoBMS Demetrio).
This commit is contained in:
28
code/Dockerfile
Normal file
28
code/Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
# Multi-stage para imagen final lean.
|
||||
# Stage 1: deps — instala dependencias Python en una venv aislada.
|
||||
# Stage 2: runtime — copia código y venv, corre como user no-root con FS read-only.
|
||||
|
||||
FROM python:3.12-slim AS deps
|
||||
WORKDIR /build
|
||||
COPY requirements.txt .
|
||||
RUN python -m venv /venv \
|
||||
&& /venv/bin/pip install --no-cache-dir --upgrade pip \
|
||||
&& /venv/bin/pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
FROM python:3.12-slim AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=deps /venv /venv
|
||||
ENV PATH="/venv/bin:$PATH"
|
||||
|
||||
COPY app /app/app
|
||||
COPY alembic /app/alembic
|
||||
COPY alembic.ini /app/alembic.ini
|
||||
|
||||
RUN useradd -u 1001 -r appuser \
|
||||
&& chown -R appuser:appuser /app
|
||||
USER appuser
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--no-access-log"]
|
||||
44
code/alembic.ini
Normal file
44
code/alembic.ini
Normal file
@@ -0,0 +1,44 @@
|
||||
[alembic]
|
||||
script_location = alembic
|
||||
prepend_sys_path = .
|
||||
file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
||||
|
||||
# La URL real la lee env.py de la variable MIGRATION_DATABASE_URL (o DATABASE_URL).
|
||||
# NO hardcodear aquí.
|
||||
sqlalchemy.url =
|
||||
|
||||
[post_write_hooks]
|
||||
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
||||
57
code/alembic/env.py
Normal file
57
code/alembic/env.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
Alembic env.py — punto de entrada de las migraciones.
|
||||
|
||||
Lee la URL de conexión de MIGRATION_DATABASE_URL (recomendado: user con DDL
|
||||
separado), o de DATABASE_URL como fallback.
|
||||
"""
|
||||
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
from alembic import context
|
||||
from app.settings import settings
|
||||
|
||||
config = context.config
|
||||
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
config.set_main_option("sqlalchemy.url", settings.migration_url)
|
||||
|
||||
# Importar Base y modelos para que --autogenerate los detecte:
|
||||
# from app.models import Base
|
||||
# target_metadata = Base.metadata
|
||||
target_metadata = None
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
"""Genera SQL sin conectar — útil para revisar antes de aplicar."""
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(
|
||||
url=url,
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
"""Aplica migraciones contra la BD real."""
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
with connectable.connect() as connection:
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
25
code/alembic/versions/0001_initial.py
Normal file
25
code/alembic/versions/0001_initial.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""migración inicial — esquema vacío
|
||||
|
||||
Revision ID: 0001_initial
|
||||
Revises:
|
||||
Create Date: 2026-05-04
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa # noqa: F401
|
||||
|
||||
from alembic import op # noqa: F401
|
||||
|
||||
revision = "0001_initial"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Esquema base vacío. Cuando agregues modelos en app/models/, regenera con:
|
||||
# alembic revision --autogenerate -m "agregar tabla X"
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
0
code/app/__init__.py
Normal file
0
code/app/__init__.py
Normal file
40
code/app/db.py
Normal file
40
code/app/db.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
Capa de conexión SQLAlchemy.
|
||||
- engine único por proceso, configurado al startup
|
||||
- sesiones por request (dependency injection FastAPI)
|
||||
- ping ligero para /health
|
||||
"""
|
||||
|
||||
from collections.abc import Iterator
|
||||
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
from app.settings import settings
|
||||
|
||||
engine = create_engine(
|
||||
settings.DATABASE_URL,
|
||||
pool_pre_ping=True,
|
||||
pool_recycle=3600,
|
||||
)
|
||||
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
|
||||
def get_session() -> Iterator[Session]:
|
||||
"""Dependency FastAPI: una sesión por request, cierre garantizado."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def db_alive() -> bool:
|
||||
"""Ping de conexión usado por /health. Retorna False ante cualquier excepción."""
|
||||
try:
|
||||
with engine.connect() as conn:
|
||||
conn.execute(text("SELECT 1"))
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
115
code/app/main.py
Normal file
115
code/app/main.py
Normal file
@@ -0,0 +1,115 @@
|
||||
"""
|
||||
Aplicación FastAPI — entry point.
|
||||
|
||||
Endpoints obligatorios del shape web-backend/python (ver coralware-shape.yaml):
|
||||
- /health → liveness + readiness
|
||||
- /docs → Swagger UI (auth opcional)
|
||||
- /demo → frontend estático servido desde STATIC_DEMO_PATH
|
||||
- /metrics → Prometheus
|
||||
|
||||
Endpoints de dominio: agregar en app/routers/ y registrar en _register_routers().
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
||||
from fastapi.responses import JSONResponse, Response
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from prometheus_client import CONTENT_TYPE_LATEST, generate_latest
|
||||
|
||||
from app.db import db_alive
|
||||
from app.settings import settings
|
||||
|
||||
logging.basicConfig(
|
||||
level=getattr(logging, settings.LOG_LEVEL, logging.INFO),
|
||||
format="%(asctime)s [%(levelname)s] [cid=%(correlation_id)s] %(message)s",
|
||||
datefmt="%Y-%m-%dT%H:%M:%SZ",
|
||||
)
|
||||
|
||||
|
||||
class CorrelationIdFilter(logging.Filter):
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
if not hasattr(record, "correlation_id"):
|
||||
record.correlation_id = "-"
|
||||
return True
|
||||
|
||||
|
||||
logging.getLogger().addFilter(CorrelationIdFilter())
|
||||
log = logging.getLogger("__APP_NAME__")
|
||||
|
||||
|
||||
def _require_auth_dep() -> None:
|
||||
"""
|
||||
Dependency placeholder para /docs cuando OPENAPI_REQUIRE_AUTH=true.
|
||||
Implementación real: validar JWT contra KEYCLOAK_ISSUER (ADR-029 R-004).
|
||||
"""
|
||||
if not settings.OPENAPI_REQUIRE_AUTH:
|
||||
return
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Auth requerido — implementar validación JWT contra Keycloak",
|
||||
)
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(
|
||||
title="__APP_NAME__",
|
||||
version="0.1.0",
|
||||
dependencies=[Depends(_require_auth_dep)] if settings.OPENAPI_REQUIRE_AUTH else [],
|
||||
)
|
||||
|
||||
@app.middleware("http")
|
||||
async def correlation_id_middleware(request: Request, call_next):
|
||||
cid = request.headers.get(settings.CORRELATION_ID_HEADER) or _generate_cid()
|
||||
request.state.correlation_id = cid
|
||||
response = await call_next(request)
|
||||
response.headers[settings.CORRELATION_ID_HEADER] = cid
|
||||
return response
|
||||
|
||||
@app.get("/health", tags=["platform"])
|
||||
async def health() -> JSONResponse:
|
||||
db_status = "up" if db_alive() else "down"
|
||||
code = 200 if db_status == "up" else 503
|
||||
return JSONResponse(
|
||||
status_code=code,
|
||||
content={"status": "ok" if code == 200 else "degraded", "db": db_status},
|
||||
)
|
||||
|
||||
@app.get("/metrics", tags=["platform"])
|
||||
async def metrics() -> Response:
|
||||
return Response(content=generate_latest(), media_type=CONTENT_TYPE_LATEST)
|
||||
|
||||
if os.path.isdir(settings.STATIC_DEMO_PATH):
|
||||
app.mount(
|
||||
"/demo",
|
||||
StaticFiles(directory=settings.STATIC_DEMO_PATH, html=True),
|
||||
name="demo",
|
||||
)
|
||||
else:
|
||||
log.warning(
|
||||
"STATIC_DEMO_PATH=%s no existe — endpoint /demo no será servido",
|
||||
settings.STATIC_DEMO_PATH,
|
||||
)
|
||||
|
||||
_register_routers(app)
|
||||
return app
|
||||
|
||||
|
||||
def _generate_cid() -> str:
|
||||
"""Genera correlation_id si el cliente no envió uno."""
|
||||
import time
|
||||
import uuid
|
||||
|
||||
return f"__APP_NAME__-{int(time.time() * 1000)}-{uuid.uuid4().hex[:8]}"
|
||||
|
||||
|
||||
def _register_routers(app: FastAPI) -> None:
|
||||
"""
|
||||
Registra los routers de dominio.
|
||||
Agrega aquí los include_router(...) conforme tu app crezca.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
app = create_app()
|
||||
8
code/app/models/__init__.py
Normal file
8
code/app/models/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# Modelos SQLAlchemy. Define tu Base aquí y heredala en cada modelo:
|
||||
#
|
||||
# from sqlalchemy.orm import DeclarativeBase
|
||||
# class Base(DeclarativeBase):
|
||||
# pass
|
||||
#
|
||||
# Tras crear modelos, genera la migración con:
|
||||
# alembic revision --autogenerate -m "descripción del cambio"
|
||||
2
code/app/routers/__init__.py
Normal file
2
code/app/routers/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# Routers de dominio. Crea un módulo por agregado (users.py, orders.py, etc.)
|
||||
# y regístralos en app/main.py:_register_routers().
|
||||
32
code/app/settings.py
Normal file
32
code/app/settings.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
Configuración runtime via variables de entorno.
|
||||
Toda la configuración pasa por aquí — no leas env vars dispersos en otros módulos.
|
||||
"""
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=None, case_sensitive=True)
|
||||
|
||||
DATABASE_URL: str = Field(..., description="Connection string runtime de la app")
|
||||
MIGRATION_DATABASE_URL: str = Field(
|
||||
default="",
|
||||
description="Connection string para Alembic; si vacío, usa DATABASE_URL",
|
||||
)
|
||||
|
||||
LOG_LEVEL: str = "INFO"
|
||||
CORRELATION_ID_HEADER: str = "X-Correlation-ID"
|
||||
|
||||
OPENAPI_REQUIRE_AUTH: bool = False
|
||||
KEYCLOAK_ISSUER: str = ""
|
||||
|
||||
STATIC_DEMO_PATH: str = "/app/static/demo"
|
||||
|
||||
@property
|
||||
def migration_url(self) -> str:
|
||||
return self.MIGRATION_DATABASE_URL or self.DATABASE_URL
|
||||
|
||||
|
||||
settings = Settings()
|
||||
41
code/app/static/demo/index.html
Normal file
41
code/app/static/demo/index.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>__APP_NAME__ — demo</title>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; max-width: 720px; margin: 4rem auto; padding: 0 1rem; }
|
||||
code { background: #f4f4f4; padding: 0.15rem 0.4rem; border-radius: 3px; }
|
||||
.status { padding: 0.5rem 1rem; border-radius: 4px; margin-top: 1rem; }
|
||||
.ok { background: #d4edda; color: #155724; }
|
||||
.err { background: #f8d7da; color: #721c24; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>__APP_NAME__</h1>
|
||||
<p>App generada desde el Golden Path <code>web-backend/python</code>.</p>
|
||||
<p>
|
||||
Este es el frontend estático servido en <code>/demo</code>. Modifica
|
||||
<code>code/app/static/demo/</code> para reemplazarlo con tu UI.
|
||||
</p>
|
||||
|
||||
<div id="health-status" class="status">cargando…</div>
|
||||
|
||||
<script>
|
||||
fetch('/health')
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const el = document.getElementById('health-status');
|
||||
const ok = data.status === 'ok';
|
||||
el.className = 'status ' + (ok ? 'ok' : 'err');
|
||||
el.textContent = `Estado: ${data.status} · DB: ${data.db}`;
|
||||
})
|
||||
.catch(err => {
|
||||
const el = document.getElementById('health-status');
|
||||
el.className = 'status err';
|
||||
el.textContent = 'No se pudo contactar a /health';
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
37
code/pyproject.toml
Normal file
37
code/pyproject.toml
Normal file
@@ -0,0 +1,37 @@
|
||||
[project]
|
||||
name = "__APP_NAME__"
|
||||
version = "0.1.0"
|
||||
description = "Web backend Python (FastAPI + Alembic) — Golden Path web-backend/python"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[tool.black]
|
||||
line-length = 100
|
||||
target-version = ["py312"]
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 100
|
||||
target-version = "py312"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "W", "I", "B", "UP", "S"]
|
||||
ignore = ["S101"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/*" = ["S105", "S106"]
|
||||
|
||||
[tool.bandit]
|
||||
exclude_dirs = ["tests", ".venv"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
pythonpath = ["."]
|
||||
testpaths = ["tests"]
|
||||
addopts = "-v --strict-markers"
|
||||
asyncio_mode = "auto"
|
||||
|
||||
[tool.coverage.run]
|
||||
source = ["app"]
|
||||
omit = ["app/__init__.py", "tests/*"]
|
||||
|
||||
[tool.coverage.report]
|
||||
fail_under = 80
|
||||
show_missing = true
|
||||
6
code/requirements-dev.txt
Normal file
6
code/requirements-dev.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
-r requirements.txt
|
||||
-r ../../code/requirements-dev-base.txt
|
||||
|
||||
httpx==0.27.2
|
||||
pytest-asyncio==0.24.0
|
||||
testcontainers[mariadb]==4.8.2
|
||||
10
code/requirements.txt
Normal file
10
code/requirements.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
fastapi==0.115.0
|
||||
uvicorn[standard]==0.32.0
|
||||
pydantic==2.9.2
|
||||
pydantic-settings==2.6.0
|
||||
sqlalchemy==2.0.36
|
||||
alembic==1.13.3
|
||||
pymysql==1.1.1
|
||||
cryptography==43.0.3
|
||||
prometheus-client==0.21.0
|
||||
python-jose[cryptography]==3.3.0
|
||||
0
code/tests/__init__.py
Normal file
0
code/tests/__init__.py
Normal file
34
code/tests/conftest.py
Normal file
34
code/tests/conftest.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
Fixtures para los tests del shape.
|
||||
|
||||
Levanta una MariaDB efímera con testcontainers para que los tests corran
|
||||
contra una BD real (no mocks). El reusable workflow ADR-038 garantiza que
|
||||
Docker está disponible en el runner.
|
||||
"""
|
||||
|
||||
import os
|
||||
from collections.abc import Iterator
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from testcontainers.mariadb import MariaDbContainer
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def mariadb_url() -> Iterator[str]:
|
||||
"""MariaDB efímera por sesión de tests; URL exportada como DATABASE_URL."""
|
||||
with MariaDbContainer("mariadb:11") as mdb:
|
||||
url = mdb.get_connection_url().replace("mysql://", "mysql+pymysql://", 1)
|
||||
os.environ["DATABASE_URL"] = url
|
||||
os.environ["MIGRATION_DATABASE_URL"] = url
|
||||
yield url
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(mariadb_url: str) -> Iterator[TestClient]:
|
||||
"""TestClient con la app cargada contra la BD efímera."""
|
||||
from app.main import create_app
|
||||
|
||||
app = create_app()
|
||||
with TestClient(app) as c:
|
||||
yield c
|
||||
22
code/tests/test_demo.py
Normal file
22
code/tests/test_demo.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Cubre el endpoint /demo: sirve el index estático."""
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_demo_serves_index_html(client: TestClient) -> None:
|
||||
response = client.get("/demo/")
|
||||
assert response.status_code == 200
|
||||
assert "text/html" in response.headers.get("content-type", "")
|
||||
assert "__APP_NAME__" in response.text or "demo" in response.text.lower()
|
||||
|
||||
|
||||
def test_metrics_endpoint_responds(client: TestClient) -> None:
|
||||
response = client.get("/metrics")
|
||||
assert response.status_code == 200
|
||||
assert "text/plain" in response.headers.get("content-type", "")
|
||||
|
||||
|
||||
def test_openapi_accessible_when_auth_disabled(client: TestClient) -> None:
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200
|
||||
spec = response.json()
|
||||
assert spec["info"]["title"] == "__APP_NAME__"
|
||||
30
code/tests/test_health.py
Normal file
30
code/tests/test_health.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Cubre el endpoint /health: respuesta 200 con la BD viva, 503 cuando cae."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_health_db_up_returns_200(client: TestClient) -> None:
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"status": "ok", "db": "up"}
|
||||
|
||||
|
||||
def test_health_db_down_returns_503(client: TestClient) -> None:
|
||||
with patch("app.main.db_alive", return_value=False):
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 503
|
||||
body = response.json()
|
||||
assert body["status"] == "degraded"
|
||||
assert body["db"] == "down"
|
||||
|
||||
|
||||
def test_health_propagates_correlation_id(client: TestClient) -> None:
|
||||
cid = "test-cid-12345"
|
||||
response = client.get("/health", headers={"X-Correlation-ID": cid})
|
||||
assert response.headers.get("X-Correlation-ID") == cid
|
||||
|
||||
|
||||
def test_health_generates_correlation_id_when_absent(client: TestClient) -> None:
|
||||
response = client.get("/health")
|
||||
assert response.headers.get("X-Correlation-ID")
|
||||
Reference in New Issue
Block a user