]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/utils/server/config.ts
Implement daily upload limit (#956)
[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 videoQuotaDaily: 318742
85 },
86 transcoding: {
87 enabled: true,
88 threads: 1,
89 resolutions: {
90 '240p': false,
91 '360p': true,
92 '480p': true,
93 '720p': false,
94 '1080p': false
95 }
96 },
97 import: {
98 videos: {
99 http: {
100 enabled: false
101 },
102 torrent: {
103 enabled: false
104 }
105 }
106 }
107 }
108
109 Object.assign(updateParams, newConfig)
110
111 return updateCustomConfig(url, token, updateParams)
112 }
113
114 function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
115 const path = '/api/v1/config/custom'
116
117 return makeDeleteRequest({
118 url,
119 token,
120 path,
121 statusCodeExpected
122 })
123 }
124
125 // ---------------------------------------------------------------------------
126
127 export {
128 getConfig,
129 getCustomConfig,
130 updateCustomConfig,
131 getAbout,
132 deleteCustomConfig,
133 updateCustomSubConfig
134 }