diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-17 15:20:42 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 9a27cdc27c900feaae5f6db4315c4ccdfc0c4493 (patch) | |
tree | f91fcfa0fa1a2e45aae1c5333ef2f7ec60e56ef0 /server/tests/api/check-params | |
parent | 975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a (diff) | |
download | PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.gz PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.zst PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.zip |
Optimize signature verification
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/follows.ts | 222 | ||||
-rw-r--r-- | server/tests/api/check-params/index.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/pods.ts | 287 | ||||
-rw-r--r-- | server/tests/api/check-params/remotes.ts | 54 | ||||
-rw-r--r-- | server/tests/api/check-params/request-schedulers.ts | 65 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.ts | 4 |
6 files changed, 225 insertions, 411 deletions
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts new file mode 100644 index 000000000..d742200c1 --- /dev/null +++ b/server/tests/api/check-params/follows.ts | |||
@@ -0,0 +1,222 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as request from 'supertest' | ||
4 | import 'mocha' | ||
5 | |||
6 | import { | ||
7 | ServerInfo, | ||
8 | flushTests, | ||
9 | runServer, | ||
10 | createUser, | ||
11 | loginAndGetAccessToken, | ||
12 | setAccessTokensToServers, | ||
13 | killallServers, | ||
14 | makePostBodyRequest | ||
15 | } from '../../utils' | ||
16 | |||
17 | describe('Test server follows API validators', function () { | ||
18 | let server: ServerInfo | ||
19 | |||
20 | // --------------------------------------------------------------- | ||
21 | |||
22 | before(async function () { | ||
23 | this.timeout(45000) | ||
24 | |||
25 | await flushTests() | ||
26 | server = await runServer(1) | ||
27 | |||
28 | await setAccessTokensToServers([ server ]) | ||
29 | }) | ||
30 | |||
31 | describe('When managing following', function () { | ||
32 | let userAccessToken = null | ||
33 | |||
34 | before(async function () { | ||
35 | await createUser(server.url, server.accessToken, 'user1', 'password') | ||
36 | server.user = { | ||
37 | username: 'user1', | ||
38 | password: 'password' | ||
39 | } | ||
40 | |||
41 | userAccessToken = await loginAndGetAccessToken(server) | ||
42 | }) | ||
43 | |||
44 | describe('When adding follows', function () { | ||
45 | const path = '/api/v1/server/following' | ||
46 | const body = { | ||
47 | hosts: [ 'localhost:9002' ] | ||
48 | } | ||
49 | |||
50 | it('Should fail without hosts', async function () { | ||
51 | await request(server.url) | ||
52 | .post(path) | ||
53 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
54 | .set('Accept', 'application/json') | ||
55 | .expect(400) | ||
56 | }) | ||
57 | |||
58 | it('Should fail if hosts is not an array', async function () { | ||
59 | await request(server.url) | ||
60 | .post(path) | ||
61 | .send({ hosts: 'localhost:9002' }) | ||
62 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
63 | .set('Accept', 'application/json') | ||
64 | .expect(400) | ||
65 | }) | ||
66 | |||
67 | it('Should fail if the array is not composed by hosts', async function () { | ||
68 | await request(server.url) | ||
69 | .post(path) | ||
70 | .send({ hosts: [ 'localhost:9002', 'localhost:coucou' ] }) | ||
71 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
72 | .set('Accept', 'application/json') | ||
73 | .expect(400) | ||
74 | }) | ||
75 | |||
76 | it('Should fail if the array is composed with http schemes', async function () { | ||
77 | await request(server.url) | ||
78 | .post(path) | ||
79 | .send({ hosts: [ 'localhost:9002', 'http://localhost:9003' ] }) | ||
80 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
81 | .set('Accept', 'application/json') | ||
82 | .expect(400) | ||
83 | }) | ||
84 | |||
85 | it('Should fail if hosts are not unique', async function () { | ||
86 | await request(server.url) | ||
87 | .post(path) | ||
88 | .send({ urls: [ 'localhost:9002', 'localhost:9002' ] }) | ||
89 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
90 | .set('Accept', 'application/json') | ||
91 | .expect(400) | ||
92 | }) | ||
93 | |||
94 | it('Should fail with an invalid token', async function () { | ||
95 | await request(server.url) | ||
96 | .post(path) | ||
97 | .send(body) | ||
98 | .set('Authorization', 'Bearer fake_token') | ||
99 | .set('Accept', 'application/json') | ||
100 | .expect(401) | ||
101 | }) | ||
102 | |||
103 | it('Should fail if the user is not an administrator', async function () { | ||
104 | await request(server.url) | ||
105 | .post(path) | ||
106 | .send(body) | ||
107 | .set('Authorization', 'Bearer ' + userAccessToken) | ||
108 | .set('Accept', 'application/json') | ||
109 | .expect(403) | ||
110 | }) | ||
111 | }) | ||
112 | |||
113 | describe('When listing followings', function () { | ||
114 | const path = '/api/v1/server/following' | ||
115 | |||
116 | it('Should fail with a bad start pagination', async function () { | ||
117 | await request(server.url) | ||
118 | .get(path) | ||
119 | .query({ start: 'hello' }) | ||
120 | .set('Accept', 'application/json') | ||
121 | .expect(400) | ||
122 | }) | ||
123 | |||
124 | it('Should fail with a bad count pagination', async function () { | ||
125 | await request(server.url) | ||
126 | .get(path) | ||
127 | .query({ count: 'hello' }) | ||
128 | .set('Accept', 'application/json') | ||
129 | .expect(400) | ||
130 | }) | ||
131 | |||
132 | it('Should fail with an incorrect sort', async function () { | ||
133 | await request(server.url) | ||
134 | .get(path) | ||
135 | .query({ sort: 'hello' }) | ||
136 | .set('Accept', 'application/json') | ||
137 | .expect(400) | ||
138 | }) | ||
139 | }) | ||
140 | |||
141 | describe('When listing followers', function () { | ||
142 | const path = '/api/v1/server/followers' | ||
143 | |||
144 | it('Should fail with a bad start pagination', async function () { | ||
145 | await request(server.url) | ||
146 | .get(path) | ||
147 | .query({ start: 'hello' }) | ||
148 | .set('Accept', 'application/json') | ||
149 | .expect(400) | ||
150 | }) | ||
151 | |||
152 | it('Should fail with a bad count pagination', async function () { | ||
153 | await request(server.url) | ||
154 | .get(path) | ||
155 | .query({ count: 'hello' }) | ||
156 | .set('Accept', 'application/json') | ||
157 | .expect(400) | ||
158 | }) | ||
159 | |||
160 | it('Should fail with an incorrect sort', async function () { | ||
161 | await request(server.url) | ||
162 | .get(path) | ||
163 | .query({ sort: 'hello' }) | ||
164 | .set('Accept', 'application/json') | ||
165 | .expect(400) | ||
166 | }) | ||
167 | }) | ||
168 | |||
169 | describe('When removing following', function () { | ||
170 | // it('Should fail with an invalid token', async function () { | ||
171 | // await request(server.url) | ||
172 | // .delete(path + '/1') | ||
173 | // .set('Authorization', 'Bearer faketoken') | ||
174 | // .set('Accept', 'application/json') | ||
175 | // .expect(401) | ||
176 | // }) | ||
177 | // | ||
178 | // it('Should fail if the user is not an administrator', async function () { | ||
179 | // await request(server.url) | ||
180 | // .delete(path + '/1') | ||
181 | // .set('Authorization', 'Bearer ' + userAccessToken) | ||
182 | // .set('Accept', 'application/json') | ||
183 | // .expect(403) | ||
184 | // }) | ||
185 | // | ||
186 | // it('Should fail with an undefined id', async function () { | ||
187 | // await request(server.url) | ||
188 | // .delete(path + '/' + undefined) | ||
189 | // .set('Authorization', 'Bearer ' + server.accessToken) | ||
190 | // .set('Accept', 'application/json') | ||
191 | // .expect(400) | ||
192 | // }) | ||
193 | // | ||
194 | // it('Should fail with an invalid id', async function () { | ||
195 | // await request(server.url) | ||
196 | // .delete(path + '/foobar') | ||
197 | // .set('Authorization', 'Bearer ' + server.accessToken) | ||
198 | // .set('Accept', 'application/json') | ||
199 | // .expect(400) | ||
200 | // }) | ||
201 | // | ||
202 | // it('Should fail we do not follow this server', async function () { | ||
203 | // await request(server.url) | ||
204 | // .delete(path + '/-1') | ||
205 | // .set('Authorization', 'Bearer ' + server.accessToken) | ||
206 | // .set('Accept', 'application/json') | ||
207 | // .expect(404) | ||
208 | // }) | ||
209 | // | ||
210 | // it('Should succeed with the correct parameters') | ||
211 | }) | ||
212 | }) | ||
213 | |||
214 | after(async function () { | ||
215 | killallServers([ server ]) | ||
216 | |||
217 | // Keep the logs if the test failed | ||
218 | if (this['ok']) { | ||
219 | await flushTests() | ||
220 | } | ||
221 | }) | ||
222 | }) | ||
diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts index 954b206e9..287480808 100644 --- a/server/tests/api/check-params/index.ts +++ b/server/tests/api/check-params/index.ts | |||
@@ -1,8 +1,6 @@ | |||
1 | // Order of the tests we want to execute | 1 | // Order of the tests we want to execute |
2 | import './pods' | 2 | import './follows' |
3 | import './remotes' | ||
4 | import './users' | 3 | import './users' |
5 | import './request-schedulers' | ||
6 | import './services' | 4 | import './services' |
7 | import './videos' | 5 | import './videos' |
8 | import './video-abuses' | 6 | import './video-abuses' |
diff --git a/server/tests/api/check-params/pods.ts b/server/tests/api/check-params/pods.ts deleted file mode 100644 index 9f9c2e4f0..000000000 --- a/server/tests/api/check-params/pods.ts +++ /dev/null | |||
@@ -1,287 +0,0 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as request from 'supertest' | ||
4 | import 'mocha' | ||
5 | |||
6 | import { | ||
7 | ServerInfo, | ||
8 | flushTests, | ||
9 | runServer, | ||
10 | createUser, | ||
11 | loginAndGetAccessToken, | ||
12 | setAccessTokensToServers, | ||
13 | killallServers, | ||
14 | makePostBodyRequest | ||
15 | } from '../../utils' | ||
16 | |||
17 | describe('Test pods API validators', function () { | ||
18 | let server: ServerInfo | ||
19 | |||
20 | // --------------------------------------------------------------- | ||
21 | |||
22 | before(async function () { | ||
23 | this.timeout(45000) | ||
24 | |||
25 | await flushTests() | ||
26 | server = await runServer(1) | ||
27 | |||
28 | await setAccessTokensToServers([ server ]) | ||
29 | }) | ||
30 | |||
31 | describe('When managing friends', function () { | ||
32 | const path = '/api/v1/pods/' | ||
33 | let userAccessToken = null | ||
34 | |||
35 | before(async function () { | ||
36 | await createUser(server.url, server.accessToken, 'user1', 'password') | ||
37 | server.user = { | ||
38 | username: 'user1', | ||
39 | password: 'password' | ||
40 | } | ||
41 | |||
42 | userAccessToken = await loginAndGetAccessToken(server) | ||
43 | }) | ||
44 | |||
45 | describe('When making friends', function () { | ||
46 | const body = { | ||
47 | hosts: [ 'localhost:9002' ] | ||
48 | } | ||
49 | |||
50 | it('Should fail without hosts', async function () { | ||
51 | await request(server.url) | ||
52 | .post(path + '/make-friends') | ||
53 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
54 | .set('Accept', 'application/json') | ||
55 | .expect(400) | ||
56 | }) | ||
57 | |||
58 | it('Should fail if hosts is not an array', async function () { | ||
59 | await request(server.url) | ||
60 | .post(path + '/make-friends') | ||
61 | .send({ hosts: 'localhost:9002' }) | ||
62 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
63 | .set('Accept', 'application/json') | ||
64 | .expect(400) | ||
65 | }) | ||
66 | |||
67 | it('Should fail if the array is not composed by hosts', async function () { | ||
68 | await request(server.url) | ||
69 | .post(path + '/make-friends') | ||
70 | .send({ hosts: [ 'localhost:9002', 'localhost:coucou' ] }) | ||
71 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
72 | .set('Accept', 'application/json') | ||
73 | .expect(400) | ||
74 | }) | ||
75 | |||
76 | it('Should fail if the array is composed with http schemes', async function () { | ||
77 | await request(server.url) | ||
78 | .post(path + '/make-friends') | ||
79 | .send({ hosts: [ 'localhost:9002', 'http://localhost:9003' ] }) | ||
80 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
81 | .set('Accept', 'application/json') | ||
82 | .expect(400) | ||
83 | }) | ||
84 | |||
85 | it('Should fail if hosts are not unique', async function () { | ||
86 | await request(server.url) | ||
87 | .post(path + '/make-friends') | ||
88 | .send({ urls: [ 'localhost:9002', 'localhost:9002' ] }) | ||
89 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
90 | .set('Accept', 'application/json') | ||
91 | .expect(400) | ||
92 | }) | ||
93 | |||
94 | it('Should fail with an invalid token', async function () { | ||
95 | await request(server.url) | ||
96 | .post(path + '/make-friends') | ||
97 | .send(body) | ||
98 | .set('Authorization', 'Bearer fake_token') | ||
99 | .set('Accept', 'application/json') | ||
100 | .expect(401) | ||
101 | }) | ||
102 | |||
103 | it('Should fail if the user is not an administrator', async function () { | ||
104 | await request(server.url) | ||
105 | .post(path + '/make-friends') | ||
106 | .send(body) | ||
107 | .set('Authorization', 'Bearer ' + userAccessToken) | ||
108 | .set('Accept', 'application/json') | ||
109 | .expect(403) | ||
110 | }) | ||
111 | }) | ||
112 | |||
113 | describe('When listing friends', function () { | ||
114 | it('Should fail with a bad start pagination', async function () { | ||
115 | await request(server.url) | ||
116 | .get(path) | ||
117 | .query({ start: 'hello' }) | ||
118 | .set('Accept', 'application/json') | ||
119 | .expect(400) | ||
120 | }) | ||
121 | |||
122 | it('Should fail with a bad count pagination', async function () { | ||
123 | await request(server.url) | ||
124 | .get(path) | ||
125 | .query({ count: 'hello' }) | ||
126 | .set('Accept', 'application/json') | ||
127 | .expect(400) | ||
128 | }) | ||
129 | |||
130 | it('Should fail with an incorrect sort', async function () { | ||
131 | await request(server.url) | ||
132 | .get(path) | ||
133 | .query({ sort: 'hello' }) | ||
134 | .set('Accept', 'application/json') | ||
135 | .expect(400) | ||
136 | }) | ||
137 | }) | ||
138 | |||
139 | describe('When quitting friends', function () { | ||
140 | it('Should fail with an invalid token', async function () { | ||
141 | await request(server.url) | ||
142 | .get(path + '/quit-friends') | ||
143 | .query({ start: 'hello' }) | ||
144 | .set('Authorization', 'Bearer faketoken') | ||
145 | .set('Accept', 'application/json') | ||
146 | .expect(401) | ||
147 | }) | ||
148 | |||
149 | it('Should fail if the user is not an administrator', async function () { | ||
150 | await request(server.url) | ||
151 | .get(path + '/quit-friends') | ||
152 | .query({ start: 'hello' }) | ||
153 | .set('Authorization', 'Bearer ' + userAccessToken) | ||
154 | .set('Accept', 'application/json') | ||
155 | .expect(403) | ||
156 | }) | ||
157 | }) | ||
158 | |||
159 | describe('When removing one friend', function () { | ||
160 | it('Should fail with an invalid token', async function () { | ||
161 | await request(server.url) | ||
162 | .delete(path + '/1') | ||
163 | .set('Authorization', 'Bearer faketoken') | ||
164 | .set('Accept', 'application/json') | ||
165 | .expect(401) | ||
166 | }) | ||
167 | |||
168 | it('Should fail if the user is not an administrator', async function () { | ||
169 | await request(server.url) | ||
170 | .delete(path + '/1') | ||
171 | .set('Authorization', 'Bearer ' + userAccessToken) | ||
172 | .set('Accept', 'application/json') | ||
173 | .expect(403) | ||
174 | }) | ||
175 | |||
176 | it('Should fail with an undefined id', async function () { | ||
177 | await request(server.url) | ||
178 | .delete(path + '/' + undefined) | ||
179 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
180 | .set('Accept', 'application/json') | ||
181 | .expect(400) | ||
182 | }) | ||
183 | |||
184 | it('Should fail with an invalid id', async function () { | ||
185 | await request(server.url) | ||
186 | .delete(path + '/foobar') | ||
187 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
188 | .set('Accept', 'application/json') | ||
189 | .expect(400) | ||
190 | }) | ||
191 | |||
192 | it('Should fail if the pod is not a friend', async function () { | ||
193 | await request(server.url) | ||
194 | .delete(path + '/-1') | ||
195 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
196 | .set('Accept', 'application/json') | ||
197 | .expect(404) | ||
198 | }) | ||
199 | |||
200 | it('Should succeed with the correct parameters') | ||
201 | }) | ||
202 | }) | ||
203 | |||
204 | describe('When adding a pod from remote', function () { | ||
205 | const path = '/api/v1/remote/pods/add' | ||
206 | |||
207 | it('Should fail with nothing', async function () { | ||
208 | const fields = {} | ||
209 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
210 | }) | ||
211 | |||
212 | it('Should fail without public key', async function () { | ||
213 | const fields = { | ||
214 | email: 'test.example.com', | ||
215 | host: 'coucou.com' | ||
216 | } | ||
217 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
218 | }) | ||
219 | |||
220 | it('Should fail without an email', async function () { | ||
221 | const fields = { | ||
222 | host: 'coucou.com', | ||
223 | publicKey: 'my super public key' | ||
224 | } | ||
225 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
226 | }) | ||
227 | |||
228 | it('Should fail without an invalid email', async function () { | ||
229 | const fields = { | ||
230 | host: 'coucou.com', | ||
231 | email: 'test.example.com', | ||
232 | publicKey: 'my super public key' | ||
233 | } | ||
234 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
235 | }) | ||
236 | |||
237 | it('Should fail without a host', async function () { | ||
238 | const fields = { | ||
239 | email: 'test.example.com', | ||
240 | publicKey: 'my super public key' | ||
241 | } | ||
242 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
243 | }) | ||
244 | |||
245 | it('Should fail with an incorrect host', async function () { | ||
246 | const fields = { | ||
247 | host: 'http://coucou.com', | ||
248 | email: 'test.example.com', | ||
249 | publicKey: 'my super public key' | ||
250 | } | ||
251 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
252 | |||
253 | fields.host = 'http://coucou' | ||
254 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
255 | |||
256 | fields.host = 'coucou' | ||
257 | await makePostBodyRequest({ url: server.url, path, fields }) | ||
258 | }) | ||
259 | |||
260 | it('Should succeed with the correct parameters', async function () { | ||
261 | const fields = { | ||
262 | host: 'coucou.com', | ||
263 | email: 'test@example.com', | ||
264 | publicKey: 'my super public key' | ||
265 | } | ||
266 | await makePostBodyRequest({ url: server.url, path, fields, statusCodeExpected: 200 }) | ||
267 | }) | ||
268 | |||
269 | it('Should fail with a host that already exists', async function () { | ||
270 | const fields = { | ||
271 | host: 'coucou.com', | ||
272 | email: 'test@example.com', | ||
273 | publicKey: 'my super public key' | ||
274 | } | ||
275 | await makePostBodyRequest({ url: server.url, path, fields, statusCodeExpected: 409 }) | ||
276 | }) | ||
277 | }) | ||
278 | |||
279 | after(async function () { | ||
280 | killallServers([ server ]) | ||
281 | |||
282 | // Keep the logs if the test failed | ||
283 | if (this['ok']) { | ||
284 | await flushTests() | ||
285 | } | ||
286 | }) | ||
287 | }) | ||
diff --git a/server/tests/api/check-params/remotes.ts b/server/tests/api/check-params/remotes.ts deleted file mode 100644 index 6d1747442..000000000 --- a/server/tests/api/check-params/remotes.ts +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import 'mocha' | ||
4 | |||
5 | import { | ||
6 | ServerInfo, | ||
7 | flushTests, | ||
8 | runServer, | ||
9 | setAccessTokensToServers, | ||
10 | killallServers | ||
11 | } from '../../utils' | ||
12 | |||
13 | describe('Test remote videos API validators', function () { | ||
14 | let server: ServerInfo | ||
15 | |||
16 | // --------------------------------------------------------------- | ||
17 | |||
18 | before(async function () { | ||
19 | this.timeout(60000) | ||
20 | |||
21 | await flushTests() | ||
22 | |||
23 | server = await runServer(1) | ||
24 | |||
25 | await setAccessTokensToServers([ server ]) | ||
26 | }) | ||
27 | |||
28 | describe('When making a secure request', async function () { | ||
29 | it('Should check a secure request') | ||
30 | }) | ||
31 | |||
32 | describe('When adding a video', async function () { | ||
33 | it('Should check when adding a video') | ||
34 | |||
35 | it('Should not add an existing uuid') | ||
36 | }) | ||
37 | |||
38 | describe('When removing a video', async function () { | ||
39 | it('Should check when removing a video') | ||
40 | }) | ||
41 | |||
42 | describe('When reporting abuse on a video', async function () { | ||
43 | it('Should check when reporting a video abuse') | ||
44 | }) | ||
45 | |||
46 | after(async function () { | ||
47 | killallServers([ server ]) | ||
48 | |||
49 | // Keep the logs if the test failed | ||
50 | if (this['ok']) { | ||
51 | await flushTests() | ||
52 | } | ||
53 | }) | ||
54 | }) | ||
diff --git a/server/tests/api/check-params/request-schedulers.ts b/server/tests/api/check-params/request-schedulers.ts deleted file mode 100644 index 01a54ffa1..000000000 --- a/server/tests/api/check-params/request-schedulers.ts +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as request from 'supertest' | ||
4 | import 'mocha' | ||
5 | |||
6 | import { | ||
7 | flushTests, | ||
8 | runServer, | ||
9 | createUser, | ||
10 | setAccessTokensToServers, | ||
11 | killallServers, | ||
12 | getUserAccessToken | ||
13 | } from '../../utils' | ||
14 | |||
15 | describe('Test request schedulers stats API validators', function () { | ||
16 | const path = '/api/v1/request-schedulers/stats' | ||
17 | let server = null | ||
18 | let userAccessToken = null | ||
19 | |||
20 | // --------------------------------------------------------------- | ||
21 | |||
22 | before(async function () { | ||
23 | this.timeout(60000) | ||
24 | |||
25 | await flushTests() | ||
26 | |||
27 | server = await runServer(1) | ||
28 | await setAccessTokensToServers([ server ]) | ||
29 | |||
30 | const username = 'user' | ||
31 | const password = 'my super password' | ||
32 | await createUser(server.url, server.accessToken, username, password) | ||
33 | |||
34 | const user = { | ||
35 | username: 'user', | ||
36 | password: 'my super password' | ||
37 | } | ||
38 | |||
39 | userAccessToken = await getUserAccessToken(server, user) | ||
40 | }) | ||
41 | |||
42 | it('Should fail with an non authenticated user', async function () { | ||
43 | await request(server.url) | ||
44 | .get(path) | ||
45 | .set('Accept', 'application/json') | ||
46 | .expect(401) | ||
47 | }) | ||
48 | |||
49 | it('Should fail with a non admin user', async function () { | ||
50 | await request(server.url) | ||
51 | .get(path) | ||
52 | .set('Authorization', 'Bearer ' + userAccessToken) | ||
53 | .set('Accept', 'application/json') | ||
54 | .expect(403) | ||
55 | }) | ||
56 | |||
57 | after(async function () { | ||
58 | killallServers([ server ]) | ||
59 | |||
60 | // Keep the logs if the test failed | ||
61 | if (this['ok']) { | ||
62 | await flushTests() | ||
63 | } | ||
64 | }) | ||
65 | }) | ||
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 5860e9195..7f5609784 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -473,7 +473,7 @@ describe('Test videos API validator', function () { | |||
473 | 473 | ||
474 | it('Should fail with a video of another user') | 474 | it('Should fail with a video of another user') |
475 | 475 | ||
476 | it('Should fail with a video of another pod') | 476 | it('Should fail with a video of another server') |
477 | 477 | ||
478 | it('Should succeed with the correct parameters', async function () { | 478 | it('Should succeed with the correct parameters', async function () { |
479 | const fields = getCompleteVideoUpdateAttributes() | 479 | const fields = getCompleteVideoUpdateAttributes() |
@@ -584,7 +584,7 @@ describe('Test videos API validator', function () { | |||
584 | 584 | ||
585 | it('Should fail with a video of another user') | 585 | it('Should fail with a video of another user') |
586 | 586 | ||
587 | it('Should fail with a video of another pod') | 587 | it('Should fail with a video of another server') |
588 | 588 | ||
589 | it('Should succeed with the correct parameters') | 589 | it('Should succeed with the correct parameters') |
590 | }) | 590 | }) |