diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-16 10:42:24 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea (patch) | |
tree | baf29753ac5d4598643e3bee719f8df0cc36c59d /server/tests/api/check-params/plugins.ts | |
parent | 08642a765ea514a00f159db898edf14c376fbe6c (diff) | |
download | PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.gz PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.zst PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.zip |
Refactor requests
Diffstat (limited to 'server/tests/api/check-params/plugins.ts')
-rw-r--r-- | server/tests/api/check-params/plugins.ts | 66 |
1 files changed, 33 insertions, 33 deletions
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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
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 | }) |