]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/utils/server/config.ts
replace fs by fs-extra to prevent EMFILE error
[github/Chocobozzz/PeerTube.git] / server / tests / utils / server / config.ts
1 import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../'
2 import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
3
4 function getConfig (url: string) {
5 const path = '/api/v1/config'
6
7 return makeGetRequest({
8 url,
9 path,
10 statusCodeExpected: 200
11 })
12 }
13
14 function getAbout (url: string) {
15 const path = '/api/v1/config/about'
16
17 return makeGetRequest({
18 url,
19 path,
20 statusCodeExpected: 200
21 })
22 }
23
24 function getCustomConfig (url: string, token: string, statusCodeExpected = 200) {
25 const path = '/api/v1/config/custom'
26
27 return makeGetRequest({
28 url,
29 token,
30 path,
31 statusCodeExpected
32 })
33 }
34
35 function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) {
36 const path = '/api/v1/config/custom'
37
38 return makePutBodyRequest({
39 url,
40 token,
41 path,
42 fields: newCustomConfig,
43 statusCodeExpected
44 })
45 }
46
47 function updateCustomSubConfig (url: string, token: string, newConfig: any) {
48 const updateParams: CustomConfig = {
49 instance: {
50 name: 'PeerTube updated',
51 shortDescription: 'my short description',
52 description: 'my super description',
53 terms: 'my super terms',
54 defaultClientRoute: '/videos/recently-added',
55 defaultNSFWPolicy: 'blur',
56 customizations: {
57 javascript: 'alert("coucou")',
58 css: 'body { background-color: red; }'
59 }
60 },
61 services: {
62 twitter: {
63 username: '@MySuperUsername',
64 whitelisted: true
65 }
66 },
67 cache: {
68 previews: {
69 size: 2
70 },
71 captions: {
72 size: 3
73 }
74 },
75 signup: {
76 enabled: false,
77 limit: 5
78 },
79 admin: {
80 email: 'superadmin1@example.com'
81 },
82 user: {
83 videoQuota: 5242881
84 },
85 transcoding: {
86 enabled: true,
87 threads: 1,
88 resolutions: {
89 '240p': false,
90 '360p': true,
91 '480p': true,
92 '720p': false,
93 '1080p': false
94 }
95 },
96 import: {
97 videos: {
98 http: {
99 enabled: false
100 },
101 torrent: {
102 enabled: false
103 }
104 }
105 }
106 }
107
108 Object.assign(updateParams, newConfig)
109
110 return updateCustomConfig(url, token, updateParams)
111 }
112
113 function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
114 const path = '/api/v1/config/custom'
115
116 return makeDeleteRequest({
117 url,
118 token,
119 path,
120 statusCodeExpected
121 })
122 }
123
124 // ---------------------------------------------------------------------------
125
126 export {
127 getConfig,
128 getCustomConfig,
129 updateCustomConfig,
130 getAbout,
131 deleteCustomConfig,
132 updateCustomSubConfig
133 }