@webex/calling 3.12.0-next.12 → 3.12.0-next.120
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/CallRecording/CallRecording.js +160 -0
- package/dist/CallRecording/CallRecording.js.map +1 -0
- package/dist/CallRecording/CallRecording.test.js +257 -0
- package/dist/CallRecording/CallRecording.test.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js +577 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js +652 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -0
- package/dist/CallRecording/callRecordingFixtures.js +235 -0
- package/dist/CallRecording/callRecordingFixtures.js.map +1 -0
- package/dist/CallRecording/constants.js +50 -0
- package/dist/CallRecording/constants.js.map +1 -0
- package/dist/CallRecording/types.js +137 -0
- package/dist/CallRecording/types.js.map +1 -0
- package/dist/CallRecording/utils.js +42 -0
- package/dist/CallRecording/utils.js.map +1 -0
- package/dist/CallRecording/utils.test.js +97 -0
- package/dist/CallRecording/utils.test.js.map +1 -0
- package/dist/CallingClient/CallingClient.js +469 -233
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +736 -179
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/CallerId/index.js +3 -1
- package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +12 -2
- package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +645 -458
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +928 -498
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +106 -35
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +140 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/calling/types.js +5 -0
- package/dist/CallingClient/calling/types.js.map +1 -1
- package/dist/CallingClient/constants.js +33 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +27 -3
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +102 -17
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +971 -506
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +946 -61
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js +26 -0
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +41 -104
- package/dist/CallingClient/registration/webWorker.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.test.js +39 -153
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
- package/dist/CallingClient/types.js +7 -0
- package/dist/CallingClient/types.js.map +1 -1
- package/dist/CallingClient/utils/constants.js +58 -0
- package/dist/CallingClient/utils/constants.js.map +1 -0
- package/dist/CallingClient/utils/index.js +63 -0
- package/dist/CallingClient/utils/index.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js +221 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
- package/dist/CallingClient/utils/request.js +435 -0
- package/dist/CallingClient/utils/request.js.map +1 -0
- package/dist/CallingClient/utils/request.test.js +999 -0
- package/dist/CallingClient/utils/request.test.js.map +1 -0
- package/dist/CallingClient/utils/types.js +7 -0
- package/dist/CallingClient/utils/types.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js +70 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +13 -11
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +3 -8
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/types.js +38 -1
- package/dist/Events/types.js.map +1 -1
- package/dist/Metrics/index.js +63 -2
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +357 -1
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +19 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/api.js +56 -0
- package/dist/api.js.map +1 -1
- package/dist/common/Utils.js +252 -127
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +493 -229
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/callUtils.js +187 -0
- package/dist/common/callUtils.js.map +1 -0
- package/dist/common/callUtils.test.js +313 -0
- package/dist/common/callUtils.test.js.map +1 -0
- package/dist/common/constants.js +27 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/index.js +11 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/testUtil.js +10 -5
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +171 -40
- package/dist/index.js.map +1 -1
- package/dist/mobius-socket/config.js +24 -0
- package/dist/mobius-socket/config.js.map +1 -0
- package/dist/mobius-socket/errors.js +143 -0
- package/dist/mobius-socket/errors.js.map +1 -0
- package/dist/mobius-socket/errors.test.js +20 -0
- package/dist/mobius-socket/errors.test.js.map +1 -0
- package/dist/mobius-socket/index.js +57 -0
- package/dist/mobius-socket/index.js.map +1 -0
- package/dist/mobius-socket/mobius-socket-events.test.js +493 -0
- package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.js +849 -0
- package/dist/mobius-socket/mobius-socket.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.test.js +1898 -0
- package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
- package/dist/mobius-socket/socket/constants.js +55 -0
- package/dist/mobius-socket/socket/constants.js.map +1 -0
- package/dist/mobius-socket/socket/index.js +15 -0
- package/dist/mobius-socket/socket/index.js.map +1 -0
- package/dist/mobius-socket/socket/socket-base.js +614 -0
- package/dist/mobius-socket/socket/socket-base.js.map +1 -0
- package/dist/mobius-socket/socket/socket.js +19 -0
- package/dist/mobius-socket/socket/socket.js.map +1 -0
- package/dist/mobius-socket/socket/socket.shim.js +26 -0
- package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
- package/dist/mobius-socket/socket/types.js +7 -0
- package/dist/mobius-socket/socket/types.js.map +1 -0
- package/dist/mobius-socket/socket.test.js +747 -0
- package/dist/mobius-socket/socket.test.js.map +1 -0
- package/dist/mobius-socket/test/mocha-helpers.js +23 -0
- package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
- package/dist/mobius-socket/test/promise-tick.js +28 -0
- package/dist/mobius-socket/test/promise-tick.js.map +1 -0
- package/dist/mobius-socket/types.js +7 -0
- package/dist/mobius-socket/types.js.map +1 -0
- package/dist/module/CallRecording/CallRecording.js +56 -0
- package/dist/module/CallRecording/WxcCallRecordingConnector.js +257 -0
- package/dist/module/CallRecording/callRecordingFixtures.js +201 -0
- package/dist/module/CallRecording/constants.js +28 -0
- package/dist/module/CallRecording/types.js +19 -0
- package/dist/module/CallRecording/utils.js +14 -0
- package/dist/module/CallingClient/CallingClient.js +137 -20
- package/dist/module/CallingClient/calling/CallerId/index.js +2 -2
- package/dist/module/CallingClient/calling/call.js +207 -68
- package/dist/module/CallingClient/calling/callManager.js +51 -11
- package/dist/module/CallingClient/calling/types.js +2 -0
- package/dist/module/CallingClient/constants.js +28 -0
- package/dist/module/CallingClient/line/index.js +11 -3
- package/dist/module/CallingClient/registration/register.js +297 -68
- package/dist/module/CallingClient/registration/types.js +5 -1
- package/dist/module/CallingClient/registration/webWorker.js +42 -61
- package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
- package/dist/module/CallingClient/utils/constants.js +36 -0
- package/dist/module/CallingClient/utils/index.js +5 -0
- package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
- package/dist/module/CallingClient/utils/request.js +211 -0
- package/dist/module/CallingClient/utils/types.js +1 -0
- package/dist/module/CallingClient/utils/wsFeatureFlag.js +41 -0
- package/dist/module/Contacts/ContactsClient.js +1 -1
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Events/types.js +23 -0
- package/dist/module/Metrics/index.js +48 -1
- package/dist/module/Metrics/types.js +18 -0
- package/dist/module/api.js +3 -2
- package/dist/module/common/Utils.js +103 -58
- package/dist/module/common/callUtils.js +90 -0
- package/dist/module/common/constants.js +11 -0
- package/dist/module/common/index.js +1 -0
- package/dist/module/common/testUtil.js +6 -1
- package/dist/module/common/types.js +3 -0
- package/dist/module/index.js +7 -3
- package/dist/module/mobius-socket/config.js +15 -0
- package/dist/module/mobius-socket/errors.js +58 -0
- package/dist/module/mobius-socket/index.js +24 -0
- package/dist/module/mobius-socket/mobius-socket.js +593 -0
- package/dist/module/mobius-socket/socket/constants.js +26 -0
- package/dist/module/mobius-socket/socket/index.js +4 -0
- package/dist/module/mobius-socket/socket/socket-base.js +376 -0
- package/dist/module/mobius-socket/socket/socket.js +9 -0
- package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
- package/dist/module/mobius-socket/socket/types.js +1 -0
- package/dist/module/mobius-socket/types.js +1 -0
- package/dist/types/CallRecording/CallRecording.d.ts +18 -0
- package/dist/types/CallRecording/CallRecording.d.ts.map +1 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +23 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts +61 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -0
- package/dist/types/CallRecording/constants.d.ts +29 -0
- package/dist/types/CallRecording/constants.d.ts.map +1 -0
- package/dist/types/CallRecording/types.d.ts +176 -0
- package/dist/types/CallRecording/types.d.ts.map +1 -0
- package/dist/types/CallRecording/utils.d.ts +3 -0
- package/dist/types/CallRecording/utils.d.ts.map +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +8 -0
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +17 -3
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts +8 -4
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/types.d.ts +38 -9
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +28 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts +3 -2
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +9 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +26 -2
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.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/CallingClient/types.d.ts +6 -2
- package/dist/types/CallingClient/types.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/constants.d.ts +35 -0
- package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/index.d.ts +6 -0
- package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/request.d.ts +28 -0
- package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/types.d.ts +34 -0
- package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Events/types.d.ts +80 -6
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +19 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +39 -12
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/api.d.ts +6 -4
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +11 -5
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/callUtils.d.ts +6 -0
- package/dist/types/common/callUtils.d.ts.map +1 -0
- package/dist/types/common/constants.d.ts +6 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +1 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +5 -1
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +5 -1
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mobius-socket/config.d.ts +17 -0
- package/dist/types/mobius-socket/config.d.ts.map +1 -0
- package/dist/types/mobius-socket/errors.d.ts +32 -0
- package/dist/types/mobius-socket/errors.d.ts.map +1 -0
- package/dist/types/mobius-socket/index.d.ts +14 -0
- package/dist/types/mobius-socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/constants.d.ts +27 -0
- package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/index.d.ts +5 -0
- package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/types.d.ts +61 -0
- package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
- package/dist/types/mobius-socket/types.d.ts +21 -0
- package/dist/types/mobius-socket/types.d.ts.map +1 -0
- package/package.json +20 -7
- package/src/mobius-socket/socket/socket.shim.ts +22 -0
- package/src/mobius-socket/socket/socket.ts +14 -0
|
@@ -23,6 +23,7 @@ var _register = require("./register");
|
|
|
23
23
|
var _testUtil = require("../../common/testUtil");
|
|
24
24
|
var _types = require("../../common/types");
|
|
25
25
|
var utils = _interopRequireWildcard(require("../../common/Utils"));
|
|
26
|
+
var callUtils = _interopRequireWildcard(require("../../common/callUtils"));
|
|
26
27
|
var _Logger = _interopRequireDefault(require("../../Logger"));
|
|
27
28
|
var _types2 = require("../../Logger/types");
|
|
28
29
|
var _registerFixtures = require("./registerFixtures");
|
|
@@ -32,9 +33,17 @@ var _constants = require("../constants");
|
|
|
32
33
|
var _types4 = require("../line/types");
|
|
33
34
|
var _LineError = require("../../Errors/catalog/LineError");
|
|
34
35
|
var _types5 = require("../../Metrics/types");
|
|
35
|
-
|
|
36
|
+
var _request = require("../utils/request");
|
|
37
|
+
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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
36
38
|
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; }
|
|
37
39
|
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 */
|
|
40
|
+
jest.mock('../../mobius-socket', function () {
|
|
41
|
+
return {
|
|
42
|
+
getMobiusSocketInstance: jest.fn().mockReturnValue({
|
|
43
|
+
sendWssRequest: jest.fn()
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
});
|
|
38
47
|
var webex = (0, _testUtil.getTestUtilsWebex)();
|
|
39
48
|
var MockServiceData = {
|
|
40
49
|
indicator: _types.ServiceIndicator.CALLING,
|
|
@@ -62,7 +71,8 @@ describe('Registration Tests', function () {
|
|
|
62
71
|
serviceData: {
|
|
63
72
|
domain: '',
|
|
64
73
|
indicator: 'calling'
|
|
65
|
-
}
|
|
74
|
+
},
|
|
75
|
+
hostIps: []
|
|
66
76
|
}
|
|
67
77
|
});
|
|
68
78
|
var ccMockResponse = _objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
@@ -137,6 +147,11 @@ describe('Registration Tests', function () {
|
|
|
137
147
|
metricSpy = jest.spyOn(reg.metricManager, 'submitRegistrationMetric');
|
|
138
148
|
};
|
|
139
149
|
beforeEach(function () {
|
|
150
|
+
_request.APIRequest.resetInstance();
|
|
151
|
+
_request.APIRequest.getInstance({
|
|
152
|
+
webex: webex,
|
|
153
|
+
isMobiusSocketEnabled: false
|
|
154
|
+
});
|
|
140
155
|
setupRegistration(MockServiceData);
|
|
141
156
|
});
|
|
142
157
|
afterEach(function () {
|
|
@@ -147,9 +162,12 @@ describe('Registration Tests', function () {
|
|
|
147
162
|
localStorage.clear();
|
|
148
163
|
});
|
|
149
164
|
it('verify successful registration', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
165
|
+
var hostIps;
|
|
150
166
|
return _regenerator.default.wrap(function (_context) {
|
|
151
167
|
while (1) switch (_context.prev = _context.next) {
|
|
152
168
|
case 0:
|
|
169
|
+
hostIps = ['10.0.0.5', '192.168.1.7'];
|
|
170
|
+
jest.spyOn(callUtils, 'getHostIps').mockReturnValueOnce(hostIps);
|
|
153
171
|
webex.request.mockReturnValueOnce({
|
|
154
172
|
body: _registerFixtures.mockPostResponse,
|
|
155
173
|
headers: {
|
|
@@ -160,7 +178,10 @@ describe('Registration Tests', function () {
|
|
|
160
178
|
return reg.triggerRegistration();
|
|
161
179
|
case 1:
|
|
162
180
|
expect(webex.request).toBeCalledOnceWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
163
|
-
method: 'POST'
|
|
181
|
+
method: 'POST',
|
|
182
|
+
body: _objectSpread(_objectSpread({}, mockResponse.body), {}, {
|
|
183
|
+
hostIps: hostIps
|
|
184
|
+
})
|
|
164
185
|
}));
|
|
165
186
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.ACTIVE);
|
|
166
187
|
expect(lineEmitter).toBeCalledTimes(2);
|
|
@@ -170,7 +191,7 @@ describe('Registration Tests', function () {
|
|
|
170
191
|
// Check that log.log was called for successful registration
|
|
171
192
|
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({
|
|
172
193
|
file: _constants.REGISTRATION_FILE,
|
|
173
|
-
method:
|
|
194
|
+
method: _constants.REGISTER_UTIL
|
|
174
195
|
}));
|
|
175
196
|
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);
|
|
176
197
|
case 2:
|
|
@@ -218,6 +239,9 @@ describe('Registration Tests', function () {
|
|
|
218
239
|
devices: [_registerFixtures.mockPostResponse.device]
|
|
219
240
|
},
|
|
220
241
|
statusCode: 403
|
|
242
|
+
}).mockResolvedValueOnce({
|
|
243
|
+
statusCode: 200,
|
|
244
|
+
body: _registerFixtures.mockDeleteResponse
|
|
221
245
|
}).mockResolvedValueOnce({
|
|
222
246
|
statusCode: 200,
|
|
223
247
|
body: _registerFixtures.mockPostResponse,
|
|
@@ -225,25 +249,18 @@ describe('Registration Tests', function () {
|
|
|
225
249
|
trackingid: 'webex-js-sdk_06bafdd0-2f9b-4cd7-b438-9c0d95ecec9b_15'
|
|
226
250
|
}
|
|
227
251
|
});
|
|
228
|
-
global.fetch = jest.fn(function () {
|
|
229
|
-
return _promise.default.resolve({
|
|
230
|
-
json: function json() {
|
|
231
|
-
return _registerFixtures.mockDeleteResponse;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
252
|
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.IDLE);
|
|
236
253
|
_context3.next = 1;
|
|
237
254
|
return reg.triggerRegistration();
|
|
238
255
|
case 1:
|
|
239
|
-
expect(webex.request).toBeCalledTimes(
|
|
256
|
+
expect(webex.request).toBeCalledTimes(3);
|
|
240
257
|
expect(webex.request).toBeCalledWith(_objectSpread(_objectSpread({}, mockResponse), {}, {
|
|
241
258
|
method: 'POST'
|
|
242
259
|
}));
|
|
243
|
-
expect(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
260
|
+
expect(webex.request).toBeCalledWith(expect.objectContaining({
|
|
261
|
+
uri: _registerFixtures.mockPostResponse.device.uri,
|
|
262
|
+
method: 'DELETE'
|
|
263
|
+
}));
|
|
247
264
|
expect(warnSpy).toBeCalledWith('User device limit exceeded', expect.anything());
|
|
248
265
|
expect(infoSpy).toBeCalledWith('Registration restoration in progress.', expect.anything());
|
|
249
266
|
expect(infoSpy).toBeCalledWith('Registration restored successfully.', expect.anything());
|
|
@@ -1277,11 +1294,8 @@ describe('Registration Tests', function () {
|
|
|
1277
1294
|
expect(reg.webWorker).toBeDefined();
|
|
1278
1295
|
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1279
1296
|
type: 'START_KEEPALIVE',
|
|
1280
|
-
accessToken: expect.any(String),
|
|
1281
|
-
deviceUrl: expect.any(String),
|
|
1282
1297
|
interval: expect.any(Number),
|
|
1283
|
-
retryCountThreshold: expect.any(Number)
|
|
1284
|
-
url: expect.any(String)
|
|
1298
|
+
retryCountThreshold: expect.any(Number)
|
|
1285
1299
|
}));
|
|
1286
1300
|
reg.webWorker.onmessage({
|
|
1287
1301
|
data: {
|
|
@@ -1690,7 +1704,7 @@ describe('Registration Tests', function () {
|
|
|
1690
1704
|
})));
|
|
1691
1705
|
it('checks for keep-alive failure with 429', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee35() {
|
|
1692
1706
|
var _reg$deviceInfo$devic;
|
|
1693
|
-
var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy;
|
|
1707
|
+
var keepaliveSpy, postMessageSpy, clearTimerSpy, retry429Spy, keepaliveInterval, retryAfter, adjustedResumeDelayMs;
|
|
1694
1708
|
return _regenerator.default.wrap(function (_context35) {
|
|
1695
1709
|
while (1) switch (_context35.prev = _context35.next) {
|
|
1696
1710
|
case 0:
|
|
@@ -1701,13 +1715,17 @@ describe('Registration Tests', function () {
|
|
|
1701
1715
|
postMessageSpy = jest.spyOn(Worker.prototype, 'postMessage');
|
|
1702
1716
|
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1703
1717
|
retry429Spy = jest.spyOn(reg, 'handle429Retry');
|
|
1718
|
+
keepaliveInterval = reg.deviceInfo.keepaliveInterval; // Choose a retryAfter strictly greater than keepaliveInterval so the
|
|
1719
|
+
// adjusted resume delay (retryAfter - keepaliveInterval) is positive and verifiable.
|
|
1720
|
+
retryAfter = keepaliveInterval + 30;
|
|
1721
|
+
adjustedResumeDelayMs = (retryAfter - keepaliveInterval) * _constants.SEC_TO_MSEC_MFACTOR;
|
|
1704
1722
|
reg.webWorker.onmessage({
|
|
1705
1723
|
data: {
|
|
1706
1724
|
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1707
1725
|
err: {
|
|
1708
1726
|
statusCode: 429,
|
|
1709
1727
|
headers: {
|
|
1710
|
-
'retry-after':
|
|
1728
|
+
'retry-after': retryAfter
|
|
1711
1729
|
}
|
|
1712
1730
|
},
|
|
1713
1731
|
keepAliveRetryCount: 1
|
|
@@ -1723,47 +1741,112 @@ describe('Registration Tests', function () {
|
|
|
1723
1741
|
expect(handleErrorSpy).toBeCalledOnceWith({
|
|
1724
1742
|
statusCode: 429,
|
|
1725
1743
|
headers: {
|
|
1726
|
-
'retry-after':
|
|
1744
|
+
'retry-after': retryAfter
|
|
1727
1745
|
}
|
|
1728
1746
|
}, expect.anything(), {
|
|
1729
1747
|
file: _constants.REGISTRATION_FILE,
|
|
1730
1748
|
method: _constants.KEEPALIVE_UTIL
|
|
1731
1749
|
}, expect.anything());
|
|
1732
|
-
expect(retry429Spy).toBeCalledOnceWith(
|
|
1750
|
+
expect(retry429Spy).toBeCalledOnceWith(retryAfter, 'startKeepaliveTimer');
|
|
1733
1751
|
expect(clearTimerSpy).toBeCalledTimes(1);
|
|
1734
1752
|
expect(reg.reconnectPending).toStrictEqual(false);
|
|
1735
1753
|
expect(reg.keepaliveTimer).toBe(undefined);
|
|
1736
1754
|
expect(reg.webWorker).toBeUndefined();
|
|
1737
|
-
|
|
1755
|
+
|
|
1756
|
+
// Resume timer must NOT fire before the adjusted (retryAfter - keepaliveInterval) interval.
|
|
1757
|
+
jest.advanceTimersByTime(adjustedResumeDelayMs - 1);
|
|
1738
1758
|
_context35.next = 3;
|
|
1739
1759
|
return flushPromises();
|
|
1740
1760
|
case 3:
|
|
1741
|
-
expect(keepaliveSpy).
|
|
1742
|
-
expect(
|
|
1761
|
+
expect(keepaliveSpy).not.toBeCalled();
|
|
1762
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1763
|
+
|
|
1764
|
+
// Advance the remaining 1ms to hit the exact adjusted timeout; keepalive must resume now.
|
|
1765
|
+
jest.advanceTimersByTime(1);
|
|
1766
|
+
_context35.next = 4;
|
|
1767
|
+
return flushPromises();
|
|
1768
|
+
case 4:
|
|
1769
|
+
expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic = reg.deviceInfo.device) === null || _reg$deviceInfo$devic === void 0 ? void 0 : _reg$deviceInfo$devic.uri, keepaliveInterval, 'UNKNOWN');
|
|
1770
|
+
expect(logSpy).toBeCalledWith("Resuming keepalive after ".concat(retryAfter, " seconds"), {
|
|
1743
1771
|
file: _constants.REGISTRATION_FILE,
|
|
1744
1772
|
method: 'handle429Retry'
|
|
1745
1773
|
});
|
|
1746
1774
|
expect(reg.webWorker).toBeDefined();
|
|
1747
1775
|
expect(postMessageSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
1748
1776
|
type: 'START_KEEPALIVE',
|
|
1749
|
-
accessToken: expect.any(String),
|
|
1750
|
-
deviceUrl: expect.any(String),
|
|
1751
1777
|
interval: expect.any(Number),
|
|
1752
|
-
retryCountThreshold: expect.any(Number)
|
|
1753
|
-
url: expect.any(String)
|
|
1778
|
+
retryCountThreshold: expect.any(Number)
|
|
1754
1779
|
}));
|
|
1755
|
-
case
|
|
1780
|
+
case 5:
|
|
1756
1781
|
case "end":
|
|
1757
1782
|
return _context35.stop();
|
|
1758
1783
|
}
|
|
1759
1784
|
}, _callee35);
|
|
1760
1785
|
})));
|
|
1761
|
-
it
|
|
1786
|
+
it.each([{
|
|
1787
|
+
description: 'retryAfter less than keepaliveInterval -> negative delay fires immediately',
|
|
1788
|
+
retryAfterDelta: -10
|
|
1789
|
+
}, {
|
|
1790
|
+
description: 'retryAfter equal to keepaliveInterval -> zero delay fires immediately',
|
|
1791
|
+
retryAfterDelta: 0
|
|
1792
|
+
}])('adjusts retry-after with keepaliveInterval on 429 keepalive failure ($description)', /*#__PURE__*/function () {
|
|
1793
|
+
var _ref37 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee36(_ref36) {
|
|
1794
|
+
var _reg$deviceInfo$devic2;
|
|
1795
|
+
var retryAfterDelta, keepaliveSpy, keepaliveInterval, retryAfter;
|
|
1796
|
+
return _regenerator.default.wrap(function (_context36) {
|
|
1797
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1798
|
+
case 0:
|
|
1799
|
+
retryAfterDelta = _ref36.retryAfterDelta;
|
|
1800
|
+
_context36.next = 1;
|
|
1801
|
+
return beforeEachSetupForKeepalive();
|
|
1802
|
+
case 1:
|
|
1803
|
+
keepaliveSpy = jest.spyOn(reg, 'startKeepaliveTimer');
|
|
1804
|
+
keepaliveInterval = reg.deviceInfo.keepaliveInterval;
|
|
1805
|
+
retryAfter = keepaliveInterval + retryAfterDelta;
|
|
1806
|
+
reg.webWorker.onmessage({
|
|
1807
|
+
data: {
|
|
1808
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1809
|
+
err: {
|
|
1810
|
+
statusCode: 429,
|
|
1811
|
+
headers: {
|
|
1812
|
+
'retry-after': retryAfter
|
|
1813
|
+
}
|
|
1814
|
+
},
|
|
1815
|
+
keepAliveRetryCount: 1
|
|
1816
|
+
}
|
|
1817
|
+
});
|
|
1818
|
+
_context36.next = 2;
|
|
1819
|
+
return flushPromises();
|
|
1820
|
+
case 2:
|
|
1821
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1822
|
+
expect(keepaliveSpy).not.toBeCalled();
|
|
1823
|
+
|
|
1824
|
+
// With a non-positive adjusted delay, the timer should fire on the next tick.
|
|
1825
|
+
jest.advanceTimersByTime(0);
|
|
1826
|
+
_context36.next = 3;
|
|
1827
|
+
return flushPromises();
|
|
1828
|
+
case 3:
|
|
1829
|
+
expect(keepaliveSpy).toBeCalledOnceWith((_reg$deviceInfo$devic2 = reg.deviceInfo.device) === null || _reg$deviceInfo$devic2 === void 0 ? void 0 : _reg$deviceInfo$devic2.uri, keepaliveInterval, 'UNKNOWN');
|
|
1830
|
+
expect(logSpy).toBeCalledWith("Resuming keepalive after ".concat(retryAfter, " seconds"), {
|
|
1831
|
+
file: _constants.REGISTRATION_FILE,
|
|
1832
|
+
method: 'handle429Retry'
|
|
1833
|
+
});
|
|
1834
|
+
case 4:
|
|
1835
|
+
case "end":
|
|
1836
|
+
return _context36.stop();
|
|
1837
|
+
}
|
|
1838
|
+
}, _callee36);
|
|
1839
|
+
}));
|
|
1840
|
+
return function (_x) {
|
|
1841
|
+
return _ref37.apply(this, arguments);
|
|
1842
|
+
};
|
|
1843
|
+
}());
|
|
1844
|
+
it('ensure retryAfter is set when 429 occurs during failover retry', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee37() {
|
|
1762
1845
|
var retry429Spy;
|
|
1763
|
-
return _regenerator.default.wrap(function (
|
|
1764
|
-
while (1) switch (
|
|
1846
|
+
return _regenerator.default.wrap(function (_context37) {
|
|
1847
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
1765
1848
|
case 0:
|
|
1766
|
-
|
|
1849
|
+
_context37.next = 1;
|
|
1767
1850
|
return beforeEachSetupForKeepalive();
|
|
1768
1851
|
case 1:
|
|
1769
1852
|
// Simulate loss of registration so failover path attempts a new registration
|
|
@@ -1774,11 +1857,11 @@ describe('Registration Tests', function () {
|
|
|
1774
1857
|
webex.request.mockRejectedValueOnce(failurePayload429One);
|
|
1775
1858
|
|
|
1776
1859
|
// Directly schedule the failover attempt
|
|
1777
|
-
|
|
1860
|
+
_context37.next = 2;
|
|
1778
1861
|
return reg.startFailoverTimer();
|
|
1779
1862
|
case 2:
|
|
1780
1863
|
jest.advanceTimersByTime(33 * _constants.SEC_TO_MSEC_MFACTOR);
|
|
1781
|
-
|
|
1864
|
+
_context37.next = 3;
|
|
1782
1865
|
return flushPromises();
|
|
1783
1866
|
case 3:
|
|
1784
1867
|
expect(retry429Spy).toBeCalledWith(failurePayload429One.headers['retry-after'], 'startFailoverTimer');
|
|
@@ -1786,16 +1869,16 @@ describe('Registration Tests', function () {
|
|
|
1786
1869
|
jest.useRealTimers();
|
|
1787
1870
|
case 4:
|
|
1788
1871
|
case "end":
|
|
1789
|
-
return
|
|
1872
|
+
return _context37.stop();
|
|
1790
1873
|
}
|
|
1791
|
-
},
|
|
1874
|
+
}, _callee37);
|
|
1792
1875
|
})));
|
|
1793
|
-
it('sets retryAfter when reconnectOnFailure caller receives 429 after keepalive threshold miss', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1876
|
+
it('sets retryAfter when reconnectOnFailure caller receives 429 after keepalive threshold miss', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee38() {
|
|
1794
1877
|
var retry429Spy, threshold;
|
|
1795
|
-
return _regenerator.default.wrap(function (
|
|
1796
|
-
while (1) switch (
|
|
1878
|
+
return _regenerator.default.wrap(function (_context38) {
|
|
1879
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
1797
1880
|
case 0:
|
|
1798
|
-
|
|
1881
|
+
_context38.next = 1;
|
|
1799
1882
|
return beforeEachSetupForKeepalive();
|
|
1800
1883
|
case 1:
|
|
1801
1884
|
retry429Spy = jest.spyOn(reg, 'handle429Retry'); // On reconnectOnFailure(RECONNECT_ON_FAILURE_UTIL) first restore attempt, make registration respond with 429 (retry-after: 20)
|
|
@@ -1818,7 +1901,7 @@ describe('Registration Tests', function () {
|
|
|
1818
1901
|
keepAliveRetryCount: threshold
|
|
1819
1902
|
}
|
|
1820
1903
|
});
|
|
1821
|
-
|
|
1904
|
+
_context38.next = 2;
|
|
1822
1905
|
return flushPromises();
|
|
1823
1906
|
case 2:
|
|
1824
1907
|
// handle429Retry is called with caller 'reconnectOnFailure' → else branch executes and sets retryAfter
|
|
@@ -1826,25 +1909,579 @@ describe('Registration Tests', function () {
|
|
|
1826
1909
|
expect(reg.retryAfter).toEqual(undefined); // Clear retryAfter after 429 retry
|
|
1827
1910
|
case 3:
|
|
1828
1911
|
case "end":
|
|
1829
|
-
return
|
|
1912
|
+
return _context38.stop();
|
|
1830
1913
|
}
|
|
1831
|
-
},
|
|
1914
|
+
}, _callee38);
|
|
1915
|
+
})));
|
|
1916
|
+
describe('409 Conflict on keepalive (session superseded)', function () {
|
|
1917
|
+
var conflictError = {
|
|
1918
|
+
statusCode: 409,
|
|
1919
|
+
headers: {
|
|
1920
|
+
trackingid: 'tid-409'
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
var sendKeepaliveFailure = /*#__PURE__*/function () {
|
|
1924
|
+
var _ref40 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee39(err, keepAliveRetryCount) {
|
|
1925
|
+
return _regenerator.default.wrap(function (_context39) {
|
|
1926
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
1927
|
+
case 0:
|
|
1928
|
+
reg.webWorker.onmessage({
|
|
1929
|
+
data: {
|
|
1930
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
1931
|
+
err: err,
|
|
1932
|
+
keepAliveRetryCount: keepAliveRetryCount
|
|
1933
|
+
}
|
|
1934
|
+
});
|
|
1935
|
+
_context39.next = 1;
|
|
1936
|
+
return flushPromises();
|
|
1937
|
+
case 1:
|
|
1938
|
+
case "end":
|
|
1939
|
+
return _context39.stop();
|
|
1940
|
+
}
|
|
1941
|
+
}, _callee39);
|
|
1942
|
+
}));
|
|
1943
|
+
return function sendKeepaliveFailure(_x2, _x3) {
|
|
1944
|
+
return _ref40.apply(this, arguments);
|
|
1945
|
+
};
|
|
1946
|
+
}();
|
|
1947
|
+
var getSupersededError = function getSupersededError() {
|
|
1948
|
+
var unregisteredCall = lineEmitter.mock.calls.find(function (_ref41) {
|
|
1949
|
+
var _ref42 = (0, _slicedToArray2.default)(_ref41, 1),
|
|
1950
|
+
event = _ref42[0];
|
|
1951
|
+
return event === _types4.LINE_EVENTS.UNREGISTERED;
|
|
1952
|
+
});
|
|
1953
|
+
return unregisteredCall === null || unregisteredCall === void 0 ? void 0 : unregisteredCall[2];
|
|
1954
|
+
};
|
|
1955
|
+
it.each([{
|
|
1956
|
+
description: 'on the very first keepalive failure',
|
|
1957
|
+
keepAliveRetryCount: 1
|
|
1958
|
+
}, {
|
|
1959
|
+
description: 'when the retry count already reached the threshold',
|
|
1960
|
+
keepAliveRetryCount: 5
|
|
1961
|
+
}])('stops keepalive without re-registration $description', /*#__PURE__*/function () {
|
|
1962
|
+
var _ref44 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee40(_ref43) {
|
|
1963
|
+
var keepAliveRetryCount, clearTimerSpy, reconnectSpy, registerSpy, handle404Spy;
|
|
1964
|
+
return _regenerator.default.wrap(function (_context40) {
|
|
1965
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
1966
|
+
case 0:
|
|
1967
|
+
keepAliveRetryCount = _ref43.keepAliveRetryCount;
|
|
1968
|
+
_context40.next = 1;
|
|
1969
|
+
return beforeEachSetupForKeepalive();
|
|
1970
|
+
case 1:
|
|
1971
|
+
clearTimerSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
1972
|
+
reconnectSpy = jest.spyOn(reg, 'reconnectOnFailure');
|
|
1973
|
+
registerSpy = jest.spyOn(reg, 'attemptRegistrationWithServers');
|
|
1974
|
+
handle404Spy = jest.spyOn(reg, 'handle404KeepaliveFailure');
|
|
1975
|
+
lineEmitter.mockClear();
|
|
1976
|
+
_context40.next = 2;
|
|
1977
|
+
return sendKeepaliveFailure(conflictError, keepAliveRetryCount);
|
|
1978
|
+
case 2:
|
|
1979
|
+
// The 409 is classified by the common registration error handler.
|
|
1980
|
+
expect(handleErrorSpy).toHaveBeenCalledWith(conflictError, expect.anything(), {
|
|
1981
|
+
file: _constants.REGISTRATION_FILE,
|
|
1982
|
+
method: _constants.KEEPALIVE_UTIL
|
|
1983
|
+
}, expect.objectContaining({
|
|
1984
|
+
sessionSupersededCb: expect.any(Function)
|
|
1985
|
+
}));
|
|
1986
|
+
expect(warnSpy).toBeCalledWith('409 Conflict: session superseded by another device for this user', {
|
|
1987
|
+
file: _constants.REGISTRATION_FILE,
|
|
1988
|
+
method: _constants.KEEPALIVE_UTIL
|
|
1989
|
+
});
|
|
1990
|
+
expect(warnSpy).toBeCalledWith("Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ".concat(keepAliveRetryCount), {
|
|
1991
|
+
file: _constants.REGISTRATION_FILE,
|
|
1992
|
+
method: _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE
|
|
1993
|
+
});
|
|
1994
|
+
|
|
1995
|
+
// Keepalive is stopped and no further keepalive can be sent.
|
|
1996
|
+
expect(clearTimerSpy).toHaveBeenCalled();
|
|
1997
|
+
expect(reg.webWorker).toBeUndefined();
|
|
1998
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
1999
|
+
expect(reg.failbackTimer).toStrictEqual(undefined);
|
|
2000
|
+
|
|
2001
|
+
// No re-registration of any kind is attempted.
|
|
2002
|
+
expect(reconnectSpy).not.toHaveBeenCalled();
|
|
2003
|
+
expect(restoreSpy).not.toHaveBeenCalled();
|
|
2004
|
+
expect(restartSpy).not.toHaveBeenCalled();
|
|
2005
|
+
expect(failoverSpy).not.toHaveBeenCalled();
|
|
2006
|
+
expect(registerSpy).not.toHaveBeenCalled();
|
|
2007
|
+
expect(handle404Spy).not.toHaveBeenCalled();
|
|
2008
|
+
expect(reg.reconnectPending).toStrictEqual(false);
|
|
2009
|
+
case 3:
|
|
2010
|
+
case "end":
|
|
2011
|
+
return _context40.stop();
|
|
2012
|
+
}
|
|
2013
|
+
}, _callee40);
|
|
2014
|
+
}));
|
|
2015
|
+
return function (_x4) {
|
|
2016
|
+
return _ref44.apply(this, arguments);
|
|
2017
|
+
};
|
|
2018
|
+
}());
|
|
2019
|
+
it('notifies the consumer with a single UNREGISTERED carrying the superseded reason', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee41() {
|
|
2020
|
+
var supersededError;
|
|
2021
|
+
return _regenerator.default.wrap(function (_context41) {
|
|
2022
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
2023
|
+
case 0:
|
|
2024
|
+
_context41.next = 1;
|
|
2025
|
+
return beforeEachSetupForKeepalive();
|
|
2026
|
+
case 1:
|
|
2027
|
+
lineEmitter.mockClear();
|
|
2028
|
+
_context41.next = 2;
|
|
2029
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2030
|
+
case 2:
|
|
2031
|
+
expect(lineEmitter.mock.calls.filter(function (_ref46) {
|
|
2032
|
+
var _ref47 = (0, _slicedToArray2.default)(_ref46, 1),
|
|
2033
|
+
event = _ref47[0];
|
|
2034
|
+
return event === _types4.LINE_EVENTS.UNREGISTERED;
|
|
2035
|
+
})).toHaveLength(1);
|
|
2036
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.RECONNECTING);
|
|
2037
|
+
expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
|
|
2038
|
+
supersededError = getSupersededError();
|
|
2039
|
+
expect(supersededError.getError()).toStrictEqual({
|
|
2040
|
+
message: _constants.SESSION_SUPERSEDED_MESSAGE,
|
|
2041
|
+
type: _types3.ERROR_TYPE.SESSION_SUPERSEDED,
|
|
2042
|
+
status: _types.RegistrationStatus.INACTIVE,
|
|
2043
|
+
context: {
|
|
2044
|
+
file: _constants.REGISTRATION_FILE,
|
|
2045
|
+
method: _constants.KEEPALIVE_UTIL
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
case 3:
|
|
2049
|
+
case "end":
|
|
2050
|
+
return _context41.stop();
|
|
2051
|
+
}
|
|
2052
|
+
}, _callee41);
|
|
2053
|
+
})));
|
|
2054
|
+
it('submits the keepalive failure metric and uploads logs', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee42() {
|
|
2055
|
+
var uploadLogsSpy;
|
|
2056
|
+
return _regenerator.default.wrap(function (_context42) {
|
|
2057
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
2058
|
+
case 0:
|
|
2059
|
+
_context42.next = 1;
|
|
2060
|
+
return beforeEachSetupForKeepalive();
|
|
2061
|
+
case 1:
|
|
2062
|
+
uploadLogsSpy = jest.spyOn(utils, 'uploadLogs');
|
|
2063
|
+
lineEmitter.mockClear();
|
|
2064
|
+
metricSpy.mockClear();
|
|
2065
|
+
_context42.next = 2;
|
|
2066
|
+
return sendKeepaliveFailure(conflictError, 2);
|
|
2067
|
+
case 2:
|
|
2068
|
+
expect(metricSpy).toBeCalledOnceWith(_types5.METRIC_EVENT.KEEPALIVE_ERROR, _types5.REG_ACTION.KEEPALIVE_FAILURE, _types5.METRIC_TYPE.BEHAVIORAL, _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE, 'PRIMARY', conflictError.headers.trackingid, 2, getSupersededError());
|
|
2069
|
+
expect(uploadLogsSpy).toHaveBeenCalled();
|
|
2070
|
+
case 3:
|
|
2071
|
+
case "end":
|
|
2072
|
+
return _context42.stop();
|
|
2073
|
+
}
|
|
2074
|
+
}, _callee42);
|
|
2075
|
+
})));
|
|
2076
|
+
it('closes the Mobius WebSocket when the socket transport is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee43() {
|
|
2077
|
+
var apiRequest, disconnectSocketSpy;
|
|
2078
|
+
return _regenerator.default.wrap(function (_context43) {
|
|
2079
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
2080
|
+
case 0:
|
|
2081
|
+
_context43.next = 1;
|
|
2082
|
+
return beforeEachSetupForKeepalive();
|
|
2083
|
+
case 1:
|
|
2084
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2085
|
+
webex: webex
|
|
2086
|
+
});
|
|
2087
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2088
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockResolvedValue();
|
|
2089
|
+
lineEmitter.mockClear();
|
|
2090
|
+
_context43.next = 2;
|
|
2091
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2092
|
+
case 2:
|
|
2093
|
+
expect(disconnectSocketSpy).toBeCalledOnceWith({
|
|
2094
|
+
code: 3050,
|
|
2095
|
+
reason: 'done (permanent)'
|
|
2096
|
+
});
|
|
2097
|
+
expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
|
|
2098
|
+
case 3:
|
|
2099
|
+
case "end":
|
|
2100
|
+
return _context43.stop();
|
|
2101
|
+
}
|
|
2102
|
+
}, _callee43);
|
|
2103
|
+
})));
|
|
2104
|
+
it('still notifies the consumer when the Mobius WebSocket teardown fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee44() {
|
|
2105
|
+
var apiRequest;
|
|
2106
|
+
return _regenerator.default.wrap(function (_context44) {
|
|
2107
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
2108
|
+
case 0:
|
|
2109
|
+
_context44.next = 1;
|
|
2110
|
+
return beforeEachSetupForKeepalive();
|
|
2111
|
+
case 1:
|
|
2112
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2113
|
+
webex: webex
|
|
2114
|
+
});
|
|
2115
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2116
|
+
jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockRejectedValue(new Error('socket teardown failed'));
|
|
2117
|
+
lineEmitter.mockClear();
|
|
2118
|
+
_context44.next = 2;
|
|
2119
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2120
|
+
case 2:
|
|
2121
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mobius socket disconnect failed after session-superseded'), {
|
|
2122
|
+
file: _constants.REGISTRATION_FILE,
|
|
2123
|
+
method: _constants.METHODS.HANDLE_409_KEEPALIVE_FAILURE
|
|
2124
|
+
});
|
|
2125
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
2126
|
+
expect(lineEmitter).toHaveBeenLastCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.any(_LineError.LineError));
|
|
2127
|
+
case 3:
|
|
2128
|
+
case "end":
|
|
2129
|
+
return _context44.stop();
|
|
2130
|
+
}
|
|
2131
|
+
}, _callee44);
|
|
2132
|
+
})));
|
|
2133
|
+
it.each([{
|
|
2134
|
+
description: '404 device not found',
|
|
2135
|
+
err: {
|
|
2136
|
+
statusCode: 404
|
|
2137
|
+
}
|
|
2138
|
+
}, {
|
|
2139
|
+
description: '429 too many requests',
|
|
2140
|
+
err: {
|
|
2141
|
+
statusCode: 429,
|
|
2142
|
+
headers: {
|
|
2143
|
+
'retry-after': 5
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
}, {
|
|
2147
|
+
description: '503 service unavailable',
|
|
2148
|
+
err: {
|
|
2149
|
+
statusCode: 503
|
|
2150
|
+
}
|
|
2151
|
+
}])('leaves the existing handling of $description untouched', /*#__PURE__*/function () {
|
|
2152
|
+
var _ref52 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee45(_ref51) {
|
|
2153
|
+
var err, handle409Spy;
|
|
2154
|
+
return _regenerator.default.wrap(function (_context45) {
|
|
2155
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
2156
|
+
case 0:
|
|
2157
|
+
err = _ref51.err;
|
|
2158
|
+
_context45.next = 1;
|
|
2159
|
+
return beforeEachSetupForKeepalive();
|
|
2160
|
+
case 1:
|
|
2161
|
+
handle409Spy = jest.spyOn(reg, 'handle409KeepaliveFailure');
|
|
2162
|
+
lineEmitter.mockClear();
|
|
2163
|
+
handleErrorSpy.mockClear();
|
|
2164
|
+
_context45.next = 2;
|
|
2165
|
+
return sendKeepaliveFailure(err, 1);
|
|
2166
|
+
case 2:
|
|
2167
|
+
expect(handle409Spy).not.toHaveBeenCalled();
|
|
2168
|
+
expect(handleErrorSpy).toHaveBeenCalledWith(err, expect.anything(), {
|
|
2169
|
+
file: _constants.REGISTRATION_FILE,
|
|
2170
|
+
method: _constants.KEEPALIVE_UTIL
|
|
2171
|
+
}, expect.anything());
|
|
2172
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.anything());
|
|
2173
|
+
case 3:
|
|
2174
|
+
case "end":
|
|
2175
|
+
return _context45.stop();
|
|
2176
|
+
}
|
|
2177
|
+
}, _callee45);
|
|
2178
|
+
}));
|
|
2179
|
+
return function (_x5) {
|
|
2180
|
+
return _ref52.apply(this, arguments);
|
|
2181
|
+
};
|
|
2182
|
+
}());
|
|
2183
|
+
it('stays terminal when the network recovers after a superseded session', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee46() {
|
|
2184
|
+
var retry;
|
|
2185
|
+
return _regenerator.default.wrap(function (_context46) {
|
|
2186
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
2187
|
+
case 0:
|
|
2188
|
+
_context46.next = 1;
|
|
2189
|
+
return beforeEachSetupForKeepalive();
|
|
2190
|
+
case 1:
|
|
2191
|
+
lineEmitter.mockClear();
|
|
2192
|
+
_context46.next = 2;
|
|
2193
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2194
|
+
case 2:
|
|
2195
|
+
expect(reg.sessionSuperseded).toStrictEqual(true);
|
|
2196
|
+
restoreSpy.mockClear();
|
|
2197
|
+
restartSpy.mockClear();
|
|
2198
|
+
postRegistrationSpy.mockClear();
|
|
2199
|
+
failoverSpy.mockClear();
|
|
2200
|
+
_context46.next = 3;
|
|
2201
|
+
return reg.handleConnectionRestoration(true);
|
|
2202
|
+
case 3:
|
|
2203
|
+
retry = _context46.sent;
|
|
2204
|
+
/* The restoration runs, but every registration attempt it makes is refused at the
|
|
2205
|
+
* choke point, so nothing reaches Mobius and no failover is rescheduled. */
|
|
2206
|
+
expect(retry).toStrictEqual(false);
|
|
2207
|
+
expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.METHODS.HANDLE_CONNECTION_RESTORATION), {
|
|
2208
|
+
file: _constants.REGISTRATION_FILE,
|
|
2209
|
+
method: _constants.METHODS.HANDLE_CONNECTION_RESTORATION
|
|
2210
|
+
});
|
|
2211
|
+
expect(postRegistrationSpy).not.toHaveBeenCalled();
|
|
2212
|
+
expect(restartSpy).not.toHaveBeenCalled();
|
|
2213
|
+
expect(failoverSpy).not.toHaveBeenCalled();
|
|
2214
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
2215
|
+
case 4:
|
|
2216
|
+
case "end":
|
|
2217
|
+
return _context46.stop();
|
|
2218
|
+
}
|
|
2219
|
+
}, _callee46);
|
|
2220
|
+
})));
|
|
2221
|
+
it('abandons a restoration that was already queued when the session was superseded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee47() {
|
|
2222
|
+
var release, restoration, _t;
|
|
2223
|
+
return _regenerator.default.wrap(function (_context47) {
|
|
2224
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
2225
|
+
case 0:
|
|
2226
|
+
_context47.next = 1;
|
|
2227
|
+
return beforeEachSetupForKeepalive();
|
|
2228
|
+
case 1:
|
|
2229
|
+
lineEmitter.mockClear();
|
|
2230
|
+
postRegistrationSpy.mockClear();
|
|
2231
|
+
restartSpy.mockClear();
|
|
2232
|
+
failoverSpy.mockClear();
|
|
2233
|
+
|
|
2234
|
+
/* Something else holds the mutex, so the restoration queues behind it having
|
|
2235
|
+
* begun while the session was still valid. */
|
|
2236
|
+
_context47.next = 2;
|
|
2237
|
+
return reg.mutex.acquire();
|
|
2238
|
+
case 2:
|
|
2239
|
+
release = _context47.sent;
|
|
2240
|
+
restoration = reg.handleConnectionRestoration(true);
|
|
2241
|
+
_context47.next = 3;
|
|
2242
|
+
return flushPromises();
|
|
2243
|
+
case 3:
|
|
2244
|
+
/* The 409 cleanup latches without the mutex, so the flip lands mid-wait. */
|
|
2245
|
+
reg.sessionSuperseded = true;
|
|
2246
|
+
release();
|
|
2247
|
+
_t = expect;
|
|
2248
|
+
_context47.next = 4;
|
|
2249
|
+
return restoration;
|
|
2250
|
+
case 4:
|
|
2251
|
+
_t(_context47.sent).toStrictEqual(false);
|
|
2252
|
+
/* The latch flipped after this restoration had already started, so the choke
|
|
2253
|
+
* point is what stops it: no device is registered for the dead session. */
|
|
2254
|
+
expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.METHODS.HANDLE_CONNECTION_RESTORATION), {
|
|
2255
|
+
file: _constants.REGISTRATION_FILE,
|
|
2256
|
+
method: _constants.METHODS.HANDLE_CONNECTION_RESTORATION
|
|
2257
|
+
});
|
|
2258
|
+
expect(postRegistrationSpy).not.toHaveBeenCalled();
|
|
2259
|
+
expect(restartSpy).not.toHaveBeenCalled();
|
|
2260
|
+
expect(failoverSpy).not.toHaveBeenCalled();
|
|
2261
|
+
case 5:
|
|
2262
|
+
case "end":
|
|
2263
|
+
return _context47.stop();
|
|
2264
|
+
}
|
|
2265
|
+
}, _callee47);
|
|
2266
|
+
})));
|
|
2267
|
+
it('stays terminal when all calls are cleared after a superseded session', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee48() {
|
|
2268
|
+
return _regenerator.default.wrap(function (_context48) {
|
|
2269
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
2270
|
+
case 0:
|
|
2271
|
+
_context48.next = 1;
|
|
2272
|
+
return beforeEachSetupForKeepalive();
|
|
2273
|
+
case 1:
|
|
2274
|
+
lineEmitter.mockClear();
|
|
2275
|
+
_context48.next = 2;
|
|
2276
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2277
|
+
case 2:
|
|
2278
|
+
postRegistrationSpy.mockClear();
|
|
2279
|
+
restartSpy.mockClear();
|
|
2280
|
+
failoverSpy.mockClear();
|
|
2281
|
+
_context48.next = 3;
|
|
2282
|
+
return reg.reconnectOnFailure(_constants.CALLS_CLEARED_HANDLER_UTIL);
|
|
2283
|
+
case 3:
|
|
2284
|
+
expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.CALLS_CLEARED_HANDLER_UTIL), {
|
|
2285
|
+
file: _constants.REGISTRATION_FILE,
|
|
2286
|
+
method: _constants.CALLS_CLEARED_HANDLER_UTIL
|
|
2287
|
+
});
|
|
2288
|
+
expect(postRegistrationSpy).not.toHaveBeenCalled();
|
|
2289
|
+
expect(restartSpy).not.toHaveBeenCalled();
|
|
2290
|
+
expect(failoverSpy).not.toHaveBeenCalled();
|
|
2291
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
2292
|
+
case 4:
|
|
2293
|
+
case "end":
|
|
2294
|
+
return _context48.stop();
|
|
2295
|
+
}
|
|
2296
|
+
}, _callee48);
|
|
2297
|
+
})));
|
|
2298
|
+
it('lets an explicit registration by the consumer clear the superseded state', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee49() {
|
|
2299
|
+
return _regenerator.default.wrap(function (_context49) {
|
|
2300
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
2301
|
+
case 0:
|
|
2302
|
+
_context49.next = 1;
|
|
2303
|
+
return beforeEachSetupForKeepalive();
|
|
2304
|
+
case 1:
|
|
2305
|
+
lineEmitter.mockClear();
|
|
2306
|
+
_context49.next = 2;
|
|
2307
|
+
return sendKeepaliveFailure(conflictError, 1);
|
|
2308
|
+
case 2:
|
|
2309
|
+
expect(reg.sessionSuperseded).toStrictEqual(true);
|
|
2310
|
+
postRegistrationSpy.mockResolvedValueOnce(successPayload);
|
|
2311
|
+
_context49.next = 3;
|
|
2312
|
+
return reg.triggerRegistration();
|
|
2313
|
+
case 3:
|
|
2314
|
+
expect(reg.sessionSuperseded).toStrictEqual(false);
|
|
2315
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
2316
|
+
case 4:
|
|
2317
|
+
case "end":
|
|
2318
|
+
return _context49.stop();
|
|
2319
|
+
}
|
|
2320
|
+
}, _callee49);
|
|
2321
|
+
})));
|
|
2322
|
+
it('latches the superseded state before waiting on the shared mutex', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee50() {
|
|
2323
|
+
var worker, release, inFlight, abort;
|
|
2324
|
+
return _regenerator.default.wrap(function (_context50) {
|
|
2325
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
2326
|
+
case 0:
|
|
2327
|
+
_context50.next = 1;
|
|
2328
|
+
return beforeEachSetupForKeepalive();
|
|
2329
|
+
case 1:
|
|
2330
|
+
worker = reg.webWorker;
|
|
2331
|
+
lineEmitter.mockClear();
|
|
2332
|
+
postRegistrationSpy.mockClear();
|
|
2333
|
+
|
|
2334
|
+
/* A recovery already holds the mutex, so the 409 cleanup queues behind it. */
|
|
2335
|
+
_context50.next = 2;
|
|
2336
|
+
return reg.mutex.acquire();
|
|
2337
|
+
case 2:
|
|
2338
|
+
release = _context50.sent;
|
|
2339
|
+
inFlight = worker.onmessage({
|
|
2340
|
+
data: {
|
|
2341
|
+
type: _types.WorkerMessageType.KEEPALIVE_FAILURE,
|
|
2342
|
+
err: conflictError,
|
|
2343
|
+
keepAliveRetryCount: 1
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
_context50.next = 3;
|
|
2347
|
+
return flushPromises();
|
|
2348
|
+
case 3:
|
|
2349
|
+
/* The latch and the worker teardown are visible before cleanup has run. */
|
|
2350
|
+
expect(reg.sessionSuperseded).toStrictEqual(true);
|
|
2351
|
+
expect(reg.webWorker).toBeUndefined();
|
|
2352
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.anything());
|
|
2353
|
+
|
|
2354
|
+
/* A registration path starting now aborts instead of racing the queued cleanup. */
|
|
2355
|
+
_context50.next = 4;
|
|
2356
|
+
return reg.attemptRegistrationWithServers(_constants.FAILOVER_UTIL);
|
|
2357
|
+
case 4:
|
|
2358
|
+
abort = _context50.sent;
|
|
2359
|
+
expect(abort).toStrictEqual(true);
|
|
2360
|
+
expect(postRegistrationSpy).not.toHaveBeenCalled();
|
|
2361
|
+
expect(warnSpy).toHaveBeenCalledWith("Session superseded, skipping registration attempt - caller: ".concat(_constants.FAILOVER_UTIL), {
|
|
2362
|
+
file: _constants.REGISTRATION_FILE,
|
|
2363
|
+
method: _constants.FAILOVER_UTIL
|
|
2364
|
+
});
|
|
2365
|
+
release();
|
|
2366
|
+
_context50.next = 5;
|
|
2367
|
+
return inFlight;
|
|
2368
|
+
case 5:
|
|
2369
|
+
_context50.next = 6;
|
|
2370
|
+
return flushPromises();
|
|
2371
|
+
case 6:
|
|
2372
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
2373
|
+
case 7:
|
|
2374
|
+
case "end":
|
|
2375
|
+
return _context50.stop();
|
|
2376
|
+
}
|
|
2377
|
+
}, _callee50);
|
|
2378
|
+
})));
|
|
2379
|
+
it('discards a 409 delivered by a keepalive worker that has been replaced', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee51() {
|
|
2380
|
+
var staleWorker, staleWorkerPostSpy, handle409Spy, failKeepalive, inFlight, currentWorker;
|
|
2381
|
+
return _regenerator.default.wrap(function (_context51) {
|
|
2382
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
2383
|
+
case 0:
|
|
2384
|
+
_context51.next = 1;
|
|
2385
|
+
return beforeEachSetupForKeepalive();
|
|
2386
|
+
case 1:
|
|
2387
|
+
staleWorker = reg.webWorker;
|
|
2388
|
+
staleWorkerPostSpy = jest.spyOn(staleWorker, 'postMessage');
|
|
2389
|
+
handle409Spy = jest.spyOn(reg, 'handle409KeepaliveFailure');
|
|
2390
|
+
jest.spyOn(reg, 'postKeepAlive').mockReturnValue(new _promise.default(function (_, reject) {
|
|
2391
|
+
failKeepalive = reject;
|
|
2392
|
+
}));
|
|
2393
|
+
lineEmitter.mockClear();
|
|
2394
|
+
inFlight = staleWorker.onmessage({
|
|
2395
|
+
data: {
|
|
2396
|
+
type: _types.WorkerMessageType.SEND_KEEPALIVE
|
|
2397
|
+
}
|
|
2398
|
+
});
|
|
2399
|
+
/* A re-registration (failback, connection restoration) swaps the worker while the
|
|
2400
|
+
* keepalive of the previous registration is still in flight. */
|
|
2401
|
+
currentWorker = {
|
|
2402
|
+
postMessage: jest.fn(),
|
|
2403
|
+
terminate: jest.fn(),
|
|
2404
|
+
onmessage: null
|
|
2405
|
+
};
|
|
2406
|
+
reg.webWorker = currentWorker;
|
|
2407
|
+
failKeepalive(conflictError);
|
|
2408
|
+
_context51.next = 2;
|
|
2409
|
+
return inFlight;
|
|
2410
|
+
case 2:
|
|
2411
|
+
_context51.next = 3;
|
|
2412
|
+
return flushPromises();
|
|
2413
|
+
case 3:
|
|
2414
|
+
expect(staleWorkerPostSpy).not.toHaveBeenCalledWith(expect.objectContaining({
|
|
2415
|
+
type: _types.WorkerMessageType.KEEPALIVE_RESULT
|
|
2416
|
+
}));
|
|
2417
|
+
expect(currentWorker.postMessage).not.toHaveBeenCalled();
|
|
2418
|
+
expect(handle409Spy).not.toHaveBeenCalled();
|
|
2419
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, expect.anything());
|
|
2420
|
+
case 4:
|
|
2421
|
+
case "end":
|
|
2422
|
+
return _context51.stop();
|
|
2423
|
+
}
|
|
2424
|
+
}, _callee51);
|
|
2425
|
+
})));
|
|
2426
|
+
});
|
|
2427
|
+
});
|
|
2428
|
+
describe('409 Conflict outside the keepalive flow', function () {
|
|
2429
|
+
/* The registration flow passes no sessionSupersededCb, so a 409 there is logged and
|
|
2430
|
+
* ignored: no consumer event, no registration-error metric, and non-final so the
|
|
2431
|
+
* server loop and failover proceed as they would for any non-fatal status. */
|
|
2432
|
+
it('ignores a 409 during registration without notifying the consumer', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee52() {
|
|
2433
|
+
var conflictPayload;
|
|
2434
|
+
return _regenerator.default.wrap(function (_context52) {
|
|
2435
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
2436
|
+
case 0:
|
|
2437
|
+
jest.useFakeTimers();
|
|
2438
|
+
conflictPayload = {
|
|
2439
|
+
statusCode: 409,
|
|
2440
|
+
headers: {
|
|
2441
|
+
trackingid: 'tid-reg-409'
|
|
2442
|
+
}
|
|
2443
|
+
};
|
|
2444
|
+
webex.request.mockRejectedValue(conflictPayload);
|
|
2445
|
+
lineEmitter.mockClear();
|
|
2446
|
+
metricSpy.mockClear();
|
|
2447
|
+
_context52.next = 1;
|
|
2448
|
+
return reg.triggerRegistration();
|
|
2449
|
+
case 1:
|
|
2450
|
+
expect(warnSpy).toHaveBeenCalledWith('409 Conflict: ignored, caller does not handle a superseded session', {
|
|
2451
|
+
file: _constants.REGISTRATION_FILE,
|
|
2452
|
+
method: _constants.REGISTRATION_UTIL
|
|
2453
|
+
});
|
|
2454
|
+
|
|
2455
|
+
/* No consumer notification and no registration-error metric on this path. */
|
|
2456
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED);
|
|
2457
|
+
expect(lineEmitter).not.toHaveBeenCalledWith(_types4.LINE_EVENTS.ERROR, undefined, expect.anything());
|
|
2458
|
+
expect(metricSpy).not.toHaveBeenCalledWith(_types5.METRIC_EVENT.REGISTRATION_ERROR, _types5.REG_ACTION.REGISTER, _types5.METRIC_TYPE.BEHAVIORAL, expect.anything(), expect.anything(), expect.anything(), expect.anything(), expect.anything());
|
|
2459
|
+
|
|
2460
|
+
/* Non-final: every server was tried and failover was scheduled. */
|
|
2461
|
+
expect(reg.getStatus()).toEqual(_types.RegistrationStatus.INACTIVE);
|
|
2462
|
+
expect(reg.sessionSuperseded).toStrictEqual(false);
|
|
2463
|
+
expect(failoverSpy).toHaveBeenCalled();
|
|
2464
|
+
case 2:
|
|
2465
|
+
case "end":
|
|
2466
|
+
return _context52.stop();
|
|
2467
|
+
}
|
|
2468
|
+
}, _callee52);
|
|
1832
2469
|
})));
|
|
1833
2470
|
});
|
|
1834
2471
|
describe('Primary server status checks', function () {
|
|
1835
|
-
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
2472
|
+
it('success: primary server status to be up', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee53() {
|
|
1836
2473
|
var pingSuccessPayload, status;
|
|
1837
|
-
return _regenerator.default.wrap(function (
|
|
1838
|
-
while (1) switch (
|
|
2474
|
+
return _regenerator.default.wrap(function (_context53) {
|
|
2475
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
1839
2476
|
case 0:
|
|
1840
2477
|
pingSuccessPayload = {
|
|
1841
2478
|
statusCode: 200
|
|
1842
2479
|
};
|
|
1843
2480
|
webex.request.mockResolvedValue(pingSuccessPayload);
|
|
1844
|
-
|
|
2481
|
+
_context53.next = 1;
|
|
1845
2482
|
return reg.isPrimaryActive();
|
|
1846
2483
|
case 1:
|
|
1847
|
-
status =
|
|
2484
|
+
status = _context53.sent;
|
|
1848
2485
|
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1849
2486
|
method: 'GET',
|
|
1850
2487
|
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
@@ -1852,23 +2489,23 @@ describe('Registration Tests', function () {
|
|
|
1852
2489
|
expect(status).toEqual(true);
|
|
1853
2490
|
case 2:
|
|
1854
2491
|
case "end":
|
|
1855
|
-
return
|
|
2492
|
+
return _context53.stop();
|
|
1856
2493
|
}
|
|
1857
|
-
},
|
|
2494
|
+
}, _callee53);
|
|
1858
2495
|
})));
|
|
1859
|
-
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
2496
|
+
it('failed: primary server status to be down', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee54() {
|
|
1860
2497
|
var pingFailurePayload, status;
|
|
1861
|
-
return _regenerator.default.wrap(function (
|
|
1862
|
-
while (1) switch (
|
|
2498
|
+
return _regenerator.default.wrap(function (_context54) {
|
|
2499
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
1863
2500
|
case 0:
|
|
1864
2501
|
pingFailurePayload = {
|
|
1865
2502
|
statusCode: 500
|
|
1866
2503
|
};
|
|
1867
2504
|
webex.request.mockResolvedValue(pingFailurePayload);
|
|
1868
|
-
|
|
2505
|
+
_context54.next = 1;
|
|
1869
2506
|
return reg.isPrimaryActive();
|
|
1870
2507
|
case 1:
|
|
1871
|
-
status =
|
|
2508
|
+
status = _context54.sent;
|
|
1872
2509
|
expect(webex.request).toBeCalledWith(_objectSpread({
|
|
1873
2510
|
method: 'GET',
|
|
1874
2511
|
uri: "https://mobius-dfw.webex.com/api/v1/ping"
|
|
@@ -1876,9 +2513,257 @@ describe('Registration Tests', function () {
|
|
|
1876
2513
|
expect(status).toEqual(false);
|
|
1877
2514
|
case 2:
|
|
1878
2515
|
case "end":
|
|
1879
|
-
return
|
|
2516
|
+
return _context54.stop();
|
|
2517
|
+
}
|
|
2518
|
+
}, _callee54);
|
|
2519
|
+
})));
|
|
2520
|
+
});
|
|
2521
|
+
describe('handleRegistrationDownEvent tests', function () {
|
|
2522
|
+
var registrationDownEvent = {
|
|
2523
|
+
type: 'async_event',
|
|
2524
|
+
eventId: 'evt-1',
|
|
2525
|
+
trackingId: 'tid-1',
|
|
2526
|
+
data: {
|
|
2527
|
+
eventType: 'registration.down',
|
|
2528
|
+
deviceInfo: {
|
|
2529
|
+
userId: 'u1',
|
|
2530
|
+
device: {
|
|
2531
|
+
deviceId: 'd1',
|
|
2532
|
+
uri: 'https://mobius/device/d1',
|
|
2533
|
+
status: 'ACTIVE'
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
beforeEach(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee55() {
|
|
2539
|
+
return _regenerator.default.wrap(function (_context55) {
|
|
2540
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
2541
|
+
case 0:
|
|
2542
|
+
postRegistrationSpy.mockResolvedValueOnce(successPayload);
|
|
2543
|
+
_context55.next = 1;
|
|
2544
|
+
return reg.triggerRegistration();
|
|
2545
|
+
case 1:
|
|
2546
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.ACTIVE);
|
|
2547
|
+
case 2:
|
|
2548
|
+
case "end":
|
|
2549
|
+
return _context55.stop();
|
|
2550
|
+
}
|
|
2551
|
+
}, _callee55);
|
|
2552
|
+
})));
|
|
2553
|
+
afterEach(function () {
|
|
2554
|
+
var calls = (0, _values.default)(reg.callManager.getActiveCalls());
|
|
2555
|
+
calls.forEach(function (call) {
|
|
2556
|
+
call.end();
|
|
2557
|
+
});
|
|
2558
|
+
reg.callManager.callCollection = {};
|
|
2559
|
+
});
|
|
2560
|
+
it('runs cleanup immediately when no active calls are present (socket disabled)', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee56() {
|
|
2561
|
+
var clearKeepaliveSpy, setStatusSpy, disconnectSocketSpy;
|
|
2562
|
+
return _regenerator.default.wrap(function (_context56) {
|
|
2563
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
2564
|
+
case 0:
|
|
2565
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
2566
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
2567
|
+
disconnectSocketSpy = jest.spyOn(_request.APIRequest.getInstance({
|
|
2568
|
+
webex: webex
|
|
2569
|
+
}), 'disconnectFromMobiusSocket');
|
|
2570
|
+
lineEmitter.mockClear();
|
|
2571
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
2572
|
+
_context56.next = 1;
|
|
2573
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2574
|
+
case 1:
|
|
2575
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
2576
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
2577
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2578
|
+
expect(reg.reconnectPending).toBe(false);
|
|
2579
|
+
expect(reg.scheduled429Retry).toBe(false);
|
|
2580
|
+
expect(reg.failoverImmediately).toBe(false);
|
|
2581
|
+
expect(reg.retryAfter).toBeUndefined();
|
|
2582
|
+
expect(reg.registerRetry).toBe(false);
|
|
2583
|
+
expect(disconnectSocketSpy).not.toHaveBeenCalled();
|
|
2584
|
+
/* A registration-down stop has no reason to report to the consumer. */
|
|
2585
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2586
|
+
case 2:
|
|
2587
|
+
case "end":
|
|
2588
|
+
return _context56.stop();
|
|
2589
|
+
}
|
|
2590
|
+
}, _callee56);
|
|
2591
|
+
})));
|
|
2592
|
+
it('ends the active call and still runs cleanup when an active call is present', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee57() {
|
|
2593
|
+
var clearKeepaliveSpy, setStatusSpy, activeCall, endSpy;
|
|
2594
|
+
return _regenerator.default.wrap(function (_context57) {
|
|
2595
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
2596
|
+
case 0:
|
|
2597
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
2598
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
2599
|
+
activeCall = reg.callManager.createCall();
|
|
2600
|
+
endSpy = jest.spyOn(activeCall, 'end');
|
|
2601
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(1);
|
|
2602
|
+
lineEmitter.mockClear();
|
|
2603
|
+
_context57.next = 1;
|
|
2604
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2605
|
+
case 1:
|
|
2606
|
+
expect(endSpy).toHaveBeenCalledTimes(1);
|
|
2607
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
2608
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
2609
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2610
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2611
|
+
case 2:
|
|
2612
|
+
case "end":
|
|
2613
|
+
return _context57.stop();
|
|
2614
|
+
}
|
|
2615
|
+
}, _callee57);
|
|
2616
|
+
})));
|
|
2617
|
+
it('runs cleanup without calling end when no active call is present on re-invocation', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee58() {
|
|
2618
|
+
var clearKeepaliveSpy, setStatusSpy;
|
|
2619
|
+
return _regenerator.default.wrap(function (_context58) {
|
|
2620
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
2621
|
+
case 0:
|
|
2622
|
+
clearKeepaliveSpy = jest.spyOn(reg, 'clearKeepaliveTimer');
|
|
2623
|
+
setStatusSpy = jest.spyOn(reg, 'setStatus');
|
|
2624
|
+
_context58.next = 1;
|
|
2625
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2626
|
+
case 1:
|
|
2627
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2628
|
+
clearKeepaliveSpy.mockClear();
|
|
2629
|
+
setStatusSpy.mockClear();
|
|
2630
|
+
lineEmitter.mockClear();
|
|
2631
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
2632
|
+
_context58.next = 2;
|
|
2633
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2634
|
+
case 2:
|
|
2635
|
+
expect(clearKeepaliveSpy).toHaveBeenCalled();
|
|
2636
|
+
expect(setStatusSpy).toHaveBeenCalledWith(_types.RegistrationStatus.INACTIVE);
|
|
2637
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2638
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2639
|
+
case 3:
|
|
2640
|
+
case "end":
|
|
2641
|
+
return _context58.stop();
|
|
2642
|
+
}
|
|
2643
|
+
}, _callee58);
|
|
2644
|
+
})));
|
|
2645
|
+
it('disconnects the Mobius WebSocket when socket is enabled', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee59() {
|
|
2646
|
+
var apiRequest, disconnectSocketSpy;
|
|
2647
|
+
return _regenerator.default.wrap(function (_context59) {
|
|
2648
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
2649
|
+
case 0:
|
|
2650
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2651
|
+
webex: webex
|
|
2652
|
+
});
|
|
2653
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2654
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockResolvedValue();
|
|
2655
|
+
lineEmitter.mockClear();
|
|
2656
|
+
expect((0, _keys.default)(reg.callManager.getActiveCalls()).length).toBe(0);
|
|
2657
|
+
_context59.next = 1;
|
|
2658
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2659
|
+
case 1:
|
|
2660
|
+
expect(disconnectSocketSpy).toHaveBeenCalledWith({
|
|
2661
|
+
code: 3050,
|
|
2662
|
+
reason: 'done (permanent)'
|
|
2663
|
+
});
|
|
2664
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2665
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2666
|
+
case 2:
|
|
2667
|
+
case "end":
|
|
2668
|
+
return _context59.stop();
|
|
2669
|
+
}
|
|
2670
|
+
}, _callee59);
|
|
2671
|
+
})));
|
|
2672
|
+
it('still emits UNREGISTERED when socket disconnect fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee60() {
|
|
2673
|
+
var apiRequest, disconnectSocketSpy;
|
|
2674
|
+
return _regenerator.default.wrap(function (_context60) {
|
|
2675
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
2676
|
+
case 0:
|
|
2677
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2678
|
+
webex: webex
|
|
2679
|
+
});
|
|
2680
|
+
jest.spyOn(apiRequest, 'isSocketEnabled').mockReturnValue(true);
|
|
2681
|
+
disconnectSocketSpy = jest.spyOn(apiRequest, 'disconnectFromMobiusSocket').mockRejectedValue(new Error('socket teardown failed'));
|
|
2682
|
+
lineEmitter.mockClear();
|
|
2683
|
+
_context60.next = 1;
|
|
2684
|
+
return reg.handleRegistrationDownEvent(registrationDownEvent);
|
|
2685
|
+
case 1:
|
|
2686
|
+
expect(disconnectSocketSpy).toHaveBeenCalled();
|
|
2687
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Mobius socket disconnect failed after registration-down'), {
|
|
2688
|
+
file: _constants.REGISTRATION_FILE,
|
|
2689
|
+
method: _constants.METHODS.HANDLE_REGISTRATION_DOWN_EVENT
|
|
2690
|
+
});
|
|
2691
|
+
expect(reg.getStatus()).toBe(_types.RegistrationStatus.INACTIVE);
|
|
2692
|
+
expect(lineEmitter).toHaveBeenCalledWith(_types4.LINE_EVENTS.UNREGISTERED, undefined, undefined);
|
|
2693
|
+
case 2:
|
|
2694
|
+
case "end":
|
|
2695
|
+
return _context60.stop();
|
|
2696
|
+
}
|
|
2697
|
+
}, _callee60);
|
|
2698
|
+
})));
|
|
2699
|
+
});
|
|
2700
|
+
describe('attemptRegistrationWithServers transport alignment', function () {
|
|
2701
|
+
var apiRequest;
|
|
2702
|
+
var setSocketEnabledSpy;
|
|
2703
|
+
beforeEach(function () {
|
|
2704
|
+
apiRequest = _request.APIRequest.getInstance({
|
|
2705
|
+
webex: webex
|
|
2706
|
+
});
|
|
2707
|
+
// Keep the actual transport on HTTP (no-op) so the registration flow stays simple;
|
|
2708
|
+
// we only assert which boolean the method derives from the server group's URL scheme.
|
|
2709
|
+
setSocketEnabledSpy = jest.spyOn(apiRequest, 'setSocketEnabled').mockImplementation(function () {});
|
|
2710
|
+
webex.request.mockResolvedValue(successPayload);
|
|
2711
|
+
});
|
|
2712
|
+
it('enables the WebSocket transport when the server group uses the wss:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee61() {
|
|
2713
|
+
return _regenerator.default.wrap(function (_context61) {
|
|
2714
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
2715
|
+
case 0:
|
|
2716
|
+
_context61.next = 1;
|
|
2717
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['wss://mobius.example.com/api/v1/calling/web/']);
|
|
2718
|
+
case 1:
|
|
2719
|
+
expect(setSocketEnabledSpy).toHaveBeenCalledWith(true);
|
|
2720
|
+
case 2:
|
|
2721
|
+
case "end":
|
|
2722
|
+
return _context61.stop();
|
|
2723
|
+
}
|
|
2724
|
+
}, _callee61);
|
|
2725
|
+
})));
|
|
2726
|
+
it('falls back to the HTTP transport when the server group uses the https:// scheme', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee62() {
|
|
2727
|
+
return _regenerator.default.wrap(function (_context62) {
|
|
2728
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
2729
|
+
case 0:
|
|
2730
|
+
_context62.next = 1;
|
|
2731
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['https://mobius.example.com/api/v1/calling/web/']);
|
|
2732
|
+
case 1:
|
|
2733
|
+
expect(setSocketEnabledSpy).toHaveBeenCalledWith(false);
|
|
2734
|
+
case 2:
|
|
2735
|
+
case "end":
|
|
2736
|
+
return _context62.stop();
|
|
2737
|
+
}
|
|
2738
|
+
}, _callee62);
|
|
2739
|
+
})));
|
|
2740
|
+
it('does not change the transport when the server group is empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee63() {
|
|
2741
|
+
return _regenerator.default.wrap(function (_context63) {
|
|
2742
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
2743
|
+
case 0:
|
|
2744
|
+
_context63.next = 1;
|
|
2745
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, []);
|
|
2746
|
+
case 1:
|
|
2747
|
+
expect(setSocketEnabledSpy).not.toHaveBeenCalled();
|
|
2748
|
+
case 2:
|
|
2749
|
+
case "end":
|
|
2750
|
+
return _context63.stop();
|
|
2751
|
+
}
|
|
2752
|
+
}, _callee63);
|
|
2753
|
+
})));
|
|
2754
|
+
it('derives the transport from the first server in the group', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee64() {
|
|
2755
|
+
return _regenerator.default.wrap(function (_context64) {
|
|
2756
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
2757
|
+
case 0:
|
|
2758
|
+
_context64.next = 1;
|
|
2759
|
+
return reg.attemptRegistrationWithServers(_constants.REGISTRATION_UTIL, ['wss://primary.example.com/api/v1/calling/web/', 'https://backup.example.com/api/v1/calling/web/']);
|
|
2760
|
+
case 1:
|
|
2761
|
+
expect(setSocketEnabledSpy).toHaveBeenCalledWith(true);
|
|
2762
|
+
case 2:
|
|
2763
|
+
case "end":
|
|
2764
|
+
return _context64.stop();
|
|
1880
2765
|
}
|
|
1881
|
-
},
|
|
2766
|
+
}, _callee64);
|
|
1882
2767
|
})));
|
|
1883
2768
|
});
|
|
1884
2769
|
});
|