@webex/internal-plugin-board 3.0.0-beta.13 → 3.0.0-beta.131
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 -3
- package/dist/board.js +44 -110
- package/dist/board.js.map +1 -1
- package/dist/config.js +0 -8
- package/dist/config.js.map +1 -1
- package/dist/index.js +7 -28
- package/dist/index.js.map +1 -1
- package/dist/realtime-channel-collection.js +2 -8
- package/dist/realtime-channel-collection.js.map +1 -1
- package/dist/realtime-channel.js +1 -5
- package/dist/realtime-channel.js.map +1 -1
- package/dist/realtime.js +38 -82
- package/dist/realtime.js.map +1 -1
- package/package.json +14 -14
- package/src/board.js +273 -207
- package/src/config.js +2 -2
- package/src/index.js +19 -21
- package/src/realtime-channel-collection.js +2 -2
- package/src/realtime-channel.js +8 -9
- package/src/realtime.js +109 -93
- package/test/integration/spec/board.js +347 -221
- package/test/integration/spec/realtime.js +84 -57
- package/test/integration/spec/sharing-mercury.js +154 -73
- package/test/unit/spec/board.js +327 -216
- package/test/unit/spec/encryption.js +152 -120
- package/test/unit/spec/realtime.js +131 -89
package/test/unit/spec/board.js
CHANGED
|
@@ -13,26 +13,32 @@ describe('plugin-board', () => {
|
|
|
13
13
|
let webex;
|
|
14
14
|
const encryptedData = 'encryptedData';
|
|
15
15
|
const decryptedText = 'decryptedText';
|
|
16
|
-
const fakeURL = `${
|
|
16
|
+
const fakeURL = `${
|
|
17
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
18
|
+
}/encryption/api/v1/keys/8a7d3d78-ce75-48aa-a943-2e8acf63fbc9`;
|
|
17
19
|
const file = 'dataURL://base64;';
|
|
18
20
|
const boardServiceUrl = 'https://awesome.service.url';
|
|
19
21
|
const boardId = 'boardId';
|
|
20
22
|
|
|
21
23
|
const mockKey = {
|
|
22
|
-
uri: `${
|
|
24
|
+
uri: `${
|
|
25
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
26
|
+
}/encryption/api/v1/keys/7ad503ec-854b-4fce-a7f0-182e1997bdb6`,
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
const image = {
|
|
26
30
|
height: 900,
|
|
27
31
|
width: 1600,
|
|
28
|
-
size: 15000
|
|
32
|
+
size: 15000,
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
const conversation = {
|
|
32
36
|
id: '7c7e69a0-a086-11e6-8670-d7b4b51d7641',
|
|
33
37
|
defaultActivityEncryptionKeyUrl: fakeURL,
|
|
34
|
-
kmsResourceObjectUrl: `${
|
|
35
|
-
|
|
38
|
+
kmsResourceObjectUrl: `${
|
|
39
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
40
|
+
}/encryption/api/v1/resources/8693f702-2012-40c6-9ec4-f1392f0a620a`,
|
|
41
|
+
aclUrl: 'https://acl-a.wbx2.com/acl/api/v1/acls/7ca94a30-a086-11e6-b599-d90deb9846ed',
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
const channel = {
|
|
@@ -41,13 +47,15 @@ describe('plugin-board', () => {
|
|
|
41
47
|
aclUrlLink: conversation.aclUrl,
|
|
42
48
|
aclUrl: 'https://acl-a.wbx2.com/acl/api/v1/acls/e2947ee0-972b-11e7-a041-d564bb1fbb45',
|
|
43
49
|
defaultEncryptionKeyUrl: mockKey.uri,
|
|
44
|
-
kmsResourceUrl: `${
|
|
50
|
+
kmsResourceUrl: `${
|
|
51
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
52
|
+
}/encryption/api/v1/resources/18f7c618-2eff-461e-ac46-819a0fd2b476`,
|
|
45
53
|
kmsMessage: {
|
|
46
54
|
method: 'create',
|
|
47
55
|
uri: '/resources',
|
|
48
56
|
userIds: [conversation.kmsResourceObjectUrl],
|
|
49
|
-
keyUris: []
|
|
50
|
-
}
|
|
57
|
+
keyUris: [],
|
|
58
|
+
},
|
|
51
59
|
};
|
|
52
60
|
|
|
53
61
|
const channelRes = {
|
|
@@ -57,62 +65,80 @@ describe('plugin-board', () => {
|
|
|
57
65
|
aclUrl: 'https://acl-a.wbx2.com/acl/api/v1/acls/e2947ee0-972b-11e7-a041-d564bb1fbb45',
|
|
58
66
|
defaultEncryptionKeyUrl: mockKey.uri,
|
|
59
67
|
creatorId: 'c321e329-28d6-4d52-a9d1-374010411530',
|
|
60
|
-
kmsResourceUrl: `${
|
|
68
|
+
kmsResourceUrl: `${
|
|
69
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
70
|
+
}/encryption/api/v1/resources/18f7c618-2eff-461e-ac46-819a0fd2b476`,
|
|
61
71
|
kmsMessage: {
|
|
62
72
|
status: 201,
|
|
63
73
|
resource: {
|
|
64
|
-
uri: `${
|
|
65
|
-
|
|
74
|
+
uri: `${
|
|
75
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
76
|
+
}/encryption/api/v1/resources/2853285c-c46b-4b35-9542-9a81d4e3c87f`,
|
|
77
|
+
keyUris: [
|
|
78
|
+
`${
|
|
79
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
80
|
+
}/encryption/api/v1/keys/5042787d-510b-46f3-b83c-ea73032de851`,
|
|
81
|
+
],
|
|
66
82
|
authorizationUris: [
|
|
67
|
-
`${
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
83
|
+
`${
|
|
84
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
85
|
+
}/encryption/api/v1/authorizations/aHR0cHM6Ly9lbmNyeXB0aW9uLWEud2J4Mi5jb20vZW5jcnlwdGlvbi9hcGkvdjEvcmVzb3VyY2VzLzI3OWIyMjgyLWZmYTItNGM3ZC04NGRmLTRkNDVlZmUzYTMzNQBodHRwczovL2VuY3J5cHRpb24tYS53YngyLmNvbS9lbmNyeXB0aW9uL2FwaS92MS9yZXNvdXJjZXMvMjg1MzI4NWMtYzQ2Yi00YjM1LTk1NDItOWE4MWQ0ZTNjODdm`,
|
|
86
|
+
`${
|
|
87
|
+
process.env.ENCRYPTION_SERVICE_URL || 'https://encryption-a.wbx2.com'
|
|
88
|
+
}/encryption/api/v1/authorizations/YzMyMWUzMjktMjhkNi00ZDUyLWE5ZDEtMzc0MDEwNDExNTMwAGh0dHBzOi8vZW5jcnlwdGlvbi1hLndieDIuY29tL2VuY3J5cHRpb24vYXBpL3YxL3Jlc291cmNlcy8yODUzMjg1Yy1jNDZiLTRiMzUtOTU0Mi05YTgxZDRlM2M4N2Y`,
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
72
92
|
};
|
|
73
93
|
|
|
74
94
|
const data1 = {
|
|
75
95
|
contentUrl: `${channel.channelUrl}/contents/data1`,
|
|
76
96
|
contentId: 'data1',
|
|
77
97
|
type: 'test',
|
|
78
|
-
data: 'data1'
|
|
98
|
+
data: 'data1',
|
|
79
99
|
};
|
|
80
100
|
|
|
81
101
|
const data2 = {
|
|
82
102
|
type: 'test',
|
|
83
|
-
data: 'data2'
|
|
103
|
+
data: 'data2',
|
|
84
104
|
};
|
|
85
105
|
|
|
86
106
|
before(() => {
|
|
87
107
|
webex = new MockWebex({
|
|
88
108
|
children: {
|
|
89
|
-
board: Board
|
|
109
|
+
board: Board,
|
|
90
110
|
},
|
|
91
|
-
request: sinon.stub().returns(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
request: sinon.stub().returns(
|
|
112
|
+
Promise.resolve({
|
|
113
|
+
headers: {},
|
|
114
|
+
body: '',
|
|
115
|
+
})
|
|
116
|
+
),
|
|
117
|
+
upload: sinon.stub().returns(Promise.resolve({body: {downloadUrl: fakeURL}})),
|
|
96
118
|
});
|
|
97
119
|
|
|
98
120
|
Object.assign(webex.internal, {
|
|
99
121
|
device: {
|
|
100
122
|
deviceType: 'FAKE_DEVICE',
|
|
101
|
-
getServiceUrl: () => boardServiceUrl
|
|
123
|
+
getServiceUrl: () => boardServiceUrl,
|
|
102
124
|
},
|
|
103
125
|
encryption: {
|
|
104
126
|
decryptText: sinon.stub().returns(Promise.resolve(decryptedText)),
|
|
105
127
|
encryptText: sinon.stub().returns(Promise.resolve(encryptedData)),
|
|
106
|
-
encryptBinary: sinon.stub().returns(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
128
|
+
encryptBinary: sinon.stub().returns(
|
|
129
|
+
Promise.resolve({
|
|
130
|
+
scr: {},
|
|
131
|
+
cdata: encryptedData,
|
|
132
|
+
})
|
|
133
|
+
),
|
|
134
|
+
download: sinon.stub().returns(
|
|
135
|
+
Promise.resolve({
|
|
136
|
+
toArrayBuffer: sinon.stub(),
|
|
137
|
+
})
|
|
138
|
+
),
|
|
113
139
|
decryptScr: sinon.stub().returns(Promise.resolve('decryptedFoo')),
|
|
114
|
-
encryptScr: sinon.stub().returns(Promise.resolve('encryptedFoo'))
|
|
115
|
-
}
|
|
140
|
+
encryptScr: sinon.stub().returns(Promise.resolve('encryptedFoo')),
|
|
141
|
+
},
|
|
116
142
|
});
|
|
117
143
|
|
|
118
144
|
webex.config.board = boardConfig.board;
|
|
@@ -123,23 +149,29 @@ describe('plugin-board', () => {
|
|
|
123
149
|
webex.request.resetHistory();
|
|
124
150
|
});
|
|
125
151
|
|
|
126
|
-
it('requests POST all contents to contents', () =>
|
|
127
|
-
.then(() => {
|
|
128
|
-
assert.calledWith(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
it('requests POST all contents to contents', () =>
|
|
153
|
+
webex.internal.board.addContent(channel, [data1, data2]).then(() => {
|
|
154
|
+
assert.calledWith(
|
|
155
|
+
webex.request,
|
|
156
|
+
sinon.match({
|
|
157
|
+
method: 'POST',
|
|
158
|
+
uri: `${boardServiceUrl}/channels/${boardId}/contents`,
|
|
159
|
+
body: [
|
|
160
|
+
{
|
|
161
|
+
device: 'FAKE_DEVICE',
|
|
162
|
+
type: 'STRING',
|
|
163
|
+
encryptionKeyUrl: mockKey.uri,
|
|
164
|
+
payload: 'encryptedData',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
device: 'FAKE_DEVICE',
|
|
168
|
+
type: 'STRING',
|
|
169
|
+
encryptionKeyUrl: mockKey.uri,
|
|
170
|
+
payload: 'encryptedData',
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
})
|
|
174
|
+
);
|
|
143
175
|
}));
|
|
144
176
|
|
|
145
177
|
it('sends large data using multiple requests', () => {
|
|
@@ -149,19 +181,20 @@ describe('plugin-board', () => {
|
|
|
149
181
|
largeData.push({data: i});
|
|
150
182
|
}
|
|
151
183
|
|
|
152
|
-
return webex.internal.board.addContent(channel, largeData)
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
});
|
|
184
|
+
return webex.internal.board.addContent(channel, largeData).then(() => {
|
|
185
|
+
assert.equal(webex.request.callCount, 3);
|
|
186
|
+
});
|
|
156
187
|
});
|
|
157
188
|
});
|
|
158
189
|
|
|
159
190
|
describe('#setSnapshotImage()', () => {
|
|
160
191
|
beforeEach(() => {
|
|
161
192
|
webex.request.resetHistory();
|
|
162
|
-
sinon.stub(webex.internal.board, '_uploadImageToWebexFiles').returns(
|
|
163
|
-
|
|
164
|
-
|
|
193
|
+
sinon.stub(webex.internal.board, '_uploadImageToWebexFiles').returns(
|
|
194
|
+
Promise.resolve({
|
|
195
|
+
downloadUrl: fakeURL,
|
|
196
|
+
})
|
|
197
|
+
);
|
|
165
198
|
webex.internal.encryption.encryptScr.resetHistory();
|
|
166
199
|
});
|
|
167
200
|
|
|
@@ -170,54 +203,87 @@ describe('plugin-board', () => {
|
|
|
170
203
|
webex.internal.encryption.encryptScr.resetHistory();
|
|
171
204
|
});
|
|
172
205
|
|
|
173
|
-
it('requests PATCH to board service', () =>
|
|
174
|
-
.then(() => {
|
|
175
|
-
assert.calledWith(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
206
|
+
it('requests PATCH to board service', () =>
|
|
207
|
+
webex.internal.board.setSnapshotImage(channel, image).then(() => {
|
|
208
|
+
assert.calledWith(
|
|
209
|
+
webex.request,
|
|
210
|
+
sinon.match({
|
|
211
|
+
method: 'PATCH',
|
|
212
|
+
uri: channel.channelUrl,
|
|
213
|
+
body: {
|
|
214
|
+
image: {
|
|
215
|
+
url: fakeURL,
|
|
216
|
+
height: image.height,
|
|
217
|
+
width: image.width,
|
|
218
|
+
mimeType: 'image/png',
|
|
219
|
+
scr: 'encryptedFoo',
|
|
220
|
+
encryptionKeyUrl: channel.defaultEncryptionKeyUrl,
|
|
221
|
+
fileSize: image.size,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
})
|
|
225
|
+
);
|
|
190
226
|
}));
|
|
191
227
|
});
|
|
192
228
|
|
|
193
229
|
describe('#createChannel()', () => {
|
|
194
230
|
const channelRequestBody = {
|
|
195
231
|
aclUrlLink: channel.aclUrlLink,
|
|
196
|
-
kmsMessage: channel.kmsMessage
|
|
232
|
+
kmsMessage: channel.kmsMessage,
|
|
197
233
|
};
|
|
198
234
|
|
|
199
235
|
before(() => {
|
|
200
236
|
webex.request.resetHistory();
|
|
201
237
|
webex.request.returns(Promise.resolve({statusCode: 200, body: channelRes}));
|
|
202
238
|
|
|
203
|
-
|
|
239
|
+
|
|
204
240
|
});
|
|
205
241
|
|
|
206
242
|
after(() => {
|
|
207
243
|
// reset request to its original behavior
|
|
208
|
-
webex.request.returns(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
244
|
+
webex.request.returns(
|
|
245
|
+
Promise.resolve({
|
|
246
|
+
headers: {},
|
|
247
|
+
body: '',
|
|
248
|
+
})
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('supports creating ambiguous channels for PMR support', () => {
|
|
253
|
+
return webex.internal.board.createChannel()
|
|
254
|
+
.then(() => {
|
|
255
|
+
assert.calledWith(
|
|
256
|
+
webex.request,
|
|
257
|
+
sinon.match({
|
|
258
|
+
method: 'POST',
|
|
259
|
+
api: 'board',
|
|
260
|
+
resource: '/channels',
|
|
261
|
+
body: {
|
|
262
|
+
kmsMessage: {
|
|
263
|
+
method: 'create',
|
|
264
|
+
uri: '/resources',
|
|
265
|
+
userIds: [],
|
|
266
|
+
keyUris: [],
|
|
267
|
+
},
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
)
|
|
271
|
+
})
|
|
212
272
|
});
|
|
213
273
|
|
|
214
274
|
it('requests POST to channels service', () => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
275
|
+
return webex.internal.board.createChannel(conversation)
|
|
276
|
+
.then(() => {
|
|
277
|
+
assert.calledWith(
|
|
278
|
+
webex.request,
|
|
279
|
+
sinon.match({
|
|
280
|
+
method: 'POST',
|
|
281
|
+
api: 'board',
|
|
282
|
+
resource: '/channels',
|
|
283
|
+
body: channelRequestBody,
|
|
284
|
+
}),
|
|
285
|
+
);
|
|
286
|
+
});
|
|
221
287
|
});
|
|
222
288
|
});
|
|
223
289
|
|
|
@@ -225,9 +291,10 @@ describe('plugin-board', () => {
|
|
|
225
291
|
it('requests PUT to ACL service to remove the link between conversation and board', () => {
|
|
226
292
|
webex.request.resetHistory();
|
|
227
293
|
|
|
228
|
-
return webex.internal.board.deleteChannel(conversation, channel)
|
|
229
|
-
.
|
|
230
|
-
|
|
294
|
+
return webex.internal.board.deleteChannel(conversation, channel).then(() => {
|
|
295
|
+
assert.calledWith(
|
|
296
|
+
webex.request,
|
|
297
|
+
sinon.match({
|
|
231
298
|
method: 'PUT',
|
|
232
299
|
uri: `${channel.aclUrl}/links`,
|
|
233
300
|
body: {
|
|
@@ -235,40 +302,52 @@ describe('plugin-board', () => {
|
|
|
235
302
|
linkedAcl: conversation.aclUrl,
|
|
236
303
|
kmsMessage: {
|
|
237
304
|
method: 'delete',
|
|
238
|
-
uri: `${channel.kmsResourceUrl}/authorizations?${querystring.stringify({
|
|
305
|
+
uri: `${channel.kmsResourceUrl}/authorizations?${querystring.stringify({
|
|
306
|
+
authId: conversation.kmsResourceObjectUrl,
|
|
307
|
+
})}`,
|
|
239
308
|
},
|
|
240
|
-
aclLinkOperation: 'DELETE'
|
|
241
|
-
}
|
|
242
|
-
})
|
|
243
|
-
|
|
309
|
+
aclLinkOperation: 'DELETE',
|
|
310
|
+
},
|
|
311
|
+
})
|
|
312
|
+
);
|
|
313
|
+
});
|
|
244
314
|
});
|
|
245
315
|
|
|
246
316
|
it('requests locks channel before delete when preventDeleteActiveChannel is enabled', () => {
|
|
247
317
|
webex.request.resetHistory();
|
|
248
318
|
|
|
249
|
-
return webex.internal.board
|
|
319
|
+
return webex.internal.board
|
|
320
|
+
.deleteChannel(conversation, channel, {preventDeleteActiveChannel: true})
|
|
250
321
|
.then(() => {
|
|
251
|
-
assert.calledWith(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
322
|
+
assert.calledWith(
|
|
323
|
+
webex.request,
|
|
324
|
+
sinon.match({
|
|
325
|
+
method: 'POST',
|
|
326
|
+
uri: `${channel.channelUrl}/lock`,
|
|
327
|
+
qs: {
|
|
328
|
+
intent: 'delete',
|
|
329
|
+
},
|
|
330
|
+
})
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
assert.calledWith(
|
|
334
|
+
webex.request,
|
|
335
|
+
sinon.match({
|
|
336
|
+
method: 'PUT',
|
|
337
|
+
uri: `${channel.aclUrl}/links`,
|
|
338
|
+
body: {
|
|
339
|
+
aclLinkType: 'INCOMING',
|
|
340
|
+
linkedAcl: conversation.aclUrl,
|
|
341
|
+
kmsMessage: {
|
|
342
|
+
method: 'delete',
|
|
343
|
+
uri: `${channel.kmsResourceUrl}/authorizations?${querystring.stringify({
|
|
344
|
+
authId: conversation.kmsResourceObjectUrl,
|
|
345
|
+
})}`,
|
|
346
|
+
},
|
|
347
|
+
aclLinkOperation: 'DELETE',
|
|
268
348
|
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}));
|
|
349
|
+
})
|
|
350
|
+
);
|
|
272
351
|
});
|
|
273
352
|
});
|
|
274
353
|
});
|
|
@@ -277,16 +356,18 @@ describe('plugin-board', () => {
|
|
|
277
356
|
it('requests POST with delete lock intent', () => {
|
|
278
357
|
webex.request.resetHistory();
|
|
279
358
|
|
|
280
|
-
return webex.internal.board.lockChannelForDeletion(channel)
|
|
281
|
-
.
|
|
282
|
-
|
|
359
|
+
return webex.internal.board.lockChannelForDeletion(channel).then(() => {
|
|
360
|
+
assert.calledWith(
|
|
361
|
+
webex.request,
|
|
362
|
+
sinon.match({
|
|
283
363
|
method: 'POST',
|
|
284
364
|
uri: `${channel.channelUrl}/lock`,
|
|
285
365
|
qs: {
|
|
286
|
-
intent: 'delete'
|
|
287
|
-
}
|
|
288
|
-
})
|
|
289
|
-
|
|
366
|
+
intent: 'delete',
|
|
367
|
+
},
|
|
368
|
+
})
|
|
369
|
+
);
|
|
370
|
+
});
|
|
290
371
|
});
|
|
291
372
|
});
|
|
292
373
|
|
|
@@ -294,13 +375,15 @@ describe('plugin-board', () => {
|
|
|
294
375
|
it('requests POST to keep channel status active', () => {
|
|
295
376
|
webex.request.resetHistory();
|
|
296
377
|
|
|
297
|
-
return webex.internal.board.keepActive(channel)
|
|
298
|
-
.
|
|
299
|
-
|
|
378
|
+
return webex.internal.board.keepActive(channel).then(() => {
|
|
379
|
+
assert.calledWith(
|
|
380
|
+
webex.request,
|
|
381
|
+
sinon.match({
|
|
300
382
|
method: 'POST',
|
|
301
|
-
uri: `${channel.channelUrl}/keepAlive
|
|
302
|
-
})
|
|
303
|
-
|
|
383
|
+
uri: `${channel.channelUrl}/keepAlive`,
|
|
384
|
+
})
|
|
385
|
+
);
|
|
386
|
+
});
|
|
304
387
|
});
|
|
305
388
|
});
|
|
306
389
|
|
|
@@ -312,10 +395,13 @@ describe('plugin-board', () => {
|
|
|
312
395
|
});
|
|
313
396
|
|
|
314
397
|
it('requests DELETE contents', () => {
|
|
315
|
-
assert.calledWith(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
398
|
+
assert.calledWith(
|
|
399
|
+
webex.request,
|
|
400
|
+
sinon.match({
|
|
401
|
+
method: 'DELETE',
|
|
402
|
+
uri: `${boardServiceUrl}/channels/${boardId}/contents`,
|
|
403
|
+
})
|
|
404
|
+
);
|
|
319
405
|
});
|
|
320
406
|
});
|
|
321
407
|
|
|
@@ -323,25 +409,31 @@ describe('plugin-board', () => {
|
|
|
323
409
|
it('requests POST contents with body contains the content to keep', () => {
|
|
324
410
|
webex.request.resetHistory();
|
|
325
411
|
|
|
326
|
-
return webex.internal.board.deletePartialContent(channel, [data1])
|
|
327
|
-
.
|
|
328
|
-
|
|
412
|
+
return webex.internal.board.deletePartialContent(channel, [data1]).then(() => {
|
|
413
|
+
assert.calledWith(
|
|
414
|
+
webex.request,
|
|
415
|
+
sinon.match({
|
|
329
416
|
method: 'POST',
|
|
330
417
|
uri: `${boardServiceUrl}/channels/${boardId}/contents`,
|
|
331
418
|
qs: {clearBoard: true},
|
|
332
|
-
body: [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
419
|
+
body: [
|
|
420
|
+
{
|
|
421
|
+
contentId: data1.contentId,
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
})
|
|
425
|
+
);
|
|
426
|
+
});
|
|
337
427
|
});
|
|
338
428
|
});
|
|
339
429
|
|
|
340
430
|
describe('#_uploadImage()', () => {
|
|
341
431
|
before(() => {
|
|
342
|
-
sinon.stub(webex.internal.board, '_uploadImageToWebexFiles').returns(
|
|
343
|
-
|
|
344
|
-
|
|
432
|
+
sinon.stub(webex.internal.board, '_uploadImageToWebexFiles').returns(
|
|
433
|
+
Promise.resolve({
|
|
434
|
+
downloadUrl: fakeURL,
|
|
435
|
+
})
|
|
436
|
+
);
|
|
345
437
|
|
|
346
438
|
return webex.internal.board._uploadImage(conversation, file);
|
|
347
439
|
});
|
|
@@ -373,74 +465,79 @@ describe('plugin-board', () => {
|
|
|
373
465
|
webex.internal.board._getSpaceUrl.resetHistory();
|
|
374
466
|
});
|
|
375
467
|
|
|
376
|
-
|
|
377
468
|
it('uses length for upload filesize', () => {
|
|
378
469
|
const blob = {
|
|
379
470
|
length: 4444,
|
|
380
471
|
size: 3333,
|
|
381
|
-
byteLength: 2222
|
|
472
|
+
byteLength: 2222,
|
|
382
473
|
};
|
|
383
474
|
|
|
384
|
-
return webex.internal.board._uploadImageToWebexFiles(conversation, blob)
|
|
385
|
-
.
|
|
386
|
-
|
|
475
|
+
return webex.internal.board._uploadImageToWebexFiles(conversation, blob).then(() => {
|
|
476
|
+
assert.calledWith(
|
|
477
|
+
webex.upload,
|
|
478
|
+
sinon.match({
|
|
387
479
|
phases: {
|
|
388
480
|
initialize: {
|
|
389
|
-
fileSize: 4444
|
|
481
|
+
fileSize: 4444,
|
|
390
482
|
},
|
|
391
483
|
finalize: {
|
|
392
484
|
body: {
|
|
393
|
-
fileSize: 4444
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
})
|
|
398
|
-
|
|
485
|
+
fileSize: 4444,
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
})
|
|
490
|
+
);
|
|
491
|
+
});
|
|
399
492
|
});
|
|
400
493
|
|
|
401
494
|
it('uses size for upload filesize when length is not available', () => {
|
|
402
495
|
const blob = {
|
|
403
496
|
size: 3333,
|
|
404
|
-
byteLength: 2222
|
|
497
|
+
byteLength: 2222,
|
|
405
498
|
};
|
|
406
499
|
|
|
407
|
-
return webex.internal.board._uploadImageToWebexFiles(conversation, blob)
|
|
408
|
-
.
|
|
409
|
-
|
|
500
|
+
return webex.internal.board._uploadImageToWebexFiles(conversation, blob).then(() => {
|
|
501
|
+
assert.calledWith(
|
|
502
|
+
webex.upload,
|
|
503
|
+
sinon.match({
|
|
410
504
|
phases: {
|
|
411
505
|
initialize: {
|
|
412
|
-
fileSize: 3333
|
|
506
|
+
fileSize: 3333,
|
|
413
507
|
},
|
|
414
508
|
finalize: {
|
|
415
509
|
body: {
|
|
416
|
-
fileSize: 3333
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
})
|
|
421
|
-
|
|
510
|
+
fileSize: 3333,
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
})
|
|
515
|
+
);
|
|
516
|
+
});
|
|
422
517
|
});
|
|
423
518
|
|
|
424
519
|
it('uses byteLenght for upload filesize when length and size are not available', () => {
|
|
425
520
|
const blob = {
|
|
426
|
-
byteLength: 2222
|
|
521
|
+
byteLength: 2222,
|
|
427
522
|
};
|
|
428
523
|
|
|
429
|
-
return webex.internal.board._uploadImageToWebexFiles(conversation, blob)
|
|
430
|
-
.
|
|
431
|
-
|
|
524
|
+
return webex.internal.board._uploadImageToWebexFiles(conversation, blob).then(() => {
|
|
525
|
+
assert.calledWith(
|
|
526
|
+
webex.upload,
|
|
527
|
+
sinon.match({
|
|
432
528
|
phases: {
|
|
433
529
|
initialize: {
|
|
434
|
-
fileSize: 2222
|
|
530
|
+
fileSize: 2222,
|
|
435
531
|
},
|
|
436
532
|
finalize: {
|
|
437
533
|
body: {
|
|
438
|
-
fileSize: 2222
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
})
|
|
443
|
-
|
|
534
|
+
fileSize: 2222,
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
})
|
|
539
|
+
);
|
|
540
|
+
});
|
|
444
541
|
});
|
|
445
542
|
});
|
|
446
543
|
|
|
@@ -458,16 +555,19 @@ describe('plugin-board', () => {
|
|
|
458
555
|
});
|
|
459
556
|
|
|
460
557
|
it('requests GET to channels service', () => {
|
|
461
|
-
assert.calledWith(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
558
|
+
assert.calledWith(
|
|
559
|
+
webex.request,
|
|
560
|
+
sinon.match({
|
|
561
|
+
method: 'GET',
|
|
562
|
+
uri: `${boardServiceUrl}/channels/${boardId}`,
|
|
563
|
+
})
|
|
564
|
+
);
|
|
465
565
|
});
|
|
466
566
|
|
|
467
|
-
it('requires conversationId', () =>
|
|
567
|
+
it('requires conversationId', () =>
|
|
568
|
+
assert.isRejected(webex.internal.board.getChannels(), '`conversation` is required'));
|
|
468
569
|
});
|
|
469
570
|
|
|
470
|
-
|
|
471
571
|
describe('#getContents()', () => {
|
|
472
572
|
beforeEach(() => {
|
|
473
573
|
sinon.stub(webex.internal.board, 'decryptContents').returns(['foo']);
|
|
@@ -478,21 +578,25 @@ describe('plugin-board', () => {
|
|
|
478
578
|
webex.internal.board.decryptContents.restore();
|
|
479
579
|
});
|
|
480
580
|
|
|
481
|
-
it('requests GET contents with default page size', () =>
|
|
482
|
-
.then(() =>
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
581
|
+
it('requests GET contents with default page size', () =>
|
|
582
|
+
webex.internal.board.getContents(channel).then(() =>
|
|
583
|
+
assert.calledWith(webex.request, {
|
|
584
|
+
uri: `${boardServiceUrl}/channels/${boardId}/contents`,
|
|
585
|
+
qs: {
|
|
586
|
+
contentsLimit: boardConfig.board.numberContentsPerPageForGet,
|
|
587
|
+
},
|
|
588
|
+
})
|
|
589
|
+
));
|
|
590
|
+
|
|
591
|
+
it('requests GET contents with client defined page size', () =>
|
|
592
|
+
webex.internal.board.getContents(channel, {contentsLimit: 25}).then(() =>
|
|
593
|
+
assert.calledWith(webex.request, {
|
|
594
|
+
uri: `${boardServiceUrl}/channels/${boardId}/contents`,
|
|
595
|
+
qs: {
|
|
596
|
+
contentsLimit: 25,
|
|
597
|
+
},
|
|
598
|
+
})
|
|
599
|
+
));
|
|
496
600
|
});
|
|
497
601
|
|
|
498
602
|
describe('#register()', () => {
|
|
@@ -503,11 +607,14 @@ describe('plugin-board', () => {
|
|
|
503
607
|
});
|
|
504
608
|
|
|
505
609
|
it('requests POST data to registration service', () => {
|
|
506
|
-
assert.calledWith(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
610
|
+
assert.calledWith(
|
|
611
|
+
webex.request,
|
|
612
|
+
sinon.match({
|
|
613
|
+
method: 'POST',
|
|
614
|
+
api: 'board',
|
|
615
|
+
resource: '/registrations',
|
|
616
|
+
})
|
|
617
|
+
);
|
|
511
618
|
});
|
|
512
619
|
});
|
|
513
620
|
|
|
@@ -516,22 +623,26 @@ describe('plugin-board', () => {
|
|
|
516
623
|
webex.request.resetHistory();
|
|
517
624
|
webex.internal.mercury.localClusterServiceUrls = {
|
|
518
625
|
mercuryApiServiceClusterUrl: 'https://mercury-api-a5.wbx2.com/v1',
|
|
519
|
-
mercuryConnectionServiceClusterUrl: 'https://mercury-connection-a5.wbx2.com/v1'
|
|
626
|
+
mercuryConnectionServiceClusterUrl: 'https://mercury-connection-a5.wbx2.com/v1',
|
|
520
627
|
};
|
|
521
628
|
webex.internal.feature.getFeature.returns(Promise.resolve(true));
|
|
522
629
|
});
|
|
523
630
|
|
|
524
|
-
it('requests POST data to registration service', () =>
|
|
525
|
-
.then(() => {
|
|
526
|
-
assert.calledWith(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
631
|
+
it('requests POST data to registration service', () =>
|
|
632
|
+
webex.internal.board.registerToShareMercury(channel).then(() => {
|
|
633
|
+
assert.calledWith(
|
|
634
|
+
webex.request,
|
|
635
|
+
sinon.match({
|
|
636
|
+
method: 'POST',
|
|
637
|
+
uri: `${channel.channelUrl}/register`,
|
|
638
|
+
body: {
|
|
639
|
+
mercuryConnectionServiceClusterUrl:
|
|
640
|
+
webex.internal.mercury.localClusterServiceUrls.mercuryConnectionServiceClusterUrl,
|
|
641
|
+
webSocketUrl: webex.internal.device.webSocketUrl,
|
|
642
|
+
action: 'ADD',
|
|
643
|
+
},
|
|
644
|
+
})
|
|
645
|
+
);
|
|
535
646
|
}));
|
|
536
647
|
|
|
537
648
|
it('rejects when localClusterServiceUrls is null', () => {
|