From 2a46cb7943074826384e0a12334ffe3ffaa9e9e6 Mon Sep 17 00:00:00 2001 From: MaximIgitov Date: Sat, 31 Jan 2026 04:12:12 +0000 Subject: [PATCH 1/2] Add healthz endpoint and CORS tests --- backend/app/main.py | 5 +++++ backend/tests/api/routes/test_healthz.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 backend/tests/api/routes/test_healthz.py diff --git a/backend/app/main.py b/backend/app/main.py index 9a95801e74..20c147ed61 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -20,6 +20,11 @@ def custom_generate_unique_id(route: APIRoute) -> str: generate_unique_id_function=custom_generate_unique_id, ) +@app.get("/healthz", include_in_schema=False) +def healthz() -> dict[str, str]: + return {"status": "ok"} + + # Set all CORS enabled origins if settings.all_cors_origins: app.add_middleware( diff --git a/backend/tests/api/routes/test_healthz.py b/backend/tests/api/routes/test_healthz.py new file mode 100644 index 0000000000..d15feeec6f --- /dev/null +++ b/backend/tests/api/routes/test_healthz.py @@ -0,0 +1,19 @@ +from fastapi.testclient import TestClient + +from app.core.config import settings + + +def test_healthz(client: TestClient) -> None: + response = client.get("/healthz") + assert response.status_code == 200 + assert response.json() == {"status": "ok"} + + +def test_cors_allows_configured_origin(client: TestClient) -> None: + response = client.get("/healthz", headers={"Origin": settings.FRONTEND_HOST}) + assert response.headers.get("access-control-allow-origin") == settings.FRONTEND_HOST + + +def test_cors_blocks_unknown_origin(client: TestClient) -> None: + response = client.get("/healthz", headers={"Origin": "https://unknown.example"}) + assert "access-control-allow-origin" not in response.headers From 1b0203f660b2f362dbedf116a014c4c5bb2711af Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 31 Jan 2026 04:12:54 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format=20and=20update?= =?UTF-8?q?=20with=20pre-commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/app/main.py b/backend/app/main.py index 20c147ed61..9fd1422395 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -20,6 +20,7 @@ def custom_generate_unique_id(route: APIRoute) -> str: generate_unique_id_function=custom_generate_unique_id, ) + @app.get("/healthz", include_in_schema=False) def healthz() -> dict[str, str]: return {"status": "ok"}