]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/server/config.ts
Check video exists before extending its expiration
[github/Chocobozzz/PeerTube.git] / server / tests / utils / server / config.ts
index b6905757a14c7d10aa482ad527497e90aecfc1d3..b85e02ab7712a41ad370a82aa9b8f2a247ed7219 100644 (file)
@@ -1,15 +1,24 @@
-import * as request from 'supertest'
 import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../'
-import { CustomConfig } from '../../../../shared/models/config/custom-config.model'
+import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
 
 function getConfig (url: string) {
   const path = '/api/v1/config'
 
-  return request(url)
-          .get(path)
-          .set('Accept', 'application/json')
-          .expect(200)
-          .expect('Content-Type', /json/)
+  return makeGetRequest({
+    url,
+    path,
+    statusCodeExpected: 200
+  })
+}
+
+function getAbout (url: string) {
+  const path = '/api/v1/config/about'
+
+  return makeGetRequest({
+    url,
+    path,
+    statusCodeExpected: 200
+  })
 }
 
 function getCustomConfig (url: string, token: string, statusCodeExpected = 200) {
@@ -35,6 +44,74 @@ function updateCustomConfig (url: string, token: string, newCustomConfig: Custom
   })
 }
 
+function updateCustomSubConfig (url: string, token: string, newConfig: any) {
+  const updateParams: CustomConfig = {
+    instance: {
+      name: 'PeerTube updated',
+      shortDescription: 'my short description',
+      description: 'my super description',
+      terms: 'my super terms',
+      defaultClientRoute: '/videos/recently-added',
+      defaultNSFWPolicy: 'blur',
+      customizations: {
+        javascript: 'alert("coucou")',
+        css: 'body { background-color: red; }'
+      }
+    },
+    services: {
+      twitter: {
+        username: '@MySuperUsername',
+        whitelisted: true
+      }
+    },
+    cache: {
+      previews: {
+        size: 2
+      },
+      captions: {
+        size: 3
+      }
+    },
+    signup: {
+      enabled: false,
+      limit: 5,
+      requiresEmailVerification: false
+    },
+    admin: {
+      email: 'superadmin1@example.com'
+    },
+    user: {
+      videoQuota: 5242881,
+      videoQuotaDaily: 318742
+    },
+    transcoding: {
+      enabled: true,
+      threads: 1,
+      resolutions: {
+        '240p': false,
+        '360p': true,
+        '480p': true,
+        '720p': false,
+        '1080p': false
+      }
+    },
+    import: {
+      videos: {
+        http: {
+          enabled: false
+        },
+        torrent: {
+          enabled: false
+        }
+      }
+    }
+  }
+
+  Object.assign(updateParams, newConfig)
+
+  return updateCustomConfig(url, token, updateParams)
+}
+
 function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
   const path = '/api/v1/config/custom'
 
@@ -52,5 +129,7 @@ export {
   getConfig,
   getCustomConfig,
   updateCustomConfig,
-  deleteCustomConfig
+  getAbout,
+  deleteCustomConfig,
+  updateCustomSubConfig
 }