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