Skip to content

Commit abdb0b6

Browse files
waleedlatif1claude
andcommitted
test(data-drains): drift guard ensures every webhook header is reserved
Asserts that any header buildHeaders writes is rejected when reused as a custom signatureHeader. Adding a new metadata header without mirroring it into RESERVED_SIGNATURE_HEADER_NAMES now fails CI. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent a1d6567 commit abdb0b6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

apps/sim/lib/data-drains/destinations/webhook.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,29 @@ describe('webhookDestination openSession', () => {
148148
expect(calls[0][1]).toBe('93.184.216.34')
149149
expect(calls[1][1]).toBe('93.184.216.34')
150150
})
151+
152+
it('rejects every header buildHeaders writes when reused as signatureHeader (drift guard)', async () => {
153+
mockPinnedFetchOnce({ ok: true, status: 200 })
154+
const session = webhookDestination.openSession({ config, credentials })
155+
await session.deliver({
156+
body: Buffer.from('x'),
157+
contentType: 'application/x-ndjson',
158+
metadata,
159+
signal: new AbortController().signal,
160+
})
161+
162+
const init = inputValidationMockFns.mockSecureFetchWithPinnedIP.mock.calls[0][2]
163+
const writtenHeaders = Object.keys(init.headers as Record<string, string>)
164+
165+
for (const name of writtenHeaders) {
166+
const result = webhookDestination.configSchema.safeParse({
167+
url: 'https://example.com/hook',
168+
signatureHeader: name,
169+
})
170+
expect(
171+
result.success,
172+
`expected signatureHeader="${name}" to be rejected (it is written by buildHeaders)`
173+
).toBe(false)
174+
}
175+
})
151176
})

0 commit comments

Comments
 (0)