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