@webex/internal-plugin-calendar 3.0.0-beta.3 → 3.0.0-beta.300
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/calendar.decrypt.helper.js +73 -0
- package/dist/calendar.decrypt.helper.js.map +1 -0
- package/dist/calendar.encrypt.helper.js +88 -0
- package/dist/calendar.encrypt.helper.js.map +1 -0
- package/dist/calendar.js +216 -116
- package/dist/calendar.js.map +1 -1
- package/dist/collection.js +0 -19
- package/dist/collection.js.map +1 -1
- package/dist/config.js +0 -3
- package/dist/config.js.map +1 -1
- package/dist/constants.js +0 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.js +10 -24
- package/dist/index.js.map +1 -1
- package/dist/util.js +0 -13
- package/dist/util.js.map +1 -1
- package/package.json +9 -11
- package/src/calendar.decrypt.helper.js +121 -0
- package/src/calendar.encrypt.helper.js +98 -0
- package/src/calendar.js +242 -53
- package/src/collection.js +2 -4
- package/src/config.js +2 -2
- package/src/index.js +124 -43
- package/src/util.js +5 -3
- package/test/integration/spec/calendar.js +379 -271
- package/test/unit/spec/calendar.decrypt.helper.js +145 -0
- package/test/unit/spec/calendar.encrypt.helper.js +52 -0
- package/test/unit/spec/calendar.js +249 -94
- package/test/unit/spec/utils.js +4 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import { expect } from "@webex/test-helper-chai";
|
|
3
|
+
import DecryptHelper from "@webex/internal-plugin-calendar/src/calendar.decrypt.helper";
|
|
4
|
+
|
|
5
|
+
describe("internal-plugin-calendar", () => {
|
|
6
|
+
describe("DecryptHelper", () => {
|
|
7
|
+
let ctx;
|
|
8
|
+
let encryptedSchedulerData;
|
|
9
|
+
let encryptedFreeBusyData;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
ctx = {
|
|
13
|
+
webex: {
|
|
14
|
+
internal: {
|
|
15
|
+
encryption: {
|
|
16
|
+
decryptText: sinon.stub()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
encryptedSchedulerData = {
|
|
23
|
+
encryptionKeyUrl: "http://example.com/encryption-key",
|
|
24
|
+
encryptedSubject: "some encrypted subject",
|
|
25
|
+
encryptedLocation: "some encrypted location",
|
|
26
|
+
encryptedNotes: "some encrypted notes",
|
|
27
|
+
encryptedParticipants: [
|
|
28
|
+
{
|
|
29
|
+
encryptedEmailAddress: "some encrypted email address",
|
|
30
|
+
encryptedName: "some encrypted name"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
encryptedEmailAddress: "another encrypted email address",
|
|
34
|
+
encryptedName: "another encrypted name"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
encryptedScheduleFor: {
|
|
38
|
+
"user1@example.com": {
|
|
39
|
+
encryptedEmail: "some encrypted email address",
|
|
40
|
+
encryptedDisplayName: "some encrypted display name"
|
|
41
|
+
},
|
|
42
|
+
"user2@example.com": {
|
|
43
|
+
encryptedEmail: "another encrypted email address",
|
|
44
|
+
encryptedDisplayName: "another encrypted display name"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
meetingJoinInfo: {
|
|
48
|
+
meetingJoinURI: "some encrypted meeting join URI",
|
|
49
|
+
meetingJoinURL: "some encrypted meeting join URL"
|
|
50
|
+
},
|
|
51
|
+
encryptedOrganizer: {
|
|
52
|
+
encryptedEmailAddress: "some encrypted email address",
|
|
53
|
+
encryptedName: "some encrypted name"
|
|
54
|
+
},
|
|
55
|
+
webexURI: "some encrypted webex URI",
|
|
56
|
+
webexURL: "some encrypted webex URL",
|
|
57
|
+
spaceMeetURL: "some encrypted space meet URL",
|
|
58
|
+
spaceURI: "some encrypted space URI",
|
|
59
|
+
spaceURL: "some encrypted space URL"
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
encryptedFreeBusyData = {
|
|
63
|
+
calendarFreeBusyScheduleResponse: {
|
|
64
|
+
encryptionKeyUrl: "https://encryption.key/url",
|
|
65
|
+
calendarFreeBusyItems: [
|
|
66
|
+
{
|
|
67
|
+
email: "encrypted-email"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
afterEach(() => {
|
|
75
|
+
sinon.restore();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("#decryptSchedulerDataResponse - should resolve with undefined if data is undefined", async () => {
|
|
79
|
+
const decryptedData = await DecryptHelper.decryptSchedulerDataResponse(ctx, undefined);
|
|
80
|
+
expect(decryptedData).to.be.undefined;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("#decryptSchedulerDataResponse - should resolve with undefined if data.encryptionKeyUrl is undefined", async () => {
|
|
84
|
+
encryptedSchedulerData.encryptionKeyUrl = undefined;
|
|
85
|
+
const decryptedData = await DecryptHelper.decryptSchedulerDataResponse(ctx, encryptedSchedulerData);
|
|
86
|
+
expect(decryptedData).to.be.undefined;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("#decryptSchedulerDataResponse - should replace encrypted data with decrypted data in response", () => {
|
|
90
|
+
it("should decrypt scheduler data response correctly", async () => {
|
|
91
|
+
// Stub the decryption method to return the plaintext value.
|
|
92
|
+
const expectedCiphertext = "some decrypted text for testing";
|
|
93
|
+
|
|
94
|
+
ctx.webex.internal.encryption.decryptText.callsFake((key, ciphertext) => Promise.resolve(expectedCiphertext));
|
|
95
|
+
|
|
96
|
+
// Decrypt the data.
|
|
97
|
+
await DecryptHelper.decryptSchedulerDataResponse(ctx, encryptedSchedulerData);
|
|
98
|
+
|
|
99
|
+
// Check that all encrypted properties were decrypted correctly.
|
|
100
|
+
expect(encryptedSchedulerData.encryptedSubject).to.equal(expectedCiphertext);
|
|
101
|
+
expect(encryptedSchedulerData.encryptedLocation).to.equal(expectedCiphertext);
|
|
102
|
+
expect(encryptedSchedulerData.encryptedNotes).to.equal(expectedCiphertext);
|
|
103
|
+
expect(encryptedSchedulerData.encryptedParticipants[0].encryptedEmailAddress).to.equal(expectedCiphertext);
|
|
104
|
+
expect(encryptedSchedulerData.encryptedParticipants[0].encryptedName).to.equal(expectedCiphertext);
|
|
105
|
+
expect(encryptedSchedulerData.encryptedScheduleFor["user1@example.com"].encryptedEmail).to.equal(expectedCiphertext);
|
|
106
|
+
expect(encryptedSchedulerData.encryptedScheduleFor["user1@example.com"].encryptedDisplayName).to.equal(expectedCiphertext);
|
|
107
|
+
expect(encryptedSchedulerData.meetingJoinInfo.meetingJoinURI).to.equal(expectedCiphertext);
|
|
108
|
+
expect(encryptedSchedulerData.meetingJoinInfo.meetingJoinURL).to.equal(expectedCiphertext);
|
|
109
|
+
|
|
110
|
+
expect(encryptedSchedulerData.encryptedOrganizer.encryptedEmailAddress).to.equal(expectedCiphertext);
|
|
111
|
+
expect(encryptedSchedulerData.encryptedOrganizer.encryptedName).to.equal(expectedCiphertext);
|
|
112
|
+
expect(encryptedSchedulerData.webexURI).to.equal(expectedCiphertext);
|
|
113
|
+
expect(encryptedSchedulerData.webexURL).to.equal(expectedCiphertext);
|
|
114
|
+
expect(encryptedSchedulerData.spaceMeetURL).to.equal(expectedCiphertext);
|
|
115
|
+
expect(encryptedSchedulerData.spaceURI).to.equal(expectedCiphertext);
|
|
116
|
+
expect(encryptedSchedulerData.spaceURL).to.equal(expectedCiphertext);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("#decryptFreeBusyResponse - should resolve with undefined if data is undefined", async () => {
|
|
121
|
+
const decryptedData = await DecryptHelper.decryptFreeBusyResponse(ctx, undefined);
|
|
122
|
+
expect(decryptedData).to.be.undefined;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("#decryptFreeBusyResponse - should resolve with undefined if data.calendarFreeBusyScheduleResponse is undefined", async () => {
|
|
126
|
+
const decryptedData = await DecryptHelper.decryptFreeBusyResponse(ctx, {});
|
|
127
|
+
expect(decryptedData).to.be.undefined;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("#decryptFreeBusyResponse - should resolve with undefined if data.calendarFreeBusyScheduleResponse.encryptionKeyUrl is undefined", async () => {
|
|
131
|
+
encryptedFreeBusyData.calendarFreeBusyScheduleResponse.encryptionKeyUrl = undefined;
|
|
132
|
+
const decryptedData = await DecryptHelper.decryptFreeBusyResponse(ctx, encryptedFreeBusyData);
|
|
133
|
+
expect(decryptedData).to.be.undefined;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("#decryptFreeBusyResponse - should replace encrypted email with decrypted email in calendarFreeBusyItems", async () => {
|
|
137
|
+
const decryptTextStub = ctx.webex.internal.encryption.decryptText;
|
|
138
|
+
decryptTextStub.resolves("decrypted-email");
|
|
139
|
+
|
|
140
|
+
await DecryptHelper.decryptFreeBusyResponse(ctx, encryptedFreeBusyData);
|
|
141
|
+
|
|
142
|
+
expect(encryptedFreeBusyData.calendarFreeBusyScheduleResponse.calendarFreeBusyItems[0].email).to.equal("decrypted-email");
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import {expect} from '@webex/test-helper-chai';
|
|
3
|
+
import EncryptHelper from '@webex/internal-plugin-calendar/src/calendar.encrypt.helper';
|
|
4
|
+
describe('internal-plugin-calendar', () => {
|
|
5
|
+
describe('encryptHelper', () => {
|
|
6
|
+
let ctx;
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
ctx = {
|
|
9
|
+
encryptionKeyUrl: 'http://example.com/encryption-key',
|
|
10
|
+
webex: {
|
|
11
|
+
internal: {
|
|
12
|
+
encryption: {
|
|
13
|
+
encryptText: sinon.stub(),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
sinon.restore();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('#encryptFreebusyRequestData with emails should ', async () => {
|
|
25
|
+
const freeBusyRequest = {
|
|
26
|
+
start: '20230712T10:20:00Z',
|
|
27
|
+
end: '20230712T20:20:00Z',
|
|
28
|
+
emails: ['test@webex.com'],
|
|
29
|
+
};
|
|
30
|
+
const expectedCiphertext = 'some encrpty data';
|
|
31
|
+
ctx.webex.internal.encryption.encryptText.callsFake((key, ciphertext) =>
|
|
32
|
+
Promise.resolve(expectedCiphertext)
|
|
33
|
+
);
|
|
34
|
+
await EncryptHelper.encryptFreeBusyRequest(ctx, freeBusyRequest);
|
|
35
|
+
expect(freeBusyRequest.emails[0]).to.be.equal(expectedCiphertext);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('#encryptFreebusyRequestData not include emails, but include ids- should b', async () => {
|
|
39
|
+
const freeBusyRequest = {
|
|
40
|
+
start: '20230712T10:20:00Z',
|
|
41
|
+
end: '20230712T20:20:00Z',
|
|
42
|
+
userIds: ['91aee1231'],
|
|
43
|
+
};
|
|
44
|
+
const expectedCiphertext = '91aee1231';
|
|
45
|
+
ctx.webex.internal.encryption.encryptText.callsFake((key, ciphertext) =>
|
|
46
|
+
Promise.resolve(expectedCiphertext)
|
|
47
|
+
);
|
|
48
|
+
await EncryptHelper.encryptFreeBusyRequest(ctx, freeBusyRequest);
|
|
49
|
+
expect(freeBusyRequest.userIds[0]).to.equal(expectedCiphertext);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {assert} from
|
|
5
|
+
import { assert, expect } from "@webex/test-helper-chai";
|
|
6
6
|
import Calendar from '@webex/internal-plugin-calendar';
|
|
7
7
|
import MockWebex from '@webex/test-helper-mock-webex';
|
|
8
|
-
import
|
|
8
|
+
import { base64 } from "@webex/common";
|
|
9
9
|
import sinon from 'sinon';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
CALENDAR_REGISTERED,
|
|
13
|
+
CALENDAR_UPDATED,
|
|
14
|
+
CALENDAR_DELETE,
|
|
15
|
+
CALENDAR_CREATE,
|
|
16
|
+
CALENDAR_UNREGISTERED,
|
|
17
|
+
} from '../../../src/constants';
|
|
12
18
|
|
|
13
19
|
describe('internal-plugin-calendar', () => {
|
|
14
20
|
describe('Calendar Apis', () => {
|
|
@@ -17,14 +23,14 @@ describe('internal-plugin-calendar', () => {
|
|
|
17
23
|
beforeEach(async () => {
|
|
18
24
|
webex = new MockWebex({
|
|
19
25
|
children: {
|
|
20
|
-
calendar: Calendar
|
|
21
|
-
}
|
|
26
|
+
calendar: Calendar,
|
|
27
|
+
},
|
|
22
28
|
});
|
|
23
29
|
|
|
24
30
|
webex.canAuthorize = true;
|
|
25
31
|
webex.internal.device = {
|
|
26
32
|
register: sinon.stub().returns(Promise.resolve()),
|
|
27
|
-
unregister: sinon.stub().returns(Promise.resolve())
|
|
33
|
+
unregister: sinon.stub().returns(Promise.resolve()),
|
|
28
34
|
};
|
|
29
35
|
webex.internal.mercury = {
|
|
30
36
|
connect: sinon.stub().returns(Promise.resolve()),
|
|
@@ -40,7 +46,15 @@ describe('internal-plugin-calendar', () => {
|
|
|
40
46
|
callback({data: {calendarMeetingExternal: {id: 'calendarId1'}}});
|
|
41
47
|
}
|
|
42
48
|
}),
|
|
43
|
-
off: sinon.spy()
|
|
49
|
+
off: sinon.spy(),
|
|
50
|
+
};
|
|
51
|
+
webex.internal.encryption = {
|
|
52
|
+
kms: {
|
|
53
|
+
createUnboundKeys: sinon.stub().resolves([{
|
|
54
|
+
uri: "kms://kms-us-int.wbx2.com/keys/xxxx-xxxx-xxxx-xxxx"
|
|
55
|
+
}])
|
|
56
|
+
},
|
|
57
|
+
encryptText: sinon.stub().resolves("encryptedText")
|
|
44
58
|
};
|
|
45
59
|
});
|
|
46
60
|
|
|
@@ -49,7 +63,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
49
63
|
it('on calendar register call mercury registration', async () => {
|
|
50
64
|
await webex.internal.calendar.register();
|
|
51
65
|
assert.calledOnce(webex.internal.device.register);
|
|
52
|
-
assert.callCount(webex.internal.mercury.on,
|
|
66
|
+
assert.callCount(webex.internal.mercury.on, 6);
|
|
53
67
|
assert.equal(webex.internal.calendar.registered, true);
|
|
54
68
|
});
|
|
55
69
|
it('should trigger `calendar:register` event', async () => {
|
|
@@ -91,7 +105,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
91
105
|
it('should call `mercury.unregister` and `device.unregister`', async () => {
|
|
92
106
|
await webex.internal.calendar.register();
|
|
93
107
|
await webex.internal.calendar.unregister();
|
|
94
|
-
assert.callCount(webex.internal.mercury.off,
|
|
108
|
+
assert.callCount(webex.internal.mercury.off, 6);
|
|
95
109
|
assert.calledOnce(webex.internal.mercury.disconnect);
|
|
96
110
|
assert.calledOnce(webex.internal.device.unregister);
|
|
97
111
|
});
|
|
@@ -108,14 +122,25 @@ describe('internal-plugin-calendar', () => {
|
|
|
108
122
|
|
|
109
123
|
describe('#syncCalendar()', () => {
|
|
110
124
|
it('should sync from calendar service', async () => {
|
|
111
|
-
webex.request = sinon
|
|
125
|
+
webex.request = sinon
|
|
126
|
+
.stub()
|
|
127
|
+
.returns(Promise.resolve({body: {items: [{id: 'calendar1'}, {id: 'calendar2'}]}}));
|
|
128
|
+
webex.request = sinon.stub().returns(
|
|
112
129
|
Promise.resolve({
|
|
113
130
|
body: {
|
|
114
131
|
items: [
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
{
|
|
133
|
+
id: 'calendar1',
|
|
134
|
+
encryptedNotes: 'notes1',
|
|
135
|
+
encryptedParticipants: ['participant1'],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: 'calendar2',
|
|
139
|
+
encryptedNotes: 'notes2',
|
|
140
|
+
encryptedParticipants: ['participant2'],
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
119
144
|
})
|
|
120
145
|
);
|
|
121
146
|
await webex.internal.calendar.syncCalendar({fromDate: 'xx-xx', toDate: 'xx-nn'});
|
|
@@ -123,7 +148,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
123
148
|
method: 'GET',
|
|
124
149
|
service: 'calendar',
|
|
125
150
|
resource: 'calendarEvents',
|
|
126
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
151
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
127
152
|
});
|
|
128
153
|
assert.equal(webex.internal.calendar.getAll().length, 2);
|
|
129
154
|
assert.equal(webex.internal.calendar.getAll()[0].id, 'calendar1');
|
|
@@ -136,10 +161,18 @@ describe('internal-plugin-calendar', () => {
|
|
|
136
161
|
Promise.resolve({
|
|
137
162
|
body: {
|
|
138
163
|
items: [
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
164
|
+
{
|
|
165
|
+
id: 'calendar1',
|
|
166
|
+
encryptedNotes: 'notes1',
|
|
167
|
+
encryptedParticipants: ['participant1'],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: 'calendar2',
|
|
171
|
+
encryptedNotes: 'notes2',
|
|
172
|
+
encryptedParticipants: ['participant2'],
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
},
|
|
143
176
|
})
|
|
144
177
|
);
|
|
145
178
|
const res = await webex.internal.calendar.list({fromDate: 'xx-xx', toDate: 'xx-nn'});
|
|
@@ -149,7 +182,7 @@ describe('internal-plugin-calendar', () => {
|
|
|
149
182
|
method: 'GET',
|
|
150
183
|
service: 'calendar',
|
|
151
184
|
resource: 'calendarEvents',
|
|
152
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
185
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
153
186
|
});
|
|
154
187
|
});
|
|
155
188
|
|
|
@@ -157,31 +190,27 @@ describe('internal-plugin-calendar', () => {
|
|
|
157
190
|
const webexRequestStub = sinon.stub();
|
|
158
191
|
|
|
159
192
|
// calendar list stub
|
|
160
|
-
webexRequestStub
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Promise.resolve({
|
|
167
|
-
body: {
|
|
168
|
-
items: [
|
|
169
|
-
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
170
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
171
|
-
]
|
|
172
|
-
}
|
|
173
|
-
})
|
|
174
|
-
);
|
|
175
|
-
// getNotes stub
|
|
176
|
-
webexRequestStub.withArgs({
|
|
177
|
-
method: 'GET',
|
|
178
|
-
service: 'calendar',
|
|
179
|
-
resource: `calendarEvents/${btoa('calendar1')}/notes`
|
|
180
|
-
}).returns(
|
|
181
|
-
Promise.resolve({
|
|
182
|
-
body: null
|
|
193
|
+
webexRequestStub
|
|
194
|
+
.withArgs({
|
|
195
|
+
method: 'GET',
|
|
196
|
+
service: 'calendar',
|
|
197
|
+
resource: 'calendarEvents',
|
|
198
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
183
199
|
})
|
|
184
|
-
|
|
200
|
+
.returns(
|
|
201
|
+
Promise.resolve({
|
|
202
|
+
body: {
|
|
203
|
+
items: [
|
|
204
|
+
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
205
|
+
{
|
|
206
|
+
id: 'calendar2',
|
|
207
|
+
encryptedNotes: 'notes2',
|
|
208
|
+
encryptedParticipants: ['participant2'],
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
})
|
|
213
|
+
);
|
|
185
214
|
|
|
186
215
|
// Assign webexRequestStub to webex.request
|
|
187
216
|
webex.request = webexRequestStub;
|
|
@@ -190,19 +219,14 @@ describe('internal-plugin-calendar', () => {
|
|
|
190
219
|
|
|
191
220
|
assert.equal(res.length, 2);
|
|
192
221
|
assert.deepEqual(res, [
|
|
193
|
-
{id: 'calendar1',
|
|
194
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
222
|
+
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
223
|
+
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']},
|
|
195
224
|
]);
|
|
196
225
|
assert.calledWith(webex.request, {
|
|
197
226
|
method: 'GET',
|
|
198
227
|
service: 'calendar',
|
|
199
228
|
resource: 'calendarEvents',
|
|
200
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
201
|
-
});
|
|
202
|
-
assert.calledWith(webex.request, {
|
|
203
|
-
method: 'GET',
|
|
204
|
-
service: 'calendar',
|
|
205
|
-
resource: `calendarEvents/${btoa('calendar1')}/notes`
|
|
229
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
206
230
|
});
|
|
207
231
|
});
|
|
208
232
|
|
|
@@ -210,33 +234,27 @@ describe('internal-plugin-calendar', () => {
|
|
|
210
234
|
const webexRequestStub = sinon.stub();
|
|
211
235
|
|
|
212
236
|
// calendar list stub
|
|
213
|
-
webexRequestStub
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Promise.resolve({
|
|
220
|
-
body: {
|
|
221
|
-
items: [
|
|
222
|
-
{id: 'calendar1', encryptedParticipants: ['participant1']},
|
|
223
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
224
|
-
]
|
|
225
|
-
}
|
|
226
|
-
})
|
|
227
|
-
);
|
|
228
|
-
// getNotes stub
|
|
229
|
-
webexRequestStub.withArgs({
|
|
230
|
-
method: 'GET',
|
|
231
|
-
service: 'calendar',
|
|
232
|
-
resource: `calendarEvents/${btoa('calendar1')}/notes`
|
|
233
|
-
}).returns(
|
|
234
|
-
Promise.resolve({
|
|
235
|
-
body: {
|
|
236
|
-
encryptedNotes: 'notes1'
|
|
237
|
-
}
|
|
237
|
+
webexRequestStub
|
|
238
|
+
.withArgs({
|
|
239
|
+
method: 'GET',
|
|
240
|
+
service: 'calendar',
|
|
241
|
+
resource: 'calendarEvents',
|
|
242
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
238
243
|
})
|
|
239
|
-
|
|
244
|
+
.returns(
|
|
245
|
+
Promise.resolve({
|
|
246
|
+
body: {
|
|
247
|
+
items: [
|
|
248
|
+
{id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
|
|
249
|
+
{
|
|
250
|
+
id: 'calendar2',
|
|
251
|
+
encryptedNotes: 'notes2',
|
|
252
|
+
encryptedParticipants: ['participant2'],
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
})
|
|
257
|
+
);
|
|
240
258
|
|
|
241
259
|
// Assign webexRequestStub to webex.request
|
|
242
260
|
webex.request = webexRequestStub;
|
|
@@ -246,18 +264,13 @@ describe('internal-plugin-calendar', () => {
|
|
|
246
264
|
assert.equal(res.length, 2);
|
|
247
265
|
assert.deepEqual(res, [
|
|
248
266
|
{id: 'calendar1', encryptedNotes: 'notes1', encryptedParticipants: ['participant1']},
|
|
249
|
-
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']}
|
|
267
|
+
{id: 'calendar2', encryptedNotes: 'notes2', encryptedParticipants: ['participant2']},
|
|
250
268
|
]);
|
|
251
269
|
assert.calledWith(webex.request, {
|
|
252
270
|
method: 'GET',
|
|
253
271
|
service: 'calendar',
|
|
254
272
|
resource: 'calendarEvents',
|
|
255
|
-
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'}
|
|
256
|
-
});
|
|
257
|
-
assert.calledWith(webex.request, {
|
|
258
|
-
method: 'GET',
|
|
259
|
-
service: 'calendar',
|
|
260
|
-
resource: `calendarEvents/${btoa('calendar1')}/notes`
|
|
273
|
+
qs: {fromDate: 'xx-xx', toDate: 'xx-nn'},
|
|
261
274
|
});
|
|
262
275
|
});
|
|
263
276
|
});
|
|
@@ -269,8 +282,8 @@ describe('internal-plugin-calendar', () => {
|
|
|
269
282
|
webex.request = sinon.stub().returns(
|
|
270
283
|
Promise.resolve({
|
|
271
284
|
body: {
|
|
272
|
-
encryptedNotes: 'notes1'
|
|
273
|
-
}
|
|
285
|
+
encryptedNotes: 'notes1',
|
|
286
|
+
},
|
|
274
287
|
})
|
|
275
288
|
);
|
|
276
289
|
|
|
@@ -280,30 +293,172 @@ describe('internal-plugin-calendar', () => {
|
|
|
280
293
|
assert.calledWith(webex.request, {
|
|
281
294
|
method: 'GET',
|
|
282
295
|
service: 'calendar',
|
|
283
|
-
resource: `calendarEvents/${
|
|
296
|
+
resource: `calendarEvents/${base64.encode(id)}/notes`,
|
|
284
297
|
});
|
|
285
298
|
});
|
|
286
299
|
});
|
|
287
300
|
|
|
288
301
|
describe('#getParticipants()', () => {
|
|
289
|
-
const
|
|
302
|
+
const uri = 'participantsUrl';
|
|
290
303
|
|
|
291
304
|
it('should fetch the meeting participants', async () => {
|
|
292
305
|
webex.request = sinon.stub().returns(
|
|
293
306
|
Promise.resolve({
|
|
294
307
|
body: {
|
|
295
|
-
encryptedParticipants: ['participant1']
|
|
296
|
-
}
|
|
308
|
+
encryptedParticipants: ['participant1'],
|
|
309
|
+
},
|
|
297
310
|
})
|
|
298
311
|
);
|
|
299
312
|
|
|
300
|
-
const res = await webex.internal.calendar.getParticipants(
|
|
313
|
+
const res = await webex.internal.calendar.getParticipants(uri);
|
|
301
314
|
|
|
302
315
|
assert.equal(res.body.encryptedParticipants.length, 1);
|
|
303
316
|
assert.calledWith(webex.request, {
|
|
304
317
|
method: 'GET',
|
|
305
|
-
|
|
306
|
-
|
|
318
|
+
uri,
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
describe('#getNotesByUrl()', () => {
|
|
324
|
+
const uri = 'notesUrl';
|
|
325
|
+
|
|
326
|
+
it('should fetch the meeting notes', async () => {
|
|
327
|
+
webex.request = sinon.stub().returns(
|
|
328
|
+
Promise.resolve({
|
|
329
|
+
body: {
|
|
330
|
+
encryptedParticipants: ['participant1'],
|
|
331
|
+
},
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const res = await webex.internal.calendar.getNotesByUrl(uri);
|
|
336
|
+
|
|
337
|
+
assert.equal(res.body.encryptedParticipants.length, 1);
|
|
338
|
+
assert.calledWith(webex.request, {
|
|
339
|
+
method: 'GET',
|
|
340
|
+
uri,
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
describe("#getSchedulerData()", () => {
|
|
346
|
+
it("should fetch meeting calendar data", async () => {
|
|
347
|
+
const query = {
|
|
348
|
+
siteName: "scheduler01.dmz.webex.com",
|
|
349
|
+
clientMeetingId: "YWJjZGFiY2QtYWJjZC1hYmNkLWFiY2QtMDAwMDAwMDA"
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
webex.request = sinon.stub().resolves({
|
|
353
|
+
body: {
|
|
354
|
+
encryptedSubject: "My Meeting 1",
|
|
355
|
+
schedulerPreferences: {
|
|
356
|
+
uiControlAttributes: {
|
|
357
|
+
displayHostSaveMeetingTemplate: true
|
|
358
|
+
},
|
|
359
|
+
webexOptions: {
|
|
360
|
+
sessionTypeId: 3
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const res = await webex.internal.calendar.getSchedulerData(query);
|
|
367
|
+
|
|
368
|
+
expect(res.body.encryptedSubject).to.equal("My Meeting 1");
|
|
369
|
+
expect(res.body.schedulerPreferences.uiControlAttributes.displayHostSaveMeetingTemplate).to.be.true;
|
|
370
|
+
expect(res.body.schedulerPreferences.webexOptions.sessionTypeId).to.equal(3);
|
|
371
|
+
assert.calledWith(webex.request, {
|
|
372
|
+
method: "GET",
|
|
373
|
+
service: "calendar",
|
|
374
|
+
resource: "schedulerData",
|
|
375
|
+
qs: {
|
|
376
|
+
siteName: query.siteName,
|
|
377
|
+
clientMeetingId: query.clientMeetingId
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
describe("#createCalendarEvent()", () => {
|
|
384
|
+
it("should create an calendar event", async () => {
|
|
385
|
+
const data = {
|
|
386
|
+
encryptionKeyUrl: "kms://kms-us-int.wbx2.com/keys/d1c14fc5-be10-4389-ae83-9521f92fbfd3",
|
|
387
|
+
notes: "This is Agenda",
|
|
388
|
+
subject: "My Meeting 1",
|
|
389
|
+
webexOptions: "{}"
|
|
390
|
+
};
|
|
391
|
+
const query = {};
|
|
392
|
+
|
|
393
|
+
webex.request = sinon.stub().resolves({
|
|
394
|
+
body: {
|
|
395
|
+
meetingId: "abcdabcd-abcd-abcd-abcd-00000000",
|
|
396
|
+
globalMeetingId: "xxxx-xxxx-xxxx-xxxx"
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
const res = await webex.internal.calendar.createCalendarEvent(data);
|
|
401
|
+
|
|
402
|
+
expect(res.body.meetingId).to.equal("abcdabcd-abcd-abcd-abcd-00000000");
|
|
403
|
+
expect(res.body.globalMeetingId).to.equal("xxxx-xxxx-xxxx-xxxx");
|
|
404
|
+
assert.calledWith(webex.request, {
|
|
405
|
+
method: "POST",
|
|
406
|
+
service: "calendar",
|
|
407
|
+
body: data,
|
|
408
|
+
resource: "calendarEvents/sync",
|
|
409
|
+
qs: query
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
describe("#updateCalendarEvent()", () => {
|
|
415
|
+
it("should update a calendar event", async () => {
|
|
416
|
+
const id = "abcdabcd-abcd-abcd-abcd-00000000";
|
|
417
|
+
const data = {
|
|
418
|
+
encryptionKeyUrl: "kms://kms-us-int.wbx2.com/keys/d1c14fc5-be10-4389-ae83-9521f92fbfd3",
|
|
419
|
+
notes: "This is Agenda",
|
|
420
|
+
subject: "My Meeting 1",
|
|
421
|
+
webexOptions: "{}"
|
|
422
|
+
};
|
|
423
|
+
const query = {};
|
|
424
|
+
|
|
425
|
+
webex.request = sinon.stub().resolves({
|
|
426
|
+
body: {
|
|
427
|
+
meetingId: "abcdabcd-abcd-abcd-abcd-00000000",
|
|
428
|
+
globalMeetingId: "xxxx-xxxx-xxxx-xxxx"
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
const res = await webex.internal.calendar.updateCalendarEvent(id, data);
|
|
433
|
+
|
|
434
|
+
expect(res.body.meetingId).to.equal("abcdabcd-abcd-abcd-abcd-00000000");
|
|
435
|
+
expect(res.body.globalMeetingId).to.equal("xxxx-xxxx-xxxx-xxxx");
|
|
436
|
+
assert.calledWith(webex.request, {
|
|
437
|
+
method: "PATCH",
|
|
438
|
+
service: "calendar",
|
|
439
|
+
body: data,
|
|
440
|
+
resource: `calendarEvents/${base64.encode(id)}/sync`,
|
|
441
|
+
qs: query
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
describe("#deleteCalendarEvent()", () => {
|
|
447
|
+
it("should delete a calendar event", async () => {
|
|
448
|
+
const id = "abcdabcd-abcd-abcd-abcd-00000000";
|
|
449
|
+
const query = {};
|
|
450
|
+
|
|
451
|
+
webex.request = sinon.stub().resolves({
|
|
452
|
+
body: {}
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
await webex.internal.calendar.deleteCalendarEvent(id, query);
|
|
456
|
+
|
|
457
|
+
assert.calledWith(webex.request, {
|
|
458
|
+
method: "DELETE",
|
|
459
|
+
service: "calendar",
|
|
460
|
+
resource: `calendarEvents/${base64.encode(id)}/sync`,
|
|
461
|
+
qs: query
|
|
307
462
|
});
|
|
308
463
|
});
|
|
309
464
|
});
|