-
Notifications
You must be signed in to change notification settings - Fork 1
Add tests for JWT bearer events; fix event when expired #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 Walkthrough""" WalkthroughThe test class for JWT WebSocket authentication was updated to support conditional enabling of JWT bearer event handlers during tests. Test methods were refactored to run with and without event handling. New flags and event hooks were added for verifying event invocation and custom claim injection. A new test demonstrates custom claim validation. The authentication service was enhanced to trigger the Changes
Sequence Diagram(s)sequenceDiagram
participant TestMethod
participant TestServer
participant JwtBearerEvents
participant WebSocketClient
participant GraphQLResolver
TestMethod->>TestServer: Create (with/without JwtBearerEvents)
TestMethod->>WebSocketClient: Connect and authenticate
WebSocketClient->>TestServer: Send JWT token
TestServer->>JwtBearerEvents: (If enabled) Trigger OnMessageReceived
TestServer->>JwtBearerEvents: (If enabled) Trigger OnTokenValidated/OnAuthenticationFailed
TestServer->>GraphQLResolver: Invoke resolver (optionally validates custom claim)
GraphQLResolver-->>TestMethod: Return result
TestMethod->>TestMethod: Assert event flags and authentication result
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (12)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/Tests/JwtBearer/JwtWebSocketAuthenticationServiceTests.cs (1)
285-288: Insert flag reset here (see comment above)Same recommendation as earlier—reset the booleans before establishing the WebSocket so that expectations reflect only this phase of the test.
🧹 Nitpick comments (2)
src/Tests/JwtBearer/JwtWebSocketAuthenticationServiceTests.cs (2)
37-41: Guard against null test actions for readability
_testFieldAction?.Invoke(ctx);is safe, but because it sits before the return statement the intent (optional extra assertions) can be lost to future readers.
Consider adding a small comment or extracting to a named local function, e.g.RunTestFieldAction(ctx);, to make this purpose crystal-clear.
No functional impact—pure readability.
43-57: Minor: includeOnChallenge/OnForbiddenif you need complete coverageYou track three core events, but
JwtBearerEventsexposes two more that are often useful when debugging GraphQL authorization issues (OnChallenge,OnForbidden).
If you ever need to assert that a challenge was generated (401) versus an authorization failure (403), wiring those here will save you another plumbing round-trip later on.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Tests/JwtBearer/JwtWebSocketAuthenticationServiceTests.cs(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test (windows-latest)
- GitHub Check: test (ubuntu-latest)
Pull Request Test Coverage Report for Build 14895387759Details
💛 - Coveralls |
Summary by CodeRabbit
New Features
Tests
Bug Fixes