@webex/calling 3.10.0 → 3.11.0
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/module/CallHistory/CallHistory.js +20 -11
- package/dist/module/CallSettings/UcmBackendConnector.js +21 -8
- package/dist/module/CallSettings/WxCallBackendConnector.js +10 -15
- package/dist/module/CallingClient/CallingClient.js +83 -123
- package/dist/module/CallingClient/calling/call.js +73 -58
- package/dist/module/CallingClient/calling/callManager.js +7 -0
- package/dist/module/CallingClient/constants.js +3 -0
- package/dist/module/CallingClient/registration/register.js +85 -5
- package/dist/module/CallingClient/registration/webWorker.js +2 -2
- package/dist/module/CallingClient/registration/webWorkerStr.js +2 -2
- package/dist/module/Contacts/ContactsClient.js +19 -25
- package/dist/module/Events/impl/index.js +1 -1
- package/dist/module/Logger/index.js +2 -2
- package/dist/module/Voicemail/BroadworksBackendConnector.js +10 -18
- package/dist/module/Voicemail/UcmBackendConnector.js +7 -11
- package/dist/module/Voicemail/Voicemail.js +42 -68
- package/dist/module/Voicemail/WxCallBackendConnector.js +14 -28
- package/dist/module/common/Utils.js +31 -5
- package/dist/module/common/constants.js +2 -0
- package/dist/module/common/testUtil.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts +1 -0
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +4 -0
- 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 +3 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +4 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +6 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/Contacts/ContactsClient.d.ts +1 -0
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Logger/index.d.ts +1 -2
- package/dist/types/Logger/index.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +16 -0
- 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.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/constants.d.ts +2 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +1 -0
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/CallHistory/CallHistory.js +0 -584
- package/dist/CallHistory/CallHistory.js.map +0 -1
- package/dist/CallHistory/CallHistory.test.js +0 -813
- package/dist/CallHistory/CallHistory.test.js.map +0 -1
- package/dist/CallHistory/callHistoryFixtures.js +0 -650
- package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
- package/dist/CallHistory/constants.js +0 -38
- package/dist/CallHistory/constants.js.map +0 -1
- package/dist/CallHistory/types.js +0 -7
- package/dist/CallHistory/types.js.map +0 -1
- package/dist/CallSettings/CallSettings.js +0 -312
- package/dist/CallSettings/CallSettings.js.map +0 -1
- package/dist/CallSettings/CallSettings.test.js +0 -122
- package/dist/CallSettings/CallSettings.test.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.js +0 -261
- package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +0 -321
- package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.js +0 -604
- package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +0 -905
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/constants.js +0 -31
- package/dist/CallSettings/constants.js.map +0 -1
- package/dist/CallSettings/testFixtures.js +0 -68
- package/dist/CallSettings/testFixtures.js.map +0 -1
- package/dist/CallSettings/types.js +0 -7
- package/dist/CallSettings/types.js.map +0 -1
- package/dist/CallingClient/CallingClient.js +0 -1071
- package/dist/CallingClient/CallingClient.js.map +0 -1
- package/dist/CallingClient/CallingClient.test.js +0 -1289
- package/dist/CallingClient/CallingClient.test.js.map +0 -1
- package/dist/CallingClient/callRecordFixtures.js +0 -101
- package/dist/CallingClient/callRecordFixtures.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.js +0 -276
- package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +0 -275
- package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/types.js +0 -7
- package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
- package/dist/CallingClient/calling/call.js +0 -3444
- package/dist/CallingClient/calling/call.js.map +0 -1
- package/dist/CallingClient/calling/call.test.js +0 -3260
- package/dist/CallingClient/calling/call.test.js.map +0 -1
- package/dist/CallingClient/calling/callManager.js +0 -456
- package/dist/CallingClient/calling/callManager.js.map +0 -1
- package/dist/CallingClient/calling/callManager.test.js +0 -741
- package/dist/CallingClient/calling/callManager.test.js.map +0 -1
- package/dist/CallingClient/calling/index.js +0 -30
- package/dist/CallingClient/calling/index.js.map +0 -1
- package/dist/CallingClient/calling/types.js +0 -74
- package/dist/CallingClient/calling/types.js.map +0 -1
- package/dist/CallingClient/callingClientFixtures.js +0 -143
- package/dist/CallingClient/callingClientFixtures.js.map +0 -1
- package/dist/CallingClient/constants.js +0 -237
- package/dist/CallingClient/constants.js.map +0 -1
- package/dist/CallingClient/line/index.js +0 -349
- package/dist/CallingClient/line/index.js.map +0 -1
- package/dist/CallingClient/line/line.test.js +0 -327
- package/dist/CallingClient/line/line.test.js.map +0 -1
- package/dist/CallingClient/line/types.js +0 -21
- package/dist/CallingClient/line/types.js.map +0 -1
- package/dist/CallingClient/registration/index.js +0 -19
- package/dist/CallingClient/registration/index.js.map +0 -1
- package/dist/CallingClient/registration/register.js +0 -1538
- package/dist/CallingClient/registration/register.js.map +0 -1
- package/dist/CallingClient/registration/register.test.js +0 -1537
- package/dist/CallingClient/registration/register.test.js.map +0 -1
- package/dist/CallingClient/registration/registerFixtures.js +0 -36
- package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
- package/dist/CallingClient/registration/types.js +0 -7
- package/dist/CallingClient/registration/types.js.map +0 -1
- package/dist/CallingClient/registration/webWorker.js +0 -130
- package/dist/CallingClient/registration/webWorker.js.map +0 -1
- package/dist/CallingClient/registration/webWorker.test.js +0 -303
- package/dist/CallingClient/registration/webWorker.test.js.map +0 -1
- package/dist/CallingClient/registration/webWorkerStr.js +0 -15
- package/dist/CallingClient/registration/webWorkerStr.js.map +0 -1
- package/dist/CallingClient/types.js +0 -7
- package/dist/CallingClient/types.js.map +0 -1
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +0 -142
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +0 -1
- package/dist/Contacts/ContactsClient.js +0 -1215
- package/dist/Contacts/ContactsClient.js.map +0 -1
- package/dist/Contacts/ContactsClient.test.js +0 -1003
- package/dist/Contacts/ContactsClient.test.js.map +0 -1
- package/dist/Contacts/constants.js +0 -40
- package/dist/Contacts/constants.js.map +0 -1
- package/dist/Contacts/contactFixtures.js +0 -430
- package/dist/Contacts/contactFixtures.js.map +0 -1
- package/dist/Contacts/types.js +0 -43
- package/dist/Contacts/types.js.map +0 -1
- package/dist/Errors/catalog/CallError.js +0 -92
- package/dist/Errors/catalog/CallError.js.map +0 -1
- package/dist/Errors/catalog/CallingDeviceError.js +0 -86
- package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
- package/dist/Errors/catalog/ExtendedError.js +0 -44
- package/dist/Errors/catalog/ExtendedError.js.map +0 -1
- package/dist/Errors/catalog/LineError.js +0 -88
- package/dist/Errors/catalog/LineError.js.map +0 -1
- package/dist/Errors/index.js +0 -28
- package/dist/Errors/index.js.map +0 -1
- package/dist/Errors/types.js +0 -59
- package/dist/Errors/types.js.map +0 -1
- package/dist/Events/impl/index.js +0 -81
- package/dist/Events/impl/index.js.map +0 -1
- package/dist/Events/types.js +0 -107
- package/dist/Events/types.js.map +0 -1
- package/dist/Logger/index.js +0 -228
- package/dist/Logger/index.js.map +0 -1
- package/dist/Logger/index.test.js +0 -87
- package/dist/Logger/index.test.js.map +0 -1
- package/dist/Logger/types.js +0 -34
- package/dist/Logger/types.js.map +0 -1
- package/dist/Metrics/index.js +0 -535
- package/dist/Metrics/index.js.map +0 -1
- package/dist/Metrics/index.test.js +0 -463
- package/dist/Metrics/index.test.js.map +0 -1
- package/dist/Metrics/types.js +0 -64
- package/dist/Metrics/types.js.map +0 -1
- package/dist/SDKConnector/index.js +0 -103
- package/dist/SDKConnector/index.js.map +0 -1
- package/dist/SDKConnector/index.test.js +0 -9
- package/dist/SDKConnector/index.test.js.map +0 -1
- package/dist/SDKConnector/types.js +0 -7
- package/dist/SDKConnector/types.js.map +0 -1
- package/dist/SDKConnector/utils.js +0 -39
- package/dist/SDKConnector/utils.js.map +0 -1
- package/dist/SDKConnector/utils.test.js +0 -9
- package/dist/SDKConnector/utils.test.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +0 -707
- package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -812
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.js +0 -632
- package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +0 -738
- package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/Voicemail.js +0 -500
- package/dist/Voicemail/Voicemail.js.map +0 -1
- package/dist/Voicemail/Voicemail.test.js +0 -391
- package/dist/Voicemail/Voicemail.test.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.js +0 -671
- package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +0 -1199
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/constants.js +0 -61
- package/dist/Voicemail/constants.js.map +0 -1
- package/dist/Voicemail/types.js +0 -7
- package/dist/Voicemail/types.js.map +0 -1
- package/dist/Voicemail/voicemailFixture.js +0 -524
- package/dist/Voicemail/voicemailFixture.js.map +0 -1
- package/dist/api.js +0 -157
- package/dist/api.js.map +0 -1
- package/dist/common/Utils.js +0 -1451
- package/dist/common/Utils.js.map +0 -1
- package/dist/common/Utils.test.js +0 -1744
- package/dist/common/Utils.test.js.map +0 -1
- package/dist/common/constants.js +0 -60
- package/dist/common/constants.js.map +0 -1
- package/dist/common/index.js +0 -19
- package/dist/common/index.js.map +0 -1
- package/dist/common/testUtil.js +0 -982
- package/dist/common/testUtil.js.map +0 -1
- package/dist/common/types.js +0 -75
- package/dist/common/types.js.map +0 -1
- package/dist/index.js +0 -321
- package/dist/index.js.map +0 -1
|
@@ -1,1537 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
-
var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
5
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
6
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
7
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
8
|
-
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
9
|
-
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
10
|
-
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
11
|
-
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
13
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
15
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
16
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
17
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
18
|
-
var _asyncMutex = require("async-mutex");
|
|
19
|
-
var _register = require("./register");
|
|
20
|
-
var _testUtil = require("../../common/testUtil");
|
|
21
|
-
var _types = require("../../common/types");
|
|
22
|
-
var utils = _interopRequireWildcard(require("../../common/Utils"));
|
|
23
|
-
var _Logger = _interopRequireDefault(require("../../Logger"));
|
|
24
|
-
var _types2 = require("../../Logger/types");
|
|
25
|
-
var _registerFixtures = require("./registerFixtures");
|
|
26
|
-
var _common = require("../../common");
|
|
27
|
-
var _types3 = require("../../Errors/types");
|
|
28
|
-
var _constants = require("../constants");
|
|
29
|
-
var _types4 = require("../line/types");
|
|
30
|
-
var _LineError = require("../../Errors/catalog/LineError");
|
|
31
|
-
var _types5 = require("../../Metrics/types");
|
|
32
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
33
|
-
function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
34
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable @typescript-eslint/no-shadow */
|
|
35
|
-
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
36
|
-
var MockServiceData = {
|
|
37
|
-
indicator: _types.ServiceIndicator.CALLING,
|
|
38
|
-
domain: ''
|
|
39
|
-
};
|
|
40
|
-
var logSpy = jest.spyOn(_Logger.default, 'log');
|
|
41
|
-
var infoSpy = jest.spyOn(_Logger.default, 'info');
|
|
42
|
-
var warnSpy = jest.spyOn(_Logger.default, 'warn');
|
|
43
|
-
var handleErrorSpy = jest.spyOn(utils, 'handleRegistrationErrors');
|
|
44
|
-
jest.spyOn(utils, 'uploadLogs').mockResolvedValue();
|
|
45
|
-
describe('Registration Tests', function () {
|
|
46
|
-
var originalProcessNextTick = process.nextTick;
|
|
47
|
-
function flushPromises() {
|
|
48
|
-
return new _promise.default(function (resolve) {
|
|
49
|
-
originalProcessNextTick(resolve);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
var lineEmitter = jest.fn();
|
|
53
|
-
var mobiusUris = (0, _common.filterMobiusUris)((0, _testUtil.getMobiusDiscoveryResponse)(), _registerFixtures.URL);
|
|
54
|
-
var mockResponse = _objectSpread(_objectSpread({}, (0, _testUtil.getMockRequestTemplate)()), {}, {
|
|
55
|
-
uri: "".concat(mobiusUris.primary[0], "device"),
|
|
56
|
-
body: {
|
|
57
|
-
userId: webex.internal.device.userId,
|
|
58
|
-
clientDeviceUri: webex.internal.device.url,
|
|
59
|
-
serviceData: {
|
|
60
|
-
domain: '',
|
|
61
|
-
indicator: 'calling'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
var ccMockResponse = _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
66
|
-
body: _objectSpread(_objectSpread({}, mockResponse.body), {}, {
|
|
67
|
-
serviceData: {
|
|
68
|
-
domain: '',
|
|
69
|
-
indicator: 'contactcenter'
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
});
|
|
73
|
-
var failurePayload = {
|
|
74
|
-
statusCode: 500,
|
|
75
|
-
body: _registerFixtures.mockPostResponse,
|
|
76
|
-
headers: {
|
|
77
|
-
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var failurePayload429One = {
|
|
81
|
-
statusCode: 429,
|
|
82
|
-
body: _registerFixtures.mockPostResponse,
|
|
83
|
-
headers: {
|
|
84
|
-
'retry-after': 42
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var failurePayload429Two = {
|
|
88
|
-
statusCode: 429,
|
|
89
|
-
body: _registerFixtures.mockPostResponse,
|
|
90
|
-
headers: {
|
|
91
|
-
'retry-after': 33
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var failurePayload429Three = {
|
|
95
|
-
statusCode: 429,
|
|
96
|
-
body: _registerFixtures.mockPostResponse,
|
|
97
|
-
headers: {
|
|
98
|
-
'retry-after': 136
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var failurePayload429Four = {
|
|
102
|
-
statusCode: 429,
|
|
103
|
-
body: _registerFixtures.mockPostResponse,
|
|
104
|
-
headers: {
|
|
105
|
-
'retry-after': 81
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var successPayload = {
|
|
109
|
-
statusCode: 200,
|
|
110
|
-
body: _registerFixtures.mockPostResponse,
|
|
111
|
-
headers: {
|
|
112
|
-
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
var reg;
|
|
116
|
-
var restartSpy;
|
|
117
|
-
var restoreSpy;
|
|
118
|
-
var postRegistrationSpy;
|
|
119
|
-
var deregisterSpy;
|
|
120
|
-
var failoverSpy;
|
|
121
|
-
var retry429Spy;
|
|
122
|
-
var metricSpy;
|
|
123
|
-
var setupRegistration = function setupRegistration(mockServiceData) {
|
|
124
|
-
var mutex = new _asyncMutex.Mutex();
|
|
125
|
-
reg = (0, _register.createRegistration)(webex, mockServiceData, mutex, lineEmitter, _types2.LOGGER.INFO);
|
|
126
|
-
reg.setMobiusServers(mobiusUris.primary, mobiusUris.backup);
|
|
127
|
-
jest.clearAllMocks();
|
|
128
|
-
restartSpy = jest.spyOn(reg, 'restartRegistration');
|
|
129
|
-
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
130
|
-
postRegistrationSpy = jest.spyOn(reg, 'postRegistration');
|
|
131
|
-
deregisterSpy = jest.spyOn(reg, 'deregister');
|
|
132
|
-
failoverSpy = jest.spyOn(reg, 'startFailoverTimer');
|
|
133
|
-
retry429Spy = jest.spyOn(reg, 'handle429Retry');
|
|
134
|
-
metricSpy = jest.spyOn(reg.metricManager, 'submitRegistrationMetric');
|
|
135
|
-
};
|
|
136
|
-
beforeEach(function () {
|
|
137
|
-
setupRegistration(MockServiceData);
|
|
138
|
-
});
|
|
139
|
-
afterEach(function () {
|
|
140
|
-
webex.request = jest.fn();
|
|
141
|
-
jest.clearAllTimers();
|
|
142
|
-
jest.clearAllMocks();
|
|
143
|
-
jest.useRealTimers();
|
|
144
|
-
});
|
|
145
|
-
it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
146
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
147
|
-
while (1) switch (_context.prev = _context.next) {
|
|
148
|
-
case 0:
|
|
149
|
-
webex.request.mockReturnValueOnce({
|
|
150
|
-
body: _registerFixtures.mockPostResponse,
|
|
151
|
-
headers: {
|
|
152
|
-
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
_context.next = 3;
|
|
156
|
-
return reg.triggerRegistration();
|
|
157
|
-
case 3:
|
|
158
|
-
expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
159
|
-
method: 'POST'
|
|
160
|
-
}));
|
|
161
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
162
|
-
expect(lineEmitter).toBeCalledTimes(2);
|
|
163
|
-
expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.CONNECTING);
|
|
164
|
-
expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.REGISTERED, _registerFixtures.mockPostResponse);
|
|
165
|
-
|
|
166
|
-
// Check that log.log was called for successful registration
|
|
167
|
-
expect(logSpy).toBeCalledWith("Registration successful for deviceId: ".concat(_registerFixtures.mockPostResponse.device.deviceId, " userId: ").concat(_registerFixtures.mockPostResponse.userId, " responseTrackingId: webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15"), expect.objectContaining({
|
|
168
|
-
file: _constants.REGISTRATION_FILE,
|
|
169
|
-
method: 'register'
|
|
170
|
-
}));
|
|
171
|
-
expect(metricSpy).toBeCalledWith(_types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.REGISTRATION_UTIL, 'PRIMARY', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
|
|
172
|
-
case 10:
|
|
173
|
-
case "end":
|
|
174
|
-
return _context.stop();
|
|
175
|
-
}
|
|
176
|
-
}, _callee);
|
|
177
|
-
})));
|
|
178
|
-
it('verify failure registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
179
|
-
var error;
|
|
180
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
181
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
182
|
-
case 0:
|
|
183
|
-
webex.request.mockRejectedValue({
|
|
184
|
-
body: _registerFixtures.mockPostResponse,
|
|
185
|
-
statusCode: 401,
|
|
186
|
-
headers: {}
|
|
187
|
-
});
|
|
188
|
-
_context2.next = 3;
|
|
189
|
-
return reg.triggerRegistration();
|
|
190
|
-
case 3:
|
|
191
|
-
expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
192
|
-
method: 'POST'
|
|
193
|
-
}));
|
|
194
|
-
error = (0, _LineError.createLineError)('User is unauthorized due to an expired token. Sign out, then sign back in.', {}, _types3.ERROR_TYPE.TOKEN_ERROR, _types.RegistrationStatus.INACTIVE);
|
|
195
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
196
|
-
expect(lineEmitter).toBeCalledTimes(2);
|
|
197
|
-
expect(lineEmitter).nthCalledWith(1, _types4.LINE_EVENTS.CONNECTING);
|
|
198
|
-
expect(lineEmitter).nthCalledWith(2, _types4.LINE_EVENTS.ERROR, undefined, error);
|
|
199
|
-
expect(metricSpy).toBeCalledWith(_types5.METRIC_EVENT.REGISTRATION_ERROR, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.REGISTRATION_UTIL, 'PRIMARY', '', undefined, error);
|
|
200
|
-
case 10:
|
|
201
|
-
case "end":
|
|
202
|
-
return _context2.stop();
|
|
203
|
-
}
|
|
204
|
-
}, _callee2);
|
|
205
|
-
})));
|
|
206
|
-
it('verify failure registration 403-101', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
207
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
208
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
209
|
-
case 0:
|
|
210
|
-
webex.request.mockRejectedValueOnce({
|
|
211
|
-
body: {
|
|
212
|
-
userId: _registerFixtures.mockPostResponse.userId,
|
|
213
|
-
errorCode: 101,
|
|
214
|
-
devices: [_registerFixtures.mockPostResponse.device]
|
|
215
|
-
},
|
|
216
|
-
statusCode: 403
|
|
217
|
-
}).mockResolvedValueOnce({
|
|
218
|
-
statusCode: 200,
|
|
219
|
-
body: _registerFixtures.mockPostResponse,
|
|
220
|
-
headers: {
|
|
221
|
-
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
global.fetch = jest.fn(function () {
|
|
225
|
-
return _promise.default.resolve({
|
|
226
|
-
json: function json() {
|
|
227
|
-
return _registerFixtures.mockDeleteResponse;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
232
|
-
_context3.next = 5;
|
|
233
|
-
return reg.triggerRegistration();
|
|
234
|
-
case 5:
|
|
235
|
-
expect(webex.request).toBeCalledTimes(2);
|
|
236
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
237
|
-
method: 'POST'
|
|
238
|
-
}));
|
|
239
|
-
expect(global.fetch).toBeCalledOnceWith(_registerFixtures.mockPostResponse.device.uri, {
|
|
240
|
-
method: 'DELETE',
|
|
241
|
-
headers: expect.anything()
|
|
242
|
-
});
|
|
243
|
-
expect(warnSpy).toBeCalledWith('User device limit exceeded', expect.anything());
|
|
244
|
-
expect(infoSpy).toBeCalledWith('Registration restoration in progress.', expect.anything());
|
|
245
|
-
expect(infoSpy).toBeCalledWith('Registration restored successfully.', expect.anything());
|
|
246
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
247
|
-
expect(lineEmitter).toBeCalledTimes(4);
|
|
248
|
-
expect(lineEmitter).nthCalledWith(1, _types4.LINE_EVENTS.CONNECTING);
|
|
249
|
-
expect(lineEmitter).nthCalledWith(2, _types4.LINE_EVENTS.UNREGISTERED);
|
|
250
|
-
expect(lineEmitter).nthCalledWith(3, _types4.LINE_EVENTS.CONNECTING);
|
|
251
|
-
expect(lineEmitter).nthCalledWith(4, _types4.LINE_EVENTS.REGISTERED, _registerFixtures.mockPostResponse);
|
|
252
|
-
expect(metricSpy).toBeCalledWith(_types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.REGISTRATION_UTIL, 'UNKNOWN', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
|
|
253
|
-
case 18:
|
|
254
|
-
case "end":
|
|
255
|
-
return _context3.stop();
|
|
256
|
-
}
|
|
257
|
-
}, _callee3);
|
|
258
|
-
})));
|
|
259
|
-
describe('429 handling tests', function () {
|
|
260
|
-
var loggerContext = {
|
|
261
|
-
file: _constants.REGISTRATION_FILE,
|
|
262
|
-
method: _constants.FAILOVER_UTIL
|
|
263
|
-
};
|
|
264
|
-
var logSpy = jest.spyOn(_Logger.default, 'log');
|
|
265
|
-
beforeEach(function () {
|
|
266
|
-
mobiusUris.backup.pop();
|
|
267
|
-
});
|
|
268
|
-
afterEach(function () {
|
|
269
|
-
mobiusUris.backup.push(_registerFixtures.URL);
|
|
270
|
-
jest.clearAllMocks();
|
|
271
|
-
});
|
|
272
|
-
it('handle 429 received during initial registration failure and first attempt with primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
273
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
274
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
275
|
-
case 0:
|
|
276
|
-
jest.useFakeTimers();
|
|
277
|
-
logSpy.mockClear();
|
|
278
|
-
webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Two).mockRejectedValueOnce(failurePayload);
|
|
279
|
-
_context4.next = 5;
|
|
280
|
-
return reg.triggerRegistration();
|
|
281
|
-
case 5:
|
|
282
|
-
/* Initial registration failed with 429 with higher retyrAfter, interval should be updtaed with retryAfter.
|
|
283
|
-
* The first attempt to register with primary should be made after retryAfter seconds.
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
287
|
-
method: 'POST',
|
|
288
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
289
|
-
}));
|
|
290
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
291
|
-
expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'triggerRegistration');
|
|
292
|
-
expect(reg.retryAfter).toEqual(failurePayload429One.headers['retry-after']);
|
|
293
|
-
expect(failoverSpy).toBeCalledOnceWith();
|
|
294
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
|
|
295
|
-
retry429Spy.mockClear();
|
|
296
|
-
failoverSpy.mockClear();
|
|
297
|
-
jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
|
|
298
|
-
_context4.next = 16;
|
|
299
|
-
return flushPromises();
|
|
300
|
-
case 16:
|
|
301
|
-
/* The first attempt to register with primary failed with 429 with lower retryAfter, interval should remain the same.
|
|
302
|
-
* The second attempt to register with primary will be scheduled as per the interval calculated.
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
306
|
-
method: 'POST',
|
|
307
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
308
|
-
}));
|
|
309
|
-
expect(retry429Spy).toBeCalledOnceWith(failurePayload429Two.headers['retry-after'], 'startFailoverTimer');
|
|
310
|
-
expect(reg.retryAfter).toEqual(failurePayload429Two.headers['retry-after']);
|
|
311
|
-
expect(failoverSpy).toBeCalledOnceWith(2, failurePayload429One.headers['retry-after']);
|
|
312
|
-
retry429Spy.mockClear();
|
|
313
|
-
failoverSpy.mockClear();
|
|
314
|
-
jest.advanceTimersByTime(43 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
315
|
-
_context4.next = 25;
|
|
316
|
-
return flushPromises();
|
|
317
|
-
case 25:
|
|
318
|
-
/* The second attempt to register with primary failed with 500, the retryAfter should be undefined.
|
|
319
|
-
* The third attempt to register with primary will be scheduled as per the interval calculated.
|
|
320
|
-
*/
|
|
321
|
-
expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
322
|
-
method: 'POST',
|
|
323
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
324
|
-
}));
|
|
325
|
-
expect(retry429Spy).not.toBeCalled();
|
|
326
|
-
expect(reg.retryAfter).toEqual(undefined);
|
|
327
|
-
expect(failoverSpy).toBeCalledOnceWith(3, 85);
|
|
328
|
-
case 29:
|
|
329
|
-
case "end":
|
|
330
|
-
return _context4.stop();
|
|
331
|
-
}
|
|
332
|
-
}, _callee4);
|
|
333
|
-
})));
|
|
334
|
-
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() {
|
|
335
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
336
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
337
|
-
case 0:
|
|
338
|
-
reg.isCCFlow = true;
|
|
339
|
-
jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
|
|
340
|
-
jest.useFakeTimers();
|
|
341
|
-
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
|
|
342
|
-
_context5.next = 6;
|
|
343
|
-
return reg.triggerRegistration();
|
|
344
|
-
case 6:
|
|
345
|
-
expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
346
|
-
method: 'POST',
|
|
347
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
348
|
-
}));
|
|
349
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
350
|
-
expect(retry429Spy).not.toBeCalled();
|
|
351
|
-
expect(failoverSpy).toBeCalledOnceWith();
|
|
352
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
|
|
353
|
-
failoverSpy.mockClear();
|
|
354
|
-
jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
355
|
-
_context5.next = 15;
|
|
356
|
-
return flushPromises();
|
|
357
|
-
case 15:
|
|
358
|
-
expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
359
|
-
method: 'POST',
|
|
360
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
361
|
-
}));
|
|
362
|
-
expect(retry429Spy).not.toBeCalled();
|
|
363
|
-
expect(failoverSpy).toBeCalledOnceWith(2, 33);
|
|
364
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 2", loggerContext);
|
|
365
|
-
logSpy.mockClear();
|
|
366
|
-
failoverSpy.mockClear();
|
|
367
|
-
jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
368
|
-
_context5.next = 24;
|
|
369
|
-
return flushPromises();
|
|
370
|
-
case 24:
|
|
371
|
-
expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
372
|
-
method: 'POST',
|
|
373
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
374
|
-
}));
|
|
375
|
-
expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
|
|
376
|
-
expect(failoverSpy).toBeCalledOnceWith(3, 73);
|
|
377
|
-
expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 3"), loggerContext);
|
|
378
|
-
expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
|
|
379
|
-
expect(webex.request).toHaveBeenNthCalledWith(4, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
380
|
-
method: 'POST',
|
|
381
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
382
|
-
}));
|
|
383
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
384
|
-
case 31:
|
|
385
|
-
case "end":
|
|
386
|
-
return _context5.stop();
|
|
387
|
-
}
|
|
388
|
-
}, _callee5);
|
|
389
|
-
})));
|
|
390
|
-
it('handle 429 received while the last attempt for primary', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
391
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
392
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
393
|
-
case 0:
|
|
394
|
-
reg.isCCFlow = true;
|
|
395
|
-
jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(33).mockReturnValueOnce(40).mockReturnValueOnce(47).mockReturnValueOnce(52);
|
|
396
|
-
jest.useFakeTimers();
|
|
397
|
-
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
|
|
398
|
-
_context6.next = 6;
|
|
399
|
-
return reg.triggerRegistration();
|
|
400
|
-
case 6:
|
|
401
|
-
/* Initial registration and first 2 attempts with primary failed with non-final 5xx error responses.
|
|
402
|
-
* Last attempt with primary failed with 429, the retryAfter should be used to schedule the next attempt but
|
|
403
|
-
* the failover is triggered before the scheduling logic kicks in.
|
|
404
|
-
*/
|
|
405
|
-
expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
406
|
-
method: 'POST',
|
|
407
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
408
|
-
}));
|
|
409
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
410
|
-
expect(retry429Spy).not.toBeCalled();
|
|
411
|
-
expect(failoverSpy).toBeCalledOnceWith();
|
|
412
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with primary in 33 seconds, number of attempts : 1", loggerContext);
|
|
413
|
-
failoverSpy.mockClear();
|
|
414
|
-
jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
415
|
-
_context6.next = 15;
|
|
416
|
-
return flushPromises();
|
|
417
|
-
case 15:
|
|
418
|
-
expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
419
|
-
method: 'POST',
|
|
420
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
421
|
-
}));
|
|
422
|
-
expect(retry429Spy).not.toBeCalled();
|
|
423
|
-
expect(failoverSpy).toBeCalledOnceWith(2, 33);
|
|
424
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 2", loggerContext);
|
|
425
|
-
logSpy.mockClear();
|
|
426
|
-
failoverSpy.mockClear();
|
|
427
|
-
jest.advanceTimersByTime(40 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
428
|
-
_context6.next = 24;
|
|
429
|
-
return flushPromises();
|
|
430
|
-
case 24:
|
|
431
|
-
expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
432
|
-
method: 'POST',
|
|
433
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
434
|
-
}));
|
|
435
|
-
expect(retry429Spy).not.toBeCalled();
|
|
436
|
-
expect(failoverSpy).toBeCalledOnceWith(3, 73);
|
|
437
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with primary in 41 seconds, number of attempts : 3", loggerContext);
|
|
438
|
-
failoverSpy.mockClear();
|
|
439
|
-
jest.advanceTimersByTime(41 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
440
|
-
_context6.next = 32;
|
|
441
|
-
return flushPromises();
|
|
442
|
-
case 32:
|
|
443
|
-
expect(webex.request).toHaveBeenNthCalledWith(4, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
444
|
-
method: 'POST',
|
|
445
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
446
|
-
}));
|
|
447
|
-
expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
|
|
448
|
-
expect(failoverSpy).toBeCalledOnceWith(4, 114);
|
|
449
|
-
expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
|
|
450
|
-
expect(webex.request).toHaveBeenNthCalledWith(5, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
451
|
-
method: 'POST',
|
|
452
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
453
|
-
}));
|
|
454
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
455
|
-
case 38:
|
|
456
|
-
case "end":
|
|
457
|
-
return _context6.stop();
|
|
458
|
-
}
|
|
459
|
-
}, _callee6);
|
|
460
|
-
})));
|
|
461
|
-
it('handle 429 received while failing over to backup server for CC flow', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
462
|
-
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
463
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
464
|
-
case 0:
|
|
465
|
-
reg.isCCFlow = true;
|
|
466
|
-
jest.useFakeTimers();
|
|
467
|
-
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload429One).mockResolvedValueOnce(successPayload);
|
|
468
|
-
_context7.next = 5;
|
|
469
|
-
return reg.triggerRegistration();
|
|
470
|
-
case 5:
|
|
471
|
-
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
472
|
-
_context7.next = 8;
|
|
473
|
-
return flushPromises();
|
|
474
|
-
case 8:
|
|
475
|
-
expect(webex.request).toBeCalledTimes(3);
|
|
476
|
-
expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
477
|
-
method: 'POST',
|
|
478
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
479
|
-
}));
|
|
480
|
-
expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
481
|
-
method: 'POST',
|
|
482
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
483
|
-
}));
|
|
484
|
-
|
|
485
|
-
/* Failover to backup server failed with 429, the retryAfter is used to schedule the next attempt with backup server.
|
|
486
|
-
* Interval will be updated with retryAfter as interval calculated is less than the retryAfter.
|
|
487
|
-
*/
|
|
488
|
-
expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
489
|
-
method: 'POST',
|
|
490
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
491
|
-
}));
|
|
492
|
-
expect(retry429Spy).toBeCalledOnceWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
|
|
493
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with backup servers in ".concat(failurePayload429One.headers['retry-after'], " seconds."), loggerContext);
|
|
494
|
-
webex.request.mockClear();
|
|
495
|
-
jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
|
|
496
|
-
_context7.next = 18;
|
|
497
|
-
return flushPromises();
|
|
498
|
-
case 18:
|
|
499
|
-
expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
500
|
-
method: 'POST',
|
|
501
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
502
|
-
}));
|
|
503
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
504
|
-
case 20:
|
|
505
|
-
case "end":
|
|
506
|
-
return _context7.stop();
|
|
507
|
-
}
|
|
508
|
-
}, _callee7);
|
|
509
|
-
})));
|
|
510
|
-
it('checking the retryAfter exceeding the threshold timers in first attempt itself', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
511
|
-
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
512
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
513
|
-
case 0:
|
|
514
|
-
reg.isCCFlow = true;
|
|
515
|
-
jest.useFakeTimers();
|
|
516
|
-
jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(40);
|
|
517
|
-
webex.request.mockRejectedValueOnce(failurePayload429Three);
|
|
518
|
-
_context8.next = 6;
|
|
519
|
-
return reg.triggerRegistration();
|
|
520
|
-
case 6:
|
|
521
|
-
expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
522
|
-
method: 'POST',
|
|
523
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
524
|
-
}));
|
|
525
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
526
|
-
expect(failoverSpy).toBeCalledOnceWith();
|
|
527
|
-
expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
|
|
528
|
-
expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in 40 seconds, number of attempts : 1", loggerContext);
|
|
529
|
-
expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429Three.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
|
|
530
|
-
expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
531
|
-
method: 'POST',
|
|
532
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
533
|
-
}));
|
|
534
|
-
case 13:
|
|
535
|
-
case "end":
|
|
536
|
-
return _context8.stop();
|
|
537
|
-
}
|
|
538
|
-
}, _callee8);
|
|
539
|
-
})));
|
|
540
|
-
it('checking the retryAfter exceeding the threshold timers in later attempts', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
541
|
-
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
542
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
543
|
-
case 0:
|
|
544
|
-
reg.isCCFlow = true;
|
|
545
|
-
jest.useFakeTimers();
|
|
546
|
-
jest.spyOn(reg, 'getRegRetryInterval').mockReturnValueOnce(39).mockReturnValueOnce(43);
|
|
547
|
-
webex.request.mockRejectedValueOnce(failurePayload429One).mockRejectedValueOnce(failurePayload429Four).mockResolvedValueOnce(successPayload);
|
|
548
|
-
_context9.next = 6;
|
|
549
|
-
return reg.triggerRegistration();
|
|
550
|
-
case 6:
|
|
551
|
-
expect(webex.request).toHaveBeenNthCalledWith(1, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
552
|
-
method: 'POST',
|
|
553
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
554
|
-
}));
|
|
555
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
556
|
-
expect(failoverSpy).toBeCalledOnceWith();
|
|
557
|
-
expect(logSpy).toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429One.headers['retry-after'], " seconds, number of attempts : 1"), loggerContext);
|
|
558
|
-
failoverSpy.mockClear();
|
|
559
|
-
jest.advanceTimersByTime(Number(failurePayload429One.headers['retry-after']) * _constants.SEC_TO_MSEC_MFACTOR);
|
|
560
|
-
_context9.next = 14;
|
|
561
|
-
return flushPromises();
|
|
562
|
-
case 14:
|
|
563
|
-
expect(webex.request).toHaveBeenNthCalledWith(2, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
564
|
-
method: 'POST',
|
|
565
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
566
|
-
}));
|
|
567
|
-
expect(failoverSpy).toBeCalledOnceWith(2, failurePayload429One.headers['retry-after']);
|
|
568
|
-
expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in 43 seconds, number of attempts : 2", loggerContext);
|
|
569
|
-
expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
|
|
570
|
-
expect(logSpy).not.toBeCalledWith("Scheduled retry with primary in ".concat(failurePayload429Four.headers['retry-after'], " seconds, number of attempts : 2"), loggerContext);
|
|
571
|
-
expect(infoSpy).toBeCalledWith("Failing over to backup servers.", loggerContext);
|
|
572
|
-
expect(webex.request).toHaveBeenNthCalledWith(3, _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
573
|
-
method: 'POST',
|
|
574
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
575
|
-
}));
|
|
576
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
577
|
-
case 22:
|
|
578
|
-
case "end":
|
|
579
|
-
return _context9.stop();
|
|
580
|
-
}
|
|
581
|
-
}, _callee9);
|
|
582
|
-
})));
|
|
583
|
-
});
|
|
584
|
-
describe('Registration failover tests', function () {
|
|
585
|
-
it('verify unreachable primary with reachable backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
586
|
-
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
587
|
-
while (1) switch (_context0.prev = _context0.next) {
|
|
588
|
-
case 0:
|
|
589
|
-
jest.useFakeTimers();
|
|
590
|
-
// try the primary twice and register successfully with backup servers
|
|
591
|
-
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
592
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
593
|
-
_context0.next = 5;
|
|
594
|
-
return reg.triggerRegistration();
|
|
595
|
-
case 5:
|
|
596
|
-
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
597
|
-
_context0.next = 8;
|
|
598
|
-
return flushPromises();
|
|
599
|
-
case 8:
|
|
600
|
-
expect(webex.request).toBeCalledTimes(3);
|
|
601
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
602
|
-
method: 'POST',
|
|
603
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
604
|
-
}));
|
|
605
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
606
|
-
method: 'POST',
|
|
607
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
608
|
-
}));
|
|
609
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
610
|
-
/* Active Url must match with the backup url as per the test */
|
|
611
|
-
expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
|
|
612
|
-
expect(metricSpy).toHaveBeenNthCalledWith(3, _types5.METRIC_EVENT.REGISTRATION, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, _constants.FAILOVER_UTIL, 'BACKUP', 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15', undefined, undefined);
|
|
613
|
-
case 14:
|
|
614
|
-
case "end":
|
|
615
|
-
return _context0.stop();
|
|
616
|
-
}
|
|
617
|
-
}, _callee0);
|
|
618
|
-
})));
|
|
619
|
-
it('cc: verify unreachable primary with reachable backup server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
620
|
-
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
621
|
-
while (1) switch (_context1.prev = _context1.next) {
|
|
622
|
-
case 0:
|
|
623
|
-
setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
|
|
624
|
-
indicator: _types.ServiceIndicator.CONTACT_CENTER
|
|
625
|
-
}));
|
|
626
|
-
jest.useFakeTimers();
|
|
627
|
-
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
628
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
629
|
-
_context1.next = 6;
|
|
630
|
-
return reg.triggerRegistration();
|
|
631
|
-
case 6:
|
|
632
|
-
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
633
|
-
_context1.next = 9;
|
|
634
|
-
return flushPromises();
|
|
635
|
-
case 9:
|
|
636
|
-
expect(webex.request).toBeCalledTimes(3);
|
|
637
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, ccMockResponse), {}, {
|
|
638
|
-
method: 'POST',
|
|
639
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
640
|
-
}));
|
|
641
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, ccMockResponse), {}, {
|
|
642
|
-
method: 'POST',
|
|
643
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
644
|
-
}));
|
|
645
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
646
|
-
/* Active Url must match with the backup url as per the test */
|
|
647
|
-
expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
|
|
648
|
-
case 14:
|
|
649
|
-
case "end":
|
|
650
|
-
return _context1.stop();
|
|
651
|
-
}
|
|
652
|
-
}, _callee1);
|
|
653
|
-
})));
|
|
654
|
-
it('verify unreachable primary and backup servers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
655
|
-
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
656
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
657
|
-
case 0:
|
|
658
|
-
jest.useFakeTimers();
|
|
659
|
-
// try the primary twice and register successfully with backup servers
|
|
660
|
-
webex.request.mockRejectedValue(failurePayload);
|
|
661
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
662
|
-
_context10.next = 5;
|
|
663
|
-
return reg.triggerRegistration();
|
|
664
|
-
case 5:
|
|
665
|
-
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
666
|
-
_context10.next = 8;
|
|
667
|
-
return flushPromises();
|
|
668
|
-
case 8:
|
|
669
|
-
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
670
|
-
_context10.next = 11;
|
|
671
|
-
return flushPromises();
|
|
672
|
-
case 11:
|
|
673
|
-
/*
|
|
674
|
-
* 2 calls for primary -> initial and after timer expiry.
|
|
675
|
-
* 2 calls for each backup entry -> 2 * 2 = 4.
|
|
676
|
-
* So a total of 6 calls to webex.request and handleErrors
|
|
677
|
-
*/
|
|
678
|
-
expect(webex.request).toBeCalledTimes(6);
|
|
679
|
-
expect(handleErrorSpy).toBeCalledTimes(6);
|
|
680
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
681
|
-
method: 'POST',
|
|
682
|
-
uri: "".concat(mobiusUris.primary[0], "device")
|
|
683
|
-
}));
|
|
684
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
685
|
-
method: 'POST',
|
|
686
|
-
uri: "".concat(mobiusUris.backup[0], "device")
|
|
687
|
-
}));
|
|
688
|
-
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
689
|
-
method: 'POST',
|
|
690
|
-
uri: "".concat(mobiusUris.backup[1], "device")
|
|
691
|
-
}));
|
|
692
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
693
|
-
case 17:
|
|
694
|
-
case "end":
|
|
695
|
-
return _context10.stop();
|
|
696
|
-
}
|
|
697
|
-
}, _callee10);
|
|
698
|
-
})));
|
|
699
|
-
});
|
|
700
|
-
describe('Registration failback tests', function () {
|
|
701
|
-
var isPrimaryActiveSpy;
|
|
702
|
-
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
703
|
-
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
704
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
705
|
-
case 0:
|
|
706
|
-
isPrimaryActiveSpy = jest.spyOn(reg, 'isPrimaryActive');
|
|
707
|
-
isPrimaryActiveSpy.mockReturnValue(true);
|
|
708
|
-
/* keep keepalive as active so that it wont interfere with the failback tests */
|
|
709
|
-
jest.useFakeTimers();
|
|
710
|
-
postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValueOnce(successPayload);
|
|
711
|
-
_context11.next = 6;
|
|
712
|
-
return reg.triggerRegistration();
|
|
713
|
-
case 6:
|
|
714
|
-
jest.advanceTimersByTime(_constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC * _constants.SEC_TO_MSEC_MFACTOR);
|
|
715
|
-
_context11.next = 9;
|
|
716
|
-
return flushPromises();
|
|
717
|
-
case 9:
|
|
718
|
-
reg.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
|
|
719
|
-
reg.rehomingIntervalMax = _constants.DEFAULT_REHOMING_INTERVAL_MAX;
|
|
720
|
-
|
|
721
|
-
/* These 2 calls to handleErrorSpy are for primary after which it fails over to backup */
|
|
722
|
-
expect(handleErrorSpy).toBeCalledTimes(2);
|
|
723
|
-
|
|
724
|
-
/* Active Url must match with the backup url as per the test */
|
|
725
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
|
|
726
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
727
|
-
case 14:
|
|
728
|
-
case "end":
|
|
729
|
-
return _context11.stop();
|
|
730
|
-
}
|
|
731
|
-
}, _callee11);
|
|
732
|
-
})));
|
|
733
|
-
afterEach(function () {
|
|
734
|
-
jest.clearAllTimers();
|
|
735
|
-
jest.clearAllMocks();
|
|
736
|
-
});
|
|
737
|
-
it('verify 429 error with failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
738
|
-
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
739
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
740
|
-
case 0:
|
|
741
|
-
// delete should be successful
|
|
742
|
-
global.fetch = jest.fn(function () {
|
|
743
|
-
return _promise.default.resolve({
|
|
744
|
-
json: function json() {
|
|
745
|
-
return _registerFixtures.mockDeleteResponse;
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
});
|
|
749
|
-
postRegistrationSpy.mockRejectedValue(failurePayload429Two);
|
|
750
|
-
|
|
751
|
-
/* Wait for failback to be triggered. */
|
|
752
|
-
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
753
|
-
_context12.next = 5;
|
|
754
|
-
return flushPromises();
|
|
755
|
-
case 5:
|
|
756
|
-
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
757
|
-
method: 'executeFailback',
|
|
758
|
-
file: _constants.REGISTRATION_FILE
|
|
759
|
-
});
|
|
760
|
-
jest.advanceTimersByTime(10000);
|
|
761
|
-
_context12.next = 9;
|
|
762
|
-
return flushPromises();
|
|
763
|
-
case 9:
|
|
764
|
-
expect(retry429Spy).toBeCalledWith(failurePayload429Two.headers['retry-after'], 'executeFailback');
|
|
765
|
-
expect(reg.failback429RetryAttempts).toBe(0);
|
|
766
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
767
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.REG_429_RETRY_UTIL);
|
|
768
|
-
expect(restartSpy).toBeCalledOnceWith(_constants.REG_429_RETRY_UTIL);
|
|
769
|
-
expect(reg.failbackTimer).toBe(undefined);
|
|
770
|
-
expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
|
|
771
|
-
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
772
|
-
case 17:
|
|
773
|
-
case "end":
|
|
774
|
-
return _context12.stop();
|
|
775
|
-
}
|
|
776
|
-
}, _callee12);
|
|
777
|
-
})));
|
|
778
|
-
it('verify unsuccessful failback to primary after initial registration with backup: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
779
|
-
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
780
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
781
|
-
case 0:
|
|
782
|
-
postRegistrationSpy.mockRejectedValue(failurePayload);
|
|
783
|
-
|
|
784
|
-
/* Wait for failback to be triggered. */
|
|
785
|
-
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
786
|
-
_context13.next = 4;
|
|
787
|
-
return flushPromises();
|
|
788
|
-
case 4:
|
|
789
|
-
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
790
|
-
method: 'executeFailback',
|
|
791
|
-
file: _constants.REGISTRATION_FILE
|
|
792
|
-
});
|
|
793
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
794
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
|
|
795
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
796
|
-
expect(restartSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
|
|
797
|
-
expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
|
|
798
|
-
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
799
|
-
case 11:
|
|
800
|
-
case "end":
|
|
801
|
-
return _context13.stop();
|
|
802
|
-
}
|
|
803
|
-
}, _callee13);
|
|
804
|
-
})));
|
|
805
|
-
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 _callee14() {
|
|
806
|
-
var finalErrorPayload;
|
|
807
|
-
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
808
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
809
|
-
case 0:
|
|
810
|
-
finalErrorPayload = {
|
|
811
|
-
statusCode: 401,
|
|
812
|
-
body: _registerFixtures.mockPostResponse
|
|
813
|
-
};
|
|
814
|
-
postRegistrationSpy.mockClear();
|
|
815
|
-
postRegistrationSpy.mockRejectedValue(finalErrorPayload).mockRejectedValueOnce(failurePayload);
|
|
816
|
-
/* Wait for failback to be triggered. */
|
|
817
|
-
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
818
|
-
_context14.next = 6;
|
|
819
|
-
return flushPromises();
|
|
820
|
-
case 6:
|
|
821
|
-
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
822
|
-
method: 'executeFailback',
|
|
823
|
-
file: _constants.REGISTRATION_FILE
|
|
824
|
-
});
|
|
825
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
826
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
|
|
827
|
-
expect(restartSpy).not.toBeCalled();
|
|
828
|
-
expect(reg.failbackTimer).toBe(undefined);
|
|
829
|
-
expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
|
|
830
|
-
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
831
|
-
case 13:
|
|
832
|
-
case "end":
|
|
833
|
-
return _context14.stop();
|
|
834
|
-
}
|
|
835
|
-
}, _callee14);
|
|
836
|
-
})));
|
|
837
|
-
it('verify unsuccessful failback to primary after initial registration with backup: Restore success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
838
|
-
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
839
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
840
|
-
case 0:
|
|
841
|
-
postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
|
|
842
|
-
|
|
843
|
-
/* Wait for failback to be triggered. */
|
|
844
|
-
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
845
|
-
_context15.next = 4;
|
|
846
|
-
return flushPromises();
|
|
847
|
-
case 4:
|
|
848
|
-
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
849
|
-
method: 'executeFailback',
|
|
850
|
-
file: _constants.REGISTRATION_FILE
|
|
851
|
-
});
|
|
852
|
-
/* Active Url should still match backup url */
|
|
853
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
|
|
854
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
855
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.FAILBACK_UTIL);
|
|
856
|
-
expect(restartSpy).not.toBeCalled();
|
|
857
|
-
expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
|
|
858
|
-
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
859
|
-
case 11:
|
|
860
|
-
case "end":
|
|
861
|
-
return _context15.stop();
|
|
862
|
-
}
|
|
863
|
-
}, _callee15);
|
|
864
|
-
})));
|
|
865
|
-
it('verify successful failback to primary after initial registration with backup', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
866
|
-
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
867
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
868
|
-
case 0:
|
|
869
|
-
postRegistrationSpy.mockResolvedValue(successPayload);
|
|
870
|
-
|
|
871
|
-
/* Wait for failback to be triggered. */
|
|
872
|
-
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
873
|
-
_context16.next = 4;
|
|
874
|
-
return flushPromises();
|
|
875
|
-
case 4:
|
|
876
|
-
expect(infoSpy).toBeCalledWith("Attempting failback to primary.", {
|
|
877
|
-
method: 'executeFailback',
|
|
878
|
-
file: _constants.REGISTRATION_FILE
|
|
879
|
-
});
|
|
880
|
-
|
|
881
|
-
/* Active Url must now match with the primary url */
|
|
882
|
-
expect(deregisterSpy).toBeCalledOnceWith();
|
|
883
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.primary[0]);
|
|
884
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
885
|
-
expect(reg.failbackTimer).toBe(undefined);
|
|
886
|
-
expect(restoreSpy).not.toBeCalled();
|
|
887
|
-
expect(reg.rehomingIntervalMin).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMin);
|
|
888
|
-
expect(reg.rehomingIntervalMax).toBe(_registerFixtures.mockPostResponse.rehomingIntervalMax);
|
|
889
|
-
case 12:
|
|
890
|
-
case "end":
|
|
891
|
-
return _context16.stop();
|
|
892
|
-
}
|
|
893
|
-
}, _callee16);
|
|
894
|
-
})));
|
|
895
|
-
it('verify unsuccessful failback attempt due to active call', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
896
|
-
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
897
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
898
|
-
case 0:
|
|
899
|
-
/** create a new call */
|
|
900
|
-
reg.callManager.createCall();
|
|
901
|
-
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
|
|
902
|
-
postRegistrationSpy.mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
|
|
903
|
-
|
|
904
|
-
/* Wait for failback to be triggered. */
|
|
905
|
-
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
906
|
-
_context17.next = 6;
|
|
907
|
-
return flushPromises();
|
|
908
|
-
case 6:
|
|
909
|
-
expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
|
|
910
|
-
method: 'executeFailback',
|
|
911
|
-
file: _constants.REGISTRATION_FILE
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
/* Active Url should still match backup url */
|
|
915
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
|
|
916
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
917
|
-
expect(deregisterSpy).not.toBeCalled();
|
|
918
|
-
expect(restoreSpy).not.toBeCalled();
|
|
919
|
-
expect(restartSpy).not.toBeCalled();
|
|
920
|
-
expect(infoSpy).toBeCalledWith('Active calls present or primary Mobius is down, deferring failback to next cycle.', {
|
|
921
|
-
file: _constants.REGISTRATION_FILE,
|
|
922
|
-
method: _constants.FAILBACK_UTIL
|
|
923
|
-
});
|
|
924
|
-
expect(reg.rehomingIntervalMin).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MIN);
|
|
925
|
-
expect(reg.rehomingIntervalMax).toBe(_constants.DEFAULT_REHOMING_INTERVAL_MAX);
|
|
926
|
-
case 15:
|
|
927
|
-
case "end":
|
|
928
|
-
return _context17.stop();
|
|
929
|
-
}
|
|
930
|
-
}, _callee17);
|
|
931
|
-
})));
|
|
932
|
-
it('verify unsuccessful failback attempt due to primary server being down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
933
|
-
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
934
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
935
|
-
case 0:
|
|
936
|
-
isPrimaryActiveSpy.mockReturnValue(false);
|
|
937
|
-
|
|
938
|
-
/* Wait for failback to be triggered. */
|
|
939
|
-
jest.advanceTimersByTime(reg.rehomingIntervalMax * _constants.MINUTES_TO_SEC_MFACTOR * _constants.SEC_TO_MSEC_MFACTOR);
|
|
940
|
-
_context18.next = 4;
|
|
941
|
-
return flushPromises();
|
|
942
|
-
case 4:
|
|
943
|
-
expect(infoSpy).toBeCalledWith("Active calls present or primary Mobius is down, deferring failback to next cycle.", {
|
|
944
|
-
method: 'executeFailback',
|
|
945
|
-
file: _constants.REGISTRATION_FILE
|
|
946
|
-
});
|
|
947
|
-
|
|
948
|
-
/* Active Url should still match backup url */
|
|
949
|
-
expect(deregisterSpy).not.toBeCalled();
|
|
950
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(mobiusUris.backup[0]);
|
|
951
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
952
|
-
case 8:
|
|
953
|
-
case "end":
|
|
954
|
-
return _context18.stop();
|
|
955
|
-
}
|
|
956
|
-
}, _callee18);
|
|
957
|
-
})));
|
|
958
|
-
});
|
|
959
|
-
|
|
960
|
-
// Keep-alive related test cases
|
|
961
|
-
describe('Keep-alive Tests', function () {
|
|
962
|
-
var beforeEachSetupForKeepalive = /*#__PURE__*/function () {
|
|
963
|
-
var _ref19 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
964
|
-
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
965
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
966
|
-
case 0:
|
|
967
|
-
postRegistrationSpy.mockResolvedValueOnce(successPayload);
|
|
968
|
-
jest.useFakeTimers();
|
|
969
|
-
_context19.next = 4;
|
|
970
|
-
return reg.triggerRegistration();
|
|
971
|
-
case 4:
|
|
972
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
973
|
-
expect(reg.webWorker).toBeDefined();
|
|
974
|
-
case 6:
|
|
975
|
-
case "end":
|
|
976
|
-
return _context19.stop();
|
|
977
|
-
}
|
|
978
|
-
}, _callee19);
|
|
979
|
-
}));
|
|
980
|
-
return function beforeEachSetupForKeepalive() {
|
|
981
|
-
return _ref19.apply(this, arguments);
|
|
982
|
-
};
|
|
983
|
-
}();
|
|
984
|
-
afterEach(function () {
|
|
985
|
-
jest.clearAllTimers();
|
|
986
|
-
jest.clearAllMocks();
|
|
987
|
-
reg.clearKeepaliveTimer();
|
|
988
|
-
reg.reconnectPending = false;
|
|
989
|
-
var calls = (0, _values.default)(reg.callManager.getActiveCalls());
|
|
990
|
-
calls.forEach(function (call) {
|
|
991
|
-
call.end();
|
|
992
|
-
});
|
|
993
|
-
});
|
|
994
|
-
it('verify successful keep-alive cases', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
995
|
-
var postMessageSpy;
|
|
996
|
-
return _regenerator.default.wrap(function _callee20$(_context20) {
|
|
997
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
998
|
-
case 0:
|
|
999
|
-
postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
|
|
1000
|
-
_context20.next = 3;
|
|
1001
|
-
return beforeEachSetupForKeepalive();
|
|
1002
|
-
case 3:
|
|
1003
|
-
expect(reg.webWorker).toBeDefined();
|
|
1004
|
-
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1005
|
-
type: 'START_KEEPALIVE',
|
|
1006
|
-
accessToken: expect.any(String),
|
|
1007
|
-
deviceUrl: expect.any(String),
|
|
1008
|
-
interval: expect.any(Number),
|
|
1009
|
-
retryCountThreshold: expect.any(Number),
|
|
1010
|
-
url: expect.any(String)
|
|
1011
|
-
}));
|
|
1012
|
-
reg.webWorker.onmessage({
|
|
1013
|
-
data: {
|
|
1014
|
-
type: 'KEEPALIVE_SUCCESS',
|
|
1015
|
-
statusCode: 200
|
|
1016
|
-
}
|
|
1017
|
-
});
|
|
1018
|
-
expect(lineEmitter).toBeCalledWith(_types4.LINE_EVENTS.RECONNECTED);
|
|
1019
|
-
case 7:
|
|
1020
|
-
case "end":
|
|
1021
|
-
return _context20.stop();
|
|
1022
|
-
}
|
|
1023
|
-
}, _callee20);
|
|
1024
|
-
})));
|
|
1025
|
-
it('verify failure keep-alive cases: Retry Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
1026
|
-
var worker;
|
|
1027
|
-
return _regenerator.default.wrap(function _callee21$(_context21) {
|
|
1028
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
1029
|
-
case 0:
|
|
1030
|
-
_context21.next = 2;
|
|
1031
|
-
return beforeEachSetupForKeepalive();
|
|
1032
|
-
case 2:
|
|
1033
|
-
worker = reg.webWorker;
|
|
1034
|
-
lineEmitter.mockClear();
|
|
1035
|
-
worker.onmessage({
|
|
1036
|
-
data: {
|
|
1037
|
-
type: 'KEEPALIVE_FAILURE',
|
|
1038
|
-
err: {
|
|
1039
|
-
statusCode: 503
|
|
1040
|
-
},
|
|
1041
|
-
keepAliveRetryCount: 1
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
worker.onmessage({
|
|
1045
|
-
data: {
|
|
1046
|
-
type: 'KEEPALIVE_SUCCESS',
|
|
1047
|
-
statusCode: 200
|
|
1048
|
-
}
|
|
1049
|
-
});
|
|
1050
|
-
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTED);
|
|
1051
|
-
case 7:
|
|
1052
|
-
case "end":
|
|
1053
|
-
return _context21.stop();
|
|
1054
|
-
}
|
|
1055
|
-
}, _callee21);
|
|
1056
|
-
})));
|
|
1057
|
-
it('verify failure keep-alive cases: Restore failure', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
1058
|
-
var reconnectSpy, restoreSpy, restartRegSpy, RETRY_COUNT_THRESHOLD, failureEvent;
|
|
1059
|
-
return _regenerator.default.wrap(function _callee22$(_context22) {
|
|
1060
|
-
while (1) switch (_context22.prev = _context22.next) {
|
|
1061
|
-
case 0:
|
|
1062
|
-
_context22.next = 2;
|
|
1063
|
-
return beforeEachSetupForKeepalive();
|
|
1064
|
-
case 2:
|
|
1065
|
-
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1066
|
-
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
1067
|
-
restartRegSpy = jest.spyOn(reg, 'restartRegistration'); // Clear previous event emissions
|
|
1068
|
-
lineEmitter.mockClear();
|
|
1069
|
-
|
|
1070
|
-
// Assume registration is active
|
|
1071
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1072
|
-
|
|
1073
|
-
// Use fake timers to trigger keepalive initialization
|
|
1074
|
-
jest.useFakeTimers();
|
|
1075
|
-
jest.advanceTimersByTime(_registerFixtures.mockPostResponse.keepaliveInterval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1076
|
-
|
|
1077
|
-
// Simulate the worker sending a KEEPALIVE_FAILURE message with retry count at threshold.
|
|
1078
|
-
RETRY_COUNT_THRESHOLD = reg.isCCFlow ? 4 : 5;
|
|
1079
|
-
failureEvent = {
|
|
1080
|
-
data: {
|
|
1081
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1082
|
-
err: {
|
|
1083
|
-
statusCode: 503
|
|
1084
|
-
},
|
|
1085
|
-
keepAliveRetryCount: RETRY_COUNT_THRESHOLD
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
reg.webWorker.onmessage(failureEvent);
|
|
1089
|
-
_context22.next = 14;
|
|
1090
|
-
return flushPromises();
|
|
1091
|
-
case 14:
|
|
1092
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
1093
|
-
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1094
|
-
expect(reconnectSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1095
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1096
|
-
expect(restartRegSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1097
|
-
jest.useRealTimers();
|
|
1098
|
-
expect(warnSpy).toHaveBeenCalledWith('Keep-alive missed 5 times. Status -> 503 ', expect.objectContaining({
|
|
1099
|
-
file: _constants.REGISTRATION_FILE,
|
|
1100
|
-
method: 'startKeepaliveTimer'
|
|
1101
|
-
}));
|
|
1102
|
-
case 21:
|
|
1103
|
-
case "end":
|
|
1104
|
-
return _context22.stop();
|
|
1105
|
-
}
|
|
1106
|
-
}, _callee22);
|
|
1107
|
-
})));
|
|
1108
|
-
it('verify failure keep-alive cases: Restore Success', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
1109
|
-
var reconnectSpy, url;
|
|
1110
|
-
return _regenerator.default.wrap(function _callee23$(_context23) {
|
|
1111
|
-
while (1) switch (_context23.prev = _context23.next) {
|
|
1112
|
-
case 0:
|
|
1113
|
-
_context23.next = 2;
|
|
1114
|
-
return beforeEachSetupForKeepalive();
|
|
1115
|
-
case 2:
|
|
1116
|
-
expect(reg.webWorker).toBeDefined();
|
|
1117
|
-
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1118
|
-
url = 'https://mobius-dfw.webex.com/api/v1/calling/web/';
|
|
1119
|
-
reg.webWorker.onmessage({
|
|
1120
|
-
data: {
|
|
1121
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1122
|
-
err: {
|
|
1123
|
-
statusCode: 503
|
|
1124
|
-
},
|
|
1125
|
-
keepAliveRetryCount: 5
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
jest.advanceTimersByTime(1000);
|
|
1129
|
-
_context23.next = 9;
|
|
1130
|
-
return flushPromises();
|
|
1131
|
-
case 9:
|
|
1132
|
-
expect(reg.webWorker).toBeUndefined();
|
|
1133
|
-
expect(reconnectSpy).toBeCalledOnceWith(reg.startKeepaliveTimer.name);
|
|
1134
|
-
webex.request.mockResolvedValueOnce(successPayload);
|
|
1135
|
-
_context23.next = 14;
|
|
1136
|
-
return reg.triggerRegistration();
|
|
1137
|
-
case 14:
|
|
1138
|
-
_context23.next = 16;
|
|
1139
|
-
return flushPromises();
|
|
1140
|
-
case 16:
|
|
1141
|
-
expect(reg.webWorker).toBeDefined();
|
|
1142
|
-
reg.webWorker.onmessage({
|
|
1143
|
-
data: {
|
|
1144
|
-
type: _types.WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
1145
|
-
statusCode: 200
|
|
1146
|
-
}
|
|
1147
|
-
});
|
|
1148
|
-
|
|
1149
|
-
// Advance timers and flush any remaining promises.
|
|
1150
|
-
jest.advanceTimersByTime(1000);
|
|
1151
|
-
_context23.next = 21;
|
|
1152
|
-
return flushPromises();
|
|
1153
|
-
case 21:
|
|
1154
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1155
|
-
// reconnectSpy should have been called only once.
|
|
1156
|
-
expect(reconnectSpy).toBeCalledTimes(1);
|
|
1157
|
-
expect(restoreSpy).toBeCalledOnceWith(reg.startKeepaliveTimer.name);
|
|
1158
|
-
expect(restartSpy).toBeCalledOnceWith(reg.startKeepaliveTimer.name);
|
|
1159
|
-
// Active Mobius URL should remain unchanged.
|
|
1160
|
-
expect(reg.getActiveMobiusUrl()).toStrictEqual(url);
|
|
1161
|
-
case 26:
|
|
1162
|
-
case "end":
|
|
1163
|
-
return _context23.stop();
|
|
1164
|
-
}
|
|
1165
|
-
}, _callee23);
|
|
1166
|
-
})));
|
|
1167
|
-
it('verify failure followed by recovery of keepalive', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
|
|
1168
|
-
return _regenerator.default.wrap(function _callee24$(_context24) {
|
|
1169
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
1170
|
-
case 0:
|
|
1171
|
-
_context24.next = 2;
|
|
1172
|
-
return beforeEachSetupForKeepalive();
|
|
1173
|
-
case 2:
|
|
1174
|
-
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
1175
|
-
expect(reg.webWorker).toBeDefined();
|
|
1176
|
-
webex.request.mockRejectedValueOnce(failurePayload).mockRejectedValueOnce(failurePayload).mockResolvedValue(successPayload);
|
|
1177
|
-
reg.webWorker.onmessage({
|
|
1178
|
-
data: {
|
|
1179
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1180
|
-
err: failurePayload,
|
|
1181
|
-
keepAliveRetryCount: reg.isCCFlow ? 4 : 5
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
_context24.next = 8;
|
|
1185
|
-
return flushPromises();
|
|
1186
|
-
case 8:
|
|
1187
|
-
expect(reg.webWorker).toBeUndefined();
|
|
1188
|
-
expect(handleErrorSpy).toBeCalledTimes(3);
|
|
1189
|
-
_context24.next = 12;
|
|
1190
|
-
return reg.triggerRegistration();
|
|
1191
|
-
case 12:
|
|
1192
|
-
_context24.next = 14;
|
|
1193
|
-
return flushPromises();
|
|
1194
|
-
case 14:
|
|
1195
|
-
expect(reg.webWorker).toBeDefined();
|
|
1196
|
-
reg.webWorker.onmessage({
|
|
1197
|
-
data: {
|
|
1198
|
-
type: _types.WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
1199
|
-
statusCode: 200
|
|
1200
|
-
}
|
|
1201
|
-
});
|
|
1202
|
-
_context24.next = 18;
|
|
1203
|
-
return flushPromises();
|
|
1204
|
-
case 18:
|
|
1205
|
-
// In a complete failure‐then-recovery scenario, we expect another failure event to have been handled.
|
|
1206
|
-
// For that, simulate a second failure event on the new worker.
|
|
1207
|
-
reg.webWorker.onmessage({
|
|
1208
|
-
data: {
|
|
1209
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1210
|
-
err: failurePayload,
|
|
1211
|
-
keepAliveRetryCount: reg.isCCFlow ? 4 : 5
|
|
1212
|
-
}
|
|
1213
|
-
});
|
|
1214
|
-
_context24.next = 21;
|
|
1215
|
-
return flushPromises();
|
|
1216
|
-
case 21:
|
|
1217
|
-
expect(handleErrorSpy).toBeCalledTimes(4);
|
|
1218
|
-
|
|
1219
|
-
// And then re-register successfully:
|
|
1220
|
-
_context24.next = 24;
|
|
1221
|
-
return reg.triggerRegistration();
|
|
1222
|
-
case 24:
|
|
1223
|
-
_context24.next = 26;
|
|
1224
|
-
return flushPromises();
|
|
1225
|
-
case 26:
|
|
1226
|
-
expect(reg.webWorker).toBeDefined();
|
|
1227
|
-
reg.webWorker.onmessage({
|
|
1228
|
-
data: {
|
|
1229
|
-
type: _types.WorkerMessageType.KEEPALIVE_SUCCESS,
|
|
1230
|
-
statusCode: 200
|
|
1231
|
-
}
|
|
1232
|
-
});
|
|
1233
|
-
_context24.next = 30;
|
|
1234
|
-
return flushPromises();
|
|
1235
|
-
case 30:
|
|
1236
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1237
|
-
expect(reg.webWorker).toBeDefined();
|
|
1238
|
-
case 32:
|
|
1239
|
-
case "end":
|
|
1240
|
-
return _context24.stop();
|
|
1241
|
-
}
|
|
1242
|
-
}, _callee24);
|
|
1243
|
-
})));
|
|
1244
|
-
it('cc: verify failover to backup server after 4 keep alive failure with primary server', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1245
|
-
var clearKeepaliveSpy, reconnectSpy;
|
|
1246
|
-
return _regenerator.default.wrap(function _callee25$(_context25) {
|
|
1247
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
1248
|
-
case 0:
|
|
1249
|
-
// Register with contact center service
|
|
1250
|
-
setupRegistration(_objectSpread(_objectSpread({}, MockServiceData), {}, {
|
|
1251
|
-
indicator: _types.ServiceIndicator.CONTACT_CENTER
|
|
1252
|
-
}));
|
|
1253
|
-
_context25.next = 3;
|
|
1254
|
-
return beforeEachSetupForKeepalive();
|
|
1255
|
-
case 3:
|
|
1256
|
-
webex.request.mockResolvedValueOnce(successPayload);
|
|
1257
|
-
_context25.next = 6;
|
|
1258
|
-
return reg.triggerRegistration();
|
|
1259
|
-
case 6:
|
|
1260
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1261
|
-
expect(reg.webWorker).toBeDefined();
|
|
1262
|
-
|
|
1263
|
-
// Spy on clearKeepaliveTimer and simulate reconnectOnFailure behavior
|
|
1264
|
-
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1265
|
-
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure'); // Simulate a KEEPALIVE_FAILURE message from the worker with a retry count equal to threshold (4 for CC)
|
|
1266
|
-
reg.webWorker.onmessage({
|
|
1267
|
-
data: {
|
|
1268
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1269
|
-
err: {
|
|
1270
|
-
statusCode: 503
|
|
1271
|
-
},
|
|
1272
|
-
keepAliveRetryCount: 4
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
|
|
1276
|
-
// Wait for any asynchronous actions to complete
|
|
1277
|
-
_context25.next = 13;
|
|
1278
|
-
return flushPromises();
|
|
1279
|
-
case 13:
|
|
1280
|
-
// Verify that the keepalive timer was cleared and reconnectOnFailure was triggered
|
|
1281
|
-
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
1282
|
-
expect(reconnectSpy).toHaveBeenCalledWith(reg.startKeepaliveTimer.name);
|
|
1283
|
-
|
|
1284
|
-
// Verify that the active Mobius URL has been updated to the backup server and registration is active
|
|
1285
|
-
expect(reg.getActiveMobiusUrl()).toEqual(mobiusUris.backup[0]);
|
|
1286
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1287
|
-
case 17:
|
|
1288
|
-
case "end":
|
|
1289
|
-
return _context25.stop();
|
|
1290
|
-
}
|
|
1291
|
-
}, _callee25);
|
|
1292
|
-
})));
|
|
1293
|
-
it('verify failure keep-alive case with active call present: Restore Success after call ends', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
|
|
1294
|
-
var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, threshold, failureEvent;
|
|
1295
|
-
return _regenerator.default.wrap(function _callee26$(_context26) {
|
|
1296
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
1297
|
-
case 0:
|
|
1298
|
-
_context26.next = 2;
|
|
1299
|
-
return beforeEachSetupForKeepalive();
|
|
1300
|
-
case 2:
|
|
1301
|
-
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1302
|
-
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
1303
|
-
restartRegSpy = jest.spyOn(reg, 'restartRegistration'); // Simulate an active call.
|
|
1304
|
-
reg.callManager.createCall();
|
|
1305
|
-
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
|
|
1306
|
-
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1307
|
-
threshold = reg.isCCFlow ? 4 : 5; // Simulate a KEEPALIVE_FAILURE event with a 503 error at threshold.
|
|
1308
|
-
failureEvent = {
|
|
1309
|
-
data: {
|
|
1310
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1311
|
-
err: {
|
|
1312
|
-
statusCode: 503
|
|
1313
|
-
},
|
|
1314
|
-
keepAliveRetryCount: threshold
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
reg.webWorker.onmessage(failureEvent);
|
|
1318
|
-
_context26.next = 13;
|
|
1319
|
-
return flushPromises();
|
|
1320
|
-
case 13:
|
|
1321
|
-
// At this point, clearKeepaliveTimer was called so the worker is terminated.
|
|
1322
|
-
expect(clearTimerSpy).toHaveBeenCalled();
|
|
1323
|
-
expect(reg.webWorker).toBeUndefined();
|
|
1324
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
1325
|
-
expect(lineEmitter).lastCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1326
|
-
expect(reg.keepaliveTimer).toStrictEqual(undefined);
|
|
1327
|
-
expect(reg.failbackTimer).toStrictEqual(undefined);
|
|
1328
|
-
expect(reconnectSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1329
|
-
expect(restoreSpy).not.toBeCalled();
|
|
1330
|
-
expect(restartRegSpy).not.toBeCalled();
|
|
1331
|
-
expect(reg.reconnectPending).toStrictEqual(true);
|
|
1332
|
-
expect(infoSpy).toBeCalledWith('Active call(s) present, deferred reconnect till call cleanup.', {
|
|
1333
|
-
file: _constants.REGISTRATION_FILE,
|
|
1334
|
-
method: expect.any(String)
|
|
1335
|
-
});
|
|
1336
|
-
reconnectSpy.mockClear();
|
|
1337
|
-
|
|
1338
|
-
// Now simulate call cleanup.
|
|
1339
|
-
reg.callManager.callCollection = {};
|
|
1340
|
-
webex.request.mockResolvedValueOnce(successPayload);
|
|
1341
|
-
|
|
1342
|
-
// Call reconnectOnFailure manually. With no active calls, this should trigger re-registration.
|
|
1343
|
-
_context26.next = 29;
|
|
1344
|
-
return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1345
|
-
case 29:
|
|
1346
|
-
_context26.next = 31;
|
|
1347
|
-
return flushPromises();
|
|
1348
|
-
case 31:
|
|
1349
|
-
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
1350
|
-
// After re-registration, registration status becomes ACTIVE and a new worker is created.
|
|
1351
|
-
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
1352
|
-
expect(reg.webWorker).toBeDefined();
|
|
1353
|
-
expect(reconnectSpy).toBeCalledOnceWith(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1354
|
-
expect(restoreSpy).toBeCalledOnceWith(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
1355
|
-
expect(restartRegSpy).not.toBeCalled();
|
|
1356
|
-
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1357
|
-
case 38:
|
|
1358
|
-
case "end":
|
|
1359
|
-
return _context26.stop();
|
|
1360
|
-
}
|
|
1361
|
-
}, _callee26);
|
|
1362
|
-
})));
|
|
1363
|
-
it('checks for keep-alive failure with final error: 404', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
|
|
1364
|
-
var reconnectSpy, restoreSpy, restartRegSpy, clearTimerSpy, handle404CbSpy, registerSpy;
|
|
1365
|
-
return _regenerator.default.wrap(function _callee27$(_context27) {
|
|
1366
|
-
while (1) switch (_context27.prev = _context27.next) {
|
|
1367
|
-
case 0:
|
|
1368
|
-
_context27.next = 2;
|
|
1369
|
-
return beforeEachSetupForKeepalive();
|
|
1370
|
-
case 2:
|
|
1371
|
-
webex.request.mockResolvedValueOnce(successPayload);
|
|
1372
|
-
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1373
|
-
restoreSpy = jest.spyOn(reg, 'restorePreviousRegistration');
|
|
1374
|
-
restartRegSpy = jest.spyOn(reg, 'restartRegistration');
|
|
1375
|
-
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1376
|
-
handle404CbSpy = jest.spyOn(reg, 'handle404KeepaliveFailure');
|
|
1377
|
-
registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
|
|
1378
|
-
reg.webWorker.onmessage({
|
|
1379
|
-
data: {
|
|
1380
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1381
|
-
err: {
|
|
1382
|
-
statusCode: 404
|
|
1383
|
-
},
|
|
1384
|
-
keepAliveRetryCount: 1
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
_context27.next = 12;
|
|
1388
|
-
return flushPromises();
|
|
1389
|
-
case 12:
|
|
1390
|
-
expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 404 ', expect.objectContaining({
|
|
1391
|
-
file: _constants.REGISTRATION_FILE,
|
|
1392
|
-
method: 'startKeepaliveTimer'
|
|
1393
|
-
}));
|
|
1394
|
-
expect(handleErrorSpy).toBeCalledOnceWith({
|
|
1395
|
-
statusCode: 404
|
|
1396
|
-
}, expect.anything(), {
|
|
1397
|
-
file: _constants.REGISTRATION_FILE,
|
|
1398
|
-
method: _constants.KEEPALIVE_UTIL
|
|
1399
|
-
}, expect.anything());
|
|
1400
|
-
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.ERROR, undefined, expect.anything());
|
|
1401
|
-
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1402
|
-
expect(clearTimerSpy).toBeCalledTimes(2);
|
|
1403
|
-
expect(reconnectSpy).not.toHaveBeenCalled();
|
|
1404
|
-
expect(restoreSpy).not.toHaveBeenCalled();
|
|
1405
|
-
expect(restartRegSpy).not.toHaveBeenCalled();
|
|
1406
|
-
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1407
|
-
expect(handle404CbSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1408
|
-
expect(registerSpy).toBeCalledOnceWith(_constants.KEEPALIVE_UTIL);
|
|
1409
|
-
case 23:
|
|
1410
|
-
case "end":
|
|
1411
|
-
return _context27.stop();
|
|
1412
|
-
}
|
|
1413
|
-
}, _callee27);
|
|
1414
|
-
})));
|
|
1415
|
-
it('checks for keep-alive failure with 429', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
|
|
1416
|
-
var _reg$deviceInfo$devic;
|
|
1417
|
-
var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy;
|
|
1418
|
-
return _regenerator.default.wrap(function _callee28$(_context28) {
|
|
1419
|
-
while (1) switch (_context28.prev = _context28.next) {
|
|
1420
|
-
case 0:
|
|
1421
|
-
_context28.next = 2;
|
|
1422
|
-
return beforeEachSetupForKeepalive();
|
|
1423
|
-
case 2:
|
|
1424
|
-
keepaliveSpy = jest.spyOn(reg, 'startKeepaliveTimer');
|
|
1425
|
-
postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
|
|
1426
|
-
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1427
|
-
retry429Spy = jest.spyOn(reg, 'handle429Retry');
|
|
1428
|
-
reg.webWorker.onmessage({
|
|
1429
|
-
data: {
|
|
1430
|
-
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1431
|
-
err: {
|
|
1432
|
-
statusCode: 429,
|
|
1433
|
-
headers: {
|
|
1434
|
-
'retry-after': 20
|
|
1435
|
-
}
|
|
1436
|
-
},
|
|
1437
|
-
keepAliveRetryCount: 1
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
_context28.next = 9;
|
|
1441
|
-
return flushPromises();
|
|
1442
|
-
case 9:
|
|
1443
|
-
expect(warnSpy).toBeCalledWith('Keep-alive missed 1 times. Status -> 429 ', expect.objectContaining({
|
|
1444
|
-
file: _constants.REGISTRATION_FILE,
|
|
1445
|
-
method: 'startKeepaliveTimer'
|
|
1446
|
-
}));
|
|
1447
|
-
expect(handleErrorSpy).toBeCalledOnceWith({
|
|
1448
|
-
statusCode: 429,
|
|
1449
|
-
headers: {
|
|
1450
|
-
'retry-after': 20
|
|
1451
|
-
}
|
|
1452
|
-
}, expect.anything(), {
|
|
1453
|
-
file: _constants.REGISTRATION_FILE,
|
|
1454
|
-
method: _constants.KEEPALIVE_UTIL
|
|
1455
|
-
}, expect.anything());
|
|
1456
|
-
expect(retry429Spy).toBeCalledOnceWith(20, 'startKeepaliveTimer');
|
|
1457
|
-
expect(clearTimerSpy).toBeCalledTimes(1);
|
|
1458
|
-
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1459
|
-
expect(reg.keepaliveTimer).toBe(undefined);
|
|
1460
|
-
expect(reg.webWorker).toBeUndefined();
|
|
1461
|
-
jest.advanceTimersByTime(20 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1462
|
-
_context28.next = 19;
|
|
1463
|
-
return flushPromises();
|
|
1464
|
-
case 19:
|
|
1465
|
-
expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic = reg.deviceInfo.device) === null || _reg$deviceInfo$devic === void 0 ? void 0 : _reg$deviceInfo$devic.uri, reg.deviceInfo.keepaliveInterval, 'UNKNOWN');
|
|
1466
|
-
expect(logSpy).toBeCalledWith('Resuming keepalive after 20 seconds', {
|
|
1467
|
-
file: _constants.REGISTRATION_FILE,
|
|
1468
|
-
method: 'handle429Retry'
|
|
1469
|
-
});
|
|
1470
|
-
expect(reg.webWorker).toBeDefined();
|
|
1471
|
-
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1472
|
-
type: 'START_KEEPALIVE',
|
|
1473
|
-
accessToken: expect.any(String),
|
|
1474
|
-
deviceUrl: expect.any(String),
|
|
1475
|
-
interval: expect.any(Number),
|
|
1476
|
-
retryCountThreshold: expect.any(Number),
|
|
1477
|
-
url: expect.any(String)
|
|
1478
|
-
}));
|
|
1479
|
-
case 23:
|
|
1480
|
-
case "end":
|
|
1481
|
-
return _context28.stop();
|
|
1482
|
-
}
|
|
1483
|
-
}, _callee28);
|
|
1484
|
-
})));
|
|
1485
|
-
});
|
|
1486
|
-
describe('Primary server status checks', function () {
|
|
1487
|
-
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
|
|
1488
|
-
var pingSuccessPayload, status;
|
|
1489
|
-
return _regenerator.default.wrap(function _callee29$(_context29) {
|
|
1490
|
-
while (1) switch (_context29.prev = _context29.next) {
|
|
1491
|
-
case 0:
|
|
1492
|
-
pingSuccessPayload = {
|
|
1493
|
-
statusCode: 200
|
|
1494
|
-
};
|
|
1495
|
-
webex.request.mockResolvedValue(pingSuccessPayload);
|
|
1496
|
-
_context29.next = 4;
|
|
1497
|
-
return reg.isPrimaryActive();
|
|
1498
|
-
case 4:
|
|
1499
|
-
status = _context29.sent;
|
|
1500
|
-
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1501
|
-
method: 'GET',
|
|
1502
|
-
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
1503
|
-
}, (0, _testUtil.getMockRequestTemplate)()));
|
|
1504
|
-
expect(status).toEqual(true);
|
|
1505
|
-
case 7:
|
|
1506
|
-
case "end":
|
|
1507
|
-
return _context29.stop();
|
|
1508
|
-
}
|
|
1509
|
-
}, _callee29);
|
|
1510
|
-
})));
|
|
1511
|
-
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
|
|
1512
|
-
var pingFailurePayload, status;
|
|
1513
|
-
return _regenerator.default.wrap(function _callee30$(_context30) {
|
|
1514
|
-
while (1) switch (_context30.prev = _context30.next) {
|
|
1515
|
-
case 0:
|
|
1516
|
-
pingFailurePayload = {
|
|
1517
|
-
statusCode: 500
|
|
1518
|
-
};
|
|
1519
|
-
webex.request.mockResolvedValue(pingFailurePayload);
|
|
1520
|
-
_context30.next = 4;
|
|
1521
|
-
return reg.isPrimaryActive();
|
|
1522
|
-
case 4:
|
|
1523
|
-
status = _context30.sent;
|
|
1524
|
-
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1525
|
-
method: 'GET',
|
|
1526
|
-
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
1527
|
-
}, (0, _testUtil.getMockRequestTemplate)()));
|
|
1528
|
-
expect(status).toEqual(false);
|
|
1529
|
-
case 7:
|
|
1530
|
-
case "end":
|
|
1531
|
-
return _context30.stop();
|
|
1532
|
-
}
|
|
1533
|
-
}, _callee30);
|
|
1534
|
-
})));
|
|
1535
|
-
});
|
|
1536
|
-
});
|
|
1537
|
-
//# sourceMappingURL=register.test.js.map
|