]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
0e1dc3e7 | 2 | |
86347717 | 3 | import { expect } from 'chai' |
c55e3d72 C |
4 | import { parallelTests } from '@shared/core-utils' |
5 | import { CustomConfig, HttpStatusCode } from '@shared/models' | |
0e1dc3e7 | 6 | import { |
7c3b7976 | 7 | cleanupTests, |
254d3579 | 8 | createSingleServer, |
a1587156 | 9 | killallServers, |
8155db66 | 10 | makeGetRequest, |
254d3579 | 11 | PeerTubeServer, |
d23dd9fb | 12 | setAccessTokensToServers |
bf54587a | 13 | } from '@shared/server-commands' |
0e1dc3e7 | 14 | |
254d3579 | 15 | function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { |
40e87e9e C |
16 | expect(data.instance.name).to.equal('PeerTube') |
17 | expect(data.instance.shortDescription).to.equal( | |
482fa503 | 18 | 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' |
40e87e9e C |
19 | ) |
20 | expect(data.instance.description).to.equal('Welcome to this PeerTube instance!') | |
ccc00cb2 | 21 | |
40e87e9e | 22 | expect(data.instance.terms).to.equal('No terms for now.') |
8ae03c37 | 23 | expect(data.instance.creationReason).to.be.empty |
ccc00cb2 C |
24 | expect(data.instance.codeOfConduct).to.be.empty |
25 | expect(data.instance.moderationInformation).to.be.empty | |
26 | expect(data.instance.administrator).to.be.empty | |
27 | expect(data.instance.maintenanceLifetime).to.be.empty | |
28 | expect(data.instance.businessModel).to.be.empty | |
be04c6fd | 29 | expect(data.instance.hardwareInformation).to.be.empty |
ccc00cb2 C |
30 | |
31 | expect(data.instance.languages).to.have.lengthOf(0) | |
32 | expect(data.instance.categories).to.have.lengthOf(0) | |
33 | ||
40e87e9e | 34 | expect(data.instance.defaultClientRoute).to.equal('/videos/trending') |
f8802489 | 35 | expect(data.instance.isNSFW).to.be.false |
40e87e9e C |
36 | expect(data.instance.defaultNSFWPolicy).to.equal('display') |
37 | expect(data.instance.customizations.css).to.be.empty | |
38 | expect(data.instance.customizations.javascript).to.be.empty | |
a4101923 | 39 | |
40e87e9e C |
40 | expect(data.services.twitter.username).to.equal('@Chocobozzz') |
41 | expect(data.services.twitter.whitelisted).to.be.false | |
a4101923 | 42 | |
0bc53e20 C |
43 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.false |
44 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.false | |
45 | ||
40e87e9e C |
46 | expect(data.cache.previews.size).to.equal(1) |
47 | expect(data.cache.captions.size).to.equal(1) | |
b3d5cb92 | 48 | expect(data.cache.torrents.size).to.equal(1) |
a4101923 | 49 | |
40e87e9e C |
50 | expect(data.signup.enabled).to.be.true |
51 | expect(data.signup.limit).to.equal(4) | |
1f256e7d | 52 | expect(data.signup.minimumAge).to.equal(16) |
b379759f | 53 | expect(data.signup.requiresApproval).to.be.false |
d9eaee39 | 54 | expect(data.signup.requiresEmailVerification).to.be.false |
a4101923 | 55 | |
48f07b4a | 56 | expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com') |
a4101923 C |
57 | expect(data.contactForm.enabled).to.be.true |
58 | ||
b302c80d | 59 | expect(data.user.history.videos.enabled).to.be.true |
40e87e9e | 60 | expect(data.user.videoQuota).to.equal(5242880) |
9ee92651 | 61 | expect(data.user.videoQuotaDaily).to.equal(-1) |
c6c0fa6c | 62 | |
754b6f5f FC |
63 | expect(data.videoChannels.maxPerUser).to.equal(20) |
64 | ||
40e87e9e | 65 | expect(data.transcoding.enabled).to.be.false |
d102de1b | 66 | expect(data.transcoding.remoteRunners.enabled).to.be.false |
14e2014a | 67 | expect(data.transcoding.allowAdditionalExtensions).to.be.false |
536598cf | 68 | expect(data.transcoding.allowAudioFiles).to.be.false |
40e87e9e | 69 | expect(data.transcoding.threads).to.equal(2) |
9129b769 | 70 | expect(data.transcoding.concurrency).to.equal(2) |
1896bca0 | 71 | expect(data.transcoding.profile).to.equal('default') |
8dd754c7 | 72 | expect(data.transcoding.resolutions['144p']).to.be.false |
40e87e9e C |
73 | expect(data.transcoding.resolutions['240p']).to.be.true |
74 | expect(data.transcoding.resolutions['360p']).to.be.true | |
75 | expect(data.transcoding.resolutions['480p']).to.be.true | |
76 | expect(data.transcoding.resolutions['720p']).to.be.true | |
77 | expect(data.transcoding.resolutions['1080p']).to.be.true | |
b7085c71 | 78 | expect(data.transcoding.resolutions['1440p']).to.be.true |
db714ab4 | 79 | expect(data.transcoding.resolutions['2160p']).to.be.true |
84cae54e | 80 | expect(data.transcoding.alwaysTranscodeOriginalResolution).to.be.true |
d7a25329 | 81 | expect(data.transcoding.webtorrent.enabled).to.be.true |
09209296 C |
82 | expect(data.transcoding.hls.enabled).to.be.true |
83 | ||
c6c0fa6c | 84 | expect(data.live.enabled).to.be.false |
c655c9ef | 85 | expect(data.live.allowReplay).to.be.false |
f443a746 | 86 | expect(data.live.latencySetting.enabled).to.be.true |
c9bc850e | 87 | expect(data.live.maxDuration).to.equal(-1) |
a056ca48 C |
88 | expect(data.live.maxInstanceLives).to.equal(20) |
89 | expect(data.live.maxUserLives).to.equal(3) | |
c6c0fa6c | 90 | expect(data.live.transcoding.enabled).to.be.false |
d102de1b | 91 | expect(data.live.transcoding.remoteRunners.enabled).to.be.false |
c6c0fa6c | 92 | expect(data.live.transcoding.threads).to.equal(2) |
1896bca0 | 93 | expect(data.live.transcoding.profile).to.equal('default') |
8dd754c7 | 94 | expect(data.live.transcoding.resolutions['144p']).to.be.false |
c6c0fa6c C |
95 | expect(data.live.transcoding.resolutions['240p']).to.be.false |
96 | expect(data.live.transcoding.resolutions['360p']).to.be.false | |
97 | expect(data.live.transcoding.resolutions['480p']).to.be.false | |
98 | expect(data.live.transcoding.resolutions['720p']).to.be.false | |
99 | expect(data.live.transcoding.resolutions['1080p']).to.be.false | |
b7085c71 | 100 | expect(data.live.transcoding.resolutions['1440p']).to.be.false |
c6c0fa6c | 101 | expect(data.live.transcoding.resolutions['2160p']).to.be.false |
84cae54e | 102 | expect(data.live.transcoding.alwaysTranscodeOriginalResolution).to.be.true |
c6c0fa6c | 103 | |
92e66e04 | 104 | expect(data.videoStudio.enabled).to.be.false |
5e47f6ab | 105 | expect(data.videoStudio.remoteRunners.enabled).to.be.false |
c729caf6 | 106 | |
9129b769 | 107 | expect(data.import.videos.concurrency).to.equal(2) |
5d08a6a7 | 108 | expect(data.import.videos.http.enabled).to.be.true |
a84b8fa5 | 109 | expect(data.import.videos.torrent.enabled).to.be.true |
7ccddd7b | 110 | expect(data.autoBlacklist.videos.ofUsers.enabled).to.be.false |
5b9c965d C |
111 | |
112 | expect(data.followers.instance.enabled).to.be.true | |
14893eb7 | 113 | expect(data.followers.instance.manualApproval).to.be.false |
8424c402 C |
114 | |
115 | expect(data.followings.instance.autoFollowBack.enabled).to.be.false | |
116 | expect(data.followings.instance.autoFollowIndex.enabled).to.be.false | |
c9215a1b | 117 | expect(data.followings.instance.autoFollowIndex.indexUrl).to.equal('') |
72c33e71 C |
118 | |
119 | expect(data.broadcastMessage.enabled).to.be.false | |
120 | expect(data.broadcastMessage.level).to.equal('info') | |
121 | expect(data.broadcastMessage.message).to.equal('') | |
122 | expect(data.broadcastMessage.dismissable).to.be.false | |
40e87e9e C |
123 | } |
124 | ||
125 | function checkUpdatedConfig (data: CustomConfig) { | |
126 | expect(data.instance.name).to.equal('PeerTube updated') | |
127 | expect(data.instance.shortDescription).to.equal('my short description') | |
128 | expect(data.instance.description).to.equal('my super description') | |
ccc00cb2 | 129 | |
40e87e9e | 130 | expect(data.instance.terms).to.equal('my super terms') |
8ae03c37 | 131 | expect(data.instance.creationReason).to.equal('my super creation reason') |
ccc00cb2 C |
132 | expect(data.instance.codeOfConduct).to.equal('my super coc') |
133 | expect(data.instance.moderationInformation).to.equal('my super moderation information') | |
134 | expect(data.instance.administrator).to.equal('Kuja') | |
135 | expect(data.instance.maintenanceLifetime).to.equal('forever') | |
136 | expect(data.instance.businessModel).to.equal('my super business model') | |
be04c6fd | 137 | expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM') |
ccc00cb2 C |
138 | |
139 | expect(data.instance.languages).to.deep.equal([ 'en', 'es' ]) | |
140 | expect(data.instance.categories).to.deep.equal([ 1, 2 ]) | |
141 | ||
40e87e9e | 142 | expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added') |
f8802489 | 143 | expect(data.instance.isNSFW).to.be.true |
40e87e9e C |
144 | expect(data.instance.defaultNSFWPolicy).to.equal('blur') |
145 | expect(data.instance.customizations.javascript).to.equal('alert("coucou")') | |
146 | expect(data.instance.customizations.css).to.equal('body { background-color: red; }') | |
a4101923 | 147 | |
40e87e9e C |
148 | expect(data.services.twitter.username).to.equal('@Kuja') |
149 | expect(data.services.twitter.whitelisted).to.be.true | |
a4101923 | 150 | |
0bc53e20 C |
151 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.true |
152 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.true | |
153 | ||
40e87e9e C |
154 | expect(data.cache.previews.size).to.equal(2) |
155 | expect(data.cache.captions.size).to.equal(3) | |
b3d5cb92 | 156 | expect(data.cache.torrents.size).to.equal(4) |
a4101923 | 157 | |
40e87e9e C |
158 | expect(data.signup.enabled).to.be.false |
159 | expect(data.signup.limit).to.equal(5) | |
b379759f | 160 | expect(data.signup.requiresApproval).to.be.false |
576ad67a | 161 | expect(data.signup.requiresEmailVerification).to.be.false |
1f256e7d | 162 | expect(data.signup.minimumAge).to.equal(10) |
a4101923 | 163 | |
48f07b4a C |
164 | // We override admin email in parallel tests, so skip this exception |
165 | if (parallelTests() === false) { | |
166 | expect(data.admin.email).to.equal('superadmin1@example.com') | |
167 | } | |
168 | ||
a4101923 C |
169 | expect(data.contactForm.enabled).to.be.false |
170 | ||
b302c80d | 171 | expect(data.user.history.videos.enabled).to.be.false |
40e87e9e | 172 | expect(data.user.videoQuota).to.equal(5242881) |
bee0abff | 173 | expect(data.user.videoQuotaDaily).to.equal(318742) |
a4101923 | 174 | |
754b6f5f FC |
175 | expect(data.videoChannels.maxPerUser).to.equal(24) |
176 | ||
40e87e9e | 177 | expect(data.transcoding.enabled).to.be.true |
d102de1b | 178 | expect(data.transcoding.remoteRunners.enabled).to.be.true |
40e87e9e | 179 | expect(data.transcoding.threads).to.equal(1) |
9129b769 | 180 | expect(data.transcoding.concurrency).to.equal(3) |
14e2014a | 181 | expect(data.transcoding.allowAdditionalExtensions).to.be.true |
536598cf | 182 | expect(data.transcoding.allowAudioFiles).to.be.true |
1896bca0 | 183 | expect(data.transcoding.profile).to.equal('vod_profile') |
8dd754c7 | 184 | expect(data.transcoding.resolutions['144p']).to.be.false |
40e87e9e C |
185 | expect(data.transcoding.resolutions['240p']).to.be.false |
186 | expect(data.transcoding.resolutions['360p']).to.be.true | |
187 | expect(data.transcoding.resolutions['480p']).to.be.true | |
188 | expect(data.transcoding.resolutions['720p']).to.be.false | |
189 | expect(data.transcoding.resolutions['1080p']).to.be.false | |
db714ab4 | 190 | expect(data.transcoding.resolutions['2160p']).to.be.false |
84cae54e | 191 | expect(data.transcoding.alwaysTranscodeOriginalResolution).to.be.false |
09209296 | 192 | expect(data.transcoding.hls.enabled).to.be.false |
d7a25329 | 193 | expect(data.transcoding.webtorrent.enabled).to.be.true |
a4101923 | 194 | |
c6c0fa6c | 195 | expect(data.live.enabled).to.be.true |
c655c9ef | 196 | expect(data.live.allowReplay).to.be.true |
f443a746 | 197 | expect(data.live.latencySetting.enabled).to.be.false |
fb719404 | 198 | expect(data.live.maxDuration).to.equal(5000) |
a056ca48 C |
199 | expect(data.live.maxInstanceLives).to.equal(-1) |
200 | expect(data.live.maxUserLives).to.equal(10) | |
c6c0fa6c | 201 | expect(data.live.transcoding.enabled).to.be.true |
d102de1b | 202 | expect(data.live.transcoding.remoteRunners.enabled).to.be.true |
c6c0fa6c | 203 | expect(data.live.transcoding.threads).to.equal(4) |
1896bca0 | 204 | expect(data.live.transcoding.profile).to.equal('live_profile') |
8dd754c7 | 205 | expect(data.live.transcoding.resolutions['144p']).to.be.true |
c6c0fa6c C |
206 | expect(data.live.transcoding.resolutions['240p']).to.be.true |
207 | expect(data.live.transcoding.resolutions['360p']).to.be.true | |
208 | expect(data.live.transcoding.resolutions['480p']).to.be.true | |
209 | expect(data.live.transcoding.resolutions['720p']).to.be.true | |
210 | expect(data.live.transcoding.resolutions['1080p']).to.be.true | |
211 | expect(data.live.transcoding.resolutions['2160p']).to.be.true | |
84cae54e | 212 | expect(data.live.transcoding.alwaysTranscodeOriginalResolution).to.be.false |
c6c0fa6c | 213 | |
92e66e04 | 214 | expect(data.videoStudio.enabled).to.be.true |
5e47f6ab | 215 | expect(data.videoStudio.remoteRunners.enabled).to.be.true |
c729caf6 | 216 | |
9129b769 | 217 | expect(data.import.videos.concurrency).to.equal(4) |
5d08a6a7 | 218 | expect(data.import.videos.http.enabled).to.be.false |
a84b8fa5 | 219 | expect(data.import.videos.torrent.enabled).to.be.false |
7ccddd7b | 220 | expect(data.autoBlacklist.videos.ofUsers.enabled).to.be.true |
5b9c965d C |
221 | |
222 | expect(data.followers.instance.enabled).to.be.false | |
14893eb7 | 223 | expect(data.followers.instance.manualApproval).to.be.true |
8424c402 C |
224 | |
225 | expect(data.followings.instance.autoFollowBack.enabled).to.be.true | |
226 | expect(data.followings.instance.autoFollowIndex.enabled).to.be.true | |
227 | expect(data.followings.instance.autoFollowIndex.indexUrl).to.equal('https://updated.example.com') | |
72c33e71 C |
228 | |
229 | expect(data.broadcastMessage.enabled).to.be.true | |
230 | expect(data.broadcastMessage.level).to.equal('error') | |
231 | expect(data.broadcastMessage.message).to.equal('super bad message') | |
232 | expect(data.broadcastMessage.dismissable).to.be.true | |
40e87e9e C |
233 | } |
234 | ||
8d8a037e JB |
235 | const newCustomConfig: CustomConfig = { |
236 | instance: { | |
237 | name: 'PeerTube updated', | |
238 | shortDescription: 'my short description', | |
239 | description: 'my super description', | |
240 | terms: 'my super terms', | |
241 | codeOfConduct: 'my super coc', | |
242 | ||
243 | creationReason: 'my super creation reason', | |
244 | moderationInformation: 'my super moderation information', | |
245 | administrator: 'Kuja', | |
246 | maintenanceLifetime: 'forever', | |
247 | businessModel: 'my super business model', | |
248 | hardwareInformation: '2vCore 3GB RAM', | |
249 | ||
250 | languages: [ 'en', 'es' ], | |
251 | categories: [ 1, 2 ], | |
252 | ||
253 | isNSFW: true, | |
254 | defaultNSFWPolicy: 'blur' as 'blur', | |
255 | ||
256 | defaultClientRoute: '/videos/recently-added', | |
257 | ||
258 | customizations: { | |
259 | javascript: 'alert("coucou")', | |
260 | css: 'body { background-color: red; }' | |
261 | } | |
262 | }, | |
263 | theme: { | |
264 | default: 'default' | |
265 | }, | |
266 | services: { | |
267 | twitter: { | |
268 | username: '@Kuja', | |
269 | whitelisted: true | |
270 | } | |
271 | }, | |
0bc53e20 C |
272 | client: { |
273 | videos: { | |
274 | miniature: { | |
275 | preferAuthorDisplayName: true | |
276 | } | |
277 | }, | |
278 | menu: { | |
279 | login: { | |
280 | redirectOnSingleExternalAuth: true | |
281 | } | |
282 | } | |
283 | }, | |
8d8a037e JB |
284 | cache: { |
285 | previews: { | |
286 | size: 2 | |
287 | }, | |
288 | captions: { | |
289 | size: 3 | |
290 | }, | |
291 | torrents: { | |
292 | size: 4 | |
293 | } | |
294 | }, | |
295 | signup: { | |
296 | enabled: false, | |
297 | limit: 5, | |
b379759f | 298 | requiresApproval: false, |
8d8a037e JB |
299 | requiresEmailVerification: false, |
300 | minimumAge: 10 | |
301 | }, | |
302 | admin: { | |
303 | email: 'superadmin1@example.com' | |
304 | }, | |
305 | contactForm: { | |
306 | enabled: false | |
307 | }, | |
308 | user: { | |
b302c80d W |
309 | history: { |
310 | videos: { | |
311 | enabled: false | |
312 | } | |
313 | }, | |
8d8a037e JB |
314 | videoQuota: 5242881, |
315 | videoQuotaDaily: 318742 | |
316 | }, | |
754b6f5f FC |
317 | videoChannels: { |
318 | maxPerUser: 24 | |
319 | }, | |
8d8a037e JB |
320 | transcoding: { |
321 | enabled: true, | |
d102de1b C |
322 | remoteRunners: { |
323 | enabled: true | |
324 | }, | |
8d8a037e JB |
325 | allowAdditionalExtensions: true, |
326 | allowAudioFiles: true, | |
327 | threads: 1, | |
328 | concurrency: 3, | |
329 | profile: 'vod_profile', | |
330 | resolutions: { | |
331 | '0p': false, | |
8dd754c7 | 332 | '144p': false, |
8d8a037e JB |
333 | '240p': false, |
334 | '360p': true, | |
335 | '480p': true, | |
336 | '720p': false, | |
337 | '1080p': false, | |
338 | '1440p': false, | |
339 | '2160p': false | |
340 | }, | |
84cae54e | 341 | alwaysTranscodeOriginalResolution: false, |
8d8a037e JB |
342 | webtorrent: { |
343 | enabled: true | |
344 | }, | |
345 | hls: { | |
346 | enabled: false | |
347 | } | |
348 | }, | |
349 | live: { | |
350 | enabled: true, | |
351 | allowReplay: true, | |
f443a746 C |
352 | latencySetting: { |
353 | enabled: false | |
354 | }, | |
8d8a037e JB |
355 | maxDuration: 5000, |
356 | maxInstanceLives: -1, | |
357 | maxUserLives: 10, | |
358 | transcoding: { | |
359 | enabled: true, | |
d102de1b C |
360 | remoteRunners: { |
361 | enabled: true | |
362 | }, | |
8d8a037e JB |
363 | threads: 4, |
364 | profile: 'live_profile', | |
365 | resolutions: { | |
8dd754c7 | 366 | '144p': true, |
8d8a037e JB |
367 | '240p': true, |
368 | '360p': true, | |
369 | '480p': true, | |
370 | '720p': true, | |
371 | '1080p': true, | |
372 | '1440p': true, | |
373 | '2160p': true | |
84cae54e C |
374 | }, |
375 | alwaysTranscodeOriginalResolution: false | |
8d8a037e JB |
376 | } |
377 | }, | |
92e66e04 | 378 | videoStudio: { |
5e47f6ab C |
379 | enabled: true, |
380 | remoteRunners: { | |
381 | enabled: true | |
382 | } | |
c729caf6 | 383 | }, |
8d8a037e JB |
384 | import: { |
385 | videos: { | |
386 | concurrency: 4, | |
387 | http: { | |
388 | enabled: false | |
389 | }, | |
390 | torrent: { | |
391 | enabled: false | |
392 | } | |
2a491182 F |
393 | }, |
394 | videoChannelSynchronization: { | |
395 | enabled: false, | |
396 | maxPerUser: 10 | |
8d8a037e JB |
397 | } |
398 | }, | |
399 | trending: { | |
400 | videos: { | |
401 | algorithms: { | |
010382b6 | 402 | enabled: [ 'hot', 'most-viewed', 'most-liked' ], |
8d8a037e JB |
403 | default: 'hot' |
404 | } | |
405 | } | |
406 | }, | |
407 | autoBlacklist: { | |
408 | videos: { | |
409 | ofUsers: { | |
410 | enabled: true | |
411 | } | |
412 | } | |
413 | }, | |
414 | followers: { | |
415 | instance: { | |
416 | enabled: false, | |
417 | manualApproval: true | |
418 | } | |
419 | }, | |
420 | followings: { | |
421 | instance: { | |
422 | autoFollowBack: { | |
423 | enabled: true | |
424 | }, | |
425 | autoFollowIndex: { | |
426 | enabled: true, | |
427 | indexUrl: 'https://updated.example.com' | |
428 | } | |
429 | } | |
430 | }, | |
431 | broadcastMessage: { | |
432 | enabled: true, | |
433 | level: 'error', | |
434 | message: 'super bad message', | |
435 | dismissable: true | |
436 | }, | |
437 | search: { | |
438 | remoteUri: { | |
439 | anonymous: true, | |
440 | users: true | |
441 | }, | |
442 | searchIndex: { | |
443 | enabled: true, | |
444 | url: 'https://search.joinpeertube.org', | |
445 | disableLocalSearch: true, | |
446 | isDefaultSearch: true | |
447 | } | |
448 | } | |
449 | } | |
450 | ||
451 | describe('Test static config', function () { | |
452 | let server: PeerTubeServer = null | |
453 | ||
454 | before(async function () { | |
455 | this.timeout(30000) | |
456 | ||
cf0c8ee5 | 457 | server = await createSingleServer(1, { webadmin: { configuration: { edition: { allowed: false } } } }) |
8d8a037e JB |
458 | await setAccessTokensToServers([ server ]) |
459 | }) | |
460 | ||
461 | it('Should tell the client that edits are not allowed', async function () { | |
462 | const data = await server.config.getConfig() | |
463 | ||
cf0c8ee5 | 464 | expect(data.webadmin.configuration.edition.allowed).to.be.false |
8d8a037e JB |
465 | }) |
466 | ||
467 | it('Should error when client tries to update', async function () { | |
468 | await server.config.updateCustomConfig({ newCustomConfig, expectedStatus: 405 }) | |
469 | }) | |
f87d82b9 C |
470 | |
471 | after(async function () { | |
472 | await cleanupTests([ server ]) | |
473 | }) | |
8d8a037e JB |
474 | }) |
475 | ||
0e1dc3e7 | 476 | describe('Test config', function () { |
254d3579 | 477 | let server: PeerTubeServer = null |
0e1dc3e7 C |
478 | |
479 | before(async function () { | |
e212f887 | 480 | this.timeout(30000) |
48f07b4a | 481 | |
254d3579 | 482 | server = await createSingleServer(1) |
fd206f0b | 483 | await setAccessTokensToServers([ server ]) |
0e1dc3e7 C |
484 | }) |
485 | ||
486 | it('Should have a correct config on a server with registration enabled', async function () { | |
89d241a7 | 487 | const data = await server.config.getConfig() |
0e1dc3e7 C |
488 | |
489 | expect(data.signup.allowed).to.be.true | |
490 | }) | |
491 | ||
492 | it('Should have a correct config on a server with registration enabled and a users limit', async function () { | |
652b3056 C |
493 | this.timeout(5000) |
494 | ||
47e0652b | 495 | await Promise.all([ |
b379759f C |
496 | server.registrations.register({ username: 'user1' }), |
497 | server.registrations.register({ username: 'user2' }), | |
498 | server.registrations.register({ username: 'user3' }) | |
47e0652b | 499 | ]) |
0e1dc3e7 | 500 | |
89d241a7 | 501 | const data = await server.config.getConfig() |
0e1dc3e7 C |
502 | |
503 | expect(data.signup.allowed).to.be.false | |
504 | }) | |
505 | ||
14e2014a | 506 | it('Should have the correct video allowed extensions', async function () { |
89d241a7 | 507 | const data = await server.config.getConfig() |
14e2014a C |
508 | |
509 | expect(data.video.file.extensions).to.have.lengthOf(3) | |
510 | expect(data.video.file.extensions).to.contain('.mp4') | |
511 | expect(data.video.file.extensions).to.contain('.webm') | |
512 | expect(data.video.file.extensions).to.contain('.ogv') | |
a4101923 | 513 | |
89d241a7 C |
514 | await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 }) |
515 | await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 }) | |
b345a804 | 516 | |
a4101923 | 517 | expect(data.contactForm.enabled).to.be.true |
14e2014a C |
518 | }) |
519 | ||
fd206f0b | 520 | it('Should get the customized configuration', async function () { |
89d241a7 | 521 | const data = await server.config.getCustomConfig() |
fd206f0b | 522 | |
48f07b4a | 523 | checkInitialConfig(server, data) |
fd206f0b C |
524 | }) |
525 | ||
526 | it('Should update the customized configuration', async function () { | |
89d241a7 | 527 | await server.config.updateCustomConfig({ newCustomConfig }) |
fd206f0b | 528 | |
89d241a7 | 529 | const data = await server.config.getCustomConfig() |
40e87e9e | 530 | checkUpdatedConfig(data) |
fd206f0b C |
531 | }) |
532 | ||
14e2014a | 533 | it('Should have the correct updated video allowed extensions', async function () { |
0cbcaccb | 534 | this.timeout(30000) |
30bc55c8 | 535 | |
89d241a7 | 536 | const data = await server.config.getConfig() |
14e2014a | 537 | |
30bc55c8 | 538 | expect(data.video.file.extensions).to.have.length.above(4) |
14e2014a C |
539 | expect(data.video.file.extensions).to.contain('.mp4') |
540 | expect(data.video.file.extensions).to.contain('.webm') | |
541 | expect(data.video.file.extensions).to.contain('.ogv') | |
542 | expect(data.video.file.extensions).to.contain('.flv') | |
fccbbc1a | 543 | expect(data.video.file.extensions).to.contain('.wmv') |
14e2014a | 544 | expect(data.video.file.extensions).to.contain('.mkv') |
b345a804 C |
545 | expect(data.video.file.extensions).to.contain('.mp3') |
546 | expect(data.video.file.extensions).to.contain('.ogg') | |
547 | expect(data.video.file.extensions).to.contain('.flac') | |
548 | ||
89d241a7 C |
549 | await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.OK_200 }) |
550 | await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.OK_200 }) | |
14e2014a C |
551 | }) |
552 | ||
fd206f0b | 553 | it('Should have the configuration updated after a restart', async function () { |
61e9908c | 554 | this.timeout(30000) |
23e27dd5 | 555 | |
9293139f | 556 | await killallServers([ server ]) |
fd206f0b | 557 | |
254d3579 | 558 | await server.run() |
fd206f0b | 559 | |
89d241a7 | 560 | const data = await server.config.getCustomConfig() |
fd206f0b | 561 | |
40e87e9e | 562 | checkUpdatedConfig(data) |
fd206f0b C |
563 | }) |
564 | ||
36f9424f | 565 | it('Should fetch the about information', async function () { |
89d241a7 | 566 | const data = await server.config.getAbout() |
36f9424f C |
567 | |
568 | expect(data.instance.name).to.equal('PeerTube updated') | |
2e3a0215 | 569 | expect(data.instance.shortDescription).to.equal('my short description') |
36f9424f C |
570 | expect(data.instance.description).to.equal('my super description') |
571 | expect(data.instance.terms).to.equal('my super terms') | |
be04c6fd C |
572 | expect(data.instance.codeOfConduct).to.equal('my super coc') |
573 | ||
574 | expect(data.instance.creationReason).to.equal('my super creation reason') | |
575 | expect(data.instance.moderationInformation).to.equal('my super moderation information') | |
576 | expect(data.instance.administrator).to.equal('Kuja') | |
577 | expect(data.instance.maintenanceLifetime).to.equal('forever') | |
578 | expect(data.instance.businessModel).to.equal('my super business model') | |
579 | expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM') | |
580 | ||
581 | expect(data.instance.languages).to.deep.equal([ 'en', 'es' ]) | |
582 | expect(data.instance.categories).to.deep.equal([ 1, 2 ]) | |
36f9424f C |
583 | }) |
584 | ||
fd206f0b | 585 | it('Should remove the custom configuration', async function () { |
89d241a7 | 586 | await server.config.deleteCustomConfig() |
fd206f0b | 587 | |
89d241a7 | 588 | const data = await server.config.getCustomConfig() |
48f07b4a | 589 | checkInitialConfig(server, data) |
fd206f0b C |
590 | }) |
591 | ||
47653481 | 592 | it('Should enable/disable security headers', async function () { |
8155db66 C |
593 | this.timeout(25000) |
594 | ||
595 | { | |
596 | const res = await makeGetRequest({ | |
597 | url: server.url, | |
598 | path: '/api/v1/config', | |
c0e8b12e | 599 | expectedStatus: 200 |
8155db66 C |
600 | }) |
601 | ||
602 | expect(res.headers['x-frame-options']).to.exist | |
47653481 | 603 | expect(res.headers['x-powered-by']).to.equal('PeerTube') |
8155db66 C |
604 | } |
605 | ||
9293139f | 606 | await killallServers([ server ]) |
8155db66 C |
607 | |
608 | const config = { | |
609 | security: { | |
47653481 C |
610 | frameguard: { enabled: false }, |
611 | powered_by_header: { enabled: false } | |
8155db66 C |
612 | } |
613 | } | |
254d3579 | 614 | await server.run(config) |
8155db66 C |
615 | |
616 | { | |
617 | const res = await makeGetRequest({ | |
618 | url: server.url, | |
619 | path: '/api/v1/config', | |
c0e8b12e | 620 | expectedStatus: 200 |
8155db66 C |
621 | }) |
622 | ||
623 | expect(res.headers['x-frame-options']).to.not.exist | |
47653481 | 624 | expect(res.headers['x-powered-by']).to.not.exist |
8155db66 C |
625 | } |
626 | }) | |
627 | ||
7c3b7976 C |
628 | after(async function () { |
629 | await cleanupTests([ server ]) | |
0e1dc3e7 C |
630 | }) |
631 | }) |