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