aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-11 11:52:34 +0100
committerChocobozzz <me@florianbigard.com>2019-02-11 11:52:34 +0100
commit88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch)
treeb242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /server/tests/api/check-params/users.ts
parent53a94c7cfa8368da4cd248d65df8346905938f0c (diff)
parent9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff)
downloadPeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz
PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst
PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip
Merge branch 'develop' into pr/1217
Diffstat (limited to 'server/tests/api/check-params/users.ts')
-rw-r--r--server/tests/api/check-params/users.ts60
1 files changed, 49 insertions, 11 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index cbfa0c137..13be8b460 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -9,11 +9,15 @@ import {
9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, 9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
10 makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers, 10 makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers,
11 updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser 11 updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser
12} from '../../utils' 12} from '../../../../shared/utils'
13import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 13import {
14import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports' 14 checkBadCountPagination,
15 checkBadSortPagination,
16 checkBadStartPagination
17} from '../../../../shared/utils/requests/check-api-params'
18import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/utils/videos/video-imports'
15import { VideoPrivacy } from '../../../../shared/models/videos' 19import { VideoPrivacy } from '../../../../shared/models/videos'
16import { waitJobs } from '../../utils/server/jobs' 20import { waitJobs } from '../../../../shared/utils/server/jobs'
17import { expect } from 'chai' 21import { expect } from 'chai'
18 22
19describe('Test users API validators', function () { 23describe('Test users API validators', function () {
@@ -99,13 +103,13 @@ describe('Test users API validators', function () {
99 } 103 }
100 104
101 it('Should fail with a too small username', async function () { 105 it('Should fail with a too small username', async function () {
102 const fields = immutableAssign(baseCorrectParams, { username: 'fi' }) 106 const fields = immutableAssign(baseCorrectParams, { username: '' })
103 107
104 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 108 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
105 }) 109 })
106 110
107 it('Should fail with a too long username', async function () { 111 it('Should fail with a too long username', async function () {
108 const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' }) 112 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
109 113
110 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 114 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
111 }) 115 })
@@ -304,6 +308,14 @@ describe('Test users API validators', function () {
304 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) 308 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
305 }) 309 })
306 310
311 it('Should fail with an invalid videosHistoryEnabled attribute', async function () {
312 const fields = {
313 videosHistoryEnabled: -1
314 }
315
316 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
317 })
318
307 it('Should fail with an non authenticated user', async function () { 319 it('Should fail with an non authenticated user', async function () {
308 const fields = { 320 const fields = {
309 currentPassword: 'my super password', 321 currentPassword: 'my super password',
@@ -315,7 +327,7 @@ describe('Test users API validators', function () {
315 327
316 it('Should fail with a too long description', async function () { 328 it('Should fail with a too long description', async function () {
317 const fields = { 329 const fields = {
318 description: 'super'.repeat(60) 330 description: 'super'.repeat(201)
319 } 331 }
320 332
321 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) 333 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
@@ -428,6 +440,14 @@ describe('Test users API validators', function () {
428 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }) 440 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
429 }) 441 })
430 442
443 it('Should fail with an invalid emailVerified attribute', async function () {
444 const fields = {
445 emailVerified: 'yes'
446 }
447
448 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
449 })
450
431 it('Should fail with an invalid videoQuota attribute', async function () { 451 it('Should fail with an invalid videoQuota attribute', async function () {
432 const fields = { 452 const fields = {
433 videoQuota: -90 453 videoQuota: -90
@@ -444,6 +464,24 @@ describe('Test users API validators', function () {
444 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }) 464 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
445 }) 465 })
446 466
467 it('Should fail with a too small password', async function () {
468 const fields = {
469 currentPassword: 'my super password',
470 password: 'bla'
471 }
472
473 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
474 })
475
476 it('Should fail with a too long password', async function () {
477 const fields = {
478 currentPassword: 'my super password',
479 password: 'super'.repeat(61)
480 }
481
482 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
483 })
484
447 it('Should fail with an non authenticated user', async function () { 485 it('Should fail with an non authenticated user', async function () {
448 const fields = { 486 const fields = {
449 videoQuota: 42 487 videoQuota: 42
@@ -463,12 +501,12 @@ describe('Test users API validators', function () {
463 it('Should succeed with the correct params', async function () { 501 it('Should succeed with the correct params', async function () {
464 const fields = { 502 const fields = {
465 email: 'email@example.com', 503 email: 'email@example.com',
504 emailVerified: true,
466 videoQuota: 42, 505 videoQuota: 42,
467 role: UserRole.MODERATOR 506 role: UserRole.USER
468 } 507 }
469 508
470 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 }) 509 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 })
471 userAccessToken = await userLogin(server, user)
472 }) 510 })
473 }) 511 })
474 512
@@ -541,13 +579,13 @@ describe('Test users API validators', function () {
541 } 579 }
542 580
543 it('Should fail with a too small username', async function () { 581 it('Should fail with a too small username', async function () {
544 const fields = immutableAssign(baseCorrectParams, { username: 'ji' }) 582 const fields = immutableAssign(baseCorrectParams, { username: '' })
545 583
546 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 584 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
547 }) 585 })
548 586
549 it('Should fail with a too long username', async function () { 587 it('Should fail with a too long username', async function () {
550 const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' }) 588 const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
551 589
552 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 590 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
553 }) 591 })