aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/blocklist.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
committerChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
commita24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch)
treea54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/check-params/blocklist.ts
parent5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff)
parentc63830f15403ac4e750829f27d8bbbdc9a59282c (diff)
downloadPeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/check-params/blocklist.ts')
-rw-r--r--server/tests/api/check-params/blocklist.ts107
1 files changed, 51 insertions, 56 deletions
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index 5ed8810ce..7d5fae5cf 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -1,43 +1,38 @@
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 createUser, 9 createMultipleServers,
8 doubleFollow, 10 doubleFollow,
9 flushAndRunMultipleServers,
10 makeDeleteRequest, 11 makeDeleteRequest,
11 makeGetRequest, 12 makeGetRequest,
12 makePostBodyRequest, 13 makePostBodyRequest,
13 ServerInfo, 14 PeerTubeServer,
14 setAccessTokensToServers, 15 setAccessTokensToServers
15 userLogin 16} from '@shared/extra-utils'
16} from '../../../../shared/extra-utils' 17import { HttpStatusCode } from '@shared/models'
17import {
18 checkBadCountPagination,
19 checkBadSortPagination,
20 checkBadStartPagination
21} from '../../../../shared/extra-utils/requests/check-api-params'
22import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
23 18
24describe('Test blocklist API validators', function () { 19describe('Test blocklist API validators', function () {
25 let servers: ServerInfo[] 20 let servers: PeerTubeServer[]
26 let server: ServerInfo 21 let server: PeerTubeServer
27 let userAccessToken: string 22 let userAccessToken: string
28 23
29 before(async function () { 24 before(async function () {
30 this.timeout(60000) 25 this.timeout(60000)
31 26
32 servers = await flushAndRunMultipleServers(2) 27 servers = await createMultipleServers(2)
33 await setAccessTokensToServers(servers) 28 await setAccessTokensToServers(servers)
34 29
35 server = servers[0] 30 server = servers[0]
36 31
37 const user = { username: 'user1', password: 'password' } 32 const user = { username: 'user1', password: 'password' }
38 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) 33 await server.users.create({ username: user.username, password: user.password })
39 34
40 userAccessToken = await userLogin(server, user) 35 userAccessToken = await server.login.getAccessToken(user)
41 36
42 await doubleFollow(servers[0], servers[1]) 37 await doubleFollow(servers[0], servers[1])
43 }) 38 })
@@ -54,7 +49,7 @@ describe('Test blocklist API validators', function () {
54 await makeGetRequest({ 49 await makeGetRequest({
55 url: server.url, 50 url: server.url,
56 path, 51 path,
57 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 52 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
58 }) 53 })
59 }) 54 })
60 55
@@ -77,7 +72,7 @@ describe('Test blocklist API validators', function () {
77 url: server.url, 72 url: server.url,
78 path, 73 path,
79 fields: { accountName: 'user1' }, 74 fields: { accountName: 'user1' },
80 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 75 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
81 }) 76 })
82 }) 77 })
83 78
@@ -87,7 +82,7 @@ describe('Test blocklist API validators', function () {
87 token: server.accessToken, 82 token: server.accessToken,
88 path, 83 path,
89 fields: { accountName: 'user2' }, 84 fields: { accountName: 'user2' },
90 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 85 expectedStatus: HttpStatusCode.NOT_FOUND_404
91 }) 86 })
92 }) 87 })
93 88
@@ -97,7 +92,7 @@ describe('Test blocklist API validators', function () {
97 token: server.accessToken, 92 token: server.accessToken,
98 path, 93 path,
99 fields: { accountName: 'root' }, 94 fields: { accountName: 'root' },
100 statusCodeExpected: HttpStatusCode.CONFLICT_409 95 expectedStatus: HttpStatusCode.CONFLICT_409
101 }) 96 })
102 }) 97 })
103 98
@@ -107,7 +102,7 @@ describe('Test blocklist API validators', function () {
107 token: server.accessToken, 102 token: server.accessToken,
108 path, 103 path,
109 fields: { accountName: 'user1' }, 104 fields: { accountName: 'user1' },
110 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 105 expectedStatus: HttpStatusCode.NO_CONTENT_204
111 }) 106 })
112 }) 107 })
113 }) 108 })
@@ -117,7 +112,7 @@ describe('Test blocklist API validators', function () {
117 await makeDeleteRequest({ 112 await makeDeleteRequest({
118 url: server.url, 113 url: server.url,
119 path: path + '/user1', 114 path: path + '/user1',
120 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 115 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
121 }) 116 })
122 }) 117 })
123 118
@@ -126,7 +121,7 @@ describe('Test blocklist API validators', function () {
126 url: server.url, 121 url: server.url,
127 path: path + '/user2', 122 path: path + '/user2',
128 token: server.accessToken, 123 token: server.accessToken,
129 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 124 expectedStatus: HttpStatusCode.NOT_FOUND_404
130 }) 125 })
131 }) 126 })
132 127
@@ -135,7 +130,7 @@ describe('Test blocklist API validators', function () {
135 url: server.url, 130 url: server.url,
136 path: path + '/user1', 131 path: path + '/user1',
137 token: server.accessToken, 132 token: server.accessToken,
138 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 133 expectedStatus: HttpStatusCode.NO_CONTENT_204
139 }) 134 })
140 }) 135 })
141 }) 136 })
@@ -149,7 +144,7 @@ describe('Test blocklist API validators', function () {
149 await makeGetRequest({ 144 await makeGetRequest({
150 url: server.url, 145 url: server.url,
151 path, 146 path,
152 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 147 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
153 }) 148 })
154 }) 149 })
155 150
@@ -172,7 +167,7 @@ describe('Test blocklist API validators', function () {
172 url: server.url, 167 url: server.url,
173 path, 168 path,
174 fields: { host: 'localhost:9002' }, 169 fields: { host: 'localhost:9002' },
175 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 170 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
176 }) 171 })
177 }) 172 })
178 173
@@ -182,7 +177,7 @@ describe('Test blocklist API validators', function () {
182 token: server.accessToken, 177 token: server.accessToken,
183 path, 178 path,
184 fields: { host: 'localhost:9003' }, 179 fields: { host: 'localhost:9003' },
185 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 180 expectedStatus: HttpStatusCode.NO_CONTENT_204
186 }) 181 })
187 }) 182 })
188 183
@@ -192,7 +187,7 @@ describe('Test blocklist API validators', function () {
192 token: server.accessToken, 187 token: server.accessToken,
193 path, 188 path,
194 fields: { host: 'localhost:' + server.port }, 189 fields: { host: 'localhost:' + server.port },
195 statusCodeExpected: HttpStatusCode.CONFLICT_409 190 expectedStatus: HttpStatusCode.CONFLICT_409
196 }) 191 })
197 }) 192 })
198 193
@@ -202,7 +197,7 @@ describe('Test blocklist API validators', function () {
202 token: server.accessToken, 197 token: server.accessToken,
203 path, 198 path,
204 fields: { host: 'localhost:' + servers[1].port }, 199 fields: { host: 'localhost:' + servers[1].port },
205 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 200 expectedStatus: HttpStatusCode.NO_CONTENT_204
206 }) 201 })
207 }) 202 })
208 }) 203 })
@@ -212,7 +207,7 @@ describe('Test blocklist API validators', function () {
212 await makeDeleteRequest({ 207 await makeDeleteRequest({
213 url: server.url, 208 url: server.url,
214 path: path + '/localhost:' + servers[1].port, 209 path: path + '/localhost:' + servers[1].port,
215 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 210 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
216 }) 211 })
217 }) 212 })
218 213
@@ -221,7 +216,7 @@ describe('Test blocklist API validators', function () {
221 url: server.url, 216 url: server.url,
222 path: path + '/localhost:9004', 217 path: path + '/localhost:9004',
223 token: server.accessToken, 218 token: server.accessToken,
224 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 219 expectedStatus: HttpStatusCode.NOT_FOUND_404
225 }) 220 })
226 }) 221 })
227 222
@@ -230,7 +225,7 @@ describe('Test blocklist API validators', function () {
230 url: server.url, 225 url: server.url,
231 path: path + '/localhost:' + servers[1].port, 226 path: path + '/localhost:' + servers[1].port,
232 token: server.accessToken, 227 token: server.accessToken,
233 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 228 expectedStatus: HttpStatusCode.NO_CONTENT_204
234 }) 229 })
235 }) 230 })
236 }) 231 })
@@ -247,7 +242,7 @@ describe('Test blocklist API validators', function () {
247 await makeGetRequest({ 242 await makeGetRequest({
248 url: server.url, 243 url: server.url,
249 path, 244 path,
250 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 245 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
251 }) 246 })
252 }) 247 })
253 248
@@ -256,7 +251,7 @@ describe('Test blocklist API validators', function () {
256 url: server.url, 251 url: server.url,
257 token: userAccessToken, 252 token: userAccessToken,
258 path, 253 path,
259 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 254 expectedStatus: HttpStatusCode.FORBIDDEN_403
260 }) 255 })
261 }) 256 })
262 257
@@ -279,7 +274,7 @@ describe('Test blocklist API validators', function () {
279 url: server.url, 274 url: server.url,
280 path, 275 path,
281 fields: { accountName: 'user1' }, 276 fields: { accountName: 'user1' },
282 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 277 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
283 }) 278 })
284 }) 279 })
285 280
@@ -289,7 +284,7 @@ describe('Test blocklist API validators', function () {
289 token: userAccessToken, 284 token: userAccessToken,
290 path, 285 path,
291 fields: { accountName: 'user1' }, 286 fields: { accountName: 'user1' },
292 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 287 expectedStatus: HttpStatusCode.FORBIDDEN_403
293 }) 288 })
294 }) 289 })
295 290
@@ -299,7 +294,7 @@ describe('Test blocklist API validators', function () {
299 token: server.accessToken, 294 token: server.accessToken,
300 path, 295 path,
301 fields: { accountName: 'user2' }, 296 fields: { accountName: 'user2' },
302 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 297 expectedStatus: HttpStatusCode.NOT_FOUND_404
303 }) 298 })
304 }) 299 })
305 300
@@ -309,7 +304,7 @@ describe('Test blocklist API validators', function () {
309 token: server.accessToken, 304 token: server.accessToken,
310 path, 305 path,
311 fields: { accountName: 'root' }, 306 fields: { accountName: 'root' },
312 statusCodeExpected: HttpStatusCode.CONFLICT_409 307 expectedStatus: HttpStatusCode.CONFLICT_409
313 }) 308 })
314 }) 309 })
315 310
@@ -319,7 +314,7 @@ describe('Test blocklist API validators', function () {
319 token: server.accessToken, 314 token: server.accessToken,
320 path, 315 path,
321 fields: { accountName: 'user1' }, 316 fields: { accountName: 'user1' },
322 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 317 expectedStatus: HttpStatusCode.NO_CONTENT_204
323 }) 318 })
324 }) 319 })
325 }) 320 })
@@ -329,7 +324,7 @@ describe('Test blocklist API validators', function () {
329 await makeDeleteRequest({ 324 await makeDeleteRequest({
330 url: server.url, 325 url: server.url,
331 path: path + '/user1', 326 path: path + '/user1',
332 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 327 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
333 }) 328 })
334 }) 329 })
335 330
@@ -338,7 +333,7 @@ describe('Test blocklist API validators', function () {
338 url: server.url, 333 url: server.url,
339 path: path + '/user1', 334 path: path + '/user1',
340 token: userAccessToken, 335 token: userAccessToken,
341 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 336 expectedStatus: HttpStatusCode.FORBIDDEN_403
342 }) 337 })
343 }) 338 })
344 339
@@ -347,7 +342,7 @@ describe('Test blocklist API validators', function () {
347 url: server.url, 342 url: server.url,
348 path: path + '/user2', 343 path: path + '/user2',
349 token: server.accessToken, 344 token: server.accessToken,
350 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 345 expectedStatus: HttpStatusCode.NOT_FOUND_404
351 }) 346 })
352 }) 347 })
353 348
@@ -356,7 +351,7 @@ describe('Test blocklist API validators', function () {
356 url: server.url, 351 url: server.url,
357 path: path + '/user1', 352 path: path + '/user1',
358 token: server.accessToken, 353 token: server.accessToken,
359 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 354 expectedStatus: HttpStatusCode.NO_CONTENT_204
360 }) 355 })
361 }) 356 })
362 }) 357 })
@@ -370,7 +365,7 @@ describe('Test blocklist API validators', function () {
370 await makeGetRequest({ 365 await makeGetRequest({
371 url: server.url, 366 url: server.url,
372 path, 367 path,
373 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 368 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
374 }) 369 })
375 }) 370 })
376 371
@@ -379,7 +374,7 @@ describe('Test blocklist API validators', function () {
379 url: server.url, 374 url: server.url,
380 token: userAccessToken, 375 token: userAccessToken,
381 path, 376 path,
382 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 377 expectedStatus: HttpStatusCode.FORBIDDEN_403
383 }) 378 })
384 }) 379 })
385 380
@@ -402,7 +397,7 @@ describe('Test blocklist API validators', function () {
402 url: server.url, 397 url: server.url,
403 path, 398 path,
404 fields: { host: 'localhost:' + servers[1].port }, 399 fields: { host: 'localhost:' + servers[1].port },
405 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 400 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
406 }) 401 })
407 }) 402 })
408 403
@@ -412,7 +407,7 @@ describe('Test blocklist API validators', function () {
412 token: userAccessToken, 407 token: userAccessToken,
413 path, 408 path,
414 fields: { host: 'localhost:' + servers[1].port }, 409 fields: { host: 'localhost:' + servers[1].port },
415 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 410 expectedStatus: HttpStatusCode.FORBIDDEN_403
416 }) 411 })
417 }) 412 })
418 413
@@ -422,7 +417,7 @@ describe('Test blocklist API validators', function () {
422 token: server.accessToken, 417 token: server.accessToken,
423 path, 418 path,
424 fields: { host: 'localhost:9003' }, 419 fields: { host: 'localhost:9003' },
425 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 420 expectedStatus: HttpStatusCode.NO_CONTENT_204
426 }) 421 })
427 }) 422 })
428 423
@@ -432,7 +427,7 @@ describe('Test blocklist API validators', function () {
432 token: server.accessToken, 427 token: server.accessToken,
433 path, 428 path,
434 fields: { host: 'localhost:' + server.port }, 429 fields: { host: 'localhost:' + server.port },
435 statusCodeExpected: HttpStatusCode.CONFLICT_409 430 expectedStatus: HttpStatusCode.CONFLICT_409
436 }) 431 })
437 }) 432 })
438 433
@@ -442,7 +437,7 @@ describe('Test blocklist API validators', function () {
442 token: server.accessToken, 437 token: server.accessToken,
443 path, 438 path,
444 fields: { host: 'localhost:' + servers[1].port }, 439 fields: { host: 'localhost:' + servers[1].port },
445 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 440 expectedStatus: HttpStatusCode.NO_CONTENT_204
446 }) 441 })
447 }) 442 })
448 }) 443 })
@@ -452,7 +447,7 @@ describe('Test blocklist API validators', function () {
452 await makeDeleteRequest({ 447 await makeDeleteRequest({
453 url: server.url, 448 url: server.url,
454 path: path + '/localhost:' + servers[1].port, 449 path: path + '/localhost:' + servers[1].port,
455 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 450 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
456 }) 451 })
457 }) 452 })
458 453
@@ -461,7 +456,7 @@ describe('Test blocklist API validators', function () {
461 url: server.url, 456 url: server.url,
462 path: path + '/localhost:' + servers[1].port, 457 path: path + '/localhost:' + servers[1].port,
463 token: userAccessToken, 458 token: userAccessToken,
464 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 459 expectedStatus: HttpStatusCode.FORBIDDEN_403
465 }) 460 })
466 }) 461 })
467 462
@@ -470,7 +465,7 @@ describe('Test blocklist API validators', function () {
470 url: server.url, 465 url: server.url,
471 path: path + '/localhost:9004', 466 path: path + '/localhost:9004',
472 token: server.accessToken, 467 token: server.accessToken,
473 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 468 expectedStatus: HttpStatusCode.NOT_FOUND_404
474 }) 469 })
475 }) 470 })
476 471
@@ -479,7 +474,7 @@ describe('Test blocklist API validators', function () {
479 url: server.url, 474 url: server.url,
480 path: path + '/localhost:' + servers[1].port, 475 path: path + '/localhost:' + servers[1].port,
481 token: server.accessToken, 476 token: server.accessToken,
482 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 477 expectedStatus: HttpStatusCode.NO_CONTENT_204
483 }) 478 })
484 }) 479 })
485 }) 480 })