Skip to content

Add router auth regression tests#11

Merged
dceoy merged 5 commits intomainfrom
bugfix/optional-auth-router-coverage
Mar 14, 2026
Merged

Add router auth regression tests#11
dceoy merged 5 commits intomainfrom
bugfix/optional-auth-router-coverage

Conversation

@dceoy
Copy link
Copy Markdown
Owner

@dceoy dceoy commented Mar 14, 2026

Summary

  • add router-level auth coverage for GET /api/v1/symbols
  • verify the endpoint returns 401 when auth is enabled and no API key is provided
  • verify the endpoint remains reachable and is removed from OpenAPI security when MT5_API_KEY is unset

Verification

  • ./scripts/qa.sh

Context

  • reported runtime behavior showed /api/v1/symbols?group=*USD* returning a 503 when MT5_API_KEY was unset
  • current source already has optional auth support; this PR locks the expected router-level behavior down with regression tests

@dceoy dceoy added bug Something isn't working codex labels Mar 14, 2026
@dceoy dceoy self-assigned this Mar 14, 2026
@dceoy dceoy marked this pull request as ready for review March 14, 2026 18:35
Comment thread tests/test_auth.py
Comment thread docs/index.md
@claude
Copy link
Copy Markdown

claude bot commented Mar 14, 2026

Good addition — the assert_not_called() check on the mock is particularly valuable here, confirming that auth rejection short-circuits before the MT5 layer is reached rather than just checking the status code. The OpenAPI schema assertion is also a nice low-cost regression guard.

Two items worth addressing:

  1. Missing invalid-key test for symbols (inline comment on test_auth.py): the version endpoint covers all three auth cases (missing key, invalid key, valid key); the symbols additions only cover two. The invalid-key branch produces a distinct error shape that's worth locking down.

  2. Note placement in docs/index.md (inline comment): the "Replace windows-host..." note sits after the uvicorn startup command rather than before the curl examples, which is slightly misleading.

The documentation switch from powershell/curl.exe to console/curl is a clear improvement for cross-platform readers.

@dceoy dceoy merged commit c9f65fa into main Mar 14, 2026
5 checks passed
@dceoy dceoy deleted the bugfix/optional-auth-router-coverage branch March 14, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant