]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/live/live-constraints.ts
Introduce blacklist command
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live-constraints.ts
index cc635de339d2102858ffbcfc08cf225187e98d97..46153f7b1b1a035c074e8eafd283cd5accc21a21 100644 (file)
@@ -6,21 +6,17 @@ import { VideoDetails, VideoPrivacy } from '@shared/models'
 import {
   checkLiveCleanup,
   cleanupTests,
-  createLive,
+  ConfigCommand,
   doubleFollow,
   flushAndRunMultipleServers,
   generateUser,
-  getCustomConfigResolutions,
   getVideo,
-  runAndTestFfmpegStreamError,
   ServerInfo,
   setAccessTokensToServers,
   setDefaultVideoChannel,
-  updateCustomSubConfig,
   updateUser,
   wait,
-  waitJobs,
-  waitUntilLivePublished
+  waitJobs
 } from '../../../../shared/extra-utils'
 
 const expect = chai.expect
@@ -39,8 +35,8 @@ describe('Test live constraints', function () {
       saveReplay
     }
 
-    const res = await createLive(servers[0].url, userAccessToken, liveAttributes)
-    return res.body.video.uuid as string
+    const { uuid } = await servers[0].liveCommand.create({ token: userAccessToken, fields: liveAttributes })
+    return uuid
   }
 
   async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) {
@@ -57,7 +53,7 @@ describe('Test live constraints', function () {
 
   async function waitUntilLivePublishedOnAllServers (videoId: string) {
     for (const server of servers) {
-      await waitUntilLivePublished(server.url, server.accessToken, videoId)
+      await server.liveCommand.waitUntilPublished({ videoId })
     }
   }
 
@@ -80,12 +76,14 @@ describe('Test live constraints', function () {
     await setAccessTokensToServers(servers)
     await setDefaultVideoChannel(servers)
 
-    await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-      live: {
-        enabled: true,
-        allowReplay: true,
-        transcoding: {
-          enabled: false
+    await servers[0].configCommand.updateCustomSubConfig({
+      newConfig: {
+        live: {
+          enabled: true,
+          allowReplay: true,
+          transcoding: {
+            enabled: false
+          }
         }
       }
     })
@@ -107,7 +105,7 @@ describe('Test live constraints', function () {
     this.timeout(60000)
 
     const userVideoLiveoId = await createLiveWrapper(false)
-    await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, false)
+    await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
   })
 
   it('Should have size limit depending on user global quota if save replay is enabled', async function () {
@@ -117,7 +115,7 @@ describe('Test live constraints', function () {
     await wait(5000)
 
     const userVideoLiveoId = await createLiveWrapper(true)
-    await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true)
+    await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
 
     await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
     await waitJobs(servers)
@@ -134,7 +132,7 @@ describe('Test live constraints', function () {
     await updateQuota({ total: -1, daily: 1 })
 
     const userVideoLiveoId = await createLiveWrapper(true)
-    await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true)
+    await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
 
     await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
     await waitJobs(servers)
@@ -151,26 +149,28 @@ describe('Test live constraints', function () {
     await updateQuota({ total: 10 * 1000 * 1000, daily: -1 })
 
     const userVideoLiveoId = await createLiveWrapper(true)
-    await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, false)
+    await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
   })
 
   it('Should have max duration limit', async function () {
     this.timeout(60000)
 
-    await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-      live: {
-        enabled: true,
-        allowReplay: true,
-        maxDuration: 1,
-        transcoding: {
+    await servers[0].configCommand.updateCustomSubConfig({
+      newConfig: {
+        live: {
           enabled: true,
-          resolutions: getCustomConfigResolutions(true)
+          allowReplay: true,
+          maxDuration: 1,
+          transcoding: {
+            enabled: true,
+            resolutions: ConfigCommand.getCustomConfigResolutions(true)
+          }
         }
       }
     })
 
     const userVideoLiveoId = await createLiveWrapper(true)
-    await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true)
+    await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
 
     await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
     await waitJobs(servers)