]>
Commit | Line | Data |
---|---|---|
1 | /* eslint-disable no-unused-expressions */ | |
2 | ||
3 | 'use strict' | |
4 | ||
5 | const chai = require('chai') | |
6 | const expect = chai.expect | |
7 | const pathUtils = require('path') | |
8 | const request = require('supertest') | |
9 | const series = require('async/series') | |
10 | ||
11 | const loginUtils = require('../../utils/login') | |
12 | const requestsUtils = require('../../utils/requests') | |
13 | const serversUtils = require('../../utils/servers') | |
14 | const videosUtils = require('../../utils/videos') | |
15 | ||
16 | describe('Test videos API validator', function () { | |
17 | const path = '/api/v1/videos/' | |
18 | let server = null | |
19 | ||
20 | // --------------------------------------------------------------- | |
21 | ||
22 | before(function (done) { | |
23 | this.timeout(20000) | |
24 | ||
25 | series([ | |
26 | function (next) { | |
27 | serversUtils.flushTests(next) | |
28 | }, | |
29 | function (next) { | |
30 | serversUtils.runServer(1, function (server1) { | |
31 | server = server1 | |
32 | ||
33 | next() | |
34 | }) | |
35 | }, | |
36 | function (next) { | |
37 | loginUtils.loginAndGetAccessToken(server, function (err, token) { | |
38 | if (err) throw err | |
39 | server.accessToken = token | |
40 | ||
41 | next() | |
42 | }) | |
43 | } | |
44 | ], done) | |
45 | }) | |
46 | ||
47 | describe('When listing a video', function () { | |
48 | it('Should fail with a bad start pagination', function (done) { | |
49 | request(server.url) | |
50 | .get(path) | |
51 | .query({ start: 'hello' }) | |
52 | .set('Accept', 'application/json') | |
53 | .expect(400, done) | |
54 | }) | |
55 | ||
56 | it('Should fail with a bad count pagination', function (done) { | |
57 | request(server.url) | |
58 | .get(path) | |
59 | .query({ count: 'hello' }) | |
60 | .set('Accept', 'application/json') | |
61 | .expect(400, done) | |
62 | }) | |
63 | ||
64 | it('Should fail with an incorrect sort', function (done) { | |
65 | request(server.url) | |
66 | .get(path) | |
67 | .query({ sort: 'hello' }) | |
68 | .set('Accept', 'application/json') | |
69 | .expect(400, done) | |
70 | }) | |
71 | }) | |
72 | ||
73 | describe('When searching a video', function () { | |
74 | it('Should fail with nothing', function (done) { | |
75 | request(server.url) | |
76 | .get(pathUtils.join(path, 'search')) | |
77 | .set('Accept', 'application/json') | |
78 | .expect(400, done) | |
79 | }) | |
80 | ||
81 | it('Should fail with a bad start pagination', function (done) { | |
82 | request(server.url) | |
83 | .get(pathUtils.join(path, 'search', 'test')) | |
84 | .query({ start: 'hello' }) | |
85 | .set('Accept', 'application/json') | |
86 | .expect(400, done) | |
87 | }) | |
88 | ||
89 | it('Should fail with a bad count pagination', function (done) { | |
90 | request(server.url) | |
91 | .get(pathUtils.join(path, 'search', 'test')) | |
92 | .query({ count: 'hello' }) | |
93 | .set('Accept', 'application/json') | |
94 | .expect(400, done) | |
95 | }) | |
96 | ||
97 | it('Should fail with an incorrect sort', function (done) { | |
98 | request(server.url) | |
99 | .get(pathUtils.join(path, 'search', 'test')) | |
100 | .query({ sort: 'hello' }) | |
101 | .set('Accept', 'application/json') | |
102 | .expect(400, done) | |
103 | }) | |
104 | }) | |
105 | ||
106 | describe('When adding a video', function () { | |
107 | it('Should fail with nothing', function (done) { | |
108 | const data = {} | |
109 | const attach = {} | |
110 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
111 | }) | |
112 | ||
113 | it('Should fail without name', function (done) { | |
114 | const data = { | |
115 | category: 5, | |
116 | licence: 1, | |
117 | language: 6, | |
118 | nsfw: false, | |
119 | description: 'my super description', | |
120 | tags: [ 'tag1', 'tag2' ] | |
121 | } | |
122 | const attach = { | |
123 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
124 | } | |
125 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
126 | }) | |
127 | ||
128 | it('Should fail with a long name', function (done) { | |
129 | const data = { | |
130 | name: 'My very very very very very very very very very very very very very very very very long name', | |
131 | category: 5, | |
132 | licence: 1, | |
133 | language: 6, | |
134 | nsfw: false, | |
135 | description: 'my super description', | |
136 | tags: [ 'tag1', 'tag2' ] | |
137 | } | |
138 | const attach = { | |
139 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
140 | } | |
141 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
142 | }) | |
143 | ||
144 | it('Should fail without a category', function (done) { | |
145 | const data = { | |
146 | name: 'my super name', | |
147 | licence: 1, | |
148 | language: 6, | |
149 | nsfw: false, | |
150 | description: 'my super description', | |
151 | tags: [ 'tag1', 'tag2' ] | |
152 | } | |
153 | const attach = { | |
154 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
155 | } | |
156 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
157 | }) | |
158 | ||
159 | it('Should fail with a bad category', function (done) { | |
160 | const data = { | |
161 | name: 'my super name', | |
162 | category: 125, | |
163 | licence: 1, | |
164 | language: 6, | |
165 | nsfw: false, | |
166 | description: 'my super description', | |
167 | tags: [ 'tag1', 'tag2' ] | |
168 | } | |
169 | const attach = { | |
170 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
171 | } | |
172 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
173 | }) | |
174 | ||
175 | it('Should fail without a licence', function (done) { | |
176 | const data = { | |
177 | name: 'my super name', | |
178 | category: 5, | |
179 | language: 6, | |
180 | nsfw: false, | |
181 | description: 'my super description', | |
182 | tags: [ 'tag1', 'tag2' ] | |
183 | } | |
184 | const attach = { | |
185 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
186 | } | |
187 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
188 | }) | |
189 | ||
190 | it('Should fail with a bad licence', function (done) { | |
191 | const data = { | |
192 | name: 'my super name', | |
193 | category: 5, | |
194 | licence: 125, | |
195 | language: 6, | |
196 | nsfw: false, | |
197 | description: 'my super description', | |
198 | tags: [ 'tag1', 'tag2' ] | |
199 | } | |
200 | const attach = { | |
201 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
202 | } | |
203 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
204 | }) | |
205 | ||
206 | it('Should fail with a bad language', function (done) { | |
207 | const data = { | |
208 | name: 'my super name', | |
209 | category: 5, | |
210 | licence: 4, | |
211 | language: 563, | |
212 | nsfw: false, | |
213 | description: 'my super description', | |
214 | tags: [ 'tag1', 'tag2' ] | |
215 | } | |
216 | const attach = { | |
217 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
218 | } | |
219 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
220 | }) | |
221 | ||
222 | it('Should fail without nsfw attribute', function (done) { | |
223 | const data = { | |
224 | name: 'my super name', | |
225 | category: 5, | |
226 | licence: 4, | |
227 | language: 6, | |
228 | description: 'my super description', | |
229 | tags: [ 'tag1', 'tag2' ] | |
230 | } | |
231 | const attach = { | |
232 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
233 | } | |
234 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
235 | }) | |
236 | ||
237 | it('Should fail with a bad nsfw attribue', function (done) { | |
238 | const data = { | |
239 | name: 'my super name', | |
240 | category: 5, | |
241 | licence: 4, | |
242 | language: 6, | |
243 | nsfw: 2, | |
244 | description: 'my super description', | |
245 | tags: [ 'tag1', 'tag2' ] | |
246 | } | |
247 | const attach = { | |
248 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
249 | } | |
250 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
251 | }) | |
252 | ||
253 | it('Should fail without description', function (done) { | |
254 | const data = { | |
255 | name: 'my super name', | |
256 | category: 5, | |
257 | licence: 1, | |
258 | language: 6, | |
259 | nsfw: false, | |
260 | tags: [ 'tag1', 'tag2' ] | |
261 | } | |
262 | const attach = { | |
263 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
264 | } | |
265 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
266 | }) | |
267 | ||
268 | it('Should fail with a long description', function (done) { | |
269 | const data = { | |
270 | name: 'my super name', | |
271 | category: 5, | |
272 | licence: 1, | |
273 | language: 6, | |
274 | nsfw: false, | |
275 | description: 'my super description which is very very very very very very very very very very very very very very' + | |
276 | 'very very very very very very very very very very very very very very very very very very very very very' + | |
277 | 'very very very very very very very very very very very very very very very long', | |
278 | tags: [ 'tag1', 'tag2' ] | |
279 | } | |
280 | const attach = { | |
281 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
282 | } | |
283 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
284 | }) | |
285 | ||
286 | it('Should fail with too many tags', function (done) { | |
287 | const data = { | |
288 | name: 'my super name', | |
289 | category: 5, | |
290 | licence: 1, | |
291 | language: 6, | |
292 | nsfw: false, | |
293 | description: 'my super description', | |
294 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] | |
295 | } | |
296 | const attach = { | |
297 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
298 | } | |
299 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
300 | }) | |
301 | ||
302 | it('Should fail with a tag length too low', function (done) { | |
303 | const data = { | |
304 | name: 'my super name', | |
305 | category: 5, | |
306 | licence: 1, | |
307 | language: 6, | |
308 | nsfw: false, | |
309 | description: 'my super description', | |
310 | tags: [ 'tag1', 't' ] | |
311 | } | |
312 | const attach = { | |
313 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
314 | } | |
315 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
316 | }) | |
317 | ||
318 | it('Should fail with a tag length too big', function (done) { | |
319 | const data = { | |
320 | name: 'my super name', | |
321 | category: 5, | |
322 | licence: 1, | |
323 | language: 6, | |
324 | nsfw: false, | |
325 | description: 'my super description', | |
326 | tags: [ 'mysupertagtoolong', 'tag1' ] | |
327 | } | |
328 | const attach = { | |
329 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
330 | } | |
331 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
332 | }) | |
333 | ||
334 | it('Should fail without an input file', function (done) { | |
335 | const data = { | |
336 | name: 'my super name', | |
337 | category: 5, | |
338 | licence: 1, | |
339 | language: 6, | |
340 | nsfw: false, | |
341 | description: 'my super description', | |
342 | tags: [ 'tag1', 'tag2' ] | |
343 | } | |
344 | const attach = {} | |
345 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
346 | }) | |
347 | ||
348 | it('Should fail without an incorrect input file', function (done) { | |
349 | const data = { | |
350 | name: 'my super name', | |
351 | category: 5, | |
352 | licence: 1, | |
353 | language: 6, | |
354 | nsfw: false, | |
355 | description: 'my super description', | |
356 | tags: [ 'tag1', 'tag2' ] | |
357 | } | |
358 | const attach = { | |
359 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm') | |
360 | } | |
361 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
362 | }) | |
363 | ||
364 | it('Should fail with a too big duration', function (done) { | |
365 | const data = { | |
366 | name: 'my super name', | |
367 | category: 5, | |
368 | licence: 1, | |
369 | language: 6, | |
370 | nsfw: false, | |
371 | description: 'my super description', | |
372 | tags: [ 'tag1', 'tag2' ] | |
373 | } | |
374 | const attach = { | |
375 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_too_long.webm') | |
376 | } | |
377 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done) | |
378 | }) | |
379 | ||
380 | it('Should succeed with the correct parameters', function (done) { | |
381 | this.timeout(10000) | |
382 | ||
383 | const data = { | |
384 | name: 'my super name', | |
385 | category: 5, | |
386 | licence: 1, | |
387 | language: 6, | |
388 | nsfw: false, | |
389 | description: 'my super description', | |
390 | tags: [ 'tag1', 'tag2' ] | |
391 | } | |
392 | const attach = { | |
393 | 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm') | |
394 | } | |
395 | ||
396 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, function () { | |
397 | attach.videofile = pathUtils.join(__dirname, '..', 'fixtures', 'video_short.mp4') | |
398 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, function () { | |
399 | attach.videofile = pathUtils.join(__dirname, '..', 'fixtures', 'video_short.ogv') | |
400 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done, 204) | |
401 | }, false) | |
402 | }, false) | |
403 | }) | |
404 | }) | |
405 | ||
406 | describe('When updating a video', function () { | |
407 | let videoId | |
408 | ||
409 | before(function (done) { | |
410 | videosUtils.getVideosList(server.url, function (err, res) { | |
411 | if (err) throw err | |
412 | ||
413 | videoId = res.body.data[0].id | |
414 | ||
415 | return done() | |
416 | }) | |
417 | }) | |
418 | ||
419 | it('Should fail with nothing', function (done) { | |
420 | const data = {} | |
421 | requestsUtils.makePutBodyRequest(server.url, path, server.accessToken, data, done) | |
422 | }) | |
423 | ||
424 | it('Should fail without a valid uuid', function (done) { | |
425 | const data = { | |
426 | category: 5, | |
427 | licence: 2, | |
428 | language: 6, | |
429 | nsfw: false, | |
430 | description: 'my super description', | |
431 | tags: [ 'tag1', 'tag2' ] | |
432 | } | |
433 | requestsUtils.makePutBodyRequest(server.url, path + 'blabla', server.accessToken, data, done) | |
434 | }) | |
435 | ||
436 | it('Should fail with an unknown id', function (done) { | |
437 | const data = { | |
438 | category: 5, | |
439 | licence: 2, | |
440 | language: 6, | |
441 | nsfw: false, | |
442 | description: 'my super description', | |
443 | tags: [ 'tag1', 'tag2' ] | |
444 | } | |
445 | requestsUtils.makePutBodyRequest(server.url, path + '4da6fde3-88f7-4d16-b119-108df5630b06', server.accessToken, data, done, 404) | |
446 | }) | |
447 | ||
448 | it('Should fail with a long name', function (done) { | |
449 | const data = { | |
450 | name: 'My very very very very very very very very very very very very very very very very long name', | |
451 | category: 5, | |
452 | licence: 2, | |
453 | language: 6, | |
454 | nsfw: false, | |
455 | description: 'my super description', | |
456 | tags: [ 'tag1', 'tag2' ] | |
457 | } | |
458 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
459 | }) | |
460 | ||
461 | it('Should fail with a bad category', function (done) { | |
462 | const data = { | |
463 | name: 'my super name', | |
464 | category: 128, | |
465 | licence: 2, | |
466 | language: 6, | |
467 | nsfw: false, | |
468 | description: 'my super description', | |
469 | tags: [ 'tag1', 'tag2' ] | |
470 | } | |
471 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
472 | }) | |
473 | ||
474 | it('Should fail with a bad licence', function (done) { | |
475 | const data = { | |
476 | name: 'my super name', | |
477 | category: 5, | |
478 | licence: 128, | |
479 | language: 6, | |
480 | nsfw: false, | |
481 | description: 'my super description', | |
482 | tags: [ 'tag1', 'tag2' ] | |
483 | } | |
484 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
485 | }) | |
486 | ||
487 | it('Should fail with a bad language', function (done) { | |
488 | const data = { | |
489 | name: 'my super name', | |
490 | category: 5, | |
491 | licence: 3, | |
492 | language: 896, | |
493 | nsfw: false, | |
494 | description: 'my super description', | |
495 | tags: [ 'tag1', 'tag2' ] | |
496 | } | |
497 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
498 | }) | |
499 | ||
500 | it('Should fail with a bad nsfw attribute', function (done) { | |
501 | const data = { | |
502 | name: 'my super name', | |
503 | category: 5, | |
504 | licence: 5, | |
505 | language: 6, | |
506 | nsfw: -4, | |
507 | description: 'my super description', | |
508 | tags: [ 'tag1', 'tag2' ] | |
509 | } | |
510 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
511 | }) | |
512 | ||
513 | it('Should fail with a long description', function (done) { | |
514 | const data = { | |
515 | name: 'my super name', | |
516 | category: 5, | |
517 | licence: 2, | |
518 | language: 6, | |
519 | nsfw: false, | |
520 | description: 'my super description which is very very very very very very very very very very very very very very' + | |
521 | 'very very very very very very very very very very very very very very very very very very very very very' + | |
522 | 'very very very very very very very very very very very very very very very long', | |
523 | tags: [ 'tag1', 'tag2' ] | |
524 | } | |
525 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
526 | }) | |
527 | ||
528 | it('Should fail with too many tags', function (done) { | |
529 | const data = { | |
530 | name: 'my super name', | |
531 | category: 5, | |
532 | licence: 2, | |
533 | language: 6, | |
534 | nsfw: false, | |
535 | description: 'my super description', | |
536 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] | |
537 | } | |
538 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
539 | }) | |
540 | ||
541 | it('Should fail with a tag length too low', function (done) { | |
542 | const data = { | |
543 | name: 'my super name', | |
544 | category: 5, | |
545 | licence: 2, | |
546 | language: 6, | |
547 | nsfw: false, | |
548 | description: 'my super description', | |
549 | tags: [ 'tag1', 't' ] | |
550 | } | |
551 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
552 | }) | |
553 | ||
554 | it('Should fail with a tag length too big', function (done) { | |
555 | const data = { | |
556 | name: 'my super name', | |
557 | category: 5, | |
558 | licence: 2, | |
559 | language: 6, | |
560 | nsfw: false, | |
561 | description: 'my super description', | |
562 | tags: [ 'mysupertagtoolong', 'tag1' ] | |
563 | } | |
564 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
565 | }) | |
566 | ||
567 | it('Should fail with a video of another user') | |
568 | ||
569 | it('Should fail with a video of another pod') | |
570 | }) | |
571 | ||
572 | describe('When getting a video', function () { | |
573 | it('Should return the list of the videos with nothing', function (done) { | |
574 | request(server.url) | |
575 | .get(path) | |
576 | .set('Accept', 'application/json') | |
577 | .expect(200) | |
578 | .expect('Content-Type', /json/) | |
579 | .end(function (err, res) { | |
580 | if (err) throw err | |
581 | ||
582 | expect(res.body.data).to.be.an('array') | |
583 | expect(res.body.data.length).to.equal(3) | |
584 | ||
585 | done() | |
586 | }) | |
587 | }) | |
588 | ||
589 | it('Should fail without a correct uuid', function (done) { | |
590 | request(server.url) | |
591 | .get(path + 'coucou') | |
592 | .set('Accept', 'application/json') | |
593 | .expect(400, done) | |
594 | }) | |
595 | ||
596 | it('Should return 404 with an incorrect video', function (done) { | |
597 | request(server.url) | |
598 | .get(path + '4da6fde3-88f7-4d16-b119-108df5630b06') | |
599 | .set('Accept', 'application/json') | |
600 | .expect(404, done) | |
601 | }) | |
602 | ||
603 | it('Should succeed with the correct parameters') | |
604 | }) | |
605 | ||
606 | describe('When rating a video', function () { | |
607 | let videoId | |
608 | ||
609 | before(function (done) { | |
610 | videosUtils.getVideosList(server.url, function (err, res) { | |
611 | if (err) throw err | |
612 | ||
613 | videoId = res.body.data[0].id | |
614 | ||
615 | return done() | |
616 | }) | |
617 | }) | |
618 | ||
619 | it('Should fail without a valid uuid', function (done) { | |
620 | const data = { | |
621 | rating: 'like' | |
622 | } | |
623 | requestsUtils.makePutBodyRequest(server.url, path + 'blabla/rate', server.accessToken, data, done) | |
624 | }) | |
625 | ||
626 | it('Should fail with an unknown id', function (done) { | |
627 | const data = { | |
628 | rating: 'like' | |
629 | } | |
630 | requestsUtils.makePutBodyRequest(server.url, path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', server.accessToken, data, done, 404) | |
631 | }) | |
632 | ||
633 | it('Should fail with a wrong rating', function (done) { | |
634 | const data = { | |
635 | rating: 'likes' | |
636 | } | |
637 | requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done) | |
638 | }) | |
639 | ||
640 | it('Should succeed with the correct parameters', function (done) { | |
641 | const data = { | |
642 | rating: 'like' | |
643 | } | |
644 | requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done, 204) | |
645 | }) | |
646 | }) | |
647 | ||
648 | describe('When removing a video', function () { | |
649 | it('Should have 404 with nothing', function (done) { | |
650 | request(server.url) | |
651 | .delete(path) | |
652 | .set('Authorization', 'Bearer ' + server.accessToken) | |
653 | .expect(400, done) | |
654 | }) | |
655 | ||
656 | it('Should fail without a correct uuid', function (done) { | |
657 | request(server.url) | |
658 | .delete(path + 'hello') | |
659 | .set('Authorization', 'Bearer ' + server.accessToken) | |
660 | .expect(400, done) | |
661 | }) | |
662 | ||
663 | it('Should fail with a video which does not exist', function (done) { | |
664 | request(server.url) | |
665 | .delete(path + '4da6fde3-88f7-4d16-b119-108df5630b06') | |
666 | .set('Authorization', 'Bearer ' + server.accessToken) | |
667 | .expect(404, done) | |
668 | }) | |
669 | ||
670 | it('Should fail with a video of another user') | |
671 | ||
672 | it('Should fail with a video of another pod') | |
673 | ||
674 | it('Should succeed with the correct parameters') | |
675 | }) | |
676 | ||
677 | after(function (done) { | |
678 | process.kill(-server.app.pid) | |
679 | ||
680 | // Keep the logs if the test failed | |
681 | if (this.ok) { | |
682 | serversUtils.flushTests(done) | |
683 | } else { | |
684 | done() | |
685 | } | |
686 | }) | |
687 | }) |