aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r--server/tests/api/check-params/videos.ts57
1 files changed, 35 insertions, 22 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 0d4665954..d60546917 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -28,6 +28,7 @@ import {
28 checkBadSortPagination, 28 checkBadSortPagination,
29 checkBadStartPagination 29 checkBadStartPagination
30} from '../../../../shared/extra-utils/requests/check-api-params' 30} from '../../../../shared/extra-utils/requests/check-api-params'
31import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
31 32
32const expect = chai.expect 33const expect = chai.expect
33 34
@@ -76,11 +77,11 @@ describe('Test videos API validator', function () {
76 }) 77 })
77 78
78 it('Should fail with a bad skipVideos query', async function () { 79 it('Should fail with a bad skipVideos query', async function () {
79 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200, query: { skipCount: 'toto' } }) 80 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
80 }) 81 })
81 82
82 it('Should success with the correct parameters', async function () { 83 it('Should success with the correct parameters', async function () {
83 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200, query: { skipCount: false } }) 84 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } })
84 }) 85 })
85 }) 86 })
86 87
@@ -90,7 +91,7 @@ describe('Test videos API validator', function () {
90 await makeGetRequest({ 91 await makeGetRequest({
91 url: server.url, 92 url: server.url,
92 path: join(path, 'search'), 93 path: join(path, 'search'),
93 statusCodeExpected: 400 94 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
94 }) 95 })
95 }) 96 })
96 97
@@ -107,7 +108,7 @@ describe('Test videos API validator', function () {
107 }) 108 })
108 109
109 it('Should success with the correct parameters', async function () { 110 it('Should success with the correct parameters', async function () {
110 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 }) 111 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
111 }) 112 })
112 }) 113 })
113 114
@@ -127,7 +128,7 @@ describe('Test videos API validator', function () {
127 }) 128 })
128 129
129 it('Should success with the correct parameters', async function () { 130 it('Should success with the correct parameters', async function () {
130 await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: 200 }) 131 await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 })
131 }) 132 })
132 }) 133 })
133 134
@@ -151,7 +152,7 @@ describe('Test videos API validator', function () {
151 }) 152 })
152 153
153 it('Should success with the correct parameters', async function () { 154 it('Should success with the correct parameters', async function () {
154 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 }) 155 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
155 }) 156 })
156 }) 157 })
157 158
@@ -175,7 +176,7 @@ describe('Test videos API validator', function () {
175 }) 176 })
176 177
177 it('Should success with the correct parameters', async function () { 178 it('Should success with the correct parameters', async function () {
178 await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 }) 179 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
179 }) 180 })
180 }) 181 })
181 182
@@ -408,7 +409,7 @@ describe('Test videos API validator', function () {
408 token: server.accessToken, 409 token: server.accessToken,
409 fields, 410 fields,
410 attaches, 411 attaches,
411 statusCodeExpected: 200 412 statusCodeExpected: HttpStatusCode.OK_200
412 }) 413 })
413 } 414 }
414 415
@@ -423,7 +424,7 @@ describe('Test videos API validator', function () {
423 token: server.accessToken, 424 token: server.accessToken,
424 fields, 425 fields,
425 attaches, 426 attaches,
426 statusCodeExpected: 200 427 statusCodeExpected: HttpStatusCode.OK_200
427 }) 428 })
428 } 429 }
429 430
@@ -438,7 +439,7 @@ describe('Test videos API validator', function () {
438 token: server.accessToken, 439 token: server.accessToken,
439 fields, 440 fields,
440 attaches, 441 attaches,
441 statusCodeExpected: 200 442 statusCodeExpected: HttpStatusCode.OK_200
442 }) 443 })
443 } 444 }
444 }) 445 })
@@ -481,7 +482,7 @@ describe('Test videos API validator', function () {
481 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', 482 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
482 token: server.accessToken, 483 token: server.accessToken,
483 fields, 484 fields,
484 statusCodeExpected: 404 485 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
485 }) 486 })
486 }) 487 })
487 488
@@ -630,7 +631,13 @@ describe('Test videos API validator', function () {
630 it('Should fail with a video of another user without the appropriate right', async function () { 631 it('Should fail with a video of another user without the appropriate right', async function () {
631 const fields = baseCorrectParams 632 const fields = baseCorrectParams
632 633
633 await makePutBodyRequest({ url: server.url, path: path + videoId, token: userAccessToken, fields, statusCodeExpected: 403 }) 634 await makePutBodyRequest({
635 url: server.url,
636 path: path + videoId,
637 token: userAccessToken,
638 fields,
639 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
640 })
634 }) 641 })
635 642
636 it('Should fail with a video of another server') 643 it('Should fail with a video of another server')
@@ -638,7 +645,13 @@ describe('Test videos API validator', function () {
638 it('Should succeed with the correct parameters', async function () { 645 it('Should succeed with the correct parameters', async function () {
639 const fields = baseCorrectParams 646 const fields = baseCorrectParams
640 647
641 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields, statusCodeExpected: 204 }) 648 await makePutBodyRequest({
649 url: server.url,
650 path: path + videoId,
651 token: server.accessToken,
652 fields,
653 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
654 })
642 }) 655 })
643 }) 656 })
644 657
@@ -647,7 +660,7 @@ describe('Test videos API validator', function () {
647 const res = await makeGetRequest({ 660 const res = await makeGetRequest({
648 url: server.url, 661 url: server.url,
649 path, 662 path,
650 statusCodeExpected: 200 663 statusCodeExpected: HttpStatusCode.OK_200
651 }) 664 })
652 665
653 expect(res.body.data).to.be.an('array') 666 expect(res.body.data).to.be.an('array')
@@ -655,11 +668,11 @@ describe('Test videos API validator', function () {
655 }) 668 })
656 669
657 it('Should fail without a correct uuid', async function () { 670 it('Should fail without a correct uuid', async function () {
658 await getVideo(server.url, 'coucou', 400) 671 await getVideo(server.url, 'coucou', HttpStatusCode.BAD_REQUEST_400)
659 }) 672 })
660 673
661 it('Should return 404 with an incorrect video', async function () { 674 it('Should return 404 with an incorrect video', async function () {
662 await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', 404) 675 await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404)
663 }) 676 })
664 677
665 it('Should succeed with the correct parameters', async function () { 678 it('Should succeed with the correct parameters', async function () {
@@ -691,7 +704,7 @@ describe('Test videos API validator', function () {
691 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', 704 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
692 token: server.accessToken, 705 token: server.accessToken,
693 fields, 706 fields,
694 statusCodeExpected: 404 707 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
695 }) 708 })
696 }) 709 })
697 710
@@ -711,7 +724,7 @@ describe('Test videos API validator', function () {
711 path: path + videoId + '/rate', 724 path: path + videoId + '/rate',
712 token: server.accessToken, 725 token: server.accessToken,
713 fields, 726 fields,
714 statusCodeExpected: 204 727 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
715 }) 728 })
716 }) 729 })
717 }) 730 })
@@ -721,20 +734,20 @@ describe('Test videos API validator', function () {
721 await makeDeleteRequest({ 734 await makeDeleteRequest({
722 url: server.url, 735 url: server.url,
723 path, 736 path,
724 statusCodeExpected: 400 737 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
725 }) 738 })
726 }) 739 })
727 740
728 it('Should fail without a correct uuid', async function () { 741 it('Should fail without a correct uuid', async function () {
729 await removeVideo(server.url, server.accessToken, 'hello', 400) 742 await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400)
730 }) 743 })
731 744
732 it('Should fail with a video which does not exist', async function () { 745 it('Should fail with a video which does not exist', async function () {
733 await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404) 746 await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404)
734 }) 747 })
735 748
736 it('Should fail with a video of another user without the appropriate right', async function () { 749 it('Should fail with a video of another user without the appropriate right', async function () {
737 await removeVideo(server.url, userAccessToken, videoId, 403) 750 await removeVideo(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403)
738 }) 751 })
739 752
740 it('Should fail with a video of another server') 753 it('Should fail with a video of another server')