aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/abuses.ts26
-rw-r--r--server/tests/api/check-params/accounts.ts2
-rw-r--r--server/tests/api/check-params/blocklist.ts91
-rw-r--r--server/tests/api/check-params/bulk.ts20
-rw-r--r--server/tests/api/check-params/config.ts24
-rw-r--r--server/tests/api/check-params/contact-form.ts2
-rw-r--r--server/tests/api/check-params/custom-pages.ts15
-rw-r--r--server/tests/api/check-params/debug.ts17
-rw-r--r--server/tests/api/check-params/follows.ts64
-rw-r--r--server/tests/api/check-params/jobs.ts19
-rw-r--r--server/tests/api/check-params/live.ts14
-rw-r--r--server/tests/api/check-params/logs.ts25
-rw-r--r--server/tests/api/check-params/plugins.ts66
-rw-r--r--server/tests/api/check-params/redundancy.ts39
-rw-r--r--server/tests/api/check-params/search.ts62
-rw-r--r--server/tests/api/check-params/services.ts6
-rw-r--r--server/tests/api/check-params/upload-quota.ts4
-rw-r--r--server/tests/api/check-params/user-notifications.ts32
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts68
-rw-r--r--server/tests/api/check-params/users.ts74
-rw-r--r--server/tests/api/check-params/video-blacklist.ts18
-rw-r--r--server/tests/api/check-params/video-captions.ts30
-rw-r--r--server/tests/api/check-params/video-channels.ts26
-rw-r--r--server/tests/api/check-params/video-comments.ts52
-rw-r--r--server/tests/api/check-params/video-imports.ts14
-rw-r--r--server/tests/api/check-params/video-playlists.ts18
-rw-r--r--server/tests/api/check-params/videos-filter.ts14
-rw-r--r--server/tests/api/check-params/videos-history.ts24
-rw-r--r--server/tests/api/check-params/videos.ts36
29 files changed, 435 insertions, 467 deletions
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 62811f932..87d93195c 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 AbusesCommand, 6 AbusesCommand,
7 checkBadCountPagination, 7 checkBadCountPagination,
@@ -66,7 +66,7 @@ describe('Test abuses API validators', function () {
66 await makeGetRequest({ 66 await makeGetRequest({
67 url: server.url, 67 url: server.url,
68 path, 68 path,
69 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 69 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
70 }) 70 })
71 }) 71 })
72 72
@@ -75,7 +75,7 @@ describe('Test abuses API validators', function () {
75 url: server.url, 75 url: server.url,
76 path, 76 path,
77 token: userToken, 77 token: userToken,
78 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 78 expectedStatus: HttpStatusCode.FORBIDDEN_403
79 }) 79 })
80 }) 80 })
81 81
@@ -110,7 +110,7 @@ describe('Test abuses API validators', function () {
110 videoIs: 'deleted' 110 videoIs: 'deleted'
111 } 111 }
112 112
113 await makeGetRequest({ url: server.url, path, token: server.accessToken, query, statusCodeExpected: HttpStatusCode.OK_200 }) 113 await makeGetRequest({ url: server.url, path, token: server.accessToken, query, expectedStatus: HttpStatusCode.OK_200 })
114 }) 114 })
115 }) 115 })
116 116
@@ -133,7 +133,7 @@ describe('Test abuses API validators', function () {
133 await makeGetRequest({ 133 await makeGetRequest({
134 url: server.url, 134 url: server.url,
135 path, 135 path,
136 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 136 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
137 }) 137 })
138 }) 138 })
139 139
@@ -152,7 +152,7 @@ describe('Test abuses API validators', function () {
152 state: 2 152 state: 2
153 } 153 }
154 154
155 await makeGetRequest({ url: server.url, path, token: userToken, query, statusCodeExpected: HttpStatusCode.OK_200 }) 155 await makeGetRequest({ url: server.url, path, token: userToken, query, expectedStatus: HttpStatusCode.OK_200 })
156 }) 156 })
157 }) 157 })
158 158
@@ -176,7 +176,7 @@ describe('Test abuses API validators', function () {
176 path, 176 path,
177 token: userToken, 177 token: userToken,
178 fields, 178 fields,
179 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 179 expectedStatus: HttpStatusCode.NOT_FOUND_404
180 }) 180 })
181 }) 181 })
182 182
@@ -192,7 +192,7 @@ describe('Test abuses API validators', function () {
192 path, 192 path,
193 token: userToken, 193 token: userToken,
194 fields, 194 fields,
195 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 195 expectedStatus: HttpStatusCode.NOT_FOUND_404
196 }) 196 })
197 }) 197 })
198 198
@@ -208,7 +208,7 @@ describe('Test abuses API validators', function () {
208 path, 208 path,
209 token: userToken, 209 token: userToken,
210 fields, 210 fields,
211 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 211 expectedStatus: HttpStatusCode.NOT_FOUND_404
212 }) 212 })
213 }) 213 })
214 214
@@ -219,14 +219,14 @@ describe('Test abuses API validators', function () {
219 path, 219 path,
220 token: userToken, 220 token: userToken,
221 fields, 221 fields,
222 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 222 expectedStatus: HttpStatusCode.BAD_REQUEST_400
223 }) 223 })
224 }) 224 })
225 225
226 it('Should fail with a non authenticated user', async function () { 226 it('Should fail with a non authenticated user', async function () {
227 const fields = { video: { id: server.store.video.id }, reason: 'my super reason' } 227 const fields = { video: { id: server.store.video.id }, reason: 'my super reason' }
228 228
229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
230 }) 230 })
231 231
232 it('Should fail with a reason too short', async function () { 232 it('Should fail with a reason too short', async function () {
@@ -249,7 +249,7 @@ describe('Test abuses API validators', function () {
249 path, 249 path,
250 token: userToken, 250 token: userToken,
251 fields, 251 fields,
252 statusCodeExpected: HttpStatusCode.OK_200 252 expectedStatus: HttpStatusCode.OK_200
253 }) 253 })
254 abuseId = res.body.abuse.id 254 abuseId = res.body.abuse.id
255 }) 255 })
@@ -283,7 +283,7 @@ describe('Test abuses API validators', function () {
283 predefinedReasons: [ 'serverRules' ] 283 predefinedReasons: [ 'serverRules' ]
284 } 284 }
285 285
286 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.OK_200 }) 286 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.OK_200 })
287 }) 287 })
288 }) 288 })
289 289
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index e866593db..0cae485d9 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index b2a1cc4e2..7d5fae5cf 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -1,23 +1,20 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 doubleFollow,
8 createMultipleServers, 9 createMultipleServers,
10 doubleFollow,
9 makeDeleteRequest, 11 makeDeleteRequest,
10 makeGetRequest, 12 makeGetRequest,
11 makePostBodyRequest, 13 makePostBodyRequest,
12 PeerTubeServer, 14 PeerTubeServer,
13 setAccessTokensToServers 15 setAccessTokensToServers
14} from '../../../../shared/extra-utils' 16} from '@shared/extra-utils'
15import { 17import { HttpStatusCode } from '@shared/models'
16 checkBadCountPagination,
17 checkBadSortPagination,
18 checkBadStartPagination
19} from '../../../../shared/extra-utils/requests/check-api-params'
20import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
21 18
22describe('Test blocklist API validators', function () { 19describe('Test blocklist API validators', function () {
23 let servers: PeerTubeServer[] 20 let servers: PeerTubeServer[]
@@ -52,7 +49,7 @@ describe('Test blocklist API validators', function () {
52 await makeGetRequest({ 49 await makeGetRequest({
53 url: server.url, 50 url: server.url,
54 path, 51 path,
55 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 52 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
56 }) 53 })
57 }) 54 })
58 55
@@ -75,7 +72,7 @@ describe('Test blocklist API validators', function () {
75 url: server.url, 72 url: server.url,
76 path, 73 path,
77 fields: { accountName: 'user1' }, 74 fields: { accountName: 'user1' },
78 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 75 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
79 }) 76 })
80 }) 77 })
81 78
@@ -85,7 +82,7 @@ describe('Test blocklist API validators', function () {
85 token: server.accessToken, 82 token: server.accessToken,
86 path, 83 path,
87 fields: { accountName: 'user2' }, 84 fields: { accountName: 'user2' },
88 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 85 expectedStatus: HttpStatusCode.NOT_FOUND_404
89 }) 86 })
90 }) 87 })
91 88
@@ -95,7 +92,7 @@ describe('Test blocklist API validators', function () {
95 token: server.accessToken, 92 token: server.accessToken,
96 path, 93 path,
97 fields: { accountName: 'root' }, 94 fields: { accountName: 'root' },
98 statusCodeExpected: HttpStatusCode.CONFLICT_409 95 expectedStatus: HttpStatusCode.CONFLICT_409
99 }) 96 })
100 }) 97 })
101 98
@@ -105,7 +102,7 @@ describe('Test blocklist API validators', function () {
105 token: server.accessToken, 102 token: server.accessToken,
106 path, 103 path,
107 fields: { accountName: 'user1' }, 104 fields: { accountName: 'user1' },
108 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 105 expectedStatus: HttpStatusCode.NO_CONTENT_204
109 }) 106 })
110 }) 107 })
111 }) 108 })
@@ -115,7 +112,7 @@ describe('Test blocklist API validators', function () {
115 await makeDeleteRequest({ 112 await makeDeleteRequest({
116 url: server.url, 113 url: server.url,
117 path: path + '/user1', 114 path: path + '/user1',
118 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 115 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
119 }) 116 })
120 }) 117 })
121 118
@@ -124,7 +121,7 @@ describe('Test blocklist API validators', function () {
124 url: server.url, 121 url: server.url,
125 path: path + '/user2', 122 path: path + '/user2',
126 token: server.accessToken, 123 token: server.accessToken,
127 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 124 expectedStatus: HttpStatusCode.NOT_FOUND_404
128 }) 125 })
129 }) 126 })
130 127
@@ -133,7 +130,7 @@ describe('Test blocklist API validators', function () {
133 url: server.url, 130 url: server.url,
134 path: path + '/user1', 131 path: path + '/user1',
135 token: server.accessToken, 132 token: server.accessToken,
136 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 133 expectedStatus: HttpStatusCode.NO_CONTENT_204
137 }) 134 })
138 }) 135 })
139 }) 136 })
@@ -147,7 +144,7 @@ describe('Test blocklist API validators', function () {
147 await makeGetRequest({ 144 await makeGetRequest({
148 url: server.url, 145 url: server.url,
149 path, 146 path,
150 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 147 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
151 }) 148 })
152 }) 149 })
153 150
@@ -170,7 +167,7 @@ describe('Test blocklist API validators', function () {
170 url: server.url, 167 url: server.url,
171 path, 168 path,
172 fields: { host: 'localhost:9002' }, 169 fields: { host: 'localhost:9002' },
173 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 170 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
174 }) 171 })
175 }) 172 })
176 173
@@ -180,7 +177,7 @@ describe('Test blocklist API validators', function () {
180 token: server.accessToken, 177 token: server.accessToken,
181 path, 178 path,
182 fields: { host: 'localhost:9003' }, 179 fields: { host: 'localhost:9003' },
183 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 180 expectedStatus: HttpStatusCode.NO_CONTENT_204
184 }) 181 })
185 }) 182 })
186 183
@@ -190,7 +187,7 @@ describe('Test blocklist API validators', function () {
190 token: server.accessToken, 187 token: server.accessToken,
191 path, 188 path,
192 fields: { host: 'localhost:' + server.port }, 189 fields: { host: 'localhost:' + server.port },
193 statusCodeExpected: HttpStatusCode.CONFLICT_409 190 expectedStatus: HttpStatusCode.CONFLICT_409
194 }) 191 })
195 }) 192 })
196 193
@@ -200,7 +197,7 @@ describe('Test blocklist API validators', function () {
200 token: server.accessToken, 197 token: server.accessToken,
201 path, 198 path,
202 fields: { host: 'localhost:' + servers[1].port }, 199 fields: { host: 'localhost:' + servers[1].port },
203 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 200 expectedStatus: HttpStatusCode.NO_CONTENT_204
204 }) 201 })
205 }) 202 })
206 }) 203 })
@@ -210,7 +207,7 @@ describe('Test blocklist API validators', function () {
210 await makeDeleteRequest({ 207 await makeDeleteRequest({
211 url: server.url, 208 url: server.url,
212 path: path + '/localhost:' + servers[1].port, 209 path: path + '/localhost:' + servers[1].port,
213 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 210 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
214 }) 211 })
215 }) 212 })
216 213
@@ -219,7 +216,7 @@ describe('Test blocklist API validators', function () {
219 url: server.url, 216 url: server.url,
220 path: path + '/localhost:9004', 217 path: path + '/localhost:9004',
221 token: server.accessToken, 218 token: server.accessToken,
222 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 219 expectedStatus: HttpStatusCode.NOT_FOUND_404
223 }) 220 })
224 }) 221 })
225 222
@@ -228,7 +225,7 @@ describe('Test blocklist API validators', function () {
228 url: server.url, 225 url: server.url,
229 path: path + '/localhost:' + servers[1].port, 226 path: path + '/localhost:' + servers[1].port,
230 token: server.accessToken, 227 token: server.accessToken,
231 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 228 expectedStatus: HttpStatusCode.NO_CONTENT_204
232 }) 229 })
233 }) 230 })
234 }) 231 })
@@ -245,7 +242,7 @@ describe('Test blocklist API validators', function () {
245 await makeGetRequest({ 242 await makeGetRequest({
246 url: server.url, 243 url: server.url,
247 path, 244 path,
248 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 245 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
249 }) 246 })
250 }) 247 })
251 248
@@ -254,7 +251,7 @@ describe('Test blocklist API validators', function () {
254 url: server.url, 251 url: server.url,
255 token: userAccessToken, 252 token: userAccessToken,
256 path, 253 path,
257 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 254 expectedStatus: HttpStatusCode.FORBIDDEN_403
258 }) 255 })
259 }) 256 })
260 257
@@ -277,7 +274,7 @@ describe('Test blocklist API validators', function () {
277 url: server.url, 274 url: server.url,
278 path, 275 path,
279 fields: { accountName: 'user1' }, 276 fields: { accountName: 'user1' },
280 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 277 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
281 }) 278 })
282 }) 279 })
283 280
@@ -287,7 +284,7 @@ describe('Test blocklist API validators', function () {
287 token: userAccessToken, 284 token: userAccessToken,
288 path, 285 path,
289 fields: { accountName: 'user1' }, 286 fields: { accountName: 'user1' },
290 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 287 expectedStatus: HttpStatusCode.FORBIDDEN_403
291 }) 288 })
292 }) 289 })
293 290
@@ -297,7 +294,7 @@ describe('Test blocklist API validators', function () {
297 token: server.accessToken, 294 token: server.accessToken,
298 path, 295 path,
299 fields: { accountName: 'user2' }, 296 fields: { accountName: 'user2' },
300 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 297 expectedStatus: HttpStatusCode.NOT_FOUND_404
301 }) 298 })
302 }) 299 })
303 300
@@ -307,7 +304,7 @@ describe('Test blocklist API validators', function () {
307 token: server.accessToken, 304 token: server.accessToken,
308 path, 305 path,
309 fields: { accountName: 'root' }, 306 fields: { accountName: 'root' },
310 statusCodeExpected: HttpStatusCode.CONFLICT_409 307 expectedStatus: HttpStatusCode.CONFLICT_409
311 }) 308 })
312 }) 309 })
313 310
@@ -317,7 +314,7 @@ describe('Test blocklist API validators', function () {
317 token: server.accessToken, 314 token: server.accessToken,
318 path, 315 path,
319 fields: { accountName: 'user1' }, 316 fields: { accountName: 'user1' },
320 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 317 expectedStatus: HttpStatusCode.NO_CONTENT_204
321 }) 318 })
322 }) 319 })
323 }) 320 })
@@ -327,7 +324,7 @@ describe('Test blocklist API validators', function () {
327 await makeDeleteRequest({ 324 await makeDeleteRequest({
328 url: server.url, 325 url: server.url,
329 path: path + '/user1', 326 path: path + '/user1',
330 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 327 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
331 }) 328 })
332 }) 329 })
333 330
@@ -336,7 +333,7 @@ describe('Test blocklist API validators', function () {
336 url: server.url, 333 url: server.url,
337 path: path + '/user1', 334 path: path + '/user1',
338 token: userAccessToken, 335 token: userAccessToken,
339 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 336 expectedStatus: HttpStatusCode.FORBIDDEN_403
340 }) 337 })
341 }) 338 })
342 339
@@ -345,7 +342,7 @@ describe('Test blocklist API validators', function () {
345 url: server.url, 342 url: server.url,
346 path: path + '/user2', 343 path: path + '/user2',
347 token: server.accessToken, 344 token: server.accessToken,
348 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 345 expectedStatus: HttpStatusCode.NOT_FOUND_404
349 }) 346 })
350 }) 347 })
351 348
@@ -354,7 +351,7 @@ describe('Test blocklist API validators', function () {
354 url: server.url, 351 url: server.url,
355 path: path + '/user1', 352 path: path + '/user1',
356 token: server.accessToken, 353 token: server.accessToken,
357 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 354 expectedStatus: HttpStatusCode.NO_CONTENT_204
358 }) 355 })
359 }) 356 })
360 }) 357 })
@@ -368,7 +365,7 @@ describe('Test blocklist API validators', function () {
368 await makeGetRequest({ 365 await makeGetRequest({
369 url: server.url, 366 url: server.url,
370 path, 367 path,
371 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 368 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
372 }) 369 })
373 }) 370 })
374 371
@@ -377,7 +374,7 @@ describe('Test blocklist API validators', function () {
377 url: server.url, 374 url: server.url,
378 token: userAccessToken, 375 token: userAccessToken,
379 path, 376 path,
380 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 377 expectedStatus: HttpStatusCode.FORBIDDEN_403
381 }) 378 })
382 }) 379 })
383 380
@@ -400,7 +397,7 @@ describe('Test blocklist API validators', function () {
400 url: server.url, 397 url: server.url,
401 path, 398 path,
402 fields: { host: 'localhost:' + servers[1].port }, 399 fields: { host: 'localhost:' + servers[1].port },
403 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 400 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
404 }) 401 })
405 }) 402 })
406 403
@@ -410,7 +407,7 @@ describe('Test blocklist API validators', function () {
410 token: userAccessToken, 407 token: userAccessToken,
411 path, 408 path,
412 fields: { host: 'localhost:' + servers[1].port }, 409 fields: { host: 'localhost:' + servers[1].port },
413 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 410 expectedStatus: HttpStatusCode.FORBIDDEN_403
414 }) 411 })
415 }) 412 })
416 413
@@ -420,7 +417,7 @@ describe('Test blocklist API validators', function () {
420 token: server.accessToken, 417 token: server.accessToken,
421 path, 418 path,
422 fields: { host: 'localhost:9003' }, 419 fields: { host: 'localhost:9003' },
423 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 420 expectedStatus: HttpStatusCode.NO_CONTENT_204
424 }) 421 })
425 }) 422 })
426 423
@@ -430,7 +427,7 @@ describe('Test blocklist API validators', function () {
430 token: server.accessToken, 427 token: server.accessToken,
431 path, 428 path,
432 fields: { host: 'localhost:' + server.port }, 429 fields: { host: 'localhost:' + server.port },
433 statusCodeExpected: HttpStatusCode.CONFLICT_409 430 expectedStatus: HttpStatusCode.CONFLICT_409
434 }) 431 })
435 }) 432 })
436 433
@@ -440,7 +437,7 @@ describe('Test blocklist API validators', function () {
440 token: server.accessToken, 437 token: server.accessToken,
441 path, 438 path,
442 fields: { host: 'localhost:' + servers[1].port }, 439 fields: { host: 'localhost:' + servers[1].port },
443 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 440 expectedStatus: HttpStatusCode.NO_CONTENT_204
444 }) 441 })
445 }) 442 })
446 }) 443 })
@@ -450,7 +447,7 @@ describe('Test blocklist API validators', function () {
450 await makeDeleteRequest({ 447 await makeDeleteRequest({
451 url: server.url, 448 url: server.url,
452 path: path + '/localhost:' + servers[1].port, 449 path: path + '/localhost:' + servers[1].port,
453 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 450 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
454 }) 451 })
455 }) 452 })
456 453
@@ -459,7 +456,7 @@ describe('Test blocklist API validators', function () {
459 url: server.url, 456 url: server.url,
460 path: path + '/localhost:' + servers[1].port, 457 path: path + '/localhost:' + servers[1].port,
461 token: userAccessToken, 458 token: userAccessToken,
462 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 459 expectedStatus: HttpStatusCode.FORBIDDEN_403
463 }) 460 })
464 }) 461 })
465 462
@@ -468,7 +465,7 @@ describe('Test blocklist API validators', function () {
468 url: server.url, 465 url: server.url,
469 path: path + '/localhost:9004', 466 path: path + '/localhost:9004',
470 token: server.accessToken, 467 token: server.accessToken,
471 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 468 expectedStatus: HttpStatusCode.NOT_FOUND_404
472 }) 469 })
473 }) 470 })
474 471
@@ -477,7 +474,7 @@ describe('Test blocklist API validators', function () {
477 url: server.url, 474 url: server.url,
478 path: path + '/localhost:' + servers[1].port, 475 path: path + '/localhost:' + servers[1].port,
479 token: server.accessToken, 476 token: server.accessToken,
480 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 477 expectedStatus: HttpStatusCode.NO_CONTENT_204
481 }) 478 })
482 }) 479 })
483 }) 480 })
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts
index a660c3d80..bc9d7784d 100644
--- a/server/tests/api/check-params/bulk.ts
+++ b/server/tests/api/check-params/bulk.ts
@@ -1,14 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { 4import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
5 cleanupTests, 5import { HttpStatusCode } from '@shared/models'
6 createSingleServer,
7 PeerTubeServer,
8 setAccessTokensToServers
9} from '../../../../shared/extra-utils'
10import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
11import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
12 6
13describe('Test bulk API validators', function () { 7describe('Test bulk API validators', function () {
14 let server: PeerTubeServer 8 let server: PeerTubeServer
@@ -36,7 +30,7 @@ describe('Test bulk API validators', function () {
36 url: server.url, 30 url: server.url,
37 path, 31 path,
38 fields: { accountName: 'user1', scope: 'my-videos' }, 32 fields: { accountName: 'user1', scope: 'my-videos' },
39 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 33 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
40 }) 34 })
41 }) 35 })
42 36
@@ -46,7 +40,7 @@ describe('Test bulk API validators', function () {
46 token: server.accessToken, 40 token: server.accessToken,
47 path, 41 path,
48 fields: { accountName: 'user2', scope: 'my-videos' }, 42 fields: { accountName: 'user2', scope: 'my-videos' },
49 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 43 expectedStatus: HttpStatusCode.NOT_FOUND_404
50 }) 44 })
51 }) 45 })
52 46
@@ -56,7 +50,7 @@ describe('Test bulk API validators', function () {
56 token: server.accessToken, 50 token: server.accessToken,
57 path, 51 path,
58 fields: { accountName: 'user1', scope: 'my-videoss' }, 52 fields: { accountName: 'user1', scope: 'my-videoss' },
59 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 53 expectedStatus: HttpStatusCode.BAD_REQUEST_400
60 }) 54 })
61 }) 55 })
62 56
@@ -66,7 +60,7 @@ describe('Test bulk API validators', function () {
66 token: userAccessToken, 60 token: userAccessToken,
67 path, 61 path,
68 fields: { accountName: 'user1', scope: 'instance' }, 62 fields: { accountName: 'user1', scope: 'instance' },
69 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 63 expectedStatus: HttpStatusCode.FORBIDDEN_403
70 }) 64 })
71 }) 65 })
72 66
@@ -76,7 +70,7 @@ describe('Test bulk API validators', function () {
76 token: server.accessToken, 70 token: server.accessToken,
77 path, 71 path,
78 fields: { accountName: 'user1', scope: 'instance' }, 72 fields: { accountName: 'user1', scope: 'instance' },
79 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 73 expectedStatus: HttpStatusCode.NO_CONTENT_204
80 }) 74 })
81 }) 75 })
82 }) 76 })
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 1756d58ee..c3438917e 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -214,7 +214,7 @@ describe('Test config API validators', function () {
214 await makeGetRequest({ 214 await makeGetRequest({
215 url: server.url, 215 url: server.url,
216 path, 216 path,
217 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 217 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
218 }) 218 })
219 }) 219 })
220 220
@@ -223,7 +223,7 @@ describe('Test config API validators', function () {
223 url: server.url, 223 url: server.url,
224 path, 224 path,
225 token: userAccessToken, 225 token: userAccessToken,
226 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 226 expectedStatus: HttpStatusCode.FORBIDDEN_403
227 }) 227 })
228 }) 228 })
229 }) 229 })
@@ -234,7 +234,7 @@ describe('Test config API validators', function () {
234 url: server.url, 234 url: server.url,
235 path, 235 path,
236 fields: updateParams, 236 fields: updateParams,
237 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 237 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
238 }) 238 })
239 }) 239 })
240 240
@@ -244,7 +244,7 @@ describe('Test config API validators', function () {
244 path, 244 path,
245 fields: updateParams, 245 fields: updateParams,
246 token: userAccessToken, 246 token: userAccessToken,
247 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 247 expectedStatus: HttpStatusCode.FORBIDDEN_403
248 }) 248 })
249 }) 249 })
250 250
@@ -256,7 +256,7 @@ describe('Test config API validators', function () {
256 path, 256 path,
257 fields: newUpdateParams, 257 fields: newUpdateParams,
258 token: server.accessToken, 258 token: server.accessToken,
259 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 259 expectedStatus: HttpStatusCode.BAD_REQUEST_400
260 }) 260 })
261 }) 261 })
262 262
@@ -274,7 +274,7 @@ describe('Test config API validators', function () {
274 path, 274 path,
275 fields: newUpdateParams, 275 fields: newUpdateParams,
276 token: server.accessToken, 276 token: server.accessToken,
277 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 277 expectedStatus: HttpStatusCode.BAD_REQUEST_400
278 }) 278 })
279 }) 279 })
280 280
@@ -295,7 +295,7 @@ describe('Test config API validators', function () {
295 path, 295 path,
296 fields: newUpdateParams, 296 fields: newUpdateParams,
297 token: server.accessToken, 297 token: server.accessToken,
298 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 298 expectedStatus: HttpStatusCode.BAD_REQUEST_400
299 }) 299 })
300 }) 300 })
301 301
@@ -318,7 +318,7 @@ describe('Test config API validators', function () {
318 path, 318 path,
319 fields: newUpdateParams, 319 fields: newUpdateParams,
320 token: server.accessToken, 320 token: server.accessToken,
321 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 321 expectedStatus: HttpStatusCode.BAD_REQUEST_400
322 }) 322 })
323 }) 323 })
324 324
@@ -328,7 +328,7 @@ describe('Test config API validators', function () {
328 path, 328 path,
329 fields: updateParams, 329 fields: updateParams,
330 token: server.accessToken, 330 token: server.accessToken,
331 statusCodeExpected: HttpStatusCode.OK_200 331 expectedStatus: HttpStatusCode.OK_200
332 }) 332 })
333 }) 333 })
334 }) 334 })
@@ -338,7 +338,7 @@ describe('Test config API validators', function () {
338 await makeDeleteRequest({ 338 await makeDeleteRequest({
339 url: server.url, 339 url: server.url,
340 path, 340 path,
341 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 341 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
342 }) 342 })
343 }) 343 })
344 344
@@ -347,7 +347,7 @@ describe('Test config API validators', function () {
347 url: server.url, 347 url: server.url,
348 path, 348 path,
349 token: userAccessToken, 349 token: userAccessToken,
350 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 350 expectedStatus: HttpStatusCode.FORBIDDEN_403
351 }) 351 })
352 }) 352 })
353 }) 353 })
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 8c2b2a84b..8e755c69b 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils' 5import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils'
6import { ContactFormCommand } from '@shared/extra-utils/server' 6import { ContactFormCommand } from '@shared/extra-utils/server'
7 7
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts
index 043505e32..9fbbea315 100644
--- a/server/tests/api/check-params/custom-pages.ts
+++ b/server/tests/api/check-params/custom-pages.ts
@@ -1,14 +1,15 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5import { 4import {
6 cleanupTests, 5 cleanupTests,
7 createSingleServer, 6 createSingleServer,
7 makeGetRequest,
8 makePutBodyRequest,
8 PeerTubeServer, 9 PeerTubeServer,
9 setAccessTokensToServers 10 setAccessTokensToServers
10} from '../../../../shared/extra-utils' 11} from '@shared/extra-utils'
11import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests' 12import { HttpStatusCode } from '@shared/models'
12 13
13describe('Test custom pages validators', function () { 14describe('Test custom pages validators', function () {
14 const path = '/api/v1/custom-pages/homepage/instance' 15 const path = '/api/v1/custom-pages/homepage/instance'
@@ -37,7 +38,7 @@ describe('Test custom pages validators', function () {
37 url: server.url, 38 url: server.url,
38 path, 39 path,
39 fields: { content: 'super content' }, 40 fields: { content: 'super content' },
40 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 41 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
41 }) 42 })
42 }) 43 })
43 44
@@ -47,7 +48,7 @@ describe('Test custom pages validators', function () {
47 path, 48 path,
48 token: userAccessToken, 49 token: userAccessToken,
49 fields: { content: 'super content' }, 50 fields: { content: 'super content' },
50 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 51 expectedStatus: HttpStatusCode.FORBIDDEN_403
51 }) 52 })
52 }) 53 })
53 54
@@ -57,7 +58,7 @@ describe('Test custom pages validators', function () {
57 path, 58 path,
58 token: server.accessToken, 59 token: server.accessToken,
59 fields: { content: 'super content' }, 60 fields: { content: 'super content' },
60 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 61 expectedStatus: HttpStatusCode.NO_CONTENT_204
61 }) 62 })
62 }) 63 })
63 }) 64 })
@@ -68,7 +69,7 @@ describe('Test custom pages validators', function () {
68 await makeGetRequest({ 69 await makeGetRequest({
69 url: server.url, 70 url: server.url,
70 path, 71 path,
71 statusCodeExpected: HttpStatusCode.OK_200 72 expectedStatus: HttpStatusCode.OK_200
72 }) 73 })
73 }) 74 })
74 }) 75 })
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 9c13e9daf..a55786359 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -1,15 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4 4import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
5import { 5import { HttpStatusCode } from '@shared/models'
6 cleanupTests,
7 createSingleServer,
8 PeerTubeServer,
9 setAccessTokensToServers
10} from '../../../../shared/extra-utils'
11import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
12import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
13 6
14describe('Test debug API validators', function () { 7describe('Test debug API validators', function () {
15 const path = '/api/v1/server/debug' 8 const path = '/api/v1/server/debug'
@@ -39,7 +32,7 @@ describe('Test debug API validators', function () {
39 await makeGetRequest({ 32 await makeGetRequest({
40 url: server.url, 33 url: server.url,
41 path, 34 path,
42 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 35 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
43 }) 36 })
44 }) 37 })
45 38
@@ -48,7 +41,7 @@ describe('Test debug API validators', function () {
48 url: server.url, 41 url: server.url,
49 path, 42 path,
50 token: userAccessToken, 43 token: userAccessToken,
51 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 44 expectedStatus: HttpStatusCode.FORBIDDEN_403
52 }) 45 })
53 }) 46 })
54 47
@@ -58,7 +51,7 @@ describe('Test debug API validators', function () {
58 path, 51 path,
59 token: server.accessToken, 52 token: server.accessToken,
60 query: { startDate: new Date().toISOString() }, 53 query: { startDate: new Date().toISOString() },
61 statusCodeExpected: HttpStatusCode.OK_200 54 expectedStatus: HttpStatusCode.OK_200
62 }) 55 })
63 }) 56 })
64 }) 57 })
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 0fd2b4925..dfe3f226d 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -1,21 +1,19 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 createSingleServer, 9 createSingleServer,
8 makeDeleteRequest, makeGetRequest, 10 makeDeleteRequest,
11 makeGetRequest,
9 makePostBodyRequest, 12 makePostBodyRequest,
10 PeerTubeServer, 13 PeerTubeServer,
11 setAccessTokensToServers 14 setAccessTokensToServers
12} from '../../../../shared/extra-utils' 15} from '@shared/extra-utils'
13import { 16import { HttpStatusCode } from '@shared/models'
14 checkBadCountPagination,
15 checkBadSortPagination,
16 checkBadStartPagination
17} from '../../../../shared/extra-utils/requests/check-api-params'
18import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 17
20describe('Test server follows API validators', function () { 18describe('Test server follows API validators', function () {
21 let server: PeerTubeServer 19 let server: PeerTubeServer
@@ -51,7 +49,7 @@ describe('Test server follows API validators', function () {
51 url: server.url, 49 url: server.url,
52 path, 50 path,
53 token: server.accessToken, 51 token: server.accessToken,
54 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 52 expectedStatus: HttpStatusCode.BAD_REQUEST_400
55 }) 53 })
56 }) 54 })
57 55
@@ -61,7 +59,7 @@ describe('Test server follows API validators', function () {
61 path, 59 path,
62 token: server.accessToken, 60 token: server.accessToken,
63 fields: { hosts: 'localhost:9002' }, 61 fields: { hosts: 'localhost:9002' },
64 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 62 expectedStatus: HttpStatusCode.BAD_REQUEST_400
65 }) 63 })
66 }) 64 })
67 65
@@ -71,7 +69,7 @@ describe('Test server follows API validators', function () {
71 path, 69 path,
72 fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, 70 fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] },
73 token: server.accessToken, 71 token: server.accessToken,
74 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 72 expectedStatus: HttpStatusCode.BAD_REQUEST_400
75 }) 73 })
76 }) 74 })
77 75
@@ -81,7 +79,7 @@ describe('Test server follows API validators', function () {
81 path, 79 path,
82 fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, 80 fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] },
83 token: server.accessToken, 81 token: server.accessToken,
84 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 82 expectedStatus: HttpStatusCode.BAD_REQUEST_400
85 }) 83 })
86 }) 84 })
87 85
@@ -91,7 +89,7 @@ describe('Test server follows API validators', function () {
91 path, 89 path,
92 fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, 90 fields: { urls: [ 'localhost:9002', 'localhost:9002' ] },
93 token: server.accessToken, 91 token: server.accessToken,
94 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 92 expectedStatus: HttpStatusCode.BAD_REQUEST_400
95 }) 93 })
96 }) 94 })
97 95
@@ -101,7 +99,7 @@ describe('Test server follows API validators', function () {
101 path, 99 path,
102 fields: { hosts: [ 'localhost:9002' ] }, 100 fields: { hosts: [ 'localhost:9002' ] },
103 token: 'fake_token', 101 token: 'fake_token',
104 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 102 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
105 }) 103 })
106 }) 104 })
107 105
@@ -111,7 +109,7 @@ describe('Test server follows API validators', function () {
111 path, 109 path,
112 fields: { hosts: [ 'localhost:9002' ] }, 110 fields: { hosts: [ 'localhost:9002' ] },
113 token: userAccessToken, 111 token: userAccessToken,
114 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 112 expectedStatus: HttpStatusCode.FORBIDDEN_403
115 }) 113 })
116 }) 114 })
117 }) 115 })
@@ -155,7 +153,7 @@ describe('Test server follows API validators', function () {
155 await makeGetRequest({ 153 await makeGetRequest({
156 url: server.url, 154 url: server.url,
157 path, 155 path,
158 statusCodeExpected: HttpStatusCode.OK_200, 156 expectedStatus: HttpStatusCode.OK_200,
159 query: { 157 query: {
160 state: 'accepted', 158 state: 'accepted',
161 actorType: 'Application' 159 actorType: 'Application'
@@ -204,7 +202,7 @@ describe('Test server follows API validators', function () {
204 await makeGetRequest({ 202 await makeGetRequest({
205 url: server.url, 203 url: server.url,
206 path, 204 path,
207 statusCodeExpected: HttpStatusCode.OK_200, 205 expectedStatus: HttpStatusCode.OK_200,
208 query: { 206 query: {
209 state: 'accepted' 207 state: 'accepted'
210 } 208 }
@@ -220,7 +218,7 @@ describe('Test server follows API validators', function () {
220 url: server.url, 218 url: server.url,
221 path: path + '/toto@localhost:9002', 219 path: path + '/toto@localhost:9002',
222 token: 'fake_token', 220 token: 'fake_token',
223 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 221 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
224 }) 222 })
225 }) 223 })
226 224
@@ -229,7 +227,7 @@ describe('Test server follows API validators', function () {
229 url: server.url, 227 url: server.url,
230 path: path + '/toto@localhost:9002', 228 path: path + '/toto@localhost:9002',
231 token: userAccessToken, 229 token: userAccessToken,
232 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 230 expectedStatus: HttpStatusCode.FORBIDDEN_403
233 }) 231 })
234 }) 232 })
235 233
@@ -238,7 +236,7 @@ describe('Test server follows API validators', function () {
238 url: server.url, 236 url: server.url,
239 path: path + '/toto', 237 path: path + '/toto',
240 token: server.accessToken, 238 token: server.accessToken,
241 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 239 expectedStatus: HttpStatusCode.BAD_REQUEST_400
242 }) 240 })
243 }) 241 })
244 242
@@ -247,7 +245,7 @@ describe('Test server follows API validators', function () {
247 url: server.url, 245 url: server.url,
248 path: path + '/toto@localhost:9003', 246 path: path + '/toto@localhost:9003',
249 token: server.accessToken, 247 token: server.accessToken,
250 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 248 expectedStatus: HttpStatusCode.NOT_FOUND_404
251 }) 249 })
252 }) 250 })
253 }) 251 })
@@ -260,7 +258,7 @@ describe('Test server follows API validators', function () {
260 url: server.url, 258 url: server.url,
261 path: path + '/toto@localhost:9002/accept', 259 path: path + '/toto@localhost:9002/accept',
262 token: 'fake_token', 260 token: 'fake_token',
263 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 261 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
264 }) 262 })
265 }) 263 })
266 264
@@ -269,7 +267,7 @@ describe('Test server follows API validators', function () {
269 url: server.url, 267 url: server.url,
270 path: path + '/toto@localhost:9002/accept', 268 path: path + '/toto@localhost:9002/accept',
271 token: userAccessToken, 269 token: userAccessToken,
272 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 270 expectedStatus: HttpStatusCode.FORBIDDEN_403
273 }) 271 })
274 }) 272 })
275 273
@@ -278,7 +276,7 @@ describe('Test server follows API validators', function () {
278 url: server.url, 276 url: server.url,
279 path: path + '/toto/accept', 277 path: path + '/toto/accept',
280 token: server.accessToken, 278 token: server.accessToken,
281 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 279 expectedStatus: HttpStatusCode.BAD_REQUEST_400
282 }) 280 })
283 }) 281 })
284 282
@@ -287,7 +285,7 @@ describe('Test server follows API validators', function () {
287 url: server.url, 285 url: server.url,
288 path: path + '/toto@localhost:9003/accept', 286 path: path + '/toto@localhost:9003/accept',
289 token: server.accessToken, 287 token: server.accessToken,
290 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 288 expectedStatus: HttpStatusCode.NOT_FOUND_404
291 }) 289 })
292 }) 290 })
293 }) 291 })
@@ -300,7 +298,7 @@ describe('Test server follows API validators', function () {
300 url: server.url, 298 url: server.url,
301 path: path + '/toto@localhost:9002/reject', 299 path: path + '/toto@localhost:9002/reject',
302 token: 'fake_token', 300 token: 'fake_token',
303 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 301 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
304 }) 302 })
305 }) 303 })
306 304
@@ -309,7 +307,7 @@ describe('Test server follows API validators', function () {
309 url: server.url, 307 url: server.url,
310 path: path + '/toto@localhost:9002/reject', 308 path: path + '/toto@localhost:9002/reject',
311 token: userAccessToken, 309 token: userAccessToken,
312 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 310 expectedStatus: HttpStatusCode.FORBIDDEN_403
313 }) 311 })
314 }) 312 })
315 313
@@ -318,7 +316,7 @@ describe('Test server follows API validators', function () {
318 url: server.url, 316 url: server.url,
319 path: path + '/toto/reject', 317 path: path + '/toto/reject',
320 token: server.accessToken, 318 token: server.accessToken,
321 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 319 expectedStatus: HttpStatusCode.BAD_REQUEST_400
322 }) 320 })
323 }) 321 })
324 322
@@ -327,7 +325,7 @@ describe('Test server follows API validators', function () {
327 url: server.url, 325 url: server.url,
328 path: path + '/toto@localhost:9003/reject', 326 path: path + '/toto@localhost:9003/reject',
329 token: server.accessToken, 327 token: server.accessToken,
330 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 328 expectedStatus: HttpStatusCode.NOT_FOUND_404
331 }) 329 })
332 }) 330 })
333 }) 331 })
@@ -340,7 +338,7 @@ describe('Test server follows API validators', function () {
340 url: server.url, 338 url: server.url,
341 path: path + '/localhost:9002', 339 path: path + '/localhost:9002',
342 token: 'fake_token', 340 token: 'fake_token',
343 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 341 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
344 }) 342 })
345 }) 343 })
346 344
@@ -349,7 +347,7 @@ describe('Test server follows API validators', function () {
349 url: server.url, 347 url: server.url,
350 path: path + '/localhost:9002', 348 path: path + '/localhost:9002',
351 token: userAccessToken, 349 token: userAccessToken,
352 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 350 expectedStatus: HttpStatusCode.FORBIDDEN_403
353 }) 351 })
354 }) 352 })
355 353
@@ -358,7 +356,7 @@ describe('Test server follows API validators', function () {
358 url: server.url, 356 url: server.url,
359 path: path + '/example.com', 357 path: path + '/example.com',
360 token: server.accessToken, 358 token: server.accessToken,
361 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 359 expectedStatus: HttpStatusCode.NOT_FOUND_404
362 }) 360 })
363 }) 361 })
364 }) 362 })
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index a370ec2d3..23d95d8e4 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -1,20 +1,17 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 createSingleServer, 9 createSingleServer,
10 makeGetRequest,
8 PeerTubeServer, 11 PeerTubeServer,
9 setAccessTokensToServers 12 setAccessTokensToServers
10} from '../../../../shared/extra-utils' 13} from '@shared/extra-utils'
11import { 14import { HttpStatusCode } from '@shared/models'
12 checkBadCountPagination,
13 checkBadSortPagination,
14 checkBadStartPagination
15} from '../../../../shared/extra-utils/requests/check-api-params'
16import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
17import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
18 15
19describe('Test jobs API validators', function () { 16describe('Test jobs API validators', function () {
20 const path = '/api/v1/jobs/failed' 17 const path = '/api/v1/jobs/failed'
@@ -75,7 +72,7 @@ describe('Test jobs API validators', function () {
75 await makeGetRequest({ 72 await makeGetRequest({
76 url: server.url, 73 url: server.url,
77 path, 74 path,
78 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 75 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
79 }) 76 })
80 }) 77 })
81 78
@@ -84,7 +81,7 @@ describe('Test jobs API validators', function () {
84 url: server.url, 81 url: server.url,
85 path, 82 path,
86 token: userAccessToken, 83 token: userAccessToken,
87 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 84 expectedStatus: HttpStatusCode.FORBIDDEN_403
88 }) 85 })
89 }) 86 })
90 87
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index eb5cdd1d8..0ef86a538 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 cleanupTests, 8 cleanupTests,
@@ -223,7 +223,7 @@ describe('Test video lives API validator', function () {
223 path, 223 path,
224 token: server.accessToken, 224 token: server.accessToken,
225 fields: baseCorrectParams, 225 fields: baseCorrectParams,
226 statusCodeExpected: HttpStatusCode.OK_200 226 expectedStatus: HttpStatusCode.OK_200
227 }) 227 })
228 228
229 video = res.body.video 229 video = res.body.video
@@ -243,7 +243,7 @@ describe('Test video lives API validator', function () {
243 path, 243 path,
244 token: server.accessToken, 244 token: server.accessToken,
245 fields: baseCorrectParams, 245 fields: baseCorrectParams,
246 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 246 expectedStatus: HttpStatusCode.FORBIDDEN_403
247 }) 247 })
248 }) 248 })
249 249
@@ -264,7 +264,7 @@ describe('Test video lives API validator', function () {
264 path, 264 path,
265 token: server.accessToken, 265 token: server.accessToken,
266 fields, 266 fields,
267 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 267 expectedStatus: HttpStatusCode.FORBIDDEN_403
268 }) 268 })
269 }) 269 })
270 270
@@ -285,7 +285,7 @@ describe('Test video lives API validator', function () {
285 path, 285 path,
286 token: server.accessToken, 286 token: server.accessToken,
287 fields, 287 fields,
288 statusCodeExpected: HttpStatusCode.OK_200 288 expectedStatus: HttpStatusCode.OK_200
289 }) 289 })
290 }) 290 })
291 291
@@ -304,7 +304,7 @@ describe('Test video lives API validator', function () {
304 path, 304 path,
305 token: server.accessToken, 305 token: server.accessToken,
306 fields: baseCorrectParams, 306 fields: baseCorrectParams,
307 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 307 expectedStatus: HttpStatusCode.FORBIDDEN_403
308 }) 308 })
309 }) 309 })
310 310
@@ -324,7 +324,7 @@ describe('Test video lives API validator', function () {
324 path, 324 path,
325 token: server.accessToken, 325 token: server.accessToken,
326 fields: baseCorrectParams, 326 fields: baseCorrectParams,
327 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 327 expectedStatus: HttpStatusCode.FORBIDDEN_403
328 }) 328 })
329 }) 329 })
330 }) 330 })
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index 2eb074007..05372257a 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -1,15 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4 4import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
5import { 5import { HttpStatusCode } from '@shared/models'
6 cleanupTests,
7 createSingleServer,
8 PeerTubeServer,
9 setAccessTokensToServers
10} from '../../../../shared/extra-utils'
11import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
12import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
13 6
14describe('Test logs API validators', function () { 7describe('Test logs API validators', function () {
15 const path = '/api/v1/server/logs' 8 const path = '/api/v1/server/logs'
@@ -39,7 +32,7 @@ describe('Test logs API validators', function () {
39 await makeGetRequest({ 32 await makeGetRequest({
40 url: server.url, 33 url: server.url,
41 path, 34 path,
42 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 35 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
43 }) 36 })
44 }) 37 })
45 38
@@ -48,7 +41,7 @@ describe('Test logs API validators', function () {
48 url: server.url, 41 url: server.url,
49 path, 42 path,
50 token: userAccessToken, 43 token: userAccessToken,
51 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 44 expectedStatus: HttpStatusCode.FORBIDDEN_403
52 }) 45 })
53 }) 46 })
54 47
@@ -57,7 +50,7 @@ describe('Test logs API validators', function () {
57 url: server.url, 50 url: server.url,
58 path, 51 path,
59 token: server.accessToken, 52 token: server.accessToken,
60 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 53 expectedStatus: HttpStatusCode.BAD_REQUEST_400
61 }) 54 })
62 }) 55 })
63 56
@@ -67,7 +60,7 @@ describe('Test logs API validators', function () {
67 path, 60 path,
68 token: server.accessToken, 61 token: server.accessToken,
69 query: { startDate: 'toto' }, 62 query: { startDate: 'toto' },
70 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 63 expectedStatus: HttpStatusCode.BAD_REQUEST_400
71 }) 64 })
72 }) 65 })
73 66
@@ -77,7 +70,7 @@ describe('Test logs API validators', function () {
77 path, 70 path,
78 token: server.accessToken, 71 token: server.accessToken,
79 query: { startDate: new Date().toISOString(), endDate: 'toto' }, 72 query: { startDate: new Date().toISOString(), endDate: 'toto' },
80 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 73 expectedStatus: HttpStatusCode.BAD_REQUEST_400
81 }) 74 })
82 }) 75 })
83 76
@@ -87,7 +80,7 @@ describe('Test logs API validators', function () {
87 path, 80 path,
88 token: server.accessToken, 81 token: server.accessToken,
89 query: { startDate: new Date().toISOString(), level: 'toto' }, 82 query: { startDate: new Date().toISOString(), level: 'toto' },
90 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 83 expectedStatus: HttpStatusCode.BAD_REQUEST_400
91 }) 84 })
92 }) 85 })
93 86
@@ -97,7 +90,7 @@ describe('Test logs API validators', function () {
97 path, 90 path,
98 token: server.accessToken, 91 token: server.accessToken,
99 query: { startDate: new Date().toISOString() }, 92 query: { startDate: new Date().toISOString() },
100 statusCodeExpected: HttpStatusCode.OK_200 93 expectedStatus: HttpStatusCode.OK_200
101 }) 94 })
102 }) 95 })
103 }) 96 })
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 2b471ee7d..d3dda7fce 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -70,7 +70,7 @@ describe('Test server plugins API validators', function () {
70 ] 70 ]
71 71
72 for (const p of paths) { 72 for (const p of paths) {
73 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 73 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
74 } 74 }
75 }) 75 })
76 76
@@ -78,7 +78,7 @@ describe('Test server plugins API validators', function () {
78 await makeGetRequest({ 78 await makeGetRequest({
79 url: server.url, 79 url: server.url,
80 path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png', 80 path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png',
81 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 81 expectedStatus: HttpStatusCode.NOT_FOUND_404
82 }) 82 })
83 }) 83 })
84 84
@@ -93,7 +93,7 @@ describe('Test server plugins API validators', function () {
93 ] 93 ]
94 94
95 for (const p of paths) { 95 for (const p of paths) {
96 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 96 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
97 } 97 }
98 }) 98 })
99 99
@@ -107,14 +107,14 @@ describe('Test server plugins API validators', function () {
107 ] 107 ]
108 108
109 for (const p of paths) { 109 for (const p of paths) {
110 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 110 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
111 } 111 }
112 }) 112 })
113 113
114 it('Should fail with an unknown auth name', async function () { 114 it('Should fail with an unknown auth name', async function () {
115 const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth' 115 const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth'
116 116
117 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 117 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
118 }) 118 })
119 119
120 it('Should fail with an unknown static file', async function () { 120 it('Should fail with an unknown static file', async function () {
@@ -126,7 +126,7 @@ describe('Test server plugins API validators', function () {
126 ] 126 ]
127 127
128 for (const p of paths) { 128 for (const p of paths) {
129 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 129 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
130 } 130 }
131 }) 131 })
132 132
@@ -134,7 +134,7 @@ describe('Test server plugins API validators', function () {
134 await makeGetRequest({ 134 await makeGetRequest({
135 url: server.url, 135 url: server.url,
136 path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css', 136 path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css',
137 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 137 expectedStatus: HttpStatusCode.NOT_FOUND_404
138 }) 138 })
139 }) 139 })
140 140
@@ -148,11 +148,11 @@ describe('Test server plugins API validators', function () {
148 ] 148 ]
149 149
150 for (const p of paths) { 150 for (const p of paths) {
151 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.OK_200 }) 151 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.OK_200 })
152 } 152 }
153 153
154 const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth' 154 const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth'
155 await makeGetRequest({ url: server.url, path: authPath, statusCodeExpected: HttpStatusCode.FOUND_302 }) 155 await makeGetRequest({ url: server.url, path: authPath, expectedStatus: HttpStatusCode.FOUND_302 })
156 }) 156 })
157 }) 157 })
158 158
@@ -170,7 +170,7 @@ describe('Test server plugins API validators', function () {
170 path, 170 path,
171 token: 'fake_token', 171 token: 'fake_token',
172 query: baseQuery, 172 query: baseQuery,
173 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 173 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
174 }) 174 })
175 }) 175 })
176 176
@@ -180,7 +180,7 @@ describe('Test server plugins API validators', function () {
180 path, 180 path,
181 token: userAccessToken, 181 token: userAccessToken,
182 query: baseQuery, 182 query: baseQuery,
183 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 183 expectedStatus: HttpStatusCode.FORBIDDEN_403
184 }) 184 })
185 }) 185 })
186 186
@@ -224,7 +224,7 @@ describe('Test server plugins API validators', function () {
224 path, 224 path,
225 token: server.accessToken, 225 token: server.accessToken,
226 query: baseQuery, 226 query: baseQuery,
227 statusCodeExpected: HttpStatusCode.OK_200 227 expectedStatus: HttpStatusCode.OK_200
228 }) 228 })
229 }) 229 })
230 }) 230 })
@@ -241,7 +241,7 @@ describe('Test server plugins API validators', function () {
241 path, 241 path,
242 token: 'fake_token', 242 token: 'fake_token',
243 query: baseQuery, 243 query: baseQuery,
244 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 244 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
245 }) 245 })
246 }) 246 })
247 247
@@ -251,7 +251,7 @@ describe('Test server plugins API validators', function () {
251 path, 251 path,
252 token: userAccessToken, 252 token: userAccessToken,
253 query: baseQuery, 253 query: baseQuery,
254 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 254 expectedStatus: HttpStatusCode.FORBIDDEN_403
255 }) 255 })
256 }) 256 })
257 257
@@ -284,7 +284,7 @@ describe('Test server plugins API validators', function () {
284 path, 284 path,
285 token: server.accessToken, 285 token: server.accessToken,
286 query: baseQuery, 286 query: baseQuery,
287 statusCodeExpected: HttpStatusCode.OK_200 287 expectedStatus: HttpStatusCode.OK_200
288 }) 288 })
289 }) 289 })
290 }) 290 })
@@ -298,7 +298,7 @@ describe('Test server plugins API validators', function () {
298 url: server.url, 298 url: server.url,
299 path: path + suffix, 299 path: path + suffix,
300 token: 'fake_token', 300 token: 'fake_token',
301 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 301 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
302 }) 302 })
303 } 303 }
304 }) 304 })
@@ -309,7 +309,7 @@ describe('Test server plugins API validators', function () {
309 url: server.url, 309 url: server.url,
310 path: path + suffix, 310 path: path + suffix,
311 token: userAccessToken, 311 token: userAccessToken,
312 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 312 expectedStatus: HttpStatusCode.FORBIDDEN_403
313 }) 313 })
314 } 314 }
315 }) 315 })
@@ -320,7 +320,7 @@ describe('Test server plugins API validators', function () {
320 url: server.url, 320 url: server.url,
321 path: path + suffix, 321 path: path + suffix,
322 token: server.accessToken, 322 token: server.accessToken,
323 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 323 expectedStatus: HttpStatusCode.BAD_REQUEST_400
324 }) 324 })
325 } 325 }
326 326
@@ -329,7 +329,7 @@ describe('Test server plugins API validators', function () {
329 url: server.url, 329 url: server.url,
330 path: path + suffix, 330 path: path + suffix,
331 token: server.accessToken, 331 token: server.accessToken,
332 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 332 expectedStatus: HttpStatusCode.BAD_REQUEST_400
333 }) 333 })
334 } 334 }
335 }) 335 })
@@ -340,7 +340,7 @@ describe('Test server plugins API validators', function () {
340 url: server.url, 340 url: server.url,
341 path: path + suffix, 341 path: path + suffix,
342 token: server.accessToken, 342 token: server.accessToken,
343 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 343 expectedStatus: HttpStatusCode.NOT_FOUND_404
344 }) 344 })
345 } 345 }
346 }) 346 })
@@ -351,7 +351,7 @@ describe('Test server plugins API validators', function () {
351 url: server.url, 351 url: server.url,
352 path: path + suffix, 352 path: path + suffix,
353 token: server.accessToken, 353 token: server.accessToken,
354 statusCodeExpected: HttpStatusCode.OK_200 354 expectedStatus: HttpStatusCode.OK_200
355 }) 355 })
356 } 356 }
357 }) 357 })
@@ -367,7 +367,7 @@ describe('Test server plugins API validators', function () {
367 path: path + npmPlugin + '/settings', 367 path: path + npmPlugin + '/settings',
368 fields: { settings }, 368 fields: { settings },
369 token: 'fake_token', 369 token: 'fake_token',
370 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 370 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
371 }) 371 })
372 }) 372 })
373 373
@@ -377,7 +377,7 @@ describe('Test server plugins API validators', function () {
377 path: path + npmPlugin + '/settings', 377 path: path + npmPlugin + '/settings',
378 fields: { settings }, 378 fields: { settings },
379 token: userAccessToken, 379 token: userAccessToken,
380 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 380 expectedStatus: HttpStatusCode.FORBIDDEN_403
381 }) 381 })
382 }) 382 })
383 383
@@ -387,7 +387,7 @@ describe('Test server plugins API validators', function () {
387 path: path + 'toto/settings', 387 path: path + 'toto/settings',
388 fields: { settings }, 388 fields: { settings },
389 token: server.accessToken, 389 token: server.accessToken,
390 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 390 expectedStatus: HttpStatusCode.BAD_REQUEST_400
391 }) 391 })
392 392
393 await makePutBodyRequest({ 393 await makePutBodyRequest({
@@ -395,7 +395,7 @@ describe('Test server plugins API validators', function () {
395 path: path + 'peertube-plugin-TOTO/settings', 395 path: path + 'peertube-plugin-TOTO/settings',
396 fields: { settings }, 396 fields: { settings },
397 token: server.accessToken, 397 token: server.accessToken,
398 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 398 expectedStatus: HttpStatusCode.BAD_REQUEST_400
399 }) 399 })
400 }) 400 })
401 401
@@ -405,7 +405,7 @@ describe('Test server plugins API validators', function () {
405 path: path + 'peertube-plugin-toto/settings', 405 path: path + 'peertube-plugin-toto/settings',
406 fields: { settings }, 406 fields: { settings },
407 token: server.accessToken, 407 token: server.accessToken,
408 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 408 expectedStatus: HttpStatusCode.NOT_FOUND_404
409 }) 409 })
410 }) 410 })
411 411
@@ -415,7 +415,7 @@ describe('Test server plugins API validators', function () {
415 path: path + npmPlugin + '/settings', 415 path: path + npmPlugin + '/settings',
416 fields: { settings }, 416 fields: { settings },
417 token: server.accessToken, 417 token: server.accessToken,
418 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 418 expectedStatus: HttpStatusCode.NO_CONTENT_204
419 }) 419 })
420 }) 420 })
421 }) 421 })
@@ -430,7 +430,7 @@ describe('Test server plugins API validators', function () {
430 path: path + suffix, 430 path: path + suffix,
431 fields: { npmName: npmPlugin }, 431 fields: { npmName: npmPlugin },
432 token: 'fake_token', 432 token: 'fake_token',
433 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 433 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
434 }) 434 })
435 } 435 }
436 }) 436 })
@@ -442,7 +442,7 @@ describe('Test server plugins API validators', function () {
442 path: path + suffix, 442 path: path + suffix,
443 fields: { npmName: npmPlugin }, 443 fields: { npmName: npmPlugin },
444 token: userAccessToken, 444 token: userAccessToken,
445 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 445 expectedStatus: HttpStatusCode.FORBIDDEN_403
446 }) 446 })
447 } 447 }
448 }) 448 })
@@ -454,7 +454,7 @@ describe('Test server plugins API validators', function () {
454 path: path + suffix, 454 path: path + suffix,
455 fields: { npmName: 'toto' }, 455 fields: { npmName: 'toto' },
456 token: server.accessToken, 456 token: server.accessToken,
457 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 457 expectedStatus: HttpStatusCode.BAD_REQUEST_400
458 }) 458 })
459 } 459 }
460 460
@@ -464,7 +464,7 @@ describe('Test server plugins API validators', function () {
464 path: path + suffix, 464 path: path + suffix,
465 fields: { npmName: 'peertube-plugin-TOTO' }, 465 fields: { npmName: 'peertube-plugin-TOTO' },
466 token: server.accessToken, 466 token: server.accessToken,
467 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 467 expectedStatus: HttpStatusCode.BAD_REQUEST_400
468 }) 468 })
469 } 469 }
470 }) 470 })
@@ -484,7 +484,7 @@ describe('Test server plugins API validators', function () {
484 path: path + obj.suffix, 484 path: path + obj.suffix,
485 fields: { npmName: npmPlugin }, 485 fields: { npmName: npmPlugin },
486 token: server.accessToken, 486 token: server.accessToken,
487 statusCodeExpected: obj.status 487 expectedStatus: obj.status
488 }) 488 })
489 } 489 }
490 }) 490 })
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index 18b98a0f9..d9f905549 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -1,15 +1,13 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { VideoCreateResult } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { 4import {
7 checkBadCountPagination, 5 checkBadCountPagination,
8 checkBadSortPagination, 6 checkBadSortPagination,
9 checkBadStartPagination, 7 checkBadStartPagination,
10 cleanupTests, 8 cleanupTests,
11 doubleFollow,
12 createMultipleServers, 9 createMultipleServers,
10 doubleFollow,
13 makeDeleteRequest, 11 makeDeleteRequest,
14 makeGetRequest, 12 makeGetRequest,
15 makePostBodyRequest, 13 makePostBodyRequest,
@@ -17,7 +15,8 @@ import {
17 PeerTubeServer, 15 PeerTubeServer,
18 setAccessTokensToServers, 16 setAccessTokensToServers,
19 waitJobs 17 waitJobs
20} from '../../../../shared/extra-utils' 18} from '@shared/extra-utils'
19import { HttpStatusCode, VideoCreateResult } from '@shared/models'
21 20
22describe('Test server redundancy API validators', function () { 21describe('Test server redundancy API validators', function () {
23 let servers: PeerTubeServer[] 22 let servers: PeerTubeServer[]
@@ -64,11 +63,11 @@ describe('Test server redundancy API validators', function () {
64 }) 63 })
65 64
66 it('Should fail with an invalid token', async function () { 65 it('Should fail with an invalid token', async function () {
67 await makeGetRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 66 await makeGetRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
68 }) 67 })
69 68
70 it('Should fail if the user is not an administrator', async function () { 69 it('Should fail if the user is not an administrator', async function () {
71 await makeGetRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 70 await makeGetRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
72 }) 71 })
73 72
74 it('Should fail with a bad start pagination', async function () { 73 it('Should fail with a bad start pagination', async function () {
@@ -92,7 +91,7 @@ describe('Test server redundancy API validators', function () {
92 }) 91 })
93 92
94 it('Should succeed with the correct params', async function () { 93 it('Should succeed with the correct params', async function () {
95 await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, statusCodeExpected: HttpStatusCode.OK_200 }) 94 await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, expectedStatus: HttpStatusCode.OK_200 })
96 }) 95 })
97 }) 96 })
98 97
@@ -108,11 +107,11 @@ describe('Test server redundancy API validators', function () {
108 }) 107 })
109 108
110 it('Should fail with an invalid token', async function () { 109 it('Should fail with an invalid token', async function () {
111 await makePostBodyRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 110 await makePostBodyRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
112 }) 111 })
113 112
114 it('Should fail if the user is not an administrator', async function () { 113 it('Should fail if the user is not an administrator', async function () {
115 await makePostBodyRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 114 await makePostBodyRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
116 }) 115 })
117 116
118 it('Should fail without a video id', async function () { 117 it('Should fail without a video id', async function () {
@@ -124,7 +123,7 @@ describe('Test server redundancy API validators', function () {
124 }) 123 })
125 124
126 it('Should fail with a not found video id', async function () { 125 it('Should fail with a not found video id', async function () {
127 await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 126 await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
128 }) 127 })
129 128
130 it('Should fail with a local a video id', async function () { 129 it('Should fail with a local a video id', async function () {
@@ -137,7 +136,7 @@ describe('Test server redundancy API validators', function () {
137 path, 136 path,
138 token, 137 token,
139 fields: { videoId: videoRemote.shortUUID }, 138 fields: { videoId: videoRemote.shortUUID },
140 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 139 expectedStatus: HttpStatusCode.NO_CONTENT_204
141 }) 140 })
142 }) 141 })
143 142
@@ -151,7 +150,7 @@ describe('Test server redundancy API validators', function () {
151 path, 150 path,
152 token, 151 token,
153 fields: { videoId: videoRemote.uuid }, 152 fields: { videoId: videoRemote.uuid },
154 statusCodeExpected: HttpStatusCode.CONFLICT_409 153 expectedStatus: HttpStatusCode.CONFLICT_409
155 }) 154 })
156 }) 155 })
157 }) 156 })
@@ -168,11 +167,11 @@ describe('Test server redundancy API validators', function () {
168 }) 167 })
169 168
170 it('Should fail with an invalid token', async function () { 169 it('Should fail with an invalid token', async function () {
171 await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 170 await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
172 }) 171 })
173 172
174 it('Should fail if the user is not an administrator', async function () { 173 it('Should fail if the user is not an administrator', async function () {
175 await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 174 await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
176 }) 175 })
177 176
178 it('Should fail with an incorrect video id', async function () { 177 it('Should fail with an incorrect video id', async function () {
@@ -180,7 +179,7 @@ describe('Test server redundancy API validators', function () {
180 }) 179 })
181 180
182 it('Should fail with a not found video redundancy', async function () { 181 it('Should fail with a not found video redundancy', async function () {
183 await makeDeleteRequest({ url, path: path + '454545', token, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 182 await makeDeleteRequest({ url, path: path + '454545', token, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
184 }) 183 })
185 }) 184 })
186 185
@@ -193,7 +192,7 @@ describe('Test server redundancy API validators', function () {
193 path: path + '/localhost:' + servers[1].port, 192 path: path + '/localhost:' + servers[1].port,
194 fields: { redundancyAllowed: true }, 193 fields: { redundancyAllowed: true },
195 token: 'fake_token', 194 token: 'fake_token',
196 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 195 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
197 }) 196 })
198 }) 197 })
199 198
@@ -203,7 +202,7 @@ describe('Test server redundancy API validators', function () {
203 path: path + '/localhost:' + servers[1].port, 202 path: path + '/localhost:' + servers[1].port,
204 fields: { redundancyAllowed: true }, 203 fields: { redundancyAllowed: true },
205 token: userAccessToken, 204 token: userAccessToken,
206 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 205 expectedStatus: HttpStatusCode.FORBIDDEN_403
207 }) 206 })
208 }) 207 })
209 208
@@ -213,7 +212,7 @@ describe('Test server redundancy API validators', function () {
213 path: path + '/example.com', 212 path: path + '/example.com',
214 fields: { redundancyAllowed: true }, 213 fields: { redundancyAllowed: true },
215 token: servers[0].accessToken, 214 token: servers[0].accessToken,
216 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 215 expectedStatus: HttpStatusCode.NOT_FOUND_404
217 }) 216 })
218 }) 217 })
219 218
@@ -223,7 +222,7 @@ describe('Test server redundancy API validators', function () {
223 path: path + '/localhost:' + servers[1].port, 222 path: path + '/localhost:' + servers[1].port,
224 fields: { blabla: true }, 223 fields: { blabla: true },
225 token: servers[0].accessToken, 224 token: servers[0].accessToken,
226 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 225 expectedStatus: HttpStatusCode.BAD_REQUEST_400
227 }) 226 })
228 }) 227 })
229 228
@@ -233,7 +232,7 @@ describe('Test server redundancy API validators', function () {
233 path: path + '/localhost:' + servers[1].port, 232 path: path + '/localhost:' + servers[1].port,
234 fields: { redundancyAllowed: true }, 233 fields: { redundancyAllowed: true },
235 token: servers[0].accessToken, 234 token: servers[0].accessToken,
236 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 235 expectedStatus: HttpStatusCode.NO_CONTENT_204
237 }) 236 })
238 }) 237 })
239 }) 238 })
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 43cd81af9..b49169e38 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -58,83 +58,83 @@ describe('Test videos API validator', function () {
58 }) 58 })
59 59
60 it('Should success with the correct parameters', async function () { 60 it('Should success with the correct parameters', async function () {
61 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 61 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
62 }) 62 })
63 63
64 it('Should fail with an invalid category', async function () { 64 it('Should fail with an invalid category', async function () {
65 const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] } 65 const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] }
66 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 66 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
67 67
68 const customQuery2 = { ...query, categoryOneOf: 'a' } 68 const customQuery2 = { ...query, categoryOneOf: 'a' }
69 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 69 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
70 }) 70 })
71 71
72 it('Should succeed with a valid category', async function () { 72 it('Should succeed with a valid category', async function () {
73 const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] } 73 const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] }
74 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 74 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
75 75
76 const customQuery2 = { ...query, categoryOneOf: 1 } 76 const customQuery2 = { ...query, categoryOneOf: 1 }
77 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 77 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
78 }) 78 })
79 79
80 it('Should fail with an invalid licence', async function () { 80 it('Should fail with an invalid licence', async function () {
81 const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] } 81 const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] }
82 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 82 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
83 83
84 const customQuery2 = { ...query, licenceOneOf: 'a' } 84 const customQuery2 = { ...query, licenceOneOf: 'a' }
85 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 85 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
86 }) 86 })
87 87
88 it('Should succeed with a valid licence', async function () { 88 it('Should succeed with a valid licence', async function () {
89 const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] } 89 const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] }
90 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 90 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
91 91
92 const customQuery2 = { ...query, licenceOneOf: 1 } 92 const customQuery2 = { ...query, licenceOneOf: 1 }
93 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 93 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
94 }) 94 })
95 95
96 it('Should succeed with a valid language', async function () { 96 it('Should succeed with a valid language', async function () {
97 const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] } 97 const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] }
98 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 98 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
99 99
100 const customQuery2 = { ...query, languageOneOf: 'fr' } 100 const customQuery2 = { ...query, languageOneOf: 'fr' }
101 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 101 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
102 }) 102 })
103 103
104 it('Should succeed with valid tags', async function () { 104 it('Should succeed with valid tags', async function () {
105 const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] } 105 const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] }
106 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 106 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
107 107
108 const customQuery2 = { ...query, tagsOneOf: 'tag1' } 108 const customQuery2 = { ...query, tagsOneOf: 'tag1' }
109 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 109 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
110 110
111 const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] } 111 const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] }
112 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 }) 112 await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.OK_200 })
113 113
114 const customQuery4 = { ...query, tagsAllOf: 'tag1' } 114 const customQuery4 = { ...query, tagsAllOf: 'tag1' }
115 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 }) 115 await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.OK_200 })
116 }) 116 })
117 117
118 it('Should fail with invalid durations', async function () { 118 it('Should fail with invalid durations', async function () {
119 const customQuery1 = { ...query, durationMin: 'hello' } 119 const customQuery1 = { ...query, durationMin: 'hello' }
120 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 120 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
121 121
122 const customQuery2 = { ...query, durationMax: 'hello' } 122 const customQuery2 = { ...query, durationMax: 'hello' }
123 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 123 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
124 }) 124 })
125 125
126 it('Should fail with invalid dates', async function () { 126 it('Should fail with invalid dates', async function () {
127 const customQuery1 = { ...query, startDate: 'hello' } 127 const customQuery1 = { ...query, startDate: 'hello' }
128 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 128 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
129 129
130 const customQuery2 = { ...query, endDate: 'hello' } 130 const customQuery2 = { ...query, endDate: 'hello' }
131 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 131 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
132 132
133 const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' } 133 const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' }
134 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 134 await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
135 135
136 const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' } 136 const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' }
137 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 137 await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
138 }) 138 })
139 }) 139 })
140 140
@@ -158,7 +158,7 @@ describe('Test videos API validator', function () {
158 }) 158 })
159 159
160 it('Should success with the correct parameters', async function () { 160 it('Should success with the correct parameters', async function () {
161 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 161 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
162 }) 162 })
163 }) 163 })
164 164
@@ -182,7 +182,7 @@ describe('Test videos API validator', function () {
182 }) 182 })
183 183
184 it('Should success with the correct parameters', async function () { 184 it('Should success with the correct parameters', async function () {
185 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 185 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
186 }) 186 })
187 }) 187 })
188 188
@@ -201,41 +201,41 @@ describe('Test videos API validator', function () {
201 for (const path of paths) { 201 for (const path of paths) {
202 { 202 {
203 const customQuery = { ...query, searchTarget: 'hello' } 203 const customQuery = { ...query, searchTarget: 'hello' }
204 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 204 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
205 } 205 }
206 206
207 { 207 {
208 const customQuery = { ...query, searchTarget: undefined } 208 const customQuery = { ...query, searchTarget: undefined }
209 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 209 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
210 } 210 }
211 211
212 { 212 {
213 const customQuery = { ...query, searchTarget: 'local' } 213 const customQuery = { ...query, searchTarget: 'local' }
214 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 214 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
215 } 215 }
216 216
217 { 217 {
218 const customQuery = { ...query, searchTarget: 'search-index' } 218 const customQuery = { ...query, searchTarget: 'search-index' }
219 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 219 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
220 } 220 }
221 221
222 await updateSearchIndex(server, true, true) 222 await updateSearchIndex(server, true, true)
223 223
224 { 224 {
225 const customQuery = { ...query, searchTarget: 'local' } 225 const customQuery = { ...query, searchTarget: 'local' }
226 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 226 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
227 } 227 }
228 228
229 { 229 {
230 const customQuery = { ...query, searchTarget: 'search-index' } 230 const customQuery = { ...query, searchTarget: 'search-index' }
231 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 231 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
232 } 232 }
233 233
234 await updateSearchIndex(server, true, false) 234 await updateSearchIndex(server, true, false)
235 235
236 { 236 {
237 const customQuery = { ...query, searchTarget: 'local' } 237 const customQuery = { ...query, searchTarget: 'local' }
238 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 238 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
239 } 239 }
240 240
241 await updateSearchIndex(server, false, false) 241 await updateSearchIndex(server, false, false)
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index c623240b7..973b25598 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 createSingleServer, 7 createSingleServer,
@@ -120,13 +120,13 @@ describe('Test services API validators', function () {
120 }) 120 })
121}) 121})
122 122
123function checkParamEmbed (server: PeerTubeServer, embedUrl: string, statusCodeExpected = HttpStatusCode.BAD_REQUEST_400, query = {}) { 123function checkParamEmbed (server: PeerTubeServer, embedUrl: string, expectedStatus = HttpStatusCode.BAD_REQUEST_400, query = {}) {
124 const path = '/services/oembed' 124 const path = '/services/oembed'
125 125
126 return makeGetRequest({ 126 return makeGetRequest({
127 url: server.url, 127 url: server.url,
128 path, 128 path,
129 query: Object.assign(query, { url: embedUrl }), 129 query: Object.assign(query, { url: embedUrl }),
130 statusCodeExpected 130 expectedStatus
131 }) 131 })
132} 132}
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts
index bd8dce975..322e93d0d 100644
--- a/server/tests/api/check-params/upload-quota.ts
+++ b/server/tests/api/check-params/upload-quota.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode, randomInt } from '@shared/core-utils' 5import { randomInt } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -13,7 +13,7 @@ import {
13 VideosCommand, 13 VideosCommand,
14 waitJobs 14 waitJobs
15} from '@shared/extra-utils' 15} from '@shared/extra-utils'
16import { VideoImportState, VideoPrivacy } from '@shared/models' 16import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models'
17 17
18describe('Test upload quota', function () { 18describe('Test upload quota', function () {
19 let server: PeerTubeServer 19 let server: PeerTubeServer
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts
index 038c444b3..3b709ee5a 100644
--- a/server/tests/api/check-params/user-notifications.ts
+++ b/server/tests/api/check-params/user-notifications.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { io } from 'socket.io-client' 4import { io } from 'socket.io-client'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 checkBadCountPagination, 7 checkBadCountPagination,
8 checkBadSortPagination, 8 checkBadSortPagination,
@@ -54,7 +54,7 @@ describe('Test user notifications API validators', function () {
54 unread: 'toto' 54 unread: 'toto'
55 }, 55 },
56 token: server.accessToken, 56 token: server.accessToken,
57 statusCodeExpected: HttpStatusCode.OK_200 57 expectedStatus: HttpStatusCode.OK_200
58 }) 58 })
59 }) 59 })
60 60
@@ -62,7 +62,7 @@ describe('Test user notifications API validators', function () {
62 await makeGetRequest({ 62 await makeGetRequest({
63 url: server.url, 63 url: server.url,
64 path, 64 path,
65 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 65 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
66 }) 66 })
67 }) 67 })
68 68
@@ -71,7 +71,7 @@ describe('Test user notifications API validators', function () {
71 url: server.url, 71 url: server.url,
72 path, 72 path,
73 token: server.accessToken, 73 token: server.accessToken,
74 statusCodeExpected: HttpStatusCode.OK_200 74 expectedStatus: HttpStatusCode.OK_200
75 }) 75 })
76 }) 76 })
77 }) 77 })
@@ -87,7 +87,7 @@ describe('Test user notifications API validators', function () {
87 ids: [ 'hello' ] 87 ids: [ 'hello' ]
88 }, 88 },
89 token: server.accessToken, 89 token: server.accessToken,
90 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 90 expectedStatus: HttpStatusCode.BAD_REQUEST_400
91 }) 91 })
92 92
93 await makePostBodyRequest({ 93 await makePostBodyRequest({
@@ -97,7 +97,7 @@ describe('Test user notifications API validators', function () {
97 ids: [ ] 97 ids: [ ]
98 }, 98 },
99 token: server.accessToken, 99 token: server.accessToken,
100 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 100 expectedStatus: HttpStatusCode.BAD_REQUEST_400
101 }) 101 })
102 102
103 await makePostBodyRequest({ 103 await makePostBodyRequest({
@@ -107,7 +107,7 @@ describe('Test user notifications API validators', function () {
107 ids: 5 107 ids: 5
108 }, 108 },
109 token: server.accessToken, 109 token: server.accessToken,
110 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 110 expectedStatus: HttpStatusCode.BAD_REQUEST_400
111 }) 111 })
112 }) 112 })
113 113
@@ -118,7 +118,7 @@ describe('Test user notifications API validators', function () {
118 fields: { 118 fields: {
119 ids: [ 5 ] 119 ids: [ 5 ]
120 }, 120 },
121 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 121 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
122 }) 122 })
123 }) 123 })
124 124
@@ -130,7 +130,7 @@ describe('Test user notifications API validators', function () {
130 ids: [ 5 ] 130 ids: [ 5 ]
131 }, 131 },
132 token: server.accessToken, 132 token: server.accessToken,
133 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 133 expectedStatus: HttpStatusCode.NO_CONTENT_204
134 }) 134 })
135 }) 135 })
136 }) 136 })
@@ -142,7 +142,7 @@ describe('Test user notifications API validators', function () {
142 await makePostBodyRequest({ 142 await makePostBodyRequest({
143 url: server.url, 143 url: server.url,
144 path, 144 path,
145 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 145 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
146 }) 146 })
147 }) 147 })
148 148
@@ -151,7 +151,7 @@ describe('Test user notifications API validators', function () {
151 url: server.url, 151 url: server.url,
152 path, 152 path,
153 token: server.accessToken, 153 token: server.accessToken,
154 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 154 expectedStatus: HttpStatusCode.NO_CONTENT_204
155 }) 155 })
156 }) 156 })
157 }) 157 })
@@ -183,7 +183,7 @@ describe('Test user notifications API validators', function () {
183 path, 183 path,
184 token: server.accessToken, 184 token: server.accessToken,
185 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, 185 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB },
186 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 186 expectedStatus: HttpStatusCode.BAD_REQUEST_400
187 }) 187 })
188 }) 188 })
189 189
@@ -196,7 +196,7 @@ describe('Test user notifications API validators', function () {
196 path, 196 path,
197 token: server.accessToken, 197 token: server.accessToken,
198 fields, 198 fields,
199 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 199 expectedStatus: HttpStatusCode.BAD_REQUEST_400
200 }) 200 })
201 } 201 }
202 202
@@ -208,7 +208,7 @@ describe('Test user notifications API validators', function () {
208 path, 208 path,
209 fields, 209 fields,
210 token: server.accessToken, 210 token: server.accessToken,
211 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 211 expectedStatus: HttpStatusCode.BAD_REQUEST_400
212 }) 212 })
213 } 213 }
214 }) 214 })
@@ -218,7 +218,7 @@ describe('Test user notifications API validators', function () {
218 url: server.url, 218 url: server.url,
219 path, 219 path,
220 fields: correctFields, 220 fields: correctFields,
221 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 221 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
222 }) 222 })
223 }) 223 })
224 224
@@ -228,7 +228,7 @@ describe('Test user notifications API validators', function () {
228 path, 228 path,
229 token: server.accessToken, 229 token: server.accessToken,
230 fields: correctFields, 230 fields: correctFields,
231 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 231 expectedStatus: HttpStatusCode.NO_CONTENT_204
232 }) 232 })
233 }) 233 })
234 }) 234 })
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 22cf130c2..624069c80 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -1,24 +1,20 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 createSingleServer, 9 createSingleServer,
8 makeDeleteRequest, 10 makeDeleteRequest,
9 makeGetRequest, 11 makeGetRequest,
10 makePostBodyRequest, 12 makePostBodyRequest,
11 PeerTubeServer, 13 PeerTubeServer,
12 setAccessTokensToServers 14 setAccessTokensToServers,
13} from '../../../../shared/extra-utils' 15 waitJobs
14 16} from '@shared/extra-utils'
15import { 17import { HttpStatusCode } from '@shared/models'
16 checkBadCountPagination,
17 checkBadSortPagination,
18 checkBadStartPagination
19} from '../../../../shared/extra-utils/requests/check-api-params'
20import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
21import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
22 18
23describe('Test user subscriptions API validators', function () { 19describe('Test user subscriptions API validators', function () {
24 const path = '/api/v1/users/me/subscriptions' 20 const path = '/api/v1/users/me/subscriptions'
@@ -59,7 +55,7 @@ describe('Test user subscriptions API validators', function () {
59 await makeGetRequest({ 55 await makeGetRequest({
60 url: server.url, 56 url: server.url,
61 path, 57 path,
62 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 58 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
63 }) 59 })
64 }) 60 })
65 61
@@ -68,7 +64,7 @@ describe('Test user subscriptions API validators', function () {
68 url: server.url, 64 url: server.url,
69 path, 65 path,
70 token: userAccessToken, 66 token: userAccessToken,
71 statusCodeExpected: HttpStatusCode.OK_200 67 expectedStatus: HttpStatusCode.OK_200
72 }) 68 })
73 }) 69 })
74 }) 70 })
@@ -92,7 +88,7 @@ describe('Test user subscriptions API validators', function () {
92 await makeGetRequest({ 88 await makeGetRequest({
93 url: server.url, 89 url: server.url,
94 path, 90 path,
95 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 91 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
96 }) 92 })
97 }) 93 })
98 94
@@ -101,7 +97,7 @@ describe('Test user subscriptions API validators', function () {
101 url: server.url, 97 url: server.url,
102 path, 98 path,
103 token: userAccessToken, 99 token: userAccessToken,
104 statusCodeExpected: HttpStatusCode.OK_200 100 expectedStatus: HttpStatusCode.OK_200
105 }) 101 })
106 }) 102 })
107 }) 103 })
@@ -112,7 +108,7 @@ describe('Test user subscriptions API validators', function () {
112 url: server.url, 108 url: server.url,
113 path, 109 path,
114 fields: { uri: 'user1_channel@localhost:' + server.port }, 110 fields: { uri: 'user1_channel@localhost:' + server.port },
115 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 111 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
116 }) 112 })
117 }) 113 })
118 114
@@ -122,7 +118,7 @@ describe('Test user subscriptions API validators', function () {
122 path, 118 path,
123 token: server.accessToken, 119 token: server.accessToken,
124 fields: { uri: 'root' }, 120 fields: { uri: 'root' },
125 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 121 expectedStatus: HttpStatusCode.BAD_REQUEST_400
126 }) 122 })
127 123
128 await makePostBodyRequest({ 124 await makePostBodyRequest({
@@ -130,7 +126,7 @@ describe('Test user subscriptions API validators', function () {
130 path, 126 path,
131 token: server.accessToken, 127 token: server.accessToken,
132 fields: { uri: 'root@' }, 128 fields: { uri: 'root@' },
133 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 129 expectedStatus: HttpStatusCode.BAD_REQUEST_400
134 }) 130 })
135 131
136 await makePostBodyRequest({ 132 await makePostBodyRequest({
@@ -138,7 +134,7 @@ describe('Test user subscriptions API validators', function () {
138 path, 134 path,
139 token: server.accessToken, 135 token: server.accessToken,
140 fields: { uri: 'root@hello@' }, 136 fields: { uri: 'root@hello@' },
141 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 137 expectedStatus: HttpStatusCode.BAD_REQUEST_400
142 }) 138 })
143 }) 139 })
144 140
@@ -150,7 +146,7 @@ describe('Test user subscriptions API validators', function () {
150 path, 146 path,
151 token: server.accessToken, 147 token: server.accessToken,
152 fields: { uri: 'user1_channel@localhost:' + server.port }, 148 fields: { uri: 'user1_channel@localhost:' + server.port },
153 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 149 expectedStatus: HttpStatusCode.NO_CONTENT_204
154 }) 150 })
155 151
156 await waitJobs([ server ]) 152 await waitJobs([ server ])
@@ -162,7 +158,7 @@ describe('Test user subscriptions API validators', function () {
162 await makeGetRequest({ 158 await makeGetRequest({
163 url: server.url, 159 url: server.url,
164 path: path + '/user1_channel@localhost:' + server.port, 160 path: path + '/user1_channel@localhost:' + server.port,
165 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 161 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
166 }) 162 })
167 }) 163 })
168 164
@@ -171,21 +167,21 @@ describe('Test user subscriptions API validators', function () {
171 url: server.url, 167 url: server.url,
172 path: path + '/root', 168 path: path + '/root',
173 token: server.accessToken, 169 token: server.accessToken,
174 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 170 expectedStatus: HttpStatusCode.BAD_REQUEST_400
175 }) 171 })
176 172
177 await makeGetRequest({ 173 await makeGetRequest({
178 url: server.url, 174 url: server.url,
179 path: path + '/root@', 175 path: path + '/root@',
180 token: server.accessToken, 176 token: server.accessToken,
181 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 177 expectedStatus: HttpStatusCode.BAD_REQUEST_400
182 }) 178 })
183 179
184 await makeGetRequest({ 180 await makeGetRequest({
185 url: server.url, 181 url: server.url,
186 path: path + '/root@hello@', 182 path: path + '/root@hello@',
187 token: server.accessToken, 183 token: server.accessToken,
188 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 184 expectedStatus: HttpStatusCode.BAD_REQUEST_400
189 }) 185 })
190 }) 186 })
191 187
@@ -194,7 +190,7 @@ describe('Test user subscriptions API validators', function () {
194 url: server.url, 190 url: server.url,
195 path: path + '/root1@localhost:' + server.port, 191 path: path + '/root1@localhost:' + server.port,
196 token: server.accessToken, 192 token: server.accessToken,
197 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 193 expectedStatus: HttpStatusCode.NOT_FOUND_404
198 }) 194 })
199 }) 195 })
200 196
@@ -203,7 +199,7 @@ describe('Test user subscriptions API validators', function () {
203 url: server.url, 199 url: server.url,
204 path: path + '/user1_channel@localhost:' + server.port, 200 path: path + '/user1_channel@localhost:' + server.port,
205 token: server.accessToken, 201 token: server.accessToken,
206 statusCodeExpected: HttpStatusCode.OK_200 202 expectedStatus: HttpStatusCode.OK_200
207 }) 203 })
208 }) 204 })
209 }) 205 })
@@ -215,7 +211,7 @@ describe('Test user subscriptions API validators', function () {
215 await makeGetRequest({ 211 await makeGetRequest({
216 url: server.url, 212 url: server.url,
217 path: existPath, 213 path: existPath,
218 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 214 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
219 }) 215 })
220 }) 216 })
221 217
@@ -225,7 +221,7 @@ describe('Test user subscriptions API validators', function () {
225 path: existPath, 221 path: existPath,
226 query: { uris: 'toto' }, 222 query: { uris: 'toto' },
227 token: server.accessToken, 223 token: server.accessToken,
228 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 224 expectedStatus: HttpStatusCode.BAD_REQUEST_400
229 }) 225 })
230 226
231 await makeGetRequest({ 227 await makeGetRequest({
@@ -233,7 +229,7 @@ describe('Test user subscriptions API validators', function () {
233 path: existPath, 229 path: existPath,
234 query: { 'uris[]': 1 }, 230 query: { 'uris[]': 1 },
235 token: server.accessToken, 231 token: server.accessToken,
236 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 232 expectedStatus: HttpStatusCode.BAD_REQUEST_400
237 }) 233 })
238 }) 234 })
239 235
@@ -243,7 +239,7 @@ describe('Test user subscriptions API validators', function () {
243 path: existPath, 239 path: existPath,
244 query: { 'uris[]': 'coucou@localhost:' + server.port }, 240 query: { 'uris[]': 'coucou@localhost:' + server.port },
245 token: server.accessToken, 241 token: server.accessToken,
246 statusCodeExpected: HttpStatusCode.OK_200 242 expectedStatus: HttpStatusCode.OK_200
247 }) 243 })
248 }) 244 })
249 }) 245 })
@@ -253,7 +249,7 @@ describe('Test user subscriptions API validators', function () {
253 await makeDeleteRequest({ 249 await makeDeleteRequest({
254 url: server.url, 250 url: server.url,
255 path: path + '/user1_channel@localhost:' + server.port, 251 path: path + '/user1_channel@localhost:' + server.port,
256 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 252 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
257 }) 253 })
258 }) 254 })
259 255
@@ -262,21 +258,21 @@ describe('Test user subscriptions API validators', function () {
262 url: server.url, 258 url: server.url,
263 path: path + '/root', 259 path: path + '/root',
264 token: server.accessToken, 260 token: server.accessToken,
265 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 261 expectedStatus: HttpStatusCode.BAD_REQUEST_400
266 }) 262 })
267 263
268 await makeDeleteRequest({ 264 await makeDeleteRequest({
269 url: server.url, 265 url: server.url,
270 path: path + '/root@', 266 path: path + '/root@',
271 token: server.accessToken, 267 token: server.accessToken,
272 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 268 expectedStatus: HttpStatusCode.BAD_REQUEST_400
273 }) 269 })
274 270
275 await makeDeleteRequest({ 271 await makeDeleteRequest({
276 url: server.url, 272 url: server.url,
277 path: path + '/root@hello@', 273 path: path + '/root@hello@',
278 token: server.accessToken, 274 token: server.accessToken,
279 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 275 expectedStatus: HttpStatusCode.BAD_REQUEST_400
280 }) 276 })
281 }) 277 })
282 278
@@ -285,7 +281,7 @@ describe('Test user subscriptions API validators', function () {
285 url: server.url, 281 url: server.url,
286 path: path + '/root1@localhost:' + server.port, 282 path: path + '/root1@localhost:' + server.port,
287 token: server.accessToken, 283 token: server.accessToken,
288 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 284 expectedStatus: HttpStatusCode.NOT_FOUND_404
289 }) 285 })
290 }) 286 })
291 287
@@ -294,7 +290,7 @@ describe('Test user subscriptions API validators', function () {
294 url: server.url, 290 url: server.url,
295 path: path + '/user1_channel@localhost:' + server.port, 291 path: path + '/user1_channel@localhost:' + server.port,
296 token: server.accessToken, 292 token: server.accessToken,
297 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 293 expectedStatus: HttpStatusCode.NO_CONTENT_204
298 }) 294 })
299 }) 295 })
300 }) 296 })
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index c2c98f429..34fe309f9 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 checkBadCountPagination, 8 checkBadCountPagination,
@@ -103,7 +103,7 @@ describe('Test users API validators', function () {
103 await makeGetRequest({ 103 await makeGetRequest({
104 url: server.url, 104 url: server.url,
105 path, 105 path,
106 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 106 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
107 }) 107 })
108 }) 108 })
109 109
@@ -112,7 +112,7 @@ describe('Test users API validators', function () {
112 url: server.url, 112 url: server.url,
113 path, 113 path,
114 token: userToken, 114 token: userToken,
115 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 115 expectedStatus: HttpStatusCode.FORBIDDEN_403
116 }) 116 })
117 }) 117 })
118 }) 118 })
@@ -210,7 +210,7 @@ describe('Test users API validators', function () {
210 path: path, 210 path: path,
211 token: server.accessToken, 211 token: server.accessToken,
212 fields, 212 fields,
213 statusCodeExpected: HttpStatusCode.OK_200 213 expectedStatus: HttpStatusCode.OK_200
214 }) 214 })
215 }) 215 })
216 216
@@ -226,7 +226,7 @@ describe('Test users API validators', function () {
226 path, 226 path,
227 token: 'super token', 227 token: 'super token',
228 fields: baseCorrectParams, 228 fields: baseCorrectParams,
229 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 229 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
230 }) 230 })
231 }) 231 })
232 232
@@ -238,7 +238,7 @@ describe('Test users API validators', function () {
238 path, 238 path,
239 token: server.accessToken, 239 token: server.accessToken,
240 fields, 240 fields,
241 statusCodeExpected: HttpStatusCode.CONFLICT_409 241 expectedStatus: HttpStatusCode.CONFLICT_409
242 }) 242 })
243 }) 243 })
244 244
@@ -250,7 +250,7 @@ describe('Test users API validators', function () {
250 path, 250 path,
251 token: server.accessToken, 251 token: server.accessToken,
252 fields, 252 fields,
253 statusCodeExpected: HttpStatusCode.CONFLICT_409 253 expectedStatus: HttpStatusCode.CONFLICT_409
254 }) 254 })
255 }) 255 })
256 256
@@ -298,7 +298,7 @@ describe('Test users API validators', function () {
298 path, 298 path,
299 token: server.accessToken, 299 token: server.accessToken,
300 fields, 300 fields,
301 statusCodeExpected: HttpStatusCode.CONFLICT_409 301 expectedStatus: HttpStatusCode.CONFLICT_409
302 }) 302 })
303 }) 303 })
304 304
@@ -311,7 +311,7 @@ describe('Test users API validators', function () {
311 path, 311 path,
312 token: moderatorToken, 312 token: moderatorToken,
313 fields, 313 fields,
314 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 314 expectedStatus: HttpStatusCode.FORBIDDEN_403
315 }) 315 })
316 } 316 }
317 }) 317 })
@@ -324,7 +324,7 @@ describe('Test users API validators', function () {
324 path, 324 path,
325 token: moderatorToken, 325 token: moderatorToken,
326 fields, 326 fields,
327 statusCodeExpected: HttpStatusCode.OK_200 327 expectedStatus: HttpStatusCode.OK_200
328 }) 328 })
329 }) 329 })
330 330
@@ -334,7 +334,7 @@ describe('Test users API validators', function () {
334 path, 334 path,
335 token: server.accessToken, 335 token: server.accessToken,
336 fields: baseCorrectParams, 336 fields: baseCorrectParams,
337 statusCodeExpected: HttpStatusCode.OK_200 337 expectedStatus: HttpStatusCode.OK_200
338 }) 338 })
339 }) 339 })
340 340
@@ -348,7 +348,7 @@ describe('Test users API validators', function () {
348 password: 'my super password', 348 password: 'my super password',
349 videoQuota: 42000000 349 videoQuota: 42000000
350 } 350 }
351 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 351 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
352 }) 352 })
353 }) 353 })
354 354
@@ -400,7 +400,7 @@ describe('Test users API validators', function () {
400 path: path + 'me', 400 path: path + 'me',
401 token: userToken, 401 token: userToken,
402 fields, 402 fields,
403 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 403 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
404 }) 404 })
405 }) 405 })
406 406
@@ -447,7 +447,7 @@ describe('Test users API validators', function () {
447 path: path + 'me', 447 path: path + 'me',
448 token: 'super token', 448 token: 'super token',
449 fields, 449 fields,
450 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 450 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
451 }) 451 })
452 }) 452 })
453 453
@@ -525,7 +525,7 @@ describe('Test users API validators', function () {
525 path: path + 'me', 525 path: path + 'me',
526 token: userToken, 526 token: userToken,
527 fields, 527 fields,
528 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 528 expectedStatus: HttpStatusCode.NO_CONTENT_204
529 }) 529 })
530 }) 530 })
531 531
@@ -540,7 +540,7 @@ describe('Test users API validators', function () {
540 path: path + 'me', 540 path: path + 'me',
541 token: userToken, 541 token: userToken,
542 fields, 542 fields,
543 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 543 expectedStatus: HttpStatusCode.NO_CONTENT_204
544 }) 544 })
545 }) 545 })
546 }) 546 })
@@ -572,7 +572,7 @@ describe('Test users API validators', function () {
572 path: path + '/me/avatar/pick', 572 path: path + '/me/avatar/pick',
573 fields, 573 fields,
574 attaches, 574 attaches,
575 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 575 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
576 }) 576 })
577 }) 577 })
578 578
@@ -587,7 +587,7 @@ describe('Test users API validators', function () {
587 token: server.accessToken, 587 token: server.accessToken,
588 fields, 588 fields,
589 attaches, 589 attaches,
590 statusCodeExpected: HttpStatusCode.OK_200 590 expectedStatus: HttpStatusCode.OK_200
591 }) 591 })
592 }) 592 })
593 }) 593 })
@@ -627,16 +627,16 @@ describe('Test users API validators', function () {
627 url: server.url, 627 url: server.url,
628 path: path + userId, 628 path: path + userId,
629 token: 'super token', 629 token: 'super token',
630 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 630 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
631 }) 631 })
632 }) 632 })
633 633
634 it('Should fail with a non admin user', async function () { 634 it('Should fail with a non admin user', async function () {
635 await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 635 await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
636 }) 636 })
637 637
638 it('Should succeed with the correct params', async function () { 638 it('Should succeed with the correct params', async function () {
639 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: HttpStatusCode.OK_200 }) 639 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
640 }) 640 })
641 }) 641 })
642 642
@@ -702,7 +702,7 @@ describe('Test users API validators', function () {
702 path: path + userId, 702 path: path + userId,
703 token: 'super token', 703 token: 'super token',
704 fields, 704 fields,
705 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 705 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
706 }) 706 })
707 }) 707 })
708 708
@@ -730,7 +730,7 @@ describe('Test users API validators', function () {
730 path: path + moderatorId, 730 path: path + moderatorId,
731 token: moderatorToken, 731 token: moderatorToken,
732 fields, 732 fields,
733 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 733 expectedStatus: HttpStatusCode.FORBIDDEN_403
734 }) 734 })
735 }) 735 })
736 736
@@ -744,7 +744,7 @@ describe('Test users API validators', function () {
744 path: path + userId, 744 path: path + userId,
745 token: moderatorToken, 745 token: moderatorToken,
746 fields, 746 fields,
747 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 747 expectedStatus: HttpStatusCode.NO_CONTENT_204
748 }) 748 })
749 }) 749 })
750 750
@@ -761,7 +761,7 @@ describe('Test users API validators', function () {
761 path: path + userId, 761 path: path + userId,
762 token: server.accessToken, 762 token: server.accessToken,
763 fields, 763 fields,
764 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 764 expectedStatus: HttpStatusCode.NO_CONTENT_204
765 }) 765 })
766 }) 766 })
767 }) 767 })
@@ -818,11 +818,11 @@ describe('Test users API validators', function () {
818 }) 818 })
819 819
820 it('Should fail with a unauthenticated user', async function () { 820 it('Should fail with a unauthenticated user', async function () {
821 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 821 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
822 }) 822 })
823 823
824 it('Should fail with a another user', async function () { 824 it('Should fail with a another user', async function () {
825 await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 825 await makeGetRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
826 }) 826 })
827 827
828 it('Should fail with a bad type', async function () { 828 it('Should fail with a bad type', async function () {
@@ -831,12 +831,12 @@ describe('Test users API validators', function () {
831 path, 831 path,
832 token: userToken, 832 token: userToken,
833 query: { rating: 'toto ' }, 833 query: { rating: 'toto ' },
834 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 834 expectedStatus: HttpStatusCode.BAD_REQUEST_400
835 }) 835 })
836 }) 836 })
837 837
838 it('Should succeed with the correct params', async function () { 838 it('Should succeed with the correct params', async function () {
839 await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.OK_200 }) 839 await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.OK_200 })
840 }) 840 })
841 }) 841 })
842 842
@@ -955,7 +955,7 @@ describe('Test users API validators', function () {
955 path: registrationPath, 955 path: registrationPath,
956 token: server.accessToken, 956 token: server.accessToken,
957 fields, 957 fields,
958 statusCodeExpected: HttpStatusCode.CONFLICT_409 958 expectedStatus: HttpStatusCode.CONFLICT_409
959 }) 959 })
960 }) 960 })
961 961
@@ -967,7 +967,7 @@ describe('Test users API validators', function () {
967 path: registrationPath, 967 path: registrationPath,
968 token: server.accessToken, 968 token: server.accessToken,
969 fields, 969 fields,
970 statusCodeExpected: HttpStatusCode.CONFLICT_409 970 expectedStatus: HttpStatusCode.CONFLICT_409
971 }) 971 })
972 }) 972 })
973 973
@@ -979,7 +979,7 @@ describe('Test users API validators', function () {
979 path: registrationPath, 979 path: registrationPath,
980 token: server.accessToken, 980 token: server.accessToken,
981 fields, 981 fields,
982 statusCodeExpected: HttpStatusCode.CONFLICT_409 982 expectedStatus: HttpStatusCode.CONFLICT_409
983 }) 983 })
984 }) 984 })
985 985
@@ -1019,7 +1019,7 @@ describe('Test users API validators', function () {
1019 path: registrationPath, 1019 path: registrationPath,
1020 token: server.accessToken, 1020 token: server.accessToken,
1021 fields, 1021 fields,
1022 statusCodeExpected: HttpStatusCode.CONFLICT_409 1022 expectedStatus: HttpStatusCode.CONFLICT_409
1023 }) 1023 })
1024 }) 1024 })
1025 1025
@@ -1031,7 +1031,7 @@ describe('Test users API validators', function () {
1031 path: registrationPath, 1031 path: registrationPath,
1032 token: server.accessToken, 1032 token: server.accessToken,
1033 fields: fields, 1033 fields: fields,
1034 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 1034 expectedStatus: HttpStatusCode.NO_CONTENT_204
1035 }) 1035 })
1036 }) 1036 })
1037 1037
@@ -1047,7 +1047,7 @@ describe('Test users API validators', function () {
1047 path: registrationPath, 1047 path: registrationPath,
1048 token: serverWithRegistrationDisabled.accessToken, 1048 token: serverWithRegistrationDisabled.accessToken,
1049 fields, 1049 fields,
1050 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 1050 expectedStatus: HttpStatusCode.FORBIDDEN_403
1051 }) 1051 })
1052 }) 1052 })
1053 }) 1053 })
@@ -1081,7 +1081,7 @@ describe('Test users API validators', function () {
1081 path, 1081 path,
1082 token: server.accessToken, 1082 token: server.accessToken,
1083 fields, 1083 fields,
1084 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 1084 expectedStatus: HttpStatusCode.NO_CONTENT_204
1085 }) 1085 })
1086 }) 1086 })
1087 }) 1087 })
@@ -1109,7 +1109,7 @@ describe('Test users API validators', function () {
1109 path, 1109 path,
1110 token: server.accessToken, 1110 token: server.accessToken,
1111 fields, 1111 fields,
1112 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 1112 expectedStatus: HttpStatusCode.NO_CONTENT_204
1113 }) 1113 })
1114 }) 1114 })
1115 }) 1115 })
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index b5d0e0778..2072df4b6 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 BlacklistCommand, 7 BlacklistCommand,
8 checkBadCountPagination, 8 checkBadCountPagination,
@@ -88,7 +88,7 @@ describe('Test video blacklist API validators', function () {
88 it('Should fail with a non authenticated user', async function () { 88 it('Should fail with a non authenticated user', async function () {
89 const path = basePath + servers[0].store.video + '/blacklist' 89 const path = basePath + servers[0].store.video + '/blacklist'
90 const fields = {} 90 const fields = {}
91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
92 }) 92 })
93 93
94 it('Should fail with a non admin user', async function () { 94 it('Should fail with a non admin user', async function () {
@@ -99,7 +99,7 @@ describe('Test video blacklist API validators', function () {
99 path, 99 path,
100 token: userAccessToken2, 100 token: userAccessToken2,
101 fields, 101 fields,
102 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 102 expectedStatus: HttpStatusCode.FORBIDDEN_403
103 }) 103 })
104 }) 104 })
105 105
@@ -119,7 +119,7 @@ describe('Test video blacklist API validators', function () {
119 path, 119 path,
120 token: servers[0].accessToken, 120 token: servers[0].accessToken,
121 fields, 121 fields,
122 statusCodeExpected: HttpStatusCode.CONFLICT_409 122 expectedStatus: HttpStatusCode.CONFLICT_409
123 }) 123 })
124 }) 124 })
125 125
@@ -132,7 +132,7 @@ describe('Test video blacklist API validators', function () {
132 path, 132 path,
133 token: servers[0].accessToken, 133 token: servers[0].accessToken,
134 fields, 134 fields,
135 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 135 expectedStatus: HttpStatusCode.NO_CONTENT_204
136 }) 136 })
137 }) 137 })
138 }) 138 })
@@ -154,14 +154,14 @@ describe('Test video blacklist API validators', function () {
154 path, 154 path,
155 token: servers[0].accessToken, 155 token: servers[0].accessToken,
156 fields, 156 fields,
157 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 157 expectedStatus: HttpStatusCode.NOT_FOUND_404
158 }) 158 })
159 }) 159 })
160 160
161 it('Should fail with a non authenticated user', async function () { 161 it('Should fail with a non authenticated user', async function () {
162 const path = basePath + servers[0].store.video + '/blacklist' 162 const path = basePath + servers[0].store.video + '/blacklist'
163 const fields = {} 163 const fields = {}
164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
165 }) 165 })
166 166
167 it('Should fail with a non admin user', async function () { 167 it('Should fail with a non admin user', async function () {
@@ -172,7 +172,7 @@ describe('Test video blacklist API validators', function () {
172 path, 172 path,
173 token: userAccessToken2, 173 token: userAccessToken2,
174 fields, 174 fields,
175 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 175 expectedStatus: HttpStatusCode.FORBIDDEN_403
176 }) 176 })
177 }) 177 })
178 178
@@ -192,7 +192,7 @@ describe('Test video blacklist API validators', function () {
192 path, 192 path,
193 token: servers[0].accessToken, 193 token: servers[0].accessToken,
194 fields, 194 fields,
195 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 195 expectedStatus: HttpStatusCode.NO_CONTENT_204
196 }) 196 })
197 }) 197 })
198 }) 198 })
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index 26aab79e7..1b3d1aa95 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 buildAbsoluteFixturePath, 6 buildAbsoluteFixturePath,
7 cleanupTests, 7 cleanupTests,
@@ -67,7 +67,7 @@ describe('Test video captions API validator', function () {
67 token: server.accessToken, 67 token: server.accessToken,
68 fields, 68 fields,
69 attaches, 69 attaches,
70 statusCodeExpected: 404 70 expectedStatus: 404
71 }) 71 })
72 }) 72 })
73 73
@@ -103,7 +103,7 @@ describe('Test video captions API validator', function () {
103 path: captionPath, 103 path: captionPath,
104 fields, 104 fields,
105 attaches, 105 attaches,
106 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 106 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
107 }) 107 })
108 }) 108 })
109 109
@@ -116,7 +116,7 @@ describe('Test video captions API validator', function () {
116 token: 'blabla', 116 token: 'blabla',
117 fields, 117 fields,
118 attaches, 118 attaches,
119 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 119 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
120 }) 120 })
121 }) 121 })
122 122
@@ -134,7 +134,7 @@ describe('Test video captions API validator', function () {
134 // token: server.accessToken, 134 // token: server.accessToken,
135 // fields, 135 // fields,
136 // attaches, 136 // attaches,
137 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 137 // expectedStatus: HttpStatusCode.BAD_REQUEST_400
138 // }) 138 // })
139 // }) 139 // })
140 140
@@ -147,7 +147,7 @@ describe('Test video captions API validator', function () {
147 // videoId: video.uuid, 147 // videoId: video.uuid,
148 // fixture: 'subtitle-bad.txt', 148 // fixture: 'subtitle-bad.txt',
149 // mimeType: 'application/octet-stream', 149 // mimeType: 'application/octet-stream',
150 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 150 // expectedStatus: HttpStatusCode.BAD_REQUEST_400
151 // }) 151 // })
152 // }) 152 // })
153 153
@@ -174,7 +174,7 @@ describe('Test video captions API validator', function () {
174 // token: server.accessToken, 174 // token: server.accessToken,
175 // fields, 175 // fields,
176 // attaches, 176 // attaches,
177 // statusCodeExpected: HttpStatusCode.INTERNAL_SERVER_ERROR_500 177 // expectedStatus: HttpStatusCode.INTERNAL_SERVER_ERROR_500
178 // }) 178 // })
179 // }) 179 // })
180 180
@@ -187,7 +187,7 @@ describe('Test video captions API validator', function () {
187 token: server.accessToken, 187 token: server.accessToken,
188 fields, 188 fields,
189 attaches, 189 attaches,
190 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 190 expectedStatus: HttpStatusCode.NO_CONTENT_204
191 }) 191 })
192 }) 192 })
193 }) 193 })
@@ -201,12 +201,12 @@ describe('Test video captions API validator', function () {
201 await makeGetRequest({ 201 await makeGetRequest({
202 url: server.url, 202 url: server.url,
203 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions', 203 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions',
204 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 204 expectedStatus: HttpStatusCode.NOT_FOUND_404
205 }) 205 })
206 }) 206 })
207 207
208 it('Should success with the correct parameters', async function () { 208 it('Should success with the correct parameters', async function () {
209 await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) 209 await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', expectedStatus: HttpStatusCode.OK_200 })
210 }) 210 })
211 }) 211 })
212 212
@@ -224,7 +224,7 @@ describe('Test video captions API validator', function () {
224 url: server.url, 224 url: server.url,
225 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr', 225 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr',
226 token: server.accessToken, 226 token: server.accessToken,
227 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 227 expectedStatus: HttpStatusCode.NOT_FOUND_404
228 }) 228 })
229 }) 229 })
230 230
@@ -248,12 +248,12 @@ describe('Test video captions API validator', function () {
248 248
249 it('Should fail without access token', async function () { 249 it('Should fail without access token', async function () {
250 const captionPath = path + video.shortUUID + '/captions/fr' 250 const captionPath = path + video.shortUUID + '/captions/fr'
251 await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 251 await makeDeleteRequest({ url: server.url, path: captionPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
252 }) 252 })
253 253
254 it('Should fail with a bad access token', async function () { 254 it('Should fail with a bad access token', async function () {
255 const captionPath = path + video.shortUUID + '/captions/fr' 255 const captionPath = path + video.shortUUID + '/captions/fr'
256 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 256 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
257 }) 257 })
258 258
259 it('Should fail with another user', async function () { 259 it('Should fail with another user', async function () {
@@ -262,7 +262,7 @@ describe('Test video captions API validator', function () {
262 url: server.url, 262 url: server.url,
263 path: captionPath, 263 path: captionPath,
264 token: userAccessToken, 264 token: userAccessToken,
265 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 265 expectedStatus: HttpStatusCode.FORBIDDEN_403
266 }) 266 })
267 }) 267 })
268 268
@@ -272,7 +272,7 @@ describe('Test video captions API validator', function () {
272 url: server.url, 272 url: server.url,
273 path: captionPath, 273 path: captionPath,
274 token: server.accessToken, 274 token: server.accessToken,
275 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 275 expectedStatus: HttpStatusCode.NO_CONTENT_204
276 }) 276 })
277 }) 277 })
278 }) 278 })
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 62b8fa4f6..bbe42e43d 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
9 ChannelsCommand, 9 ChannelsCommand,
@@ -88,7 +88,7 @@ describe('Test video channels API validator', function () {
88 await makeGetRequest({ 88 await makeGetRequest({
89 url: server.url, 89 url: server.url,
90 path: accountChannelPath, 90 path: accountChannelPath,
91 statusCodeExpected: HttpStatusCode.OK_200 91 expectedStatus: HttpStatusCode.OK_200
92 }) 92 })
93 }) 93 })
94 }) 94 })
@@ -107,7 +107,7 @@ describe('Test video channels API validator', function () {
107 path: videoChannelPath, 107 path: videoChannelPath,
108 token: 'none', 108 token: 'none',
109 fields: baseCorrectParams, 109 fields: baseCorrectParams,
110 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 110 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
111 }) 111 })
112 }) 112 })
113 113
@@ -152,7 +152,7 @@ describe('Test video channels API validator', function () {
152 path: videoChannelPath, 152 path: videoChannelPath,
153 token: server.accessToken, 153 token: server.accessToken,
154 fields: baseCorrectParams, 154 fields: baseCorrectParams,
155 statusCodeExpected: HttpStatusCode.OK_200 155 expectedStatus: HttpStatusCode.OK_200
156 }) 156 })
157 }) 157 })
158 158
@@ -162,7 +162,7 @@ describe('Test video channels API validator', function () {
162 path: videoChannelPath, 162 path: videoChannelPath,
163 token: server.accessToken, 163 token: server.accessToken,
164 fields: baseCorrectParams, 164 fields: baseCorrectParams,
165 statusCodeExpected: HttpStatusCode.CONFLICT_409 165 expectedStatus: HttpStatusCode.CONFLICT_409
166 }) 166 })
167 }) 167 })
168 }) 168 })
@@ -186,7 +186,7 @@ describe('Test video channels API validator', function () {
186 path, 186 path,
187 token: 'hi', 187 token: 'hi',
188 fields: baseCorrectParams, 188 fields: baseCorrectParams,
189 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 189 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
190 }) 190 })
191 }) 191 })
192 192
@@ -196,7 +196,7 @@ describe('Test video channels API validator', function () {
196 path, 196 path,
197 token: accessTokenUser, 197 token: accessTokenUser,
198 fields: baseCorrectParams, 198 fields: baseCorrectParams,
199 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 199 expectedStatus: HttpStatusCode.FORBIDDEN_403
200 }) 200 })
201 }) 201 })
202 202
@@ -226,7 +226,7 @@ describe('Test video channels API validator', function () {
226 path, 226 path,
227 token: server.accessToken, 227 token: server.accessToken,
228 fields: baseCorrectParams, 228 fields: baseCorrectParams,
229 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 229 expectedStatus: HttpStatusCode.NO_CONTENT_204
230 }) 230 })
231 }) 231 })
232 }) 232 })
@@ -271,7 +271,7 @@ describe('Test video channels API validator', function () {
271 path: `${path}/${type}/pick`, 271 path: `${path}/${type}/pick`,
272 fields, 272 fields,
273 attaches, 273 attaches,
274 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 274 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
275 }) 275 })
276 } 276 }
277 }) 277 })
@@ -288,7 +288,7 @@ describe('Test video channels API validator', function () {
288 token: server.accessToken, 288 token: server.accessToken,
289 fields, 289 fields,
290 attaches, 290 attaches,
291 statusCodeExpected: HttpStatusCode.OK_200 291 expectedStatus: HttpStatusCode.OK_200
292 }) 292 })
293 } 293 }
294 }) 294 })
@@ -299,7 +299,7 @@ describe('Test video channels API validator', function () {
299 const res = await makeGetRequest({ 299 const res = await makeGetRequest({
300 url: server.url, 300 url: server.url,
301 path: videoChannelPath, 301 path: videoChannelPath,
302 statusCodeExpected: HttpStatusCode.OK_200 302 expectedStatus: HttpStatusCode.OK_200
303 }) 303 })
304 304
305 expect(res.body.data).to.be.an('array') 305 expect(res.body.data).to.be.an('array')
@@ -309,7 +309,7 @@ describe('Test video channels API validator', function () {
309 await makeGetRequest({ 309 await makeGetRequest({
310 url: server.url, 310 url: server.url,
311 path: videoChannelPath + '/super_channel2', 311 path: videoChannelPath + '/super_channel2',
312 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 312 expectedStatus: HttpStatusCode.NOT_FOUND_404
313 }) 313 })
314 }) 314 })
315 315
@@ -317,7 +317,7 @@ describe('Test video channels API validator', function () {
317 await makeGetRequest({ 317 await makeGetRequest({
318 url: server.url, 318 url: server.url,
319 path: videoChannelPath + '/super_channel', 319 path: videoChannelPath + '/super_channel',
320 statusCodeExpected: HttpStatusCode.OK_200 320 expectedStatus: HttpStatusCode.OK_200
321 }) 321 })
322 }) 322 })
323 }) 323 })
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 92c29da0e..bfd9e0172 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 checkBadCountPagination, 7 checkBadCountPagination,
8 checkBadSortPagination, 8 checkBadSortPagination,
@@ -78,7 +78,7 @@ describe('Test video comments API validator', function () {
78 await makeGetRequest({ 78 await makeGetRequest({
79 url: server.url, 79 url: server.url,
80 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads', 80 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads',
81 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 81 expectedStatus: HttpStatusCode.NOT_FOUND_404
82 }) 82 })
83 }) 83 })
84 }) 84 })
@@ -88,7 +88,7 @@ describe('Test video comments API validator', function () {
88 await makeGetRequest({ 88 await makeGetRequest({
89 url: server.url, 89 url: server.url,
90 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId, 90 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId,
91 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 91 expectedStatus: HttpStatusCode.NOT_FOUND_404
92 }) 92 })
93 }) 93 })
94 94
@@ -96,7 +96,7 @@ describe('Test video comments API validator', function () {
96 await makeGetRequest({ 96 await makeGetRequest({
97 url: server.url, 97 url: server.url,
98 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156', 98 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156',
99 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 99 expectedStatus: HttpStatusCode.NOT_FOUND_404
100 }) 100 })
101 }) 101 })
102 102
@@ -104,7 +104,7 @@ describe('Test video comments API validator', function () {
104 await makeGetRequest({ 104 await makeGetRequest({
105 url: server.url, 105 url: server.url,
106 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId, 106 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId,
107 statusCodeExpected: HttpStatusCode.OK_200 107 expectedStatus: HttpStatusCode.OK_200
108 }) 108 })
109 }) 109 })
110 }) 110 })
@@ -120,7 +120,7 @@ describe('Test video comments API validator', function () {
120 path: pathThread, 120 path: pathThread,
121 token: 'none', 121 token: 'none',
122 fields, 122 fields,
123 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 123 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
124 }) 124 })
125 }) 125 })
126 126
@@ -153,7 +153,7 @@ describe('Test video comments API validator', function () {
153 path, 153 path,
154 token: server.accessToken, 154 token: server.accessToken,
155 fields, 155 fields,
156 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 156 expectedStatus: HttpStatusCode.NOT_FOUND_404
157 }) 157 })
158 }) 158 })
159 159
@@ -166,7 +166,7 @@ describe('Test video comments API validator', function () {
166 path: pathThread, 166 path: pathThread,
167 token: server.accessToken, 167 token: server.accessToken,
168 fields, 168 fields,
169 statusCodeExpected: HttpStatusCode.OK_200 169 expectedStatus: HttpStatusCode.OK_200
170 }) 170 })
171 }) 171 })
172 }) 172 })
@@ -181,7 +181,7 @@ describe('Test video comments API validator', function () {
181 path: pathComment, 181 path: pathComment,
182 token: 'none', 182 token: 'none',
183 fields, 183 fields,
184 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 184 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
185 }) 185 })
186 }) 186 })
187 187
@@ -214,7 +214,7 @@ describe('Test video comments API validator', function () {
214 path, 214 path,
215 token: server.accessToken, 215 token: server.accessToken,
216 fields, 216 fields,
217 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 217 expectedStatus: HttpStatusCode.NOT_FOUND_404
218 }) 218 })
219 }) 219 })
220 220
@@ -228,7 +228,7 @@ describe('Test video comments API validator', function () {
228 path, 228 path,
229 token: server.accessToken, 229 token: server.accessToken,
230 fields, 230 fields,
231 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 231 expectedStatus: HttpStatusCode.NOT_FOUND_404
232 }) 232 })
233 }) 233 })
234 234
@@ -241,14 +241,14 @@ describe('Test video comments API validator', function () {
241 path: pathComment, 241 path: pathComment,
242 token: server.accessToken, 242 token: server.accessToken,
243 fields, 243 fields,
244 statusCodeExpected: HttpStatusCode.OK_200 244 expectedStatus: HttpStatusCode.OK_200
245 }) 245 })
246 }) 246 })
247 }) 247 })
248 248
249 describe('When removing video comments', function () { 249 describe('When removing video comments', function () {
250 it('Should fail with a non authenticated user', async function () { 250 it('Should fail with a non authenticated user', async function () {
251 await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 251 await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
252 }) 252 })
253 253
254 it('Should fail with another user', async function () { 254 it('Should fail with another user', async function () {
@@ -256,18 +256,18 @@ describe('Test video comments API validator', function () {
256 url: server.url, 256 url: server.url,
257 path: pathComment, 257 path: pathComment,
258 token: userAccessToken, 258 token: userAccessToken,
259 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 259 expectedStatus: HttpStatusCode.FORBIDDEN_403
260 }) 260 })
261 }) 261 })
262 262
263 it('Should fail with an incorrect video', async function () { 263 it('Should fail with an incorrect video', async function () {
264 const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId 264 const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId
265 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 265 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
266 }) 266 })
267 267
268 it('Should fail with an incorrect comment', async function () { 268 it('Should fail with an incorrect comment', async function () {
269 const path = '/api/v1/videos/' + video.uuid + '/comments/124' 269 const path = '/api/v1/videos/' + video.uuid + '/comments/124'
270 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 270 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
271 }) 271 })
272 272
273 it('Should succeed with the same user', async function () { 273 it('Should succeed with the same user', async function () {
@@ -280,8 +280,8 @@ describe('Test video comments API validator', function () {
280 280
281 const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete 281 const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete
282 282
283 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 283 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
284 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) 284 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
285 }) 285 })
286 286
287 it('Should succeed with the owner of the video', async function () { 287 it('Should succeed with the owner of the video', async function () {
@@ -300,8 +300,8 @@ describe('Test video comments API validator', function () {
300 300
301 const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete 301 const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete
302 302
303 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 303 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
304 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) 304 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
305 }) 305 })
306 306
307 it('Should succeed with the correct parameters', async function () { 307 it('Should succeed with the correct parameters', async function () {
@@ -309,7 +309,7 @@ describe('Test video comments API validator', function () {
309 url: server.url, 309 url: server.url,
310 path: pathComment, 310 path: pathComment,
311 token: server.accessToken, 311 token: server.accessToken,
312 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 312 expectedStatus: HttpStatusCode.NO_CONTENT_204
313 }) 313 })
314 }) 314 })
315 }) 315 })
@@ -324,7 +324,7 @@ describe('Test video comments API validator', function () {
324 const res = await makeGetRequest({ 324 const res = await makeGetRequest({
325 url: server.url, 325 url: server.url,
326 path: pathThread, 326 path: pathThread,
327 statusCodeExpected: HttpStatusCode.OK_200 327 expectedStatus: HttpStatusCode.OK_200
328 }) 328 })
329 expect(res.body.total).to.equal(0) 329 expect(res.body.total).to.equal(0)
330 expect(res.body.data).to.have.lengthOf(0) 330 expect(res.body.data).to.have.lengthOf(0)
@@ -341,7 +341,7 @@ describe('Test video comments API validator', function () {
341 path: pathThread, 341 path: pathThread,
342 token: server.accessToken, 342 token: server.accessToken,
343 fields, 343 fields,
344 statusCodeExpected: HttpStatusCode.CONFLICT_409 344 expectedStatus: HttpStatusCode.CONFLICT_409
345 }) 345 })
346 }) 346 })
347 347
@@ -367,7 +367,7 @@ describe('Test video comments API validator', function () {
367 await makeGetRequest({ 367 await makeGetRequest({
368 url: server.url, 368 url: server.url,
369 path, 369 path,
370 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 370 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
371 }) 371 })
372 }) 372 })
373 373
@@ -376,7 +376,7 @@ describe('Test video comments API validator', function () {
376 url: server.url, 376 url: server.url,
377 path, 377 path,
378 token: userAccessToken, 378 token: userAccessToken,
379 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 379 expectedStatus: HttpStatusCode.FORBIDDEN_403
380 }) 380 })
381 }) 381 })
382 382
@@ -391,7 +391,7 @@ describe('Test video comments API validator', function () {
391 searchAccount: 'toto', 391 searchAccount: 'toto',
392 searchVideo: 'toto' 392 searchVideo: 'toto'
393 }, 393 },
394 statusCodeExpected: HttpStatusCode.OK_200 394 expectedStatus: HttpStatusCode.OK_200
395 }) 395 })
396 }) 396 })
397 }) 397 })
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 0209275ac..957556c9b 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 checkBadCountPagination, 8 checkBadCountPagination,
@@ -61,7 +61,7 @@ describe('Test video imports API validator', function () {
61 }) 61 })
62 62
63 it('Should success with the correct parameters', async function () { 63 it('Should success with the correct parameters', async function () {
64 await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) 64 await makeGetRequest({ url: server.url, path: myPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
65 }) 65 })
66 }) 66 })
67 67
@@ -99,7 +99,7 @@ describe('Test video imports API validator', function () {
99 path, 99 path,
100 token: server.accessToken, 100 token: server.accessToken,
101 fields, 101 fields,
102 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 102 expectedStatus: HttpStatusCode.BAD_REQUEST_400
103 }) 103 })
104 }) 104 })
105 105
@@ -251,7 +251,7 @@ describe('Test video imports API validator', function () {
251 path, 251 path,
252 token: server.accessToken, 252 token: server.accessToken,
253 fields: baseCorrectParams, 253 fields: baseCorrectParams,
254 statusCodeExpected: HttpStatusCode.OK_200 254 expectedStatus: HttpStatusCode.OK_200
255 }) 255 })
256 }) 256 })
257 257
@@ -276,7 +276,7 @@ describe('Test video imports API validator', function () {
276 path, 276 path,
277 token: server.accessToken, 277 token: server.accessToken,
278 fields: baseCorrectParams, 278 fields: baseCorrectParams,
279 statusCodeExpected: HttpStatusCode.CONFLICT_409 279 expectedStatus: HttpStatusCode.CONFLICT_409
280 }) 280 })
281 }) 281 })
282 282
@@ -304,7 +304,7 @@ describe('Test video imports API validator', function () {
304 path, 304 path,
305 token: server.accessToken, 305 token: server.accessToken,
306 fields, 306 fields,
307 statusCodeExpected: HttpStatusCode.CONFLICT_409 307 expectedStatus: HttpStatusCode.CONFLICT_409
308 }) 308 })
309 309
310 fields = omit(fields, 'magnetUri') 310 fields = omit(fields, 'magnetUri')
@@ -318,7 +318,7 @@ describe('Test video imports API validator', function () {
318 token: server.accessToken, 318 token: server.accessToken,
319 fields, 319 fields,
320 attaches, 320 attaches,
321 statusCodeExpected: HttpStatusCode.CONFLICT_409 321 expectedStatus: HttpStatusCode.CONFLICT_409
322 }) 322 })
323 }) 323 })
324 }) 324 })
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index 9d054b176..7dcb4935a 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -119,7 +119,7 @@ describe('Test video playlists API validator', function () {
119 await makeGetRequest({ 119 await makeGetRequest({
120 url: server.url, 120 url: server.url,
121 path: accountPath, 121 path: accountPath,
122 statusCodeExpected: HttpStatusCode.NOT_FOUND_404, 122 expectedStatus: HttpStatusCode.NOT_FOUND_404,
123 token: server.accessToken 123 token: server.accessToken
124 }) 124 })
125 }) 125 })
@@ -130,18 +130,18 @@ describe('Test video playlists API validator', function () {
130 await makeGetRequest({ 130 await makeGetRequest({
131 url: server.url, 131 url: server.url,
132 path: accountPath, 132 path: accountPath,
133 statusCodeExpected: HttpStatusCode.NOT_FOUND_404, 133 expectedStatus: HttpStatusCode.NOT_FOUND_404,
134 token: server.accessToken 134 token: server.accessToken
135 }) 135 })
136 }) 136 })
137 137
138 it('Should success with the correct parameters', async function () { 138 it('Should success with the correct parameters', async function () {
139 await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) 139 await makeGetRequest({ url: server.url, path: globalPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
140 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) 140 await makeGetRequest({ url: server.url, path: accountPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
141 await makeGetRequest({ 141 await makeGetRequest({
142 url: server.url, 142 url: server.url,
143 path: videoChannelPath, 143 path: videoChannelPath,
144 statusCodeExpected: HttpStatusCode.OK_200, 144 expectedStatus: HttpStatusCode.OK_200,
145 token: server.accessToken 145 token: server.accessToken
146 }) 146 })
147 }) 147 })
@@ -159,7 +159,7 @@ describe('Test video playlists API validator', function () {
159 }) 159 })
160 160
161 it('Should success with the correct parameters', async function () { 161 it('Should success with the correct parameters', async function () {
162 await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) 162 await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', expectedStatus: HttpStatusCode.OK_200 })
163 }) 163 })
164 }) 164 })
165 165
@@ -580,7 +580,7 @@ describe('Test video playlists API validator', function () {
580 url: server.url, 580 url: server.url,
581 path, 581 path,
582 query: { videoIds: [ 1, 2 ] }, 582 query: { videoIds: [ 1, 2 ] },
583 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 583 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
584 }) 584 })
585 }) 585 })
586 586
@@ -613,7 +613,7 @@ describe('Test video playlists API validator', function () {
613 token: server.accessToken, 613 token: server.accessToken,
614 path, 614 path,
615 query: { videoIds: [ 1, 2 ] }, 615 query: { videoIds: [ 1, 2 ] },
616 statusCodeExpected: HttpStatusCode.OK_200 616 expectedStatus: HttpStatusCode.OK_200
617 }) 617 })
618 }) 618 })
619 }) 619 })
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index e4e799cc7..c2c69904f 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -1,6 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/models'
4import { 5import {
5 cleanupTests, 6 cleanupTests,
6 createSingleServer, 7 createSingleServer,
@@ -8,11 +9,10 @@ import {
8 PeerTubeServer, 9 PeerTubeServer,
9 setAccessTokensToServers, 10 setAccessTokensToServers,
10 setDefaultVideoChannel 11 setDefaultVideoChannel
11} from '../../../../shared/extra-utils' 12} from '@shared/extra-utils'
12import { UserRole } from '../../../../shared/models/users' 13import { UserRole } from '@shared/models'
13import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
14 14
15async function testEndpoints (server: PeerTubeServer, token: string, filter: string, statusCodeExpected: HttpStatusCode) { 15async function testEndpoints (server: PeerTubeServer, token: string, filter: string, expectedStatus: HttpStatusCode) {
16 const paths = [ 16 const paths = [
17 '/api/v1/video-channels/root_channel/videos', 17 '/api/v1/video-channels/root_channel/videos',
18 '/api/v1/accounts/root/videos', 18 '/api/v1/accounts/root/videos',
@@ -28,7 +28,7 @@ async function testEndpoints (server: PeerTubeServer, token: string, filter: str
28 query: { 28 query: {
29 filter 29 filter
30 }, 30 },
31 statusCodeExpected 31 expectedStatus
32 }) 32 })
33 } 33 }
34} 34}
@@ -89,7 +89,7 @@ describe('Test video filters validators', function () {
89 await makeGetRequest({ 89 await makeGetRequest({
90 url: server.url, 90 url: server.url,
91 path: '/feeds/videos.json', 91 path: '/feeds/videos.json',
92 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401, 92 expectedStatus: HttpStatusCode.UNAUTHORIZED_401,
93 query: { 93 query: {
94 filter 94 filter
95 } 95 }
@@ -101,7 +101,7 @@ describe('Test video filters validators', function () {
101 await makeGetRequest({ 101 await makeGetRequest({
102 url: server.url, 102 url: server.url,
103 path: '/feeds/videos.json', 103 path: '/feeds/videos.json',
104 statusCodeExpected: HttpStatusCode.OK_200, 104 expectedStatus: HttpStatusCode.OK_200,
105 query: { 105 query: {
106 filter: 'local' 106 filter: 'local'
107 } 107 }
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 3c1f479e4..7283a4d28 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadStartPagination, 7 checkBadStartPagination,
@@ -37,7 +37,7 @@ describe('Test videos history API validator', function () {
37 37
38 it('Should fail with an unauthenticated user', async function () { 38 it('Should fail with an unauthenticated user', async function () {
39 const fields = { currentTime: 5 } 39 const fields = { currentTime: 5 }
40 await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 40 await makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
41 }) 41 })
42 42
43 it('Should fail with an incorrect video id', async function () { 43 it('Should fail with an incorrect video id', async function () {
@@ -48,7 +48,7 @@ describe('Test videos history API validator', function () {
48 path, 48 path,
49 fields, 49 fields,
50 token: server.accessToken, 50 token: server.accessToken,
51 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 51 expectedStatus: HttpStatusCode.BAD_REQUEST_400
52 }) 52 })
53 }) 53 })
54 54
@@ -61,7 +61,7 @@ describe('Test videos history API validator', function () {
61 path, 61 path,
62 fields, 62 fields,
63 token: server.accessToken, 63 token: server.accessToken,
64 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 64 expectedStatus: HttpStatusCode.NOT_FOUND_404
65 }) 65 })
66 }) 66 })
67 67
@@ -72,7 +72,7 @@ describe('Test videos history API validator', function () {
72 path: watchingPath, 72 path: watchingPath,
73 fields, 73 fields,
74 token: server.accessToken, 74 token: server.accessToken,
75 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 75 expectedStatus: HttpStatusCode.BAD_REQUEST_400
76 }) 76 })
77 }) 77 })
78 78
@@ -84,7 +84,7 @@ describe('Test videos history API validator', function () {
84 path: watchingPath, 84 path: watchingPath,
85 fields, 85 fields,
86 token: server.accessToken, 86 token: server.accessToken,
87 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 87 expectedStatus: HttpStatusCode.NO_CONTENT_204
88 }) 88 })
89 }) 89 })
90 }) 90 })
@@ -99,17 +99,17 @@ describe('Test videos history API validator', function () {
99 }) 99 })
100 100
101 it('Should fail with an unauthenticated user', async function () { 101 it('Should fail with an unauthenticated user', async function () {
102 await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 102 await makeGetRequest({ url: server.url, path: myHistoryPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
103 }) 103 })
104 104
105 it('Should succeed with the correct params', async function () { 105 it('Should succeed with the correct params', async function () {
106 await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: HttpStatusCode.OK_200 }) 106 await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: HttpStatusCode.OK_200 })
107 }) 107 })
108 }) 108 })
109 109
110 describe('When removing user videos history', function () { 110 describe('When removing user videos history', function () {
111 it('Should fail with an unauthenticated user', async function () { 111 it('Should fail with an unauthenticated user', async function () {
112 await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 112 await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
113 }) 113 })
114 114
115 it('Should fail with a bad beforeDate parameter', async function () { 115 it('Should fail with a bad beforeDate parameter', async function () {
@@ -119,7 +119,7 @@ describe('Test videos history API validator', function () {
119 token: server.accessToken, 119 token: server.accessToken,
120 path: myHistoryRemove, 120 path: myHistoryRemove,
121 fields: body, 121 fields: body,
122 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 122 expectedStatus: HttpStatusCode.BAD_REQUEST_400
123 }) 123 })
124 }) 124 })
125 125
@@ -130,7 +130,7 @@ describe('Test videos history API validator', function () {
130 token: server.accessToken, 130 token: server.accessToken,
131 path: myHistoryRemove, 131 path: myHistoryRemove,
132 fields: body, 132 fields: body,
133 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 133 expectedStatus: HttpStatusCode.NO_CONTENT_204
134 }) 134 })
135 }) 135 })
136 136
@@ -139,7 +139,7 @@ describe('Test videos history API validator', function () {
139 url: server.url, 139 url: server.url,
140 token: server.accessToken, 140 token: server.accessToken,
141 path: myHistoryRemove, 141 path: myHistoryRemove,
142 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 142 expectedStatus: HttpStatusCode.NO_CONTENT_204
143 }) 143 })
144 }) 144 })
145 }) 145 })
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index c60de2640..e11ca0c82 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode, randomInt } from '@shared/core-utils' 7import { randomInt } from '@shared/core-utils'
8import { 8import {
9 checkBadCountPagination, 9 checkBadCountPagination,
10 checkBadSortPagination, 10 checkBadSortPagination,
@@ -16,11 +16,11 @@ import {
16 makeGetRequest, 16 makeGetRequest,
17 makePutBodyRequest, 17 makePutBodyRequest,
18 makeUploadRequest, 18 makeUploadRequest,
19 root,
20 PeerTubeServer, 19 PeerTubeServer,
20 root,
21 setAccessTokensToServers 21 setAccessTokensToServers
22} from '@shared/extra-utils' 22} from '@shared/extra-utils'
23import { PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' 23import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
24 24
25const expect = chai.expect 25const expect = chai.expect
26 26
@@ -69,11 +69,11 @@ describe('Test videos API validator', function () {
69 }) 69 })
70 70
71 it('Should fail with a bad skipVideos query', async function () { 71 it('Should fail with a bad skipVideos query', async function () {
72 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } }) 72 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
73 }) 73 })
74 74
75 it('Should success with the correct parameters', async function () { 75 it('Should success with the correct parameters', async function () {
76 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } }) 76 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } })
77 }) 77 })
78 }) 78 })
79 79
@@ -83,7 +83,7 @@ describe('Test videos API validator', function () {
83 await makeGetRequest({ 83 await makeGetRequest({
84 url: server.url, 84 url: server.url,
85 path: join(path, 'search'), 85 path: join(path, 'search'),
86 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 86 expectedStatus: HttpStatusCode.BAD_REQUEST_400
87 }) 87 })
88 }) 88 })
89 89
@@ -100,7 +100,7 @@ describe('Test videos API validator', function () {
100 }) 100 })
101 101
102 it('Should success with the correct parameters', async function () { 102 it('Should success with the correct parameters', async function () {
103 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) 103 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
104 }) 104 })
105 }) 105 })
106 106
@@ -120,7 +120,7 @@ describe('Test videos API validator', function () {
120 }) 120 })
121 121
122 it('Should success with the correct parameters', async function () { 122 it('Should success with the correct parameters', async function () {
123 await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 }) 123 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
124 }) 124 })
125 }) 125 })
126 126
@@ -144,7 +144,7 @@ describe('Test videos API validator', function () {
144 }) 144 })
145 145
146 it('Should success with the correct parameters', async function () { 146 it('Should success with the correct parameters', async function () {
147 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) 147 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
148 }) 148 })
149 }) 149 })
150 150
@@ -168,7 +168,7 @@ describe('Test videos API validator', function () {
168 }) 168 })
169 169
170 it('Should success with the correct parameters', async function () { 170 it('Should success with the correct parameters', async function () {
171 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) 171 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
172 }) 172 })
173 }) 173 })
174 174
@@ -506,7 +506,7 @@ describe('Test videos API validator', function () {
506 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', 506 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
507 token: server.accessToken, 507 token: server.accessToken,
508 fields, 508 fields,
509 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 509 expectedStatus: HttpStatusCode.NOT_FOUND_404
510 }) 510 })
511 }) 511 })
512 512
@@ -660,7 +660,7 @@ describe('Test videos API validator', function () {
660 path: path + video.shortUUID, 660 path: path + video.shortUUID,
661 token: userAccessToken, 661 token: userAccessToken,
662 fields, 662 fields,
663 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 663 expectedStatus: HttpStatusCode.FORBIDDEN_403
664 }) 664 })
665 }) 665 })
666 666
@@ -692,7 +692,7 @@ describe('Test videos API validator', function () {
692 path: path + video.shortUUID, 692 path: path + video.shortUUID,
693 token: server.accessToken, 693 token: server.accessToken,
694 fields, 694 fields,
695 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 695 expectedStatus: HttpStatusCode.NO_CONTENT_204
696 }) 696 })
697 }) 697 })
698 }) 698 })
@@ -702,7 +702,7 @@ describe('Test videos API validator', function () {
702 const res = await makeGetRequest({ 702 const res = await makeGetRequest({
703 url: server.url, 703 url: server.url,
704 path, 704 path,
705 statusCodeExpected: HttpStatusCode.OK_200 705 expectedStatus: HttpStatusCode.OK_200
706 }) 706 })
707 707
708 expect(res.body.data).to.be.an('array') 708 expect(res.body.data).to.be.an('array')
@@ -762,7 +762,7 @@ describe('Test videos API validator', function () {
762 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', 762 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
763 token: server.accessToken, 763 token: server.accessToken,
764 fields, 764 fields,
765 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 765 expectedStatus: HttpStatusCode.NOT_FOUND_404
766 }) 766 })
767 }) 767 })
768 768
@@ -782,7 +782,7 @@ describe('Test videos API validator', function () {
782 path: path + videoId + '/rate', 782 path: path + videoId + '/rate',
783 token: server.accessToken, 783 token: server.accessToken,
784 fields, 784 fields,
785 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 785 expectedStatus: HttpStatusCode.NO_CONTENT_204
786 }) 786 })
787 }) 787 })
788 }) 788 })
@@ -792,7 +792,7 @@ describe('Test videos API validator', function () {
792 await makeDeleteRequest({ 792 await makeDeleteRequest({
793 url: server.url, 793 url: server.url,
794 path, 794 path,
795 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 795 expectedStatus: HttpStatusCode.BAD_REQUEST_400
796 }) 796 })
797 }) 797 })
798 798
@@ -812,7 +812,7 @@ describe('Test videos API validator', function () {
812 812
813 it('Shoud report the appropriate error', async function () { 813 it('Shoud report the appropriate error', async function () {
814 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 814 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
815 const error = body as unknown as PeerTubeProblemDocument 815 const error = body as PeerTubeProblemDocument
816 816
817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') 817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
818 818