chore: import upstream snapshot with attribution
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
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
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* @vitest-environment node
|
||||
*/
|
||||
import { redisConfigMock } from '@sim/testing'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('@/lib/core/config/redis', () => redisConfigMock)
|
||||
|
||||
import {
|
||||
clearPendingWebhookVerification,
|
||||
getPendingWebhookVerification,
|
||||
matchesPendingWebhookVerificationProbe,
|
||||
PendingWebhookVerificationTracker,
|
||||
registerPendingWebhookVerification,
|
||||
} from '@/lib/webhooks/pending-verification'
|
||||
|
||||
describe('pending webhook verification', () => {
|
||||
afterEach(async () => {
|
||||
await clearPendingWebhookVerification('grain-path-1')
|
||||
await clearPendingWebhookVerification('grain-path-2')
|
||||
await clearPendingWebhookVerification('grain-path-3')
|
||||
await clearPendingWebhookVerification('grain-path-4')
|
||||
})
|
||||
|
||||
it('stores and retrieves pending Grain verification entries', async () => {
|
||||
await registerPendingWebhookVerification({
|
||||
path: 'grain-path-1',
|
||||
provider: 'grain',
|
||||
workflowId: 'workflow-1',
|
||||
blockId: 'block-1',
|
||||
})
|
||||
|
||||
const entry = await getPendingWebhookVerification('grain-path-1')
|
||||
|
||||
expect(entry).toMatchObject({
|
||||
path: 'grain-path-1',
|
||||
provider: 'grain',
|
||||
workflowId: 'workflow-1',
|
||||
blockId: 'block-1',
|
||||
})
|
||||
})
|
||||
|
||||
it('matches Grain verification probe shapes only for registered paths', async () => {
|
||||
await registerPendingWebhookVerification({
|
||||
path: 'grain-path-2',
|
||||
provider: 'grain',
|
||||
})
|
||||
|
||||
const entry = await getPendingWebhookVerification('grain-path-2')
|
||||
|
||||
expect(entry).not.toBeNull()
|
||||
expect(
|
||||
matchesPendingWebhookVerificationProbe(entry!, {
|
||||
method: 'POST',
|
||||
body: {},
|
||||
})
|
||||
).toBe(true)
|
||||
expect(
|
||||
matchesPendingWebhookVerificationProbe(entry!, {
|
||||
method: 'POST',
|
||||
body: { type: 'recording_added' },
|
||||
})
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('does not register generic pending verification unless verifyTestEvents is enabled', async () => {
|
||||
await registerPendingWebhookVerification({
|
||||
path: 'grain-path-3',
|
||||
provider: 'generic',
|
||||
metadata: { verifyTestEvents: false },
|
||||
})
|
||||
|
||||
expect(await getPendingWebhookVerification('grain-path-3')).toBeNull()
|
||||
})
|
||||
|
||||
it('registers generic pending verification when verifyTestEvents is enabled', async () => {
|
||||
await registerPendingWebhookVerification({
|
||||
path: 'grain-path-3',
|
||||
provider: 'generic',
|
||||
metadata: { verifyTestEvents: true },
|
||||
})
|
||||
|
||||
const entry = await getPendingWebhookVerification('grain-path-3')
|
||||
|
||||
expect(entry).toMatchObject({
|
||||
path: 'grain-path-3',
|
||||
provider: 'generic',
|
||||
metadata: { verifyTestEvents: true },
|
||||
})
|
||||
expect(
|
||||
matchesPendingWebhookVerificationProbe(entry!, {
|
||||
method: 'POST',
|
||||
body: {},
|
||||
})
|
||||
).toBe(true)
|
||||
expect(
|
||||
matchesPendingWebhookVerificationProbe(entry!, {
|
||||
method: 'POST',
|
||||
body: { message: 'real event' },
|
||||
})
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('clears tracked pending verifications after a successful lifecycle', async () => {
|
||||
const tracker = new PendingWebhookVerificationTracker()
|
||||
|
||||
await tracker.register({
|
||||
path: 'grain-path-3',
|
||||
provider: 'grain',
|
||||
})
|
||||
|
||||
expect(await getPendingWebhookVerification('grain-path-3')).not.toBeNull()
|
||||
|
||||
await tracker.clearAll()
|
||||
|
||||
expect(await getPendingWebhookVerification('grain-path-3')).toBeNull()
|
||||
})
|
||||
|
||||
it('clears tracked pending verifications after a failed lifecycle', async () => {
|
||||
const tracker = new PendingWebhookVerificationTracker()
|
||||
|
||||
await tracker.register({
|
||||
path: 'grain-path-4',
|
||||
provider: 'grain',
|
||||
})
|
||||
|
||||
expect(await getPendingWebhookVerification('grain-path-4')).not.toBeNull()
|
||||
|
||||
await tracker.clear('grain-path-4')
|
||||
|
||||
expect(await getPendingWebhookVerification('grain-path-4')).toBeNull()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user