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