@webex/internal-plugin-mercury 2.59.2 → 2.59.3-next.1
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/.eslintrc.js +6 -6
- package/README.md +64 -64
- package/babel.config.js +3 -3
- package/dist/config.js +18 -18
- package/dist/config.js.map +1 -1
- package/dist/errors.js +13 -13
- package/dist/errors.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mercury.js +1 -1
- package/dist/mercury.js.map +1 -1
- package/dist/socket/index.js.map +1 -1
- package/dist/socket/socket-base.js +76 -76
- package/dist/socket/socket-base.js.map +1 -1
- package/dist/socket/socket.js +2 -2
- package/dist/socket/socket.js.map +1 -1
- package/dist/socket/socket.shim.js +2 -2
- package/dist/socket/socket.shim.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +24 -23
- package/process +1 -1
- package/src/config.js +34 -34
- package/src/errors.js +66 -66
- package/src/index.js +32 -32
- package/src/mercury.js +498 -498
- package/src/socket/index.js +5 -5
- package/src/socket/socket-base.js +481 -481
- package/src/socket/socket.js +13 -13
- package/src/socket/socket.shim.js +31 -31
- package/test/integration/spec/mercury.js +117 -117
- package/test/integration/spec/sharable-mercury.js +59 -59
- package/test/integration/spec/webex.js +43 -43
- package/test/unit/lib/promise-tick.js +19 -19
- package/test/unit/spec/mercury-events.js +473 -473
- package/test/unit/spec/mercury.js +709 -709
- package/test/unit/spec/socket.js +812 -812
package/src/socket/socket.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import WS from 'ws';
|
|
6
|
-
|
|
7
|
-
import Socket from './socket-base';
|
|
8
|
-
|
|
9
|
-
Socket.getWebSocketConstructor = function getWebSocketConstructor() {
|
|
10
|
-
return WS;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default Socket;
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import WS from 'ws';
|
|
6
|
+
|
|
7
|
+
import Socket from './socket-base';
|
|
8
|
+
|
|
9
|
+
Socket.getWebSocketConstructor = function getWebSocketConstructor() {
|
|
10
|
+
return WS;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default Socket;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-globals */
|
|
2
|
-
|
|
3
|
-
/*!
|
|
4
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/* eslint-env browser */
|
|
8
|
-
|
|
9
|
-
import Socket from './socket-base';
|
|
10
|
-
|
|
11
|
-
Socket.getWebSocketConstructor = function getWebSocketConstructor() {
|
|
12
|
-
// Grabed from https://github.com/heineiuo/isomorphic-ws/blob/9b977394ac875638c045fd9cf774ed418484b394/browser.js
|
|
13
|
-
let ws;
|
|
14
|
-
|
|
15
|
-
if (typeof WebSocket !== 'undefined') {
|
|
16
|
-
ws = WebSocket;
|
|
17
|
-
} else if (typeof MozWebSocket !== 'undefined') {
|
|
18
|
-
// eslint-disable-next-line no-undef
|
|
19
|
-
ws = MozWebSocket;
|
|
20
|
-
} else if (typeof global !== 'undefined') {
|
|
21
|
-
ws = global.WebSocket || global.MozWebSocket;
|
|
22
|
-
} else if (typeof window !== 'undefined') {
|
|
23
|
-
ws = window.WebSocket || window.MozWebSocket;
|
|
24
|
-
} else if (typeof self !== 'undefined') {
|
|
25
|
-
ws = self.WebSocket || self.MozWebSocket;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return ws;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default Socket;
|
|
1
|
+
/* eslint-disable no-restricted-globals */
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-env browser */
|
|
8
|
+
|
|
9
|
+
import Socket from './socket-base';
|
|
10
|
+
|
|
11
|
+
Socket.getWebSocketConstructor = function getWebSocketConstructor() {
|
|
12
|
+
// Grabed from https://github.com/heineiuo/isomorphic-ws/blob/9b977394ac875638c045fd9cf774ed418484b394/browser.js
|
|
13
|
+
let ws;
|
|
14
|
+
|
|
15
|
+
if (typeof WebSocket !== 'undefined') {
|
|
16
|
+
ws = WebSocket;
|
|
17
|
+
} else if (typeof MozWebSocket !== 'undefined') {
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
19
|
+
ws = MozWebSocket;
|
|
20
|
+
} else if (typeof global !== 'undefined') {
|
|
21
|
+
ws = global.WebSocket || global.MozWebSocket;
|
|
22
|
+
} else if (typeof window !== 'undefined') {
|
|
23
|
+
ws = window.WebSocket || window.MozWebSocket;
|
|
24
|
+
} else if (typeof self !== 'undefined') {
|
|
25
|
+
ws = self.WebSocket || self.MozWebSocket;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return ws;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default Socket;
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-mercury';
|
|
6
|
-
|
|
7
|
-
import {assert} from '@webex/test-helper-chai';
|
|
8
|
-
import {flaky} from '@webex/test-helper-mocha';
|
|
9
|
-
import sinon from 'sinon';
|
|
10
|
-
import WebexCore from '@webex/webex-core';
|
|
11
|
-
import testUsers from '@webex/test-helper-test-users';
|
|
12
|
-
import refreshCallback from '@webex/test-helper-refresh-callback';
|
|
13
|
-
|
|
14
|
-
describe('plugin-mercury', function () {
|
|
15
|
-
this.timeout(30000);
|
|
16
|
-
describe('Mercury', () => {
|
|
17
|
-
let webex;
|
|
18
|
-
|
|
19
|
-
beforeEach(() =>
|
|
20
|
-
testUsers.create({count: 1}).then((users) => {
|
|
21
|
-
webex = new WebexCore({
|
|
22
|
-
credentials: {
|
|
23
|
-
supertoken: users[0].token,
|
|
24
|
-
},
|
|
25
|
-
config: {
|
|
26
|
-
credentials: {
|
|
27
|
-
refreshCallback,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
afterEach(() => webex && webex.internal.mercury.disconnect());
|
|
35
|
-
|
|
36
|
-
describe('#connect()', () => {
|
|
37
|
-
it('connects to mercury', () => webex.internal.mercury.connect());
|
|
38
|
-
|
|
39
|
-
it('refreshes the access token when a 4401 is received', () =>
|
|
40
|
-
webex.internal.device
|
|
41
|
-
.register()
|
|
42
|
-
.then(() => {
|
|
43
|
-
// eslint-disable-next-line camelcase
|
|
44
|
-
webex.credentials.supertoken.access_token = 'fake token';
|
|
45
|
-
|
|
46
|
-
return webex.internal.mercury.connect();
|
|
47
|
-
})
|
|
48
|
-
// eslint-disable-next-line camelcase
|
|
49
|
-
.then(() => assert.notEqual(webex.credentials.supertoken.access_token, 'fake token')));
|
|
50
|
-
|
|
51
|
-
// This doesn't work as designed yet. The only way to get a 4404 is to try
|
|
52
|
-
// to connect to someone else's valid registration; the intent was to get
|
|
53
|
-
// a 4404 any time we try to connect to an invalid url. Actually, as it's
|
|
54
|
-
// implemented, it should really be a 4403.
|
|
55
|
-
// it(`refreshes the device when a 4404 is received`, () => webex.internal.device.register()
|
|
56
|
-
// .then(() => {
|
|
57
|
-
// const webSocketUrl = webex.internal.device.webSocketUrl;
|
|
58
|
-
// const wsu = webex.internal.device.webSocketUrl.split(`/`);
|
|
59
|
-
// wsu.reverse();
|
|
60
|
-
// wsu[1] = uuid.v4();
|
|
61
|
-
// wsu.reverse();
|
|
62
|
-
// webex.internal.device.webSocketUrl = wsu.join(`/`);
|
|
63
|
-
// return webex.internal.mercury.connect()
|
|
64
|
-
// .then(() => assert.notEqual(webex.internal.device.webSocketUrl, webSocketUrl));
|
|
65
|
-
// }));
|
|
66
|
-
|
|
67
|
-
describe('when using an ephemeral device', () => {
|
|
68
|
-
beforeEach(() => {
|
|
69
|
-
webex.config.device.ephemeral = true;
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('connects to mercury', () => webex.internal.mercury.connect());
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe('when web-high-availability is enabled', () => {
|
|
76
|
-
flaky(it, process.env.SKIP_FLAKY_TESTS)(
|
|
77
|
-
'connects to mercury using service catalog url',
|
|
78
|
-
() => {
|
|
79
|
-
let defaultWebSocketUrl;
|
|
80
|
-
|
|
81
|
-
// we need to ensure the feature is set for user before "registering"
|
|
82
|
-
// the device
|
|
83
|
-
return (
|
|
84
|
-
webex.internal.device
|
|
85
|
-
.register()
|
|
86
|
-
.then(() =>
|
|
87
|
-
webex.internal.feature.setFeature('developer', 'web-high-availability', true)
|
|
88
|
-
)
|
|
89
|
-
.then(() => webex.internal.device.unregister())
|
|
90
|
-
// start the test flow the device list
|
|
91
|
-
.then(() => webex.internal.device.register())
|
|
92
|
-
.then(() => {
|
|
93
|
-
defaultWebSocketUrl = webex.internal.device.webSocketUrl;
|
|
94
|
-
})
|
|
95
|
-
.then(() => webex.internal.mercury.connect())
|
|
96
|
-
.then(() => webex.internal.device.getWebSocketUrl())
|
|
97
|
-
.then((wsUrl) => {
|
|
98
|
-
assert.notEqual(defaultWebSocketUrl, webex.internal.mercury.socket.url);
|
|
99
|
-
assert.include(webex.internal.mercury.socket.url, wsUrl);
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('emits messages that arrive before authorization completes', () => {
|
|
108
|
-
const spy = sinon.spy();
|
|
109
|
-
|
|
110
|
-
webex.internal.mercury.on('event:mercury.buffer_state', spy);
|
|
111
|
-
|
|
112
|
-
return webex.internal.mercury.connect().then(() => {
|
|
113
|
-
assert.calledOnce(spy);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@webex/internal-plugin-mercury';
|
|
6
|
+
|
|
7
|
+
import {assert} from '@webex/test-helper-chai';
|
|
8
|
+
import {flaky} from '@webex/test-helper-mocha';
|
|
9
|
+
import sinon from 'sinon';
|
|
10
|
+
import WebexCore from '@webex/webex-core';
|
|
11
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
12
|
+
import refreshCallback from '@webex/test-helper-refresh-callback';
|
|
13
|
+
|
|
14
|
+
describe('plugin-mercury', function () {
|
|
15
|
+
this.timeout(30000);
|
|
16
|
+
describe('Mercury', () => {
|
|
17
|
+
let webex;
|
|
18
|
+
|
|
19
|
+
beforeEach(() =>
|
|
20
|
+
testUsers.create({count: 1}).then((users) => {
|
|
21
|
+
webex = new WebexCore({
|
|
22
|
+
credentials: {
|
|
23
|
+
supertoken: users[0].token,
|
|
24
|
+
},
|
|
25
|
+
config: {
|
|
26
|
+
credentials: {
|
|
27
|
+
refreshCallback,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
afterEach(() => webex && webex.internal.mercury.disconnect());
|
|
35
|
+
|
|
36
|
+
describe('#connect()', () => {
|
|
37
|
+
it('connects to mercury', () => webex.internal.mercury.connect());
|
|
38
|
+
|
|
39
|
+
it('refreshes the access token when a 4401 is received', () =>
|
|
40
|
+
webex.internal.device
|
|
41
|
+
.register()
|
|
42
|
+
.then(() => {
|
|
43
|
+
// eslint-disable-next-line camelcase
|
|
44
|
+
webex.credentials.supertoken.access_token = 'fake token';
|
|
45
|
+
|
|
46
|
+
return webex.internal.mercury.connect();
|
|
47
|
+
})
|
|
48
|
+
// eslint-disable-next-line camelcase
|
|
49
|
+
.then(() => assert.notEqual(webex.credentials.supertoken.access_token, 'fake token')));
|
|
50
|
+
|
|
51
|
+
// This doesn't work as designed yet. The only way to get a 4404 is to try
|
|
52
|
+
// to connect to someone else's valid registration; the intent was to get
|
|
53
|
+
// a 4404 any time we try to connect to an invalid url. Actually, as it's
|
|
54
|
+
// implemented, it should really be a 4403.
|
|
55
|
+
// it(`refreshes the device when a 4404 is received`, () => webex.internal.device.register()
|
|
56
|
+
// .then(() => {
|
|
57
|
+
// const webSocketUrl = webex.internal.device.webSocketUrl;
|
|
58
|
+
// const wsu = webex.internal.device.webSocketUrl.split(`/`);
|
|
59
|
+
// wsu.reverse();
|
|
60
|
+
// wsu[1] = uuid.v4();
|
|
61
|
+
// wsu.reverse();
|
|
62
|
+
// webex.internal.device.webSocketUrl = wsu.join(`/`);
|
|
63
|
+
// return webex.internal.mercury.connect()
|
|
64
|
+
// .then(() => assert.notEqual(webex.internal.device.webSocketUrl, webSocketUrl));
|
|
65
|
+
// }));
|
|
66
|
+
|
|
67
|
+
describe('when using an ephemeral device', () => {
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
webex.config.device.ephemeral = true;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('connects to mercury', () => webex.internal.mercury.connect());
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('when web-high-availability is enabled', () => {
|
|
76
|
+
flaky(it, process.env.SKIP_FLAKY_TESTS)(
|
|
77
|
+
'connects to mercury using service catalog url',
|
|
78
|
+
() => {
|
|
79
|
+
let defaultWebSocketUrl;
|
|
80
|
+
|
|
81
|
+
// we need to ensure the feature is set for user before "registering"
|
|
82
|
+
// the device
|
|
83
|
+
return (
|
|
84
|
+
webex.internal.device
|
|
85
|
+
.register()
|
|
86
|
+
.then(() =>
|
|
87
|
+
webex.internal.feature.setFeature('developer', 'web-high-availability', true)
|
|
88
|
+
)
|
|
89
|
+
.then(() => webex.internal.device.unregister())
|
|
90
|
+
// start the test flow the device list
|
|
91
|
+
.then(() => webex.internal.device.register())
|
|
92
|
+
.then(() => {
|
|
93
|
+
defaultWebSocketUrl = webex.internal.device.webSocketUrl;
|
|
94
|
+
})
|
|
95
|
+
.then(() => webex.internal.mercury.connect())
|
|
96
|
+
.then(() => webex.internal.device.getWebSocketUrl())
|
|
97
|
+
.then((wsUrl) => {
|
|
98
|
+
assert.notEqual(defaultWebSocketUrl, webex.internal.mercury.socket.url);
|
|
99
|
+
assert.include(webex.internal.mercury.socket.url, wsUrl);
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('emits messages that arrive before authorization completes', () => {
|
|
108
|
+
const spy = sinon.spy();
|
|
109
|
+
|
|
110
|
+
webex.internal.mercury.on('event:mercury.buffer_state', spy);
|
|
111
|
+
|
|
112
|
+
return webex.internal.mercury.connect().then(() => {
|
|
113
|
+
assert.calledOnce(spy);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-mercury';
|
|
6
|
-
|
|
7
|
-
import {assert} from '@webex/test-helper-chai';
|
|
8
|
-
import sinon from 'sinon';
|
|
9
|
-
import WebexCore from '@webex/webex-core';
|
|
10
|
-
import testUsers from '@webex/test-helper-test-users';
|
|
11
|
-
|
|
12
|
-
describe('plugin-mercury', function () {
|
|
13
|
-
this.timeout(30000);
|
|
14
|
-
describe('Sharable Mercury', () => {
|
|
15
|
-
let webex;
|
|
16
|
-
|
|
17
|
-
beforeEach(() =>
|
|
18
|
-
testUsers.create({count: 1}).then((users) => {
|
|
19
|
-
webex = new WebexCore({
|
|
20
|
-
credentials: {
|
|
21
|
-
supertoken: users[0].token,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return webex.internal.device
|
|
26
|
-
.register()
|
|
27
|
-
.then(() => webex.internal.feature.setFeature('developer', 'web-shared-mercury', true));
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
afterEach(() => webex && webex.internal.mercury.disconnect());
|
|
32
|
-
|
|
33
|
-
describe('#connect()', () => {
|
|
34
|
-
it('connects to mercury', () => webex.internal.mercury.connect());
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('emits messages that arrive before authorization completes', () => {
|
|
38
|
-
const spy1 = sinon.spy();
|
|
39
|
-
const spy2 = sinon.spy();
|
|
40
|
-
|
|
41
|
-
webex.internal.mercury.on('event:mercury.buffer_state', spy1);
|
|
42
|
-
webex.internal.mercury.on('event:mercury.registration_status', spy2);
|
|
43
|
-
|
|
44
|
-
return webex.internal.mercury.connect().then(() => {
|
|
45
|
-
assert.notCalled(spy1);
|
|
46
|
-
assert.calledOnce(spy2);
|
|
47
|
-
const {data} = spy2.args[0][0];
|
|
48
|
-
|
|
49
|
-
assert.property(data, 'bufferState');
|
|
50
|
-
assert.property(data, 'localClusterServiceUrls');
|
|
51
|
-
|
|
52
|
-
assert.deepEqual(
|
|
53
|
-
webex.internal.mercury.localClusterServiceUrls,
|
|
54
|
-
data.localClusterServiceUrls
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
});
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@webex/internal-plugin-mercury';
|
|
6
|
+
|
|
7
|
+
import {assert} from '@webex/test-helper-chai';
|
|
8
|
+
import sinon from 'sinon';
|
|
9
|
+
import WebexCore from '@webex/webex-core';
|
|
10
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
11
|
+
|
|
12
|
+
describe('plugin-mercury', function () {
|
|
13
|
+
this.timeout(30000);
|
|
14
|
+
describe('Sharable Mercury', () => {
|
|
15
|
+
let webex;
|
|
16
|
+
|
|
17
|
+
beforeEach(() =>
|
|
18
|
+
testUsers.create({count: 1}).then((users) => {
|
|
19
|
+
webex = new WebexCore({
|
|
20
|
+
credentials: {
|
|
21
|
+
supertoken: users[0].token,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return webex.internal.device
|
|
26
|
+
.register()
|
|
27
|
+
.then(() => webex.internal.feature.setFeature('developer', 'web-shared-mercury', true));
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
afterEach(() => webex && webex.internal.mercury.disconnect());
|
|
32
|
+
|
|
33
|
+
describe('#connect()', () => {
|
|
34
|
+
it('connects to mercury', () => webex.internal.mercury.connect());
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('emits messages that arrive before authorization completes', () => {
|
|
38
|
+
const spy1 = sinon.spy();
|
|
39
|
+
const spy2 = sinon.spy();
|
|
40
|
+
|
|
41
|
+
webex.internal.mercury.on('event:mercury.buffer_state', spy1);
|
|
42
|
+
webex.internal.mercury.on('event:mercury.registration_status', spy2);
|
|
43
|
+
|
|
44
|
+
return webex.internal.mercury.connect().then(() => {
|
|
45
|
+
assert.notCalled(spy1);
|
|
46
|
+
assert.calledOnce(spy2);
|
|
47
|
+
const {data} = spy2.args[0][0];
|
|
48
|
+
|
|
49
|
+
assert.property(data, 'bufferState');
|
|
50
|
+
assert.property(data, 'localClusterServiceUrls');
|
|
51
|
+
|
|
52
|
+
assert.deepEqual(
|
|
53
|
+
webex.internal.mercury.localClusterServiceUrls,
|
|
54
|
+
data.localClusterServiceUrls
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-mercury';
|
|
6
|
-
|
|
7
|
-
import {assert} from '@webex/test-helper-chai';
|
|
8
|
-
import sinon from 'sinon';
|
|
9
|
-
import WebexCore from '@webex/webex-core';
|
|
10
|
-
import testUsers from '@webex/test-helper-test-users';
|
|
11
|
-
|
|
12
|
-
describe('plugin-mercury', function () {
|
|
13
|
-
this.timeout(30000);
|
|
14
|
-
|
|
15
|
-
let webex;
|
|
16
|
-
|
|
17
|
-
beforeEach('create users', () =>
|
|
18
|
-
testUsers.create({count: 1}).then(async (users) => {
|
|
19
|
-
// Pause for 5 seconds for CI
|
|
20
|
-
await new Promise((done) => setTimeout(done, 5000));
|
|
21
|
-
|
|
22
|
-
webex = new WebexCore({
|
|
23
|
-
credentials: {
|
|
24
|
-
supertoken: users[0].token,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
sinon.spy(webex.internal.mercury, 'disconnect');
|
|
28
|
-
sinon.spy(webex.internal.device, 'unregister');
|
|
29
|
-
|
|
30
|
-
return webex.internal.mercury.connect();
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
describe('onBeforeLogout()', () => {
|
|
35
|
-
it('disconnects the web socket', () =>
|
|
36
|
-
webex.logout({noRedirect: true}).then(() => {
|
|
37
|
-
assert.called(webex.internal.mercury.disconnect);
|
|
38
|
-
assert.isFalse(webex.internal.mercury.connected);
|
|
39
|
-
assert.called(webex.internal.device.unregister);
|
|
40
|
-
assert.isFalse(webex.internal.device.registered);
|
|
41
|
-
}));
|
|
42
|
-
});
|
|
43
|
-
});
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@webex/internal-plugin-mercury';
|
|
6
|
+
|
|
7
|
+
import {assert} from '@webex/test-helper-chai';
|
|
8
|
+
import sinon from 'sinon';
|
|
9
|
+
import WebexCore from '@webex/webex-core';
|
|
10
|
+
import testUsers from '@webex/test-helper-test-users';
|
|
11
|
+
|
|
12
|
+
describe('plugin-mercury', function () {
|
|
13
|
+
this.timeout(30000);
|
|
14
|
+
|
|
15
|
+
let webex;
|
|
16
|
+
|
|
17
|
+
beforeEach('create users', () =>
|
|
18
|
+
testUsers.create({count: 1}).then(async (users) => {
|
|
19
|
+
// Pause for 5 seconds for CI
|
|
20
|
+
await new Promise((done) => setTimeout(done, 5000));
|
|
21
|
+
|
|
22
|
+
webex = new WebexCore({
|
|
23
|
+
credentials: {
|
|
24
|
+
supertoken: users[0].token,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
sinon.spy(webex.internal.mercury, 'disconnect');
|
|
28
|
+
sinon.spy(webex.internal.device, 'unregister');
|
|
29
|
+
|
|
30
|
+
return webex.internal.mercury.connect();
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
describe('onBeforeLogout()', () => {
|
|
35
|
+
it('disconnects the web socket', () =>
|
|
36
|
+
webex.logout({noRedirect: true}).then(() => {
|
|
37
|
+
assert.called(webex.internal.mercury.disconnect);
|
|
38
|
+
assert.isFalse(webex.internal.mercury.connected);
|
|
39
|
+
assert.called(webex.internal.device.unregister);
|
|
40
|
+
assert.isFalse(webex.internal.device.registered);
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Uses Promise#then to run some number of ticks
|
|
7
|
-
* @param {number} count
|
|
8
|
-
* @returns {Promise}
|
|
9
|
-
*/
|
|
10
|
-
export default function promiseTick(count) {
|
|
11
|
-
let promise = Promise.resolve();
|
|
12
|
-
|
|
13
|
-
while (count > 1) {
|
|
14
|
-
promise = promise.then(() => promiseTick(1));
|
|
15
|
-
count -= 1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return promise;
|
|
19
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Uses Promise#then to run some number of ticks
|
|
7
|
+
* @param {number} count
|
|
8
|
+
* @returns {Promise}
|
|
9
|
+
*/
|
|
10
|
+
export default function promiseTick(count) {
|
|
11
|
+
let promise = Promise.resolve();
|
|
12
|
+
|
|
13
|
+
while (count > 1) {
|
|
14
|
+
promise = promise.then(() => promiseTick(1));
|
|
15
|
+
count -= 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return promise;
|
|
19
|
+
}
|