Skip to content

fix(tests): repoint security tests + add CI - #6

Merged
magi8101 merged 3 commits into
mainfrom
ci/tests-and-pipeline
Sep 1, 2026
Merged

fix(tests): repoint security tests + add CI#6
magi8101 merged 3 commits into
mainfrom
ci/tests-and-pipeline

Conversation

@magi8101

Copy link
Copy Markdown
Member

4 security test files imported a standalone API that was deliberately reverted before the tests were written — never ran. Rewrote them against the current middleware-only API, keeping every real assertion. Implemented router.py's metrics tracking too (test_router_metrics.py expected it, it was never built).

252/252 tests pass, ruff is clean. Added GitHub Actions running both on push+PR, matrixed 3.11/3.12. mypy runs but doesn't gate yet — 13 pre-existing type errors elsewhere aren't this PR's job to fix.

Fixes #2, Fixes #3

requirements.txt pinned fast-query-parsers>=2.0.0, but the latest release
published on PyPI is 1.0.3, making the constraint unsatisfiable and
breaking `pip install -r requirements.txt` for a fresh install.

Verified parse_query_string()'s API and return shape on 1.0.3 match what
velocix/core/request.py expects (ordered (key, value) pairs), so the
lower pin is safe.

Fixes #1
…er metrics

4 security test files imported a standalone API (BruteForceProtection.create,
CSRFProtection, RequestLimits, InputSanitizer) that was deliberately reverted
before these tests were written — they never ran. Rewrote them against the
current middleware-only surface, keeping every real assertion (brute-force
unit tests now build via BruteForceProtection(app, ...) instead of the
removed .create() sugar). Also fixed test_middleware_blocks_locked_ip, which
asserted nothing about actually being locked out.

test_router_metrics.py expected CachedRoute.metrics / get_metrics()
["cache_hit_rate"] that were never implemented behind the existing
metrics_enabled flag — implemented it instead of weakening the tests.

Ran `ruff check --fix` repo-wide and cleaned up the remaining 8 by hand.
Added B008 to ruff's ignore list: Depends()/Query()/... as default-arg
values is velocix's own DI pattern, not a bug.

Fixes #2
Runs on push to main and on every PR, matrixed across Python 3.11/3.12:
pip install, pytest, ruff check. mypy runs too but doesn't fail the build
yet — there are 13 pre-existing type errors scattered across the codebase
unrelated to this change; fixing them is its own PR.

Also silences the one mypy error that was actually in scope here
(velocix/cli.py's Granian(**granian_params) splat).

Fixes #3
Copilot AI lite review requested due to automatic review settings August 31, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@magi8101
magi8101 requested a review from Vattsa-11 August 31, 2026 18:53

@Vattsa-11 Vattsa-11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete

@magi8101
magi8101 merged commit a234cba into main Sep 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants