Skip to content

Commit

Permalink
Add GET /api/v1/identities endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rolodato committed Dec 13, 2024
1 parent fc8534b commit e0212fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/edge_proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ async def identity(
data = environment_service.get_identity_response_data(input_data, x_environment_key)
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(
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"] == []

0 comments on commit e0212fe

Please sign in to comment.