"""Tests for the health check router.""" import pytest from httpx import AsyncClient @pytest.mark.asyncio async def test_health_check_returns_200(client: AsyncClient) -> None: """``GET /api/health`` must return HTTP 200.""" response = await client.get("/api/health") assert response.status_code == 200 @pytest.mark.asyncio async def test_health_check_returns_ok_status(client: AsyncClient) -> None: """``GET /api/health`` must contain ``status: ok`` and a ``fail2ban`` field.""" response = await client.get("/api/health") data: dict[str, str] = response.json() assert data["status"] == "ok" assert data["fail2ban"] in ("online", "offline") @pytest.mark.asyncio async def test_health_check_content_type_is_json(client: AsyncClient) -> None: """``GET /api/health`` must set the ``Content-Type`` header to JSON.""" response = await client.get("/api/health") assert "application/json" in response.headers.get("content-type", "")