Skip to content

test(webhooks): cover webhook subscription lifecycle, filtering, and secret rotation (#2079) - #2204

Open
huangji6693-max wants to merge 1 commit into
LabsCrypt:mainfrom
huangji6693-max:test/issue-2079-webhook-subscription-lifecycle
Open

huangji6693-max wants to merge 1 commit into
LabsCrypt:mainfrom
huangji6693-max:test/issue-2079-webhook-subscription-lifecycle

Conversation

@huangji6693-max

Copy link
Copy Markdown

Summary

Adds deterministic unit test coverage in backend/src/__tests__/webhookService.test.ts for the webhook subscription lifecycle and delivery filtering in backend/src/services/webhookService.ts:

  • Subscription lifecycle: Covers registerSubscription (mapping callbackUrl, eventTypes, isActive, createdAt, updatedAt), listSubscriptions, and idempotent deleteSubscription (true on deletion, false when already deleted).
  • Event filtering: Verifies WebhookService.isSupported against all SUPPORTED_WEBHOOK_EVENT_TYPES and confirms dispatch filters out unsubscribed event types via event_types @> $1::jsonb.
  • Deletion during active delivery: Verifies that concurrent deletion of one subscription mid-flight (causing a foreign-key rejection when logging its delivery) is isolated and does not abort webhook delivery or persistence for remaining active subscribers.
  • Secret rotation: Verifies rotating a subscription's HMAC secret (secret-v1 -> secret-v2 -> null), asserting that x-remitlend-signature (t=<timestamp>,v1=<hmac_sha256>) updates to match the new secret, invalidates signatures under the previous secret, and is omitted once the secret is cleared.

Closes #2079

Verification

  • node --experimental-vm-modules node_modules/jest/bin/jest.js src/__tests__/webhookService.test.ts: 17 passed, 0 failed.

Payout Wallets

  • Stellar (XLM / USDC): GBYWLISGOUWQ43VQEGXX6KRGDZ3CKAFFK3JXVLXKDO5TIFJUJ3OHJYOZ
  • EVM / Base USDC: 0x380C97bcbcAEf29DAc2d0ba7E180F1b4A7F38fdd
  • Solana (USDC / SOL): AyXYaA9Nf4z5fpLKY6DmubWe6D2qveMd79w8pEDNHcDw

This branch has not been deployed

No deployments
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.

[test] Cover webhook subscription lifecycle

1 participant