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 { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared'
8 import { randomInt, root } from '@shared/core-utils'
9 import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
18 setAccessTokensToServers
19 } from '@shared/server-commands'
21 const expect = chai.expect
23 describe('Test videos API validator', function () {
24 const path = '/api/v1/videos/'
25 let server: PeerTubeServer
26 let userAccessToken = ''
27 let accountName: string
29 let channelName: string
30 let video: VideoCreateResult
32 // ---------------------------------------------------------------
34 before(async function () {
37 server = await createSingleServer(1)
39 await setAccessTokensToServers([ server ])
41 const username = 'user1'
42 const password = 'my super password'
43 await server.users.create({ username: username, password: password })
44 userAccessToken = await server.login.getAccessToken({ username, password })
47 const body = await server.users.getMyInfo()
48 channelId = body.videoChannels[0].id
49 channelName = body.videoChannels[0].name
50 accountName = body.account.name + '@' + body.account.host
54 describe('When listing videos', function () {
55 it('Should fail with a bad start pagination', async function () {
56 await checkBadStartPagination(server.url, path)
59 it('Should fail with a bad count pagination', async function () {
60 await checkBadCountPagination(server.url, path)
63 it('Should fail with an incorrect sort', async function () {
64 await checkBadSortPagination(server.url, path)
67 it('Should fail with a bad skipVideos query', async function () {
68 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
71 it('Should success with the correct parameters', async function () {
72 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } })
76 describe('When searching a video', function () {
78 it('Should fail with nothing', async function () {
79 await makeGetRequest({
81 path: join(path, 'search'),
82 expectedStatus: HttpStatusCode.BAD_REQUEST_400
86 it('Should fail with a bad start pagination', async function () {
87 await checkBadStartPagination(server.url, join(path, 'search', 'test'))
90 it('Should fail with a bad count pagination', async function () {
91 await checkBadCountPagination(server.url, join(path, 'search', 'test'))
94 it('Should fail with an incorrect sort', async function () {
95 await checkBadSortPagination(server.url, join(path, 'search', 'test'))
98 it('Should success with the correct parameters', async function () {
99 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
103 describe('When listing my videos', function () {
104 const path = '/api/v1/users/me/videos'
106 it('Should fail with a bad start pagination', async function () {
107 await checkBadStartPagination(server.url, path, server.accessToken)
110 it('Should fail with a bad count pagination', async function () {
111 await checkBadCountPagination(server.url, path, server.accessToken)
114 it('Should fail with an incorrect sort', async function () {
115 await checkBadSortPagination(server.url, path, server.accessToken)
118 it('Should fail with an invalid channel', async function () {
119 await makeGetRequest({ url: server.url, token: server.accessToken, path, query: { channelId: 'toto' } })
122 it('Should fail with an unknown channel', async function () {
123 await makeGetRequest({
125 token: server.accessToken,
127 query: { channelId: 89898 },
128 expectedStatus: HttpStatusCode.NOT_FOUND_404
132 it('Should success with the correct parameters', async function () {
133 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
137 describe('When listing account videos', function () {
140 before(async function () {
141 path = '/api/v1/accounts/' + accountName + '/videos'
144 it('Should fail with a bad start pagination', async function () {
145 await checkBadStartPagination(server.url, path, server.accessToken)
148 it('Should fail with a bad count pagination', async function () {
149 await checkBadCountPagination(server.url, path, server.accessToken)
152 it('Should fail with an incorrect sort', async function () {
153 await checkBadSortPagination(server.url, path, server.accessToken)
156 it('Should success with the correct parameters', async function () {
157 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
161 describe('When listing video channel videos', function () {
164 before(async function () {
165 path = '/api/v1/video-channels/' + channelName + '/videos'
168 it('Should fail with a bad start pagination', async function () {
169 await checkBadStartPagination(server.url, path, server.accessToken)
172 it('Should fail with a bad count pagination', async function () {
173 await checkBadCountPagination(server.url, path, server.accessToken)
176 it('Should fail with an incorrect sort', async function () {
177 await checkBadSortPagination(server.url, path, server.accessToken)
180 it('Should success with the correct parameters', async function () {
181 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
185 describe('When adding a video', function () {
186 let baseCorrectParams
187 const baseCorrectAttaches = {
188 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
192 // Put in before to have channelId
193 baseCorrectParams = {
194 name: 'my super name',
199 commentsEnabled: true,
200 downloadEnabled: true,
201 waitTranscoding: true,
202 description: 'my super description',
203 support: 'my super support text',
204 tags: [ 'tag1', 'tag2' ],
205 privacy: VideoPrivacy.PUBLIC,
206 channelId: channelId,
207 originallyPublishedAt: new Date().toISOString()
211 function runSuite (mode: 'legacy' | 'resumable') {
213 it('Should fail with nothing', async function () {
216 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
219 it('Should fail without name', async function () {
220 const fields = omit(baseCorrectParams, 'name')
221 const attaches = baseCorrectAttaches
223 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
226 it('Should fail with a long name', async function () {
227 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
228 const attaches = baseCorrectAttaches
230 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
233 it('Should fail with a bad category', async function () {
234 const fields = { ...baseCorrectParams, category: 125 }
235 const attaches = baseCorrectAttaches
237 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
240 it('Should fail with a bad licence', async function () {
241 const fields = { ...baseCorrectParams, licence: 125 }
242 const attaches = baseCorrectAttaches
244 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
247 it('Should fail with a bad language', async function () {
248 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
249 const attaches = baseCorrectAttaches
251 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
254 it('Should fail with a long description', async function () {
255 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
256 const attaches = baseCorrectAttaches
258 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
261 it('Should fail with a long support text', async function () {
262 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
263 const attaches = baseCorrectAttaches
265 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
268 it('Should fail without a channel', async function () {
269 const fields = omit(baseCorrectParams, 'channelId')
270 const attaches = baseCorrectAttaches
272 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
275 it('Should fail with a bad channel', async function () {
276 const fields = { ...baseCorrectParams, channelId: 545454 }
277 const attaches = baseCorrectAttaches
279 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
282 it('Should fail with another user channel', async function () {
284 username: 'fake' + randomInt(0, 1500),
285 password: 'fake_password'
287 await server.users.create({ username: user.username, password: user.password })
289 const accessTokenUser = await server.login.getAccessToken(user)
290 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
291 const customChannelId = videoChannels[0].id
293 const fields = { ...baseCorrectParams, channelId: customChannelId }
294 const attaches = baseCorrectAttaches
296 await checkUploadVideoParam(server, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
299 it('Should fail with too many tags', async function () {
300 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
301 const attaches = baseCorrectAttaches
303 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
306 it('Should fail with a tag length too low', async function () {
307 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
308 const attaches = baseCorrectAttaches
310 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
313 it('Should fail with a tag length too big', async function () {
314 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
315 const attaches = baseCorrectAttaches
317 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
320 it('Should fail with a bad schedule update (miss updateAt)', async function () {
321 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
322 const attaches = baseCorrectAttaches
324 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
327 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
329 ...baseCorrectParams,
332 privacy: VideoPrivacy.PUBLIC,
336 const attaches = baseCorrectAttaches
338 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
341 it('Should fail with a bad originally published at attribute', async function () {
342 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
343 const attaches = baseCorrectAttaches
345 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
348 it('Should fail without an input file', async function () {
349 const fields = baseCorrectParams
351 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
354 it('Should fail with an incorrect input file', async function () {
355 const fields = baseCorrectParams
356 let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }
358 await checkUploadVideoParam(
361 { ...fields, ...attaches },
362 HttpStatusCode.UNPROCESSABLE_ENTITY_422,
366 attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') }
367 await checkUploadVideoParam(
370 { ...fields, ...attaches },
371 HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415,
376 it('Should fail with an incorrect thumbnail file', async function () {
377 const fields = baseCorrectParams
379 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
380 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
383 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
386 it('Should fail with a big thumbnail file', async function () {
387 const fields = baseCorrectParams
389 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
390 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
393 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
396 it('Should fail with an incorrect preview file', async function () {
397 const fields = baseCorrectParams
399 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
400 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
403 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
406 it('Should fail with a big preview file', async function () {
407 const fields = baseCorrectParams
409 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
410 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
413 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
416 it('Should report the appropriate error', async function () {
417 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
418 const attaches = baseCorrectAttaches
420 const attributes = { ...fields, ...attaches }
421 const body = await checkUploadVideoParam(server, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode)
423 const error = body as unknown as PeerTubeProblemDocument
425 if (mode === 'legacy') {
426 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy')
428 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit')
431 expect(error.type).to.equal('about:blank')
432 expect(error.title).to.equal('Bad Request')
434 expect(error.detail).to.equal('Incorrect request parameters: language')
435 expect(error.error).to.equal('Incorrect request parameters: language')
437 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
438 expect(error['invalid-params'].language).to.exist
441 it('Should succeed with the correct parameters', async function () {
444 const fields = baseCorrectParams
447 const attaches = baseCorrectAttaches
448 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
453 ...baseCorrectAttaches,
455 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
458 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
463 ...baseCorrectAttaches,
465 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
468 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
473 describe('Resumable upload', function () {
474 runSuite('resumable')
477 describe('Legacy upload', function () {
482 describe('When updating a video', function () {
483 const baseCorrectParams = {
484 name: 'my super name',
489 commentsEnabled: false,
490 downloadEnabled: false,
491 description: 'my super description',
492 privacy: VideoPrivacy.PUBLIC,
493 tags: [ 'tag1', 'tag2' ]
496 before(async function () {
497 const { data } = await server.videos.list()
501 it('Should fail with nothing', async function () {
503 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
506 it('Should fail without a valid uuid', async function () {
507 const fields = baseCorrectParams
508 await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields })
511 it('Should fail with an unknown id', async function () {
512 const fields = baseCorrectParams
514 await makePutBodyRequest({
516 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
517 token: server.accessToken,
519 expectedStatus: HttpStatusCode.NOT_FOUND_404
523 it('Should fail with a long name', async function () {
524 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
526 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
529 it('Should fail with a bad category', async function () {
530 const fields = { ...baseCorrectParams, category: 125 }
532 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
535 it('Should fail with a bad licence', async function () {
536 const fields = { ...baseCorrectParams, licence: 125 }
538 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
541 it('Should fail with a bad language', async function () {
542 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
544 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
547 it('Should fail with a long description', async function () {
548 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
550 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
553 it('Should fail with a long support text', async function () {
554 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
556 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
559 it('Should fail with a bad channel', async function () {
560 const fields = { ...baseCorrectParams, channelId: 545454 }
562 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
565 it('Should fail with too many tags', async function () {
566 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
568 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
571 it('Should fail with a tag length too low', async function () {
572 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
574 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
577 it('Should fail with a tag length too big', async function () {
578 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
580 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
583 it('Should fail with a bad schedule update (miss updateAt)', async function () {
584 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
586 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
589 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
590 const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }
592 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
595 it('Should fail with a bad originally published at param', async function () {
596 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
598 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
601 it('Should fail with an incorrect thumbnail file', async function () {
602 const fields = baseCorrectParams
604 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
607 await makeUploadRequest({
610 path: path + video.shortUUID,
611 token: server.accessToken,
617 it('Should fail with a big thumbnail file', async function () {
618 const fields = baseCorrectParams
620 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
623 await makeUploadRequest({
626 path: path + video.shortUUID,
627 token: server.accessToken,
633 it('Should fail with an incorrect preview file', async function () {
634 const fields = baseCorrectParams
636 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
639 await makeUploadRequest({
642 path: path + video.shortUUID,
643 token: server.accessToken,
649 it('Should fail with a big preview file', async function () {
650 const fields = baseCorrectParams
652 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
655 await makeUploadRequest({
658 path: path + video.shortUUID,
659 token: server.accessToken,
665 it('Should fail with a video of another user without the appropriate right', async function () {
666 const fields = baseCorrectParams
668 await makePutBodyRequest({
670 path: path + video.shortUUID,
671 token: userAccessToken,
673 expectedStatus: HttpStatusCode.FORBIDDEN_403
677 it('Should fail with a video of another server')
679 it('Shoud report the appropriate error', async function () {
680 const fields = { ...baseCorrectParams, licence: 125 }
682 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
683 const error = res.body as PeerTubeProblemDocument
685 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo')
687 expect(error.type).to.equal('about:blank')
688 expect(error.title).to.equal('Bad Request')
690 expect(error.detail).to.equal('Incorrect request parameters: licence')
691 expect(error.error).to.equal('Incorrect request parameters: licence')
693 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
694 expect(error['invalid-params'].licence).to.exist
697 it('Should succeed with the correct parameters', async function () {
698 const fields = baseCorrectParams
700 await makePutBodyRequest({
702 path: path + video.shortUUID,
703 token: server.accessToken,
705 expectedStatus: HttpStatusCode.NO_CONTENT_204
710 describe('When getting a video', function () {
711 it('Should return the list of the videos with nothing', async function () {
712 const res = await makeGetRequest({
715 expectedStatus: HttpStatusCode.OK_200
718 expect(res.body.data).to.be.an('array')
719 expect(res.body.data.length).to.equal(6)
722 it('Should fail without a correct uuid', async function () {
723 await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
726 it('Should return 404 with an incorrect video', async function () {
727 await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
730 it('Shoud report the appropriate error', async function () {
731 const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
732 const error = body as unknown as PeerTubeProblemDocument
734 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
736 expect(error.type).to.equal('about:blank')
737 expect(error.title).to.equal('Bad Request')
739 expect(error.detail).to.equal('Incorrect request parameters: id')
740 expect(error.error).to.equal('Incorrect request parameters: id')
742 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
743 expect(error['invalid-params'].id).to.exist
746 it('Should succeed with the correct parameters', async function () {
747 await server.videos.get({ id: video.shortUUID })
751 describe('When rating a video', function () {
754 before(async function () {
755 const { data } = await server.videos.list()
759 it('Should fail without a valid uuid', async function () {
763 await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields })
766 it('Should fail with an unknown id', async function () {
770 await makePutBodyRequest({
772 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
773 token: server.accessToken,
775 expectedStatus: HttpStatusCode.NOT_FOUND_404
779 it('Should fail with a wrong rating', async function () {
783 await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields })
786 it('Should succeed with the correct parameters', async function () {
790 await makePutBodyRequest({
792 path: path + videoId + '/rate',
793 token: server.accessToken,
795 expectedStatus: HttpStatusCode.NO_CONTENT_204
800 describe('When removing a video', function () {
801 it('Should have 404 with nothing', async function () {
802 await makeDeleteRequest({
805 expectedStatus: HttpStatusCode.BAD_REQUEST_400
809 it('Should fail without a correct uuid', async function () {
810 await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
813 it('Should fail with a video which does not exist', async function () {
814 await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
817 it('Should fail with a video of another user without the appropriate right', async function () {
818 await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
821 it('Should fail with a video of another server')
823 it('Shoud report the appropriate error', async function () {
824 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
825 const error = body as PeerTubeProblemDocument
827 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
829 expect(error.type).to.equal('about:blank')
830 expect(error.title).to.equal('Bad Request')
832 expect(error.detail).to.equal('Incorrect request parameters: id')
833 expect(error.error).to.equal('Incorrect request parameters: id')
835 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
836 expect(error['invalid-params'].id).to.exist
839 it('Should succeed with the correct parameters', async function () {
840 await server.videos.remove({ id: video.uuid })
844 after(async function () {
845 await cleanupTests([ server ])