1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
4 import { join } from 'path'
5 import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared'
6 import { omit, randomInt, root } from '@shared/core-utils'
7 import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
16 setAccessTokensToServers
17 } from '@shared/server-commands'
19 describe('Test videos API validator', function () {
20 const path = '/api/v1/videos/'
21 let server: PeerTubeServer
22 let userAccessToken = ''
23 let accountName: string
25 let channelName: string
26 let video: VideoCreateResult
27 let privateVideo: VideoCreateResult
29 // ---------------------------------------------------------------
31 before(async function () {
34 server = await createSingleServer(1)
36 await setAccessTokensToServers([ server ])
38 userAccessToken = await server.users.generateUserAndToken('user1')
41 const body = await server.users.getMyInfo()
42 channelId = body.videoChannels[0].id
43 channelName = body.videoChannels[0].name
44 accountName = body.account.name + '@' + body.account.host
48 privateVideo = await server.videos.quickUpload({ name: 'private video', privacy: VideoPrivacy.PRIVATE })
52 describe('When listing videos', function () {
53 it('Should fail with a bad start pagination', async function () {
54 await checkBadStartPagination(server.url, path)
57 it('Should fail with a bad count pagination', async function () {
58 await checkBadCountPagination(server.url, path)
61 it('Should fail with an incorrect sort', async function () {
62 await checkBadSortPagination(server.url, path)
65 it('Should fail with a bad skipVideos query', async function () {
66 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
69 it('Should success with the correct parameters', async function () {
70 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } })
74 describe('When searching a video', function () {
76 it('Should fail with nothing', async function () {
77 await makeGetRequest({
79 path: join(path, 'search'),
80 expectedStatus: HttpStatusCode.BAD_REQUEST_400
84 it('Should fail with a bad start pagination', async function () {
85 await checkBadStartPagination(server.url, join(path, 'search', 'test'))
88 it('Should fail with a bad count pagination', async function () {
89 await checkBadCountPagination(server.url, join(path, 'search', 'test'))
92 it('Should fail with an incorrect sort', async function () {
93 await checkBadSortPagination(server.url, join(path, 'search', 'test'))
96 it('Should success with the correct parameters', async function () {
97 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
101 describe('When listing my videos', function () {
102 const path = '/api/v1/users/me/videos'
104 it('Should fail with a bad start pagination', async function () {
105 await checkBadStartPagination(server.url, path, server.accessToken)
108 it('Should fail with a bad count pagination', async function () {
109 await checkBadCountPagination(server.url, path, server.accessToken)
112 it('Should fail with an incorrect sort', async function () {
113 await checkBadSortPagination(server.url, path, server.accessToken)
116 it('Should fail with an invalid channel', async function () {
117 await makeGetRequest({ url: server.url, token: server.accessToken, path, query: { channelId: 'toto' } })
120 it('Should fail with an unknown channel', async function () {
121 await makeGetRequest({
123 token: server.accessToken,
125 query: { channelId: 89898 },
126 expectedStatus: HttpStatusCode.NOT_FOUND_404
130 it('Should success with the correct parameters', async function () {
131 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
135 describe('When listing account videos', function () {
138 before(async function () {
139 path = '/api/v1/accounts/' + accountName + '/videos'
142 it('Should fail with a bad start pagination', async function () {
143 await checkBadStartPagination(server.url, path, server.accessToken)
146 it('Should fail with a bad count pagination', async function () {
147 await checkBadCountPagination(server.url, path, server.accessToken)
150 it('Should fail with an incorrect sort', async function () {
151 await checkBadSortPagination(server.url, path, server.accessToken)
154 it('Should success with the correct parameters', async function () {
155 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
159 describe('When listing video channel videos', function () {
162 before(async function () {
163 path = '/api/v1/video-channels/' + channelName + '/videos'
166 it('Should fail with a bad start pagination', async function () {
167 await checkBadStartPagination(server.url, path, server.accessToken)
170 it('Should fail with a bad count pagination', async function () {
171 await checkBadCountPagination(server.url, path, server.accessToken)
174 it('Should fail with an incorrect sort', async function () {
175 await checkBadSortPagination(server.url, path, server.accessToken)
178 it('Should success with the correct parameters', async function () {
179 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
183 describe('When adding a video', function () {
184 let baseCorrectParams
185 const baseCorrectAttaches = {
186 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
190 // Put in before to have channelId
191 baseCorrectParams = {
192 name: 'my super name',
197 commentsEnabled: true,
198 downloadEnabled: true,
199 waitTranscoding: true,
200 description: 'my super description',
201 support: 'my super support text',
202 tags: [ 'tag1', 'tag2' ],
203 privacy: VideoPrivacy.PUBLIC,
205 originallyPublishedAt: new Date().toISOString()
209 function runSuite (mode: 'legacy' | 'resumable') {
211 it('Should fail with nothing', async function () {
214 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
217 it('Should fail without name', async function () {
218 const fields = omit(baseCorrectParams, [ 'name' ])
219 const attaches = baseCorrectAttaches
221 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
224 it('Should fail with a long name', async function () {
225 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
226 const attaches = baseCorrectAttaches
228 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
231 it('Should fail with a bad category', async function () {
232 const fields = { ...baseCorrectParams, category: 125 }
233 const attaches = baseCorrectAttaches
235 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
238 it('Should fail with a bad licence', async function () {
239 const fields = { ...baseCorrectParams, licence: 125 }
240 const attaches = baseCorrectAttaches
242 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
245 it('Should fail with a bad language', async function () {
246 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
247 const attaches = baseCorrectAttaches
249 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
252 it('Should fail with a long description', async function () {
253 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
254 const attaches = baseCorrectAttaches
256 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
259 it('Should fail with a long support text', async function () {
260 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
261 const attaches = baseCorrectAttaches
263 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
266 it('Should fail without a channel', async function () {
267 const fields = omit(baseCorrectParams, [ 'channelId' ])
268 const attaches = baseCorrectAttaches
270 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
273 it('Should fail with a bad channel', async function () {
274 const fields = { ...baseCorrectParams, channelId: 545454 }
275 const attaches = baseCorrectAttaches
277 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
280 it('Should fail with another user channel', async function () {
282 username: 'fake' + randomInt(0, 1500),
283 password: 'fake_password'
285 await server.users.create({ username: user.username, password: user.password })
287 const accessTokenUser = await server.login.getAccessToken(user)
288 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
289 const customChannelId = videoChannels[0].id
291 const fields = { ...baseCorrectParams, channelId: customChannelId }
292 const attaches = baseCorrectAttaches
294 await checkUploadVideoParam(server, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
297 it('Should fail with too many tags', async function () {
298 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
299 const attaches = baseCorrectAttaches
301 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
304 it('Should fail with a tag length too low', async function () {
305 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
306 const attaches = baseCorrectAttaches
308 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
311 it('Should fail with a tag length too big', async function () {
312 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
313 const attaches = baseCorrectAttaches
315 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
318 it('Should fail with a bad schedule update (miss updateAt)', async function () {
319 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
320 const attaches = baseCorrectAttaches
322 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
325 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
327 ...baseCorrectParams,
330 privacy: VideoPrivacy.PUBLIC,
334 const attaches = baseCorrectAttaches
336 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
339 it('Should fail with a bad originally published at attribute', async function () {
340 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
341 const attaches = baseCorrectAttaches
343 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
346 it('Should fail without an input file', async function () {
347 const fields = baseCorrectParams
349 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
352 it('Should fail with an incorrect input file', async function () {
353 const fields = baseCorrectParams
354 let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }
356 await checkUploadVideoParam(
359 { ...fields, ...attaches },
360 HttpStatusCode.UNPROCESSABLE_ENTITY_422,
364 attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') }
365 await checkUploadVideoParam(
368 { ...fields, ...attaches },
369 HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415,
374 it('Should fail with an incorrect thumbnail file', async function () {
375 const fields = baseCorrectParams
377 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
378 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
381 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
384 it('Should fail with a big thumbnail file', async function () {
385 const fields = baseCorrectParams
387 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
388 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
391 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
394 it('Should fail with an incorrect preview file', async function () {
395 const fields = baseCorrectParams
397 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
398 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
401 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
404 it('Should fail with a big preview file', async function () {
405 const fields = baseCorrectParams
407 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
408 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
411 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
414 it('Should report the appropriate error', async function () {
415 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
416 const attaches = baseCorrectAttaches
418 const attributes = { ...fields, ...attaches }
419 const body = await checkUploadVideoParam(server, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode)
421 const error = body as unknown as PeerTubeProblemDocument
423 if (mode === 'legacy') {
424 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy')
426 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit')
429 expect(error.type).to.equal('about:blank')
430 expect(error.title).to.equal('Bad Request')
432 expect(error.detail).to.equal('Incorrect request parameters: language')
433 expect(error.error).to.equal('Incorrect request parameters: language')
435 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
436 expect(error['invalid-params'].language).to.exist
439 it('Should succeed with the correct parameters', async function () {
442 const fields = baseCorrectParams
445 const attaches = baseCorrectAttaches
446 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
451 ...baseCorrectAttaches,
453 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
456 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
461 ...baseCorrectAttaches,
463 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
466 await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
471 describe('Resumable upload', function () {
472 runSuite('resumable')
475 describe('Legacy upload', function () {
480 describe('When updating a video', function () {
481 const baseCorrectParams = {
482 name: 'my super name',
487 commentsEnabled: false,
488 downloadEnabled: false,
489 description: 'my super description',
490 privacy: VideoPrivacy.PUBLIC,
491 tags: [ 'tag1', 'tag2' ]
494 before(async function () {
495 const { data } = await server.videos.list()
499 it('Should fail with nothing', async function () {
501 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
504 it('Should fail without a valid uuid', async function () {
505 const fields = baseCorrectParams
506 await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields })
509 it('Should fail with an unknown id', async function () {
510 const fields = baseCorrectParams
512 await makePutBodyRequest({
514 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
515 token: server.accessToken,
517 expectedStatus: HttpStatusCode.NOT_FOUND_404
521 it('Should fail with a long name', async function () {
522 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
524 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
527 it('Should fail with a bad category', async function () {
528 const fields = { ...baseCorrectParams, category: 125 }
530 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
533 it('Should fail with a bad licence', async function () {
534 const fields = { ...baseCorrectParams, licence: 125 }
536 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
539 it('Should fail with a bad language', async function () {
540 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
542 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
545 it('Should fail with a long description', async function () {
546 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
548 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
551 it('Should fail with a long support text', async function () {
552 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
554 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
557 it('Should fail with a bad channel', async function () {
558 const fields = { ...baseCorrectParams, channelId: 545454 }
560 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
563 it('Should fail with too many tags', async function () {
564 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
566 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
569 it('Should fail with a tag length too low', async function () {
570 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
572 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
575 it('Should fail with a tag length too big', async function () {
576 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
578 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
581 it('Should fail with a bad schedule update (miss updateAt)', async function () {
582 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
584 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
587 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
588 const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }
590 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
593 it('Should fail with a bad originally published at param', async function () {
594 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
596 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
599 it('Should fail with an incorrect thumbnail file', async function () {
600 const fields = baseCorrectParams
602 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
605 await makeUploadRequest({
608 path: path + video.shortUUID,
609 token: server.accessToken,
615 it('Should fail with a big thumbnail file', async function () {
616 const fields = baseCorrectParams
618 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
621 await makeUploadRequest({
624 path: path + video.shortUUID,
625 token: server.accessToken,
631 it('Should fail with an incorrect preview file', async function () {
632 const fields = baseCorrectParams
634 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
637 await makeUploadRequest({
640 path: path + video.shortUUID,
641 token: server.accessToken,
647 it('Should fail with a big preview file', async function () {
648 const fields = baseCorrectParams
650 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
653 await makeUploadRequest({
656 path: path + video.shortUUID,
657 token: server.accessToken,
663 it('Should fail with a video of another user without the appropriate right', async function () {
664 const fields = baseCorrectParams
666 await makePutBodyRequest({
668 path: path + video.shortUUID,
669 token: userAccessToken,
671 expectedStatus: HttpStatusCode.FORBIDDEN_403
675 it('Should fail with a video of another server')
677 it('Shoud report the appropriate error', async function () {
678 const fields = { ...baseCorrectParams, licence: 125 }
680 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
681 const error = res.body as PeerTubeProblemDocument
683 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo')
685 expect(error.type).to.equal('about:blank')
686 expect(error.title).to.equal('Bad Request')
688 expect(error.detail).to.equal('Incorrect request parameters: licence')
689 expect(error.error).to.equal('Incorrect request parameters: licence')
691 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
692 expect(error['invalid-params'].licence).to.exist
695 it('Should succeed with the correct parameters', async function () {
696 const fields = baseCorrectParams
698 await makePutBodyRequest({
700 path: path + video.shortUUID,
701 token: server.accessToken,
703 expectedStatus: HttpStatusCode.NO_CONTENT_204
708 describe('When getting a video', function () {
709 it('Should return the list of the videos with nothing', async function () {
710 const res = await makeGetRequest({
713 expectedStatus: HttpStatusCode.OK_200
716 expect(res.body.data).to.be.an('array')
717 expect(res.body.data.length).to.equal(6)
720 it('Should fail without a correct uuid', async function () {
721 await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
724 it('Should return 404 with an incorrect video', async function () {
725 await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
728 it('Shoud report the appropriate error', async function () {
729 const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
730 const error = body as unknown as PeerTubeProblemDocument
732 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
734 expect(error.type).to.equal('about:blank')
735 expect(error.title).to.equal('Bad Request')
737 expect(error.detail).to.equal('Incorrect request parameters: id')
738 expect(error.error).to.equal('Incorrect request parameters: id')
740 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
741 expect(error['invalid-params'].id).to.exist
744 it('Should succeed with the correct parameters', async function () {
745 await server.videos.get({ id: video.shortUUID })
749 describe('When rating a video', function () {
752 before(async function () {
753 const { data } = await server.videos.list()
757 it('Should fail without a valid uuid', async function () {
761 await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields })
764 it('Should fail with an unknown id', async function () {
768 await makePutBodyRequest({
770 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
771 token: server.accessToken,
773 expectedStatus: HttpStatusCode.NOT_FOUND_404
777 it('Should fail with a wrong rating', async function () {
781 await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields })
784 it('Should fail with a private video of another user', async function () {
788 await makePutBodyRequest({
790 path: path + privateVideo.uuid + '/rate',
791 token: userAccessToken,
793 expectedStatus: HttpStatusCode.FORBIDDEN_403
797 it('Should succeed with the correct parameters', async function () {
801 await makePutBodyRequest({
803 path: path + videoId + '/rate',
804 token: server.accessToken,
806 expectedStatus: HttpStatusCode.NO_CONTENT_204
811 describe('When removing a video', function () {
812 it('Should have 404 with nothing', async function () {
813 await makeDeleteRequest({
816 expectedStatus: HttpStatusCode.BAD_REQUEST_400
820 it('Should fail without a correct uuid', async function () {
821 await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
824 it('Should fail with a video which does not exist', async function () {
825 await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
828 it('Should fail with a video of another user without the appropriate right', async function () {
829 await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
832 it('Should fail with a video of another server')
834 it('Shoud report the appropriate error', async function () {
835 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
836 const error = body as PeerTubeProblemDocument
838 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
840 expect(error.type).to.equal('about:blank')
841 expect(error.title).to.equal('Bad Request')
843 expect(error.detail).to.equal('Incorrect request parameters: id')
844 expect(error.error).to.equal('Incorrect request parameters: id')
846 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
847 expect(error['invalid-params'].id).to.exist
850 it('Should succeed with the correct parameters', async function () {
851 await server.videos.remove({ id: video.uuid })
855 after(async function () {
856 await cleanupTests([ server ])