Commit 72ce5452 authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

feat(: add test for partner registry handling invalid response schemas

parent 2e4616c6
Loading
Loading
Loading
Loading
Loading
+22 −0
Changes for tests/unit/test_federation_manager_endpoints.py: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -805,6 +805,28 @@ def test_partner_registry_rejects_statuses_fm_does_not_declare(
    )


@pytest.mark.parametrize(("http_method", "path", "body", "status", "fm_body"), _PARTNER_ENDPOINTS)
@pytest.mark.parametrize("bad_body", [b"", b"{}", b"[{}]", b"{not valid json"])
def test_partner_success_body_not_matching_the_response_schema_returns_502(
    client: TestClient,
    fake_fm_client: _FakeFmClient,
    http_method: str,
    path: str,
    body: bytes | None,
    status: int,
    fm_body: bytes,
    bad_body: bytes,
) -> None:
    fake_fm_client.response = httpx.Response(
        status, content=bad_body, headers={"content-type": "application/json"}
    )
    headers = {"content-type": "application/json"} if body else {}

    _assert_bad_response_502(
        client.request(http_method, f"{BASE_PATH}{path}", content=body, headers=headers)
    )


def test_partner_error_without_problem_details_returns_502(
    client: TestClient, fake_fm_client: _FakeFmClient
) -> None: