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