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