Files
simstudioai--sim/apps/sim/lib/webhooks/providers/zoom.test.ts
T
wehub-resource-sync d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

62 lines
2.3 KiB
TypeScript

import crypto from 'node:crypto'
import { NextRequest } from 'next/server'
import { describe, expect, it } from 'vitest'
import { validateZoomSignature, zoomHandler } from '@/lib/webhooks/providers/zoom'
import { isZoomEventMatch } from '@/triggers/zoom/utils'
function reqWithHeaders(headers: Record<string, string>): NextRequest {
return new NextRequest('http://localhost/test', { headers })
}
describe('Zoom webhook provider', () => {
it('isZoomEventMatch rejects empty event for specialized triggers', () => {
expect(isZoomEventMatch('zoom_meeting_started', '')).toBe(false)
expect(isZoomEventMatch('zoom_meeting_started', ' ')).toBe(false)
expect(isZoomEventMatch('zoom_meeting_started', 'meeting.started')).toBe(true)
expect(isZoomEventMatch('zoom_webhook', '')).toBe(true)
})
it('validateZoomSignature uses raw body bytes, not a re-serialized variant', () => {
const secret = 'test-secret'
const timestamp = String(Math.floor(Date.now() / 1000))
const rawA = '{"a":1,"b":2}'
const rawB = '{"b":2,"a":1}'
const computed = crypto.createHmac('sha256', secret).update(`v0:${timestamp}:${rawA}`)
const hashA = `v0=${computed.digest('hex')}`
expect(validateZoomSignature(secret, hashA, timestamp, rawA)).toBe(true)
expect(validateZoomSignature(secret, hashA, timestamp, rawB)).toBe(false)
})
it('does not implement extractIdempotencyId (x-zm-request-id handled at service level)', () => {
expect(zoomHandler.extractIdempotencyId).toBeUndefined()
})
it('formatInput passes through the Zoom webhook envelope', async () => {
const body = {
event: 'meeting.started',
event_ts: 1700000000000,
payload: { account_id: 'acct', object: { id: 1 } },
}
const { input } = await zoomHandler.formatInput!({
webhook: {},
workflow: { id: 'wf', userId: 'u' },
body,
headers: {},
requestId: 'zoom-format',
})
expect(input).toBe(body)
})
it('matchEvent never executes endpoint validation payloads', async () => {
const result = await zoomHandler.matchEvent!({
webhook: { id: 'w' },
workflow: { id: 'wf' },
body: { event: 'endpoint.url_validation' },
request: reqWithHeaders({}),
requestId: 't5',
providerConfig: { triggerId: 'zoom_webhook' },
})
expect(result).toBe(false)
})
})