aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/blocklist.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/blocklist.ts')
-rw-r--r--server/tests/api/check-params/blocklist.ts91
1 files changed, 44 insertions, 47 deletions
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 })