Fix #66: Add JWT auth middleware regression tests#68
Conversation
📝 WalkthroughWalkthroughA new test suite JWT Auth Middleware Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 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. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment Warning |
|
@Faizehy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/__tests__/jwtAuth.api.test.ts`:
- Around line 67-90: The JWT auth test suite has a nested `it()` inside the
`requireJwtAuthApi` test, which makes the error-case assertion a subtest instead
of a sibling case. Move the `should return 401 with error details if
verification throws an Error` block out to the same level as `should map sub to
userId`, keeping both inside the `describe`/suite that covers
`requireJwtAuthApi`. Make sure the `requireJwtAuthApi` and `mockNext`
setup/teardown remain scoped correctly so each `it()` runs independently.
- Around line 54-89: The current jwtAuth.api tests only cover malformed tokens,
so add cases in requireJwtAuthApi that exercise jwt.verify rejecting a
valid-looking token with a bad signature and an expired token. In
src/__tests__/jwtAuth.api.test.ts, extend the existing auth error tests by
signing one token with the wrong secret to assert the AUTH_INVALID_TOKEN path,
and another with expiresIn: 0 to assert the TokenExpiredError/expired-token
handling, keeping the existing mockResponse, resetNext, and mockNext assertions
consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bf6dda1b-72c6-42f0-88f5-813608083347
📒 Files selected for processing (2)
package.jsonsrc/__tests__/jwtAuth.api.test.ts
|
Hi @Faizehy Thank you for your awesome contribution, however after analyzing your implementation, there are some minor fixes to be done. Kindly fix them to merge your PR asap. Also do not forget to use fundable.finance to offramp. |
|
Done |
|
Please merge |
Summary
Describe what changed and why.
Area
src/)indexer/common/)indexer/streams/)indexer/distributions/)Scope
Verification
bun run type-checkbun run testbun run lintbun run indexer:type-checkif indexer files changedbun run indexer:testif indexer files changedbun run indexer:lintif indexer files changedIndexer Safety
Notes
Closes #66
Summary by CodeRabbit