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 fail with an invalid theme', async function () {
391 const fields = { theme: 'invalid' }
392 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
395 it('Should fail with an unknown theme', async function () {
396 const fields = { theme: 'peertube-theme-unknown' }
397 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
400 it('Should succeed to change password with the correct params', async function () {
402 currentPassword: 'my super password',
403 password: 'my super password',
405 autoPlayVideo: false,
406 email: 'super_email@example.com',
410 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
413 it('Should succeed without password change with the correct params', async function () {
419 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
423 describe('When updating my avatar', function () {
424 it('Should fail without an incorrect input file', async function () {
427 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
429 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
432 it('Should fail with a big file', async function () {
435 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
437 await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
440 it('Should fail with an unauthenticated user', async function () {
443 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
445 await makeUploadRequest({
447 path: path + '/me/avatar/pick',
450 statusCodeExpected: 401
454 it('Should succeed with the correct params', async function () {
457 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
459 await makeUploadRequest({
461 path: path + '/me/avatar/pick',
462 token: server.accessToken,
465 statusCodeExpected: 200
470 describe('When getting a user', function () {
471 before(async function () {
472 const res = await getUsersList(server.url, server.accessToken)
474 userId = res.body.data[1].id
477 it('Should fail with an non authenticated user', async function () {
478 await makeGetRequest({ url: server.url, path: path + userId, token: 'super token', statusCodeExpected: 401 })
481 it('Should fail with a non admin user', async function () {
482 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 403 })
485 it('Should succeed with the correct params', async function () {
486 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: 200 })
490 describe('When updating a user', function () {
492 before(async function () {
493 const res = await getUsersList(server.url, server.accessToken)
495 userId = res.body.data[1].id
496 rootId = res.body.data[2].id
499 it('Should fail with an invalid email attribute', async function () {
504 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
507 it('Should fail with an invalid emailVerified attribute', async function () {
512 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
515 it('Should fail with an invalid videoQuota attribute', async function () {
520 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
523 it('Should fail with an invalid user role attribute', async function () {
528 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
531 it('Should fail with a too small password', async function () {
533 currentPassword: 'my super password',
537 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
540 it('Should fail with a too long password', async function () {
542 currentPassword: 'my super password',
543 password: 'super'.repeat(61)
546 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
549 it('Should fail with an non authenticated user', async function () {
554 await makePutBodyRequest({ url: server.url, path: path + userId, token: 'super token', fields, statusCodeExpected: 401 })
557 it('Should fail when updating root role', async function () {
559 role: UserRole.MODERATOR
562 await makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields })
565 it('Should fail with invalid admin flags', async function () {
566 const fields = { adminFlags: 'toto' }
568 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
571 it('Should succeed with the correct params', async function () {
573 email: 'email@example.com',
579 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 })
583 describe('When getting my information', function () {
584 it('Should fail with a non authenticated user', async function () {
585 await getMyUserInformation(server.url, 'fake_token', 401)
588 it('Should success with the correct parameters', async function () {
589 await getMyUserInformation(server.url, userAccessToken)
593 describe('When getting my video rating', function () {
594 it('Should fail with a non authenticated user', async function () {
595 await getMyUserVideoRating(server.url, 'fake_token', videoId, 401)
598 it('Should fail with an incorrect video uuid', async function () {
599 await getMyUserVideoRating(server.url, server.accessToken, 'blabla', 400)
602 it('Should fail with an unknown video', async function () {
603 await getMyUserVideoRating(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
606 it('Should succeed with the correct parameters', async function () {
607 await getMyUserVideoRating(server.url, server.accessToken, videoId)
611 describe('When retrieving my global ratings', function () {
612 const path = '/api/v1/accounts/user1/ratings'
614 it('Should fail with a bad start pagination', async function () {
615 await checkBadStartPagination(server.url, path, userAccessToken)
618 it('Should fail with a bad count pagination', async function () {
619 await checkBadCountPagination(server.url, path, userAccessToken)
622 it('Should fail with an incorrect sort', async function () {
623 await checkBadSortPagination(server.url, path, userAccessToken)
626 it('Should fail with a unauthenticated user', async function () {
627 await makeGetRequest({ url: server.url, path, statusCodeExpected: 401 })
630 it('Should fail with a another user', async function () {
631 await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 403 })
634 it('Should fail with a bad type', async function () {
635 await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { rating: 'toto ' }, statusCodeExpected: 400 })
638 it('Should succeed with the correct params', async function () {
639 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 200 })
643 describe('When blocking/unblocking/removing user', function () {
644 it('Should fail with an incorrect id', async function () {
645 await removeUser(server.url, 'blabla', server.accessToken, 400)
646 await blockUser(server.url, 'blabla', server.accessToken, 400)
647 await unblockUser(server.url, 'blabla', server.accessToken, 400)
650 it('Should fail with the root user', async function () {
651 await removeUser(server.url, rootId, server.accessToken, 400)
652 await blockUser(server.url, rootId, server.accessToken, 400)
653 await unblockUser(server.url, rootId, server.accessToken, 400)
656 it('Should return 404 with a non existing id', async function () {
657 await removeUser(server.url, 4545454, server.accessToken, 404)
658 await blockUser(server.url, 4545454, server.accessToken, 404)
659 await unblockUser(server.url, 4545454, server.accessToken, 404)
662 it('Should fail with a non admin user', async function () {
663 await removeUser(server.url, userId, userAccessToken, 403)
664 await blockUser(server.url, userId, userAccessToken, 403)
665 await unblockUser(server.url, userId, userAccessToken, 403)
669 describe('When deleting our account', function () {
670 it('Should fail with with the root account', async function () {
671 await deleteMe(server.url, server.accessToken, 400)
675 describe('When registering a new user', function () {
676 const registrationPath = path + '/register'
677 const baseCorrectParams = {
679 displayName: 'super user',
680 email: 'test3@example.com',
681 password: 'my super password'
684 it('Should fail with a too small username', async function () {
685 const fields = immutableAssign(baseCorrectParams, { username: '' })
687 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
690 it('Should fail with a too long username', async function () {
691 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
693 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
696 it('Should fail with an incorrect username', async function () {
697 const fields = immutableAssign(baseCorrectParams, { username: 'my username' })
699 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
702 it('Should fail with a missing email', async function () {
703 const fields = omit(baseCorrectParams, 'email')
705 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
708 it('Should fail with an invalid email', async function () {
709 const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' })
711 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
714 it('Should fail with a too small password', async function () {
715 const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
717 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
720 it('Should fail with a too long password', async function () {
721 const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
723 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
726 it('Should fail if we register a user with the same username', async function () {
727 const fields = immutableAssign(baseCorrectParams, { username: 'root' })
729 await makePostBodyRequest({
731 path: registrationPath,
732 token: server.accessToken,
734 statusCodeExpected: 409
738 it('Should fail with a "peertube" username', async function () {
739 const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
741 await makePostBodyRequest({
743 path: registrationPath,
744 token: server.accessToken,
746 statusCodeExpected: 409
750 it('Should fail if we register a user with the same email', async function () {
751 const fields = immutableAssign(baseCorrectParams, { email: 'admin' + server.internalServerNumber + '@example.com' })
753 await makePostBodyRequest({
755 path: registrationPath,
756 token: server.accessToken,
758 statusCodeExpected: 409
762 it('Should fail with a bad display name', async function () {
763 const fields = immutableAssign(baseCorrectParams, { displayName: 'a'.repeat(150) })
765 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
768 it('Should fail with a bad channel name', async function () {
769 const fields = immutableAssign(baseCorrectParams, { channel: { name: '[]azf', displayName: 'toto' } })
771 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
774 it('Should fail with a bad channel display name', async function () {
775 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'toto', displayName: '' } })
777 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
780 it('Should fail with a channel name that is the same than user username', async function () {
781 const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
782 const fields = immutableAssign(baseCorrectParams, source)
784 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
787 it('Should fail with an existing channel', async function () {
788 const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
789 await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg)
791 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } })
793 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields, statusCodeExpected: 409 })
796 it('Should succeed with the correct params', async function () {
797 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } })
799 await makePostBodyRequest({
801 path: registrationPath,
802 token: server.accessToken,
804 statusCodeExpected: 204
808 it('Should fail on a server with registration disabled', async function () {
811 email: 'test4@example.com',
812 password: 'my super password 4'
815 await makePostBodyRequest({
816 url: serverWithRegistrationDisabled.url,
817 path: registrationPath,
818 token: serverWithRegistrationDisabled.accessToken,
820 statusCodeExpected: 403
825 describe('When registering multiple users on a server with users limit', function () {
826 it('Should fail when after 3 registrations', async function () {
827 await registerUser(server.url, 'user42', 'super password', 403)
831 describe('When having a video quota', function () {
832 it('Should fail with a user having too many videos', async function () {
836 accessToken: server.accessToken,
840 await uploadVideo(server.url, server.accessToken, {}, 403)
843 it('Should fail with a registered user having too many videos', async function () {
848 password: 'my super password'
850 userAccessToken = await userLogin(server, user)
852 const videoAttributes = { fixture: 'video_short2.webm' }
853 await uploadVideo(server.url, userAccessToken, videoAttributes)
854 await uploadVideo(server.url, userAccessToken, videoAttributes)
855 await uploadVideo(server.url, userAccessToken, videoAttributes)
856 await uploadVideo(server.url, userAccessToken, videoAttributes)
857 await uploadVideo(server.url, userAccessToken, videoAttributes)
858 await uploadVideo(server.url, userAccessToken, videoAttributes, 403)
861 it('Should fail to import with HTTP/Torrent/magnet', async function () {
864 const baseAttributes = {
866 privacy: VideoPrivacy.PUBLIC
868 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() }))
869 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
870 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' }))
872 await waitJobs([ server ])
874 const res = await getMyVideoImports(server.url, server.accessToken)
876 expect(res.body.total).to.equal(3)
877 const videoImports: VideoImport[] = res.body.data
878 expect(videoImports).to.have.lengthOf(3)
880 for (const videoImport of videoImports) {
881 expect(videoImport.state.id).to.equal(VideoImportState.FAILED)
882 expect(videoImport.error).not.to.be.undefined
883 expect(videoImport.error).to.contain('user video quota is exceeded')
888 describe('When having a daily video quota', function () {
889 it('Should fail with a user having too many videos', async function () {
893 accessToken: server.accessToken,
897 await uploadVideo(server.url, server.accessToken, {}, 403)
901 describe('When having an absolute and daily video quota', function () {
902 it('Should fail if exceeding total quota', async function () {
906 accessToken: server.accessToken,
908 videoQuotaDaily: 1024 * 1024 * 1024
911 await uploadVideo(server.url, server.accessToken, {}, 403)
914 it('Should fail if exceeding daily quota', async function () {
918 accessToken: server.accessToken,
919 videoQuota: 1024 * 1024 * 1024,
923 await uploadVideo(server.url, server.accessToken, {}, 403)
927 describe('When asking a password reset', function () {
928 const path = '/api/v1/users/ask-reset-password'
930 it('Should fail with a missing email', async function () {
933 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
936 it('Should fail with an invalid email', async function () {
937 const fields = { email: 'hello' }
939 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
942 it('Should success with the correct params', async function () {
943 const fields = { email: 'admin@example.com' }
945 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 })
949 describe('When asking for an account verification email', function () {
950 const path = '/api/v1/users/ask-send-verify-email'
952 it('Should fail with a missing email', async function () {
955 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
958 it('Should fail with an invalid email', async function () {
959 const fields = { email: 'hello' }
961 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
964 it('Should succeed with the correct params', async function () {
965 const fields = { email: 'admin@example.com' }
967 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 })
971 after(async function () {
972 await cleanupTests([ server, serverWithRegistrationDisabled ])