aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/live.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/live.ts')
-rw-r--r--server/tests/api/check-params/live.ts40
1 files changed, 21 insertions, 19 deletions
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 32233c9da..933d8abf2 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { LiveVideo, VideoPrivacy } from '@shared/models' 5import { LiveVideo, VideoCreateResult, VideoPrivacy } from '@shared/models'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
@@ -31,7 +31,7 @@ describe('Test video lives API validator', function () {
31 let server: ServerInfo 31 let server: ServerInfo
32 let userAccessToken = '' 32 let userAccessToken = ''
33 let channelId: number 33 let channelId: number
34 let videoId: number 34 let video: VideoCreateResult
35 let videoIdNotLive: number 35 let videoIdNotLive: number
36 36
37 // --------------------------------------------------------------- 37 // ---------------------------------------------------------------
@@ -230,7 +230,7 @@ describe('Test video lives API validator', function () {
230 statusCodeExpected: HttpStatusCode.OK_200 230 statusCodeExpected: HttpStatusCode.OK_200
231 }) 231 })
232 232
233 videoId = res.body.video.id 233 video = res.body.video
234 }) 234 })
235 235
236 it('Should forbid if live is disabled', async function () { 236 it('Should forbid if live is disabled', async function () {
@@ -326,15 +326,15 @@ describe('Test video lives API validator', function () {
326 describe('When getting live information', function () { 326 describe('When getting live information', function () {
327 327
328 it('Should fail without access token', async function () { 328 it('Should fail without access token', async function () {
329 await getLive(server.url, '', videoId, HttpStatusCode.UNAUTHORIZED_401) 329 await getLive(server.url, '', video.id, HttpStatusCode.UNAUTHORIZED_401)
330 }) 330 })
331 331
332 it('Should fail with a bad access token', async function () { 332 it('Should fail with a bad access token', async function () {
333 await getLive(server.url, 'toto', videoId, HttpStatusCode.UNAUTHORIZED_401) 333 await getLive(server.url, 'toto', video.id, HttpStatusCode.UNAUTHORIZED_401)
334 }) 334 })
335 335
336 it('Should fail with access token of another user', async function () { 336 it('Should fail with access token of another user', async function () {
337 await getLive(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) 337 await getLive(server.url, userAccessToken, video.id, HttpStatusCode.FORBIDDEN_403)
338 }) 338 })
339 339
340 it('Should fail with a bad video id', async function () { 340 it('Should fail with a bad video id', async function () {
@@ -350,22 +350,23 @@ describe('Test video lives API validator', function () {
350 }) 350 })
351 351
352 it('Should succeed with the correct params', async function () { 352 it('Should succeed with the correct params', async function () {
353 await getLive(server.url, server.accessToken, videoId) 353 await getLive(server.url, server.accessToken, video.id)
354 await getLive(server.url, server.accessToken, video.shortUUID)
354 }) 355 })
355 }) 356 })
356 357
357 describe('When updating live information', async function () { 358 describe('When updating live information', async function () {
358 359
359 it('Should fail without access token', async function () { 360 it('Should fail without access token', async function () {
360 await updateLive(server.url, '', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) 361 await updateLive(server.url, '', video.id, {}, HttpStatusCode.UNAUTHORIZED_401)
361 }) 362 })
362 363
363 it('Should fail with a bad access token', async function () { 364 it('Should fail with a bad access token', async function () {
364 await updateLive(server.url, 'toto', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) 365 await updateLive(server.url, 'toto', video.id, {}, HttpStatusCode.UNAUTHORIZED_401)
365 }) 366 })
366 367
367 it('Should fail with access token of another user', async function () { 368 it('Should fail with access token of another user', async function () {
368 await updateLive(server.url, userAccessToken, videoId, {}, HttpStatusCode.FORBIDDEN_403) 369 await updateLive(server.url, userAccessToken, video.id, {}, HttpStatusCode.FORBIDDEN_403)
369 }) 370 })
370 371
371 it('Should fail with a bad video id', async function () { 372 it('Should fail with a bad video id', async function () {
@@ -383,11 +384,12 @@ describe('Test video lives API validator', function () {
383 it('Should fail with save replay and permanent live set to true', async function () { 384 it('Should fail with save replay and permanent live set to true', async function () {
384 const fields = { saveReplay: true, permanentLive: true } 385 const fields = { saveReplay: true, permanentLive: true }
385 386
386 await updateLive(server.url, server.accessToken, videoId, fields, HttpStatusCode.BAD_REQUEST_400) 387 await updateLive(server.url, server.accessToken, video.id, fields, HttpStatusCode.BAD_REQUEST_400)
387 }) 388 })
388 389
389 it('Should succeed with the correct params', async function () { 390 it('Should succeed with the correct params', async function () {
390 await updateLive(server.url, server.accessToken, videoId, { saveReplay: false }) 391 await updateLive(server.url, server.accessToken, video.id, { saveReplay: false })
392 await updateLive(server.url, server.accessToken, video.shortUUID, { saveReplay: false })
391 }) 393 })
392 394
393 it('Should fail to update replay status if replay is not allowed on the instance', async function () { 395 it('Should fail to update replay status if replay is not allowed on the instance', async function () {
@@ -398,19 +400,19 @@ describe('Test video lives API validator', function () {
398 } 400 }
399 }) 401 })
400 402
401 await updateLive(server.url, server.accessToken, videoId, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403) 403 await updateLive(server.url, server.accessToken, video.id, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403)
402 }) 404 })
403 405
404 it('Should fail to update a live if it has already started', async function () { 406 it('Should fail to update a live if it has already started', async function () {
405 this.timeout(40000) 407 this.timeout(40000)
406 408
407 const resLive = await getLive(server.url, server.accessToken, videoId) 409 const resLive = await getLive(server.url, server.accessToken, video.id)
408 const live: LiveVideo = resLive.body 410 const live: LiveVideo = resLive.body
409 411
410 const command = sendRTMPStream(live.rtmpUrl, live.streamKey) 412 const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
411 413
412 await waitUntilLivePublished(server.url, server.accessToken, videoId) 414 await waitUntilLivePublished(server.url, server.accessToken, video.id)
413 await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400) 415 await updateLive(server.url, server.accessToken, video.id, {}, HttpStatusCode.BAD_REQUEST_400)
414 416
415 await stopFfmpeg(command) 417 await stopFfmpeg(command)
416 }) 418 })
@@ -418,14 +420,14 @@ describe('Test video lives API validator', function () {
418 it('Should fail to stream twice in the save live', async function () { 420 it('Should fail to stream twice in the save live', async function () {
419 this.timeout(40000) 421 this.timeout(40000)
420 422
421 const resLive = await getLive(server.url, server.accessToken, videoId) 423 const resLive = await getLive(server.url, server.accessToken, video.id)
422 const live: LiveVideo = resLive.body 424 const live: LiveVideo = resLive.body
423 425
424 const command = sendRTMPStream(live.rtmpUrl, live.streamKey) 426 const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
425 427
426 await waitUntilLivePublished(server.url, server.accessToken, videoId) 428 await waitUntilLivePublished(server.url, server.accessToken, video.id)
427 429
428 await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true) 430 await runAndTestFfmpegStreamError(server.url, server.accessToken, video.id, true)
429 431
430 await stopFfmpeg(command) 432 await stopFfmpeg(command)
431 }) 433 })