]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/check-params/users.ts
add user account email verificiation (#977)
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / users.ts
1 /* tslint:disable:no-unused-expression */
2
3 import { omit } from 'lodash'
4 import 'mocha'
5 import { join } from 'path'
6 import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
7
8 import {
9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
10 makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers,
11 updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser
12 } from '../../utils'
13 import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
14 import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports'
15 import { VideoPrivacy } from '../../../../shared/models/videos'
16 import { waitJobs } from '../../utils/server/jobs'
17 import { expect } from 'chai'
18
19 describe('Test users API validators', function () {
20 const path = '/api/v1/users/'
21 let userId: number
22 let rootId: number
23 let videoId: number
24 let server: ServerInfo
25 let serverWithRegistrationDisabled: ServerInfo
26 let userAccessToken = ''
27 let channelId: number
28 const user = {
29 username: 'user1',
30 password: 'my super password'
31 }
32
33 // ---------------------------------------------------------------
34
35 before(async function () {
36 this.timeout(30000)
37
38 await flushTests()
39
40 server = await runServer(1)
41 serverWithRegistrationDisabled = await runServer(2)
42
43 await setAccessTokensToServers([ server ])
44
45 const videoQuota = 42000000
46 await createUser(server.url, server.accessToken, user.username, user.password, videoQuota)
47 userAccessToken = await userLogin(server, user)
48
49 {
50 const res = await getMyUserInformation(server.url, server.accessToken)
51 channelId = res.body.videoChannels[ 0 ].id
52 }
53
54 {
55 const res = await uploadVideo(server.url, server.accessToken, {})
56 videoId = res.body.video.id
57 }
58 })
59
60 describe('When listing users', function () {
61 it('Should fail with a bad start pagination', async function () {
62 await checkBadStartPagination(server.url, path, server.accessToken)
63 })
64
65 it('Should fail with a bad count pagination', async function () {
66 await checkBadCountPagination(server.url, path, server.accessToken)
67 })
68
69 it('Should fail with an incorrect sort', async function () {
70 await checkBadSortPagination(server.url, path, server.accessToken)
71 })
72
73 it('Should fail with a non authenticated user', async function () {
74 await makeGetRequest({
75 url: server.url,
76 path,
77 statusCodeExpected: 401
78 })
79 })
80
81 it('Should fail with a non admin user', async function () {
82 await makeGetRequest({
83 url: server.url,
84 path,
85 token: userAccessToken,
86 statusCodeExpected: 403
87 })
88 })
89 })
90
91 describe('When adding a new user', function () {
92 const baseCorrectParams = {
93 username: 'user2',
94 email: 'test@example.com',
95 password: 'my super password',
96 videoQuota: -1,
97 videoQuotaDaily: -1,
98 role: UserRole.USER
99 }
100
101 it('Should fail with a too small username', async function () {
102 const fields = immutableAssign(baseCorrectParams, { username: 'fi' })
103
104 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
105 })
106
107 it('Should fail with a too long username', async function () {
108 const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' })
109
110 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
111 })
112
113 it('Should fail with a not lowercase username', async function () {
114 const fields = immutableAssign(baseCorrectParams, { username: 'Toto' })
115
116 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
117 })
118
119 it('Should fail with an incorrect username', async function () {
120 const fields = immutableAssign(baseCorrectParams, { username: 'my username' })
121
122 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
123 })
124
125 it('Should fail with a missing email', async function () {
126 const fields = omit(baseCorrectParams, 'email')
127
128 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
129 })
130
131 it('Should fail with an invalid email', async function () {
132 const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' })
133
134 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
135 })
136
137 it('Should fail with a too small password', async function () {
138 const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
139
140 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
141 })
142
143 it('Should fail with a too long password', async function () {
144 const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
145
146 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
147 })
148
149 it('Should fail with an non authenticated user', async function () {
150 await makePostBodyRequest({
151 url: server.url,
152 path,
153 token: 'super token',
154 fields: baseCorrectParams,
155 statusCodeExpected: 401
156 })
157 })
158
159 it('Should fail if we add a user with the same username', async function () {
160 const fields = immutableAssign(baseCorrectParams, { username: 'user1' })
161
162 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 })
163 })
164
165 it('Should fail if we add a user with the same email', async function () {
166 const fields = immutableAssign(baseCorrectParams, { email: 'user1@example.com' })
167
168 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 })
169 })
170
171 it('Should fail without a videoQuota', async function () {
172 const fields = omit(baseCorrectParams, 'videoQuota')
173
174 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
175 })
176
177 it('Should fail without a videoQuotaDaily', async function () {
178 const fields = omit(baseCorrectParams, 'videoQuotaDaily')
179
180 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
181 })
182
183 it('Should fail with an invalid videoQuota', async function () {
184 const fields = immutableAssign(baseCorrectParams, { videoQuota: -5 })
185
186 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
187 })
188
189 it('Should fail with an invalid videoQuotaDaily', async function () {
190 const fields = immutableAssign(baseCorrectParams, { videoQuotaDaily: -7 })
191
192 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
193 })
194
195 it('Should fail without a user role', async function () {
196 const fields = omit(baseCorrectParams, 'role')
197
198 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
199 })
200
201 it('Should fail with an invalid user role', async function () {
202 const fields = immutableAssign(baseCorrectParams, { role: 88989 })
203
204 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
205 })
206
207 it('Should fail with a "peertube" username', async function () {
208 const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
209
210 await makePostBodyRequest({
211 url: server.url,
212 path,
213 token: server.accessToken,
214 fields,
215 statusCodeExpected: 409
216 })
217 })
218
219 it('Should succeed with the correct params', async function () {
220 await makePostBodyRequest({
221 url: server.url,
222 path,
223 token: server.accessToken,
224 fields: baseCorrectParams,
225 statusCodeExpected: 200
226 })
227 })
228
229 it('Should fail with a non admin user', async function () {
230 const user = {
231 username: 'user1',
232 password: 'my super password'
233 }
234 userAccessToken = await userLogin(server, user)
235
236 const fields = {
237 username: 'user3',
238 email: 'test@example.com',
239 password: 'my super password',
240 videoQuota: 42000000
241 }
242 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields, statusCodeExpected: 403 })
243 })
244 })
245
246 describe('When updating my account', function () {
247 it('Should fail with an invalid email attribute', async function () {
248 const fields = {
249 email: 'blabla'
250 }
251
252 await makePutBodyRequest({ url: server.url, path: path + 'me', token: server.accessToken, fields })
253 })
254
255 it('Should fail with a too small password', async function () {
256 const fields = {
257 password: 'bla'
258 }
259
260 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
261 })
262
263 it('Should fail with a too long password', async function () {
264 const fields = {
265 password: 'super'.repeat(61)
266 }
267
268 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
269 })
270
271 it('Should fail with an invalid NSFW policy attribute', async function () {
272 const fields = {
273 nsfwPolicy: 'hello'
274 }
275
276 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
277 })
278
279 it('Should fail with an invalid autoPlayVideo attribute', async function () {
280 const fields = {
281 autoPlayVideo: -1
282 }
283
284 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
285 })
286
287 it('Should fail with an non authenticated user', async function () {
288 const fields = {
289 password: 'my super password'
290 }
291
292 await makePutBodyRequest({ url: server.url, path: path + 'me', token: 'super token', fields, statusCodeExpected: 401 })
293 })
294
295 it('Should fail with a too long description', async function () {
296 const fields = {
297 description: 'super'.repeat(60)
298 }
299
300 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
301 })
302
303 it('Should succeed with the correct params', async function () {
304 const fields = {
305 password: 'my super password',
306 nsfwPolicy: 'blur',
307 autoPlayVideo: false,
308 email: 'super_email@example.com'
309 }
310
311 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
312 })
313 })
314
315 describe('When updating my avatar', function () {
316 it('Should fail without an incorrect input file', async function () {
317 const fields = {}
318 const attaches = {
319 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
320 }
321 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
322 })
323
324 it('Should fail with a big file', async function () {
325 const fields = {}
326 const attaches = {
327 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
328 }
329 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
330 })
331
332 it('Should fail with an unauthenticated user', async function () {
333 const fields = {}
334 const attaches = {
335 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
336 }
337 await makeUploadRequest({
338 url: server.url,
339 path: path + '/me/avatar/pick',
340 fields,
341 attaches,
342 statusCodeExpected: 401
343 })
344 })
345
346 it('Should succeed with the correct params', async function () {
347 const fields = {}
348 const attaches = {
349 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
350 }
351 await makeUploadRequest({
352 url: server.url,
353 path: path + '/me/avatar/pick',
354 token: server.accessToken,
355 fields,
356 attaches,
357 statusCodeExpected: 200
358 })
359 })
360 })
361
362 describe('When getting a user', function () {
363 before(async function () {
364 const res = await getUsersList(server.url, server.accessToken)
365
366 userId = res.body.data[1].id
367 })
368
369 it('Should fail with an non authenticated user', async function () {
370 await makeGetRequest({ url: server.url, path: path + userId, token: 'super token', statusCodeExpected: 401 })
371 })
372
373 it('Should fail with a non admin user', async function () {
374 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 403 })
375 })
376
377 it('Should succeed with the correct params', async function () {
378 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: 200 })
379 })
380 })
381
382 describe('When updating a user', function () {
383
384 before(async function () {
385 const res = await getUsersList(server.url, server.accessToken)
386
387 userId = res.body.data[1].id
388 rootId = res.body.data[2].id
389 })
390
391 it('Should fail with an invalid email attribute', async function () {
392 const fields = {
393 email: 'blabla'
394 }
395
396 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
397 })
398
399 it('Should fail with an invalid videoQuota attribute', async function () {
400 const fields = {
401 videoQuota: -90
402 }
403
404 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
405 })
406
407 it('Should fail with an invalid user role attribute', async function () {
408 const fields = {
409 role: 54878
410 }
411
412 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
413 })
414
415 it('Should fail with an non authenticated user', async function () {
416 const fields = {
417 videoQuota: 42
418 }
419
420 await makePutBodyRequest({ url: server.url, path: path + userId, token: 'super token', fields, statusCodeExpected: 401 })
421 })
422
423 it('Should fail when updating root role', async function () {
424 const fields = {
425 role: UserRole.MODERATOR
426 }
427
428 await makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields })
429 })
430
431 it('Should succeed with the correct params', async function () {
432 const fields = {
433 email: 'email@example.com',
434 videoQuota: 42,
435 role: UserRole.MODERATOR
436 }
437
438 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 })
439 userAccessToken = await userLogin(server, user)
440 })
441 })
442
443 describe('When getting my information', function () {
444 it('Should fail with a non authenticated user', async function () {
445 await getMyUserInformation(server.url, 'fake_token', 401)
446 })
447
448 it('Should success with the correct parameters', async function () {
449 await getMyUserInformation(server.url, userAccessToken)
450 })
451 })
452
453 describe('When getting my video rating', function () {
454 it('Should fail with a non authenticated user', async function () {
455 await getMyUserVideoRating(server.url, 'fake_token', videoId, 401)
456 })
457
458 it('Should fail with an incorrect video uuid', async function () {
459 await getMyUserVideoRating(server.url, server.accessToken, 'blabla', 400)
460 })
461
462 it('Should fail with an unknown video', async function () {
463 await getMyUserVideoRating(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
464 })
465
466 it('Should succeed with the correct parameters', async function () {
467 await getMyUserVideoRating(server.url, server.accessToken, videoId)
468 })
469 })
470
471 describe('When blocking/unblocking/removing user', function () {
472 it('Should fail with an incorrect id', async function () {
473 await removeUser(server.url, 'blabla', server.accessToken, 400)
474 await blockUser(server.url, 'blabla', server.accessToken, 400)
475 await unblockUser(server.url, 'blabla', server.accessToken, 400)
476 })
477
478 it('Should fail with the root user', async function () {
479 await removeUser(server.url, rootId, server.accessToken, 400)
480 await blockUser(server.url, rootId, server.accessToken, 400)
481 await unblockUser(server.url, rootId, server.accessToken, 400)
482 })
483
484 it('Should return 404 with a non existing id', async function () {
485 await removeUser(server.url, 4545454, server.accessToken, 404)
486 await blockUser(server.url, 4545454, server.accessToken, 404)
487 await unblockUser(server.url, 4545454, server.accessToken, 404)
488 })
489
490 it('Should fail with a non admin user', async function () {
491 await removeUser(server.url, userId, userAccessToken, 403)
492 await blockUser(server.url, userId, userAccessToken, 403)
493 await unblockUser(server.url, userId, userAccessToken, 403)
494 })
495 })
496
497 describe('When deleting our account', function () {
498 it('Should fail with with the root account', async function () {
499 await deleteMe(server.url, server.accessToken, 400)
500 })
501 })
502
503 describe('When register a new user', function () {
504 const registrationPath = path + '/register'
505 const baseCorrectParams = {
506 username: 'user3',
507 email: 'test3@example.com',
508 password: 'my super password'
509 }
510
511 it('Should fail with a too small username', async function () {
512 const fields = immutableAssign(baseCorrectParams, { username: 'ji' })
513
514 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
515 })
516
517 it('Should fail with a too long username', async function () {
518 const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' })
519
520 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
521 })
522
523 it('Should fail with an incorrect username', async function () {
524 const fields = immutableAssign(baseCorrectParams, { username: 'my username' })
525
526 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
527 })
528
529 it('Should fail with a missing email', async function () {
530 const fields = omit(baseCorrectParams, 'email')
531
532 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
533 })
534
535 it('Should fail with an invalid email', async function () {
536 const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' })
537
538 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
539 })
540
541 it('Should fail with a too small password', async function () {
542 const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
543
544 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
545 })
546
547 it('Should fail with a too long password', async function () {
548 const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
549
550 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
551 })
552
553 it('Should fail if we register a user with the same username', async function () {
554 const fields = immutableAssign(baseCorrectParams, { username: 'root' })
555
556 await makePostBodyRequest({
557 url: server.url,
558 path: registrationPath,
559 token: server.accessToken,
560 fields,
561 statusCodeExpected: 409
562 })
563 })
564
565 it('Should fail with a "peertube" username', async function () {
566 const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
567
568 await makePostBodyRequest({
569 url: server.url,
570 path: registrationPath,
571 token: server.accessToken,
572 fields,
573 statusCodeExpected: 409
574 })
575 })
576
577 it('Should fail if we register a user with the same email', async function () {
578 const fields = immutableAssign(baseCorrectParams, { email: 'admin1@example.com' })
579
580 await makePostBodyRequest({
581 url: server.url,
582 path: registrationPath,
583 token: server.accessToken,
584 fields,
585 statusCodeExpected: 409
586 })
587 })
588
589 it('Should succeed with the correct params', async function () {
590 await makePostBodyRequest({
591 url: server.url,
592 path: registrationPath,
593 token: server.accessToken,
594 fields: baseCorrectParams,
595 statusCodeExpected: 204
596 })
597 })
598
599 it('Should fail on a server with registration disabled', async function () {
600 const fields = {
601 username: 'user4',
602 email: 'test4@example.com',
603 password: 'my super password 4'
604 }
605
606 await makePostBodyRequest({
607 url: serverWithRegistrationDisabled.url,
608 path: registrationPath,
609 token: serverWithRegistrationDisabled.accessToken,
610 fields,
611 statusCodeExpected: 403
612 })
613 })
614 })
615
616 describe('When registering multiple users on a server with users limit', function () {
617 it('Should fail when after 3 registrations', async function () {
618 await registerUser(server.url, 'user42', 'super password', 403)
619 })
620 })
621
622 describe('When having a video quota', function () {
623 it('Should fail with a user having too many videos', async function () {
624 await updateUser({
625 url: server.url,
626 userId: rootId,
627 accessToken: server.accessToken,
628 videoQuota: 42
629 })
630
631 await uploadVideo(server.url, server.accessToken, {}, 403)
632 })
633
634 it('Should fail with a registered user having too many videos', async function () {
635 this.timeout(30000)
636
637 const user = {
638 username: 'user3',
639 password: 'my super password'
640 }
641 userAccessToken = await userLogin(server, user)
642
643 const videoAttributes = { fixture: 'video_short2.webm' }
644 await uploadVideo(server.url, userAccessToken, videoAttributes)
645 await uploadVideo(server.url, userAccessToken, videoAttributes)
646 await uploadVideo(server.url, userAccessToken, videoAttributes)
647 await uploadVideo(server.url, userAccessToken, videoAttributes)
648 await uploadVideo(server.url, userAccessToken, videoAttributes)
649 await uploadVideo(server.url, userAccessToken, videoAttributes, 403)
650 })
651
652 it('Should fail to import with HTTP/Torrent/magnet', async function () {
653 this.timeout(120000)
654
655 const baseAttributes = {
656 channelId: 1,
657 privacy: VideoPrivacy.PUBLIC
658 }
659 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }))
660 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
661 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' }))
662
663 await waitJobs([ server ])
664
665 const res = await getMyVideoImports(server.url, server.accessToken)
666
667 expect(res.body.total).to.equal(3)
668 const videoImports: VideoImport[] = res.body.data
669 expect(videoImports).to.have.lengthOf(3)
670
671 for (const videoImport of videoImports) {
672 expect(videoImport.state.id).to.equal(VideoImportState.FAILED)
673 expect(videoImport.error).not.to.be.undefined
674 expect(videoImport.error).to.contain('user video quota is exceeded')
675 }
676 })
677 })
678
679 describe('When having a daily video quota', function () {
680 it('Should fail with a user having too many videos', async function () {
681 await updateUser({
682 url: server.url,
683 userId: rootId,
684 accessToken: server.accessToken,
685 videoQuotaDaily: 42
686 })
687
688 await uploadVideo(server.url, server.accessToken, {}, 403)
689 })
690 })
691
692 describe('When having an absolute and daily video quota', function () {
693 it('Should fail if exceeding total quota', async function () {
694 await updateUser({
695 url: server.url,
696 userId: rootId,
697 accessToken: server.accessToken,
698 videoQuota: 42,
699 videoQuotaDaily: 1024 * 1024 * 1024
700 })
701
702 await uploadVideo(server.url, server.accessToken, {}, 403)
703 })
704
705 it('Should fail if exceeding daily quota', async function () {
706 await updateUser({
707 url: server.url,
708 userId: rootId,
709 accessToken: server.accessToken,
710 videoQuota: 1024 * 1024 * 1024,
711 videoQuotaDaily: 42
712 })
713
714 await uploadVideo(server.url, server.accessToken, {}, 403)
715 })
716 })
717
718 describe('When asking a password reset', function () {
719 const path = '/api/v1/users/ask-reset-password'
720
721 it('Should fail with a missing email', async function () {
722 const fields = {}
723
724 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
725 })
726
727 it('Should fail with an invalid email', async function () {
728 const fields = { email: 'hello' }
729
730 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
731 })
732
733 it('Should success with the correct params', async function () {
734 const fields = { email: 'admin@example.com' }
735
736 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 })
737 })
738 })
739
740 describe('When asking for an account verification email', function () {
741 const path = '/api/v1/users/ask-send-verify-email'
742
743 it('Should fail with a missing email', async function () {
744 const fields = {}
745
746 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
747 })
748
749 it('Should fail with an invalid email', async function () {
750 const fields = { email: 'hello' }
751
752 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
753 })
754
755 it('Should succeed with the correct params', async function () {
756 const fields = { email: 'admin@example.com' }
757
758 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 })
759 })
760 })
761
762 after(async function () {
763 killallServers([ server, serverWithRegistrationDisabled ])
764
765 // Keep the logs if the test failed
766 if (this['ok']) {
767 await flushTests()
768 }
769 })
770 })