Skip to content

test(axum): cover builder methods, rotation phases, and middleware reject paths#709

Merged
EffortlessSteven merged 1 commit into
mainfrom
claude/coverage-axum-Xmgd3
May 16, 2026
Merged

test(axum): cover builder methods, rotation phases, and middleware reject paths#709
EffortlessSteven merged 1 commit into
mainfrom
claude/coverage-axum-Xmgd3

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Adds 17 integration tests in a new crates/uselesskey-axum/tests/accessors.rs file to close coverage gaps in uselesskey-axum. No production code changes — tests only, plus the dev-dependency on uselesskey-test-support.

Gaps closed

  • AuthExpectations::{with_issuer, with_audience, with_kid} builder methods (previously unexercised — each replaces only its target field and leaves the others intact).
  • Builder chaining round-trips to an equivalent AuthExpectations::new.
  • AuthExpectations Clone + PartialEq derives (single-field mutation breaks equality).
  • RotationPhase::Next derives a kid distinct from Primary while preserving the configured issuer/audience, and is deterministic across phase rebuilds.
  • verify_bearer_token middleware reject paths each return 401 with the documented message bytes:
    • missing Authorization header (missing authorization header)
    • non-Bearer scheme (invalid authorization scheme)
    • empty bearer token (empty bearer token)
    • malformed JWT (invalid jwt header)
    • kid mismatch — token signed by Next phase against a Primary verifier (unexpected kid)
  • MockJwtVerifierState::oidc_json trims a single trailing slash from base_url (with/without slash produces an identical body) and preserves intermediate path segments; the same payload is served by oidc_router.
  • jwks_router serves MockJwtVerifierState::jwks_json verbatim.
  • inject_auth_context_layer makes TestAuthContext extractable in handler bodies.

Policy compliance

All new tests return TestResult<()> and use uselesskey_test_support::{ensure, ensure_eq, require_ok} per the no-panic-family policy — no .unwrap() / .expect() in new test code. Existing inline tests in src/lib.rs and tests/integration.rs are unchanged.

Test plan

  • cargo test -p uselesskey-axum — 17 new + existing pass
  • cargo clippy -p uselesskey-axum --all-targets -- -D warnings
  • cargo fmt -p uselesskey-axum -- --check

https://claude.ai/code/session_TODO


Generated by Claude Code

…ject paths

Adds 17 integration tests to `uselesskey-axum/tests/accessors.rs` that
close coverage gaps surfaced by the test-grid:

- `AuthExpectations::{with_issuer, with_audience, with_kid}` builders
  each replace only their target field and leave the others intact
- Builder chaining round-trips to an equivalent `AuthExpectations::new`
- `AuthExpectations` `Clone` + `PartialEq` derives detect single-field
  mutation
- `RotationPhase::Next` derives a kid distinct from `Primary` while
  preserving issuer/audience, and is deterministic across phase rebuilds
- `verify_bearer_token` middleware reject paths: missing `Authorization`
  header, non-`Bearer` scheme, empty bearer token, malformed JWT header,
  and `kid` mismatch (token signed by `Next` phase against a `Primary`
  verifier) each return `401` with the documented message bytes
- `MockJwtVerifierState::oidc_json` trims a single trailing slash from
  `base_url` but preserves intermediate path segments, and the same
  result is served by `oidc_router`
- `jwks_router` serves `MockJwtVerifierState::jwks_json` verbatim
- `inject_auth_context_layer` makes `TestAuthContext` extractable in
  handler bodies

No production code changes. All new tests return `TestResult<()>` and
use `uselesskey_test_support::{ensure, ensure_eq, require_ok}` so they
add no new no-panic-family debt.

https://claude.ai/code/session_TODO

Co-authored-by: Claude <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 59 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3dc3319b-f368-424a-a0b1-f27bd17b096d

📥 Commits

Reviewing files that changed from the base of the PR and between 5be9464 and 3ab7133.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/uselesskey-axum/Cargo.toml
  • crates/uselesskey-axum/tests/accessors.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/coverage-axum-Xmgd3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@EffortlessSteven EffortlessSteven marked this pull request as ready for review May 16, 2026 07:47
@EffortlessSteven EffortlessSteven merged commit 72c324e into main May 16, 2026
6 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants