diff options
Diffstat (limited to 'server/tests/api/check-params/request-schedulers.js')
-rw-r--r-- | server/tests/api/check-params/request-schedulers.js | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/server/tests/api/check-params/request-schedulers.js b/server/tests/api/check-params/request-schedulers.js deleted file mode 100644 index 9ba0df730..000000000 --- a/server/tests/api/check-params/request-schedulers.js +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | /* eslint-disable no-unused-expressions */ | ||
2 | |||
3 | 'use strict' | ||
4 | |||
5 | const request = require('supertest') | ||
6 | const series = require('async/series') | ||
7 | |||
8 | const loginUtils = require('../../utils/login') | ||
9 | const usersUtils = require('../../utils/users') | ||
10 | const serversUtils = require('../../utils/servers') | ||
11 | |||
12 | describe('Test request schedulers stats API validators', function () { | ||
13 | const path = '/api/v1/request-schedulers/stats' | ||
14 | let server = null | ||
15 | let userAccessToken = null | ||
16 | |||
17 | // --------------------------------------------------------------- | ||
18 | |||
19 | before(function (done) { | ||
20 | this.timeout(20000) | ||
21 | |||
22 | series([ | ||
23 | function (next) { | ||
24 | serversUtils.flushTests(next) | ||
25 | }, | ||
26 | function (next) { | ||
27 | serversUtils.runServer(1, function (server1) { | ||
28 | server = server1 | ||
29 | |||
30 | next() | ||
31 | }) | ||
32 | }, | ||
33 | function (next) { | ||
34 | loginUtils.loginAndGetAccessToken(server, function (err, token) { | ||
35 | if (err) throw err | ||
36 | server.accessToken = token | ||
37 | |||
38 | next() | ||
39 | }) | ||
40 | }, | ||
41 | function (next) { | ||
42 | const username = 'user' | ||
43 | const password = 'my super password' | ||
44 | |||
45 | usersUtils.createUser(server.url, server.accessToken, username, password, next) | ||
46 | }, | ||
47 | function (next) { | ||
48 | const user = { | ||
49 | username: 'user', | ||
50 | password: 'my super password' | ||
51 | } | ||
52 | |||
53 | loginUtils.getUserAccessToken(server, user, function (err, accessToken) { | ||
54 | if (err) throw err | ||
55 | |||
56 | userAccessToken = accessToken | ||
57 | |||
58 | next() | ||
59 | }) | ||
60 | } | ||
61 | ], done) | ||
62 | }) | ||
63 | |||
64 | it('Should fail with an non authenticated user', function (done) { | ||
65 | request(server.url) | ||
66 | .get(path) | ||
67 | .set('Accept', 'application/json') | ||
68 | .expect(401, done) | ||
69 | }) | ||
70 | |||
71 | it('Should fail with a non admin user', function (done) { | ||
72 | request(server.url) | ||
73 | .get(path) | ||
74 | .set('Authorization', 'Bearer ' + userAccessToken) | ||
75 | .set('Accept', 'application/json') | ||
76 | .expect(403, done) | ||
77 | }) | ||
78 | |||
79 | after(function (done) { | ||
80 | process.kill(-server.app.pid) | ||
81 | |||
82 | // Keep the logs if the test failed | ||
83 | if (this.ok) { | ||
84 | serversUtils.flushTests(done) | ||
85 | } else { | ||
86 | done() | ||
87 | } | ||
88 | }) | ||
89 | }) | ||