Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: Add ICE to webhooks events #149

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions packages/voice/tests/rest/v1/callbacks/webhooks-events.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,41 @@ Then('the Voice event describes a "ACE" event', () => {
assert.equal(aceEvent.custom, 'Custom text');
assert.equal(aceEvent.applicationKey, 'f00dcafe-abba-c0de-1dea-dabb1ed4caf3');
});

When('I send a request to trigger a "ICE" event', async () => {
const response = await fetch('http://localhost:3019/webhooks/voice/ice');
await processEvent(response);
});

Then('the header of the "ICE" event contains a valid authorization', () => {
assert.ok(voiceCallbackWebhooks.validateAuthenticationHeader(
formattedHeaders,
rawEvent,
'/webhooks/voice',
'POST'));
});

Then('the Voice event describes a "ICE" event', () => {
const iceEvent = event as Voice.IceRequest;
assert.equal(iceEvent.callid, '1ce0ffee-ca11-ca11-ca11-abcdef000053');
assert.equal(iceEvent.event, 'ice');
assert.deepEqual(iceEvent.timestamp, new Date('2024-06-06T17:20:14Z'));
assert.equal(iceEvent.callResourceUrl, 'https://calling-use1.api.sinch.com/calling/v1/calls/id/1ce0ffee-ca11-ca11-ca11-abcdef000053');
assert.equal(iceEvent.version, 1);
assert.equal(iceEvent.applicationKey, 'f00dcafe-abba-c0de-1dea-dabb1ed4caf3');
const price: Voice.VoicePrice = {
currencyId: 'USD',
amount: 0.0,
};
assert.deepEqual(iceEvent.userRate, price);
assert.equal(iceEvent.cli, '12015555555');
const destination: Voice.Participant = {
type: 'did',
endpoint: '+12017777777',
};
assert.deepEqual(iceEvent.to, destination);
assert.equal(iceEvent.domain, 'pstn');
assert.equal(iceEvent.originationType, 'PSTN');
assert.equal(iceEvent.rdnis, '');

});
Loading