@webex/internal-plugin-user 3.0.0-beta.9 → 3.0.0-bnr.2
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/config.js +0 -3
- package/dist/config.js.map +1 -1
- package/dist/index.js +2 -9
- package/dist/index.js.map +1 -1
- package/dist/internal-plugin-user.d.ts +7 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/config.d.ts +17 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/user-uuid-batcher.d.ts +5 -0
- package/dist/types/user-uuid-store.d.ts +34 -0
- package/dist/types/user.d.ts +5 -0
- package/dist/user-uuid-batcher.js +4 -21
- package/dist/user-uuid-batcher.js.map +1 -1
- package/dist/user-uuid-store.js +17 -37
- package/dist/user-uuid-store.js.map +1 -1
- package/dist/user.js +18 -82
- package/dist/user.js.map +1 -1
- package/package.json +8 -8
- package/src/config.js +5 -5
- package/src/index.js +2 -3
- package/src/user-uuid-batcher.js +22 -22
- package/src/user-uuid-store.js +7 -6
- package/src/user.js +90 -81
- package/test/integration/spec/user.js +130 -87
- package/test/unit/spec/user-uuid-batcher.js +22 -19
- package/test/unit/spec/user.js +83 -35
|
@@ -22,7 +22,11 @@ const runs = [
|
|
|
22
22
|
// This line can be ommited until a future pull request is generated to update @ciscospark/test-users-legacy
|
|
23
23
|
// {it: 'with EU user with Federation enabled', EUUser: true, attrs: {config: {credentials: {federation: true}}}},
|
|
24
24
|
{it: 'with US user without Federation enabled', EUUser: false, attrs: {}},
|
|
25
|
-
{
|
|
25
|
+
{
|
|
26
|
+
it: 'with US user with Federation enabled',
|
|
27
|
+
EUUser: false,
|
|
28
|
+
attrs: {config: {credentials: {federation: true}}},
|
|
29
|
+
},
|
|
26
30
|
];
|
|
27
31
|
|
|
28
32
|
runs.forEach((run) => {
|
|
@@ -37,39 +41,44 @@ runs.forEach((run) => {
|
|
|
37
41
|
testUserParm.config = {orgId: process.env.EU_PRIMARY_ORG_ID};
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
before(() =>
|
|
41
|
-
.then((users) => {
|
|
44
|
+
before(() =>
|
|
45
|
+
testUsers.create(testUserParm).then((users) => {
|
|
42
46
|
user1 = users[0];
|
|
43
47
|
user2 = users[1];
|
|
44
48
|
user3 = users[2];
|
|
45
|
-
webex = new WebexCore(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
webex = new WebexCore(
|
|
50
|
+
merge({}, run.attrs, {
|
|
51
|
+
credentials: {
|
|
52
|
+
supertoken: user1.token,
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
);
|
|
50
56
|
assert.isDefined(webex.credentials.supertoken);
|
|
51
57
|
assert.isTrue(webex.canAuthorize);
|
|
52
58
|
assert.isFalse(webex.internal.user.hasPassword);
|
|
53
59
|
|
|
54
60
|
return webex.internal.device.register();
|
|
55
|
-
})
|
|
61
|
+
})
|
|
62
|
+
);
|
|
56
63
|
|
|
57
64
|
describe('#verify()', () => {
|
|
58
65
|
const unauthWebex = new WebexCore(run.attrs);
|
|
59
66
|
|
|
60
|
-
it('registers a new user', () =>
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
it('registers a new user', () =>
|
|
68
|
+
unauthWebex.internal.user
|
|
69
|
+
.verify({email: `Collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`})
|
|
70
|
+
.then((res) => {
|
|
71
|
+
assert.property(res, 'hasPassword');
|
|
72
|
+
assert.property(res, 'verificationEmailTriggered');
|
|
73
|
+
assert.property(res, 'sso');
|
|
74
|
+
assert.isFalse(res.hasPassword);
|
|
75
|
+
assert.isTrue(res.verificationEmailTriggered);
|
|
76
|
+
assert.isFalse(res.sso);
|
|
77
|
+
assert.isFalse(webex.internal.user.hasPassword);
|
|
78
|
+
}));
|
|
70
79
|
|
|
71
|
-
it('verifies an existing user', () =>
|
|
72
|
-
.then((res) => {
|
|
80
|
+
it('verifies an existing user', () =>
|
|
81
|
+
unauthWebex.internal.user.verify({email: user1.email}).then((res) => {
|
|
73
82
|
assert.property(res, 'hasPassword');
|
|
74
83
|
assert.property(res, 'verificationEmailTriggered');
|
|
75
84
|
assert.property(res, 'sso');
|
|
@@ -79,13 +88,16 @@ runs.forEach((run) => {
|
|
|
79
88
|
assert.isTrue(unauthWebex.internal.user.hasPassword);
|
|
80
89
|
}));
|
|
81
90
|
|
|
82
|
-
it('leaves email address validation up to Atlas', () =>
|
|
83
|
-
|
|
91
|
+
it('leaves email address validation up to Atlas', () =>
|
|
92
|
+
assert
|
|
93
|
+
.isRejected(unauthWebex.internal.user.verify({email: 'not an email address'}))
|
|
94
|
+
.then((res) => assert.statusCode(res, 400)));
|
|
84
95
|
});
|
|
85
96
|
|
|
86
97
|
describe('#setPassword()', () => {
|
|
87
|
-
it(
|
|
88
|
-
webex.internal.user
|
|
98
|
+
it("sets the user's password", () =>
|
|
99
|
+
webex.internal.user
|
|
100
|
+
.setPassword({password: 'P@ssword123'})
|
|
89
101
|
.then(() => webex.internal.user.verify({email: user1.email}))
|
|
90
102
|
.then((res) => {
|
|
91
103
|
assert.property(res, 'hasPassword');
|
|
@@ -106,7 +118,8 @@ runs.forEach((run) => {
|
|
|
106
118
|
assert.isUndefined(unauthWebex.credentials.supertoken);
|
|
107
119
|
const email = `collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`;
|
|
108
120
|
|
|
109
|
-
return unauthWebex.internal.user
|
|
121
|
+
return unauthWebex.internal.user
|
|
122
|
+
.verify({email})
|
|
110
123
|
.then((res) => {
|
|
111
124
|
assert.isTrue(res.verificationEmailTriggered);
|
|
112
125
|
assert.property(res, 'verifyEmailURL');
|
|
@@ -141,7 +154,8 @@ runs.forEach((run) => {
|
|
|
141
154
|
assert.isUndefined(unauthWebex.credentials.supertoken);
|
|
142
155
|
const email = `collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`;
|
|
143
156
|
|
|
144
|
-
return unauthWebex.internal.user
|
|
157
|
+
return unauthWebex.internal.user
|
|
158
|
+
.verify({email})
|
|
145
159
|
.then((res) => {
|
|
146
160
|
assert.isTrue(res.verificationEmailTriggered);
|
|
147
161
|
assert.property(res, 'verifyEmailURL');
|
|
@@ -158,7 +172,9 @@ runs.forEach((run) => {
|
|
|
158
172
|
})
|
|
159
173
|
.then(() => unauthWebex.internal.device.register())
|
|
160
174
|
.then(() => unauthWebex.internal.user.get())
|
|
161
|
-
.then((user) =>
|
|
175
|
+
.then((user) =>
|
|
176
|
+
unauthWebex.internal.user.setPassword({email: user.email, password: 'P@ssword123'})
|
|
177
|
+
)
|
|
162
178
|
.then(() => unauthWebex.internal.user.verify({email}))
|
|
163
179
|
.then((res) => {
|
|
164
180
|
assert.property(res, 'hasPassword');
|
|
@@ -180,7 +196,8 @@ runs.forEach((run) => {
|
|
|
180
196
|
// NOTE: need collabctg+*@gmail.com to get oneTimePassword
|
|
181
197
|
const email = `collabctg+webex-js-sdk-${uuid.v4()}@gmail.com`;
|
|
182
198
|
|
|
183
|
-
return unauthWebex.internal.user
|
|
199
|
+
return unauthWebex.internal.user
|
|
200
|
+
.verify({email})
|
|
184
201
|
.then((res) => {
|
|
185
202
|
const {query} = url.parse(res.verifyEmailURL);
|
|
186
203
|
const token = querystring.parse(query).t;
|
|
@@ -189,7 +206,9 @@ runs.forEach((run) => {
|
|
|
189
206
|
})
|
|
190
207
|
.then(() => unauthWebex.internal.device.register())
|
|
191
208
|
.then(() => unauthWebex.internal.user.get())
|
|
192
|
-
.then((user) =>
|
|
209
|
+
.then((user) =>
|
|
210
|
+
unauthWebex.internal.user.setPassword({email: user.email, password: 'P@ssword123'})
|
|
211
|
+
)
|
|
193
212
|
.then(() => unauthWebex.internal.user.verify({email}))
|
|
194
213
|
.then(() => unauthWebex.internal.user.generateOTP({email}))
|
|
195
214
|
.then((res) => {
|
|
@@ -200,7 +219,10 @@ runs.forEach((run) => {
|
|
|
200
219
|
assert.property(res, 'url');
|
|
201
220
|
assert.property(res, 'status');
|
|
202
221
|
|
|
203
|
-
return unauthWebex.internal.user.validateOTP({
|
|
222
|
+
return unauthWebex.internal.user.validateOTP({
|
|
223
|
+
email,
|
|
224
|
+
oneTimePassword: res.oneTimePassword,
|
|
225
|
+
});
|
|
204
226
|
})
|
|
205
227
|
.then((res) => {
|
|
206
228
|
assert.property(res, 'email');
|
|
@@ -210,15 +232,21 @@ runs.forEach((run) => {
|
|
|
210
232
|
assert.equal(res.email, email);
|
|
211
233
|
assert.equal(res.tokenData.token_type, unauthWebex.credentials.supertoken.token_type);
|
|
212
234
|
assert.equal(res.tokenData.expires_in, unauthWebex.credentials.supertoken.expires_in);
|
|
213
|
-
assert.equal(
|
|
214
|
-
|
|
235
|
+
assert.equal(
|
|
236
|
+
res.tokenData.access_token,
|
|
237
|
+
unauthWebex.credentials.supertoken.access_token
|
|
238
|
+
);
|
|
239
|
+
assert.equal(
|
|
240
|
+
res.tokenData.refresh_token_expires_in,
|
|
241
|
+
unauthWebex.credentials.supertoken.refresh_token_expires_in
|
|
242
|
+
);
|
|
215
243
|
});
|
|
216
244
|
});
|
|
217
245
|
});
|
|
218
246
|
|
|
219
247
|
describe('#get()', () => {
|
|
220
|
-
it('gets the current user', () =>
|
|
221
|
-
.then((user) => {
|
|
248
|
+
it('gets the current user', () =>
|
|
249
|
+
webex.internal.user.get().then((user) => {
|
|
222
250
|
assert.equal(user.id, webex.internal.device.userId);
|
|
223
251
|
assert.property(user, 'entitlements');
|
|
224
252
|
assert.property(user, 'email');
|
|
@@ -237,13 +265,17 @@ runs.forEach((run) => {
|
|
|
237
265
|
email = makeEmailAddress();
|
|
238
266
|
});
|
|
239
267
|
|
|
240
|
-
it('maps an email address to a uuid', () =>
|
|
241
|
-
.
|
|
268
|
+
it('maps an email address to a uuid', () =>
|
|
269
|
+
webex.internal.user
|
|
270
|
+
.asUUID(user2, {force: true})
|
|
271
|
+
.then((result) => assert.equal(result, user2.id)));
|
|
242
272
|
|
|
243
|
-
it('maps an email address for a non-existent user to a fake uuid', () =>
|
|
244
|
-
.
|
|
245
|
-
|
|
246
|
-
|
|
273
|
+
it('maps an email address for a non-existent user to a fake uuid', () =>
|
|
274
|
+
webex.internal.user
|
|
275
|
+
.asUUID(email)
|
|
276
|
+
.then((result) => assert.match(result, patterns.uuid))
|
|
277
|
+
.then(() => webex.internal.user.store.getByEmail(email))
|
|
278
|
+
.then((u) => assert.isFalse(u.userExists, 'User does not exist')));
|
|
247
279
|
|
|
248
280
|
describe('with {create: true}', () => {
|
|
249
281
|
let spy;
|
|
@@ -253,37 +285,46 @@ runs.forEach((run) => {
|
|
|
253
285
|
});
|
|
254
286
|
afterEach(() => spy.restore());
|
|
255
287
|
|
|
256
|
-
it('creates a new user', () =>
|
|
257
|
-
.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
288
|
+
it('creates a new user', () =>
|
|
289
|
+
webex.internal.user
|
|
290
|
+
.asUUID(email, {create: true})
|
|
291
|
+
.then((result) => assert.match(result, patterns.uuid))
|
|
292
|
+
.then(() => webex.internal.user.store.getByEmail(email))
|
|
293
|
+
.then((u) => assert.isTrue(u.userExists, 'User exists')));
|
|
294
|
+
|
|
295
|
+
it('does not use a cached value if the previous value was marked as non-existent', () =>
|
|
296
|
+
webex.internal.user
|
|
297
|
+
.asUUID(email)
|
|
298
|
+
.then((result) => assert.match(result, patterns.uuid))
|
|
299
|
+
.then(() => webex.internal.user.store.getByEmail(email))
|
|
300
|
+
.then((u) => assert.isFalse(u.userExists, 'User does not exist'))
|
|
301
|
+
.then(() => webex.internal.user.asUUID(email, {create: true}), patterns.uuid)
|
|
302
|
+
.then(() => webex.internal.user.store.getByEmail(email))
|
|
303
|
+
.then((u) => assert.isTrue(u.userExists, 'User exists'))
|
|
304
|
+
.then(() => assert.calledTwice(spy)));
|
|
305
|
+
|
|
306
|
+
it("does not use a cached value if the previous value's existence is unknown", () =>
|
|
307
|
+
webex.internal.user
|
|
308
|
+
.recordUUID({
|
|
309
|
+
id: user3.id,
|
|
310
|
+
emailAddress: user3.email,
|
|
311
|
+
})
|
|
312
|
+
.then(() => webex.internal.user.store.getByEmail(user3.email))
|
|
313
|
+
.then((user) => assert.isUndefined(user.userExists, "User's existence is unknown"))
|
|
314
|
+
.then(() =>
|
|
315
|
+
webex.internal.user
|
|
316
|
+
.asUUID(user3.email, {create: true})
|
|
317
|
+
.then((result) => assert.equal(result, user3.id))
|
|
318
|
+
)
|
|
319
|
+
.then(() => assert.called(spy))
|
|
320
|
+
.then(() => webex.internal.user.store.getByEmail(user3.email))
|
|
321
|
+
.then((user) => assert.isTrue(user.userExists, 'User exists')));
|
|
281
322
|
});
|
|
282
323
|
});
|
|
283
324
|
|
|
284
325
|
describe('#update()', () => {
|
|
285
|
-
it(
|
|
286
|
-
.then((user) => {
|
|
326
|
+
it("updates a user's name", () =>
|
|
327
|
+
webex.internal.user.update({displayName: 'New Display Name'}).then((user) => {
|
|
287
328
|
assert.equal(user.id, webex.internal.device.userId);
|
|
288
329
|
assert.property(user, 'entitlements');
|
|
289
330
|
assert.property(user, 'email');
|
|
@@ -292,28 +333,28 @@ runs.forEach((run) => {
|
|
|
292
333
|
}));
|
|
293
334
|
});
|
|
294
335
|
describe('#updateName()', () => {
|
|
295
|
-
it(
|
|
296
|
-
.then((user) => {
|
|
336
|
+
it("updates a user's displayName", () =>
|
|
337
|
+
webex.internal.user.updateName({displayName: 'New Name'}).then((user) => {
|
|
297
338
|
assert.equal(user.id, webex.internal.device.userId);
|
|
298
339
|
assert.property(user, 'displayName');
|
|
299
340
|
assert.equal(user.displayName, 'New Name');
|
|
300
341
|
}));
|
|
301
|
-
it(
|
|
302
|
-
.then((user) => {
|
|
342
|
+
it("updates a user's givenName", () =>
|
|
343
|
+
webex.internal.user.updateName({givenName: 'Jack'}).then((user) => {
|
|
303
344
|
assert.equal(user.id, webex.internal.device.userId);
|
|
304
345
|
assert.property(user, 'name');
|
|
305
346
|
assert.property(user.name, 'givenName');
|
|
306
347
|
assert.equal(user.name.givenName, 'Jack');
|
|
307
348
|
}));
|
|
308
|
-
it(
|
|
309
|
-
.then((user) => {
|
|
349
|
+
it("updates a user's familyName", () =>
|
|
350
|
+
webex.internal.user.updateName({familyName: 'Jill'}).then((user) => {
|
|
310
351
|
assert.equal(user.id, webex.internal.device.userId);
|
|
311
352
|
assert.property(user, 'name');
|
|
312
353
|
assert.property(user.name, 'familyName');
|
|
313
354
|
assert.equal(user.name.familyName, 'Jill');
|
|
314
355
|
}));
|
|
315
|
-
it(
|
|
316
|
-
.then((user) => {
|
|
356
|
+
it("updates a user's givenName and familyName", () =>
|
|
357
|
+
webex.internal.user.updateName({givenName: 'T', familyName: 'Rex'}).then((user) => {
|
|
317
358
|
assert.equal(user.id, webex.internal.device.userId);
|
|
318
359
|
assert.property(user, 'name');
|
|
319
360
|
assert.property(user.name, 'givenName');
|
|
@@ -321,17 +362,19 @@ runs.forEach((run) => {
|
|
|
321
362
|
assert.equal(user.name.givenName, 'T');
|
|
322
363
|
assert.equal(user.name.familyName, 'Rex');
|
|
323
364
|
}));
|
|
324
|
-
it(
|
|
325
|
-
.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
365
|
+
it("updates a user's givenName familyName and displayName", () =>
|
|
366
|
+
webex.internal.user
|
|
367
|
+
.updateName({givenName: 'Max', familyName: 'Bob', displayName: 'Max Bob'})
|
|
368
|
+
.then((user) => {
|
|
369
|
+
assert.equal(user.id, webex.internal.device.userId);
|
|
370
|
+
assert.property(user, 'displayName');
|
|
371
|
+
assert.equal(user.displayName, 'Max Bob');
|
|
372
|
+
assert.property(user, 'name');
|
|
373
|
+
assert.property(user.name, 'givenName');
|
|
374
|
+
assert.property(user.name, 'familyName');
|
|
375
|
+
assert.equal(user.name.givenName, 'Max');
|
|
376
|
+
assert.equal(user.name.familyName, 'Bob');
|
|
377
|
+
}));
|
|
335
378
|
});
|
|
336
379
|
});
|
|
337
380
|
});
|
|
@@ -15,8 +15,8 @@ describe('plugin-user', () => {
|
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
webex = new MockWebex({
|
|
17
17
|
children: {
|
|
18
|
-
user: User
|
|
19
|
-
}
|
|
18
|
+
user: User,
|
|
19
|
+
},
|
|
20
20
|
});
|
|
21
21
|
batcher = webex.internal.user.batcher.creator;
|
|
22
22
|
});
|
|
@@ -24,10 +24,10 @@ describe('plugin-user', () => {
|
|
|
24
24
|
describe('#fingerprints', () => {
|
|
25
25
|
const email = 'test@example.com';
|
|
26
26
|
|
|
27
|
-
it(
|
|
28
|
-
.then((res) => assert.deepEqual(res, email)));
|
|
29
|
-
it(
|
|
30
|
-
.then((res) => assert.deepEqual(res, email)));
|
|
27
|
+
it("fingerprintRequest returns 'email'", () =>
|
|
28
|
+
batcher.fingerprintRequest(email).then((res) => assert.deepEqual(res, email)));
|
|
29
|
+
it("fingerprintResponse returns 'email'", () =>
|
|
30
|
+
batcher.fingerprintRequest({email}).then((res) => assert.deepEqual(res, email)));
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
describe('#submitHttpRequest()', () => {
|
|
@@ -38,8 +38,8 @@ describe('plugin-user', () => {
|
|
|
38
38
|
resource: '/users',
|
|
39
39
|
body: email,
|
|
40
40
|
qs: {
|
|
41
|
-
shouldCreateUsers: true
|
|
42
|
-
}
|
|
41
|
+
shouldCreateUsers: true,
|
|
42
|
+
},
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
it('calls webex.request with expected params', () => {
|
|
@@ -47,7 +47,8 @@ describe('plugin-user', () => {
|
|
|
47
47
|
return Promise.resolve(options);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
return batcher
|
|
50
|
+
return batcher
|
|
51
|
+
.submitHttpRequest(mockRequest.body)
|
|
51
52
|
.then((req) => assert.deepEqual(req, mockRequest));
|
|
52
53
|
});
|
|
53
54
|
});
|
|
@@ -64,13 +65,14 @@ describe('plugin-user', () => {
|
|
|
64
65
|
it('handles item success', () => {
|
|
65
66
|
const mockResponse = {
|
|
66
67
|
[email]: {
|
|
67
|
-
id: '11111'
|
|
68
|
-
}
|
|
68
|
+
id: '11111',
|
|
69
|
+
},
|
|
69
70
|
};
|
|
70
71
|
|
|
71
|
-
return batcher
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
return batcher
|
|
73
|
+
.handleHttpSuccess({
|
|
74
|
+
body: mockResponse,
|
|
75
|
+
})
|
|
74
76
|
.then(() => {
|
|
75
77
|
assert.calledWith(successSpy, email, mockResponse[email]);
|
|
76
78
|
});
|
|
@@ -79,13 +81,14 @@ describe('plugin-user', () => {
|
|
|
79
81
|
it('handles item failure', () => {
|
|
80
82
|
const mockResponse = {
|
|
81
83
|
[email]: {
|
|
82
|
-
errorCode: 11111
|
|
83
|
-
}
|
|
84
|
+
errorCode: 11111,
|
|
85
|
+
},
|
|
84
86
|
};
|
|
85
87
|
|
|
86
|
-
return batcher
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
return batcher
|
|
89
|
+
.handleHttpSuccess({
|
|
90
|
+
body: mockResponse,
|
|
91
|
+
})
|
|
89
92
|
.then(() => {
|
|
90
93
|
assert.calledWith(failureSpy, email, mockResponse[email]);
|
|
91
94
|
});
|
package/test/unit/spec/user.js
CHANGED
|
@@ -15,8 +15,8 @@ describe('plugin-user', () => {
|
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
webex = new MockWebex({
|
|
17
17
|
children: {
|
|
18
|
-
user: UserService
|
|
19
|
-
}
|
|
18
|
+
user: UserService,
|
|
19
|
+
},
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
userService = webex.internal.user;
|
|
@@ -24,51 +24,72 @@ describe('plugin-user', () => {
|
|
|
24
24
|
|
|
25
25
|
describe('#activate()', () => {
|
|
26
26
|
it('requires a `verificationToken` or a confirmationCode + user id', () => {
|
|
27
|
-
assert.isRejected(
|
|
27
|
+
assert.isRejected(
|
|
28
|
+
userService.activate(),
|
|
29
|
+
/either options.verificationToken is required or both options.confirmationCode and options.id are required/
|
|
30
|
+
);
|
|
28
31
|
});
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
describe('#asUUID()', () => {
|
|
32
35
|
it('requires a `user`', () => assert.isRejected(userService.asUUID(), /`user` is required/));
|
|
33
36
|
|
|
34
|
-
it('requires a `user` in the array', () =>
|
|
37
|
+
it('requires a `user` in the array', () =>
|
|
38
|
+
assert.isRejected(userService.asUUID(['']), /`user` is required/));
|
|
35
39
|
|
|
36
|
-
it('requires a valid email', () =>
|
|
40
|
+
it('requires a valid email', () =>
|
|
41
|
+
assert.isRejected(
|
|
42
|
+
userService.asUUID('not valid email'),
|
|
43
|
+
/Provided user object does not appear to identify a user/
|
|
44
|
+
));
|
|
37
45
|
|
|
38
46
|
it('resolves id if id is passed', () => {
|
|
39
47
|
const id = uuid.v4();
|
|
40
48
|
|
|
41
|
-
return userService.asUUID(id)
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
});
|
|
49
|
+
return userService.asUUID(id).then((res) => {
|
|
50
|
+
assert.equal(res, id);
|
|
51
|
+
});
|
|
45
52
|
});
|
|
46
53
|
});
|
|
47
54
|
|
|
48
55
|
describe('#recordUUID()', () => {
|
|
49
|
-
it('requires a `user`', () =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
it('requires a `user`', () =>
|
|
57
|
+
assert.isRejected(userService.recordUUID(), /`user` is required/));
|
|
58
|
+
|
|
59
|
+
it('requires an `id`', () =>
|
|
60
|
+
assert.isRejected(userService.recordUUID({}), /`user.id` is required/));
|
|
61
|
+
|
|
62
|
+
it('requires the `id` to be a uuid', () =>
|
|
63
|
+
assert.isRejected(
|
|
64
|
+
userService.recordUUID({
|
|
65
|
+
id: 'not a uuid',
|
|
66
|
+
}),
|
|
67
|
+
/`user.id` must be a uuid/
|
|
68
|
+
));
|
|
69
|
+
|
|
70
|
+
it('requires an `emailAddress`', () =>
|
|
71
|
+
assert.isRejected(
|
|
72
|
+
userService.recordUUID({
|
|
73
|
+
id: uuid.v4(),
|
|
74
|
+
}),
|
|
75
|
+
/`user.emailAddress` is required/
|
|
76
|
+
));
|
|
77
|
+
|
|
78
|
+
it('requires the `emailAddress` to be a uuid', () =>
|
|
79
|
+
assert.isRejected(
|
|
80
|
+
userService.recordUUID({
|
|
81
|
+
id: uuid.v4(),
|
|
82
|
+
emailAddress: 'not an email address',
|
|
83
|
+
}),
|
|
84
|
+
/`user.emailAddress` must be an email address/
|
|
85
|
+
));
|
|
65
86
|
|
|
66
87
|
it('places the user in the userstore', () => {
|
|
67
88
|
const spy = sinon.stub(userService.store, 'add').returns(Promise.resolve());
|
|
68
89
|
|
|
69
90
|
const user = {
|
|
70
91
|
id: uuid.v4(),
|
|
71
|
-
emailAddress: 'test@example.com'
|
|
92
|
+
emailAddress: 'test@example.com',
|
|
72
93
|
};
|
|
73
94
|
|
|
74
95
|
userService.recordUUID(user);
|
|
@@ -78,30 +99,57 @@ describe('plugin-user', () => {
|
|
|
78
99
|
});
|
|
79
100
|
|
|
80
101
|
describe('#generateOTP()', () => {
|
|
81
|
-
it('requires one of `email` or `id`', () =>
|
|
102
|
+
it('requires one of `email` or `id`', () =>
|
|
103
|
+
assert.isRejected(
|
|
104
|
+
userService.generateOTP(),
|
|
105
|
+
/One of `options.email` or `options.id` is required/
|
|
106
|
+
));
|
|
82
107
|
});
|
|
83
108
|
|
|
84
109
|
describe('#validateOTP()', () => {
|
|
85
|
-
it('requires one of `email` or `id` and `oneTimePassword`', () =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
110
|
+
it('requires one of `email` or `id` and `oneTimePassword`', () =>
|
|
111
|
+
assert.isRejected(
|
|
112
|
+
userService.validateOTP(),
|
|
113
|
+
/One of `options.email` or `options.id` and `options.oneTimePassword` are required/
|
|
114
|
+
));
|
|
115
|
+
it('requires one of `email` or `id` even when otp is given', () =>
|
|
116
|
+
assert.isRejected(
|
|
117
|
+
userService.validateOTP({oneTimePassword: '123456'}),
|
|
118
|
+
/One of `options.email` or `options.id` and `options.oneTimePassword` are required/
|
|
119
|
+
));
|
|
120
|
+
it('requires oneTimePassword even when email is given', () =>
|
|
121
|
+
assert.isRejected(
|
|
122
|
+
userService.validateOTP({email: 'example@test.com'}),
|
|
123
|
+
/One of `options.email` or `options.id` and `options.oneTimePassword` are required/
|
|
124
|
+
));
|
|
125
|
+
it('requires oneTimePassword even when id is given', () =>
|
|
126
|
+
assert.isRejected(
|
|
127
|
+
userService.validateOTP({id: 'some-fake-id'}),
|
|
128
|
+
/One of `options.email` or `options.id` and `options.oneTimePassword` are required/
|
|
129
|
+
));
|
|
89
130
|
});
|
|
90
131
|
|
|
91
132
|
describe('#setPassword()', () => {
|
|
92
|
-
it('requires a `password`', () =>
|
|
133
|
+
it('requires a `password`', () =>
|
|
134
|
+
assert.isRejected(userService.setPassword(), /`options.password` is required/));
|
|
93
135
|
});
|
|
94
136
|
|
|
95
137
|
describe('#update()', () => {
|
|
96
|
-
it('requires a `displayName`', () =>
|
|
138
|
+
it('requires a `displayName`', () =>
|
|
139
|
+
assert.isRejected(userService.update(), /`options.displayName` is required/));
|
|
97
140
|
});
|
|
98
141
|
|
|
99
142
|
describe('#updateName()', () => {
|
|
100
|
-
it('requires one of `givenName` `familyName` or `displayName`', () =>
|
|
143
|
+
it('requires one of `givenName` `familyName` or `displayName`', () =>
|
|
144
|
+
assert.isRejected(
|
|
145
|
+
userService.updateName(),
|
|
146
|
+
/One of `givenName` and `familyName` or `displayName` is required/
|
|
147
|
+
));
|
|
101
148
|
});
|
|
102
149
|
|
|
103
150
|
describe('#verify()', () => {
|
|
104
|
-
it('requires an `email` param', () =>
|
|
151
|
+
it('requires an `email` param', () =>
|
|
152
|
+
assert.isRejected(userService.verify(), /`options.email` is required/));
|
|
105
153
|
});
|
|
106
154
|
});
|
|
107
155
|
});
|