@webex/calling 3.8.0 → 3.8.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CallHistory/CallHistory.js +100 -63
- package/dist/CallHistory/CallHistory.js.map +1 -1
- package/dist/CallHistory/CallHistory.test.js +115 -19
- package/dist/CallHistory/CallHistory.test.js.map +1 -1
- package/dist/CallHistory/constants.js +9 -1
- package/dist/CallHistory/constants.js.map +1 -1
- package/dist/CallSettings/CallSettings.js +46 -13
- package/dist/CallSettings/CallSettings.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.js +62 -18
- package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +70 -7
- package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.js +153 -103
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +52 -15
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/constants.js +15 -1
- package/dist/CallSettings/constants.js.map +1 -1
- package/dist/CallingClient/CallingClient.js +220 -159
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +53 -24
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +251 -189
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +96 -41
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +73 -48
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +96 -37
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/constants.js +105 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +47 -18
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +2 -2
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +359 -297
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +561 -163
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/Contacts/ContactsClient.js +156 -102
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +197 -49
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Contacts/constants.js +11 -1
- package/dist/Contacts/constants.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/impl/index.js +1 -1
- package/dist/Events/impl/index.js.map +1 -1
- package/dist/Metrics/index.js +102 -41
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +10 -4
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +4 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +154 -91
- package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +99 -19
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.js +105 -54
- package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +127 -17
- package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/Voicemail.js +198 -79
- package/dist/Voicemail/Voicemail.js.map +1 -1
- package/dist/Voicemail/Voicemail.test.js +188 -23
- package/dist/Voicemail/Voicemail.test.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.js +277 -161
- package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +268 -10
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/constants.js +25 -1
- package/dist/Voicemail/constants.js.map +1 -1
- package/dist/Voicemail/types.js.map +1 -1
- package/dist/common/Utils.js +168 -104
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +199 -35
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/constants.js +2 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/testUtil.js +3 -0
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/module/CallHistory/CallHistory.js +32 -13
- package/dist/module/CallHistory/constants.js +6 -0
- package/dist/module/CallSettings/CallSettings.js +36 -3
- package/dist/module/CallSettings/UcmBackendConnector.js +50 -5
- package/dist/module/CallSettings/WxCallBackendConnector.js +54 -18
- package/dist/module/CallSettings/constants.js +12 -0
- package/dist/module/CallingClient/CallingClient.js +54 -16
- package/dist/module/CallingClient/calling/call.js +172 -121
- package/dist/module/CallingClient/calling/callManager.js +51 -26
- package/dist/module/CallingClient/constants.js +102 -2
- package/dist/module/CallingClient/line/index.js +37 -8
- package/dist/module/CallingClient/registration/register.js +103 -64
- package/dist/module/Contacts/ContactsClient.js +65 -21
- package/dist/module/Contacts/constants.js +10 -0
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Events/impl/index.js +1 -1
- package/dist/module/Metrics/index.js +57 -2
- package/dist/module/Metrics/types.js +3 -0
- package/dist/module/Voicemail/BroadworksBackendConnector.js +66 -17
- package/dist/module/Voicemail/UcmBackendConnector.js +51 -11
- package/dist/module/Voicemail/Voicemail.js +109 -9
- package/dist/module/Voicemail/WxCallBackendConnector.js +67 -18
- package/dist/module/Voicemail/constants.js +21 -0
- package/dist/module/common/Utils.js +51 -12
- package/dist/module/common/constants.js +1 -0
- package/dist/module/common/testUtil.js +3 -0
- package/dist/module/index.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallHistory/constants.d.ts +6 -0
- package/dist/types/CallHistory/constants.d.ts.map +1 -1
- package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/constants.d.ts +12 -0
- package/dist/types/CallSettings/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts +2 -3
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +102 -2
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +3 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +1 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Contacts/constants.d.ts +10 -0
- package/dist/types/Contacts/constants.d.ts.map +1 -1
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +7 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +11 -2
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts +3 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/constants.d.ts +21 -0
- package/dist/types/Voicemail/constants.d.ts.map +1 -1
- package/dist/types/Voicemail/types.d.ts +1 -1
- package/dist/types/Voicemail/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +4 -4
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/constants.d.ts +1 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +3 -0
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +12 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -36,6 +36,7 @@ describe('ContactClient Tests', function () {
|
|
|
36
36
|
// eslint-disable-next-line no-underscore-dangle
|
|
37
37
|
var contactServiceGroupUrl = "".concat(webex.internal.services._serviceUrls.contactsService, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER);
|
|
38
38
|
var serviceErrorCodeHandlerSpy = jest.spyOn(utils, 'serviceErrorCodeHandler');
|
|
39
|
+
var uploadLogsSpy = jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
39
40
|
var failureResponsePayload = {
|
|
40
41
|
statusCode: 503,
|
|
41
42
|
body: {}
|
|
@@ -47,6 +48,12 @@ describe('ContactClient Tests', function () {
|
|
|
47
48
|
});
|
|
48
49
|
expect(contactClient).toBeTruthy();
|
|
49
50
|
expect(contactClient.getSDKConnector().getWebex()).toBeTruthy();
|
|
51
|
+
|
|
52
|
+
// Set up log spies for each test
|
|
53
|
+
jest.spyOn(_Logger.default, 'info');
|
|
54
|
+
jest.spyOn(_Logger.default, 'log');
|
|
55
|
+
jest.spyOn(_Logger.default, 'warn');
|
|
56
|
+
jest.spyOn(_Logger.default, 'error');
|
|
50
57
|
});
|
|
51
58
|
afterEach(function () {
|
|
52
59
|
webex.request.mockClear();
|
|
@@ -211,11 +218,28 @@ describe('ContactClient Tests', function () {
|
|
|
211
218
|
}
|
|
212
219
|
});
|
|
213
220
|
}
|
|
221
|
+
expect(_Logger.default.info).toHaveBeenCalledWith(_constants.METHOD_START_MESSAGE, {
|
|
222
|
+
file: _constants2.CONTACTS_FILE,
|
|
223
|
+
method: _constants2.METHODS.GET_CONTACTS
|
|
224
|
+
});
|
|
225
|
+
if (codeObj.payloadData) {
|
|
226
|
+
expect(_Logger.default.log).toHaveBeenCalledWith('Successfully fetched contacts and groups', {
|
|
227
|
+
file: _constants2.CONTACTS_FILE,
|
|
228
|
+
method: _constants2.METHODS.GET_CONTACTS
|
|
229
|
+
});
|
|
230
|
+
} else {
|
|
231
|
+
expect(_Logger.default.error).toHaveBeenCalled();
|
|
232
|
+
}
|
|
214
233
|
} else {
|
|
215
234
|
expect(webex.request).toBeCalledOnceWith({
|
|
216
235
|
uri: contactServiceUrl,
|
|
217
236
|
method: _types.HTTP_METHODS.GET
|
|
218
237
|
});
|
|
238
|
+
expect(_Logger.default.info).toHaveBeenCalledWith(_constants.METHOD_START_MESSAGE, {
|
|
239
|
+
file: _constants2.CONTACTS_FILE,
|
|
240
|
+
method: _constants2.METHODS.GET_CONTACTS
|
|
241
|
+
});
|
|
242
|
+
expect(_Logger.default.error).toHaveBeenCalled();
|
|
219
243
|
}
|
|
220
244
|
expect(contactsResponse).toEqual({
|
|
221
245
|
data: expect.any(Object),
|
|
@@ -227,7 +251,7 @@ describe('ContactClient Tests', function () {
|
|
|
227
251
|
} else {
|
|
228
252
|
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith(codeObj.payloadData ? respPayload : expect.any(Error), {
|
|
229
253
|
file: _constants2.CONTACTS_FILE,
|
|
230
|
-
method:
|
|
254
|
+
method: _constants2.METHODS.GET_CONTACTS
|
|
231
255
|
});
|
|
232
256
|
}
|
|
233
257
|
case 8:
|
|
@@ -291,7 +315,27 @@ describe('ContactClient Tests', function () {
|
|
|
291
315
|
});
|
|
292
316
|
expect(contactClient['groups'].length).toEqual(2);
|
|
293
317
|
expect(contactClient['groups'][1].displayName).toEqual('Top Contacts');
|
|
294
|
-
|
|
318
|
+
expect(_Logger.default.info).toHaveBeenCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with displayName: Top Contacts"), {
|
|
319
|
+
file: _constants2.CONTACTS_FILE,
|
|
320
|
+
method: _constants2.METHODS.CREATE_CONTACT_GROUP
|
|
321
|
+
});
|
|
322
|
+
expect(_Logger.default.info).toHaveBeenCalledWith(_constants.METHOD_START_MESSAGE, {
|
|
323
|
+
file: _constants2.CONTACTS_FILE,
|
|
324
|
+
method: _constants2.METHODS.CREATE_NEW_ENCRYPTION_KEY_URL
|
|
325
|
+
});
|
|
326
|
+
expect(_Logger.default.info).toHaveBeenCalledWith('Requesting kms for a new KRO and key', {
|
|
327
|
+
file: _constants2.CONTACTS_FILE,
|
|
328
|
+
method: _constants2.METHODS.CREATE_NEW_ENCRYPTION_KEY_URL
|
|
329
|
+
});
|
|
330
|
+
expect(_Logger.default.log).toHaveBeenCalledWith("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
|
|
331
|
+
file: _constants2.CONTACTS_FILE,
|
|
332
|
+
method: 'fetchEncryptionKeyUrl'
|
|
333
|
+
});
|
|
334
|
+
expect(_Logger.default.log).toHaveBeenCalledWith("Contact group Top Contacts successfully created", {
|
|
335
|
+
file: _constants2.CONTACTS_FILE,
|
|
336
|
+
method: _constants2.METHODS.CREATE_CONTACT_GROUP
|
|
337
|
+
});
|
|
338
|
+
case 24:
|
|
295
339
|
case "end":
|
|
296
340
|
return _context2.stop();
|
|
297
341
|
}
|
|
@@ -299,7 +343,7 @@ describe('ContactClient Tests', function () {
|
|
|
299
343
|
})));
|
|
300
344
|
it('create a contact group with existing key info', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
301
345
|
var _contactsResponse$dat2;
|
|
302
|
-
var successResponsePayload,
|
|
346
|
+
var successResponsePayload, infoSpy, contactsResponse;
|
|
303
347
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
304
348
|
while (1) switch (_context3.prev = _context3.next) {
|
|
305
349
|
case 0:
|
|
@@ -310,16 +354,24 @@ describe('ContactClient Tests', function () {
|
|
|
310
354
|
contactClient['groups'] = _contactFixtures.mockContactGroupListOne;
|
|
311
355
|
webex.request.mockResolvedValue(successResponsePayload);
|
|
312
356
|
webex.internal.encryption.encryptText.mockResolvedValue('Encrypted Top Contacts');
|
|
313
|
-
|
|
357
|
+
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
314
358
|
_context3.next = 7;
|
|
315
359
|
return contactClient.createContactGroup('Top Contacts');
|
|
316
360
|
case 7:
|
|
317
361
|
contactsResponse = _context3.sent;
|
|
318
362
|
expect(contactsResponse.statusCode).toEqual(201);
|
|
319
363
|
expect((_contactsResponse$dat2 = contactsResponse.data.group) === null || _contactsResponse$dat2 === void 0 ? void 0 : _contactsResponse$dat2.groupId).toBe(mockGroupResponse.groupId);
|
|
320
|
-
expect(
|
|
364
|
+
expect(infoSpy).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with displayName: Top Contacts"), {
|
|
321
365
|
file: _constants2.CONTACTS_FILE,
|
|
322
|
-
method:
|
|
366
|
+
method: _constants2.METHODS.CREATE_CONTACT_GROUP
|
|
367
|
+
});
|
|
368
|
+
expect(_Logger.default.log).toBeCalledWith("Contact group Top Contacts successfully created", {
|
|
369
|
+
file: _constants2.CONTACTS_FILE,
|
|
370
|
+
method: _constants2.METHODS.CREATE_CONTACT_GROUP
|
|
371
|
+
});
|
|
372
|
+
expect(infoSpy).not.toBeCalledWith(_constants.METHOD_START_MESSAGE, {
|
|
373
|
+
file: _constants2.CONTACTS_FILE,
|
|
374
|
+
method: _constants2.METHODS.CREATE_NEW_ENCRYPTION_KEY_URL
|
|
323
375
|
});
|
|
324
376
|
expect(webex.request).toBeCalledOnceWith({
|
|
325
377
|
uri: contactServiceGroupUrl,
|
|
@@ -333,7 +385,7 @@ describe('ContactClient Tests', function () {
|
|
|
333
385
|
});
|
|
334
386
|
expect(contactClient['groups'].length).toEqual(2);
|
|
335
387
|
expect(contactClient['groups'][1].displayName).toEqual('Top Contacts');
|
|
336
|
-
case
|
|
388
|
+
case 16:
|
|
337
389
|
case "end":
|
|
338
390
|
return _context3.stop();
|
|
339
391
|
}
|
|
@@ -356,17 +408,21 @@ describe('ContactClient Tests', function () {
|
|
|
356
408
|
expect(contactsResponse.statusCode).toBe(400);
|
|
357
409
|
expect(logSpy).toBeCalledOnceWith("Group name ".concat(mockGroupResponse.displayName, " already exists."), {
|
|
358
410
|
file: _constants2.CONTACTS_FILE,
|
|
359
|
-
method:
|
|
411
|
+
method: _constants2.METHODS.CREATE_CONTACT_GROUP
|
|
412
|
+
});
|
|
413
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with displayName: ").concat(mockGroupResponse.displayName), {
|
|
414
|
+
file: _constants2.CONTACTS_FILE,
|
|
415
|
+
method: _constants2.METHODS.CREATE_CONTACT_GROUP
|
|
360
416
|
});
|
|
361
417
|
expect(contactClient['groups']).toEqual(_contactFixtures.mockContactResponseBodyOne.groups);
|
|
362
|
-
case
|
|
418
|
+
case 12:
|
|
363
419
|
case "end":
|
|
364
420
|
return _context4.stop();
|
|
365
421
|
}
|
|
366
422
|
}, _callee4);
|
|
367
423
|
})));
|
|
368
424
|
it('create a contact group - service unavailable', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
369
|
-
var loggerContext, warnSpy, contactsResponse;
|
|
425
|
+
var loggerContext, warnSpy, errorSpy, contactsResponse;
|
|
370
426
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
371
427
|
while (1) switch (_context5.prev = _context5.next) {
|
|
372
428
|
case 0:
|
|
@@ -380,9 +436,10 @@ describe('ContactClient Tests', function () {
|
|
|
380
436
|
webex.internal.encryption.kms.createResource.mockResolvedValue(_contactFixtures.mockKmsKey);
|
|
381
437
|
webex.internal.encryption.encryptText.mockResolvedValueOnce('Encrypted group name');
|
|
382
438
|
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
383
|
-
|
|
439
|
+
errorSpy = jest.spyOn(_Logger.default, 'error');
|
|
440
|
+
_context5.next = 10;
|
|
384
441
|
return contactClient.createContactGroup('New group');
|
|
385
|
-
case
|
|
442
|
+
case 10:
|
|
386
443
|
contactsResponse = _context5.sent;
|
|
387
444
|
expect(contactsResponse.statusCode).toBe(503);
|
|
388
445
|
expect(webex.request).toBeCalledOnceWith({
|
|
@@ -395,19 +452,21 @@ describe('ContactClient Tests', function () {
|
|
|
395
452
|
schemas: 'urn:cisco:codev:identity:contact:core:1.0'
|
|
396
453
|
}
|
|
397
454
|
});
|
|
398
|
-
expect(
|
|
399
|
-
expect(warnSpy).
|
|
400
|
-
expect(warnSpy).toHaveBeenNthCalledWith(
|
|
455
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with displayName: New group"), loggerContext);
|
|
456
|
+
expect(warnSpy).toBeCalledTimes(1);
|
|
457
|
+
expect(warnSpy).toHaveBeenNthCalledWith(1, '503 Unable to establish a connection with the server', loggerContext);
|
|
458
|
+
expect(errorSpy).toBeCalledTimes(1);
|
|
459
|
+
expect(errorSpy).toHaveBeenNthCalledWith(1, Error("Unable to create contact group: ".concat(failureResponsePayload)), loggerContext);
|
|
401
460
|
expect(contactClient['groups']).toEqual(_contactFixtures.mockContactGroupListOne);
|
|
402
461
|
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith(failureResponsePayload, loggerContext);
|
|
403
|
-
case
|
|
462
|
+
case 20:
|
|
404
463
|
case "end":
|
|
405
464
|
return _context5.stop();
|
|
406
465
|
}
|
|
407
466
|
}, _callee5);
|
|
408
467
|
})));
|
|
409
468
|
it('delete a contact group - service unavailable', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
410
|
-
var loggerContext, warnSpy, contactsResponse;
|
|
469
|
+
var loggerContext, warnSpy, errorSpy, contactsResponse;
|
|
411
470
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
412
471
|
while (1) switch (_context6.prev = _context6.next) {
|
|
413
472
|
case 0:
|
|
@@ -420,21 +479,26 @@ describe('ContactClient Tests', function () {
|
|
|
420
479
|
webex.internal.encryption.kms.createUnboundKeys.mockResolvedValue([_contactFixtures.mockKmsKey]);
|
|
421
480
|
webex.internal.encryption.kms.createResource.mockResolvedValue(_contactFixtures.mockKmsKey);
|
|
422
481
|
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
423
|
-
|
|
482
|
+
errorSpy = jest.spyOn(_Logger.default, 'error');
|
|
483
|
+
_context6.next = 9;
|
|
424
484
|
return contactClient.deleteContactGroup(mockGroupResponse.groupId);
|
|
425
|
-
case
|
|
485
|
+
case 9:
|
|
426
486
|
contactsResponse = _context6.sent;
|
|
427
487
|
expect(contactsResponse.statusCode).toBe(503);
|
|
428
488
|
expect(webex.request).toBeCalledOnceWith({
|
|
429
489
|
method: _types.HTTP_METHODS.DELETE,
|
|
430
490
|
uri: "".concat(contactServiceGroupUrl, "/").concat(mockGroupResponse.groupId)
|
|
431
491
|
});
|
|
432
|
-
expect(
|
|
433
|
-
expect(
|
|
434
|
-
expect(warnSpy).
|
|
492
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with groupId: ").concat(mockGroupResponse.groupId), loggerContext);
|
|
493
|
+
expect(_Logger.default.info).toBeCalledWith("Deleting contact group: ".concat(mockGroupResponse.groupId), loggerContext);
|
|
494
|
+
expect(warnSpy).toBeCalledTimes(1);
|
|
495
|
+
expect(errorSpy).toBeCalledTimes(1);
|
|
496
|
+
expect(uploadLogsSpy).toBeCalledTimes(1);
|
|
497
|
+
expect(errorSpy).toHaveBeenNthCalledWith(1, Error("Unable to delete contact group ".concat(mockGroupResponse.groupId, ": ").concat(failureResponsePayload)), loggerContext);
|
|
498
|
+
expect(warnSpy).toHaveBeenNthCalledWith(1, '503 Unable to establish a connection with the server', loggerContext);
|
|
435
499
|
expect(contactClient['groups']).toEqual(_contactFixtures.mockContactGroupListOne);
|
|
436
500
|
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith(failureResponsePayload, loggerContext);
|
|
437
|
-
case
|
|
501
|
+
case 21:
|
|
438
502
|
case "end":
|
|
439
503
|
return _context6.stop();
|
|
440
504
|
}
|
|
@@ -460,7 +524,15 @@ describe('ContactClient Tests', function () {
|
|
|
460
524
|
method: _types.HTTP_METHODS.DELETE
|
|
461
525
|
});
|
|
462
526
|
expect(contactClient['groups']).toEqual([]);
|
|
463
|
-
|
|
527
|
+
expect(_Logger.default.info).toBeCalledWith("Deleting contact group: ".concat(_contactFixtures.mockContactGroupListOne[0].groupId), {
|
|
528
|
+
file: _constants2.CONTACTS_FILE,
|
|
529
|
+
method: 'deleteContactGroup'
|
|
530
|
+
});
|
|
531
|
+
expect(_Logger.default.log).toBeCalledWith("Contact group ".concat(_contactFixtures.mockContactGroupListOne[0].groupId, " successfully deleted"), {
|
|
532
|
+
file: _constants2.CONTACTS_FILE,
|
|
533
|
+
method: 'deleteContactGroup'
|
|
534
|
+
});
|
|
535
|
+
case 11:
|
|
464
536
|
case "end":
|
|
465
537
|
return _context7.stop();
|
|
466
538
|
}
|
|
@@ -468,7 +540,7 @@ describe('ContactClient Tests', function () {
|
|
|
468
540
|
})));
|
|
469
541
|
it('create a contact with an existing group', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
470
542
|
var _res$data$contact, _result$data$contact;
|
|
471
|
-
var mockContactResponse, successResponsePayload, logSpy, contact, res, result;
|
|
543
|
+
var mockContactResponse, successResponsePayload, infoSpy, logSpy, contact, res, result;
|
|
472
544
|
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
473
545
|
while (1) switch (_context8.prev = _context8.next) {
|
|
474
546
|
case 0:
|
|
@@ -479,17 +551,26 @@ describe('ContactClient Tests', function () {
|
|
|
479
551
|
};
|
|
480
552
|
webex.request.mockResolvedValue(successResponsePayload);
|
|
481
553
|
webex.internal.encryption.encryptText.mockResolvedValue('Encrypted contact name');
|
|
482
|
-
|
|
554
|
+
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
555
|
+
logSpy = jest.spyOn(_Logger.default, 'log');
|
|
483
556
|
contactClient['groups'] = _contactFixtures.mockContactGroupListOne;
|
|
484
557
|
contactClient['encryptionKeyUrl'] = _contactFixtures.mockContactGroupListOne[0].encryptionKeyUrl;
|
|
485
558
|
contact = _contactFixtures.mockContactListTwo.slice()[0];
|
|
486
559
|
contact.groups = [];
|
|
487
|
-
_context8.next =
|
|
560
|
+
_context8.next = 12;
|
|
488
561
|
return contactClient.createContact(contact);
|
|
489
|
-
case
|
|
562
|
+
case 12:
|
|
490
563
|
res = _context8.sent;
|
|
491
564
|
expect(res.statusCode).toEqual(201);
|
|
492
565
|
expect((_res$data$contact = res.data.contact) === null || _res$data$contact === void 0 ? void 0 : _res$data$contact.contactId).toBe(mockContactResponse.contactId);
|
|
566
|
+
expect(infoSpy).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with contactType: ").concat(contact.contactType), {
|
|
567
|
+
file: _constants2.CONTACTS_FILE,
|
|
568
|
+
method: _constants2.METHODS.CREATE_CONTACT
|
|
569
|
+
});
|
|
570
|
+
expect(logSpy).toBeCalledWith("Contact successfully created", {
|
|
571
|
+
file: _constants2.CONTACTS_FILE,
|
|
572
|
+
method: _constants2.METHODS.CREATE_CONTACT
|
|
573
|
+
});
|
|
493
574
|
expect(logSpy).not.toBeCalledWith('Created a KRO and encryptionKeyUrl', {
|
|
494
575
|
file: _constants2.CONTACTS_FILE,
|
|
495
576
|
method: 'createNewEncryptionKeyUrl'
|
|
@@ -498,7 +579,7 @@ describe('ContactClient Tests', function () {
|
|
|
498
579
|
file: _constants2.CONTACTS_FILE,
|
|
499
580
|
method: 'createNewEncryptionKeyUrl'
|
|
500
581
|
});
|
|
501
|
-
expect(
|
|
582
|
+
expect(infoSpy).not.toBeCalledWith("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
|
|
502
583
|
file: _constants2.CONTACTS_FILE,
|
|
503
584
|
method: 'fetchEncryptionKeyUrl'
|
|
504
585
|
});
|
|
@@ -515,16 +596,16 @@ describe('ContactClient Tests', function () {
|
|
|
515
596
|
logSpy.mockClear();
|
|
516
597
|
|
|
517
598
|
/* for coverage */
|
|
518
|
-
_context8.next =
|
|
599
|
+
_context8.next = 25;
|
|
519
600
|
return contactClient.createContact(contact);
|
|
520
|
-
case
|
|
601
|
+
case 25:
|
|
521
602
|
result = _context8.sent;
|
|
522
603
|
expect((_result$data$contact = result.data.contact) === null || _result$data$contact === void 0 ? void 0 : _result$data$contact.contactId).toBe(mockContactResponse.contactId);
|
|
523
604
|
expect(logSpy).not.toBeCalledWith("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
|
|
524
605
|
file: _constants2.CONTACTS_FILE,
|
|
525
606
|
method: 'fetchEncryptionKeyUrl'
|
|
526
607
|
});
|
|
527
|
-
case
|
|
608
|
+
case 28:
|
|
528
609
|
case "end":
|
|
529
610
|
return _context8.stop();
|
|
530
611
|
}
|
|
@@ -588,7 +669,27 @@ describe('ContactClient Tests', function () {
|
|
|
588
669
|
keyUris: [_contactFixtures.mockKmsKey.uri]
|
|
589
670
|
});
|
|
590
671
|
expect((_res$data$contact2 = res.data.contact) === null || _res$data$contact2 === void 0 ? void 0 : _res$data$contact2.contactId).toBe(mockContactResponse.contactId);
|
|
591
|
-
|
|
672
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with contactType: CUSTOM"), {
|
|
673
|
+
file: _constants2.CONTACTS_FILE,
|
|
674
|
+
method: _constants2.METHODS.CREATE_CONTACT
|
|
675
|
+
});
|
|
676
|
+
expect(_Logger.default.info).toBeCalledWith(_constants.METHOD_START_MESSAGE, {
|
|
677
|
+
file: _constants2.CONTACTS_FILE,
|
|
678
|
+
method: _constants2.METHODS.CREATE_NEW_ENCRYPTION_KEY_URL
|
|
679
|
+
});
|
|
680
|
+
expect(_Logger.default.info).toBeCalledWith('Requesting kms for a new KRO and key', {
|
|
681
|
+
file: _constants2.CONTACTS_FILE,
|
|
682
|
+
method: _constants2.METHODS.CREATE_NEW_ENCRYPTION_KEY_URL
|
|
683
|
+
});
|
|
684
|
+
expect(_Logger.default.log).toBeCalledWith("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
|
|
685
|
+
file: _constants2.CONTACTS_FILE,
|
|
686
|
+
method: _constants2.METHODS.FETCH_ENCRYPTION_KEY_URL
|
|
687
|
+
});
|
|
688
|
+
expect(_Logger.default.log).toBeCalledWith("Contact successfully created", {
|
|
689
|
+
file: _constants2.CONTACTS_FILE,
|
|
690
|
+
method: 'createContact'
|
|
691
|
+
});
|
|
692
|
+
case 26:
|
|
592
693
|
case "end":
|
|
593
694
|
return _context9.stop();
|
|
594
695
|
}
|
|
@@ -623,10 +724,14 @@ describe('ContactClient Tests', function () {
|
|
|
623
724
|
res = _context10.sent;
|
|
624
725
|
expect(res.statusCode).toEqual(400);
|
|
625
726
|
expect(res.data.error).toEqual('contactId is required for contactType:CLOUD.');
|
|
727
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with contactType: CLOUD"), {
|
|
728
|
+
file: _constants2.CONTACTS_FILE,
|
|
729
|
+
method: _constants2.METHODS.CREATE_CONTACT
|
|
730
|
+
});
|
|
626
731
|
contact.contactId = mockContactResponse.contactId;
|
|
627
|
-
_context10.next =
|
|
732
|
+
_context10.next = 18;
|
|
628
733
|
return contactClient.createContact(contact);
|
|
629
|
-
case
|
|
734
|
+
case 18:
|
|
630
735
|
res = _context10.sent;
|
|
631
736
|
expect(res.statusCode).toEqual(201);
|
|
632
737
|
expect((_res$data$contact3 = res.data.contact) === null || _res$data$contact3 === void 0 ? void 0 : _res$data$contact3.contactId).toBe(mockContactResponse.contactId);
|
|
@@ -660,7 +765,11 @@ describe('ContactClient Tests', function () {
|
|
|
660
765
|
'spark-user-agent': 'webex-calling/beta'
|
|
661
766
|
}
|
|
662
767
|
});
|
|
663
|
-
|
|
768
|
+
expect(_Logger.default.log).toBeCalledWith("Contact successfully created", {
|
|
769
|
+
file: _constants2.CONTACTS_FILE,
|
|
770
|
+
method: 'createContact'
|
|
771
|
+
});
|
|
772
|
+
case 26:
|
|
664
773
|
case "end":
|
|
665
774
|
return _context10.stop();
|
|
666
775
|
}
|
|
@@ -693,10 +802,18 @@ describe('ContactClient Tests', function () {
|
|
|
693
802
|
});
|
|
694
803
|
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith(failureResponsePayload, {
|
|
695
804
|
file: _constants2.CONTACTS_FILE,
|
|
696
|
-
method:
|
|
805
|
+
method: _constants2.METHODS.CREATE_CONTACT
|
|
697
806
|
});
|
|
698
807
|
expect(res.statusCode).toEqual(503);
|
|
699
|
-
|
|
808
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with contactType: CLOUD"), {
|
|
809
|
+
file: _constants2.CONTACTS_FILE,
|
|
810
|
+
method: _constants2.METHODS.CREATE_CONTACT
|
|
811
|
+
});
|
|
812
|
+
expect(_Logger.default.error).toBeCalledWith(Error("Failed to create contact: ".concat(failureResponsePayload)), {
|
|
813
|
+
file: _constants2.CONTACTS_FILE,
|
|
814
|
+
method: _constants2.METHODS.CREATE_CONTACT
|
|
815
|
+
});
|
|
816
|
+
case 12:
|
|
700
817
|
case "end":
|
|
701
818
|
return _context11.stop();
|
|
702
819
|
}
|
|
@@ -722,7 +839,15 @@ describe('ContactClient Tests', function () {
|
|
|
722
839
|
method: _types.HTTP_METHODS.DELETE
|
|
723
840
|
});
|
|
724
841
|
expect(contactClient['contacts']).toEqual([]);
|
|
725
|
-
|
|
842
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with contactId: ").concat(_contactFixtures.mockContactListOne[0].contactId), {
|
|
843
|
+
file: _constants2.CONTACTS_FILE,
|
|
844
|
+
method: _constants2.METHODS.DELETE_CONTACT
|
|
845
|
+
});
|
|
846
|
+
expect(_Logger.default.info).toBeCalledWith("Deleting contact : ".concat(_contactFixtures.mockContactListOne[0].contactId), {
|
|
847
|
+
file: _constants2.CONTACTS_FILE,
|
|
848
|
+
method: _constants2.METHODS.DELETE_CONTACT
|
|
849
|
+
});
|
|
850
|
+
case 11:
|
|
726
851
|
case "end":
|
|
727
852
|
return _context12.stop();
|
|
728
853
|
}
|
|
@@ -746,10 +871,18 @@ describe('ContactClient Tests', function () {
|
|
|
746
871
|
});
|
|
747
872
|
expect(serviceErrorCodeHandlerSpy).toBeCalledOnceWith(failureResponsePayload, {
|
|
748
873
|
file: _constants2.CONTACTS_FILE,
|
|
749
|
-
method:
|
|
874
|
+
method: _constants2.METHODS.DELETE_CONTACT
|
|
750
875
|
});
|
|
751
876
|
expect(contactClient['contacts']).toEqual(_contactFixtures.mockContactListOne);
|
|
752
|
-
|
|
877
|
+
expect(_Logger.default.info).toBeCalledWith("".concat(_constants.METHOD_START_MESSAGE, " with contactId: ").concat(_contactFixtures.mockContactListOne[0].contactId), {
|
|
878
|
+
file: _constants2.CONTACTS_FILE,
|
|
879
|
+
method: _constants2.METHODS.DELETE_CONTACT
|
|
880
|
+
});
|
|
881
|
+
expect(_Logger.default.info).toBeCalledWith("Deleting contact : ".concat(_contactFixtures.mockContactListOne[0].contactId), {
|
|
882
|
+
file: _constants2.CONTACTS_FILE,
|
|
883
|
+
method: _constants2.METHODS.DELETE_CONTACT
|
|
884
|
+
});
|
|
885
|
+
case 11:
|
|
753
886
|
case "end":
|
|
754
887
|
return _context13.stop();
|
|
755
888
|
}
|
|
@@ -813,13 +946,18 @@ describe('ContactClient Tests', function () {
|
|
|
813
946
|
}]);
|
|
814
947
|
});
|
|
815
948
|
it('test resolveContacts function encountering an error', function () {
|
|
949
|
+
var warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
816
950
|
var contact = contactClient['resolveCloudContacts']({
|
|
817
951
|
userId: _contactFixtures.mockContactMinimum
|
|
818
952
|
}, _contactFixtures.mockSCIMMinListResponse);
|
|
819
953
|
expect(contact).toEqual(null);
|
|
954
|
+
expect(warnSpy).toHaveBeenCalledWith('Error occurred while parsing resolved contacts', {
|
|
955
|
+
file: _constants2.CONTACTS_FILE,
|
|
956
|
+
method: 'resolveCloudContacts'
|
|
957
|
+
});
|
|
820
958
|
});
|
|
821
959
|
it('logs error for chunk when scimQuery API call fails in the loop for getContacts', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
822
|
-
var mockData, respPayload;
|
|
960
|
+
var mockData, respPayload, warnSpy, infoSpy, logSpy;
|
|
823
961
|
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
824
962
|
while (1) switch (_context14.prev = _context14.next) {
|
|
825
963
|
case 0:
|
|
@@ -836,17 +974,27 @@ describe('ContactClient Tests', function () {
|
|
|
836
974
|
mockData.decryptTextList.forEach(function (text) {
|
|
837
975
|
webex.internal.encryption.decryptText.mockResolvedValueOnce(text);
|
|
838
976
|
});
|
|
839
|
-
jest.spyOn(_Logger.default, 'warn');
|
|
840
|
-
|
|
977
|
+
warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
978
|
+
infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
979
|
+
logSpy = jest.spyOn(_Logger.default, 'log');
|
|
980
|
+
_context14.next = 9;
|
|
841
981
|
return contactClient.getContacts();
|
|
842
|
-
case
|
|
982
|
+
case 9:
|
|
843
983
|
expect(webex.request).toBeCalledTimes(2);
|
|
844
|
-
expect(
|
|
845
|
-
expect(
|
|
984
|
+
expect(warnSpy).toBeCalledTimes(1);
|
|
985
|
+
expect(warnSpy).toBeCalledWith('Error processing contact chunk 0-50', {
|
|
846
986
|
file: 'Contacts',
|
|
847
|
-
method:
|
|
987
|
+
method: _constants2.METHODS.GET_CONTACTS
|
|
848
988
|
});
|
|
849
|
-
|
|
989
|
+
expect(infoSpy).toBeCalledWith(_constants.METHOD_START_MESSAGE, {
|
|
990
|
+
file: _constants2.CONTACTS_FILE,
|
|
991
|
+
method: _constants2.METHODS.GET_CONTACTS
|
|
992
|
+
});
|
|
993
|
+
expect(logSpy).toBeCalledWith('Successfully fetched contacts and groups', {
|
|
994
|
+
file: _constants2.CONTACTS_FILE,
|
|
995
|
+
method: _constants2.METHODS.GET_CONTACTS
|
|
996
|
+
});
|
|
997
|
+
case 14:
|
|
850
998
|
case "end":
|
|
851
999
|
return _context14.stop();
|
|
852
1000
|
}
|