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