diff --git a/api/src/bracc/main.py b/api/src/bracc/main.py index cdaf4a2..b875f24 100644 --- a/api/src/bracc/main.py +++ b/api/src/bracc/main.py @@ -2,7 +2,7 @@ import logging from collections.abc import AsyncIterator from contextlib import asynccontextmanager -from fastapi import FastAPI +from fastapi import FastAPI, Request from fastapi.middleware.cors import CORSMiddleware from slowapi import _rate_limit_exceeded_handler from slowapi.errors import RateLimitExceeded @@ -85,5 +85,5 @@ app.include_router(investigation.shared_router) @app.get("/health") -async def health() -> dict[str, str]: - return {"status": "ok"} +async def health(request: Request) -> dict[str, str]: + return {"status": "ok", "version": request.app.version} diff --git a/api/tests/unit/test_cpf_masking.py b/api/tests/unit/test_cpf_masking.py index 29ed41e..271df24 100644 --- a/api/tests/unit/test_cpf_masking.py +++ b/api/tests/unit/test_cpf_masking.py @@ -205,4 +205,4 @@ async def test_health_not_masked(client: AsyncClient) -> None: """Non-CPF JSON responses pass through unchanged.""" resp = await client.get("/health") assert resp.status_code == 200 - assert resp.json() == {"status": "ok"} + assert resp.json()["status"] == "ok" and "version" in resp.json() diff --git a/api/tests/unit/test_health.py b/api/tests/unit/test_health.py index 320e27b..d250005 100644 --- a/api/tests/unit/test_health.py +++ b/api/tests/unit/test_health.py @@ -8,7 +8,9 @@ from httpx import AsyncClient async def test_health_returns_ok(client: AsyncClient) -> None: response = await client.get("/health") assert response.status_code == 200 - assert response.json() == {"status": "ok"} + data = response.json() + assert data["status"] == "ok" + assert "version" in data assert response.headers["x-content-type-options"] == "nosniff" assert response.headers["x-frame-options"] == "DENY" assert response.headers["referrer-policy"] == "no-referrer"