diff options
Diffstat (limited to 'server/tests/api/check-params/users.ts')
-rw-r--r-- | server/tests/api/check-params/users.ts | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index c2c98f429..34fe309f9 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | buildAbsoluteFixturePath, | 7 | buildAbsoluteFixturePath, |
8 | checkBadCountPagination, | 8 | checkBadCountPagination, |
@@ -103,7 +103,7 @@ describe('Test users API validators', function () { | |||
103 | await makeGetRequest({ | 103 | await makeGetRequest({ |
104 | url: server.url, | 104 | url: server.url, |
105 | path, | 105 | path, |
106 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 106 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
107 | }) | 107 | }) |
108 | }) | 108 | }) |
109 | 109 | ||
@@ -112,7 +112,7 @@ describe('Test users API validators', function () { | |||
112 | url: server.url, | 112 | url: server.url, |
113 | path, | 113 | path, |
114 | token: userToken, | 114 | token: userToken, |
115 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 115 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
116 | }) | 116 | }) |
117 | }) | 117 | }) |
118 | }) | 118 | }) |
@@ -210,7 +210,7 @@ describe('Test users API validators', function () { | |||
210 | path: path, | 210 | path: path, |
211 | token: server.accessToken, | 211 | token: server.accessToken, |
212 | fields, | 212 | fields, |
213 | statusCodeExpected: HttpStatusCode.OK_200 | 213 | expectedStatus: HttpStatusCode.OK_200 |
214 | }) | 214 | }) |
215 | }) | 215 | }) |
216 | 216 | ||
@@ -226,7 +226,7 @@ describe('Test users API validators', function () { | |||
226 | path, | 226 | path, |
227 | token: 'super token', | 227 | token: 'super token', |
228 | fields: baseCorrectParams, | 228 | fields: baseCorrectParams, |
229 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 229 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
230 | }) | 230 | }) |
231 | }) | 231 | }) |
232 | 232 | ||
@@ -238,7 +238,7 @@ describe('Test users API validators', function () { | |||
238 | path, | 238 | path, |
239 | token: server.accessToken, | 239 | token: server.accessToken, |
240 | fields, | 240 | fields, |
241 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 241 | expectedStatus: HttpStatusCode.CONFLICT_409 |
242 | }) | 242 | }) |
243 | }) | 243 | }) |
244 | 244 | ||
@@ -250,7 +250,7 @@ describe('Test users API validators', function () { | |||
250 | path, | 250 | path, |
251 | token: server.accessToken, | 251 | token: server.accessToken, |
252 | fields, | 252 | fields, |
253 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 253 | expectedStatus: HttpStatusCode.CONFLICT_409 |
254 | }) | 254 | }) |
255 | }) | 255 | }) |
256 | 256 | ||
@@ -298,7 +298,7 @@ describe('Test users API validators', function () { | |||
298 | path, | 298 | path, |
299 | token: server.accessToken, | 299 | token: server.accessToken, |
300 | fields, | 300 | fields, |
301 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 301 | expectedStatus: HttpStatusCode.CONFLICT_409 |
302 | }) | 302 | }) |
303 | }) | 303 | }) |
304 | 304 | ||
@@ -311,7 +311,7 @@ describe('Test users API validators', function () { | |||
311 | path, | 311 | path, |
312 | token: moderatorToken, | 312 | token: moderatorToken, |
313 | fields, | 313 | fields, |
314 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 314 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
315 | }) | 315 | }) |
316 | } | 316 | } |
317 | }) | 317 | }) |
@@ -324,7 +324,7 @@ describe('Test users API validators', function () { | |||
324 | path, | 324 | path, |
325 | token: moderatorToken, | 325 | token: moderatorToken, |
326 | fields, | 326 | fields, |
327 | statusCodeExpected: HttpStatusCode.OK_200 | 327 | expectedStatus: HttpStatusCode.OK_200 |
328 | }) | 328 | }) |
329 | }) | 329 | }) |
330 | 330 | ||
@@ -334,7 +334,7 @@ describe('Test users API validators', function () { | |||
334 | path, | 334 | path, |
335 | token: server.accessToken, | 335 | token: server.accessToken, |
336 | fields: baseCorrectParams, | 336 | fields: baseCorrectParams, |
337 | statusCodeExpected: HttpStatusCode.OK_200 | 337 | expectedStatus: HttpStatusCode.OK_200 |
338 | }) | 338 | }) |
339 | }) | 339 | }) |
340 | 340 | ||
@@ -348,7 +348,7 @@ describe('Test users API validators', function () { | |||
348 | password: 'my super password', | 348 | password: 'my super password', |
349 | videoQuota: 42000000 | 349 | videoQuota: 42000000 |
350 | } | 350 | } |
351 | await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 351 | await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
352 | }) | 352 | }) |
353 | }) | 353 | }) |
354 | 354 | ||
@@ -400,7 +400,7 @@ describe('Test users API validators', function () { | |||
400 | path: path + 'me', | 400 | path: path + 'me', |
401 | token: userToken, | 401 | token: userToken, |
402 | fields, | 402 | fields, |
403 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 403 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
404 | }) | 404 | }) |
405 | }) | 405 | }) |
406 | 406 | ||
@@ -447,7 +447,7 @@ describe('Test users API validators', function () { | |||
447 | path: path + 'me', | 447 | path: path + 'me', |
448 | token: 'super token', | 448 | token: 'super token', |
449 | fields, | 449 | fields, |
450 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 450 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
451 | }) | 451 | }) |
452 | }) | 452 | }) |
453 | 453 | ||
@@ -525,7 +525,7 @@ describe('Test users API validators', function () { | |||
525 | path: path + 'me', | 525 | path: path + 'me', |
526 | token: userToken, | 526 | token: userToken, |
527 | fields, | 527 | fields, |
528 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 528 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
529 | }) | 529 | }) |
530 | }) | 530 | }) |
531 | 531 | ||
@@ -540,7 +540,7 @@ describe('Test users API validators', function () { | |||
540 | path: path + 'me', | 540 | path: path + 'me', |
541 | token: userToken, | 541 | token: userToken, |
542 | fields, | 542 | fields, |
543 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 543 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
544 | }) | 544 | }) |
545 | }) | 545 | }) |
546 | }) | 546 | }) |
@@ -572,7 +572,7 @@ describe('Test users API validators', function () { | |||
572 | path: path + '/me/avatar/pick', | 572 | path: path + '/me/avatar/pick', |
573 | fields, | 573 | fields, |
574 | attaches, | 574 | attaches, |
575 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 575 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
576 | }) | 576 | }) |
577 | }) | 577 | }) |
578 | 578 | ||
@@ -587,7 +587,7 @@ describe('Test users API validators', function () { | |||
587 | token: server.accessToken, | 587 | token: server.accessToken, |
588 | fields, | 588 | fields, |
589 | attaches, | 589 | attaches, |
590 | statusCodeExpected: HttpStatusCode.OK_200 | 590 | expectedStatus: HttpStatusCode.OK_200 |
591 | }) | 591 | }) |
592 | }) | 592 | }) |
593 | }) | 593 | }) |
@@ -627,16 +627,16 @@ describe('Test users API validators', function () { | |||
627 | url: server.url, | 627 | url: server.url, |
628 | path: path + userId, | 628 | path: path + userId, |
629 | token: 'super token', | 629 | token: 'super token', |
630 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 630 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
631 | }) | 631 | }) |
632 | }) | 632 | }) |
633 | 633 | ||
634 | it('Should fail with a non admin user', async function () { | 634 | it('Should fail with a non admin user', async function () { |
635 | await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 635 | await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
636 | }) | 636 | }) |
637 | 637 | ||
638 | it('Should succeed with the correct params', async function () { | 638 | it('Should succeed with the correct params', async function () { |
639 | await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: HttpStatusCode.OK_200 }) | 639 | await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) |
640 | }) | 640 | }) |
641 | }) | 641 | }) |
642 | 642 | ||
@@ -702,7 +702,7 @@ describe('Test users API validators', function () { | |||
702 | path: path + userId, | 702 | path: path + userId, |
703 | token: 'super token', | 703 | token: 'super token', |
704 | fields, | 704 | fields, |
705 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 705 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
706 | }) | 706 | }) |
707 | }) | 707 | }) |
708 | 708 | ||
@@ -730,7 +730,7 @@ describe('Test users API validators', function () { | |||
730 | path: path + moderatorId, | 730 | path: path + moderatorId, |
731 | token: moderatorToken, | 731 | token: moderatorToken, |
732 | fields, | 732 | fields, |
733 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 733 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
734 | }) | 734 | }) |
735 | }) | 735 | }) |
736 | 736 | ||
@@ -744,7 +744,7 @@ describe('Test users API validators', function () { | |||
744 | path: path + userId, | 744 | path: path + userId, |
745 | token: moderatorToken, | 745 | token: moderatorToken, |
746 | fields, | 746 | fields, |
747 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 747 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
748 | }) | 748 | }) |
749 | }) | 749 | }) |
750 | 750 | ||
@@ -761,7 +761,7 @@ describe('Test users API validators', function () { | |||
761 | path: path + userId, | 761 | path: path + userId, |
762 | token: server.accessToken, | 762 | token: server.accessToken, |
763 | fields, | 763 | fields, |
764 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 764 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
765 | }) | 765 | }) |
766 | }) | 766 | }) |
767 | }) | 767 | }) |
@@ -818,11 +818,11 @@ describe('Test users API validators', function () { | |||
818 | }) | 818 | }) |
819 | 819 | ||
820 | it('Should fail with a unauthenticated user', async function () { | 820 | it('Should fail with a unauthenticated user', async function () { |
821 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 821 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
822 | }) | 822 | }) |
823 | 823 | ||
824 | it('Should fail with a another user', async function () { | 824 | it('Should fail with a another user', async function () { |
825 | await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 825 | await makeGetRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
826 | }) | 826 | }) |
827 | 827 | ||
828 | it('Should fail with a bad type', async function () { | 828 | it('Should fail with a bad type', async function () { |
@@ -831,12 +831,12 @@ describe('Test users API validators', function () { | |||
831 | path, | 831 | path, |
832 | token: userToken, | 832 | token: userToken, |
833 | query: { rating: 'toto ' }, | 833 | query: { rating: 'toto ' }, |
834 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 834 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
835 | }) | 835 | }) |
836 | }) | 836 | }) |
837 | 837 | ||
838 | it('Should succeed with the correct params', async function () { | 838 | it('Should succeed with the correct params', async function () { |
839 | await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.OK_200 }) | 839 | await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.OK_200 }) |
840 | }) | 840 | }) |
841 | }) | 841 | }) |
842 | 842 | ||
@@ -955,7 +955,7 @@ describe('Test users API validators', function () { | |||
955 | path: registrationPath, | 955 | path: registrationPath, |
956 | token: server.accessToken, | 956 | token: server.accessToken, |
957 | fields, | 957 | fields, |
958 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 958 | expectedStatus: HttpStatusCode.CONFLICT_409 |
959 | }) | 959 | }) |
960 | }) | 960 | }) |
961 | 961 | ||
@@ -967,7 +967,7 @@ describe('Test users API validators', function () { | |||
967 | path: registrationPath, | 967 | path: registrationPath, |
968 | token: server.accessToken, | 968 | token: server.accessToken, |
969 | fields, | 969 | fields, |
970 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 970 | expectedStatus: HttpStatusCode.CONFLICT_409 |
971 | }) | 971 | }) |
972 | }) | 972 | }) |
973 | 973 | ||
@@ -979,7 +979,7 @@ describe('Test users API validators', function () { | |||
979 | path: registrationPath, | 979 | path: registrationPath, |
980 | token: server.accessToken, | 980 | token: server.accessToken, |
981 | fields, | 981 | fields, |
982 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 982 | expectedStatus: HttpStatusCode.CONFLICT_409 |
983 | }) | 983 | }) |
984 | }) | 984 | }) |
985 | 985 | ||
@@ -1019,7 +1019,7 @@ describe('Test users API validators', function () { | |||
1019 | path: registrationPath, | 1019 | path: registrationPath, |
1020 | token: server.accessToken, | 1020 | token: server.accessToken, |
1021 | fields, | 1021 | fields, |
1022 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 1022 | expectedStatus: HttpStatusCode.CONFLICT_409 |
1023 | }) | 1023 | }) |
1024 | }) | 1024 | }) |
1025 | 1025 | ||
@@ -1031,7 +1031,7 @@ describe('Test users API validators', function () { | |||
1031 | path: registrationPath, | 1031 | path: registrationPath, |
1032 | token: server.accessToken, | 1032 | token: server.accessToken, |
1033 | fields: fields, | 1033 | fields: fields, |
1034 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 1034 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
1035 | }) | 1035 | }) |
1036 | }) | 1036 | }) |
1037 | 1037 | ||
@@ -1047,7 +1047,7 @@ describe('Test users API validators', function () { | |||
1047 | path: registrationPath, | 1047 | path: registrationPath, |
1048 | token: serverWithRegistrationDisabled.accessToken, | 1048 | token: serverWithRegistrationDisabled.accessToken, |
1049 | fields, | 1049 | fields, |
1050 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 1050 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
1051 | }) | 1051 | }) |
1052 | }) | 1052 | }) |
1053 | }) | 1053 | }) |
@@ -1081,7 +1081,7 @@ describe('Test users API validators', function () { | |||
1081 | path, | 1081 | path, |
1082 | token: server.accessToken, | 1082 | token: server.accessToken, |
1083 | fields, | 1083 | fields, |
1084 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 1084 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
1085 | }) | 1085 | }) |
1086 | }) | 1086 | }) |
1087 | }) | 1087 | }) |
@@ -1109,7 +1109,7 @@ describe('Test users API validators', function () { | |||
1109 | path, | 1109 | path, |
1110 | token: server.accessToken, | 1110 | token: server.accessToken, |
1111 | fields, | 1111 | fields, |
1112 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 1112 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
1113 | }) | 1113 | }) |
1114 | }) | 1114 | }) |
1115 | }) | 1115 | }) |