import 'mocha'
import * as chai from 'chai'
-import { About } from '../../../../shared/models/server/about.model'
-import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
+import { HttpStatusCode } from '@shared/core-utils'
import {
cleanupTests,
- deleteCustomConfig,
flushAndRunServer,
- getAbout,
- getConfig,
- getCustomConfig,
killallServers,
+ makeGetRequest,
parallelTests,
registerUser,
reRunServer,
ServerInfo,
setAccessTokensToServers,
- updateCustomConfig,
uploadVideo
-} from '../../../../shared/extra-utils'
-import { ServerConfig } from '../../../../shared/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+} from '@shared/extra-utils'
+import { CustomConfig } from '@shared/models'
const expect = chai.expect
expect(data.signup.enabled).to.be.true
expect(data.signup.limit).to.equal(4)
+ expect(data.signup.minimumAge).to.equal(16)
expect(data.signup.requiresEmailVerification).to.be.false
expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(data.signup.enabled).to.be.false
expect(data.signup.limit).to.equal(5)
expect(data.signup.requiresEmailVerification).to.be.false
+ expect(data.signup.minimumAge).to.equal(10)
// We override admin email in parallel tests, so skip this exception
if (parallelTests() === false) {
}
describe('Test config', function () {
- let server = null
+ let server: ServerInfo = null
before(async function () {
this.timeout(30000)
})
it('Should have a correct config on a server with registration enabled', async function () {
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.signup.allowed).to.be.true
})
registerUser(server.url, 'user3', 'super password')
])
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.signup.allowed).to.be.false
})
it('Should have the correct video allowed extensions', async function () {
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.video.file.extensions).to.have.lengthOf(3)
expect(data.video.file.extensions).to.contain('.mp4')
})
it('Should get the customized configuration', async function () {
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body as CustomConfig
+ const data = await server.configCommand.getCustomConfig()
checkInitialConfig(server, data)
})
signup: {
enabled: false,
limit: 5,
- requiresEmailVerification: false
+ requiresEmailVerification: false,
+ minimumAge: 10
},
admin: {
email: 'superadmin1@example.com'
}
}
}
- await updateCustomConfig(server.url, server.accessToken, newCustomConfig)
-
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body
+ await server.configCommand.updateCustomConfig({ newCustomConfig })
+ const data = await server.configCommand.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should have the correct updated video allowed extensions', async function () {
this.timeout(10000)
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.video.file.extensions).to.have.length.above(4)
expect(data.video.file.extensions).to.contain('.mp4')
await reRunServer(server)
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body
+ const data = await server.configCommand.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should fetch the about information', async function () {
- const res = await getAbout(server.url)
- const data: About = res.body
+ const data = await server.configCommand.getAbout()
expect(data.instance.name).to.equal('PeerTube updated')
expect(data.instance.shortDescription).to.equal('my short description')
it('Should remove the custom configuration', async function () {
this.timeout(10000)
- await deleteCustomConfig(server.url, server.accessToken)
-
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body
+ await server.configCommand.deleteCustomConfig()
+ const data = await server.configCommand.getCustomConfig()
checkInitialConfig(server, data)
})
+ it('Should enable frameguard', async function () {
+ this.timeout(25000)
+
+ {
+ const res = await makeGetRequest({
+ url: server.url,
+ path: '/api/v1/config',
+ statusCodeExpected: 200
+ })
+
+ expect(res.headers['x-frame-options']).to.exist
+ }
+
+ killallServers([ server ])
+
+ const config = {
+ security: {
+ frameguard: { enabled: false }
+ }
+ }
+ server = await reRunServer(server, config)
+
+ {
+ const res = await makeGetRequest({
+ url: server.url,
+ path: '/api/v1/config',
+ statusCodeExpected: 200
+ })
+
+ expect(res.headers['x-frame-options']).to.not.exist
+ }
+ })
+
after(async function () {
await cleanupTests([ server ])
})