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