Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/edge_proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
):
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,
Expand Down
24 changes: 24 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,27 @@ 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):
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"] == []
Comment on lines +287 to +288
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add an assert on the flags here as well.

Loading