From 522469ca89e2ca494a73639c8d8a44cff2bf96f7 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Sun, 7 May 2023 17:25:13 +0700 Subject: [PATCH] fix failing testcase --- lib/session/call-info.js | 3 +-- test/create-call-test.js | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/session/call-info.js b/lib/session/call-info.js index b46db0e9..852b0373 100644 --- a/lib/session/call-info.js +++ b/lib/session/call-info.js @@ -13,7 +13,6 @@ class CallInfo { this.direction = opts.direction; this.traceId = opts.traceId; this.callTerminationBy = undefined; - this.metadata = opts.metadata; if (opts.req) { const u = opts.req.getParsedHeader('from'); const uri = parseUri(u.uri); @@ -92,7 +91,7 @@ class CallInfo { this.from = from || req.callingNumber; this.to = to; if (tag) this._customerData = tag; - if (this.metadata) this._customerData = {...this._customerData, ...this.metadata}; + if (opts.metadata) this._customerData = {...this._customerData, ...opts.metadata}; } this.localSipAddress = srf.locals.localSipAddress; diff --git a/test/create-call-test.js b/test/create-call-test.js index 1de8db64..17dd2353 100644 --- a/test/create-call-test.js +++ b/test/create-call-test.js @@ -106,17 +106,19 @@ test("test create-call call-hook basic authentication", async (t) => { await p; let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}`); + console.log(obj); t.ok( - (obj.headers.Authorization === "Basic dXNlcm5hbWU6cGFzc3dvcmQ="), + obj.headers.Authorization === "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", "create-call: call-hook contains basic authentication header" ); t.ok( - (obj.customerData.customer === 'acme'), + obj.body.customerdata.customer === "acme", "create-call: metadata is working" ); obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`); + console.log(obj); t.ok( - (obj.customerData.customer === 'acme'), + obj.body.customerData.customer === "acme", "create-call: metadata is working" ); disconnect();