aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/plugins.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/tests/api/check-params/plugins.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/tests/api/check-params/plugins.ts')
-rw-r--r--server/tests/api/check-params/plugins.ts69
1 files changed, 35 insertions, 34 deletions
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 07ded26ee..6e540bcbb 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -18,6 +18,7 @@ import {
18} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
19import { PluginType } from '../../../../shared/models/plugins/plugin.type' 19import { PluginType } from '../../../../shared/models/plugins/plugin.type'
20import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugin.model' 20import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugin.model'
21import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
21 22
22describe('Test server plugins API validators', function () { 23describe('Test server plugins API validators', function () {
23 let server: ServerInfo 24 let server: ServerInfo
@@ -73,7 +74,7 @@ describe('Test server plugins API validators', function () {
73 ] 74 ]
74 75
75 for (const p of paths) { 76 for (const p of paths) {
76 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: 404 }) 77 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
77 } 78 }
78 }) 79 })
79 80
@@ -81,7 +82,7 @@ describe('Test server plugins API validators', function () {
81 await makeGetRequest({ 82 await makeGetRequest({
82 url: server.url, 83 url: server.url,
83 path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png', 84 path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png',
84 statusCodeExpected: 404 85 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
85 }) 86 })
86 }) 87 })
87 88
@@ -96,7 +97,7 @@ describe('Test server plugins API validators', function () {
96 ] 97 ]
97 98
98 for (const p of paths) { 99 for (const p of paths) {
99 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: 400 }) 100 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
100 } 101 }
101 }) 102 })
102 103
@@ -110,14 +111,14 @@ describe('Test server plugins API validators', function () {
110 ] 111 ]
111 112
112 for (const p of paths) { 113 for (const p of paths) {
113 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: 400 }) 114 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
114 } 115 }
115 }) 116 })
116 117
117 it('Should fail with an unknown auth name', async function () { 118 it('Should fail with an unknown auth name', async function () {
118 const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth' 119 const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth'
119 120
120 await makeGetRequest({ url: server.url, path, statusCodeExpected: 404 }) 121 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
121 }) 122 })
122 123
123 it('Should fail with an unknown static file', async function () { 124 it('Should fail with an unknown static file', async function () {
@@ -129,7 +130,7 @@ describe('Test server plugins API validators', function () {
129 ] 130 ]
130 131
131 for (const p of paths) { 132 for (const p of paths) {
132 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: 404 }) 133 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
133 } 134 }
134 }) 135 })
135 136
@@ -137,7 +138,7 @@ describe('Test server plugins API validators', function () {
137 await makeGetRequest({ 138 await makeGetRequest({
138 url: server.url, 139 url: server.url,
139 path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css', 140 path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css',
140 statusCodeExpected: 404 141 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
141 }) 142 })
142 }) 143 })
143 144
@@ -151,11 +152,11 @@ describe('Test server plugins API validators', function () {
151 ] 152 ]
152 153
153 for (const p of paths) { 154 for (const p of paths) {
154 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: 200 }) 155 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.OK_200 })
155 } 156 }
156 157
157 const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth' 158 const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth'
158 await makeGetRequest({ url: server.url, path: authPath, statusCodeExpected: 302 }) 159 await makeGetRequest({ url: server.url, path: authPath, statusCodeExpected: HttpStatusCode.FOUND_302 })
159 }) 160 })
160 }) 161 })
161 162
@@ -173,7 +174,7 @@ describe('Test server plugins API validators', function () {
173 path, 174 path,
174 token: 'fake_token', 175 token: 'fake_token',
175 query: baseQuery, 176 query: baseQuery,
176 statusCodeExpected: 401 177 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
177 }) 178 })
178 }) 179 })
179 180
@@ -183,7 +184,7 @@ describe('Test server plugins API validators', function () {
183 path, 184 path,
184 token: userAccessToken, 185 token: userAccessToken,
185 query: baseQuery, 186 query: baseQuery,
186 statusCodeExpected: 403 187 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
187 }) 188 })
188 }) 189 })
189 190
@@ -227,7 +228,7 @@ describe('Test server plugins API validators', function () {
227 path, 228 path,
228 token: server.accessToken, 229 token: server.accessToken,
229 query: baseQuery, 230 query: baseQuery,
230 statusCodeExpected: 200 231 statusCodeExpected: HttpStatusCode.OK_200
231 }) 232 })
232 }) 233 })
233 }) 234 })
@@ -244,7 +245,7 @@ describe('Test server plugins API validators', function () {
244 path, 245 path,
245 token: 'fake_token', 246 token: 'fake_token',
246 query: baseQuery, 247 query: baseQuery,
247 statusCodeExpected: 401 248 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
248 }) 249 })
249 }) 250 })
250 251
@@ -254,7 +255,7 @@ describe('Test server plugins API validators', function () {
254 path, 255 path,
255 token: userAccessToken, 256 token: userAccessToken,
256 query: baseQuery, 257 query: baseQuery,
257 statusCodeExpected: 403 258 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
258 }) 259 })
259 }) 260 })
260 261
@@ -287,7 +288,7 @@ describe('Test server plugins API validators', function () {
287 path, 288 path,
288 token: server.accessToken, 289 token: server.accessToken,
289 query: baseQuery, 290 query: baseQuery,
290 statusCodeExpected: 200 291 statusCodeExpected: HttpStatusCode.OK_200
291 }) 292 })
292 }) 293 })
293 }) 294 })
@@ -301,7 +302,7 @@ describe('Test server plugins API validators', function () {
301 url: server.url, 302 url: server.url,
302 path: path + suffix, 303 path: path + suffix,
303 token: 'fake_token', 304 token: 'fake_token',
304 statusCodeExpected: 401 305 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
305 }) 306 })
306 } 307 }
307 }) 308 })
@@ -312,7 +313,7 @@ describe('Test server plugins API validators', function () {
312 url: server.url, 313 url: server.url,
313 path: path + suffix, 314 path: path + suffix,
314 token: userAccessToken, 315 token: userAccessToken,
315 statusCodeExpected: 403 316 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
316 }) 317 })
317 } 318 }
318 }) 319 })
@@ -323,7 +324,7 @@ describe('Test server plugins API validators', function () {
323 url: server.url, 324 url: server.url,
324 path: path + suffix, 325 path: path + suffix,
325 token: server.accessToken, 326 token: server.accessToken,
326 statusCodeExpected: 400 327 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
327 }) 328 })
328 } 329 }
329 330
@@ -332,7 +333,7 @@ describe('Test server plugins API validators', function () {
332 url: server.url, 333 url: server.url,
333 path: path + suffix, 334 path: path + suffix,
334 token: server.accessToken, 335 token: server.accessToken,
335 statusCodeExpected: 400 336 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
336 }) 337 })
337 } 338 }
338 }) 339 })
@@ -343,7 +344,7 @@ describe('Test server plugins API validators', function () {
343 url: server.url, 344 url: server.url,
344 path: path + suffix, 345 path: path + suffix,
345 token: server.accessToken, 346 token: server.accessToken,
346 statusCodeExpected: 404 347 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
347 }) 348 })
348 } 349 }
349 }) 350 })
@@ -354,7 +355,7 @@ describe('Test server plugins API validators', function () {
354 url: server.url, 355 url: server.url,
355 path: path + suffix, 356 path: path + suffix,
356 token: server.accessToken, 357 token: server.accessToken,
357 statusCodeExpected: 200 358 statusCodeExpected: HttpStatusCode.OK_200
358 }) 359 })
359 } 360 }
360 }) 361 })
@@ -370,7 +371,7 @@ describe('Test server plugins API validators', function () {
370 path: path + npmPlugin + '/settings', 371 path: path + npmPlugin + '/settings',
371 fields: { settings }, 372 fields: { settings },
372 token: 'fake_token', 373 token: 'fake_token',
373 statusCodeExpected: 401 374 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
374 }) 375 })
375 }) 376 })
376 377
@@ -380,7 +381,7 @@ describe('Test server plugins API validators', function () {
380 path: path + npmPlugin + '/settings', 381 path: path + npmPlugin + '/settings',
381 fields: { settings }, 382 fields: { settings },
382 token: userAccessToken, 383 token: userAccessToken,
383 statusCodeExpected: 403 384 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
384 }) 385 })
385 }) 386 })
386 387
@@ -390,7 +391,7 @@ describe('Test server plugins API validators', function () {
390 path: path + 'toto/settings', 391 path: path + 'toto/settings',
391 fields: { settings }, 392 fields: { settings },
392 token: server.accessToken, 393 token: server.accessToken,
393 statusCodeExpected: 400 394 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
394 }) 395 })
395 396
396 await makePutBodyRequest({ 397 await makePutBodyRequest({
@@ -398,7 +399,7 @@ describe('Test server plugins API validators', function () {
398 path: path + 'peertube-plugin-TOTO/settings', 399 path: path + 'peertube-plugin-TOTO/settings',
399 fields: { settings }, 400 fields: { settings },
400 token: server.accessToken, 401 token: server.accessToken,
401 statusCodeExpected: 400 402 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
402 }) 403 })
403 }) 404 })
404 405
@@ -408,7 +409,7 @@ describe('Test server plugins API validators', function () {
408 path: path + 'peertube-plugin-toto/settings', 409 path: path + 'peertube-plugin-toto/settings',
409 fields: { settings }, 410 fields: { settings },
410 token: server.accessToken, 411 token: server.accessToken,
411 statusCodeExpected: 404 412 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
412 }) 413 })
413 }) 414 })
414 415
@@ -418,7 +419,7 @@ describe('Test server plugins API validators', function () {
418 path: path + npmPlugin + '/settings', 419 path: path + npmPlugin + '/settings',
419 fields: { settings }, 420 fields: { settings },
420 token: server.accessToken, 421 token: server.accessToken,
421 statusCodeExpected: 204 422 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
422 }) 423 })
423 }) 424 })
424 }) 425 })
@@ -433,7 +434,7 @@ describe('Test server plugins API validators', function () {
433 path: path + suffix, 434 path: path + suffix,
434 fields: { npmName: npmPlugin }, 435 fields: { npmName: npmPlugin },
435 token: 'fake_token', 436 token: 'fake_token',
436 statusCodeExpected: 401 437 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
437 }) 438 })
438 } 439 }
439 }) 440 })
@@ -445,7 +446,7 @@ describe('Test server plugins API validators', function () {
445 path: path + suffix, 446 path: path + suffix,
446 fields: { npmName: npmPlugin }, 447 fields: { npmName: npmPlugin },
447 token: userAccessToken, 448 token: userAccessToken,
448 statusCodeExpected: 403 449 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
449 }) 450 })
450 } 451 }
451 }) 452 })
@@ -457,7 +458,7 @@ describe('Test server plugins API validators', function () {
457 path: path + suffix, 458 path: path + suffix,
458 fields: { npmName: 'toto' }, 459 fields: { npmName: 'toto' },
459 token: server.accessToken, 460 token: server.accessToken,
460 statusCodeExpected: 400 461 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
461 }) 462 })
462 } 463 }
463 464
@@ -467,7 +468,7 @@ describe('Test server plugins API validators', function () {
467 path: path + suffix, 468 path: path + suffix,
468 fields: { npmName: 'peertube-plugin-TOTO' }, 469 fields: { npmName: 'peertube-plugin-TOTO' },
469 token: server.accessToken, 470 token: server.accessToken,
470 statusCodeExpected: 400 471 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
471 }) 472 })
472 } 473 }
473 }) 474 })
@@ -476,9 +477,9 @@ describe('Test server plugins API validators', function () {
476 this.timeout(10000) 477 this.timeout(10000)
477 478
478 const it = [ 479 const it = [
479 { suffix: 'install', status: 200 }, 480 { suffix: 'install', status: HttpStatusCode.OK_200 },
480 { suffix: 'update', status: 200 }, 481 { suffix: 'update', status: HttpStatusCode.OK_200 },
481 { suffix: 'uninstall', status: 204 } 482 { suffix: 'uninstall', status: HttpStatusCode.NO_CONTENT_204 }
482 ] 483 ]
483 484
484 for (const obj of it) { 485 for (const obj of it) {