fix(tests): stop unconditionally mocking require_api_key in saved-views tests - #2193
fix(tests): stop unconditionally mocking require_api_key in saved-views tests#2193Subramaniyajothi6 wants to merge 955 commits into
Conversation
…tksh1#1547) * Resolves issue-utksh1#1413 * test: remove trailing whitespace
…1546) Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
…h1#1542) Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
…ksh1#1527) * Resolves issue-utksh1#1427 * Removes white spaces.
…odule (utksh1#1524) The extract_target helper in executor.py is a pure function but lives in a heavy import chain (FastAPI, cache, config). Per the maintainer's approved extraction pattern (used for routes_json_helpers), this extracts extract_target into a small import-safe executor_target_helpers module and re-exports it from executor.py so existing call sites keep working. Closes utksh1#1389. Co-authored-by: tmdeveloper007 <[email protected]>
…1520) * Resolves issue-utksh1#1425 * Removed white spaces.
Co-authored-by: Tomeshwari-02 <[email protected]>
…ile, and workflow endpoints (utksh1#1557)
…h1#1563) Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
Co-authored-by: tmdeveloper007 <[email protected]>
* fix: stop dashboard polling after health failure and add manual retry * fix: skip pre-existing upstream auth tests that cannot pass with mocked auth * fix: update postcss to resolve GHSA-r28c-9q8g-f849 high severity vulnerability * fix: document localhost-only Docker binding, add opt-in network override
9755d3f to
663cc7a
Compare
|
Rebased onto current Why the extra commit is needed
@pytest.mark.skip(reason="pre-existing upstream issue: app_client overrides auth so 401 cannot be tested here")That reason is accurate about the cause — the Merging as-is would have kept them. Simulating the merge against current So the PR would have gone green, closed #2192, and left both auth tests skipped on Verification (rebased branch,
On the issue title: worth noting there was never a live auth bypass. Diff is still one file: |
* Fix risk scoring defaults * Update risk scoring tests
…low runs (utksh1#2396) POST /workflows/{id}/run and WorkflowScheduler._run_workflow now apply the same exploit-validation gate as start_task: exploit-level plugins and validation_mode=CONTROLLED_EXTRACT steps require a target policy with allow_exploit_validation=True, otherwise the step is skipped with a warning. Fixes utksh1#2395
…h1#2367) Closes utksh1#1845 Escape was a no-op outside text fields. useShortcuts had: if (e.key === 'Escape') { // Could emit global event to close modals return } so nothing was ever emitted and no popover had anything to listen for. useShortcuts now broadcasts a CustomEvent, and useEscapeToClose is the subscriber side. Keeping the single window-level keydown listener in useShortcuts and fanning out via one event means the listener count does not grow with the number of overlays on a page, and every overlay closes the same way. Wired into both affected surfaces. The Saved Views panel is the one named in the issue; the bulk-export dropdown on the Findings page had the same problem and is fixed with it. useEscapeToClose only subscribes while its overlay is open, so a closed popover neither reacts nor keeps a listener alive. Escape while typing keeps its existing behaviour: useShortcuts blurs the focused field and returns without broadcasting. A field inside a panel therefore takes two presses — one to leave the field, one to close the panel — so a stray Escape mid-typing cannot discard what was being entered. That is pinned by a test rather than left implicit. Verified by mutation: dropping the broadcast fails the useShortcuts test, and dropping the subscriber fails the SavedViewsPanel test.
* Add retry support for notification delivery * Remove trailing whitespace
Co-authored-by: Soujanya S H <[email protected]>
utksh1
left a comment
There was a problem hiding this comment.
Reviewed the updated test fixture and auth coverage. Removing the unconditional dependency override allows the unauthenticated and invalid-key tests to exercise the real router dependency, and the added commit removes the skips introduced on main. The branch still needs a fresh rebase and required checks before merge.
663cc7a to
fa68e3f
Compare
|
Fresh required CI is blocked at the shared frontend npm audit gate by high-severity undici advisory GHSA-4cwx-7wf7-3272. This PR is backend-test-only and does not change frontend dependencies; approval remains in place while the repository-level audit issue is unresolved. |
* test: add unit tests for _validate_lengths field length guard Covers valid/boundary/over-limit cases for name, description, and notes fields, plus custom resource_type substitution and None handling for optional fields. Closes utksh1#2307. * fix: bump undici to patch high-severity vulnerability (GHSA-8xcm-r25x-g524 and related)
…ws tests The app_client fixture overrode require_api_key with a mock that always succeeds, regardless of the X-Api-Key header. That made the fixture's own negative-path tests (test_unauthenticated_request_rejected, test_wrong_api_key_rejected) always observe a 200, since the real auth check never ran. The fixture already issues a real API key and sends it via X-Api-Key, so the mock was redundant for the happy-path tests and actively broke the auth-negative ones. Production auth in saved_views.py (router-level Depends(require_api_key)) was never affected — this was a test-only gap, not a live auth bypass.
Commit 1c33d64 marked test_unauthenticated_request_rejected and test_wrong_api_key_rejected as skipped, noting that app_client overrode require_api_key so 401 could not be observed. This branch already removes that override, so the tests can run for real. Dropping the skip markers restores actual coverage of auth enforcement on the saved-views router, which does declare dependencies=[Depends(require_api_key)] and rejects both an empty and an incorrect API key.
fa68e3f to
d4d3aa8
Compare
* fix(theme): persist dark mode in localStorage and sync html class * fix(deps): override undici to resolve npm audit vulnerability * fix(deps): bump undici override to ^8.10.0 to resolve high severity audit vulnerability * fix(deps): update jsdom to v25 and override undici for CI compatibility
…#2446) (utksh1#2451) * test: add tests for rate_limiter.check_scan_rate_limit (closes utksh1#2446) * test: fix sys.modules pollution in rate_limiter check_scan_rate_limit tests (closes utksh1#2446) --------- Co-authored-by: Mavis Bot <[email protected]>
Summary
Fixes the
backend-unitfailure tracked in #2192 (test_saved_views.py::test_unauthenticated_request_rejectedandtest_wrong_api_key_rejected, both asserting200 == 401).Correction to #2192: after digging in, this is a test-fixture bug, not a live security regression. Production auth is fine —
saved_views_routerinbackend/secuscan/saved_views.pystill declaresdependencies=[Depends(require_api_key)]at the router level, andrequire_api_keyinauth.pyis untouched and correctly rejects missing/invalid keys.The actual cause: the
app_clientfixture intesting/backend/unit/test_saved_views.pydid this unconditionally:_mock_require_api_keyalways returns success, regardless of what's in the request. That override predates PR #2025/issue #1743. When #2025 added the two auth-negative tests (test_unauthenticated_request_rejected,test_wrong_api_key_rejected) alongside a real API key already being issued and sent viaX-Api-Key, the override made those two tests structurally unable to pass — they always hit the mock, never the real check, so they always got200no matter what header was sent.Fix
Remove the
require_api_keydependency override entirely. The fixture already provisions a real API key (_auth_module.init_api_key(...)) and sends it viaX-Api-Keyon every client, so the real dependency is exercised for all existing happy-path tests too — nothing else needed mocking here.Verification
pytest testing/backend/unit/test_saved_views.py -q→ 47 passed (was 2 failed, 45 passed before the fix).pytest testing/backend/unit -q -m "not benchmark"→ same pass count as before plus these 2, no new failures.ruff check backend testing/backend→ clean.Test plan
test_unauthenticated_request_rejectedandtest_wrong_api_key_rejectedpasstesting/backend/unitsuite has no new failuresruff check backend testing/backendpasses