diff --git a/src/edge_proxy/server.py b/src/edge_proxy/server.py index 1413417..0d26b85 100644 --- a/src/edge_proxy/server.py +++ b/src/edge_proxy/server.py @@ -92,6 +92,17 @@ async def identity( return ORJSONResponse(data) +@app.get("/api/v1/identities/", response_class=ORJSONResponse) +async def get_identities( + identifier: str, + x_environment_key: str = Header(None), +) -> ORJSONResponse: + data = environment_service.get_identity_response_data( + IdentityWithTraits(identifier=identifier), x_environment_key + ) + return ORJSONResponse(data) + + @app.on_event("startup") @repeat_every( seconds=settings.api_poll_frequency_seconds, diff --git a/tests/test_server.py b/tests/test_server.py index 9bf7ea1..3e6c6ff 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -259,3 +259,30 @@ def test_post_identity__invalid_trait_data__expected_response( "constrained-str", ] assert response.json()["detail"][-1]["type"] == "string_too_long" + + +def test_get_identities( + mocker: MockerFixture, + client: TestClient, +) -> None: + x_environment_key = "test_environment_key" + identifier = "test_identifier" + + mocked_environment_cache = mocker.patch( + "edge_proxy.server.environment_service.cache" + ) + mocked_environment_cache.get_environment.return_value = environment_1 + mocked_environment_cache.get_identity.return_value = { + "environment_api_key": x_environment_key, + "identifier": identifier, + } + + response = client.get( + "/api/v1/identities/", + headers={"x-environment-key": x_environment_key}, + params={"identifier": identifier}, + ) + data = response.json() + + assert response.status_code == 200 + assert data["traits"] == []