-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.2-next' into DEVEXP-526_E2E-Voice/Conferences
- Loading branch information
Showing
11 changed files
with
133 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/verification/src/models/v1/mod-callbacks/verification-callback-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { VerificationRequestEvent } from './verification-request-event'; | ||
import { VerificationResultEvent } from './verification-result-event'; | ||
|
||
export type VerificationCallbackEvent = VerificationRequestEvent | VerificationResultEvent; |
2 changes: 1 addition & 1 deletion
2
packages/verification/src/models/v1/mod-callbacks/verification-request-event/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export type { VerificationRequestEvent } from './verification-request-event'; | ||
export type { VerificationRequestEvent, MethodEnum } from './verification-request-event'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
packages/verification/tests/rest/v1/callbacks/webhooks-events.steps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { VerificationCallbackWebhooks, Verification } from '../../../../src'; | ||
import { Given, Then, When } from '@cucumber/cucumber'; | ||
import assert from 'assert'; | ||
import { IncomingHttpHeaders } from 'http'; | ||
|
||
let verificationCallbackWebhook: VerificationCallbackWebhooks; | ||
let rawEvent: any; | ||
let event: Verification.VerificationCallbackEvent; | ||
let formattedHeaders: IncomingHttpHeaders; | ||
|
||
const processEvent = async (response: Response) => { | ||
formattedHeaders = {}; | ||
response.headers.forEach((value, name) => { | ||
formattedHeaders[name.toLowerCase()] = value; | ||
}); | ||
rawEvent = await response.text(); | ||
event = verificationCallbackWebhook.parseEvent(JSON.parse(rawEvent)); | ||
}; | ||
|
||
Given('the Verification Webhooks handler is available', () => { | ||
verificationCallbackWebhook = new VerificationCallbackWebhooks({ | ||
applicationKey: 'appKey', | ||
applicationSecret: 'appSecret', | ||
}); | ||
}); | ||
|
||
When('I send a request to trigger a "Verification Request" event', async () => { | ||
const response = await fetch('http://localhost:3018/webhooks/verification/verification-request-event'); | ||
await processEvent(response); | ||
}); | ||
|
||
Then('the header of the Verification event "Verification Request" contains a valid authorization', () => { | ||
assert.ok(verificationCallbackWebhook.validateAuthenticationHeader( | ||
formattedHeaders, | ||
rawEvent, | ||
'/webhooks/verification', | ||
'POST')); | ||
}); | ||
|
||
Then('the Verification event describes a "Verification Request" event type', () => { | ||
const verificationRequestEvent = event as Verification.VerificationRequestEvent; | ||
assert.equal(verificationRequestEvent.id, '1ce0ffee-c0de-5eed-d00d-f00dfeed1337'); | ||
assert.equal(verificationRequestEvent.event, 'VerificationRequestEvent'); | ||
const smsVerificationMethod: Verification.MethodEnum = 'sms'; | ||
assert.equal(verificationRequestEvent.method, smsVerificationMethod); | ||
const identity: Verification.Identity = { | ||
type: 'number', | ||
endpoint: '+33612345678', | ||
}; | ||
assert.equal(verificationRequestEvent.identity.type, identity.type); | ||
assert.equal(verificationRequestEvent.identity.endpoint, identity.endpoint); | ||
const smsPrice: Verification.Price = { | ||
currencyId: 'EUR', | ||
amount: 0.0453, | ||
}; | ||
assert.deepEqual(verificationRequestEvent.price, smsPrice); | ||
const smsRate: Verification.Price = { | ||
currencyId: 'EUR', | ||
amount: 0, | ||
}; | ||
assert.deepEqual(verificationRequestEvent.rate, smsRate); | ||
}); | ||
|
||
When('I send a request to trigger a "Verification Result" event', async () => { | ||
const response = await fetch('http://localhost:3018/webhooks/verification/verification-result-event'); | ||
await processEvent(response); | ||
}); | ||
|
||
Then('the header of the Verification event "Verification Result" contains a valid authorization', () => { | ||
assert.ok(verificationCallbackWebhook.validateAuthenticationHeader( | ||
formattedHeaders, | ||
rawEvent, | ||
'/webhooks/verification', | ||
'POST')); | ||
}); | ||
|
||
Then('the Verification event describes a "Verification Result" event type', () => { | ||
const verificationRequestEvent = event as Verification.VerificationResultEvent; | ||
assert.equal(verificationRequestEvent.id, '1ce0ffee-c0de-5eed-d00d-f00dfeed1337'); | ||
assert.equal(verificationRequestEvent.event, 'VerificationResultEvent'); | ||
const smsVerificationMethod: Verification.MethodEnum = 'sms'; | ||
assert.equal(verificationRequestEvent.method, smsVerificationMethod); | ||
const identity: Verification.Identity = { | ||
type: 'number', | ||
endpoint: '+33612345678', | ||
}; | ||
assert.equal(verificationRequestEvent.identity.type, identity.type); | ||
assert.equal(verificationRequestEvent.identity.endpoint, identity.endpoint); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters