aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/users.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/users.js')
-rw-r--r--server/tests/api/check-params/users.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/server/tests/api/check-params/users.js b/server/tests/api/check-params/users.js
index 6edb54660..11e2bada4 100644
--- a/server/tests/api/check-params/users.js
+++ b/server/tests/api/check-params/users.js
@@ -9,11 +9,13 @@ const loginUtils = require('../../utils/login')
9const requestsUtils = require('../../utils/requests') 9const requestsUtils = require('../../utils/requests')
10const serversUtils = require('../../utils/servers') 10const serversUtils = require('../../utils/servers')
11const usersUtils = require('../../utils/users') 11const usersUtils = require('../../utils/users')
12const videosUtils = require('../../utils/videos')
12 13
13describe('Test users API validators', function () { 14describe('Test users API validators', function () {
14 const path = '/api/v1/users/' 15 const path = '/api/v1/users/'
15 let userId = null 16 let userId = null
16 let rootId = null 17 let rootId = null
18 let videoId = null
17 let server = null 19 let server = null
18 let userAccessToken = null 20 let userAccessToken = null
19 21
@@ -48,6 +50,23 @@ describe('Test users API validators', function () {
48 usersUtils.createUser(server.url, server.accessToken, username, password, next) 50 usersUtils.createUser(server.url, server.accessToken, username, password, next)
49 }, 51 },
50 function (next) { 52 function (next) {
53 const name = 'my super name for pod'
54 const description = 'my super description for pod'
55 const tags = [ 'tag' ]
56 const file = 'video_short2.webm'
57 videosUtils.uploadVideo(server.url, server.accessToken, name, description, tags, file, next)
58 },
59 function (next) {
60 videosUtils.getVideosList(server.url, function (err, res) {
61 if (err) throw err
62
63 const videos = res.body.data
64 videoId = videos[0].id
65
66 next()
67 })
68 },
69 function (next) {
51 const user = { 70 const user = {
52 username: 'user1', 71 username: 'user1',
53 password: 'my super password' 72 password: 'my super password'
@@ -289,6 +308,63 @@ describe('Test users API validators', function () {
289 }) 308 })
290 }) 309 })
291 310
311 describe('When getting my video rating', function () {
312 it('Should fail with a non authenticated user', function (done) {
313 request(server.url)
314 .get(path + 'me/videos/' + videoId + '/rating')
315 .set('Authorization', 'Bearer faketoken')
316 .set('Accept', 'application/json')
317 .expect(401, done)
318 })
319
320 it('Should fail with an incorrect video uuid', function (done) {
321 request(server.url)
322 .get(path + 'me/videos/blabla/rating')
323 .set('Authorization', 'Bearer ' + userAccessToken)
324 .set('Accept', 'application/json')
325 .expect(400, done)
326 })
327
328 it('Should fail with an unknown video', function (done) {
329 request(server.url)
330 .get(path + 'me/videos/4da6fde3-88f7-4d16-b119-108df5630b06/rating')
331 .set('Authorization', 'Bearer ' + userAccessToken)
332 .set('Accept', 'application/json')
333 .expect(404, done)
334 })
335
336 it('Should success with the correct parameters', function (done) {
337 request(server.url)
338 .get(path + 'me/videos/' + videoId + '/rating')
339 .set('Authorization', 'Bearer ' + userAccessToken)
340 .set('Accept', 'application/json')
341 .expect(200, done)
342 })
343 })
344
345 describe('When removing an user', function () {
346 it('Should fail with an incorrect id', function (done) {
347 request(server.url)
348 .delete(path + 'bla-bla')
349 .set('Authorization', 'Bearer ' + server.accessToken)
350 .expect(400, done)
351 })
352
353 it('Should fail with the root user', function (done) {
354 request(server.url)
355 .delete(path + rootId)
356 .set('Authorization', 'Bearer ' + server.accessToken)
357 .expect(400, done)
358 })
359
360 it('Should return 404 with a non existing id', function (done) {
361 request(server.url)
362 .delete(path + '45')
363 .set('Authorization', 'Bearer ' + server.accessToken)
364 .expect(404, done)
365 })
366 })
367
292 describe('When removing an user', function () { 368 describe('When removing an user', function () {
293 it('Should fail with an incorrect id', function (done) { 369 it('Should fail with an incorrect id', function (done) {
294 request(server.url) 370 request(server.url)