@webex/calling 3.8.0-next.30 → 3.8.0-next.32

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.
@@ -72,9 +72,33 @@ describe('Registration Tests', function () {
72
72
  statusCode: 500,
73
73
  body: _registerFixtures.mockPostResponse
74
74
  };
75
- var failurePayload429 = {
75
+ var failurePayload429One = {
76
76
  statusCode: 429,
77
- body: _registerFixtures.mockPostResponse
77
+ body: _registerFixtures.mockPostResponse,
78
+ headers: {
79
+ 'retry-after': 42
80
+ }
81
+ };
82
+ var failurePayload429Two = {
83
+ statusCode: 429,
84
+ body: _registerFixtures.mockPostResponse,
85
+ headers: {
86
+ 'retry-after': 33
87
+ }
88
+ };
89
+ var failurePayload429Three = {
90
+ statusCode: 429,
91
+ body: _registerFixtures.mockPostResponse,
92
+ headers: {
93
+ 'retry-after': 136
94
+ }
95
+ };
96
+ var failurePayload429Four = {
97
+ statusCode: 429,
98
+ body: _registerFixtures.mockPostResponse,
99
+ headers: {
100
+ 'retry-after': 81
101
+ }
78
102
  };
79
103
  var successPayload = {
80
104
  statusCode: 200,
@@ -82,18 +106,20 @@ describe('Registration Tests', function () {
82
106
  };
83
107
  var reg;
84
108
  var restartSpy;
85
- var failbackRetry429Spy;
86
109
  var restoreSpy;
87
110
  var postRegistrationSpy;
111
+ var failoverSpy;
112
+ var retry429Spy;
88
113
  var setupRegistration = function setupRegistration(mockServiceData) {
89
114
  var mutex = new _asyncMutex.Mutex();
90
115
  reg = (0, _register.createRegistration)(webex, mockServiceData, mutex, lineEmitter, _types2.LOGGER.INFO);
91
116
  reg.setMobiusServers(mobiusUris.primary, mobiusUris.backup);
92
117
  jest.clearAllMocks();
93
118
  restartSpy = jest.spyOn(reg, 'restartRegistration');
94
- failbackRetry429Spy = jest.spyOn(reg, _constants.FAILBACK_429_RETRY_UTIL);
95
119
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
96
120
  postRegistrationSpy = jest.spyOn(reg, 'postRegistration');
121
+ failoverSpy = jest.spyOn(reg, 'startFailoverTimer');
122
+ retry429Spy = jest.spyOn(reg, 'handle429Retry');
97
123
  };
98
124
  beforeEach(function () {
99
125
  setupRegistration(MockServiceData);
@@ -202,20 +228,345 @@ describe('Registration Tests', function () {
202
228
  }
203
229
  }, _callee3);
204
230
  })));
205
- describe('Registration failover tests', function () {
206
- it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
231
+ describe('429 handling tests', function () {
232
+ var loggerContext = {
233
+ file: _constants.REGISTRATION_FILE,
234
+ method: _constants.FAILOVER_UTIL
235
+ };
236
+ var logSpy = jest.spyOn(_Logger.default, 'log');
237
+ beforeEach(function () {
238
+ mobiusUris.backup.pop();
239
+ });
240
+ afterEach(function () {
241
+ mobiusUris.backup.push(_registerFixtures.URL);
242
+ jest.clearAllMocks();
243
+ });
244
+ it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
207
245
  return _regenerator.default.wrap(function _callee4$(_context4) {
208
246
  while (1) switch (_context4.prev = _context4.next) {
247
+ case 0:
248
+ jest.useFakeTimers();
249
+ logSpy.mockClear();
250
+ webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Two).mockRejectedValueOnce(failurePayload);
251
+ _context4.next = 5;
252
+ return reg.triggerRegistration();
253
+ case 5:
254
+ /* Initial registration failed with 429 with higher retyrAfter, interval should be updtaed with retryAfter.
255
+ * The first attempt to register with primary should be made after retryAfter seconds.
256
+ */
257
+
258
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
259
+ method: 'POST',
260
+ uri: "".concat(mobiusUris.primary[0], "device")
261
+ }));
262
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
263
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'triggerRegistration');
264
+ expect(reg.retryAfter).toEqual(failurePayload429One.headers['retry-after']);
265
+ expect(failoverSpy).toBeCalledOnceWith();
266
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
267
+ retry429Spy.mockClear();
268
+ failoverSpy.mockClear();
269
+ jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
270
+ _context4.next = 16;
271
+ return flushPromises();
272
+ case 16:
273
+ /* The first attempt to register with primary failed with 429 with lower retryAfter, interval should remain the same.
274
+ * The second attempt to register with primary will be scheduled as per the interval calculated.
275
+ */
276
+
277
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
278
+ method: 'POST',
279
+ uri: "".concat(mobiusUris.primary[0], "device")
280
+ }));
281
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429Two.headers['retry-after'], 'startFailoverTimer');
282
+ expect(reg.retryAfter).toEqual(failurePayload429Two.headers['retry-after']);
283
+ expect(failoverSpy).toBeCalledOnceWith(2, failurePayload429One.headers['retry-after']);
284
+ retry429Spy.mockClear();
285
+ failoverSpy.mockClear();
286
+ jest.advanceTimersByTime(43 * _constants.SEC_TO_MSEC_MFACTOR);
287
+ _context4.next = 25;
288
+ return flushPromises();
289
+ case 25:
290
+ /* The second attempt to register with primary failed with 500, the retryAfter should be undefined.
291
+ * The third attempt to register with primary will be scheduled as per the interval calculated.
292
+ */
293
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
294
+ method: 'POST',
295
+ uri: "".concat(mobiusUris.primary[0], "device")
296
+ }));
297
+ expect(retry429Spy).not.toBeCalled();
298
+ expect(reg.retryAfter).toEqual(undefined);
299
+ expect(failoverSpy).toBeCalledOnceWith(3, 85);
300
+ case 29:
301
+ case "end":
302
+ return _context4.stop();
303
+ }
304
+ }, _callee4);
305
+ })));
306
+ it('handle 429 received with higher retryAfter than the interval when interval with elapsedTime is already reaching threshold timer so we failover immediately', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
307
+ return _regenerator.default.wrap(function _callee5$(_context5) {
308
+ while (1) switch (_context5.prev = _context5.next) {
309
+ case 0:
310
+ reg.isCCFlow = true;
311
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
312
+ jest.useFakeTimers();
313
+ webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
314
+ _context5.next = 6;
315
+ return reg.triggerRegistration();
316
+ case 6:
317
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
318
+ method: 'POST',
319
+ uri: "".concat(mobiusUris.primary[0], "device")
320
+ }));
321
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
322
+ expect(retry429Spy).not.toBeCalled();
323
+ expect(failoverSpy).toBeCalledOnceWith();
324
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
325
+ failoverSpy.mockClear();
326
+ jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
327
+ _context5.next = 15;
328
+ return flushPromises();
329
+ case 15:
330
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
331
+ method: 'POST',
332
+ uri: "".concat(mobiusUris.primary[0], "device")
333
+ }));
334
+ expect(retry429Spy).not.toBeCalled();
335
+ expect(failoverSpy).toBeCalledOnceWith(2, 33);
336
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 2", loggerContext);
337
+ logSpy.mockClear();
338
+ failoverSpy.mockClear();
339
+ jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
340
+ _context5.next = 24;
341
+ return flushPromises();
342
+ case 24:
343
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
344
+ method: 'POST',
345
+ uri: "".concat(mobiusUris.primary[0], "device")
346
+ }));
347
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
348
+ expect(failoverSpy).toBeCalledOnceWith(3, 73);
349
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 3"), loggerContext);
350
+ expect(logSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
351
+ expect(webex.request).toHaveBeenNthCalledWith(4, _objectSpread(_objectSpread({}, mockResponse), {}, {
352
+ method: 'POST',
353
+ uri: "".concat(mobiusUris.backup[0], "device")
354
+ }));
355
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
356
+ case 31:
357
+ case "end":
358
+ return _context5.stop();
359
+ }
360
+ }, _callee5);
361
+ })));
362
+ it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
363
+ return _regenerator.default.wrap(function _callee6$(_context6) {
364
+ while (1) switch (_context6.prev = _context6.next) {
365
+ case 0:
366
+ reg.isCCFlow = true;
367
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
368
+ jest.useFakeTimers();
369
+ webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
370
+ _context6.next = 6;
371
+ return reg.triggerRegistration();
372
+ case 6:
373
+ /* Initial registration and first 2 attempts with primary failed with non-final 5xx error responses.
374
+ * Last attempt with primary failed with 429, the retryAfter should be used to schedule the next attempt but
375
+ * the failover is triggered before the scheduling logic kicks in.
376
+ */
377
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
378
+ method: 'POST',
379
+ uri: "".concat(mobiusUris.primary[0], "device")
380
+ }));
381
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
382
+ expect(retry429Spy).not.toBeCalled();
383
+ expect(failoverSpy).toBeCalledOnceWith();
384
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
385
+ failoverSpy.mockClear();
386
+ jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
387
+ _context6.next = 15;
388
+ return flushPromises();
389
+ case 15:
390
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
391
+ method: 'POST',
392
+ uri: "".concat(mobiusUris.primary[0], "device")
393
+ }));
394
+ expect(retry429Spy).not.toBeCalled();
395
+ expect(failoverSpy).toBeCalledOnceWith(2, 33);
396
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 2", loggerContext);
397
+ logSpy.mockClear();
398
+ failoverSpy.mockClear();
399
+ jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
400
+ _context6.next = 24;
401
+ return flushPromises();
402
+ case 24:
403
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
404
+ method: 'POST',
405
+ uri: "".concat(mobiusUris.primary[0], "device")
406
+ }));
407
+ expect(retry429Spy).not.toBeCalled();
408
+ expect(failoverSpy).toBeCalledOnceWith(3, 73);
409
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in 41 seconds, number of attempts : 3", loggerContext);
410
+ failoverSpy.mockClear();
411
+ jest.advanceTimersByTime(41 * _constants.SEC_TO_MSEC_MFACTOR);
412
+ _context6.next = 32;
413
+ return flushPromises();
414
+ case 32:
415
+ expect(webex.request).toHaveBeenNthCalledWith(4, _objectSpread(_objectSpread({}, mockResponse), {}, {
416
+ method: 'POST',
417
+ uri: "".concat(mobiusUris.primary[0], "device")
418
+ }));
419
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
420
+ expect(failoverSpy).toBeCalledOnceWith(4, 114);
421
+ expect(logSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
422
+ expect(webex.request).toHaveBeenNthCalledWith(5, _objectSpread(_objectSpread({}, mockResponse), {}, {
423
+ method: 'POST',
424
+ uri: "".concat(mobiusUris.backup[0], "device")
425
+ }));
426
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
427
+ case 38:
428
+ case "end":
429
+ return _context6.stop();
430
+ }
431
+ }, _callee6);
432
+ })));
433
+ it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
434
+ return _regenerator.default.wrap(function _callee7$(_context7) {
435
+ while (1) switch (_context7.prev = _context7.next) {
436
+ case 0:
437
+ reg.isCCFlow = true;
438
+ jest.useFakeTimers();
439
+ webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
440
+ _context7.next = 5;
441
+ return reg.triggerRegistration();
442
+ case 5:
443
+ jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
444
+ _context7.next = 8;
445
+ return flushPromises();
446
+ case 8:
447
+ expect(webex.request).toBeCalledTimes(3);
448
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
449
+ method: 'POST',
450
+ uri: "".concat(mobiusUris.primary[0], "device")
451
+ }));
452
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
453
+ method: 'POST',
454
+ uri: "".concat(mobiusUris.primary[0], "device")
455
+ }));
456
+
457
+ /* Failover to backup server failed with 429, the retryAfter is used to schedule the next attempt with backup server.
458
+ * Interval will be updated with retryAfter as interval calculated is less than the retryAfter.
459
+ */
460
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
461
+ method: 'POST',
462
+ uri: "".concat(mobiusUris.backup[0], "device")
463
+ }));
464
+ expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
465
+ expect(logSpy).toBeCalledWith("Scheduled retry with backup servers in ".concat(failurePayload429One.headers['retry-after'], " seconds."), loggerContext);
466
+ webex.request.mockClear();
467
+ jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
468
+ _context7.next = 18;
469
+ return flushPromises();
470
+ case 18:
471
+ expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
472
+ method: 'POST',
473
+ uri: "".concat(mobiusUris.backup[0], "device")
474
+ }));
475
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
476
+ case 20:
477
+ case "end":
478
+ return _context7.stop();
479
+ }
480
+ }, _callee7);
481
+ })));
482
+ it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
483
+ return _regenerator.default.wrap(function _callee8$(_context8) {
484
+ while (1) switch (_context8.prev = _context8.next) {
485
+ case 0:
486
+ reg.isCCFlow = true;
487
+ jest.useFakeTimers();
488
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(40);
489
+ webex.request.mockRejectedValueOnce(failurePayload429Three);
490
+ _context8.next = 6;
491
+ return reg.triggerRegistration();
492
+ case 6:
493
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
494
+ method: 'POST',
495
+ uri: "".concat(mobiusUris.primary[0], "device")
496
+ }));
497
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
498
+ expect(failoverSpy).toBeCalledOnceWith();
499
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 1", loggerContext);
500
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429Three.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
501
+ expect(logSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
502
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
503
+ method: 'POST',
504
+ uri: "".concat(mobiusUris.backup[0], "device")
505
+ }));
506
+ case 13:
507
+ case "end":
508
+ return _context8.stop();
509
+ }
510
+ }, _callee8);
511
+ })));
512
+ it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
513
+ return _regenerator.default.wrap(function _callee9$(_context9) {
514
+ while (1) switch (_context9.prev = _context9.next) {
515
+ case 0:
516
+ reg.isCCFlow = true;
517
+ jest.useFakeTimers();
518
+ jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(39).mockReturnValueOnce(43);
519
+ webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Four).mockResolvedValueOnce(successPayload);
520
+ _context9.next = 6;
521
+ return reg.triggerRegistration();
522
+ case 6:
523
+ expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
524
+ method: 'POST',
525
+ uri: "".concat(mobiusUris.primary[0], "device")
526
+ }));
527
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
528
+ expect(failoverSpy).toBeCalledOnceWith();
529
+ expect(logSpy).toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
530
+ failoverSpy.mockClear();
531
+ jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
532
+ _context9.next = 14;
533
+ return flushPromises();
534
+ case 14:
535
+ expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
536
+ method: 'POST',
537
+ uri: "".concat(mobiusUris.primary[0], "device")
538
+ }));
539
+ expect(failoverSpy).toBeCalledOnceWith(2, failurePayload429One.headers['retry-after']);
540
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in 43 seconds, number of attempts : 2", loggerContext);
541
+ expect(logSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
542
+ expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429Four.headers['retry-after'], " seconds, number of attempts : 2"), loggerContext);
543
+ expect(logSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
544
+ expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
545
+ method: 'POST',
546
+ uri: "".concat(mobiusUris.backup[0], "device")
547
+ }));
548
+ expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
549
+ case 22:
550
+ case "end":
551
+ return _context9.stop();
552
+ }
553
+ }, _callee9);
554
+ })));
555
+ });
556
+ describe('Registration failover tests', function () {
557
+ it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
558
+ return _regenerator.default.wrap(function _callee10$(_context10) {
559
+ while (1) switch (_context10.prev = _context10.next) {
209
560
  case 0:
210
561
  jest.useFakeTimers();
211
562
  // try the primary twice and register successfully with backup servers
212
563
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
213
564
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
214
- _context4.next = 5;
565
+ _context10.next = 5;
215
566
  return reg.triggerRegistration();
216
567
  case 5:
217
568
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
218
- _context4.next = 8;
569
+ _context10.next = 8;
219
570
  return flushPromises();
220
571
  case 8:
221
572
  expect(webex.request).toBeCalledTimes(3);
@@ -232,13 +583,13 @@ describe('Registration Tests', function () {
232
583
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
233
584
  case 13:
234
585
  case "end":
235
- return _context4.stop();
586
+ return _context10.stop();
236
587
  }
237
- }, _callee4);
588
+ }, _callee10);
238
589
  })));
239
- it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
240
- return _regenerator.default.wrap(function _callee5$(_context5) {
241
- while (1) switch (_context5.prev = _context5.next) {
590
+ it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
591
+ return _regenerator.default.wrap(function _callee11$(_context11) {
592
+ while (1) switch (_context11.prev = _context11.next) {
242
593
  case 0:
243
594
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
244
595
  indicator: _types.ServiceIndicator.CONTACT_CENTER
@@ -246,11 +597,11 @@ describe('Registration Tests', function () {
246
597
  jest.useFakeTimers();
247
598
  webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
248
599
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
249
- _context5.next = 6;
600
+ _context11.next = 6;
250
601
  return reg.triggerRegistration();
251
602
  case 6:
252
603
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
253
- _context5.next = 9;
604
+ _context11.next = 9;
254
605
  return flushPromises();
255
606
  case 9:
256
607
  expect(webex.request).toBeCalledTimes(3);
@@ -267,27 +618,27 @@ describe('Registration Tests', function () {
267
618
  expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
268
619
  case 14:
269
620
  case "end":
270
- return _context5.stop();
621
+ return _context11.stop();
271
622
  }
272
- }, _callee5);
623
+ }, _callee11);
273
624
  })));
274
- it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
275
- return _regenerator.default.wrap(function _callee6$(_context6) {
276
- while (1) switch (_context6.prev = _context6.next) {
625
+ it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
626
+ return _regenerator.default.wrap(function _callee12$(_context12) {
627
+ while (1) switch (_context12.prev = _context12.next) {
277
628
  case 0:
278
629
  jest.useFakeTimers();
279
630
  // try the primary twice and register successfully with backup servers
280
631
  webex.request.mockRejectedValue(failurePayload);
281
632
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
282
- _context6.next = 5;
633
+ _context12.next = 5;
283
634
  return reg.triggerRegistration();
284
635
  case 5:
285
636
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
286
- _context6.next = 8;
637
+ _context12.next = 8;
287
638
  return flushPromises();
288
639
  case 8:
289
640
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
290
- _context6.next = 11;
641
+ _context12.next = 11;
291
642
  return flushPromises();
292
643
  case 11:
293
644
  /*
@@ -312,25 +663,25 @@ describe('Registration Tests', function () {
312
663
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
313
664
  case 17:
314
665
  case "end":
315
- return _context6.stop();
666
+ return _context12.stop();
316
667
  }
317
- }, _callee6);
668
+ }, _callee12);
318
669
  })));
319
670
  });
320
671
  describe('Registration failback tests', function () {
321
- beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
322
- return _regenerator.default.wrap(function _callee7$(_context7) {
323
- while (1) switch (_context7.prev = _context7.next) {
672
+ beforeEach( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
673
+ return _regenerator.default.wrap(function _callee13$(_context13) {
674
+ while (1) switch (_context13.prev = _context13.next) {
324
675
  case 0:
325
676
  /* keep keepalive as active so that it wont interfere with the failback tests */
326
677
  jest.spyOn(reg, 'postKeepAlive').mockResolvedValue(successPayload);
327
678
  jest.useFakeTimers();
328
679
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
329
- _context7.next = 5;
680
+ _context13.next = 5;
330
681
  return reg.triggerRegistration();
331
682
  case 5:
332
683
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
333
- _context7.next = 8;
684
+ _context13.next = 8;
334
685
  return flushPromises();
335
686
  case 8:
336
687
  reg.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
@@ -344,17 +695,17 @@ describe('Registration Tests', function () {
344
695
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
345
696
  case 13:
346
697
  case "end":
347
- return _context7.stop();
698
+ return _context13.stop();
348
699
  }
349
- }, _callee7);
700
+ }, _callee13);
350
701
  })));
351
702
  afterEach(function () {
352
703
  jest.clearAllTimers();
353
704
  jest.clearAllMocks();
354
705
  });
355
- it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
356
- return _regenerator.default.wrap(function _callee8$(_context8) {
357
- while (1) switch (_context8.prev = _context8.next) {
706
+ it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
707
+ return _regenerator.default.wrap(function _callee14$(_context14) {
708
+ while (1) switch (_context14.prev = _context14.next) {
358
709
  case 0:
359
710
  // delete should be successful
360
711
  global.fetch = jest.fn(function () {
@@ -364,40 +715,44 @@ describe('Registration Tests', function () {
364
715
  }
365
716
  });
366
717
  });
367
- postRegistrationSpy.mockRejectedValue(failurePayload429);
718
+ postRegistrationSpy.mockRejectedValue(failurePayload429Two);
368
719
 
369
720
  /* Wait for failback to be triggered. */
370
721
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
371
- _context8.next = 5;
722
+ _context14.next = 5;
372
723
  return flushPromises();
373
724
  case 5:
374
725
  expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
375
726
  method: 'executeFailback',
376
727
  file: _constants.REGISTRATION_FILE
377
728
  });
378
- expect(failbackRetry429Spy).toBeCalledOnceWith();
729
+ jest.advanceTimersByTime(10000);
730
+ _context14.next = 9;
731
+ return flushPromises();
732
+ case 9:
733
+ expect(retry429Spy).toBeCalledWith(failurePayload429Two.headers['retry-after'], 'executeFailback');
379
734
  expect(reg.failback429RetryAttempts).toBe(0);
380
735
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
381
- expect(restoreSpy).toBeCalledOnceWith(_constants.FAILBACK_429_RETRY_UTIL);
382
- expect(restartSpy).toBeCalledOnceWith(_constants.FAILBACK_429_RETRY_UTIL);
736
+ expect(restoreSpy).toBeCalledOnceWith(_constants.REG_429_RETRY_UTIL);
737
+ expect(restartSpy).toBeCalledOnceWith(_constants.REG_429_RETRY_UTIL);
383
738
  expect(reg.failbackTimer).toBe(undefined);
384
739
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
385
740
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
386
- case 14:
741
+ case 17:
387
742
  case "end":
388
- return _context8.stop();
743
+ return _context14.stop();
389
744
  }
390
- }, _callee8);
745
+ }, _callee14);
391
746
  })));
392
- it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
393
- return _regenerator.default.wrap(function _callee9$(_context9) {
394
- while (1) switch (_context9.prev = _context9.next) {
747
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
748
+ return _regenerator.default.wrap(function _callee15$(_context15) {
749
+ while (1) switch (_context15.prev = _context15.next) {
395
750
  case 0:
396
751
  postRegistrationSpy.mockRejectedValue(failurePayload);
397
752
 
398
753
  /* Wait for failback to be triggered. */
399
754
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
400
- _context9.next = 4;
755
+ _context15.next = 4;
401
756
  return flushPromises();
402
757
  case 4:
403
758
  expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -406,19 +761,20 @@ describe('Registration Tests', function () {
406
761
  });
407
762
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
408
763
  expect(restoreSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
764
+ expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
409
765
  expect(restartSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
410
766
  expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
411
767
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
412
- case 10:
768
+ case 11:
413
769
  case "end":
414
- return _context9.stop();
770
+ return _context15.stop();
415
771
  }
416
- }, _callee9);
772
+ }, _callee15);
417
773
  })));
418
- it('verify unsuccessful failback to primary after initial registration with backup: Restore failure with final error', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
774
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore failure with final error', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
419
775
  var finalErrorPayload;
420
- return _regenerator.default.wrap(function _callee10$(_context10) {
421
- while (1) switch (_context10.prev = _context10.next) {
776
+ return _regenerator.default.wrap(function _callee16$(_context16) {
777
+ while (1) switch (_context16.prev = _context16.next) {
422
778
  case 0:
423
779
  finalErrorPayload = {
424
780
  statusCode: 401,
@@ -428,7 +784,7 @@ describe('Registration Tests', function () {
428
784
  postRegistrationSpy.mockRejectedValue(finalErrorPayload).mockRejectedValueOnce(failurePayload);
429
785
  /* Wait for failback to be triggered. */
430
786
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
431
- _context10.next = 6;
787
+ _context16.next = 6;
432
788
  return flushPromises();
433
789
  case 6:
434
790
  expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -443,19 +799,19 @@ describe('Registration Tests', function () {
443
799
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
444
800
  case 13:
445
801
  case "end":
446
- return _context10.stop();
802
+ return _context16.stop();
447
803
  }
448
- }, _callee10);
804
+ }, _callee16);
449
805
  })));
450
- it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
451
- return _regenerator.default.wrap(function _callee11$(_context11) {
452
- while (1) switch (_context11.prev = _context11.next) {
806
+ it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
807
+ return _regenerator.default.wrap(function _callee17$(_context17) {
808
+ while (1) switch (_context17.prev = _context17.next) {
453
809
  case 0:
454
810
  postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
455
811
 
456
812
  /* Wait for failback to be triggered. */
457
813
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
458
- _context11.next = 4;
814
+ _context17.next = 4;
459
815
  return flushPromises();
460
816
  case 4:
461
817
  expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -471,19 +827,19 @@ describe('Registration Tests', function () {
471
827
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
472
828
  case 11:
473
829
  case "end":
474
- return _context11.stop();
830
+ return _context17.stop();
475
831
  }
476
- }, _callee11);
832
+ }, _callee17);
477
833
  })));
478
- it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
479
- return _regenerator.default.wrap(function _callee12$(_context12) {
480
- while (1) switch (_context12.prev = _context12.next) {
834
+ it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
835
+ return _regenerator.default.wrap(function _callee18$(_context18) {
836
+ while (1) switch (_context18.prev = _context18.next) {
481
837
  case 0:
482
838
  postRegistrationSpy.mockResolvedValue(successPayload);
483
839
 
484
840
  /* Wait for failback to be triggered. */
485
841
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
486
- _context12.next = 4;
842
+ _context18.next = 4;
487
843
  return flushPromises();
488
844
  case 4:
489
845
  expect(logSpy).toBeCalledWith("Attempting failback to primary.", {
@@ -500,13 +856,13 @@ describe('Registration Tests', function () {
500
856
  expect(reg.rehomingIntervalMax).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMax);
501
857
  case 11:
502
858
  case "end":
503
- return _context12.stop();
859
+ return _context18.stop();
504
860
  }
505
- }, _callee12);
861
+ }, _callee18);
506
862
  })));
507
- it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
508
- return _regenerator.default.wrap(function _callee13$(_context13) {
509
- while (1) switch (_context13.prev = _context13.next) {
863
+ it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
864
+ return _regenerator.default.wrap(function _callee19$(_context19) {
865
+ while (1) switch (_context19.prev = _context19.next) {
510
866
  case 0:
511
867
  /** create a new call */
512
868
  reg.callManager.createCall();
@@ -515,7 +871,7 @@ describe('Registration Tests', function () {
515
871
 
516
872
  /* Wait for failback to be triggered. */
517
873
  jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
518
- _context13.next = 6;
874
+ _context19.next = 6;
519
875
  return flushPromises();
520
876
  case 6:
521
877
  expect(logSpy).toBeCalledWith("Active calls present, deferring failback to next cycle.", {
@@ -536,9 +892,9 @@ describe('Registration Tests', function () {
536
892
  expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
537
893
  case 14:
538
894
  case "end":
539
- return _context13.stop();
895
+ return _context19.stop();
540
896
  }
541
- }, _callee13);
897
+ }, _callee19);
542
898
  })));
543
899
  });
544
900
 
@@ -552,24 +908,24 @@ describe('Registration Tests', function () {
552
908
  device: _registerFixtures.mockPostResponse.device
553
909
  };
554
910
  var beforeEachSetupForKeepalive = /*#__PURE__*/function () {
555
- var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
556
- return _regenerator.default.wrap(function _callee14$(_context14) {
557
- while (1) switch (_context14.prev = _context14.next) {
911
+ var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
912
+ return _regenerator.default.wrap(function _callee20$(_context20) {
913
+ while (1) switch (_context20.prev = _context20.next) {
558
914
  case 0:
559
915
  postRegistrationSpy.mockResolvedValueOnce(successPayload);
560
916
  jest.useFakeTimers();
561
- _context14.next = 4;
917
+ _context20.next = 4;
562
918
  return reg.triggerRegistration();
563
919
  case 4:
564
920
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
565
921
  case 5:
566
922
  case "end":
567
- return _context14.stop();
923
+ return _context20.stop();
568
924
  }
569
- }, _callee14);
925
+ }, _callee20);
570
926
  }));
571
927
  return function beforeEachSetupForKeepalive() {
572
- return _ref14.apply(this, arguments);
928
+ return _ref20.apply(this, arguments);
573
929
  };
574
930
  }();
575
931
  afterEach(function () {
@@ -585,12 +941,12 @@ describe('Registration Tests', function () {
585
941
  call.end();
586
942
  });
587
943
  });
588
- it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
944
+ it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
589
945
  var keepAlivePayload, funcSpy;
590
- return _regenerator.default.wrap(function _callee15$(_context15) {
591
- while (1) switch (_context15.prev = _context15.next) {
946
+ return _regenerator.default.wrap(function _callee21$(_context21) {
947
+ while (1) switch (_context21.prev = _context21.next) {
592
948
  case 0:
593
- _context15.next = 2;
949
+ _context21.next = 2;
594
950
  return beforeEachSetupForKeepalive();
595
951
  case 2:
596
952
  keepAlivePayload = {
@@ -600,23 +956,23 @@ describe('Registration Tests', function () {
600
956
  webex.request.mockReturnValue(keepAlivePayload);
601
957
  funcSpy = jest.spyOn(reg, 'postKeepAlive');
602
958
  jest.advanceTimersByTime(2 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
603
- _context15.next = 8;
959
+ _context21.next = 8;
604
960
  return flushPromises();
605
961
  case 8:
606
962
  expect(funcSpy).toBeCalledTimes(2); // should be called 2 times: first try and after the interval.
607
963
  expect(logSpy).lastCalledWith('Sent Keepalive, status: 200', logObj);
608
964
  case 10:
609
965
  case "end":
610
- return _context15.stop();
966
+ return _context21.stop();
611
967
  }
612
- }, _callee15);
968
+ }, _callee21);
613
969
  })));
614
- it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
970
+ it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
615
971
  var failurePayload, successPayload, timer;
616
- return _regenerator.default.wrap(function _callee16$(_context16) {
617
- while (1) switch (_context16.prev = _context16.next) {
972
+ return _regenerator.default.wrap(function _callee22$(_context22) {
973
+ while (1) switch (_context22.prev = _context22.next) {
618
974
  case 0:
619
- _context16.next = 2;
975
+ _context22.next = 2;
620
976
  return beforeEachSetupForKeepalive();
621
977
  case 2:
622
978
  failurePayload = {
@@ -631,7 +987,7 @@ describe('Registration Tests', function () {
631
987
  lineEmitter.mockClear();
632
988
  webex.request.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
633
989
  jest.advanceTimersByTime(2 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
634
- _context16.next = 10;
990
+ _context22.next = 10;
635
991
  return flushPromises();
636
992
  case 10:
637
993
  expect(handleErrorSpy).toBeCalledOnceWith(failurePayload, expect.anything(), {
@@ -645,16 +1001,16 @@ describe('Registration Tests', function () {
645
1001
  expect(lineEmitter).toBeCalledTimes(2);
646
1002
  case 16:
647
1003
  case "end":
648
- return _context16.stop();
1004
+ return _context22.stop();
649
1005
  }
650
- }, _callee16);
1006
+ }, _callee22);
651
1007
  })));
652
- it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
1008
+ it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
653
1009
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, clearIntervalSpy, timer;
654
- return _regenerator.default.wrap(function _callee17$(_context17) {
655
- while (1) switch (_context17.prev = _context17.next) {
1010
+ return _regenerator.default.wrap(function _callee23$(_context23) {
1011
+ while (1) switch (_context23.prev = _context23.next) {
656
1012
  case 0:
657
- _context17.next = 2;
1013
+ _context23.next = 2;
658
1014
  return beforeEachSetupForKeepalive();
659
1015
  case 2:
660
1016
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -670,7 +1026,7 @@ describe('Registration Tests', function () {
670
1026
  expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
671
1027
  timer = reg.keepaliveTimer;
672
1028
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
673
- _context17.next = 14;
1029
+ _context23.next = 14;
674
1030
  return flushPromises();
675
1031
  case 14:
676
1032
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -697,16 +1053,16 @@ describe('Registration Tests', function () {
697
1053
  expect(lineEmitter).toBeCalledTimes(9);
698
1054
  case 31:
699
1055
  case "end":
700
- return _context17.stop();
1056
+ return _context23.stop();
701
1057
  }
702
- }, _callee17);
1058
+ }, _callee23);
703
1059
  })));
704
- it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
1060
+ it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
705
1061
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, successPayload, clearIntervalSpy, url, timer;
706
- return _regenerator.default.wrap(function _callee18$(_context18) {
707
- while (1) switch (_context18.prev = _context18.next) {
1062
+ return _regenerator.default.wrap(function _callee24$(_context24) {
1063
+ while (1) switch (_context24.prev = _context24.next) {
708
1064
  case 0:
709
- _context18.next = 2;
1065
+ _context24.next = 2;
710
1066
  return beforeEachSetupForKeepalive();
711
1067
  case 2:
712
1068
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -732,7 +1088,7 @@ describe('Registration Tests', function () {
732
1088
  reg.setActiveMobiusUrl(url);
733
1089
  timer = reg.keepaliveTimer;
734
1090
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
735
- _context18.next = 16;
1091
+ _context24.next = 16;
736
1092
  return flushPromises();
737
1093
  case 16:
738
1094
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -747,16 +1103,16 @@ describe('Registration Tests', function () {
747
1103
  expect(reg.keepaliveTimer).not.toBe(timer);
748
1104
  case 26:
749
1105
  case "end":
750
- return _context18.stop();
1106
+ return _context24.stop();
751
1107
  }
752
- }, _callee18);
1108
+ }, _callee24);
753
1109
  })));
754
- it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
1110
+ it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
755
1111
  var failurePayload, successPayload, clearIntervalSpy, timer;
756
- return _regenerator.default.wrap(function _callee19$(_context19) {
757
- while (1) switch (_context19.prev = _context19.next) {
1112
+ return _regenerator.default.wrap(function _callee25$(_context25) {
1113
+ while (1) switch (_context25.prev = _context25.next) {
758
1114
  case 0:
759
- _context19.next = 2;
1115
+ _context25.next = 2;
760
1116
  return beforeEachSetupForKeepalive();
761
1117
  case 2:
762
1118
  failurePayload = {
@@ -772,7 +1128,7 @@ describe('Registration Tests', function () {
772
1128
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
773
1129
  timer = reg.keepaliveTimer; // sendKeepAlive tries to retry 3 times and receiving success on third time
774
1130
  jest.advanceTimersByTime(3 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
775
- _context19.next = 11;
1131
+ _context25.next = 11;
776
1132
  return flushPromises();
777
1133
  case 11:
778
1134
  expect(webex.request).toBeCalledTimes(3);
@@ -782,20 +1138,20 @@ describe('Registration Tests', function () {
782
1138
  expect(reg.keepaliveTimer).toBe(timer);
783
1139
  case 16:
784
1140
  case "end":
785
- return _context19.stop();
1141
+ return _context25.stop();
786
1142
  }
787
- }, _callee19);
1143
+ }, _callee25);
788
1144
  })));
789
- it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
1145
+ it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26() {
790
1146
  var failurePayload, successPayload, clearIntervalSpy, timer;
791
- return _regenerator.default.wrap(function _callee20$(_context20) {
792
- while (1) switch (_context20.prev = _context20.next) {
1147
+ return _regenerator.default.wrap(function _callee26$(_context26) {
1148
+ while (1) switch (_context26.prev = _context26.next) {
793
1149
  case 0:
794
1150
  // Register with contact center service
795
1151
  setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
796
1152
  indicator: _types.ServiceIndicator.CONTACT_CENTER
797
1153
  }));
798
- _context20.next = 3;
1154
+ _context26.next = 3;
799
1155
  return beforeEachSetupForKeepalive();
800
1156
  case 3:
801
1157
  failurePayload = {
@@ -811,7 +1167,7 @@ describe('Registration Tests', function () {
811
1167
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
812
1168
  timer = reg.keepaliveTimer;
813
1169
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
814
- _context20.next = 12;
1170
+ _context26.next = 12;
815
1171
  return flushPromises();
816
1172
  case 12:
817
1173
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -819,7 +1175,7 @@ describe('Registration Tests', function () {
819
1175
  expect(reg.keepaliveTimer).not.toBe(timer);
820
1176
  webex.request.mockResolvedValue(successPayload);
821
1177
  jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
822
- _context20.next = 19;
1178
+ _context26.next = 19;
823
1179
  return flushPromises();
824
1180
  case 19:
825
1181
  /* Active Url must match with the backup url as per the test */
@@ -827,16 +1183,16 @@ describe('Registration Tests', function () {
827
1183
  expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
828
1184
  case 21:
829
1185
  case "end":
830
- return _context20.stop();
1186
+ return _context26.stop();
831
1187
  }
832
- }, _callee20);
1188
+ }, _callee26);
833
1189
  })));
834
- it('verify final error for keep-alive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
1190
+ it('verify final error for keep-alive', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
835
1191
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, clearIntervalSpy;
836
- return _regenerator.default.wrap(function _callee21$(_context21) {
837
- while (1) switch (_context21.prev = _context21.next) {
1192
+ return _regenerator.default.wrap(function _callee27$(_context27) {
1193
+ while (1) switch (_context27.prev = _context27.next) {
838
1194
  case 0:
839
- _context21.next = 2;
1195
+ _context27.next = 2;
840
1196
  return beforeEachSetupForKeepalive();
841
1197
  case 2:
842
1198
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -852,7 +1208,7 @@ describe('Registration Tests', function () {
852
1208
 
853
1209
  /* send one keepalive */
854
1210
  jest.advanceTimersByTime(_registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
855
- _context21.next = 12;
1211
+ _context27.next = 12;
856
1212
  return flushPromises();
857
1213
  case 12:
858
1214
  expect(clearIntervalSpy).toBeCalledTimes(1);
@@ -874,16 +1230,16 @@ describe('Registration Tests', function () {
874
1230
  });
875
1231
  case 21:
876
1232
  case "end":
877
- return _context21.stop();
1233
+ return _context27.stop();
878
1234
  }
879
- }, _callee21);
1235
+ }, _callee27);
880
1236
  })));
881
- it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
1237
+ it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
882
1238
  var restoreSpy, restartRegSpy, reconnectSpy, failurePayload, successPayload, clearIntervalSpy, url, timer, call;
883
- return _regenerator.default.wrap(function _callee22$(_context22) {
884
- while (1) switch (_context22.prev = _context22.next) {
1239
+ return _regenerator.default.wrap(function _callee28$(_context28) {
1240
+ while (1) switch (_context28.prev = _context28.next) {
885
1241
  case 0:
886
- _context22.next = 2;
1242
+ _context28.next = 2;
887
1243
  return beforeEachSetupForKeepalive();
888
1244
  case 2:
889
1245
  restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
@@ -912,7 +1268,7 @@ describe('Registration Tests', function () {
912
1268
 
913
1269
  /* send one keepalive */
914
1270
  jest.advanceTimersByTime(5 * _registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
915
- _context22.next = 18;
1271
+ _context28.next = 18;
916
1272
  return flushPromises();
917
1273
  case 18:
918
1274
  expect(clearIntervalSpy).toBeCalledOnceWith(timer);
@@ -933,7 +1289,7 @@ describe('Registration Tests', function () {
933
1289
 
934
1290
  /* simulate call disconnect and Calling client will trigger reconnect upon receiving disconnect event from CallManager */
935
1291
  reg.callManager.callCollection = {};
936
- _context22.next = 33;
1292
+ _context28.next = 33;
937
1293
  return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
938
1294
  case 33:
939
1295
  expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
@@ -947,9 +1303,9 @@ describe('Registration Tests', function () {
947
1303
  expect(reg.keepaliveTimer).not.toBe(timer);
948
1304
  case 42:
949
1305
  case "end":
950
- return _context22.stop();
1306
+ return _context28.stop();
951
1307
  }
952
- }, _callee22);
1308
+ }, _callee28);
953
1309
  })));
954
1310
  });
955
1311
  });