Skip to content
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
4 changes: 4 additions & 0 deletions campus_python/audit/v1/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def search(
api_key_id: "str | None" = None,
client_id: "str | None" = None,
user_id: "str | None" = None,
journey_id: "str | None" = None,
since: "str | None" = None,
until: "str | None" = None,
limit: "int | None" = None,
Expand All @@ -105,6 +106,7 @@ def search(
api_key_id: Filter by audit API key
client_id: Filter by OAuth client
user_id: Filter by user
journey_id: Filter by login-journey tag (campus#803)
since, until, limit, cursor: As in list()

Returns:
Expand All @@ -121,6 +123,8 @@ def search(
query["client_id"] = client_id
if user_id is not None:
query["user_id"] = user_id
if journey_id is not None:
query["journey_id"] = journey_id
if since is not None:
query["since"] = since
if until is not None:
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ def test_search_gets_leaf_route_with_filters(self):
query={"path": "/api/v1/timetable/", "status": 404},
)

def test_search_sends_journey_id_when_given(self):
# journey_id rides as a query param like the other optional
# filters (#110); the exact-dict assertion above covers its
# omission when not passed.
self.client.get.return_value.json.return_value = {
"traces": [], "cursor": {"next": None, "has_more": False}
}
self.audit.traces.search(journey_id="uid-journey-abc123")
self.client.get.assert_called_once_with(
"/audit/v1/traces/search",
query={"journey_id": "uid-journey-abc123"},
)

def test_trace_get_returns_tree_envelope(self):
self.client.get.return_value.json.return_value = {
"trace_id": "a" * 32,
Expand Down
Loading