Compare commits

...

7 Commits

Author SHA1 Message Date
Quan HL
0a4cb11dff fix 2023-07-27 22:26:03 +07:00
Quan HL
4fcc8d23f0 fix 2023-07-27 22:24:33 +07:00
Quan HL
b5efb7351b fix 2023-07-27 22:23:01 +07:00
Quan HL
ad57931222 fix customerdata should not be snakeCase 2023-07-27 22:00:35 +07:00
Quan HL
702948715d fix customerdata should not be snakeCase 2023-07-27 21:59:47 +07:00
Quan HL
7e3911d786 fix customerdata should not be snakeCase 2023-07-27 21:08:43 +07:00
Quan HL
4119864a35 fix customerdata should not be snakeCase 2023-07-27 21:07:44 +07:00
5 changed files with 49 additions and 3 deletions

View File

@@ -145,6 +145,9 @@ class CallInfo {
if (this._customerData) {
Object.assign(obj, {customerData: this._customerData});
// Duplicate customer data here to respect API contract that was created by bug
//https://github.com/jambonz/jambonz-feature-server/issues/406
Object.assign(obj, {customerdata: this._customerData});
}
if (JAMBONES_API_BASE_URL) {

View File

@@ -68,7 +68,7 @@ class TaskRestDial extends Task {
const b3 = this.getTracingPropagation();
const httpHeaders = b3 && {b3};
const params = {
...cs.callInfo,
...cs.callInfo.toJSON(),
defaults: {
synthesizer: {
vendor: cs.speechSynthesisVendor,

View File

@@ -87,7 +87,7 @@ class HttpRequestor extends BaseRequestor {
assert(HookMsgTypes.includes(type));
const payload = params ? snakeCaseKeys(params, ['customerData', 'sip']) : null;
const payload = params ? snakeCaseKeys(params, ['customerdata', 'customerData', 'sip']) : null;
const url = hook.url || hook;
const method = hook.method || 'POST';
let buf = '';

View File

@@ -80,6 +80,19 @@ test('test create-call call-hook basic authentication', async(t) => {
"username": "username",
"password": "password"
},
"call_status_hook": {
"url": "http://127.0.0.1:3100/callStatus",
"method": "POST"
},
"tag": {
"callCount": 10,
"env": "DEVELOPMENT",
"processId": "processId",
"Customer": "Customer",
"Vehicle": "Vehicle",
"Event_Camel": "Event_Camel",
"CamelCase": "CamelCase"
},
"from": from,
"to": {
"type": "phone",
@@ -96,9 +109,19 @@ test('test create-call call-hook basic authentication', async(t) => {
//THEN
await p;
let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}`)
let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}`);
t.ok(obj.headers.Authorization = 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
'create-call: call-hook contains basic authentication header');
t.ok(obj.body.customerdata.callCount === 10,
'create-call: call-hook contains correct format for customerData');
t.ok(obj.body.customerData.callCount === 10,
'create-call: call-hook contains correct format for customerData');
obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`);
t.ok(obj.body.customerdata.callCount === 10,
'create-call: status-hook contains correct format for customerData');
t.ok(obj.body.customerData.callCount === 10,
'create-call: status-hook contains correct format for customerData');
disconnect();
} catch (err) {
console.log(`error received: ${err}`);

View File

@@ -2,6 +2,8 @@ const test = require('tape');
const { sippUac } = require('./sipp')('test_fs');
const clearModule = require('clear-module');
const {provisionCallHook} = require('./utils')
const bent = require('bent');
const getJSON = bent('json')
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
@@ -27,6 +29,18 @@ test('\'say\' tests', async(t) => {
{
verb: 'say',
text: 'hello'
},
{
verb: "tag",
data: {
callCount: 10,
env: "DEVELOPMENT",
processId: "processId",
Customer: "Customer",
Vehicle: "Vehicle",
Event_Camel: "Event_Camel",
CamelCase: "CamelCase"
}
}
];
@@ -36,6 +50,12 @@ test('\'say\' tests', async(t) => {
// THEN
await sippUac('uac-success-received-bye.xml', '172.38.0.10', from);
t.pass('say: succeeds when using using account credentials');
let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`);
console.log(obj);
t.ok(obj.body.customerdata.callCount === 10,
'create-call: status-hook contains correct format for customerData');
t.ok(obj.body.customerData.callCount === 10,
'create-call: status-hook contains correct format for customerData');
disconnect();
} catch (err) {
console.log(`error received: ${err}`);