Commit 441def16 authored by George Papathanail's avatar George Papathanail
Browse files

fix(fm): make availableZoneNotifLink optional in ZoneSubscribe body

parent eb1a3b45
Loading
Loading
Loading
Loading
Loading
+6 −2
Changes for src/open_exposure_gateway/api/gsma/federation_manager/v1_4_0/schemas.py: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -353,10 +353,14 @@ class ZoneRegisteredData(BaseModel):


class ZoneRegistrationRequestData(BaseModel):
    """Body of ``ZoneSubscribe``."""
    """Body of ``ZoneSubscribe``.

    v1.4.0 requires only ``acceptedAvailabilityZones``; FM fills in its own
    ``availZoneNotifLink`` when the caller omits it.
    """

    acceptedAvailabilityZones: Annotated[list[ZoneIdentifier], Field(min_length=1)]
    availZoneNotifLink: Uri
    availZoneNotifLink: Optional[Uri] = None


class ZoneRegistrationResponseData(BaseModel):
+16 −0
Changes for tests/unit/test_federation_manager_endpoints.py: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -354,6 +354,22 @@ def test_wrong_shape_zone_subscribe_body_returns_problem_details_400(
    assert fake_fm_client.calls == []


def test_zone_subscribe_body_without_notif_link_is_forwarded(
    client: TestClient, fake_fm_client: _FakeFmClient
) -> None:
    """v1.4.0 requires only acceptedAvailabilityZones; FM fills in availZoneNotifLink."""
    body = b'{"acceptedAvailabilityZones": ["zone-a"]}'
    fake_fm_client.response = _fm_ok(_ZONE_REGISTRATION_RESPONSE)
    response = client.post(
        f"{BASE_PATH}{_FEDERATIONS}/{_CTX}/zones",
        content=body,
        headers={"content-type": "application/json"},
    )

    assert response.status_code == 200
    assert fake_fm_client.calls[0]["content"] == body


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