Skip to content

Test: Add token verification error propagation tests (#167)#265

Merged
phertyameen merged 1 commit into
bridgelet-org:mainfrom
kilodesodiq-arch:fix/issue-167-add-unit-tests-claims-service-and-redemption-provider
Jun 27, 2026
Merged

Test: Add token verification error propagation tests (#167)#265
phertyameen merged 1 commit into
bridgelet-org:mainfrom
kilodesodiq-arch:fix/issue-167-add-unit-tests-claims-service-and-redemption-provider

Conversation

@kilodesodiq-arch

@kilodesodiq-arch kilodesodiq-arch commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Closes #167

Closes #165

What

Adds three unit tests to ClaimRedemptionProvider's spec (in src/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 expired
  • rethrows BadRequestException when token does not match the requested account (wrong account)
  • rethrows BadRequestException for malformed JWT

Each mocks TokenVerificationProvider.verifyClaimToken to throw BadRequestException with the failing message, then asserts that ClaimRedemptionProvider.redeemClaim rethrows 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:

  • Successful redemption (4 cases incl. SELECT FOR UPDATE lock verification)
  • Double-spend rejection via concurrent CLAIMING state (ConflictException)
  • Destination Stellar-address validation (format / prefix / length / hex)
  • Sweep-failure rollback to PENDING_CLAIM

So the issue case categorization maps to existing + new tests as follows:

  • token generation -> out of this PR scope (see below)
  • token validation (expired / wrong account / malformed) -> added in this PR
  • successful redemption flow -> already covered upstream
  • double-spend rejection -> already covered upstream
  • destination validation failure -> already covered upstream

Scope note: token generation

The token generation case from the issue's checklist is not testable in ClaimsService or ClaimRedemptionProvider: token issuance / hash storage happens earlier in AccountsService.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 file
  • npx eslint -> clean for this file
  • npx prettier --check -> clean for this file
  • Working tree clean except for the one spec file

Branch

fix/issue-167-add-unit-tests-claims-service-and-redemption-provider

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.
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@phertyameen phertyameen merged commit 206e379 into bridgelet-org:main Jun 27, 2026
3 checks passed
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.

Unit tests for ClaimsService and ClaimRedemptionProvider Validate claim token scope matches account on redemption

2 participants