@webex/internal-plugin-ediscovery 3.0.0-beta.8 → 3.0.0-bnr.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.
@@ -22,7 +22,7 @@ describe('EDiscovery Transform Tests', () => {
22
22
  ctx.webex.config.ediscovery = config.ediscovery;
23
23
  ctx.webex.internal = {
24
24
  device: {
25
- deviceType: 'FAKE_DEVICE'
25
+ deviceType: 'FAKE_DEVICE',
26
26
  },
27
27
  encryption: {
28
28
  encryptText: sinon.stub().returns(Promise.resolve(encryptedText)),
@@ -30,9 +30,9 @@ describe('EDiscovery Transform Tests', () => {
30
30
  decryptScr: sinon.stub().returns(Promise.resolve(decryptedScr)),
31
31
  kms: {
32
32
  createUnboundKeys: sinon.stub().returns(Promise.resolve([{userIds: uuid, uri: keyUri}])),
33
- createResource: sinon.stub().returns(Promise.resolve())
34
- }
35
- }
33
+ createResource: sinon.stub().returns(Promise.resolve()),
34
+ },
35
+ },
36
36
  };
37
37
  });
38
38
 
@@ -61,21 +61,20 @@ describe('EDiscovery Transform Tests', () => {
61
61
  it('Calls the correct encrypt functions when transforming a report request', () => {
62
62
  // body IS a ReportRequest
63
63
  object = {body: reportRequest};
64
- const result = Transforms.encryptReportRequest(ctx, object)
65
- .then(() => {
66
- assert.callCount(ctx.webex.internal.encryption.encryptText, 4);
67
- assert.equal(reportRequest.name, encryptedText);
68
- assert.equal(reportRequest.description, '');
69
- assert.equal(reportRequest.spaceNames[0], encryptedText);
70
- assert.equal(reportRequest.emails[0], encryptedText);
71
- assert.equal(reportRequest.emails[1], encryptedText);
72
- // unencryptedEmails should be copied from emails before decryption
73
- assert.equal(reportRequest.unencryptedEmails[0], 'email1@test.com');
74
- assert.equal(reportRequest.unencryptedEmails[1], 'email2@test.com');
75
- assert.empty(reportRequest.keywords);
76
- // this should be populated by request to kms
77
- assert.notEqual(reportRequest.encryptionKeyUrl, '');
78
- });
64
+ const result = Transforms.encryptReportRequest(ctx, object).then(() => {
65
+ assert.callCount(ctx.webex.internal.encryption.encryptText, 4);
66
+ assert.equal(reportRequest.name, encryptedText);
67
+ assert.equal(reportRequest.description, '');
68
+ assert.equal(reportRequest.spaceNames[0], encryptedText);
69
+ assert.equal(reportRequest.emails[0], encryptedText);
70
+ assert.equal(reportRequest.emails[1], encryptedText);
71
+ // unencryptedEmails should be copied from emails before decryption
72
+ assert.equal(reportRequest.unencryptedEmails[0], 'email1@test.com');
73
+ assert.equal(reportRequest.unencryptedEmails[1], 'email2@test.com');
74
+ assert.empty(reportRequest.keywords);
75
+ // this should be populated by request to kms
76
+ assert.notEqual(reportRequest.encryptionKeyUrl, '');
77
+ });
79
78
 
80
79
  return result;
81
80
  });
@@ -87,16 +86,15 @@ describe('EDiscovery Transform Tests', () => {
87
86
  object = {body: {reportRequest}};
88
87
  // object to be decrypted must have an encryption key
89
88
  reportRequest.encryptionKeyUrl = keyUri;
90
- const result = Transforms.decryptReportRequest(ctx, object)
91
- .then(() => {
92
- assert.callCount(ctx.webex.internal.encryption.decryptText, 4);
93
- assert.equal(reportRequest.name, decryptedText);
94
- assert.equal(reportRequest.description, '');
95
- assert.equal(reportRequest.spaceNames[0], decryptedText);
96
- assert.equal(reportRequest.emails[0], decryptedText);
97
- assert.equal(reportRequest.emails[1], decryptedText);
98
- assert.empty(reportRequest.keywords);
99
- });
89
+ const result = Transforms.decryptReportRequest(ctx, object).then(() => {
90
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 4);
91
+ assert.equal(reportRequest.name, decryptedText);
92
+ assert.equal(reportRequest.description, '');
93
+ assert.equal(reportRequest.spaceNames[0], decryptedText);
94
+ assert.equal(reportRequest.emails[0], decryptedText);
95
+ assert.equal(reportRequest.emails[1], decryptedText);
96
+ assert.empty(reportRequest.keywords);
97
+ });
100
98
 
101
99
  return result;
102
100
  });
@@ -104,10 +102,9 @@ describe('EDiscovery Transform Tests', () => {
104
102
  it('Does not attempt to decrypt a report request if there is no encryption key url', () => {
105
103
  // body CONTAINS a ReportRequest
106
104
  object = {body: {reportRequest}};
107
- const result = Transforms.decryptReportRequest(ctx, object)
108
- .then(() => {
109
- assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
110
- });
105
+ const result = Transforms.decryptReportRequest(ctx, object).then(() => {
106
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
107
+ });
111
108
 
112
109
  return result;
113
110
  });
@@ -136,27 +133,41 @@ describe('EDiscovery Transform Tests', () => {
136
133
  contentContainer.containerId = '0';
137
134
  contentContainer.containerName = 'spaceName';
138
135
  contentContainer.isOneOnOne = false;
139
- contentContainer.participants = [{id: uuid, displayName: 'user1'}, {id: uuid, displayName: 'user2'}, {id: uuid, displayName: 'user3'}];
136
+ contentContainer.participants = [
137
+ {id: uuid, displayName: 'user1'},
138
+ {id: uuid, displayName: 'user2'},
139
+ {id: uuid, displayName: 'user3'},
140
+ ];
140
141
  contentContainer.onBehalfOfUser = uuid;
141
142
  contentContainer.encryptionKeyUrl = keyUri;
142
143
 
143
- ctx.webex.internal.ediscovery = {getContentContainerByContainerId: sinon.stub().returns(Promise.resolve({body: contentContainer}))};
144
+ ctx.webex.internal.ediscovery = {
145
+ getContentContainerByContainerId: sinon
146
+ .stub()
147
+ .returns(Promise.resolve({body: contentContainer})),
148
+ };
144
149
  });
145
150
 
146
- afterEach(() => ctx.webex.internal.ediscovery.getContentContainerByContainerId.resetHistory());
151
+ afterEach(() =>
152
+ ctx.webex.internal.ediscovery.getContentContainerByContainerId.resetHistory()
153
+ );
147
154
 
148
155
  it('Calls the decrypt functions when extension type is customApp', () => {
149
156
  object.body.extension = {
150
- objectType: 'extension', extensionType: 'customApp', contentUrl: 'encrypted content', displayName: 'encrypted content', webUrl: 'encrypted content', appId: uuid
157
+ objectType: 'extension',
158
+ extensionType: 'customApp',
159
+ contentUrl: 'encrypted content',
160
+ displayName: 'encrypted content',
161
+ webUrl: 'encrypted content',
162
+ appId: uuid,
151
163
  };
152
- const result = Transforms.decryptReportContent(ctx, object, reportId)
153
- .then(() => {
154
- assert.equal(object.body.extension.contentUrl, decryptedText);
155
- assert.equal(object.body.extension.webUrl, decryptedText);
156
- assert.equal(object.body.extension.appId, uuid);
157
- assert.equal(object.body.extension.displayName, decryptedText);
158
- assert.equal(activity.error, undefined);
159
- });
164
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
165
+ assert.equal(object.body.extension.contentUrl, decryptedText);
166
+ assert.equal(object.body.extension.webUrl, decryptedText);
167
+ assert.equal(object.body.extension.appId, uuid);
168
+ assert.equal(object.body.extension.displayName, decryptedText);
169
+ assert.equal(activity.error, undefined);
170
+ });
160
171
 
161
172
  return result;
162
173
  });
@@ -164,26 +175,28 @@ describe('EDiscovery Transform Tests', () => {
164
175
  it('Calls the decrypt functions when extension type is customApp along with the verb is update', () => {
165
176
  object.body.verb = 'update';
166
177
  object.body.extension = {
167
- objectType: 'extension', extensionType: 'customApp', contentUrl: 'encrypted content', displayName: 'encrypted content', previous: {contentUrl: 'encrypted content', displayName: 'encrypted content'}
178
+ objectType: 'extension',
179
+ extensionType: 'customApp',
180
+ contentUrl: 'encrypted content',
181
+ displayName: 'encrypted content',
182
+ previous: {contentUrl: 'encrypted content', displayName: 'encrypted content'},
168
183
  };
169
- const result = Transforms.decryptReportContent(ctx, object, reportId)
170
- .then(() => {
171
- assert.equal(object.body.extension.contentUrl, decryptedText);
172
- assert.equal(object.body.extension.displayName, decryptedText);
173
- assert.equal(object.body.extension.previous.contentUrl, decryptedText);
174
- assert.equal(object.body.extension.previous.displayName, decryptedText);
175
- assert.equal(activity.error, undefined);
176
- });
184
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
185
+ assert.equal(object.body.extension.contentUrl, decryptedText);
186
+ assert.equal(object.body.extension.displayName, decryptedText);
187
+ assert.equal(object.body.extension.previous.contentUrl, decryptedText);
188
+ assert.equal(object.body.extension.previous.displayName, decryptedText);
189
+ assert.equal(activity.error, undefined);
190
+ });
177
191
 
178
192
  return result;
179
193
  });
180
194
 
181
195
  it('Calls the correct decrypt functions when transforming post activities', () => {
182
- const result = Transforms.decryptReportContent(ctx, object, reportId)
183
- .then(() => {
184
- assert.equal(activity.objectDisplayName, decryptedText);
185
- assert.equal(activity.spaceName, contentContainer.containerName);
186
- });
196
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
197
+ assert.equal(activity.objectDisplayName, decryptedText);
198
+ assert.equal(activity.spaceName, contentContainer.containerName);
199
+ });
187
200
 
188
201
  return result;
189
202
  });
@@ -191,14 +204,16 @@ describe('EDiscovery Transform Tests', () => {
191
204
  it('Creates spaceName from participantDisplayNames for one to one spaces', () => {
192
205
  contentContainer.isOneOnOne = true;
193
206
  // one to one conversations have only 2 participants
194
- contentContainer.participants = [{id: uuid, displayName: 'user1'}, {id: uuid, displayName: 'user2'}];
207
+ contentContainer.participants = [
208
+ {id: uuid, displayName: 'user1'},
209
+ {id: uuid, displayName: 'user2'},
210
+ ];
195
211
  // spacename should be undefined for one on one conversations
196
212
  contentContainer.containerName = undefined;
197
- const result = Transforms.decryptReportContent(ctx, object, reportId)
198
- .then(() => {
199
- assert.equal(activity.objectDisplayName, decryptedText);
200
- assert.equal(activity.spaceName, 'user1 & user2');
201
- });
213
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
214
+ assert.equal(activity.objectDisplayName, decryptedText);
215
+ assert.equal(activity.spaceName, 'user1 & user2');
216
+ });
202
217
 
203
218
  return result;
204
219
  });
@@ -207,12 +222,11 @@ describe('EDiscovery Transform Tests', () => {
207
222
  object.body.verb = 'add';
208
223
  // object display name for add activity is a uuid
209
224
  object.body.objectDisplayName = uuid;
210
- const result = Transforms.decryptReportContent(ctx, object, reportId)
211
- .then(() => {
212
- assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
213
- assert.equal(activity.objectDisplayName, uuid);
214
- assert.equal(activity.spaceName, contentContainer.containerName);
215
- });
225
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
226
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
227
+ assert.equal(activity.objectDisplayName, uuid);
228
+ assert.equal(activity.spaceName, contentContainer.containerName);
229
+ });
216
230
 
217
231
  return result;
218
232
  });
@@ -221,73 +235,71 @@ describe('EDiscovery Transform Tests', () => {
221
235
  object.body.verb = 'leave';
222
236
  // object display name for leave activity is a uuid
223
237
  object.body.objectDisplayName = uuid;
224
- const result = Transforms.decryptReportContent(ctx, object, reportId)
225
- .then(() => {
226
- assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
227
- assert.equal(activity.objectDisplayName, uuid);
228
- assert.equal(activity.spaceName, contentContainer.containerName);
229
- });
238
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
239
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
240
+ assert.equal(activity.objectDisplayName, uuid);
241
+ assert.equal(activity.spaceName, contentContainer.containerName);
242
+ });
230
243
 
231
244
  return result;
232
245
  });
233
246
 
234
247
  it('Does not call any decrypt functions if encryption key url is empty', () => {
235
248
  object.body.encryptionKeyUrl = '';
236
- const result = Transforms.decryptReportContent(ctx, object, reportId)
237
- .then(() => {
238
- assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
239
- assert.equal(activity.objectDisplayName, 'encrypted content');
240
- assert.equal(activity.spaceName, contentContainer.containerName);
241
- });
249
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
250
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
251
+ assert.equal(activity.objectDisplayName, 'encrypted content');
252
+ assert.equal(activity.spaceName, contentContainer.containerName);
253
+ });
242
254
 
243
255
  return result;
244
256
  });
245
257
 
246
258
  it('Does not call any decrypt functions if encryption key url is undefined', () => {
247
259
  object.body.encryptionKeyUrl = undefined;
248
- const result = Transforms.decryptReportContent(ctx, object, reportId)
249
- .then(() => {
250
- assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
251
- assert.equal(activity.objectDisplayName, 'encrypted content');
252
- assert.equal(activity.spaceName, contentContainer.containerName);
253
- });
260
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
261
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
262
+ assert.equal(activity.objectDisplayName, 'encrypted content');
263
+ assert.equal(activity.spaceName, contentContainer.containerName);
264
+ });
254
265
 
255
266
  return result;
256
267
  });
257
268
 
258
269
  it('Does not call any decrypt functions if onBehalfOfUser is empty', () => {
259
270
  contentContainer.onBehalfOfUser = '';
260
- const result = Transforms.decryptReportContent(ctx, object, reportId)
261
- .then(() => {
262
- assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
263
- assert.equal(activity.objectDisplayName, 'encrypted content');
264
- assert.equal(activity.spaceName, contentContainer.containerName);
265
- });
271
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
272
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
273
+ assert.equal(activity.objectDisplayName, 'encrypted content');
274
+ assert.equal(activity.spaceName, contentContainer.containerName);
275
+ });
266
276
 
267
277
  return result;
268
278
  });
269
279
 
270
280
  it('Does not call any decrypt functions if onBehalfOfUser is undefined', () => {
271
281
  contentContainer.onBehalfOfUser = undefined;
272
- const result = Transforms.decryptReportContent(ctx, object, reportId)
273
- .then(() => {
274
- assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
275
- assert.equal(activity.objectDisplayName, 'encrypted content');
276
- assert.equal(activity.spaceName, contentContainer.containerName);
277
- });
282
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
283
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 0);
284
+ assert.equal(activity.objectDisplayName, 'encrypted content');
285
+ assert.equal(activity.spaceName, contentContainer.containerName);
286
+ });
278
287
 
279
288
  return result;
280
289
  });
281
290
 
282
291
  it('Decrypt function throws an exception', () => {
283
- ctx.webex.internal.encryption.decryptText = sinon.stub().returns(Promise.reject(new Error('@@@@@@')));
292
+ const expectedError = new Error('Failed to acquire a key');
293
+ ctx.webex.internal.encryption.decryptText = sinon
294
+ .stub()
295
+ .returns(Promise.reject(expectedError));
284
296
 
285
297
  const result = Transforms.decryptReportContent(ctx, object, reportId)
286
298
  .then(() => {
287
299
  assert.fail('Decrypt did not fail as expected');
288
300
  })
289
301
  .catch(() => {
290
- assert.isDefined(activity.error);
302
+ assert.deepEqual(activity.error, expectedError);
291
303
  });
292
304
 
293
305
  return result;
@@ -298,14 +310,13 @@ describe('EDiscovery Transform Tests', () => {
298
310
  // there should be no other content for a share
299
311
  object.body.objectDisplayName = undefined;
300
312
  object.body.files = [{displayName: 'file name', scr: 'eyJhbGciOi...'}];
301
- const result = Transforms.decryptReportContent(ctx, object, reportId)
302
- .then(() => {
303
- assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
304
- assert.callCount(ctx.webex.internal.encryption.decryptScr, 1);
305
- assert.equal(activity.objectDisplayName, undefined);
306
- assert.equal(activity.files[0].displayName, decryptedText);
307
- assert.equal(activity.files[0].scr, decryptedScr);
308
- });
313
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
314
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
315
+ assert.callCount(ctx.webex.internal.encryption.decryptScr, 1);
316
+ assert.equal(activity.objectDisplayName, undefined);
317
+ assert.equal(activity.files[0].displayName, decryptedText);
318
+ assert.equal(activity.files[0].scr, decryptedScr);
319
+ });
309
320
 
310
321
  return result;
311
322
  });
@@ -314,27 +325,31 @@ describe('EDiscovery Transform Tests', () => {
314
325
  object.body.verb = 'share';
315
326
  // there should be no other content for a share
316
327
  object.body.objectDisplayName = undefined;
317
- object.body.files = [{displayName: 'file name', scr: 'eyJhbGciOi...', microsoftSharedLinkInfo: {driveId: '1', itemId: '2'}}];
318
- const result = Transforms.decryptReportContent(ctx, object, reportId)
319
- .then(() => {
320
- assert.callCount(ctx.webex.internal.encryption.decryptText, 3);
321
- assert.callCount(ctx.webex.internal.encryption.decryptScr, 1);
322
- assert.equal(activity.objectDisplayName, undefined);
323
- assert.equal(activity.files[0].displayName, decryptedText);
324
- assert.equal(activity.files[0].scr, decryptedScr);
325
- assert.equal(activity.files[0].microsoftSharedLinkInfo.driveId, decryptedText);
326
- assert.equal(activity.files[0].microsoftSharedLinkInfo.itemId, decryptedText);
327
- });
328
+ object.body.files = [
329
+ {
330
+ displayName: 'file name',
331
+ scr: 'eyJhbGciOi...',
332
+ microsoftSharedLinkInfo: {driveId: '1', itemId: '2'},
333
+ },
334
+ ];
335
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
336
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 3);
337
+ assert.callCount(ctx.webex.internal.encryption.decryptScr, 1);
338
+ assert.equal(activity.objectDisplayName, undefined);
339
+ assert.equal(activity.files[0].displayName, decryptedText);
340
+ assert.equal(activity.files[0].scr, decryptedScr);
341
+ assert.equal(activity.files[0].microsoftSharedLinkInfo.driveId, decryptedText);
342
+ assert.equal(activity.files[0].microsoftSharedLinkInfo.itemId, decryptedText);
343
+ });
328
344
 
329
345
  return result;
330
346
  });
331
347
 
332
348
  it('Adds warning to activity if warning found while retrieving space', () => {
333
349
  contentContainer.warning = 'warn';
334
- const result = Transforms.decryptReportContent(ctx, object, reportId)
335
- .then(() => {
336
- assert.equal(activity.warn, contentContainer.warn);
337
- });
350
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
351
+ assert.equal(activity.warn, contentContainer.warn);
352
+ });
338
353
 
339
354
  return result;
340
355
  });
@@ -343,11 +358,10 @@ describe('EDiscovery Transform Tests', () => {
343
358
  object.body.verb = 'add';
344
359
  object.body.objectDisplayName = undefined;
345
360
  object.body.meeting = {title: 'Encrypted Title'};
346
- const result = Transforms.decryptReportContent(ctx, object, reportId)
347
- .then(() => {
348
- assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
349
- assert.equal(activity.error, undefined);
350
- });
361
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
362
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
363
+ assert.equal(activity.error, undefined);
364
+ });
351
365
 
352
366
  return result;
353
367
  });
@@ -356,11 +370,10 @@ describe('EDiscovery Transform Tests', () => {
356
370
  object.body.verb = 'add';
357
371
  object.body.objectDisplayName = undefined;
358
372
  object.body.recording = {topic: 'Encrypted Topic'};
359
- const result = Transforms.decryptReportContent(ctx, object, reportId)
360
- .then(() => {
361
- assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
362
- assert.equal(activity.error, undefined);
363
- });
373
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
374
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
375
+ assert.equal(activity.error, undefined);
376
+ });
364
377
 
365
378
  return result;
366
379
  });
@@ -369,24 +382,26 @@ describe('EDiscovery Transform Tests', () => {
369
382
  object.body.verb = 'update';
370
383
  object.body.spaceInfo = {name: 'Encrypted Name'};
371
384
  object.body.objectDisplayName = undefined;
372
- const result = Transforms.decryptReportContent(ctx, object, reportId)
373
- .then(() => {
374
- assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
375
- assert.equal(activity.error, undefined);
376
- });
385
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
386
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
387
+ assert.equal(activity.error, undefined);
388
+ });
377
389
 
378
390
  return result;
379
391
  });
380
392
 
381
393
  it('Calls the correct decrypt functions when transforming activity.spaceInfo.name with previousValue', () => {
382
394
  object.body.verb = 'update';
383
- object.body.spaceInfo = {name: 'Encrypted Name', previousName: 'Previous Name', previousEncryptionKeyUrl: keyUri};
395
+ object.body.spaceInfo = {
396
+ name: 'Encrypted Name',
397
+ previousName: 'Previous Name',
398
+ previousEncryptionKeyUrl: keyUri,
399
+ };
384
400
  object.body.objectDisplayName = undefined;
385
- const result = Transforms.decryptReportContent(ctx, object, reportId)
386
- .then(() => {
387
- assert.callCount(ctx.webex.internal.encryption.decryptText, 2);
388
- assert.equal(activity.error, undefined);
389
- });
401
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
402
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 2);
403
+ assert.equal(activity.error, undefined);
404
+ });
390
405
 
391
406
  return result;
392
407
  });
@@ -395,23 +410,83 @@ describe('EDiscovery Transform Tests', () => {
395
410
  object.body.verb = 'update';
396
411
  object.body.spaceInfo = {description: 'Encrypted Description'};
397
412
  object.body.objectDisplayName = undefined;
413
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
414
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
415
+ assert.equal(activity.error, undefined);
416
+ });
417
+
418
+ return result;
419
+ });
420
+
421
+ it('Calls the correct decrypt functions when transforming both activity.spaceInfo.name and activity.spaceInfo.description', () => {
422
+ object.body.verb = 'update';
423
+ object.body.spaceInfo = {name: 'Encrypted Name', description: 'Encrypted description'};
424
+ object.body.objectDisplayName = undefined;
425
+ const result = Transforms.decryptReportContent(ctx, object, reportId).then(() => {
426
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 2);
427
+ assert.equal(activity.error, undefined);
428
+ });
429
+
430
+ return result;
431
+ });
432
+
433
+ it('Calls the correct decrypt functions when transforming activity.encryptedTextKeyValues', () => {
434
+ object.body.verb = 'add';
435
+ object.body.objectDisplayName = undefined;
436
+ object.body.encryptedTextKeyValues = {
437
+ CallingLineId: 'Encrypted Phone Number 1',
438
+ CallingNumber: 'Encrypted Phone Number 2',
439
+ RedirectingNumber: 'Encrypted Phone Number 3',
440
+ };
398
441
  const result = Transforms.decryptReportContent(ctx, object, reportId)
399
442
  .then(() => {
400
- assert.callCount(ctx.webex.internal.encryption.decryptText, 1);
443
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 3);
401
444
  assert.equal(activity.error, undefined);
445
+ assert.equal(object.body.encryptedTextKeyValues.CallingLineId, decryptedText);
446
+ assert.equal(object.body.encryptedTextKeyValues.CallingNumber, decryptedText);
447
+ assert.equal(object.body.encryptedTextKeyValues.RedirectingNumber, decryptedText);
402
448
  });
403
449
 
404
450
  return result;
405
451
  });
406
452
 
407
- it('Calls the correct decrypt functions when transforming both activity.spaceInfo.name and activity.spaceInfo.description', () => {
408
- object.body.verb = 'update';
409
- object.body.spaceInfo = {name: 'Encrypted Name', description: 'Encrypted description'};
453
+ it('Calls the correct decrypt functions when transforming activity.encryptedTextKeyValues and no onBehalfOfUser user is present', () => {
454
+ contentContainer.onBehalfOfUser = undefined;
455
+ object.body.verb = 'add';
410
456
  object.body.objectDisplayName = undefined;
457
+ object.body.encryptedTextKeyValues = {
458
+ CallingLineId: 'Encrypted Phone Number 1',
459
+ CallingNumber: 'Encrypted Phone Number 2',
460
+ RedirectingNumber: 'Encrypted Phone Number 3',
461
+ };
411
462
  const result = Transforms.decryptReportContent(ctx, object, reportId)
412
463
  .then(() => {
413
- assert.callCount(ctx.webex.internal.encryption.decryptText, 2);
464
+ assert.callCount(ctx.webex.internal.encryption.decryptText, 3);
414
465
  assert.equal(activity.error, undefined);
466
+ assert.equal(object.body.encryptedTextKeyValues.CallingLineId, decryptedText);
467
+ assert.equal(object.body.encryptedTextKeyValues.CallingNumber, decryptedText);
468
+ assert.equal(object.body.encryptedTextKeyValues.RedirectingNumber, decryptedText);
469
+ });
470
+
471
+ return result;
472
+ });
473
+
474
+ it('Decrypt function throws an exception when processing activity.encryptedTextKeyValues', () => {
475
+ const expectedError = new Error('Failed to acquire a key');
476
+ ctx.webex.internal.encryption.decryptText = sinon.stub().returns(Promise.reject(expectedError));
477
+ object.body.verb = 'add';
478
+ object.body.objectDisplayName = undefined;
479
+ object.body.encryptedTextKeyValues = {
480
+ CallingLineId: 'Encrypted Phone Number 1',
481
+ CallingNumber: 'Encrypted Phone Number 2',
482
+ RedirectingNumber: 'Encrypted Phone Number 3',
483
+ };
484
+ const result = Transforms.decryptReportContent(ctx, object, reportId)
485
+ .then(() => {
486
+ assert.fail('Decrypt did not fail as expected');
487
+ })
488
+ .catch(() => {
489
+ assert.deepEqual(activity.error, expectedError);
415
490
  });
416
491
 
417
492
  return result;