tests: add OAuth2 issuance, JWT verification, consent, discovery, sessions, and MCP auth unit tests#4523
Conversation
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds nine new test files providing coverage for the OAuth2 and MCP authentication stack: RDB store operations (signing key, consent/consume lifecycle, token rotation, sweeps, session listing), HTTP handler logic (JWT extraction and verification, redirect URI matching, discovery endpoints, consent flow, DCR registration and token issuance, session management), and MCP server auth request routing. ChangesConfigStore OAuth2 and MCP Sessions Tests
HTTP Handler OAuth2 Tests
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
5e5e90a to
5ee117b
Compare
91623fa to
045411d
Compare
5ee117b to
ce7bb1b
Compare
045411d to
7cae97e
Compare

Summary
Adds a comprehensive test suite for the OAuth2/MCP authentication layer, covering the configstore persistence layer, HTTP handler logic, JWT issuance and verification, consent flows, session management, and discovery endpoints.
Changes
ListOauthUserTokens.getMCPServerForRequestcovering the JWT path (vk/user/session modes, active/inactive VK checks, session validation matching, auth enforcement gating) and the header/anonymous path (header VK acceptance and rejection, anonymous fallback, OAuth strict mode WWW-Authenticate responses).flowDetail(pending, missing, empty id, expired, already-consented) andflowSubmitacross VK (active, inactive, unknown, empty, double-submit), session (enforced vs. not enforced), user (no resolver, resolved, no session), and VK-to-user upgrade binding (matching owner, mismatched owner, not signed in).matchRedirectURI(exact match, loopback port flexibility, path/scheme enforcement, malformed input),oauth2IssuerURL(configured vs. request-host fallback), andoauth2ServerCfgdefault TTL values.mockOAuth2Store,newTestSigningKey,newTestOAuth2Config,mintTestToken,newTestMCPHandler, and real SQLite-backed store helpers for issuance tests that require actual atomic semantics.Type of change
Affected areas
How to test
go test ./framework/configstore/... ./transports/bifrost-http/handlers/...All new test files are self-contained and use in-memory SQLite or mock stores; no external services are required.
Screenshots/Recordings
N/A
Breaking changes
Related issues
N/A
Security considerations
Tests explicitly cover security-critical paths: JWT algorithm confusion (alg:none, HS256, RS384), replay detection for authorization codes and refresh tokens, family-wide token revocation on replay, inactive VK rejection, identity mismatch on session revocation, and WWW-Authenticate header presence on OAuth strict mode rejections.
Checklist
docs/contributing/README.mdand followed the guidelines