1 /* tslint:disable:no-unused-expression */
3 import { omit } from 'lodash'
5 import { join } from 'path'
6 import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
26 setAccessTokensToServers,
31 } from '../../../../shared/extra-utils'
33 checkBadCountPagination,
34 checkBadSortPagination,
35 checkBadStartPagination
36 } from '../../../../shared/extra-utils/requests/check-api-params'
37 import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
38 import { VideoPrivacy } from '../../../../shared/models/videos'
39 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
40 import { expect } from 'chai'
41 import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
43 describe('Test users API validators', function () {
44 const path = '/api/v1/users/'
48 let server: ServerInfo
49 let serverWithRegistrationDisabled: ServerInfo
50 let userAccessToken = ''
54 password: 'my super password'
57 // ---------------------------------------------------------------
59 before(async function () {
62 server = await flushAndRunServer(1)
63 serverWithRegistrationDisabled = await flushAndRunServer(2)
65 await setAccessTokensToServers([ server ])
67 const videoQuota = 42000000
70 accessToken: server.accessToken,
71 username: user.username,
72 password: user.password,
73 videoQuota: videoQuota
75 userAccessToken = await userLogin(server, user)
78 const res = await getMyUserInformation(server.url, server.accessToken)
79 channelId = res.body.videoChannels[ 0 ].id
83 const res = await uploadVideo(server.url, server.accessToken, {})
84 videoId = res.body.video.id
88 describe('When listing users', function () {
89 it('Should fail with a bad start pagination', async function () {
90 await checkBadStartPagination(server.url, path, server.accessToken)
93 it('Should fail with a bad count pagination', async function () {
94 await checkBadCountPagination(server.url, path, server.accessToken)
97 it('Should fail with an incorrect sort', async function () {
98 await checkBadSortPagination(server.url, path, server.accessToken)
101 it('Should fail with a non authenticated user', async function () {
102 await makeGetRequest({
105 statusCodeExpected: 401
109 it('Should fail with a non admin user', async function () {
110 await makeGetRequest({
113 token: userAccessToken,
114 statusCodeExpected: 403
119 describe('When adding a new user', function () {
120 const baseCorrectParams = {
122 email: 'test@example.com',
123 password: 'my super password',
127 adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST
130 it('Should fail with a too small username', async function () {
131 const fields = immutableAssign(baseCorrectParams, { username: '' })
133 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
136 it('Should fail with a too long username', async function () {
137 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
139 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
142 it('Should fail with a not lowercase username', async function () {
143 const fields = immutableAssign(baseCorrectParams, { username: 'Toto' })
145 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
148 it('Should fail with an incorrect username', async function () {
149 const fields = immutableAssign(baseCorrectParams, { username: 'my username' })
151 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
154 it('Should fail with a missing email', async function () {
155 const fields = omit(baseCorrectParams, 'email')
157 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
160 it('Should fail with an invalid email', async function () {
161 const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' })
163 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
166 it('Should fail with a too small password', async function () {
167 const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
169 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
172 it('Should fail with a too long password', async function () {
173 const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
175 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
178 it('Should fail with invalid admin flags', async function () {
179 const fields = immutableAssign(baseCorrectParams, { adminFlags: 'toto' })
181 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
184 it('Should fail with an non authenticated user', async function () {
185 await makePostBodyRequest({
188 token: 'super token',
189 fields: baseCorrectParams,
190 statusCodeExpected: 401
194 it('Should fail if we add a user with the same username', async function () {
195 const fields = immutableAssign(baseCorrectParams, { username: 'user1' })
197 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 })
200 it('Should fail if we add a user with the same email', async function () {
201 const fields = immutableAssign(baseCorrectParams, { email: 'user1@example.com' })
203 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 })
206 it('Should fail without a videoQuota', async function () {
207 const fields = omit(baseCorrectParams, 'videoQuota')
209 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
212 it('Should fail without a videoQuotaDaily', async function () {
213 const fields = omit(baseCorrectParams, 'videoQuotaDaily')
215 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
218 it('Should fail with an invalid videoQuota', async function () {
219 const fields = immutableAssign(baseCorrectParams, { videoQuota: -5 })
221 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
224 it('Should fail with an invalid videoQuotaDaily', async function () {
225 const fields = immutableAssign(baseCorrectParams, { videoQuotaDaily: -7 })
227 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
230 it('Should fail without a user role', async function () {
231 const fields = omit(baseCorrectParams, 'role')
233 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
236 it('Should fail with an invalid user role', async function () {
237 const fields = immutableAssign(baseCorrectParams, { role: 88989 })
239 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
242 it('Should fail with a "peertube" username', async function () {
243 const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
245 await makePostBodyRequest({
248 token: server.accessToken,
250 statusCodeExpected: 409
254 it('Should succeed with the correct params', async function () {
255 await makePostBodyRequest({
258 token: server.accessToken,
259 fields: baseCorrectParams,
260 statusCodeExpected: 200
264 it('Should fail with a non admin user', async function () {
267 password: 'my super password'
269 userAccessToken = await userLogin(server, user)
273 email: 'test@example.com',
274 password: 'my super password',
277 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields, statusCodeExpected: 403 })
281 describe('When updating my account', function () {
282 it('Should fail with an invalid email attribute', async function () {
287 await makePutBodyRequest({ url: server.url, path: path + 'me', token: server.accessToken, fields })
290 it('Should fail with a too small password', async function () {
292 currentPassword: 'my super password',
296 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
299 it('Should fail with a too long password', async function () {
301 currentPassword: 'my super password',
302 password: 'super'.repeat(61)
305 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
308 it('Should fail without the current password', async function () {
310 currentPassword: 'my super password',
311 password: 'super'.repeat(61)
314 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
317 it('Should fail with an invalid current password', async function () {
319 currentPassword: 'my super password fail',
320 password: 'super'.repeat(61)
323 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 401 })
326 it('Should fail with an invalid NSFW policy attribute', async function () {
331 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
334 it('Should fail with an invalid autoPlayVideo attribute', async function () {
339 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
342 it('Should fail with an invalid videosHistoryEnabled attribute', async function () {
344 videosHistoryEnabled: -1
347 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
350 it('Should fail with an non authenticated user', async function () {
352 currentPassword: 'my super password',
353 password: 'my super password'
356 await makePutBodyRequest({ url: server.url, path: path + 'me', token: 'super token', fields, statusCodeExpected: 401 })
359 it('Should fail with a too long description', async function () {
361 description: 'super'.repeat(201)
364 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
367 it('Should fail with an invalid videoLanguages attribute', async function () {
370 videoLanguages: 'toto'
373 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
378 for (let i = 0; i < 1000; i++) {
383 videoLanguages: languages
386 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
390 it('Should succeed to change password with the correct params', async function () {
392 currentPassword: 'my super password',
393 password: 'my super password',
395 autoPlayVideo: false,
396 email: 'super_email@example.com'
399 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
402 it('Should succeed without password change with the correct params', async function () {
408 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
412 describe('When updating my avatar', function () {
413 it('Should fail without an incorrect input file', async function () {
416 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
418 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
421 it('Should fail with a big file', async function () {
424 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
426 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
429 it('Should fail with an unauthenticated user', async function () {
432 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
434 await makeUploadRequest({
436 path: path + '/me/avatar/pick',
439 statusCodeExpected: 401
443 it('Should succeed with the correct params', async function () {
446 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
448 await makeUploadRequest({
450 path: path + '/me/avatar/pick',
451 token: server.accessToken,
454 statusCodeExpected: 200
459 describe('When getting a user', function () {
460 before(async function () {
461 const res = await getUsersList(server.url, server.accessToken)
463 userId = res.body.data[1].id
466 it('Should fail with an non authenticated user', async function () {
467 await makeGetRequest({ url: server.url, path: path + userId, token: 'super token', statusCodeExpected: 401 })
470 it('Should fail with a non admin user', async function () {
471 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 403 })
474 it('Should succeed with the correct params', async function () {
475 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: 200 })
479 describe('When updating a user', function () {
481 before(async function () {
482 const res = await getUsersList(server.url, server.accessToken)
484 userId = res.body.data[1].id
485 rootId = res.body.data[2].id
488 it('Should fail with an invalid email attribute', async function () {
493 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
496 it('Should fail with an invalid emailVerified attribute', async function () {
501 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
504 it('Should fail with an invalid videoQuota attribute', async function () {
509 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
512 it('Should fail with an invalid user role attribute', async function () {
517 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
520 it('Should fail with a too small password', async function () {
522 currentPassword: 'my super password',
526 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
529 it('Should fail with a too long password', async function () {
531 currentPassword: 'my super password',
532 password: 'super'.repeat(61)
535 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
538 it('Should fail with an non authenticated user', async function () {
543 await makePutBodyRequest({ url: server.url, path: path + userId, token: 'super token', fields, statusCodeExpected: 401 })
546 it('Should fail when updating root role', async function () {
548 role: UserRole.MODERATOR
551 await makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields })
554 it('Should fail with invalid admin flags', async function () {
555 const fields = { adminFlags: 'toto' }
557 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
560 it('Should succeed with the correct params', async function () {
562 email: 'email@example.com',
568 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 })
572 describe('When getting my information', function () {
573 it('Should fail with a non authenticated user', async function () {
574 await getMyUserInformation(server.url, 'fake_token', 401)
577 it('Should success with the correct parameters', async function () {
578 await getMyUserInformation(server.url, userAccessToken)
582 describe('When getting my video rating', function () {
583 it('Should fail with a non authenticated user', async function () {
584 await getMyUserVideoRating(server.url, 'fake_token', videoId, 401)
587 it('Should fail with an incorrect video uuid', async function () {
588 await getMyUserVideoRating(server.url, server.accessToken, 'blabla', 400)
591 it('Should fail with an unknown video', async function () {
592 await getMyUserVideoRating(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
595 it('Should succeed with the correct parameters', async function () {
596 await getMyUserVideoRating(server.url, server.accessToken, videoId)
600 describe('When retrieving my global ratings', function () {
601 const path = '/api/v1/accounts/user1/ratings'
603 it('Should fail with a bad start pagination', async function () {
604 await checkBadStartPagination(server.url, path, userAccessToken)
607 it('Should fail with a bad count pagination', async function () {
608 await checkBadCountPagination(server.url, path, userAccessToken)
611 it('Should fail with an incorrect sort', async function () {
612 await checkBadSortPagination(server.url, path, userAccessToken)
615 it('Should fail with a unauthenticated user', async function () {
616 await makeGetRequest({ url: server.url, path, statusCodeExpected: 401 })
619 it('Should fail with a another user', async function () {
620 await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 403 })
623 it('Should fail with a bad type', async function () {
624 await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { rating: 'toto ' }, statusCodeExpected: 400 })
627 it('Should succeed with the correct params', async function () {
628 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 200 })
632 describe('When blocking/unblocking/removing user', function () {
633 it('Should fail with an incorrect id', async function () {
634 await removeUser(server.url, 'blabla', server.accessToken, 400)
635 await blockUser(server.url, 'blabla', server.accessToken, 400)
636 await unblockUser(server.url, 'blabla', server.accessToken, 400)
639 it('Should fail with the root user', async function () {
640 await removeUser(server.url, rootId, server.accessToken, 400)
641 await blockUser(server.url, rootId, server.accessToken, 400)
642 await unblockUser(server.url, rootId, server.accessToken, 400)
645 it('Should return 404 with a non existing id', async function () {
646 await removeUser(server.url, 4545454, server.accessToken, 404)
647 await blockUser(server.url, 4545454, server.accessToken, 404)
648 await unblockUser(server.url, 4545454, server.accessToken, 404)
651 it('Should fail with a non admin user', async function () {
652 await removeUser(server.url, userId, userAccessToken, 403)
653 await blockUser(server.url, userId, userAccessToken, 403)
654 await unblockUser(server.url, userId, userAccessToken, 403)
658 describe('When deleting our account', function () {
659 it('Should fail with with the root account', async function () {
660 await deleteMe(server.url, server.accessToken, 400)
664 describe('When registering a new user', function () {
665 const registrationPath = path + '/register'
666 const baseCorrectParams = {
668 displayName: 'super user',
669 email: 'test3@example.com',
670 password: 'my super password'
673 it('Should fail with a too small username', async function () {
674 const fields = immutableAssign(baseCorrectParams, { username: '' })
676 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
679 it('Should fail with a too long username', async function () {
680 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
682 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
685 it('Should fail with an incorrect username', async function () {
686 const fields = immutableAssign(baseCorrectParams, { username: 'my username' })
688 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
691 it('Should fail with a missing email', async function () {
692 const fields = omit(baseCorrectParams, 'email')
694 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
697 it('Should fail with an invalid email', async function () {
698 const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' })
700 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
703 it('Should fail with a too small password', async function () {
704 const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
706 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
709 it('Should fail with a too long password', async function () {
710 const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
712 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
715 it('Should fail if we register a user with the same username', async function () {
716 const fields = immutableAssign(baseCorrectParams, { username: 'root' })
718 await makePostBodyRequest({
720 path: registrationPath,
721 token: server.accessToken,
723 statusCodeExpected: 409
727 it('Should fail with a "peertube" username', async function () {
728 const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
730 await makePostBodyRequest({
732 path: registrationPath,
733 token: server.accessToken,
735 statusCodeExpected: 409
739 it('Should fail if we register a user with the same email', async function () {
740 const fields = immutableAssign(baseCorrectParams, { email: 'admin' + server.internalServerNumber + '@example.com' })
742 await makePostBodyRequest({
744 path: registrationPath,
745 token: server.accessToken,
747 statusCodeExpected: 409
751 it('Should fail with a bad display name', async function () {
752 const fields = immutableAssign(baseCorrectParams, { displayName: 'a'.repeat(150) })
754 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
757 it('Should fail with a bad channel name', async function () {
758 const fields = immutableAssign(baseCorrectParams, { channel: { name: '[]azf', displayName: 'toto' } })
760 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
763 it('Should fail with a bad channel display name', async function () {
764 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'toto', displayName: '' } })
766 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
769 it('Should fail with a channel name that is the same than user username', async function () {
770 const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
771 const fields = immutableAssign(baseCorrectParams, source)
773 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
776 it('Should fail with an existing channel', async function () {
777 const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
778 await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg)
780 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } })
782 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields, statusCodeExpected: 409 })
785 it('Should succeed with the correct params', async function () {
786 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } })
788 await makePostBodyRequest({
790 path: registrationPath,
791 token: server.accessToken,
793 statusCodeExpected: 204
797 it('Should fail on a server with registration disabled', async function () {
800 email: 'test4@example.com',
801 password: 'my super password 4'
804 await makePostBodyRequest({
805 url: serverWithRegistrationDisabled.url,
806 path: registrationPath,
807 token: serverWithRegistrationDisabled.accessToken,
809 statusCodeExpected: 403
814 describe('When registering multiple users on a server with users limit', function () {
815 it('Should fail when after 3 registrations', async function () {
816 await registerUser(server.url, 'user42', 'super password', 403)
820 describe('When having a video quota', function () {
821 it('Should fail with a user having too many videos', async function () {
825 accessToken: server.accessToken,
829 await uploadVideo(server.url, server.accessToken, {}, 403)
832 it('Should fail with a registered user having too many videos', async function () {
837 password: 'my super password'
839 userAccessToken = await userLogin(server, user)
841 const videoAttributes = { fixture: 'video_short2.webm' }
842 await uploadVideo(server.url, userAccessToken, videoAttributes)
843 await uploadVideo(server.url, userAccessToken, videoAttributes)
844 await uploadVideo(server.url, userAccessToken, videoAttributes)
845 await uploadVideo(server.url, userAccessToken, videoAttributes)
846 await uploadVideo(server.url, userAccessToken, videoAttributes)
847 await uploadVideo(server.url, userAccessToken, videoAttributes, 403)
850 it('Should fail to import with HTTP/Torrent/magnet', async function () {
853 const baseAttributes = {
855 privacy: VideoPrivacy.PUBLIC
857 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }))
858 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
859 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' }))
861 await waitJobs([ server ])
863 const res = await getMyVideoImports(server.url, server.accessToken)
865 expect(res.body.total).to.equal(3)
866 const videoImports: VideoImport[] = res.body.data
867 expect(videoImports).to.have.lengthOf(3)
869 for (const videoImport of videoImports) {
870 expect(videoImport.state.id).to.equal(VideoImportState.FAILED)
871 expect(videoImport.error).not.to.be.undefined
872 expect(videoImport.error).to.contain('user video quota is exceeded')
877 describe('When having a daily video quota', function () {
878 it('Should fail with a user having too many videos', async function () {
882 accessToken: server.accessToken,
886 await uploadVideo(server.url, server.accessToken, {}, 403)
890 describe('When having an absolute and daily video quota', function () {
891 it('Should fail if exceeding total quota', async function () {
895 accessToken: server.accessToken,
897 videoQuotaDaily: 1024 * 1024 * 1024
900 await uploadVideo(server.url, server.accessToken, {}, 403)
903 it('Should fail if exceeding daily quota', async function () {
907 accessToken: server.accessToken,
908 videoQuota: 1024 * 1024 * 1024,
912 await uploadVideo(server.url, server.accessToken, {}, 403)
916 describe('When asking a password reset', function () {
917 const path = '/api/v1/users/ask-reset-password'
919 it('Should fail with a missing email', async function () {
922 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
925 it('Should fail with an invalid email', async function () {
926 const fields = { email: 'hello' }
928 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
931 it('Should success with the correct params', async function () {
932 const fields = { email: 'admin@example.com' }
934 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 })
938 describe('When asking for an account verification email', function () {
939 const path = '/api/v1/users/ask-send-verify-email'
941 it('Should fail with a missing email', async function () {
944 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
947 it('Should fail with an invalid email', async function () {
948 const fields = { email: 'hello' }
950 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
953 it('Should succeed with the correct params', async function () {
954 const fields = { email: 'admin@example.com' }
956 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 })
960 after(async function () {
961 await cleanupTests([ server, serverWithRegistrationDisabled ])