aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/live.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/live.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/live.ts')
-rw-r--r--server/tests/api/check-params/live.ts43
1 files changed, 22 insertions, 21 deletions
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 055f2f295..40dca908b 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -24,6 +24,7 @@ import {
24 userLogin, 24 userLogin,
25 waitUntilLiveStarts 25 waitUntilLiveStarts
26} from '../../../../shared/extra-utils' 26} from '../../../../shared/extra-utils'
27import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
27 28
28describe('Test video lives API validator', function () { 29describe('Test video lives API validator', function () {
29 const path = '/api/v1/videos/live' 30 const path = '/api/v1/videos/live'
@@ -226,7 +227,7 @@ describe('Test video lives API validator', function () {
226 path, 227 path,
227 token: server.accessToken, 228 token: server.accessToken,
228 fields: baseCorrectParams, 229 fields: baseCorrectParams,
229 statusCodeExpected: 200 230 statusCodeExpected: HttpStatusCode.OK_200
230 }) 231 })
231 232
232 videoId = res.body.video.id 233 videoId = res.body.video.id
@@ -244,7 +245,7 @@ describe('Test video lives API validator', function () {
244 path, 245 path,
245 token: server.accessToken, 246 token: server.accessToken,
246 fields: baseCorrectParams, 247 fields: baseCorrectParams,
247 statusCodeExpected: 403 248 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
248 }) 249 })
249 }) 250 })
250 251
@@ -263,7 +264,7 @@ describe('Test video lives API validator', function () {
263 path, 264 path,
264 token: server.accessToken, 265 token: server.accessToken,
265 fields, 266 fields,
266 statusCodeExpected: 403 267 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
267 }) 268 })
268 }) 269 })
269 270
@@ -282,7 +283,7 @@ describe('Test video lives API validator', function () {
282 path, 283 path,
283 token: server.accessToken, 284 token: server.accessToken,
284 fields, 285 fields,
285 statusCodeExpected: 200 286 statusCodeExpected: HttpStatusCode.OK_200
286 }) 287 })
287 }) 288 })
288 289
@@ -299,7 +300,7 @@ describe('Test video lives API validator', function () {
299 path, 300 path,
300 token: server.accessToken, 301 token: server.accessToken,
301 fields: baseCorrectParams, 302 fields: baseCorrectParams,
302 statusCodeExpected: 403 303 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
303 }) 304 })
304 }) 305 })
305 306
@@ -317,7 +318,7 @@ describe('Test video lives API validator', function () {
317 path, 318 path,
318 token: server.accessToken, 319 token: server.accessToken,
319 fields: baseCorrectParams, 320 fields: baseCorrectParams,
320 statusCodeExpected: 403 321 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
321 }) 322 })
322 }) 323 })
323 }) 324 })
@@ -325,27 +326,27 @@ describe('Test video lives API validator', function () {
325 describe('When getting live information', function () { 326 describe('When getting live information', function () {
326 327
327 it('Should fail without access token', async function () { 328 it('Should fail without access token', async function () {
328 await getLive(server.url, '', videoId, 401) 329 await getLive(server.url, '', videoId, HttpStatusCode.UNAUTHORIZED_401)
329 }) 330 })
330 331
331 it('Should fail with a bad access token', async function () { 332 it('Should fail with a bad access token', async function () {
332 await getLive(server.url, 'toto', videoId, 401) 333 await getLive(server.url, 'toto', videoId, HttpStatusCode.UNAUTHORIZED_401)
333 }) 334 })
334 335
335 it('Should fail with access token of another user', async function () { 336 it('Should fail with access token of another user', async function () {
336 await getLive(server.url, userAccessToken, videoId, 403) 337 await getLive(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403)
337 }) 338 })
338 339
339 it('Should fail with a bad video id', async function () { 340 it('Should fail with a bad video id', async function () {
340 await getLive(server.url, server.accessToken, 'toto', 400) 341 await getLive(server.url, server.accessToken, 'toto', HttpStatusCode.BAD_REQUEST_400)
341 }) 342 })
342 343
343 it('Should fail with an unknown video id', async function () { 344 it('Should fail with an unknown video id', async function () {
344 await getLive(server.url, server.accessToken, 454555, 404) 345 await getLive(server.url, server.accessToken, 454555, HttpStatusCode.NOT_FOUND_404)
345 }) 346 })
346 347
347 it('Should fail with a non live video', async function () { 348 it('Should fail with a non live video', async function () {
348 await getLive(server.url, server.accessToken, videoIdNotLive, 404) 349 await getLive(server.url, server.accessToken, videoIdNotLive, HttpStatusCode.NOT_FOUND_404)
349 }) 350 })
350 351
351 it('Should succeed with the correct params', async function () { 352 it('Should succeed with the correct params', async function () {
@@ -356,33 +357,33 @@ describe('Test video lives API validator', function () {
356 describe('When updating live information', async function () { 357 describe('When updating live information', async function () {
357 358
358 it('Should fail without access token', async function () { 359 it('Should fail without access token', async function () {
359 await updateLive(server.url, '', videoId, {}, 401) 360 await updateLive(server.url, '', videoId, {}, HttpStatusCode.UNAUTHORIZED_401)
360 }) 361 })
361 362
362 it('Should fail with a bad access token', async function () { 363 it('Should fail with a bad access token', async function () {
363 await updateLive(server.url, 'toto', videoId, {}, 401) 364 await updateLive(server.url, 'toto', videoId, {}, HttpStatusCode.UNAUTHORIZED_401)
364 }) 365 })
365 366
366 it('Should fail with access token of another user', async function () { 367 it('Should fail with access token of another user', async function () {
367 await updateLive(server.url, userAccessToken, videoId, {}, 403) 368 await updateLive(server.url, userAccessToken, videoId, {}, HttpStatusCode.FORBIDDEN_403)
368 }) 369 })
369 370
370 it('Should fail with a bad video id', async function () { 371 it('Should fail with a bad video id', async function () {
371 await updateLive(server.url, server.accessToken, 'toto', {}, 400) 372 await updateLive(server.url, server.accessToken, 'toto', {}, HttpStatusCode.BAD_REQUEST_400)
372 }) 373 })
373 374
374 it('Should fail with an unknown video id', async function () { 375 it('Should fail with an unknown video id', async function () {
375 await updateLive(server.url, server.accessToken, 454555, {}, 404) 376 await updateLive(server.url, server.accessToken, 454555, {}, HttpStatusCode.NOT_FOUND_404)
376 }) 377 })
377 378
378 it('Should fail with a non live video', async function () { 379 it('Should fail with a non live video', async function () {
379 await updateLive(server.url, server.accessToken, videoIdNotLive, {}, 404) 380 await updateLive(server.url, server.accessToken, videoIdNotLive, {}, HttpStatusCode.NOT_FOUND_404)
380 }) 381 })
381 382
382 it('Should fail with save replay and permanent live set to true', async function () { 383 it('Should fail with save replay and permanent live set to true', async function () {
383 const fields = { saveReplay: true, permanentLive: true } 384 const fields = { saveReplay: true, permanentLive: true }
384 385
385 await updateLive(server.url, server.accessToken, videoId, fields, 400) 386 await updateLive(server.url, server.accessToken, videoId, fields, HttpStatusCode.BAD_REQUEST_400)
386 }) 387 })
387 388
388 it('Should succeed with the correct params', async function () { 389 it('Should succeed with the correct params', async function () {
@@ -397,7 +398,7 @@ describe('Test video lives API validator', function () {
397 } 398 }
398 }) 399 })
399 400
400 await updateLive(server.url, server.accessToken, videoId, { saveReplay: true }, 403) 401 await updateLive(server.url, server.accessToken, videoId, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403)
401 }) 402 })
402 403
403 it('Should fail to update a live if it has already started', async function () { 404 it('Should fail to update a live if it has already started', async function () {
@@ -409,7 +410,7 @@ describe('Test video lives API validator', function () {
409 const command = sendRTMPStream(live.rtmpUrl, live.streamKey) 410 const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
410 411
411 await waitUntilLiveStarts(server.url, server.accessToken, videoId) 412 await waitUntilLiveStarts(server.url, server.accessToken, videoId)
412 await updateLive(server.url, server.accessToken, videoId, {}, 400) 413 await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400)
413 414
414 await stopFfmpeg(command) 415 await stopFfmpeg(command)
415 }) 416 })