]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/utils/server/config.ts
Set sort refractoring
[github/Chocobozzz/PeerTube.git] / server / tests / utils / server / config.ts
1 import * as request from 'supertest'
2 import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../'
3 import { CustomConfig } from '../../../../shared/models/config/custom-config.model'
4
5 function getConfig (url: string) {
6 const path = '/api/v1/config'
7
8 return request(url)
9 .get(path)
10 .set('Accept', 'application/json')
11 .expect(200)
12 .expect('Content-Type', /json/)
13 }
14
15 function getCustomConfig (url: string, token: string, statusCodeExpected = 200) {
16 const path = '/api/v1/config/custom'
17
18 return makeGetRequest({
19 url,
20 token,
21 path,
22 statusCodeExpected
23 })
24 }
25
26 function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) {
27 const path = '/api/v1/config/custom'
28
29 return makePutBodyRequest({
30 url,
31 token,
32 path,
33 fields: newCustomConfig,
34 statusCodeExpected
35 })
36 }
37
38 function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
39 const path = '/api/v1/config/custom'
40
41 return makeDeleteRequest({
42 url,
43 token,
44 path,
45 statusCodeExpected
46 })
47 }
48
49 // ---------------------------------------------------------------------------
50
51 export {
52 getConfig,
53 getCustomConfig,
54 updateCustomConfig,
55 deleteCustomConfig
56 }