]>
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(5000) | |
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 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, function () { | |
396 | attach.videofile = pathUtils.join(__dirname, '..', 'fixtures', 'video_short.mp4') | |
397 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, function () { | |
398 | attach.videofile = pathUtils.join(__dirname, '..', 'fixtures', 'video_short.ogv') | |
399 | requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done, 204) | |
400 | }, false) | |
401 | }, false) | |
402 | }) | |
403 | }) | |
404 | ||
405 | describe('When updating a video', function () { | |
406 | let videoId | |
407 | ||
408 | before(function (done) { | |
409 | videosUtils.getVideosList(server.url, function (err, res) { | |
410 | if (err) throw err | |
411 | ||
412 | videoId = res.body.data[0].id | |
413 | ||
414 | return done() | |
415 | }) | |
416 | }) | |
417 | ||
418 | it('Should fail with nothing', function (done) { | |
419 | const data = {} | |
420 | requestsUtils.makePutBodyRequest(server.url, path, server.accessToken, data, done) | |
421 | }) | |
422 | ||
423 | it('Should fail without a valid uuid', function (done) { | |
424 | const data = { | |
425 | category: 5, | |
426 | licence: 2, | |
427 | language: 6, | |
428 | nsfw: false, | |
429 | description: 'my super description', | |
430 | tags: [ 'tag1', 'tag2' ] | |
431 | } | |
432 | requestsUtils.makePutBodyRequest(server.url, path + 'blabla', server.accessToken, data, done) | |
433 | }) | |
434 | ||
435 | it('Should fail with an unknown id', function (done) { | |
436 | const data = { | |
437 | category: 5, | |
438 | licence: 2, | |
439 | language: 6, | |
440 | nsfw: false, | |
441 | description: 'my super description', | |
442 | tags: [ 'tag1', 'tag2' ] | |
443 | } | |
444 | requestsUtils.makePutBodyRequest(server.url, path + '4da6fde3-88f7-4d16-b119-108df5630b06', server.accessToken, data, done, 404) | |
445 | }) | |
446 | ||
447 | it('Should fail with a long name', function (done) { | |
448 | const data = { | |
449 | name: 'My very very very very very very very very very very very very very very very very long name', | |
450 | category: 5, | |
451 | licence: 2, | |
452 | language: 6, | |
453 | nsfw: false, | |
454 | description: 'my super description', | |
455 | tags: [ 'tag1', 'tag2' ] | |
456 | } | |
457 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
458 | }) | |
459 | ||
460 | it('Should fail with a bad category', function (done) { | |
461 | const data = { | |
462 | name: 'my super name', | |
463 | category: 128, | |
464 | licence: 2, | |
465 | language: 6, | |
466 | nsfw: false, | |
467 | description: 'my super description', | |
468 | tags: [ 'tag1', 'tag2' ] | |
469 | } | |
470 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
471 | }) | |
472 | ||
473 | it('Should fail with a bad licence', function (done) { | |
474 | const data = { | |
475 | name: 'my super name', | |
476 | category: 5, | |
477 | licence: 128, | |
478 | language: 6, | |
479 | nsfw: false, | |
480 | description: 'my super description', | |
481 | tags: [ 'tag1', 'tag2' ] | |
482 | } | |
483 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
484 | }) | |
485 | ||
486 | it('Should fail with a bad language', function (done) { | |
487 | const data = { | |
488 | name: 'my super name', | |
489 | category: 5, | |
490 | licence: 3, | |
491 | language: 896, | |
492 | nsfw: false, | |
493 | description: 'my super description', | |
494 | tags: [ 'tag1', 'tag2' ] | |
495 | } | |
496 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
497 | }) | |
498 | ||
499 | it('Should fail with a bad nsfw attribute', function (done) { | |
500 | const data = { | |
501 | name: 'my super name', | |
502 | category: 5, | |
503 | licence: 5, | |
504 | language: 6, | |
505 | nsfw: -4, | |
506 | description: 'my super description', | |
507 | tags: [ 'tag1', 'tag2' ] | |
508 | } | |
509 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
510 | }) | |
511 | ||
512 | it('Should fail with a long description', function (done) { | |
513 | const data = { | |
514 | name: 'my super name', | |
515 | category: 5, | |
516 | licence: 2, | |
517 | language: 6, | |
518 | nsfw: false, | |
519 | description: 'my super description which is very very very very very very very very very very very very very very' + | |
520 | 'very very very very very very very 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 long', | |
522 | tags: [ 'tag1', 'tag2' ] | |
523 | } | |
524 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
525 | }) | |
526 | ||
527 | it('Should fail with too many tags', function (done) { | |
528 | const data = { | |
529 | name: 'my super name', | |
530 | category: 5, | |
531 | licence: 2, | |
532 | language: 6, | |
533 | nsfw: false, | |
534 | description: 'my super description', | |
535 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] | |
536 | } | |
537 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
538 | }) | |
539 | ||
540 | it('Should fail with a tag length too low', function (done) { | |
541 | const data = { | |
542 | name: 'my super name', | |
543 | category: 5, | |
544 | licence: 2, | |
545 | language: 6, | |
546 | nsfw: false, | |
547 | description: 'my super description', | |
548 | tags: [ 'tag1', 't' ] | |
549 | } | |
550 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
551 | }) | |
552 | ||
553 | it('Should fail with a tag length too big', function (done) { | |
554 | const data = { | |
555 | name: 'my super name', | |
556 | category: 5, | |
557 | licence: 2, | |
558 | language: 6, | |
559 | nsfw: false, | |
560 | description: 'my super description', | |
561 | tags: [ 'mysupertagtoolong', 'tag1' ] | |
562 | } | |
563 | requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done) | |
564 | }) | |
565 | ||
566 | it('Should fail with a video of another user') | |
567 | ||
568 | it('Should fail with a video of another pod') | |
569 | }) | |
570 | ||
571 | describe('When getting a video', function () { | |
572 | it('Should return the list of the videos with nothing', function (done) { | |
573 | request(server.url) | |
574 | .get(path) | |
575 | .set('Accept', 'application/json') | |
576 | .expect(200) | |
577 | .expect('Content-Type', /json/) | |
578 | .end(function (err, res) { | |
579 | if (err) throw err | |
580 | ||
581 | expect(res.body.data).to.be.an('array') | |
582 | expect(res.body.data.length).to.equal(3) | |
583 | ||
584 | done() | |
585 | }) | |
586 | }) | |
587 | ||
588 | it('Should fail without a correct uuid', function (done) { | |
589 | request(server.url) | |
590 | .get(path + 'coucou') | |
591 | .set('Accept', 'application/json') | |
592 | .expect(400, done) | |
593 | }) | |
594 | ||
595 | it('Should return 404 with an incorrect video', function (done) { | |
596 | request(server.url) | |
597 | .get(path + '4da6fde3-88f7-4d16-b119-108df5630b06') | |
598 | .set('Accept', 'application/json') | |
599 | .expect(404, done) | |
600 | }) | |
601 | ||
602 | it('Should succeed with the correct parameters') | |
603 | }) | |
604 | ||
605 | describe('When rating a video', function () { | |
606 | let videoId | |
607 | ||
608 | before(function (done) { | |
609 | videosUtils.getVideosList(server.url, function (err, res) { | |
610 | if (err) throw err | |
611 | ||
612 | videoId = res.body.data[0].id | |
613 | ||
614 | return done() | |
615 | }) | |
616 | }) | |
617 | ||
618 | it('Should fail without a valid uuid', function (done) { | |
619 | const data = { | |
620 | rating: 'like' | |
621 | } | |
622 | requestsUtils.makePutBodyRequest(server.url, path + 'blabla/rate', server.accessToken, data, done) | |
623 | }) | |
624 | ||
625 | it('Should fail with an unknown id', function (done) { | |
626 | const data = { | |
627 | rating: 'like' | |
628 | } | |
629 | requestsUtils.makePutBodyRequest(server.url, path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', server.accessToken, data, done, 404) | |
630 | }) | |
631 | ||
632 | it('Should fail with a wrong rating', function (done) { | |
633 | const data = { | |
634 | rating: 'likes' | |
635 | } | |
636 | requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done) | |
637 | }) | |
638 | ||
639 | it('Should succeed with the correct parameters', function (done) { | |
640 | const data = { | |
641 | rating: 'like' | |
642 | } | |
643 | requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done, 204) | |
644 | }) | |
645 | }) | |
646 | ||
647 | describe('When removing a video', function () { | |
648 | it('Should have 404 with nothing', function (done) { | |
649 | request(server.url) | |
650 | .delete(path) | |
651 | .set('Authorization', 'Bearer ' + server.accessToken) | |
652 | .expect(400, done) | |
653 | }) | |
654 | ||
655 | it('Should fail without a correct uuid', function (done) { | |
656 | request(server.url) | |
657 | .delete(path + 'hello') | |
658 | .set('Authorization', 'Bearer ' + server.accessToken) | |
659 | .expect(400, done) | |
660 | }) | |
661 | ||
662 | it('Should fail with a video which does not exist', function (done) { | |
663 | request(server.url) | |
664 | .delete(path + '4da6fde3-88f7-4d16-b119-108df5630b06') | |
665 | .set('Authorization', 'Bearer ' + server.accessToken) | |
666 | .expect(404, done) | |
667 | }) | |
668 | ||
669 | it('Should fail with a video of another user') | |
670 | ||
671 | it('Should fail with a video of another pod') | |
672 | ||
673 | it('Should succeed with the correct parameters') | |
674 | }) | |
675 | ||
676 | after(function (done) { | |
677 | process.kill(-server.app.pid) | |
678 | ||
679 | // Keep the logs if the test failed | |
680 | if (this.ok) { | |
681 | serversUtils.flushTests(done) | |
682 | } else { | |
683 | done() | |
684 | } | |
685 | }) | |
686 | }) |