Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add GET /api/v1/identities endpoint #135

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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),
) -> 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,
Expand Down
27 changes: 27 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] == []
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