aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/users.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/tests/api/check-params/users.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/tests/api/check-params/users.ts')
-rw-r--r--server/tests/api/check-params/users.ts210
1 files changed, 144 insertions, 66 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index da7dc9704..21ace36aa 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -43,6 +43,7 @@ import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
43import { getGoodVideoUrl, getMagnetURI, getMyVideoImports, importVideo } from '../../../../shared/extra-utils/videos/video-imports' 43import { getGoodVideoUrl, getMagnetURI, getMyVideoImports, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
44import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' 44import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
45import { VideoPrivacy } from '../../../../shared/models/videos' 45import { VideoPrivacy } from '../../../../shared/models/videos'
46import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
46 47
47describe('Test users API validators', function () { 48describe('Test users API validators', function () {
48 const path = '/api/v1/users/' 49 const path = '/api/v1/users/'
@@ -160,7 +161,7 @@ describe('Test users API validators', function () {
160 await makeGetRequest({ 161 await makeGetRequest({
161 url: server.url, 162 url: server.url,
162 path, 163 path,
163 statusCodeExpected: 401 164 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
164 }) 165 })
165 }) 166 })
166 167
@@ -169,7 +170,7 @@ describe('Test users API validators', function () {
169 url: server.url, 170 url: server.url,
170 path, 171 path,
171 token: userAccessToken, 172 token: userAccessToken,
172 statusCodeExpected: 403 173 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
173 }) 174 })
174 }) 175 })
175 }) 176 })
@@ -263,7 +264,7 @@ describe('Test users API validators', function () {
263 path: path, 264 path: path,
264 token: server.accessToken, 265 token: server.accessToken,
265 fields, 266 fields,
266 statusCodeExpected: 200 267 statusCodeExpected: HttpStatusCode.OK_200
267 }) 268 })
268 }) 269 })
269 270
@@ -279,20 +280,32 @@ describe('Test users API validators', function () {
279 path, 280 path,
280 token: 'super token', 281 token: 'super token',
281 fields: baseCorrectParams, 282 fields: baseCorrectParams,
282 statusCodeExpected: 401 283 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
283 }) 284 })
284 }) 285 })
285 286
286 it('Should fail if we add a user with the same username', async function () { 287 it('Should fail if we add a user with the same username', async function () {
287 const fields = immutableAssign(baseCorrectParams, { username: 'user1' }) 288 const fields = immutableAssign(baseCorrectParams, { username: 'user1' })
288 289
289 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 }) 290 await makePostBodyRequest({
291 url: server.url,
292 path,
293 token: server.accessToken,
294 fields,
295 statusCodeExpected: HttpStatusCode.CONFLICT_409
296 })
290 }) 297 })
291 298
292 it('Should fail if we add a user with the same email', async function () { 299 it('Should fail if we add a user with the same email', async function () {
293 const fields = immutableAssign(baseCorrectParams, { email: 'user1@example.com' }) 300 const fields = immutableAssign(baseCorrectParams, { email: 'user1@example.com' })
294 301
295 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 }) 302 await makePostBodyRequest({
303 url: server.url,
304 path,
305 token: server.accessToken,
306 fields,
307 statusCodeExpected: HttpStatusCode.CONFLICT_409
308 })
296 }) 309 })
297 310
298 it('Should fail without a videoQuota', async function () { 311 it('Should fail without a videoQuota', async function () {
@@ -339,7 +352,7 @@ describe('Test users API validators', function () {
339 path, 352 path,
340 token: server.accessToken, 353 token: server.accessToken,
341 fields, 354 fields,
342 statusCodeExpected: 409 355 statusCodeExpected: HttpStatusCode.CONFLICT_409
343 }) 356 })
344 }) 357 })
345 358
@@ -352,7 +365,7 @@ describe('Test users API validators', function () {
352 path, 365 path,
353 token: moderatorAccessToken, 366 token: moderatorAccessToken,
354 fields, 367 fields,
355 statusCodeExpected: 403 368 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
356 }) 369 })
357 } 370 }
358 }) 371 })
@@ -365,7 +378,7 @@ describe('Test users API validators', function () {
365 path, 378 path,
366 token: moderatorAccessToken, 379 token: moderatorAccessToken,
367 fields, 380 fields,
368 statusCodeExpected: 200 381 statusCodeExpected: HttpStatusCode.OK_200
369 }) 382 })
370 }) 383 })
371 384
@@ -375,7 +388,7 @@ describe('Test users API validators', function () {
375 path, 388 path,
376 token: server.accessToken, 389 token: server.accessToken,
377 fields: baseCorrectParams, 390 fields: baseCorrectParams,
378 statusCodeExpected: 200 391 statusCodeExpected: HttpStatusCode.OK_200
379 }) 392 })
380 }) 393 })
381 394
@@ -392,7 +405,7 @@ describe('Test users API validators', function () {
392 password: 'my super password', 405 password: 'my super password',
393 videoQuota: 42000000 406 videoQuota: 42000000
394 } 407 }
395 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields, statusCodeExpected: 403 }) 408 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
396 }) 409 })
397 }) 410 })
398 411
@@ -438,7 +451,13 @@ describe('Test users API validators', function () {
438 password: 'super'.repeat(61) 451 password: 'super'.repeat(61)
439 } 452 }
440 453
441 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 401 }) 454 await makePutBodyRequest({
455 url: server.url,
456 path: path + 'me',
457 token: userAccessToken,
458 fields,
459 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
460 })
442 }) 461 })
443 462
444 it('Should fail with an invalid NSFW policy attribute', async function () { 463 it('Should fail with an invalid NSFW policy attribute', async function () {
@@ -479,7 +498,13 @@ describe('Test users API validators', function () {
479 password: 'my super password' 498 password: 'my super password'
480 } 499 }
481 500
482 await makePutBodyRequest({ url: server.url, path: path + 'me', token: 'super token', fields, statusCodeExpected: 401 }) 501 await makePutBodyRequest({
502 url: server.url,
503 path: path + 'me',
504 token: 'super token',
505 fields,
506 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
507 })
483 }) 508 })
484 509
485 it('Should fail with a too long description', async function () { 510 it('Should fail with a too long description', async function () {
@@ -551,7 +576,13 @@ describe('Test users API validators', function () {
551 noWelcomeModal: true 576 noWelcomeModal: true
552 } 577 }
553 578
554 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) 579 await makePutBodyRequest({
580 url: server.url,
581 path: path + 'me',
582 token: userAccessToken,
583 fields,
584 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
585 })
555 }) 586 })
556 587
557 it('Should succeed without password change with the correct params', async function () { 588 it('Should succeed without password change with the correct params', async function () {
@@ -560,7 +591,13 @@ describe('Test users API validators', function () {
560 autoPlayVideo: false 591 autoPlayVideo: false
561 } 592 }
562 593
563 await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) 594 await makePutBodyRequest({
595 url: server.url,
596 path: path + 'me',
597 token: userAccessToken,
598 fields,
599 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
600 })
564 }) 601 })
565 }) 602 })
566 603
@@ -591,7 +628,7 @@ describe('Test users API validators', function () {
591 path: path + '/me/avatar/pick', 628 path: path + '/me/avatar/pick',
592 fields, 629 fields,
593 attaches, 630 attaches,
594 statusCodeExpected: 401 631 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
595 }) 632 })
596 }) 633 })
597 634
@@ -606,7 +643,7 @@ describe('Test users API validators', function () {
606 token: server.accessToken, 643 token: server.accessToken,
607 fields, 644 fields,
608 attaches, 645 attaches,
609 statusCodeExpected: 200 646 statusCodeExpected: HttpStatusCode.OK_200
610 }) 647 })
611 }) 648 })
612 }) 649 })
@@ -614,11 +651,11 @@ describe('Test users API validators', function () {
614 describe('When managing my scoped tokens', function () { 651 describe('When managing my scoped tokens', function () {
615 652
616 it('Should fail to get my scoped tokens with an non authenticated user', async function () { 653 it('Should fail to get my scoped tokens with an non authenticated user', async function () {
617 await getUserScopedTokens(server.url, null, 401) 654 await getUserScopedTokens(server.url, null, HttpStatusCode.UNAUTHORIZED_401)
618 }) 655 })
619 656
620 it('Should fail to get my scoped tokens with a bad token', async function () { 657 it('Should fail to get my scoped tokens with a bad token', async function () {
621 await getUserScopedTokens(server.url, 'bad', 401) 658 await getUserScopedTokens(server.url, 'bad', HttpStatusCode.UNAUTHORIZED_401)
622 659
623 }) 660 })
624 661
@@ -627,11 +664,11 @@ describe('Test users API validators', function () {
627 }) 664 })
628 665
629 it('Should fail to renew my scoped tokens with an non authenticated user', async function () { 666 it('Should fail to renew my scoped tokens with an non authenticated user', async function () {
630 await renewUserScopedTokens(server.url, null, 401) 667 await renewUserScopedTokens(server.url, null, HttpStatusCode.UNAUTHORIZED_401)
631 }) 668 })
632 669
633 it('Should fail to renew my scoped tokens with a bad token', async function () { 670 it('Should fail to renew my scoped tokens with a bad token', async function () {
634 await renewUserScopedTokens(server.url, 'bad', 401) 671 await renewUserScopedTokens(server.url, 'bad', HttpStatusCode.UNAUTHORIZED_401)
635 }) 672 })
636 673
637 it('Should succeed to renew my scoped tokens', async function () { 674 it('Should succeed to renew my scoped tokens', async function () {
@@ -642,15 +679,20 @@ describe('Test users API validators', function () {
642 describe('When getting a user', function () { 679 describe('When getting a user', function () {
643 680
644 it('Should fail with an non authenticated user', async function () { 681 it('Should fail with an non authenticated user', async function () {
645 await makeGetRequest({ url: server.url, path: path + userId, token: 'super token', statusCodeExpected: 401 }) 682 await makeGetRequest({
683 url: server.url,
684 path: path + userId,
685 token: 'super token',
686 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
687 })
646 }) 688 })
647 689
648 it('Should fail with a non admin user', async function () { 690 it('Should fail with a non admin user', async function () {
649 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 403 }) 691 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
650 }) 692 })
651 693
652 it('Should succeed with the correct params', async function () { 694 it('Should succeed with the correct params', async function () {
653 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: 200 }) 695 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: HttpStatusCode.OK_200 })
654 }) 696 })
655 }) 697 })
656 698
@@ -711,7 +753,13 @@ describe('Test users API validators', function () {
711 videoQuota: 42 753 videoQuota: 42
712 } 754 }
713 755
714 await makePutBodyRequest({ url: server.url, path: path + userId, token: 'super token', fields, statusCodeExpected: 401 }) 756 await makePutBodyRequest({
757 url: server.url,
758 path: path + userId,
759 token: 'super token',
760 fields,
761 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
762 })
715 }) 763 })
716 764
717 it('Should fail when updating root role', async function () { 765 it('Should fail when updating root role', async function () {
@@ -738,7 +786,7 @@ describe('Test users API validators', function () {
738 path: path + moderatorId, 786 path: path + moderatorId,
739 token: moderatorAccessToken, 787 token: moderatorAccessToken,
740 fields, 788 fields,
741 statusCodeExpected: 403 789 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
742 }) 790 })
743 }) 791 })
744 792
@@ -752,7 +800,7 @@ describe('Test users API validators', function () {
752 path: path + userId, 800 path: path + userId,
753 token: moderatorAccessToken, 801 token: moderatorAccessToken,
754 fields, 802 fields,
755 statusCodeExpected: 204 803 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
756 }) 804 })
757 }) 805 })
758 806
@@ -764,13 +812,19 @@ describe('Test users API validators', function () {
764 role: UserRole.USER 812 role: UserRole.USER
765 } 813 }
766 814
767 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 }) 815 await makePutBodyRequest({
816 url: server.url,
817 path: path + userId,
818 token: server.accessToken,
819 fields,
820 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
821 })
768 }) 822 })
769 }) 823 })
770 824
771 describe('When getting my information', function () { 825 describe('When getting my information', function () {
772 it('Should fail with a non authenticated user', async function () { 826 it('Should fail with a non authenticated user', async function () {
773 await getMyUserInformation(server.url, 'fake_token', 401) 827 await getMyUserInformation(server.url, 'fake_token', HttpStatusCode.UNAUTHORIZED_401)
774 }) 828 })
775 829
776 it('Should success with the correct parameters', async function () { 830 it('Should success with the correct parameters', async function () {
@@ -780,15 +834,15 @@ describe('Test users API validators', function () {
780 834
781 describe('When getting my video rating', function () { 835 describe('When getting my video rating', function () {
782 it('Should fail with a non authenticated user', async function () { 836 it('Should fail with a non authenticated user', async function () {
783 await getMyUserVideoRating(server.url, 'fake_token', videoId, 401) 837 await getMyUserVideoRating(server.url, 'fake_token', videoId, HttpStatusCode.UNAUTHORIZED_401)
784 }) 838 })
785 839
786 it('Should fail with an incorrect video uuid', async function () { 840 it('Should fail with an incorrect video uuid', async function () {
787 await getMyUserVideoRating(server.url, server.accessToken, 'blabla', 400) 841 await getMyUserVideoRating(server.url, server.accessToken, 'blabla', HttpStatusCode.BAD_REQUEST_400)
788 }) 842 })
789 843
790 it('Should fail with an unknown video', async function () { 844 it('Should fail with an unknown video', async function () {
791 await getMyUserVideoRating(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404) 845 await getMyUserVideoRating(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404)
792 }) 846 })
793 847
794 it('Should succeed with the correct parameters', async function () { 848 it('Should succeed with the correct parameters', async function () {
@@ -812,51 +866,57 @@ describe('Test users API validators', function () {
812 }) 866 })
813 867
814 it('Should fail with a unauthenticated user', async function () { 868 it('Should fail with a unauthenticated user', async function () {
815 await makeGetRequest({ url: server.url, path, statusCodeExpected: 401 }) 869 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
816 }) 870 })
817 871
818 it('Should fail with a another user', async function () { 872 it('Should fail with a another user', async function () {
819 await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 403 }) 873 await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
820 }) 874 })
821 875
822 it('Should fail with a bad type', async function () { 876 it('Should fail with a bad type', async function () {
823 await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { rating: 'toto ' }, statusCodeExpected: 400 }) 877 await makeGetRequest({
878 url: server.url,
879 path,
880 token: userAccessToken,
881 query: { rating: 'toto ' },
882 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
883 })
824 }) 884 })
825 885
826 it('Should succeed with the correct params', async function () { 886 it('Should succeed with the correct params', async function () {
827 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 200 }) 887 await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.OK_200 })
828 }) 888 })
829 }) 889 })
830 890
831 describe('When blocking/unblocking/removing user', function () { 891 describe('When blocking/unblocking/removing user', function () {
832 it('Should fail with an incorrect id', async function () { 892 it('Should fail with an incorrect id', async function () {
833 await removeUser(server.url, 'blabla', server.accessToken, 400) 893 await removeUser(server.url, 'blabla', server.accessToken, HttpStatusCode.BAD_REQUEST_400)
834 await blockUser(server.url, 'blabla', server.accessToken, 400) 894 await blockUser(server.url, 'blabla', server.accessToken, HttpStatusCode.BAD_REQUEST_400)
835 await unblockUser(server.url, 'blabla', server.accessToken, 400) 895 await unblockUser(server.url, 'blabla', server.accessToken, HttpStatusCode.BAD_REQUEST_400)
836 }) 896 })
837 897
838 it('Should fail with the root user', async function () { 898 it('Should fail with the root user', async function () {
839 await removeUser(server.url, rootId, server.accessToken, 400) 899 await removeUser(server.url, rootId, server.accessToken, HttpStatusCode.BAD_REQUEST_400)
840 await blockUser(server.url, rootId, server.accessToken, 400) 900 await blockUser(server.url, rootId, server.accessToken, HttpStatusCode.BAD_REQUEST_400)
841 await unblockUser(server.url, rootId, server.accessToken, 400) 901 await unblockUser(server.url, rootId, server.accessToken, HttpStatusCode.BAD_REQUEST_400)
842 }) 902 })
843 903
844 it('Should return 404 with a non existing id', async function () { 904 it('Should return 404 with a non existing id', async function () {
845 await removeUser(server.url, 4545454, server.accessToken, 404) 905 await removeUser(server.url, 4545454, server.accessToken, HttpStatusCode.NOT_FOUND_404)
846 await blockUser(server.url, 4545454, server.accessToken, 404) 906 await blockUser(server.url, 4545454, server.accessToken, HttpStatusCode.NOT_FOUND_404)
847 await unblockUser(server.url, 4545454, server.accessToken, 404) 907 await unblockUser(server.url, 4545454, server.accessToken, HttpStatusCode.NOT_FOUND_404)
848 }) 908 })
849 909
850 it('Should fail with a non admin user', async function () { 910 it('Should fail with a non admin user', async function () {
851 await removeUser(server.url, userId, userAccessToken, 403) 911 await removeUser(server.url, userId, userAccessToken, HttpStatusCode.FORBIDDEN_403)
852 await blockUser(server.url, userId, userAccessToken, 403) 912 await blockUser(server.url, userId, userAccessToken, HttpStatusCode.FORBIDDEN_403)
853 await unblockUser(server.url, userId, userAccessToken, 403) 913 await unblockUser(server.url, userId, userAccessToken, HttpStatusCode.FORBIDDEN_403)
854 }) 914 })
855 915
856 it('Should fail on a moderator with a moderator', async function () { 916 it('Should fail on a moderator with a moderator', async function () {
857 await removeUser(server.url, moderatorId, moderatorAccessToken, 403) 917 await removeUser(server.url, moderatorId, moderatorAccessToken, HttpStatusCode.FORBIDDEN_403)
858 await blockUser(server.url, moderatorId, moderatorAccessToken, 403) 918 await blockUser(server.url, moderatorId, moderatorAccessToken, HttpStatusCode.FORBIDDEN_403)
859 await unblockUser(server.url, moderatorId, moderatorAccessToken, 403) 919 await unblockUser(server.url, moderatorId, moderatorAccessToken, HttpStatusCode.FORBIDDEN_403)
860 }) 920 })
861 921
862 it('Should succeed on a user with a moderator', async function () { 922 it('Should succeed on a user with a moderator', async function () {
@@ -867,7 +927,7 @@ describe('Test users API validators', function () {
867 927
868 describe('When deleting our account', function () { 928 describe('When deleting our account', function () {
869 it('Should fail with with the root account', async function () { 929 it('Should fail with with the root account', async function () {
870 await deleteMe(server.url, server.accessToken, 400) 930 await deleteMe(server.url, server.accessToken, HttpStatusCode.BAD_REQUEST_400)
871 }) 931 })
872 }) 932 })
873 933
@@ -930,7 +990,7 @@ describe('Test users API validators', function () {
930 path: registrationPath, 990 path: registrationPath,
931 token: server.accessToken, 991 token: server.accessToken,
932 fields, 992 fields,
933 statusCodeExpected: 409 993 statusCodeExpected: HttpStatusCode.CONFLICT_409
934 }) 994 })
935 }) 995 })
936 996
@@ -942,7 +1002,7 @@ describe('Test users API validators', function () {
942 path: registrationPath, 1002 path: registrationPath,
943 token: server.accessToken, 1003 token: server.accessToken,
944 fields, 1004 fields,
945 statusCodeExpected: 409 1005 statusCodeExpected: HttpStatusCode.CONFLICT_409
946 }) 1006 })
947 }) 1007 })
948 1008
@@ -954,7 +1014,7 @@ describe('Test users API validators', function () {
954 path: registrationPath, 1014 path: registrationPath,
955 token: server.accessToken, 1015 token: server.accessToken,
956 fields, 1016 fields,
957 statusCodeExpected: 409 1017 statusCodeExpected: HttpStatusCode.CONFLICT_409
958 }) 1018 })
959 }) 1019 })
960 1020
@@ -989,7 +1049,13 @@ describe('Test users API validators', function () {
989 1049
990 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } }) 1050 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } })
991 1051
992 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields, statusCodeExpected: 409 }) 1052 await makePostBodyRequest({
1053 url: server.url,
1054 path: registrationPath,
1055 token: server.accessToken,
1056 fields,
1057 statusCodeExpected: HttpStatusCode.CONFLICT_409
1058 })
993 }) 1059 })
994 1060
995 it('Should succeed with the correct params', async function () { 1061 it('Should succeed with the correct params', async function () {
@@ -1000,7 +1066,7 @@ describe('Test users API validators', function () {
1000 path: registrationPath, 1066 path: registrationPath,
1001 token: server.accessToken, 1067 token: server.accessToken,
1002 fields: fields, 1068 fields: fields,
1003 statusCodeExpected: 204 1069 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
1004 }) 1070 })
1005 }) 1071 })
1006 1072
@@ -1016,14 +1082,14 @@ describe('Test users API validators', function () {
1016 path: registrationPath, 1082 path: registrationPath,
1017 token: serverWithRegistrationDisabled.accessToken, 1083 token: serverWithRegistrationDisabled.accessToken,
1018 fields, 1084 fields,
1019 statusCodeExpected: 403 1085 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
1020 }) 1086 })
1021 }) 1087 })
1022 }) 1088 })
1023 1089
1024 describe('When registering multiple users on a server with users limit', function () { 1090 describe('When registering multiple users on a server with users limit', function () {
1025 it('Should fail when after 3 registrations', async function () { 1091 it('Should fail when after 3 registrations', async function () {
1026 await registerUser(server.url, 'user42', 'super password', 403) 1092 await registerUser(server.url, 'user42', 'super password', HttpStatusCode.FORBIDDEN_403)
1027 }) 1093 })
1028 }) 1094 })
1029 1095
@@ -1036,7 +1102,7 @@ describe('Test users API validators', function () {
1036 videoQuota: 42 1102 videoQuota: 42
1037 }) 1103 })
1038 1104
1039 await uploadVideo(server.url, server.accessToken, {}, 403) 1105 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403)
1040 }) 1106 })
1041 1107
1042 it('Should fail with a registered user having too many videos', async function () { 1108 it('Should fail with a registered user having too many videos', async function () {
@@ -1054,7 +1120,7 @@ describe('Test users API validators', function () {
1054 await uploadVideo(server.url, userAccessToken, videoAttributes) 1120 await uploadVideo(server.url, userAccessToken, videoAttributes)
1055 await uploadVideo(server.url, userAccessToken, videoAttributes) 1121 await uploadVideo(server.url, userAccessToken, videoAttributes)
1056 await uploadVideo(server.url, userAccessToken, videoAttributes) 1122 await uploadVideo(server.url, userAccessToken, videoAttributes)
1057 await uploadVideo(server.url, userAccessToken, videoAttributes, 403) 1123 await uploadVideo(server.url, userAccessToken, videoAttributes, HttpStatusCode.FORBIDDEN_403)
1058 }) 1124 })
1059 1125
1060 it('Should fail to import with HTTP/Torrent/magnet', async function () { 1126 it('Should fail to import with HTTP/Torrent/magnet', async function () {
@@ -1093,7 +1159,7 @@ describe('Test users API validators', function () {
1093 videoQuotaDaily: 42 1159 videoQuotaDaily: 42
1094 }) 1160 })
1095 1161
1096 await uploadVideo(server.url, server.accessToken, {}, 403) 1162 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403)
1097 }) 1163 })
1098 }) 1164 })
1099 1165
@@ -1107,7 +1173,7 @@ describe('Test users API validators', function () {
1107 videoQuotaDaily: 1024 * 1024 * 1024 1173 videoQuotaDaily: 1024 * 1024 * 1024
1108 }) 1174 })
1109 1175
1110 await uploadVideo(server.url, server.accessToken, {}, 403) 1176 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403)
1111 }) 1177 })
1112 1178
1113 it('Should fail if exceeding daily quota', async function () { 1179 it('Should fail if exceeding daily quota', async function () {
@@ -1119,7 +1185,7 @@ describe('Test users API validators', function () {
1119 videoQuotaDaily: 42 1185 videoQuotaDaily: 42
1120 }) 1186 })
1121 1187
1122 await uploadVideo(server.url, server.accessToken, {}, 403) 1188 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403)
1123 }) 1189 })
1124 }) 1190 })
1125 1191
@@ -1141,7 +1207,13 @@ describe('Test users API validators', function () {
1141 it('Should success with the correct params', async function () { 1207 it('Should success with the correct params', async function () {
1142 const fields = { email: 'admin@example.com' } 1208 const fields = { email: 'admin@example.com' }
1143 1209
1144 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 }) 1210 await makePostBodyRequest({
1211 url: server.url,
1212 path,
1213 token: server.accessToken,
1214 fields,
1215 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
1216 })
1145 }) 1217 })
1146 }) 1218 })
1147 1219
@@ -1163,7 +1235,13 @@ describe('Test users API validators', function () {
1163 it('Should succeed with the correct params', async function () { 1235 it('Should succeed with the correct params', async function () {
1164 const fields = { email: 'admin@example.com' } 1236 const fields = { email: 'admin@example.com' }
1165 1237
1166 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 }) 1238 await makePostBodyRequest({
1239 url: server.url,
1240 path,
1241 token: server.accessToken,
1242 fields,
1243 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
1244 })
1167 }) 1245 })
1168 }) 1246 })
1169 1247