from app.main import app
from fastapi.testclient import TestClient


def test_liveness_is_minimal_and_correlated():
    response = TestClient(app).get("/health", headers={"x-request-id": "test-request"})
    assert response.status_code == 200
    assert response.json() == {"status": "ok", "service": "core-api"}
    assert response.headers["x-request-id"] == "test-request"


def test_untrusted_request_id_is_replaced_before_it_reaches_audit_or_logs():
    response = TestClient(app).get("/health", headers={"x-request-id": "x" * 81})
    assert response.status_code == 200
    assert response.headers["x-request-id"] != "x" * 81
    assert len(response.headers["x-request-id"]) == 36
