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 success with the correct parameters', async function () {
123 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
127 describe('When listing account videos', function () {
130 before(async function () {
131 path = '/api/v1/accounts/' + accountName + '/videos'
134 it('Should fail with a bad start pagination', async function () {
135 await checkBadStartPagination(server.url, path, server.accessToken)
138 it('Should fail with a bad count pagination', async function () {
139 await checkBadCountPagination(server.url, path, server.accessToken)
142 it('Should fail with an incorrect sort', async function () {
143 await checkBadSortPagination(server.url, path, server.accessToken)
146 it('Should success with the correct parameters', async function () {
147 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
151 describe('When listing video channel videos', function () {
154 before(async function () {
155 path = '/api/v1/video-channels/' + channelName + '/videos'
158 it('Should fail with a bad start pagination', async function () {
159 await checkBadStartPagination(server.url, path, server.accessToken)
162 it('Should fail with a bad count pagination', async function () {
163 await checkBadCountPagination(server.url, path, server.accessToken)
166 it('Should fail with an incorrect sort', async function () {
167 await checkBadSortPagination(server.url, path, server.accessToken)
170 it('Should success with the correct parameters', async function () {
171 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
175 describe('When adding a video', function () {
176 let baseCorrectParams
177 const baseCorrectAttaches = {
178 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
182 // Put in before to have channelId
183 baseCorrectParams = {
184 name: 'my super name',
189 commentsEnabled: true,
190 downloadEnabled: true,
191 waitTranscoding: true,
192 description: 'my super description',
193 support: 'my super support text',
194 tags: [ 'tag1', 'tag2' ],
195 privacy: VideoPrivacy.PUBLIC,
196 channelId: channelId,
197 originallyPublishedAt: new Date().toISOString()
201 function runSuite (mode: 'legacy' | 'resumable') {
203 it('Should fail with nothing', async function () {
206 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
209 it('Should fail without name', async function () {
210 const fields = omit(baseCorrectParams, 'name')
211 const attaches = baseCorrectAttaches
213 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
216 it('Should fail with a long name', async function () {
217 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
218 const attaches = baseCorrectAttaches
220 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
223 it('Should fail with a bad category', async function () {
224 const fields = { ...baseCorrectParams, category: 125 }
225 const attaches = baseCorrectAttaches
227 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
230 it('Should fail with a bad licence', async function () {
231 const fields = { ...baseCorrectParams, licence: 125 }
232 const attaches = baseCorrectAttaches
234 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
237 it('Should fail with a bad language', async function () {
238 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
239 const attaches = baseCorrectAttaches
241 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
244 it('Should fail with a long description', async function () {
245 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
246 const attaches = baseCorrectAttaches
248 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
251 it('Should fail with a long support text', async function () {
252 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
253 const attaches = baseCorrectAttaches
255 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
258 it('Should fail without a channel', async function () {
259 const fields = omit(baseCorrectParams, 'channelId')
260 const attaches = baseCorrectAttaches
262 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
265 it('Should fail with a bad channel', async function () {
266 const fields = { ...baseCorrectParams, channelId: 545454 }
267 const attaches = baseCorrectAttaches
269 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
272 it('Should fail with another user channel', async function () {
274 username: 'fake' + randomInt(0, 1500),
275 password: 'fake_password'
277 await server.users.create({ username: user.username, password: user.password })
279 const accessTokenUser = await server.login.getAccessToken(user)
280 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
281 const customChannelId = videoChannels[0].id
283 const fields = { ...baseCorrectParams, channelId: customChannelId }
284 const attaches = baseCorrectAttaches
286 await checkUploadVideoParam(server, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
289 it('Should fail with too many tags', async function () {
290 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
291 const attaches = baseCorrectAttaches
293 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
296 it('Should fail with a tag length too low', async function () {
297 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
298 const attaches = baseCorrectAttaches
300 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
303 it('Should fail with a tag length too big', async function () {
304 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
305 const attaches = baseCorrectAttaches
307 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
310 it('Should fail with a bad schedule update (miss updateAt)', async function () {
311 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
312 const attaches = baseCorrectAttaches
314 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
317 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
319 ...baseCorrectParams,
322 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 originally published at attribute', async function () {
332 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
333 const attaches = baseCorrectAttaches
335 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
338 it('Should fail without an input file', async function () {
339 const fields = baseCorrectParams
341 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
344 it('Should fail with an incorrect input file', async function () {
345 const fields = baseCorrectParams
346 let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }
348 await checkUploadVideoParam(
351 { ...fields, ...attaches },
352 HttpStatusCode.UNPROCESSABLE_ENTITY_422,
356 attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') }
357 await checkUploadVideoParam(
360 { ...fields, ...attaches },
361 HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415,
366 it('Should fail with an incorrect thumbnail file', async function () {
367 const fields = baseCorrectParams
369 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
370 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
373 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
376 it('Should fail with a big thumbnail file', async function () {
377 const fields = baseCorrectParams
379 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
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 an incorrect preview file', async function () {
387 const fields = baseCorrectParams
389 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
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 a big preview file', async function () {
397 const fields = baseCorrectParams
399 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
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 report the appropriate error', async function () {
407 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
408 const attaches = baseCorrectAttaches
410 const attributes = { ...fields, ...attaches }
411 const body = await checkUploadVideoParam(server, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode)
413 const error = body as unknown as PeerTubeProblemDocument
415 if (mode === 'legacy') {
416 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy')
418 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit')
421 expect(error.type).to.equal('about:blank')
422 expect(error.title).to.equal('Bad Request')
424 expect(error.detail).to.equal('Incorrect request parameters: language')
425 expect(error.error).to.equal('Incorrect request parameters: language')
427 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
428 expect(error['invalid-params'].language).to.exist
431 it('Should succeed with the correct parameters', async function () {
434 const fields = baseCorrectParams
437 const attaches = baseCorrectAttaches
438 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
443 ...baseCorrectAttaches,
445 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
448 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
453 ...baseCorrectAttaches,
455 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
458 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
463 describe('Resumable upload', function () {
464 runSuite('resumable')
467 describe('Legacy upload', function () {
472 describe('When updating a video', function () {
473 const baseCorrectParams = {
474 name: 'my super name',
479 commentsEnabled: false,
480 downloadEnabled: false,
481 description: 'my super description',
482 privacy: VideoPrivacy.PUBLIC,
483 tags: [ 'tag1', 'tag2' ]
486 before(async function () {
487 const { data } = await server.videos.list()
491 it('Should fail with nothing', async function () {
493 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
496 it('Should fail without a valid uuid', async function () {
497 const fields = baseCorrectParams
498 await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields })
501 it('Should fail with an unknown id', async function () {
502 const fields = baseCorrectParams
504 await makePutBodyRequest({
506 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
507 token: server.accessToken,
509 expectedStatus: HttpStatusCode.NOT_FOUND_404
513 it('Should fail with a long name', async function () {
514 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
516 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
519 it('Should fail with a bad category', async function () {
520 const fields = { ...baseCorrectParams, category: 125 }
522 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
525 it('Should fail with a bad licence', async function () {
526 const fields = { ...baseCorrectParams, licence: 125 }
528 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
531 it('Should fail with a bad language', async function () {
532 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
534 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
537 it('Should fail with a long description', async function () {
538 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
540 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
543 it('Should fail with a long support text', async function () {
544 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
546 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
549 it('Should fail with a bad channel', async function () {
550 const fields = { ...baseCorrectParams, channelId: 545454 }
552 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
555 it('Should fail with too many tags', async function () {
556 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
558 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
561 it('Should fail with a tag length too low', async function () {
562 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
564 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
567 it('Should fail with a tag length too big', async function () {
568 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
570 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
573 it('Should fail with a bad schedule update (miss updateAt)', async function () {
574 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
576 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
579 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
580 const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }
582 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
585 it('Should fail with a bad originally published at param', async function () {
586 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
588 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
591 it('Should fail with an incorrect thumbnail file', async function () {
592 const fields = baseCorrectParams
594 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
597 await makeUploadRequest({
600 path: path + video.shortUUID,
601 token: server.accessToken,
607 it('Should fail with a big thumbnail file', async function () {
608 const fields = baseCorrectParams
610 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
613 await makeUploadRequest({
616 path: path + video.shortUUID,
617 token: server.accessToken,
623 it('Should fail with an incorrect preview file', async function () {
624 const fields = baseCorrectParams
626 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
629 await makeUploadRequest({
632 path: path + video.shortUUID,
633 token: server.accessToken,
639 it('Should fail with a big preview file', async function () {
640 const fields = baseCorrectParams
642 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
645 await makeUploadRequest({
648 path: path + video.shortUUID,
649 token: server.accessToken,
655 it('Should fail with a video of another user without the appropriate right', async function () {
656 const fields = baseCorrectParams
658 await makePutBodyRequest({
660 path: path + video.shortUUID,
661 token: userAccessToken,
663 expectedStatus: HttpStatusCode.FORBIDDEN_403
667 it('Should fail with a video of another server')
669 it('Shoud report the appropriate error', async function () {
670 const fields = { ...baseCorrectParams, licence: 125 }
672 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
673 const error = res.body as PeerTubeProblemDocument
675 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo')
677 expect(error.type).to.equal('about:blank')
678 expect(error.title).to.equal('Bad Request')
680 expect(error.detail).to.equal('Incorrect request parameters: licence')
681 expect(error.error).to.equal('Incorrect request parameters: licence')
683 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
684 expect(error['invalid-params'].licence).to.exist
687 it('Should succeed with the correct parameters', async function () {
688 const fields = baseCorrectParams
690 await makePutBodyRequest({
692 path: path + video.shortUUID,
693 token: server.accessToken,
695 expectedStatus: HttpStatusCode.NO_CONTENT_204
700 describe('When getting a video', function () {
701 it('Should return the list of the videos with nothing', async function () {
702 const res = await makeGetRequest({
705 expectedStatus: HttpStatusCode.OK_200
708 expect(res.body.data).to.be.an('array')
709 expect(res.body.data.length).to.equal(6)
712 it('Should fail without a correct uuid', async function () {
713 await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
716 it('Should return 404 with an incorrect video', async function () {
717 await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
720 it('Shoud report the appropriate error', async function () {
721 const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
722 const error = body as unknown as PeerTubeProblemDocument
724 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
726 expect(error.type).to.equal('about:blank')
727 expect(error.title).to.equal('Bad Request')
729 expect(error.detail).to.equal('Incorrect request parameters: id')
730 expect(error.error).to.equal('Incorrect request parameters: id')
732 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
733 expect(error['invalid-params'].id).to.exist
736 it('Should succeed with the correct parameters', async function () {
737 await server.videos.get({ id: video.shortUUID })
741 describe('When rating a video', function () {
744 before(async function () {
745 const { data } = await server.videos.list()
749 it('Should fail without a valid uuid', async function () {
753 await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields })
756 it('Should fail with an unknown id', async function () {
760 await makePutBodyRequest({
762 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
763 token: server.accessToken,
765 expectedStatus: HttpStatusCode.NOT_FOUND_404
769 it('Should fail with a wrong rating', async function () {
773 await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields })
776 it('Should succeed with the correct parameters', async function () {
780 await makePutBodyRequest({
782 path: path + videoId + '/rate',
783 token: server.accessToken,
785 expectedStatus: HttpStatusCode.NO_CONTENT_204
790 describe('When removing a video', function () {
791 it('Should have 404 with nothing', async function () {
792 await makeDeleteRequest({
795 expectedStatus: HttpStatusCode.BAD_REQUEST_400
799 it('Should fail without a correct uuid', async function () {
800 await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
803 it('Should fail with a video which does not exist', async function () {
804 await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
807 it('Should fail with a video of another user without the appropriate right', async function () {
808 await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
811 it('Should fail with a video of another server')
813 it('Shoud report the appropriate error', async function () {
814 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
815 const error = body as PeerTubeProblemDocument
817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
819 expect(error.type).to.equal('about:blank')
820 expect(error.title).to.equal('Bad Request')
822 expect(error.detail).to.equal('Incorrect request parameters: id')
823 expect(error.error).to.equal('Incorrect request parameters: id')
825 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
826 expect(error['invalid-params'].id).to.exist
829 it('Should succeed with the correct parameters', async function () {
830 await server.videos.remove({ id: video.uuid })
834 after(async function () {
835 await cleanupTests([ server ])