]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/server/config.ts
Begin import script with youtube-dl
[github/Chocobozzz/PeerTube.git] / server / tests / utils / server / config.ts
index d09c19c6019f726570de9b44ff7fc20641b47d32..e5411117a655d6f2c365b7c96fed67146cb3e04c 100644 (file)
@@ -1,17 +1,66 @@
-import * as request from 'supertest'
+import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../'
+import { CustomConfig } from '../../../../shared/models/config/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) {
+  const path = '/api/v1/config/custom'
+
+  return makeGetRequest({
+    url,
+    token,
+    path,
+    statusCodeExpected
+  })
+}
+
+function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) {
+  const path = '/api/v1/config/custom'
+
+  return makePutBodyRequest({
+    url,
+    token,
+    path,
+    fields: newCustomConfig,
+    statusCodeExpected
+  })
+}
+
+function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
+  const path = '/api/v1/config/custom'
+
+  return makeDeleteRequest({
+    url,
+    token,
+    path,
+    statusCodeExpected
+  })
 }
 
 // ---------------------------------------------------------------------------
 
 export {
-  getConfig
+  getConfig,
+  getCustomConfig,
+  updateCustomConfig,
+  getAbout,
+  deleteCustomConfig
 }