]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/video-imports.ts
Fix fps federation
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / video-imports.ts
index 7f58efb744ff1965cfba8d46d1916b62ba113cde..0ead34a47148f556086d9fec689776188c617a68 100644 (file)
@@ -16,9 +16,11 @@ import {
   runServer,
   ServerInfo,
   setAccessTokensToServers,
+  updateCustomSubConfig,
   userLogin
 } from '../../utils'
 import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
+import { getYoutubeVideoUrl } from '../../utils/videos/video-imports'
 
 describe('Test video imports API validator', function () {
   const path = '/api/v1/videos/imports'
@@ -77,7 +79,7 @@ describe('Test video imports API validator', function () {
 
     before(function () {
       baseCorrectParams = {
-        targetUrl: 'https://youtu.be/msX3jv1XdvM',
+        targetUrl: getYoutubeVideoUrl(),
         name: 'my super name',
         category: 5,
         licence: 1,
@@ -98,6 +100,17 @@ describe('Test video imports API validator', function () {
       await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
     })
 
+    it('Should fail without a target url', async function () {
+      const fields = omit(baseCorrectParams, 'targetUrl')
+      await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 400 })
+    })
+
+    it('Should fail with a bad target url', async function () {
+      const fields = immutableAssign(baseCorrectParams, { targetUrl: 'htt://hello' })
+
+      await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+    })
+
     it('Should fail with a long name', async function () {
       const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
 
@@ -219,20 +232,36 @@ describe('Test video imports API validator', function () {
     it('Should succeed with the correct parameters', async function () {
       this.timeout(10000)
 
-      const fields = baseCorrectParams
-
       {
         await makePostBodyRequest({
           url: server.url,
           path,
           token: server.accessToken,
-          fields,
+          fields: baseCorrectParams,
           statusCodeExpected: 200
         })
       }
     })
 
-    it('Should forbid importing')
+    it('Should forbid to import videos', async function () {
+      await updateCustomSubConfig(server.url, server.accessToken, {
+        import: {
+          videos: {
+            http: {
+              enabled: false
+            }
+          }
+        }
+      })
+
+      await makePostBodyRequest({
+        url: server.url,
+        path,
+        token: server.accessToken,
+        fields: baseCorrectParams,
+        statusCodeExpected: 409
+      })
+    })
   })
 
   after(async function () {