]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/check-params/videos.ts
Fix support field validation in video edit
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / videos.ts
CommitLineData
0e1dc3e7
C
1/* tslint:disable:no-unused-expression */
2
0e1dc3e7 3import * as chai from 'chai'
11ba2ab3
C
4import { omit } from 'lodash'
5import 'mocha'
6import { join } from 'path'
7import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
0e1dc3e7 8import {
11ba2ab3 9 createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest,
ac81d1a0 10 makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin
0e1dc3e7 11} from '../../utils'
11ba2ab3
C
12import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
13
14const expect = chai.expect
0e1dc3e7
C
15
16describe('Test videos API validator', function () {
17 const path = '/api/v1/videos/'
18 let server: ServerInfo
5f04dd2f 19 let channelId: number
0e1dc3e7
C
20
21 // ---------------------------------------------------------------
22
23 before(async function () {
e212f887 24 this.timeout(30000)
0e1dc3e7
C
25
26 await flushTests()
27
28 server = await runServer(1)
29
30 await setAccessTokensToServers([ server ])
5f04dd2f
C
31
32 const res = await getMyUserInformation(server.url, server.accessToken)
33 channelId = res.body.videoChannels[0].id
0e1dc3e7
C
34 })
35
36 describe('When listing a video', function () {
37 it('Should fail with a bad start pagination', async function () {
11ba2ab3 38 await checkBadStartPagination(server.url, path)
0e1dc3e7
C
39 })
40
41 it('Should fail with a bad count pagination', async function () {
11ba2ab3 42 await checkBadCountPagination(server.url, path)
0e1dc3e7
C
43 })
44
45 it('Should fail with an incorrect sort', async function () {
11ba2ab3 46 await checkBadSortPagination(server.url, path)
0e1dc3e7
C
47 })
48 })
49
50 describe('When searching a video', function () {
11ba2ab3 51
0e1dc3e7 52 it('Should fail with nothing', async function () {
11ba2ab3
C
53 await makeGetRequest({
54 url: server.url,
55 path: join(path, 'search'),
56 statusCodeExpected: 400
57 })
0e1dc3e7
C
58 })
59
60 it('Should fail with a bad start pagination', async function () {
11ba2ab3 61 await checkBadStartPagination(server.url, join(path, 'search', 'test'))
0e1dc3e7
C
62 })
63
64 it('Should fail with a bad count pagination', async function () {
11ba2ab3 65 await checkBadCountPagination(server.url, join(path, 'search', 'test'))
0e1dc3e7
C
66 })
67
68 it('Should fail with an incorrect sort', async function () {
11ba2ab3 69 await checkBadSortPagination(server.url, join(path, 'search', 'test'))
0e1dc3e7
C
70 })
71 })
72
11474c3c
C
73 describe('When listing my videos', function () {
74 const path = '/api/v1/users/me/videos'
75
76 it('Should fail with a bad start pagination', async function () {
11ba2ab3 77 await checkBadStartPagination(server.url, path, server.accessToken)
11474c3c
C
78 })
79
80 it('Should fail with a bad count pagination', async function () {
11ba2ab3 81 await checkBadCountPagination(server.url, path, server.accessToken)
11474c3c
C
82 })
83
84 it('Should fail with an incorrect sort', async function () {
11ba2ab3 85 await checkBadSortPagination(server.url, path, server.accessToken)
11474c3c
C
86 })
87 })
88
0e1dc3e7 89 describe('When adding a video', function () {
11ba2ab3
C
90 let baseCorrectParams
91 const baseCorrectAttaches = {
92 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
93 }
94
95 before(function () {
96 // Put in before to have channelId
97 baseCorrectParams = {
98 name: 'my super name',
99 category: 5,
100 licence: 1,
101 language: 6,
102 nsfw: false,
47564bbe 103 commentsEnabled: true,
11ba2ab3 104 description: 'my super description',
2422c46b 105 support: 'my super support text',
11ba2ab3
C
106 tags: [ 'tag1', 'tag2' ],
107 privacy: VideoPrivacy.PUBLIC,
108 channelId
109 }
110 })
111
0e1dc3e7
C
112 it('Should fail with nothing', async function () {
113 const fields = {}
114 const attaches = {}
ac81d1a0 115 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
116 })
117
118 it('Should fail without name', async function () {
11ba2ab3
C
119 const fields = omit(baseCorrectParams, 'name')
120 const attaches = baseCorrectAttaches
11474c3c 121
ac81d1a0 122 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
123 })
124
125 it('Should fail with a long name', async function () {
11ba2ab3
C
126 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
127 const attaches = baseCorrectAttaches
11474c3c 128
ac81d1a0 129 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
130 })
131
0e1dc3e7 132 it('Should fail with a bad category', async function () {
11ba2ab3
C
133 const fields = immutableAssign(baseCorrectParams, { category: 125 })
134 const attaches = baseCorrectAttaches
11474c3c 135
ac81d1a0 136 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
137 })
138
0e1dc3e7 139 it('Should fail with a bad licence', async function () {
11ba2ab3
C
140 const fields = immutableAssign(baseCorrectParams, { licence: 125 })
141 const attaches = baseCorrectAttaches
11474c3c 142
ac81d1a0 143 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
144 })
145
146 it('Should fail with a bad language', async function () {
11ba2ab3
C
147 const fields = immutableAssign(baseCorrectParams, { language: 125 })
148 const attaches = baseCorrectAttaches
11474c3c 149
ac81d1a0 150 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
151 })
152
153 it('Should fail without nsfw attribute', async function () {
11ba2ab3
C
154 const fields = omit(baseCorrectParams, 'nsfw')
155 const attaches = baseCorrectAttaches
11474c3c 156
ac81d1a0 157 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
158 })
159
5f04dd2f 160 it('Should fail with a bad nsfw attribute', async function () {
11ba2ab3
C
161 const fields = immutableAssign(baseCorrectParams, { nsfw: 2 })
162 const attaches = baseCorrectAttaches
11474c3c 163
ac81d1a0 164 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
165 })
166
47564bbe
C
167 it('Should fail without commentsEnabled attribute', async function () {
168 const fields = omit(baseCorrectParams, 'commentsEnabled')
169 const attaches = baseCorrectAttaches
170
ac81d1a0 171 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
47564bbe
C
172 })
173
174 it('Should fail with a bad commentsEnabled attribute', async function () {
175 const fields = immutableAssign(baseCorrectParams, { commentsEnabled: 2 })
176 const attaches = baseCorrectAttaches
177
ac81d1a0 178 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
47564bbe
C
179 })
180
0e1dc3e7 181 it('Should fail with a long description', async function () {
2422c46b
C
182 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
183 const attaches = baseCorrectAttaches
184
185 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
186 })
187
188 it('Should fail with a long support text', async function () {
189 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) })
11ba2ab3 190 const attaches = baseCorrectAttaches
11474c3c 191
ac81d1a0 192 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
5f04dd2f
C
193 })
194
195 it('Should fail without a channel', async function () {
11ba2ab3
C
196 const fields = omit(baseCorrectParams, 'channelId')
197 const attaches = baseCorrectAttaches
11474c3c 198
ac81d1a0 199 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
200 })
201
5f04dd2f 202 it('Should fail with a bad channel', async function () {
11ba2ab3
C
203 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
204 const attaches = baseCorrectAttaches
11474c3c 205
ac81d1a0 206 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
5f04dd2f
C
207 })
208
209 it('Should fail with another user channel', async function () {
210 const user = {
211 username: 'fake',
212 password: 'fake_password'
213 }
214 await createUser(server.url, server.accessToken, user.username, user.password)
215
eec63bbc 216 const accessTokenUser = await userLogin(server, user)
5f04dd2f 217 const res = await getMyUserInformation(server.url, accessTokenUser)
11474c3c
C
218 const customChannelId = res.body.videoChannels[0].id
219
11ba2ab3
C
220 const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId })
221 const attaches = baseCorrectAttaches
11474c3c 222
ac81d1a0 223 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
5f04dd2f
C
224 })
225
0e1dc3e7 226 it('Should fail with too many tags', async function () {
11ba2ab3
C
227 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
228 const attaches = baseCorrectAttaches
11474c3c 229
ac81d1a0 230 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
231 })
232
233 it('Should fail with a tag length too low', async function () {
11ba2ab3
C
234 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
235 const attaches = baseCorrectAttaches
11474c3c 236
ac81d1a0 237 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
238 })
239
240 it('Should fail with a tag length too big', async function () {
11ba2ab3
C
241 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
242 const attaches = baseCorrectAttaches
11474c3c 243
ac81d1a0 244 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
245 })
246
247 it('Should fail without an input file', async function () {
11ba2ab3 248 const fields = baseCorrectParams
0e1dc3e7 249 const attaches = {}
ac81d1a0 250 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
251 })
252
253 it('Should fail without an incorrect input file', async function () {
11ba2ab3 254 const fields = baseCorrectParams
0e1dc3e7
C
255 const attaches = {
256 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
257 }
ac81d1a0
C
258 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
259 })
260
261 it('Should fail with an incorrect thumbnail file', async function () {
262 const fields = baseCorrectParams
263 const attaches = {
264 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar.png'),
265 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
266 }
267
268 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
269 })
270
271 it('Should fail with a big thumbnail file', async function () {
272 const fields = baseCorrectParams
273 const attaches = {
274 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar-big.png'),
275 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
276 }
277
278 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
279 })
280
281 it('Should fail with an incorrect preview file', async function () {
282 const fields = baseCorrectParams
283 const attaches = {
284 'previewfile': join(__dirname, '..', 'fixtures', 'avatar.png'),
285 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
286 }
287
288 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
289 })
290
291 it('Should fail with a big preview file', async function () {
292 const fields = baseCorrectParams
293 const attaches = {
294 'previewfile': join(__dirname, '..', 'fixtures', 'avatar-big.png'),
295 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
296 }
297
298 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
0e1dc3e7
C
299 })
300
0e1dc3e7
C
301 it('Should succeed with the correct parameters', async function () {
302 this.timeout(10000)
303
11ba2ab3
C
304 const fields = baseCorrectParams
305
306 {
307 const attaches = baseCorrectAttaches
ac81d1a0 308 await makeUploadRequest({
11ba2ab3
C
309 url: server.url,
310 path: path + '/upload',
311 token: server.accessToken,
312 fields,
313 attaches,
314 statusCodeExpected: 200
315 })
316 }
0e1dc3e7 317
11ba2ab3
C
318 {
319 const attaches = immutableAssign(baseCorrectAttaches, {
320 videofile: join(__dirname, '..', 'fixtures', 'video_short.mp4')
321 })
322
ac81d1a0 323 await makeUploadRequest({
11ba2ab3
C
324 url: server.url,
325 path: path + '/upload',
326 token: server.accessToken,
327 fields,
328 attaches,
329 statusCodeExpected: 200
330 })
331 }
0e1dc3e7 332
11ba2ab3
C
333 {
334 const attaches = immutableAssign(baseCorrectAttaches, {
335 videofile: join(__dirname, '..', 'fixtures', 'video_short.ogv')
336 })
337
ac81d1a0 338 await makeUploadRequest({
11ba2ab3
C
339 url: server.url,
340 path: path + '/upload',
341 token: server.accessToken,
342 fields,
343 attaches,
344 statusCodeExpected: 200
345 })
346 }
0e1dc3e7
C
347 })
348 })
349
350 describe('When updating a video', function () {
11ba2ab3
C
351 const baseCorrectParams = {
352 name: 'my super name',
353 category: 5,
354 licence: 2,
355 language: 6,
356 nsfw: false,
47564bbe 357 commentsEnabled: false,
11ba2ab3
C
358 description: 'my super description',
359 privacy: VideoPrivacy.PUBLIC,
360 tags: [ 'tag1', 'tag2' ]
361 }
0e1dc3e7
C
362 let videoId
363
364 before(async function () {
365 const res = await getVideosList(server.url)
366 videoId = res.body.data[0].id
367 })
368
369 it('Should fail with nothing', async function () {
370 const fields = {}
371 await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
372 })
373
374 it('Should fail without a valid uuid', async function () {
11ba2ab3 375 const fields = baseCorrectParams
0e1dc3e7
C
376 await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields })
377 })
378
379 it('Should fail with an unknown id', async function () {
11ba2ab3 380 const fields = baseCorrectParams
11474c3c 381
0e1dc3e7
C
382 await makePutBodyRequest({
383 url: server.url,
384 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
385 token: server.accessToken,
386 fields,
387 statusCodeExpected: 404
388 })
389 })
390
391 it('Should fail with a long name', async function () {
11ba2ab3 392 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
11474c3c 393
0e1dc3e7
C
394 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
395 })
396
397 it('Should fail with a bad category', async function () {
11ba2ab3 398 const fields = immutableAssign(baseCorrectParams, { category: 125 })
11474c3c 399
0e1dc3e7
C
400 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
401 })
402
403 it('Should fail with a bad licence', async function () {
11ba2ab3 404 const fields = immutableAssign(baseCorrectParams, { licence: 125 })
11474c3c 405
0e1dc3e7
C
406 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
407 })
408
409 it('Should fail with a bad language', async function () {
11ba2ab3 410 const fields = immutableAssign(baseCorrectParams, { language: 125 })
11474c3c 411
0e1dc3e7
C
412 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
413 })
414
415 it('Should fail with a bad nsfw attribute', async function () {
11ba2ab3 416 const fields = immutableAssign(baseCorrectParams, { nsfw: 2 })
11474c3c 417
0e1dc3e7
C
418 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
419 })
420
47564bbe
C
421 it('Should fail with a bad commentsEnabled attribute', async function () {
422 const fields = immutableAssign(baseCorrectParams, { commentsEnabled: 2 })
423
424 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
425 })
426
0e1dc3e7 427 it('Should fail with a long description', async function () {
2422c46b
C
428 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
429
430 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
431 })
432
433 it('Should fail with a long support text', async function () {
434 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) })
11474c3c 435
0e1dc3e7
C
436 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
437 })
438
439 it('Should fail with too many tags', async function () {
11ba2ab3 440 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
11474c3c 441
0e1dc3e7
C
442 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
443 })
444
445 it('Should fail with a tag length too low', async function () {
11ba2ab3 446 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
11474c3c 447
0e1dc3e7
C
448 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
449 })
450
451 it('Should fail with a tag length too big', async function () {
11ba2ab3 452 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
11474c3c 453
0e1dc3e7
C
454 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
455 })
456
ac81d1a0
C
457 it('Should fail with an incorrect thumbnail file', async function () {
458 const fields = baseCorrectParams
459 const attaches = {
460 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar.png')
461 }
462
463 await makeUploadRequest({
464 url: server.url,
465 method: 'PUT',
466 path: path + videoId,
467 token: server.accessToken,
468 fields,
469 attaches
470 })
471 })
472
473 it('Should fail with a big thumbnail file', async function () {
474 const fields = baseCorrectParams
475 const attaches = {
476 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar-big.png')
477 }
478
479 await makeUploadRequest({
480 url: server.url,
481 method: 'PUT',
482 path: path + videoId,
483 token: server.accessToken,
484 fields,
485 attaches
486 })
487 })
488
489 it('Should fail with an incorrect preview file', async function () {
490 const fields = baseCorrectParams
491 const attaches = {
492 'previewfile': join(__dirname, '..', 'fixtures', 'avatar.png')
493 }
494
495 await makeUploadRequest({
496 url: server.url,
497 method: 'PUT',
498 path: path + videoId,
499 token: server.accessToken,
500 fields,
501 attaches
502 })
503 })
504
505 it('Should fail with a big preview file', async function () {
506 const fields = baseCorrectParams
507 const attaches = {
508 'previewfile': join(__dirname, '..', 'fixtures', 'avatar-big.png')
509 }
510
511 await makeUploadRequest({
512 url: server.url,
513 method: 'PUT',
514 path: path + videoId,
515 token: server.accessToken,
516 fields,
517 attaches
518 })
519 })
520
0e1dc3e7
C
521 it('Should fail with a video of another user')
522
9a27cdc2 523 it('Should fail with a video of another server')
11474c3c
C
524
525 it('Should succeed with the correct parameters', async function () {
11ba2ab3 526 const fields = baseCorrectParams
11474c3c
C
527
528 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields, statusCodeExpected: 204 })
529 })
0e1dc3e7
C
530 })
531
532 describe('When getting a video', function () {
533 it('Should return the list of the videos with nothing', async function () {
11ba2ab3
C
534 const res = await makeGetRequest({
535 url: server.url,
536 path,
537 statusCodeExpected: 200
538 })
0e1dc3e7
C
539
540 expect(res.body.data).to.be.an('array')
541 expect(res.body.data.length).to.equal(3)
542 })
543
544 it('Should fail without a correct uuid', async function () {
11ba2ab3 545 await getVideo(server.url, 'coucou', 400)
0e1dc3e7
C
546 })
547
548 it('Should return 404 with an incorrect video', async function () {
11ba2ab3 549 await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
0e1dc3e7
C
550 })
551
552 it('Should succeed with the correct parameters')
553 })
554
555 describe('When rating a video', function () {
556 let videoId
557
558 before(async function () {
559 const res = await getVideosList(server.url)
560 videoId = res.body.data[0].id
561 })
562
563 it('Should fail without a valid uuid', async function () {
564 const fields = {
565 rating: 'like'
566 }
567 await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields })
568 })
569
570 it('Should fail with an unknown id', async function () {
571 const fields = {
572 rating: 'like'
573 }
574 await makePutBodyRequest({
575 url: server.url,
576 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
577 token: server.accessToken,
578 fields,
579 statusCodeExpected: 404
580 })
581 })
582
583 it('Should fail with a wrong rating', async function () {
584 const fields = {
585 rating: 'likes'
586 }
587 await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields })
588 })
589
590 it('Should succeed with the correct parameters', async function () {
591 const fields = {
592 rating: 'like'
593 }
594 await makePutBodyRequest({
595 url: server.url,
596 path: path + videoId + '/rate',
597 token: server.accessToken,
598 fields,
599 statusCodeExpected: 204
600 })
601 })
602 })
603
604 describe('When removing a video', function () {
605 it('Should have 404 with nothing', async function () {
11ba2ab3
C
606 await makeDeleteRequest({
607 url: server.url,
608 path,
609 statusCodeExpected: 400
610 })
0e1dc3e7
C
611 })
612
613 it('Should fail without a correct uuid', async function () {
11ba2ab3 614 await removeVideo(server.url, server.accessToken, 'hello', 400)
0e1dc3e7
C
615 })
616
617 it('Should fail with a video which does not exist', async function () {
11ba2ab3 618 await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
0e1dc3e7
C
619 })
620
621 it('Should fail with a video of another user')
622
9a27cdc2 623 it('Should fail with a video of another server')
0e1dc3e7
C
624
625 it('Should succeed with the correct parameters')
626 })
627
628 after(async function () {
629 killallServers([ server ])
630
631 // Keep the logs if the test failed
632 if (this['ok']) {
633 await flushTests()
634 }
635 })
636})