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'
8 import { PeerTubeProblemDocument, VideoCreateResult } from '@shared/models'
9 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
11 checkUploadVideoParam,
25 setAccessTokensToServers
26 } from '../../../../shared/extra-utils'
28 checkBadCountPagination,
29 checkBadSortPagination,
30 checkBadStartPagination
31 } from '../../../../shared/extra-utils/requests/check-api-params'
32 import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
34 const expect = chai.expect
36 describe('Test videos API validator', function () {
37 const path = '/api/v1/videos/'
38 let server: ServerInfo
39 let userAccessToken = ''
40 let accountName: string
42 let channelName: string
43 let video: VideoCreateResult
45 // ---------------------------------------------------------------
47 before(async function () {
50 server = await flushAndRunServer(1)
52 await setAccessTokensToServers([ server ])
54 const username = 'user1'
55 const password = 'my super password'
56 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
57 userAccessToken = await server.loginCommand.getAccessToken({ username, password })
60 const res = await getMyUserInformation(server.url, server.accessToken)
61 channelId = res.body.videoChannels[0].id
62 channelName = res.body.videoChannels[0].name
63 accountName = res.body.account.name + '@' + res.body.account.host
67 describe('When listing videos', function () {
68 it('Should fail with a bad start pagination', async function () {
69 await checkBadStartPagination(server.url, path)
72 it('Should fail with a bad count pagination', async function () {
73 await checkBadCountPagination(server.url, path)
76 it('Should fail with an incorrect sort', async function () {
77 await checkBadSortPagination(server.url, path)
80 it('Should fail with a bad skipVideos query', async function () {
81 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
84 it('Should success with the correct parameters', async function () {
85 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } })
89 describe('When searching a video', function () {
91 it('Should fail with nothing', async function () {
92 await makeGetRequest({
94 path: join(path, 'search'),
95 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
99 it('Should fail with a bad start pagination', async function () {
100 await checkBadStartPagination(server.url, join(path, 'search', 'test'))
103 it('Should fail with a bad count pagination', async function () {
104 await checkBadCountPagination(server.url, join(path, 'search', 'test'))
107 it('Should fail with an incorrect sort', async function () {
108 await checkBadSortPagination(server.url, join(path, 'search', 'test'))
111 it('Should success with the correct parameters', async function () {
112 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
116 describe('When listing my videos', function () {
117 const path = '/api/v1/users/me/videos'
119 it('Should fail with a bad start pagination', async function () {
120 await checkBadStartPagination(server.url, path, server.accessToken)
123 it('Should fail with a bad count pagination', async function () {
124 await checkBadCountPagination(server.url, path, server.accessToken)
127 it('Should fail with an incorrect sort', async function () {
128 await checkBadSortPagination(server.url, path, server.accessToken)
131 it('Should success with the correct parameters', async function () {
132 await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 })
136 describe('When listing account videos', function () {
139 before(async function () {
140 path = '/api/v1/accounts/' + accountName + '/videos'
143 it('Should fail with a bad start pagination', async function () {
144 await checkBadStartPagination(server.url, path, server.accessToken)
147 it('Should fail with a bad count pagination', async function () {
148 await checkBadCountPagination(server.url, path, server.accessToken)
151 it('Should fail with an incorrect sort', async function () {
152 await checkBadSortPagination(server.url, path, server.accessToken)
155 it('Should success with the correct parameters', async function () {
156 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
160 describe('When listing video channel videos', function () {
163 before(async function () {
164 path = '/api/v1/video-channels/' + channelName + '/videos'
167 it('Should fail with a bad start pagination', async function () {
168 await checkBadStartPagination(server.url, path, server.accessToken)
171 it('Should fail with a bad count pagination', async function () {
172 await checkBadCountPagination(server.url, path, server.accessToken)
175 it('Should fail with an incorrect sort', async function () {
176 await checkBadSortPagination(server.url, path, server.accessToken)
179 it('Should success with the correct parameters', async function () {
180 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
184 describe('When adding a video', function () {
185 let baseCorrectParams
186 const baseCorrectAttaches = {
187 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
191 // Put in before to have channelId
192 baseCorrectParams = {
193 name: 'my super name',
198 commentsEnabled: true,
199 downloadEnabled: true,
200 waitTranscoding: true,
201 description: 'my super description',
202 support: 'my super support text',
203 tags: [ 'tag1', 'tag2' ],
204 privacy: VideoPrivacy.PUBLIC,
205 channelId: channelId,
206 originallyPublishedAt: new Date().toISOString()
210 function runSuite (mode: 'legacy' | 'resumable') {
212 it('Should fail with nothing', async function () {
215 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
218 it('Should fail without name', async function () {
219 const fields = omit(baseCorrectParams, 'name')
220 const attaches = baseCorrectAttaches
222 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
225 it('Should fail with a long name', async function () {
226 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
227 const attaches = baseCorrectAttaches
229 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
232 it('Should fail with a bad category', async function () {
233 const fields = { ...baseCorrectParams, category: 125 }
234 const attaches = baseCorrectAttaches
236 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
239 it('Should fail with a bad licence', async function () {
240 const fields = { ...baseCorrectParams, licence: 125 }
241 const attaches = baseCorrectAttaches
243 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
246 it('Should fail with a bad language', async function () {
247 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
248 const attaches = baseCorrectAttaches
250 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
253 it('Should fail with a long description', async function () {
254 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
255 const attaches = baseCorrectAttaches
257 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
260 it('Should fail with a long support text', async function () {
261 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
262 const attaches = baseCorrectAttaches
264 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
267 it('Should fail without a channel', async function () {
268 const fields = omit(baseCorrectParams, 'channelId')
269 const attaches = baseCorrectAttaches
271 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
274 it('Should fail with a bad channel', async function () {
275 const fields = { ...baseCorrectParams, channelId: 545454 }
276 const attaches = baseCorrectAttaches
278 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
281 it('Should fail with another user channel', async function () {
283 username: 'fake' + randomInt(0, 1500),
284 password: 'fake_password'
286 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
288 const accessTokenUser = await server.loginCommand.getAccessToken(user)
289 const res = await getMyUserInformation(server.url, accessTokenUser)
290 const customChannelId = res.body.videoChannels[0].id
292 const fields = { ...baseCorrectParams, channelId: customChannelId }
293 const attaches = baseCorrectAttaches
295 await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
298 it('Should fail with too many tags', async function () {
299 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
300 const attaches = baseCorrectAttaches
302 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
305 it('Should fail with a tag length too low', async function () {
306 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
307 const attaches = baseCorrectAttaches
309 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
312 it('Should fail with a tag length too big', async function () {
313 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
314 const attaches = baseCorrectAttaches
316 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
319 it('Should fail with a bad schedule update (miss updateAt)', async function () {
320 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
321 const attaches = baseCorrectAttaches
323 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
326 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
328 ...baseCorrectParams,
331 privacy: VideoPrivacy.PUBLIC,
335 const attaches = baseCorrectAttaches
337 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
340 it('Should fail with a bad originally published at attribute', async function () {
341 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
342 const attaches = baseCorrectAttaches
344 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
347 it('Should fail without an input file', async function () {
348 const fields = baseCorrectParams
350 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
353 it('Should fail with an incorrect input file', async function () {
354 const fields = baseCorrectParams
355 let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }
357 await checkUploadVideoParam(
360 { ...fields, ...attaches },
361 HttpStatusCode.UNPROCESSABLE_ENTITY_422,
365 attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') }
366 await checkUploadVideoParam(
369 { ...fields, ...attaches },
370 HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415,
375 it('Should fail with an incorrect thumbnail file', async function () {
376 const fields = baseCorrectParams
378 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
379 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
382 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
385 it('Should fail with a big thumbnail file', async function () {
386 const fields = baseCorrectParams
388 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
389 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
392 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
395 it('Should fail with an incorrect preview file', async function () {
396 const fields = baseCorrectParams
398 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
399 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
402 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
405 it('Should fail with a big preview file', async function () {
406 const fields = baseCorrectParams
408 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
409 fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
412 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
415 it('Should report the appropriate error', async function () {
416 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
417 const attaches = baseCorrectAttaches
419 const attributes = { ...fields, ...attaches }
420 const res = await checkUploadVideoParam(server.url, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode)
422 const error = res.body as PeerTubeProblemDocument
424 if (mode === 'legacy') {
425 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy')
427 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit')
430 expect(error.type).to.equal('about:blank')
431 expect(error.title).to.equal('Bad Request')
433 expect(error.detail).to.equal('Incorrect request parameters: language')
434 expect(error.error).to.equal('Incorrect request parameters: language')
436 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
437 expect(error['invalid-params'].language).to.exist
440 it('Should succeed with the correct parameters', async function () {
443 const fields = baseCorrectParams
446 const attaches = baseCorrectAttaches
447 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
452 ...baseCorrectAttaches,
454 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
457 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
462 ...baseCorrectAttaches,
464 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
467 await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
472 describe('Resumable upload', function () {
473 runSuite('resumable')
476 describe('Legacy upload', function () {
481 describe('When updating a video', function () {
482 const baseCorrectParams = {
483 name: 'my super name',
488 commentsEnabled: false,
489 downloadEnabled: false,
490 description: 'my super description',
491 privacy: VideoPrivacy.PUBLIC,
492 tags: [ 'tag1', 'tag2' ]
495 before(async function () {
496 const res = await getVideosList(server.url)
497 video = res.body.data[0]
500 it('Should fail with nothing', async function () {
502 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
505 it('Should fail without a valid uuid', async function () {
506 const fields = baseCorrectParams
507 await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields })
510 it('Should fail with an unknown id', async function () {
511 const fields = baseCorrectParams
513 await makePutBodyRequest({
515 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
516 token: server.accessToken,
518 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
522 it('Should fail with a long name', async function () {
523 const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
525 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
528 it('Should fail with a bad category', async function () {
529 const fields = { ...baseCorrectParams, category: 125 }
531 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
534 it('Should fail with a bad licence', async function () {
535 const fields = { ...baseCorrectParams, licence: 125 }
537 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
540 it('Should fail with a bad language', async function () {
541 const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
543 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
546 it('Should fail with a long description', async function () {
547 const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
549 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
552 it('Should fail with a long support text', async function () {
553 const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
555 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
558 it('Should fail with a bad channel', async function () {
559 const fields = { ...baseCorrectParams, channelId: 545454 }
561 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
564 it('Should fail with too many tags', async function () {
565 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
567 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
570 it('Should fail with a tag length too low', async function () {
571 const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
573 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
576 it('Should fail with a tag length too big', async function () {
577 const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
579 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
582 it('Should fail with a bad schedule update (miss updateAt)', async function () {
583 const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
585 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
588 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
589 const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }
591 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
594 it('Should fail with a bad originally published at param', async function () {
595 const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
597 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
600 it('Should fail with an incorrect thumbnail file', async function () {
601 const fields = baseCorrectParams
603 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
606 await makeUploadRequest({
609 path: path + video.shortUUID,
610 token: server.accessToken,
616 it('Should fail with a big thumbnail file', async function () {
617 const fields = baseCorrectParams
619 thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
622 await makeUploadRequest({
625 path: path + video.shortUUID,
626 token: server.accessToken,
632 it('Should fail with an incorrect preview file', async function () {
633 const fields = baseCorrectParams
635 previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
638 await makeUploadRequest({
641 path: path + video.shortUUID,
642 token: server.accessToken,
648 it('Should fail with a big preview file', async function () {
649 const fields = baseCorrectParams
651 previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png')
654 await makeUploadRequest({
657 path: path + video.shortUUID,
658 token: server.accessToken,
664 it('Should fail with a video of another user without the appropriate right', async function () {
665 const fields = baseCorrectParams
667 await makePutBodyRequest({
669 path: path + video.shortUUID,
670 token: userAccessToken,
672 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
676 it('Should fail with a video of another server')
678 it('Shoud report the appropriate error', async function () {
679 const fields = { ...baseCorrectParams, licence: 125 }
681 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
682 const error = res.body as PeerTubeProblemDocument
684 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo')
686 expect(error.type).to.equal('about:blank')
687 expect(error.title).to.equal('Bad Request')
689 expect(error.detail).to.equal('Incorrect request parameters: licence')
690 expect(error.error).to.equal('Incorrect request parameters: licence')
692 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
693 expect(error['invalid-params'].licence).to.exist
696 it('Should succeed with the correct parameters', async function () {
697 const fields = baseCorrectParams
699 await makePutBodyRequest({
701 path: path + video.shortUUID,
702 token: server.accessToken,
704 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
709 describe('When getting a video', function () {
710 it('Should return the list of the videos with nothing', async function () {
711 const res = await makeGetRequest({
714 statusCodeExpected: HttpStatusCode.OK_200
717 expect(res.body.data).to.be.an('array')
718 expect(res.body.data.length).to.equal(6)
721 it('Should fail without a correct uuid', async function () {
722 await getVideo(server.url, 'coucou', HttpStatusCode.BAD_REQUEST_400)
725 it('Should return 404 with an incorrect video', async function () {
726 await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404)
729 it('Shoud report the appropriate error', async function () {
730 const res = await getVideo(server.url, 'hi', HttpStatusCode.BAD_REQUEST_400)
731 const error = res.body as PeerTubeProblemDocument
733 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
735 expect(error.type).to.equal('about:blank')
736 expect(error.title).to.equal('Bad Request')
738 expect(error.detail).to.equal('Incorrect request parameters: id')
739 expect(error.error).to.equal('Incorrect request parameters: id')
741 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
742 expect(error['invalid-params'].id).to.exist
745 it('Should succeed with the correct parameters', async function () {
746 await getVideo(server.url, video.shortUUID)
750 describe('When rating a video', function () {
753 before(async function () {
754 const res = await getVideosList(server.url)
755 videoId = res.body.data[0].id
758 it('Should fail without a valid uuid', async function () {
762 await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields })
765 it('Should fail with an unknown id', async function () {
769 await makePutBodyRequest({
771 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
772 token: server.accessToken,
774 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
778 it('Should fail with a wrong rating', async function () {
782 await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields })
785 it('Should succeed with the correct parameters', async function () {
789 await makePutBodyRequest({
791 path: path + videoId + '/rate',
792 token: server.accessToken,
794 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
799 describe('When removing a video', function () {
800 it('Should have 404 with nothing', async function () {
801 await makeDeleteRequest({
804 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
808 it('Should fail without a correct uuid', async function () {
809 await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400)
812 it('Should fail with a video which does not exist', async function () {
813 await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404)
816 it('Should fail with a video of another user without the appropriate right', async function () {
817 await removeVideo(server.url, userAccessToken, video.uuid, HttpStatusCode.FORBIDDEN_403)
820 it('Should fail with a video of another server')
822 it('Shoud report the appropriate error', async function () {
823 const res = await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400)
824 const error = res.body as PeerTubeProblemDocument
826 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
828 expect(error.type).to.equal('about:blank')
829 expect(error.title).to.equal('Bad Request')
831 expect(error.detail).to.equal('Incorrect request parameters: id')
832 expect(error.error).to.equal('Incorrect request parameters: id')
834 expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
835 expect(error['invalid-params'].id).to.exist
838 it('Should succeed with the correct parameters', async function () {
839 await removeVideo(server.url, server.accessToken, video.uuid)
843 after(async function () {
844 await cleanupTests([ server ])