1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { omit } from 'lodash'
6 import { join } from 'path'
7 import { randomInt } from '@shared/core-utils'
9 checkBadCountPagination,
10 checkBadSortPagination,
11 checkBadStartPagination,
12 checkUploadVideoParam,
21 setAccessTokensToServers
22 } from '@shared/extra-utils'
23 import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
25 const expect = chai.expect
27 describe('Test videos API validator', function () {
28 const path = '/api/v1/videos/'
29 let server: PeerTubeServer
30 let userAccessToken = ''
31 let accountName: string
33 let channelName: string
34 let video: VideoCreateResult
36 // ---------------------------------------------------------------
38 before(async function () {
41 server = await createSingleServer(1)
43 await setAccessTokensToServers([ server ])
45 const username = 'user1'
46 const password = 'my super password'
47 await server.users.create({ username: username, password: password })
48 userAccessToken = await server.login.getAccessToken({ username, password })
51 const body = await server.users.getMyInfo()
52 channelId = body.videoChannels[0].id
53 channelName = body.videoChannels[0].name
54 accountName = body.account.name + '@' + body.account.host
58 describe('When listing videos', function () {
59 it('Should fail with a bad start pagination', async function () {
60 await checkBadStartPagination(server.url, path)
63 it('Should fail with a bad count pagination', async function () {
64 await checkBadCountPagination(server.url, path)
67 it('Should fail with an incorrect sort', async function () {
68 await checkBadSortPagination(server.url, path)
71 it('Should fail with a bad skipVideos query', async function () {
72 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
75 it('Should success with the correct parameters', async function () {
76 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } })
80 describe('When searching a video', function () {
82 it('Should fail with nothing', async function () {
83 await makeGetRequest({
85 path: join(path, 'search'),
86 expectedStatus: HttpStatusCode.BAD_REQUEST_400
90 it('Should fail with a bad start pagination', async function () {
91 await checkBadStartPagination(server.url, join(path, 'search', 'test'))
94 it('Should fail with a bad count pagination', async function () {
95 await checkBadCountPagination(server.url, join(path, 'search', 'test'))
98 it('Should fail with an incorrect sort', async function () {
99 await checkBadSortPagination(server.url, join(path, 'search', 'test'))
102 it('Should success with the correct parameters', async function () {
103 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
107 describe('When listing my videos', function () {
108 const path = '/api/v1/users/me/videos'
110 it('Should fail with a bad start pagination', async function () {
111 await checkBadStartPagination(server.url, path, server.accessToken)
114 it('Should fail with a bad count pagination', async function () {
115 await checkBadCountPagination(server.url, path, server.accessToken)
118 it('Should fail with an incorrect sort', async function () {
119 await checkBadSortPagination(server.url, path, server.accessToken)
122 it('Should fail with an invalid channel', async function () {
123 await makeGetRequest({ url: server.url, token: server.accessToken, path, query: { channelId: 'toto' } })
126 it('Should fail with an unknown channel', async function () {
127 await makeGetRequest({
129 token: server.accessToken,
131 query: { channelId: 89898 },
132 expectedStatus: HttpStatusCode.NOT_FOUND_404
136 it('Should success with the correct parameters', async function () {
137 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
141 describe('When listing account videos', function () {
144 before(async function () {
145 path = '/api/v1/accounts/' + accountName + '/videos'
148 it('Should fail with a bad start pagination', async function () {
149 await checkBadStartPagination(server.url, path, server.accessToken)
152 it('Should fail with a bad count pagination', async function () {
153 await checkBadCountPagination(server.url, path, server.accessToken)
156 it('Should fail with an incorrect sort', async function () {
157 await checkBadSortPagination(server.url, path, server.accessToken)
160 it('Should success with the correct parameters', async function () {
161 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
165 describe('When listing video channel videos', function () {
168 before(async function () {
169 path = '/api/v1/video-channels/' + channelName + '/videos'
172 it('Should fail with a bad start pagination', async function () {
173 await checkBadStartPagination(server.url, path, server.accessToken)
176 it('Should fail with a bad count pagination', async function () {
177 await checkBadCountPagination(server.url, path, server.accessToken)
180 it('Should fail with an incorrect sort', async function () {
181 await checkBadSortPagination(server.url, path, server.accessToken)
184 it('Should success with the correct parameters', async function () {
185 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
189 describe('When adding a video', function () {
190 let baseCorrectParams
191 const baseCorrectAttaches = {
192 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
196 // Put in before to have channelId
197 baseCorrectParams = {
198 name: 'my super name',
203 commentsEnabled: true,
204 downloadEnabled: true,
205 waitTranscoding: true,
206 description: 'my super description',
207 support: 'my super support text',
208 tags: [ 'tag1', 'tag2' ],
209 privacy: VideoPrivacy.PUBLIC,
210 channelId: channelId,
211 originallyPublishedAt: new Date().toISOString()
215 function runSuite (mode: 'legacy' | 'resumable') {
217 it('Should fail with nothing', async function () {
220 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
223 it('Should fail without name', async function () {
224 const fields = omit(baseCorrectParams, 'name')
225 const attaches = baseCorrectAttaches
227 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
230 it('Should fail with a long name', async function () {
231 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
232 const attaches = baseCorrectAttaches
234 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
237 it('Should fail with a bad category', async function () {
238 const fields = { ...baseCorrectParams, category: 125 }
239 const attaches = baseCorrectAttaches
241 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
244 it('Should fail with a bad licence', async function () {
245 const fields = { ...baseCorrectParams, licence: 125 }
246 const attaches = baseCorrectAttaches
248 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
251 it('Should fail with a bad language', async function () {
252 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
253 const attaches = baseCorrectAttaches
255 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
258 it('Should fail with a long description', async function () {
259 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
260 const attaches = baseCorrectAttaches
262 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
265 it('Should fail with a long support text', async function () {
266 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
267 const attaches = baseCorrectAttaches
269 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
272 it('Should fail without a channel', async function () {
273 const fields = omit(baseCorrectParams, 'channelId')
274 const attaches = baseCorrectAttaches
276 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
279 it('Should fail with a bad channel', async function () {
280 const fields = { ...baseCorrectParams, channelId: 545454 }
281 const attaches = baseCorrectAttaches
283 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
286 it('Should fail with another user channel', async function () {
288 username: 'fake' + randomInt(0, 1500),
289 password: 'fake_password'
291 await server.users.create({ username: user.username, password: user.password })
293 const accessTokenUser = await server.login.getAccessToken(user)
294 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
295 const customChannelId = videoChannels[0].id
297 const fields = { ...baseCorrectParams, channelId: customChannelId }
298 const attaches = baseCorrectAttaches
300 await checkUploadVideoParam(server, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
303 it('Should fail with too many tags', async function () {
304 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
305 const attaches = baseCorrectAttaches
307 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
310 it('Should fail with a tag length too low', async function () {
311 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
312 const attaches = baseCorrectAttaches
314 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
317 it('Should fail with a tag length too big', async function () {
318 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
319 const attaches = baseCorrectAttaches
321 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
324 it('Should fail with a bad schedule update (miss updateAt)', async function () {
325 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
326 const attaches = baseCorrectAttaches
328 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
331 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
333 ...baseCorrectParams,
336 privacy: VideoPrivacy.PUBLIC,
340 const attaches = baseCorrectAttaches
342 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
345 it('Should fail with a bad originally published at attribute', async function () {
346 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
347 const attaches = baseCorrectAttaches
349 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
352 it('Should fail without an input file', async function () {
353 const fields = baseCorrectParams
355 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
358 it('Should fail with an incorrect input file', async function () {
359 const fields = baseCorrectParams
360 let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }
362 await checkUploadVideoParam(
365 { ...fields, ...attaches },
366 HttpStatusCode.UNPROCESSABLE_ENTITY_422,
370 attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') }
371 await checkUploadVideoParam(
374 { ...fields, ...attaches },
375 HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415,
380 it('Should fail with an incorrect thumbnail file', async function () {
381 const fields = baseCorrectParams
383 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
384 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
387 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
390 it('Should fail with a big thumbnail file', async function () {
391 const fields = baseCorrectParams
393 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
394 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
397 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
400 it('Should fail with an incorrect preview file', async function () {
401 const fields = baseCorrectParams
403 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
404 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
407 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
410 it('Should fail with a big preview file', async function () {
411 const fields = baseCorrectParams
413 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
414 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
417 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
420 it('Should report the appropriate error', async function () {
421 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
422 const attaches = baseCorrectAttaches
424 const attributes = { ...fields, ...attaches }
425 const body = await checkUploadVideoParam(server, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode)
427 const error = body as unknown as PeerTubeProblemDocument
429 if (mode === 'legacy') {
430 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy')
432 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit')
435 expect(error.type).to.equal('about:blank')
436 expect(error.title).to.equal('Bad Request')
438 expect(error.detail).to.equal('Incorrect request parameters: language')
439 expect(error.error).to.equal('Incorrect request parameters: language')
441 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
442 expect(error['invalid-params'].language).to.exist
445 it('Should succeed with the correct parameters', async function () {
448 const fields = baseCorrectParams
451 const attaches = baseCorrectAttaches
452 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
457 ...baseCorrectAttaches,
459 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
462 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
467 ...baseCorrectAttaches,
469 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
472 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
477 describe('Resumable upload', function () {
478 runSuite('resumable')
481 describe('Legacy upload', function () {
486 describe('When updating a video', function () {
487 const baseCorrectParams = {
488 name: 'my super name',
493 commentsEnabled: false,
494 downloadEnabled: false,
495 description: 'my super description',
496 privacy: VideoPrivacy.PUBLIC,
497 tags: [ 'tag1', 'tag2' ]
500 before(async function () {
501 const { data } = await server.videos.list()
505 it('Should fail with nothing', async function () {
507 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
510 it('Should fail without a valid uuid', async function () {
511 const fields = baseCorrectParams
512 await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields })
515 it('Should fail with an unknown id', async function () {
516 const fields = baseCorrectParams
518 await makePutBodyRequest({
520 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
521 token: server.accessToken,
523 expectedStatus: HttpStatusCode.NOT_FOUND_404
527 it('Should fail with a long name', async function () {
528 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
530 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
533 it('Should fail with a bad category', async function () {
534 const fields = { ...baseCorrectParams, category: 125 }
536 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
539 it('Should fail with a bad licence', async function () {
540 const fields = { ...baseCorrectParams, licence: 125 }
542 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
545 it('Should fail with a bad language', async function () {
546 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
548 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
551 it('Should fail with a long description', async function () {
552 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
554 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
557 it('Should fail with a long support text', async function () {
558 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
560 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
563 it('Should fail with a bad channel', async function () {
564 const fields = { ...baseCorrectParams, channelId: 545454 }
566 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
569 it('Should fail with too many tags', async function () {
570 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
572 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
575 it('Should fail with a tag length too low', async function () {
576 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
578 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
581 it('Should fail with a tag length too big', async function () {
582 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
584 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
587 it('Should fail with a bad schedule update (miss updateAt)', async function () {
588 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
590 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
593 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
594 const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }
596 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
599 it('Should fail with a bad originally published at param', async function () {
600 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
602 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
605 it('Should fail with an incorrect thumbnail file', async function () {
606 const fields = baseCorrectParams
608 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
611 await makeUploadRequest({
614 path: path + video.shortUUID,
615 token: server.accessToken,
621 it('Should fail with a big thumbnail file', async function () {
622 const fields = baseCorrectParams
624 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
627 await makeUploadRequest({
630 path: path + video.shortUUID,
631 token: server.accessToken,
637 it('Should fail with an incorrect preview file', async function () {
638 const fields = baseCorrectParams
640 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
643 await makeUploadRequest({
646 path: path + video.shortUUID,
647 token: server.accessToken,
653 it('Should fail with a big preview file', async function () {
654 const fields = baseCorrectParams
656 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
659 await makeUploadRequest({
662 path: path + video.shortUUID,
663 token: server.accessToken,
669 it('Should fail with a video of another user without the appropriate right', async function () {
670 const fields = baseCorrectParams
672 await makePutBodyRequest({
674 path: path + video.shortUUID,
675 token: userAccessToken,
677 expectedStatus: HttpStatusCode.FORBIDDEN_403
681 it('Should fail with a video of another server')
683 it('Shoud report the appropriate error', async function () {
684 const fields = { ...baseCorrectParams, licence: 125 }
686 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
687 const error = res.body as PeerTubeProblemDocument
689 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo')
691 expect(error.type).to.equal('about:blank')
692 expect(error.title).to.equal('Bad Request')
694 expect(error.detail).to.equal('Incorrect request parameters: licence')
695 expect(error.error).to.equal('Incorrect request parameters: licence')
697 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
698 expect(error['invalid-params'].licence).to.exist
701 it('Should succeed with the correct parameters', async function () {
702 const fields = baseCorrectParams
704 await makePutBodyRequest({
706 path: path + video.shortUUID,
707 token: server.accessToken,
709 expectedStatus: HttpStatusCode.NO_CONTENT_204
714 describe('When getting a video', function () {
715 it('Should return the list of the videos with nothing', async function () {
716 const res = await makeGetRequest({
719 expectedStatus: HttpStatusCode.OK_200
722 expect(res.body.data).to.be.an('array')
723 expect(res.body.data.length).to.equal(6)
726 it('Should fail without a correct uuid', async function () {
727 await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
730 it('Should return 404 with an incorrect video', async function () {
731 await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
734 it('Shoud report the appropriate error', async function () {
735 const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
736 const error = body as unknown as PeerTubeProblemDocument
738 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
740 expect(error.type).to.equal('about:blank')
741 expect(error.title).to.equal('Bad Request')
743 expect(error.detail).to.equal('Incorrect request parameters: id')
744 expect(error.error).to.equal('Incorrect request parameters: id')
746 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
747 expect(error['invalid-params'].id).to.exist
750 it('Should succeed with the correct parameters', async function () {
751 await server.videos.get({ id: video.shortUUID })
755 describe('When rating a video', function () {
758 before(async function () {
759 const { data } = await server.videos.list()
763 it('Should fail without a valid uuid', async function () {
767 await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields })
770 it('Should fail with an unknown id', async function () {
774 await makePutBodyRequest({
776 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
777 token: server.accessToken,
779 expectedStatus: HttpStatusCode.NOT_FOUND_404
783 it('Should fail with a wrong rating', async function () {
787 await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields })
790 it('Should succeed with the correct parameters', async function () {
794 await makePutBodyRequest({
796 path: path + videoId + '/rate',
797 token: server.accessToken,
799 expectedStatus: HttpStatusCode.NO_CONTENT_204
804 describe('When removing a video', function () {
805 it('Should have 404 with nothing', async function () {
806 await makeDeleteRequest({
809 expectedStatus: HttpStatusCode.BAD_REQUEST_400
813 it('Should fail without a correct uuid', async function () {
814 await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
817 it('Should fail with a video which does not exist', async function () {
818 await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
821 it('Should fail with a video of another user without the appropriate right', async function () {
822 await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
825 it('Should fail with a video of another server')
827 it('Shoud report the appropriate error', async function () {
828 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
829 const error = body as PeerTubeProblemDocument
831 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
833 expect(error.type).to.equal('about:blank')
834 expect(error.title).to.equal('Bad Request')
836 expect(error.detail).to.equal('Incorrect request parameters: id')
837 expect(error.error).to.equal('Incorrect request parameters: id')
839 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
840 expect(error['invalid-params'].id).to.exist
843 it('Should succeed with the correct parameters', async function () {
844 await server.videos.remove({ id: video.uuid })
848 after(async function () {
849 await cleanupTests([ server ])