Test: Add token verification error propagation tests (#167)#265
Merged
Conversation
Adds rethrow tests for the three token-verification failure modes that flow through ClaimRedemptionProvider.redeemClaim: expired token, wrong account, and malformed JWT. Each mocks TokenVerificationProvider.verifyClaimToken to throw BadRequestException and asserts the redemption path rethrows the exception class. Note: the 'token generation' case from issue bridgelet-org#167 is out of this PR's scope -- token issuance + hash storage live in AccountsService.createAccount. Coverage for that case will be in a separate PR at a later pass.
|
@kilodesodiq-arch 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! 🚀 |
phertyameen
approved these changes
Jun 27, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #167
Closes #165
What
Adds three unit tests to
ClaimRedemptionProvider's spec (insrc/modules/claims/providers/claim-redemption.provider.spec.ts) covering the token-verification error propagation paths from the issue checklist that were not previously asserted in this scope:rethrows BadRequestException when token is expiredrethrows BadRequestException when token does not match the requested account(wrong account)rethrows BadRequestException for malformed JWTEach mocks
TokenVerificationProvider.verifyClaimTokento throwBadRequestExceptionwith the failing message, then asserts thatClaimRedemptionProvider.redeemClaimrethrows the exception class -- pinning that the redemption flow does not swallow token-verification errors.Already covered upstream
The existing spec for this provider already covers:
ConflictException)PENDING_CLAIMSo the issue case categorization maps to existing + new tests as follows:
Scope note: token generation
The
token generationcase from the issue's checklist is not testable inClaimsServiceorClaimRedemptionProvider: token issuance / hash storage happens earlier inAccountsService.createAccount. The plaintext token is returned to the API caller at account-creation time, only its hash is persisted. Coverage for that flow will be added in a separate PR.Testing
npx jest --testPathPattern=modules/claims/providers/claim-redemption-> 17/17 passed (3 new + 14 existing)npx tsc --noEmit -p tsconfig.json-> clean for this filenpx eslint-> clean for this filenpx prettier --check-> clean for this fileBranch
fix/issue-167-add-unit-tests-claims-service-and-redemption-provider