@webex/plugin-meetings 2.25.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/logs/logger-proxy.js +7 -6
- package/dist/common/logs/logger-proxy.js.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.js +4 -11
- package/dist/constants.js.map +1 -1
- package/dist/media/properties.js +2 -2
- package/dist/media/properties.js.map +1 -1
- package/dist/media/util.js +18 -4
- package/dist/media/util.js.map +1 -1
- package/dist/meeting/index.js +3 -1
- package/dist/meeting/index.js.map +1 -1
- package/dist/metrics/constants.js +2 -1
- package/dist/metrics/constants.js.map +1 -1
- package/dist/peer-connection-manager/index.js +6 -4
- package/dist/peer-connection-manager/index.js.map +1 -1
- package/dist/reconnection-manager/index.js +40 -14
- package/dist/reconnection-manager/index.js.map +1 -1
- package/dist/roap/handler.js +0 -2
- package/dist/roap/handler.js.map +1 -1
- package/dist/roap/index.js +36 -7
- package/dist/roap/index.js.map +1 -1
- package/dist/roap/request.js +5 -3
- package/dist/roap/request.js.map +1 -1
- package/dist/roap/turnDiscovery.js +273 -0
- package/dist/roap/turnDiscovery.js.map +1 -0
- package/dist/roap/util.js +0 -2
- package/dist/roap/util.js.map +1 -1
- package/package.json +5 -5
- package/src/common/logs/logger-proxy.js +7 -6
- package/src/config.js +2 -1
- package/src/constants.ts +3 -4
- package/src/media/properties.js +2 -2
- package/src/media/util.js +17 -7
- package/src/meeting/index.js +3 -2
- package/src/metrics/constants.js +2 -1
- package/src/peer-connection-manager/index.js +6 -3
- package/src/reconnection-manager/index.js +13 -10
- package/src/roap/handler.js +0 -2
- package/src/roap/index.js +36 -6
- package/src/roap/request.js +5 -3
- package/src/roap/turnDiscovery.ts +238 -0
- package/src/roap/util.js +0 -2
- package/test/unit/spec/meeting/index.js +35 -0
- package/test/unit/spec/peerconnection-manager/index.js +47 -4
- package/test/unit/spec/roap/index.ts +113 -0
- package/test/unit/spec/roap/turnDiscovery.ts +334 -0
|
@@ -893,6 +893,7 @@ describe('plugin-meetings', () => {
|
|
|
893
893
|
meeting.mediaProperties.peerConnection.connectionState = CONSTANTS.CONNECTION_STATE.CONNECTED;
|
|
894
894
|
resolve();
|
|
895
895
|
}));
|
|
896
|
+
meeting.roap.doTurnDiscovery = sinon.stub().resolves();
|
|
896
897
|
PeerConnectionManager.setContentSlides = sinon.stub().returns(true);
|
|
897
898
|
});
|
|
898
899
|
|
|
@@ -1008,22 +1009,56 @@ describe('plugin-meetings', () => {
|
|
|
1008
1009
|
|
|
1009
1010
|
it('should attach the media and return promise', async () => {
|
|
1010
1011
|
meeting.meetingState = 'ACTIVE';
|
|
1012
|
+
MediaUtil.createPeerConnection.resetHistory();
|
|
1011
1013
|
const media = meeting.addMedia({
|
|
1012
1014
|
mediaSettings: {}
|
|
1013
1015
|
});
|
|
1014
1016
|
|
|
1015
1017
|
assert.exists(media);
|
|
1016
1018
|
await media;
|
|
1019
|
+
assert.calledOnce(meeting.roap.doTurnDiscovery);
|
|
1020
|
+
assert.calledWith(meeting.roap.doTurnDiscovery, meeting, false);
|
|
1017
1021
|
assert.calledOnce(meeting.mediaProperties.setMediaDirection);
|
|
1018
1022
|
assert.calledOnce(Media.attachMedia);
|
|
1019
1023
|
assert.calledOnce(meeting.setMercuryListener);
|
|
1020
1024
|
assert.calledOnce(meeting.setRemoteStream);
|
|
1021
1025
|
assert.calledOnce(meeting.roap.sendRoapMediaRequest);
|
|
1026
|
+
assert.calledOnce(MediaUtil.createPeerConnection);
|
|
1027
|
+
assert.calledWith(MediaUtil.createPeerConnection, undefined);
|
|
1022
1028
|
/* statsAnalyzer is initiated inside of addMedia so there isn't
|
|
1023
1029
|
* a good way to mock it without mocking the constructor
|
|
1024
1030
|
*/
|
|
1025
1031
|
});
|
|
1026
1032
|
|
|
1033
|
+
it('should pass the turn server info to the peer connection', async () => {
|
|
1034
|
+
const FAKE_TURN_URL = 'turns:webex.com:3478';
|
|
1035
|
+
const FAKE_TURN_USER = 'some-turn-username';
|
|
1036
|
+
const FAKE_TURN_PASSWORD = 'some-password';
|
|
1037
|
+
|
|
1038
|
+
meeting.meetingState = 'ACTIVE';
|
|
1039
|
+
MediaUtil.createPeerConnection.resetHistory();
|
|
1040
|
+
|
|
1041
|
+
meeting.roap.doTurnDiscovery = sinon.stub().resolves({
|
|
1042
|
+
url: FAKE_TURN_URL,
|
|
1043
|
+
username: FAKE_TURN_USER,
|
|
1044
|
+
password: FAKE_TURN_PASSWORD
|
|
1045
|
+
});
|
|
1046
|
+
const media = meeting.addMedia({
|
|
1047
|
+
mediaSettings: {}
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
assert.exists(media);
|
|
1051
|
+
await media;
|
|
1052
|
+
assert.calledOnce(meeting.roap.doTurnDiscovery);
|
|
1053
|
+
assert.calledWith(meeting.roap.doTurnDiscovery, meeting, false);
|
|
1054
|
+
assert.calledOnce(MediaUtil.createPeerConnection);
|
|
1055
|
+
assert.calledWith(MediaUtil.createPeerConnection, {
|
|
1056
|
+
url: FAKE_TURN_URL,
|
|
1057
|
+
username: FAKE_TURN_USER,
|
|
1058
|
+
password: FAKE_TURN_PASSWORD
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1027
1062
|
it('should attach the media and return promise', async () => {
|
|
1028
1063
|
meeting.meetingState = 'ACTIVE';
|
|
1029
1064
|
meeting.mediaProperties.peerConnection.connectionState = 'DISCONNECTED';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import 'jsdom-global/register';
|
|
2
2
|
import {assert} from '@webex/test-helper-chai';
|
|
3
3
|
import sinon from 'sinon';
|
|
4
|
+
|
|
4
5
|
import PeerConnectionManager from '@webex/plugin-meetings/src/peer-connection-manager/index';
|
|
5
6
|
import StaticConfig from '@webex/plugin-meetings/src/common/config';
|
|
6
|
-
import {
|
|
7
|
+
import {InvalidSdpError} from '@webex/plugin-meetings/src/common/errors/webex-errors';
|
|
7
8
|
|
|
8
9
|
describe('Peerconnection Manager', () => {
|
|
9
10
|
describe('Methods', () => {
|
|
@@ -85,6 +86,45 @@ describe('Peerconnection Manager', () => {
|
|
|
85
86
|
|
|
86
87
|
assert.equal(result.sdp, remoteSdp);
|
|
87
88
|
});
|
|
89
|
+
|
|
90
|
+
it('removes xTLS candidates from the remote sdp', async () => {
|
|
91
|
+
StaticConfig.set({bandwidth: {}});
|
|
92
|
+
|
|
93
|
+
const remoteSdpWithXtlsCandidates = 'v=0\r\n' +
|
|
94
|
+
'm=video 5004 UDP/TLS/RTP/SAVPF 102 127 97 99\r\n' +
|
|
95
|
+
'a=candidate:1 1 UDP 2130706175 18.206.82.54 9000 typ host\r\n' +
|
|
96
|
+
'a=candidate:2 1 TCP 1962934271 18.206.82.54 5004 typ host tcptype passive\r\n' +
|
|
97
|
+
'a=candidate:3 1 TCP 1962934015 18.206.82.54 9000 typ host tcptype passive\r\n' +
|
|
98
|
+
'a=candidate:4 1 xTLS 1795162111 external-media2.aintm-a-6.int.infra.webex.com 443 typ host tcptype passive fingerprint sha-1;55:B8:1D:94:BC:9D:B2:A5:5E:82:E7:84:C6:C8:10:AC:D3:FD:96:26\r\n' +
|
|
99
|
+
'a=rtpmap:127 H264/90000\r\n' +
|
|
100
|
+
'a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\n' +
|
|
101
|
+
'm=video 9000 UDP/TLS/RTP/SAVPF 102 127 97 99\r\n' +
|
|
102
|
+
'a=candidate:1 1 xTLS 1795162111 external-media2.aintm-a-6.int.infra.webex.com 443 typ host tcptype passive fingerprint sha-1;55:B8:1D:94:BC:9D:B2:A5:5E:82:E7:84:C6:C8:10:AC:D3:FD:96:26\r\n' +
|
|
103
|
+
'a=candidate:2 1 TCP 1962934271 18.206.82.54 5004 typ host tcptype passive\r\n' +
|
|
104
|
+
'a=fmtp:127 profile-level-id=42e016;max-mbps=244800;max-fs=8160;max-fps=3000;max-dpb=12240;max-rcmd-nalu-size=196608;level-asymmetry-allowed=1\r\n';
|
|
105
|
+
|
|
106
|
+
// same as remoteSdpWithXtlsCandidates but without the xtls candidates
|
|
107
|
+
const resultSdp = 'v=0\r\n' +
|
|
108
|
+
'm=video 5004 UDP/TLS/RTP/SAVPF 102 127 97 99\r\n' +
|
|
109
|
+
'a=candidate:1 1 UDP 2130706175 18.206.82.54 9000 typ host\r\n' +
|
|
110
|
+
'a=candidate:2 1 TCP 1962934271 18.206.82.54 5004 typ host tcptype passive\r\n' +
|
|
111
|
+
'a=candidate:3 1 TCP 1962934015 18.206.82.54 9000 typ host tcptype passive\r\n' +
|
|
112
|
+
'a=rtpmap:127 H264/90000\r\n' +
|
|
113
|
+
'a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\n' +
|
|
114
|
+
'm=video 9000 UDP/TLS/RTP/SAVPF 102 127 97 99\r\n' +
|
|
115
|
+
'a=candidate:2 1 TCP 1962934271 18.206.82.54 5004 typ host tcptype passive\r\n' +
|
|
116
|
+
'a=fmtp:127 profile-level-id=42e016;max-mbps=244800;max-fs=8160;max-fps=3000;max-dpb=12240;max-rcmd-nalu-size=196608;level-asymmetry-allowed=1\r\n';
|
|
117
|
+
|
|
118
|
+
const peerConnection = {
|
|
119
|
+
signalingState: 'have-local-offer',
|
|
120
|
+
setRemoteDescription: sinon.stub().resolves(),
|
|
121
|
+
enableExtmap: true
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
await PeerConnectionManager.setRemoteSessionDetails(peerConnection, 'answer', remoteSdpWithXtlsCandidates, '');
|
|
125
|
+
|
|
126
|
+
assert.calledWith(peerConnection.setRemoteDescription, new global.window.RTCSessionDescription({sdp: resultSdp, type: 'answer'}));
|
|
127
|
+
});
|
|
88
128
|
});
|
|
89
129
|
|
|
90
130
|
describe('iceCandidate', () => {
|
|
@@ -123,13 +163,16 @@ describe('Peerconnection Manager', () => {
|
|
|
123
163
|
});
|
|
124
164
|
});
|
|
125
165
|
|
|
126
|
-
it('should
|
|
166
|
+
it('should still generate sdp even if onicecandidateerror is called ', async () => {
|
|
127
167
|
peerConnection.iceGatheringState = 'none';
|
|
128
168
|
setTimeout(() => {
|
|
129
169
|
peerConnection.onicecandidateerror();
|
|
170
|
+
peerConnection.onicecandidate({candidate: null});
|
|
130
171
|
}, 1000);
|
|
131
|
-
await
|
|
132
|
-
|
|
172
|
+
await PeerConnectionManager.iceCandidate(peerConnection, {remoteQualityLevel: 'HIGH'})
|
|
173
|
+
.then(() => {
|
|
174
|
+
assert(peerConnection.sdp.search('max-fs:8192'), true);
|
|
175
|
+
});
|
|
133
176
|
});
|
|
134
177
|
|
|
135
178
|
it('should throw generated SDP does not have candidates ', async () => {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {assert} from '@webex/test-helper-chai';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import TurnDiscovery from '@webex/plugin-meetings/src/roap/turnDiscovery';
|
|
4
|
+
import {ROAP} from '@webex/plugin-meetings/src/constants';
|
|
5
|
+
|
|
6
|
+
import RoapRequest from '@webex/plugin-meetings/src/roap/request';
|
|
7
|
+
import RoapHandler from '@webex/plugin-meetings/src/roap/handler';
|
|
8
|
+
import Roap from '@webex/plugin-meetings/src/roap/';
|
|
9
|
+
|
|
10
|
+
describe('Roap', () => {
|
|
11
|
+
describe('doTurnDiscovery', () => {
|
|
12
|
+
it('calls this.turnDiscovery.doTurnDiscovery() and forwards all the arguments', async () => {
|
|
13
|
+
const RESULT = {something: 'some value'};
|
|
14
|
+
const meeting = {id: 'some meeting id'};
|
|
15
|
+
|
|
16
|
+
const doTurnDiscoveryStub = sinon.stub(TurnDiscovery.prototype, 'doTurnDiscovery').resolves(RESULT);
|
|
17
|
+
|
|
18
|
+
const roap = new Roap({}, {parent: 'fake'});
|
|
19
|
+
|
|
20
|
+
// call with isReconnecting: true
|
|
21
|
+
const result = await roap.doTurnDiscovery(meeting, true);
|
|
22
|
+
|
|
23
|
+
assert.calledOnceWithExactly(doTurnDiscoveryStub, meeting, true);
|
|
24
|
+
assert.deepEqual(result, RESULT);
|
|
25
|
+
|
|
26
|
+
doTurnDiscoveryStub.resetHistory();
|
|
27
|
+
|
|
28
|
+
// and with isReconnecting: false
|
|
29
|
+
const result2 = await roap.doTurnDiscovery(meeting, false);
|
|
30
|
+
|
|
31
|
+
assert.calledOnceWithExactly(doTurnDiscoveryStub, meeting, false);
|
|
32
|
+
assert.deepEqual(result2, RESULT);
|
|
33
|
+
|
|
34
|
+
sinon.restore();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('sendRoapMediaRequest', () => {
|
|
39
|
+
let sendRoapStub;
|
|
40
|
+
let roapHandlerSubmitStub;
|
|
41
|
+
|
|
42
|
+
const meeting = {
|
|
43
|
+
id: 'some meeting id',
|
|
44
|
+
correlationId: 'correlation id',
|
|
45
|
+
selfUrl: 'self url',
|
|
46
|
+
mediaId: 'media id',
|
|
47
|
+
isAudioMuted: () => true,
|
|
48
|
+
isVideoMuted: () => false,
|
|
49
|
+
setRoapSeq: sinon.stub(),
|
|
50
|
+
config: {experimental: {enableTurnDiscovery: false}},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
sendRoapStub = sinon.stub(RoapRequest.prototype, 'sendRoap').resolves({});
|
|
55
|
+
roapHandlerSubmitStub = sinon.stub(RoapHandler.prototype, 'submit');
|
|
56
|
+
meeting.setRoapSeq.resetHistory();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
sinon.restore();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
[
|
|
64
|
+
{reconnect: true, enableTurnDiscovery: true, expectEmptyMediaId: false},
|
|
65
|
+
{reconnect: true, enableTurnDiscovery: false, expectEmptyMediaId: true},
|
|
66
|
+
{reconnect: false, enableTurnDiscovery: true, expectEmptyMediaId: false},
|
|
67
|
+
{reconnect: false, enableTurnDiscovery: false, expectEmptyMediaId: false},
|
|
68
|
+
].forEach(({reconnect, enableTurnDiscovery, expectEmptyMediaId}) =>
|
|
69
|
+
it(`sends roap OFFER with ${expectEmptyMediaId ? 'empty ' : ''}mediaId when ${reconnect ? '' : 'not '}reconnecting and TURN discovery is ${enableTurnDiscovery ? 'enabled' : 'disabled'}`, async () => {
|
|
70
|
+
meeting.config.experimental.enableTurnDiscovery = enableTurnDiscovery;
|
|
71
|
+
|
|
72
|
+
const roap = new Roap({}, {parent: 'fake'});
|
|
73
|
+
|
|
74
|
+
await roap.sendRoapMediaRequest({
|
|
75
|
+
meeting, sdp: 'sdp', reconnect, roapSeq: 1
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const expectedRoapMessage = {
|
|
79
|
+
messageType: 'OFFER',
|
|
80
|
+
sdps: ['sdp'],
|
|
81
|
+
version: '2',
|
|
82
|
+
seq: 2,
|
|
83
|
+
tieBreaker: 4294967294
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
assert.calledOnce(sendRoapStub);
|
|
87
|
+
assert.calledWith(sendRoapStub, {
|
|
88
|
+
roapMessage: expectedRoapMessage,
|
|
89
|
+
correlationId: meeting.correlationId,
|
|
90
|
+
locusSelfUrl: meeting.selfUrl,
|
|
91
|
+
mediaId: expectEmptyMediaId ? '' : meeting.mediaId,
|
|
92
|
+
audioMuted: meeting.isAudioMuted(),
|
|
93
|
+
videoMuted: meeting.isVideoMuted(),
|
|
94
|
+
meetingId: meeting.id
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
assert.calledTwice(roapHandlerSubmitStub);
|
|
98
|
+
assert.calledWith(roapHandlerSubmitStub, {
|
|
99
|
+
type: ROAP.SEND_ROAP_MSG,
|
|
100
|
+
msg: expectedRoapMessage,
|
|
101
|
+
correlationId: meeting.correlationId
|
|
102
|
+
});
|
|
103
|
+
assert.calledWith(roapHandlerSubmitStub, {
|
|
104
|
+
type: ROAP.SEND_ROAP_MSG_SUCCESS,
|
|
105
|
+
seq: 2,
|
|
106
|
+
correlationId: meeting.correlationId
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
assert.calledOnce(meeting.setRoapSeq);
|
|
110
|
+
assert.calledWith(meeting.setRoapSeq, 2);
|
|
111
|
+
}));
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import {assert} from '@webex/test-helper-chai';
|
|
3
|
+
import TurnDiscovery from '@webex/plugin-meetings/src/roap/turnDiscovery';
|
|
4
|
+
|
|
5
|
+
import Metrics from '@webex/plugin-meetings/src/metrics';
|
|
6
|
+
import BEHAVIORAL_METRICS from '@webex/plugin-meetings/src/metrics/constants';
|
|
7
|
+
import RoapRequest from '@webex/plugin-meetings/src/roap/request';
|
|
8
|
+
|
|
9
|
+
import testUtils from '../../../utils/testUtils';
|
|
10
|
+
|
|
11
|
+
describe('TurnDiscovery', () => {
|
|
12
|
+
let clock;
|
|
13
|
+
let mockRoapRequest: RoapRequest;
|
|
14
|
+
let testMeeting: any;
|
|
15
|
+
|
|
16
|
+
const FAKE_TURN_URL = 'turns:fakeTurnServer.com:443?transport=tcp';
|
|
17
|
+
const FAKE_TURN_USERNAME = 'someUsernameFromServer';
|
|
18
|
+
const FAKE_TURN_PASSWORD = 'fakePasswordFromServer';
|
|
19
|
+
const FAKE_LOCUS_ID = '09493311-f5d5-3e58-b491-009cc628162e';
|
|
20
|
+
const FAKE_MEDIA_CONNECTIONS_FROM_LOCUS = [{mediaId: '464ff97f-4bda-466a-ad06-3a22184a2274'}];
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
clock = sinon.useFakeTimers();
|
|
24
|
+
|
|
25
|
+
sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
26
|
+
|
|
27
|
+
mockRoapRequest = {
|
|
28
|
+
sendRoap: sinon.fake.resolves({mediaConnections: FAKE_MEDIA_CONNECTIONS_FROM_LOCUS})
|
|
29
|
+
} as unknown as RoapRequest;
|
|
30
|
+
|
|
31
|
+
testMeeting = {
|
|
32
|
+
id: 'fake meeting id',
|
|
33
|
+
config: {
|
|
34
|
+
experimental: {
|
|
35
|
+
enableTurnDiscovery: true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
correlationId: 'fake correlation id',
|
|
39
|
+
selfUrl: 'fake self url',
|
|
40
|
+
mediaId: 'fake media id',
|
|
41
|
+
locusUrl: `https://locus-a.wbx2.com/locus/api/v1/loci/${FAKE_LOCUS_ID}`,
|
|
42
|
+
roapSeq: -1,
|
|
43
|
+
isAudioMuted: () => true,
|
|
44
|
+
isVideoMuted: () => false,
|
|
45
|
+
setRoapSeq: sinon.fake((newSeq) => {
|
|
46
|
+
testMeeting.roapSeq = newSeq;
|
|
47
|
+
}),
|
|
48
|
+
updateMediaConnections: sinon.stub(),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
clock.restore();
|
|
54
|
+
sinon.restore();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const checkRoapMessageSent = async (messageType, expectedSeq, expectedMediaId = testMeeting.mediaId) => {
|
|
58
|
+
await testUtils.flushPromises();
|
|
59
|
+
|
|
60
|
+
assert.calledOnce(mockRoapRequest.sendRoap);
|
|
61
|
+
assert.calledWith(mockRoapRequest.sendRoap, {
|
|
62
|
+
roapMessage: {
|
|
63
|
+
messageType,
|
|
64
|
+
version: '2',
|
|
65
|
+
seq: expectedSeq,
|
|
66
|
+
},
|
|
67
|
+
correlationId: testMeeting.correlationId,
|
|
68
|
+
locusSelfUrl: testMeeting.selfUrl,
|
|
69
|
+
mediaId: expectedMediaId,
|
|
70
|
+
audioMuted: testMeeting.isAudioMuted(),
|
|
71
|
+
videoMuted: testMeeting.isVideoMuted(),
|
|
72
|
+
meetingId: testMeeting.id
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (messageType === 'TURN_DISCOVERY_REQUEST') {
|
|
76
|
+
// check also that we've applied the media connections from the response
|
|
77
|
+
assert.calledOnce(testMeeting.updateMediaConnections);
|
|
78
|
+
assert.calledWith(testMeeting.updateMediaConnections, FAKE_MEDIA_CONNECTIONS_FROM_LOCUS);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const checkFailureMetricsSent = () => {
|
|
83
|
+
assert.calledOnce(Metrics.sendBehavioralMetric);
|
|
84
|
+
assert.calledWith(
|
|
85
|
+
Metrics.sendBehavioralMetric,
|
|
86
|
+
BEHAVIORAL_METRICS.TURN_DISCOVERY_FAILURE,
|
|
87
|
+
sinon.match({
|
|
88
|
+
correlation_id: testMeeting.correlationId,
|
|
89
|
+
locus_id: FAKE_LOCUS_ID,
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
describe('doTurnDiscovery', () => {
|
|
95
|
+
it('sends TURN_DISCOVERY_REQUEST, waits for response and sends OK', async () => {
|
|
96
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
97
|
+
|
|
98
|
+
const result = td.doTurnDiscovery(testMeeting, false);
|
|
99
|
+
|
|
100
|
+
// check that TURN_DISCOVERY_REQUEST was sent
|
|
101
|
+
await checkRoapMessageSent('TURN_DISCOVERY_REQUEST', 0);
|
|
102
|
+
|
|
103
|
+
mockRoapRequest.sendRoap.resetHistory();
|
|
104
|
+
|
|
105
|
+
// simulate the response
|
|
106
|
+
td.handleTurnDiscoveryResponse({
|
|
107
|
+
headers: [
|
|
108
|
+
`x-cisco-turn-url=${FAKE_TURN_URL}`,
|
|
109
|
+
`x-cisco-turn-username=${FAKE_TURN_USERNAME}`,
|
|
110
|
+
`x-cisco-turn-password=${FAKE_TURN_PASSWORD}`,
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await testUtils.flushPromises();
|
|
115
|
+
|
|
116
|
+
// check that we've sent OK
|
|
117
|
+
await checkRoapMessageSent('OK', 0);
|
|
118
|
+
|
|
119
|
+
const turnInfo = await result;
|
|
120
|
+
|
|
121
|
+
assert.deepEqual(turnInfo, {
|
|
122
|
+
url: FAKE_TURN_URL,
|
|
123
|
+
username: FAKE_TURN_USERNAME,
|
|
124
|
+
password: FAKE_TURN_PASSWORD
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('sends TURN_DISCOVERY_REQUEST with empty mediaId when isReconnecting is true', async () => {
|
|
129
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
130
|
+
|
|
131
|
+
const result = td.doTurnDiscovery(testMeeting, true);
|
|
132
|
+
|
|
133
|
+
// check that TURN_DISCOVERY_REQUEST was sent with empty mediaId
|
|
134
|
+
await checkRoapMessageSent('TURN_DISCOVERY_REQUEST', 0, '');
|
|
135
|
+
|
|
136
|
+
// the main part of the test is complete now, checking the remaining part of the flow just for completeness
|
|
137
|
+
mockRoapRequest.sendRoap.resetHistory();
|
|
138
|
+
|
|
139
|
+
// simulate the response
|
|
140
|
+
td.handleTurnDiscoveryResponse({
|
|
141
|
+
headers: [
|
|
142
|
+
`x-cisco-turn-url=${FAKE_TURN_URL}`,
|
|
143
|
+
`x-cisco-turn-username=${FAKE_TURN_USERNAME}`,
|
|
144
|
+
`x-cisco-turn-password=${FAKE_TURN_PASSWORD}`,
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
await testUtils.flushPromises();
|
|
149
|
+
|
|
150
|
+
// check that we've sent OK
|
|
151
|
+
await checkRoapMessageSent('OK', 0);
|
|
152
|
+
|
|
153
|
+
const turnInfo = await result;
|
|
154
|
+
|
|
155
|
+
assert.deepEqual(turnInfo, {
|
|
156
|
+
url: FAKE_TURN_URL,
|
|
157
|
+
username: FAKE_TURN_USERNAME,
|
|
158
|
+
password: FAKE_TURN_PASSWORD
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('ignores any extra, unexpected headers in the response', async () => {
|
|
163
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
164
|
+
const result = td.doTurnDiscovery(testMeeting, false);
|
|
165
|
+
|
|
166
|
+
// check that TURN_DISCOVERY_REQUEST was sent
|
|
167
|
+
await checkRoapMessageSent('TURN_DISCOVERY_REQUEST', 0);
|
|
168
|
+
|
|
169
|
+
mockRoapRequest.sendRoap.resetHistory();
|
|
170
|
+
|
|
171
|
+
// simulate the response with some extra headers
|
|
172
|
+
td.handleTurnDiscoveryResponse({
|
|
173
|
+
headers: [
|
|
174
|
+
'x-cisco-turn-unexpected-header=xxx',
|
|
175
|
+
`x-cisco-turn-url=${FAKE_TURN_URL}`,
|
|
176
|
+
'x-cisco-some-other-header',
|
|
177
|
+
`x-cisco-turn-username=${FAKE_TURN_USERNAME}`,
|
|
178
|
+
`x-cisco-turn-password=${FAKE_TURN_PASSWORD}`,
|
|
179
|
+
'another-header-at-the-end=12345',
|
|
180
|
+
]
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
await testUtils.flushPromises();
|
|
184
|
+
|
|
185
|
+
// check that we've sent OK and still parsed the headers we care about
|
|
186
|
+
await checkRoapMessageSent('OK', 0);
|
|
187
|
+
|
|
188
|
+
const turnInfo = await result;
|
|
189
|
+
|
|
190
|
+
assert.deepEqual(turnInfo, {
|
|
191
|
+
url: FAKE_TURN_URL,
|
|
192
|
+
username: FAKE_TURN_USERNAME,
|
|
193
|
+
password: FAKE_TURN_PASSWORD
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('resolves with undefined if turn discovery feature is disabled in config', async () => {
|
|
198
|
+
const prevConfigValue = testMeeting.config.experimental.enableTurnDiscovery;
|
|
199
|
+
|
|
200
|
+
testMeeting.config.experimental.enableTurnDiscovery = false;
|
|
201
|
+
|
|
202
|
+
const result = await new TurnDiscovery(mockRoapRequest).doTurnDiscovery(testMeeting);
|
|
203
|
+
|
|
204
|
+
assert.isUndefined(result);
|
|
205
|
+
assert.notCalled(mockRoapRequest.sendRoap);
|
|
206
|
+
assert.notCalled(Metrics.sendBehavioralMetric);
|
|
207
|
+
|
|
208
|
+
// restore previous config
|
|
209
|
+
testMeeting.config.experimental.enableTurnDiscovery = prevConfigValue;
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('resolves with undefined if sending the request fails', async () => {
|
|
213
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
214
|
+
|
|
215
|
+
mockRoapRequest.sendRoap = sinon.fake.rejects(new Error('fake error'));
|
|
216
|
+
|
|
217
|
+
const result = await td.doTurnDiscovery(testMeeting, false);
|
|
218
|
+
|
|
219
|
+
assert.isUndefined(result);
|
|
220
|
+
checkFailureMetricsSent();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('resolves with undefined if we don\'t get a response within 10s', async () => {
|
|
224
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
225
|
+
|
|
226
|
+
const promise = td.doTurnDiscovery(testMeeting, false);
|
|
227
|
+
|
|
228
|
+
await clock.tickAsync(10 * 1000);
|
|
229
|
+
await testUtils.flushPromises();
|
|
230
|
+
|
|
231
|
+
const turnInfo = await promise;
|
|
232
|
+
|
|
233
|
+
assert.isUndefined(turnInfo);
|
|
234
|
+
checkFailureMetricsSent();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('resolves with undefined if the response does not have all the headers we expect', async () => {
|
|
238
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
239
|
+
const turnDiscoveryPromise = td.doTurnDiscovery(testMeeting, false);
|
|
240
|
+
|
|
241
|
+
// simulate the response without the password
|
|
242
|
+
td.handleTurnDiscoveryResponse({
|
|
243
|
+
headers: [
|
|
244
|
+
`x-cisco-turn-url=${FAKE_TURN_URL}`,
|
|
245
|
+
`x-cisco-turn-username=${FAKE_TURN_USERNAME}`,
|
|
246
|
+
]
|
|
247
|
+
});
|
|
248
|
+
await testUtils.flushPromises();
|
|
249
|
+
const turnInfo = await turnDiscoveryPromise;
|
|
250
|
+
|
|
251
|
+
assert.isUndefined(turnInfo);
|
|
252
|
+
checkFailureMetricsSent();
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('resolves with undefined if the response does not have any headers', async () => {
|
|
256
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
257
|
+
const turnDiscoveryPromise = td.doTurnDiscovery(testMeeting, false);
|
|
258
|
+
|
|
259
|
+
// simulate the response without the headers
|
|
260
|
+
td.handleTurnDiscoveryResponse({});
|
|
261
|
+
|
|
262
|
+
await testUtils.flushPromises();
|
|
263
|
+
const turnInfo = await turnDiscoveryPromise;
|
|
264
|
+
|
|
265
|
+
assert.isUndefined(turnInfo);
|
|
266
|
+
checkFailureMetricsSent();
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('resolves with undefined if the response has empty headers array', async () => {
|
|
270
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
271
|
+
const turnDiscoveryPromise = td.doTurnDiscovery(testMeeting, false);
|
|
272
|
+
|
|
273
|
+
// simulate the response without the headers
|
|
274
|
+
td.handleTurnDiscoveryResponse({headers: []});
|
|
275
|
+
|
|
276
|
+
await testUtils.flushPromises();
|
|
277
|
+
const turnInfo = await turnDiscoveryPromise;
|
|
278
|
+
|
|
279
|
+
assert.isUndefined(turnInfo);
|
|
280
|
+
checkFailureMetricsSent();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('resolves with undefined if failed to send OK', async () => {
|
|
284
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
285
|
+
|
|
286
|
+
const turnDiscoveryPromise = td.doTurnDiscovery(testMeeting, false);
|
|
287
|
+
|
|
288
|
+
// check that TURN_DISCOVERY_REQUEST was sent
|
|
289
|
+
await checkRoapMessageSent('TURN_DISCOVERY_REQUEST', 0);
|
|
290
|
+
|
|
291
|
+
mockRoapRequest.sendRoap.resetHistory();
|
|
292
|
+
|
|
293
|
+
// setup the mock so that sending of OK fails
|
|
294
|
+
mockRoapRequest.sendRoap = sinon.fake.rejects(new Error('fake error'));
|
|
295
|
+
|
|
296
|
+
// simulate the response
|
|
297
|
+
td.handleTurnDiscoveryResponse({
|
|
298
|
+
headers: [
|
|
299
|
+
`x-cisco-turn-url=${FAKE_TURN_URL}`,
|
|
300
|
+
`x-cisco-turn-username=${FAKE_TURN_USERNAME}`,
|
|
301
|
+
`x-cisco-turn-password=${FAKE_TURN_PASSWORD}`,
|
|
302
|
+
]
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
await testUtils.flushPromises();
|
|
306
|
+
|
|
307
|
+
// check that we've sent OK
|
|
308
|
+
await checkRoapMessageSent('OK', 0);
|
|
309
|
+
|
|
310
|
+
const turnInfo = await turnDiscoveryPromise;
|
|
311
|
+
|
|
312
|
+
assert.isUndefined(turnInfo);
|
|
313
|
+
checkFailureMetricsSent();
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
describe('handleTurnDiscoveryResponse', () => {
|
|
318
|
+
it('doesn\'t do anything if turn discovery was not started', () => {
|
|
319
|
+
const td = new TurnDiscovery(mockRoapRequest);
|
|
320
|
+
|
|
321
|
+
// there is not much we can check, but we mainly want to make
|
|
322
|
+
// sure that it doesn't crash
|
|
323
|
+
td.handleTurnDiscoveryResponse({
|
|
324
|
+
headers: [
|
|
325
|
+
`x-cisco-turn-url=${FAKE_TURN_URL}`,
|
|
326
|
+
`x-cisco-turn-username=${FAKE_TURN_USERNAME}`,
|
|
327
|
+
`x-cisco-turn-password=${FAKE_TURN_PASSWORD}`,
|
|
328
|
+
]
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
assert.notCalled(mockRoapRequest.sendRoap);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
});
|