Introduces integration-based webhook registration, message parsing, dry-run monitoring, JSM ticket creation, and OAuth token refresh for DC Ops spaces. Co-authored-by: Cursor <cursoragent@cursor.com>
24 lines
967 B
JavaScript
24 lines
967 B
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import crypto from 'crypto';
|
|
import { verifyWebhookSignature } from '../services/webexInbound.js';
|
|
|
|
describe('verifyWebhookSignature', () => {
|
|
it('accepts valid signatures', () => {
|
|
const secret = 'super-secret-webhook-key';
|
|
const rawBody = Buffer.from(JSON.stringify({ hello: 'world' }));
|
|
const signature = crypto.createHmac('sha1', secret).update(rawBody).digest('hex');
|
|
|
|
assert.equal(verifyWebhookSignature(rawBody, signature, secret), true);
|
|
});
|
|
|
|
it('rejects invalid signatures', () => {
|
|
const rawBody = Buffer.from(JSON.stringify({ hello: 'world' }));
|
|
assert.equal(verifyWebhookSignature(rawBody, 'bad-signature', 'secret'), false);
|
|
});
|
|
|
|
it('rejects when secret is missing', () => {
|
|
const rawBody = Buffer.from('{}');
|
|
assert.equal(verifyWebhookSignature(rawBody, 'abc', ''), false);
|
|
});
|
|
});
|