-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: add search filter to payload list API #3288
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
Changes from all commits
0eb781f
345ec26
48daeb2
0fbfa10
7bb07ce
43520d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||||
| import os | ||||||||||
| import pathlib | ||||||||||
| import tempfile | ||||||||||
| from http import HTTPStatus | ||||||||||
|
|
||||||||||
|
|
@@ -49,6 +50,35 @@ async def test_get_payloads(self, api_v2_client, api_cookies, expected_payload_f | |||||||||
|
|
||||||||||
| assert filtered_payload_file_names == expected_payload_file_names | ||||||||||
|
|
||||||||||
| @pytest.mark.parametrize('query_name', ['payload_', 'PAYLOAD_']) | ||||||||||
| async def test_get_payloads_name_filter(self, api_v2_client, api_cookies, expected_payload_file_names, query_name): | ||||||||||
| resp = await api_v2_client.get(f'/api/v2/payloads?name={query_name}', cookies=api_cookies) | ||||||||||
| assert resp.status == HTTPStatus.OK | ||||||||||
| payload_file_names = await resp.json() | ||||||||||
|
|
||||||||||
| # All expected payloads should be present | ||||||||||
| assert expected_payload_file_names <= set(payload_file_names) | ||||||||||
| # Every returned payload must match the filter (no false positives) | ||||||||||
| assert all('payload_' in pathlib.PurePath(p).name.lower() for p in payload_file_names) | ||||||||||
|
Comment on lines
+61
to
+62
|
||||||||||
| # Every returned payload must match the filter (no false positives) | |
| assert all('payload_' in pathlib.PurePath(p).name.lower() for p in payload_file_names) | |
| # Every returned payload must match the requested filter (no false positives) | |
| assert all(query_name.lower() in pathlib.PurePath(p).name.lower() for p in payload_file_names) |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous test, this assertion hard-codes 'payload_' instead of checking against the actual query value used for the request. Using the request's filter value in the assertion would keep the test aligned with what it's exercising.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpenAPI/apispec response schema for this endpoint is declared as
PayloadSchema(an object with apayloadslist), but the handler returnsweb.json_response(payloads)wherepayloadsis a raw JSON array of strings. This makes the generated API spec inaccurate for clients. Update the response schema to match the actual array response (or wrap the response in the schema shape).