import { omit } from 'lodash'
import 'mocha'
-import { CustomConfig } from '../../../../shared/models/config/custom-config.model'
+import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
import {
createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, runServer, ServerInfo,
- setAccessTokensToServers, userLogin
-} from '../../utils'
+ setAccessTokensToServers, userLogin, immutableAssign
+} from '../../../../shared/utils'
describe('Test config API validators', function () {
const path = '/api/v1/config/custom'
const updateParams: CustomConfig = {
instance: {
name: 'PeerTube updated',
+ shortDescription: 'my short description',
description: 'my super description',
terms: 'my super terms',
+ defaultClientRoute: '/videos/recently-added',
+ defaultNSFWPolicy: 'blur',
customizations: {
javascript: 'alert("coucou")',
css: 'body { background-color: red; }'
}
},
+ services: {
+ twitter: {
+ username: '@MySuperUsername',
+ whitelisted: true
+ }
+ },
cache: {
previews: {
size: 2
+ },
+ captions: {
+ size: 3
}
},
signup: {
enabled: false,
- limit: 5
+ limit: 5,
+ requiresEmailVerification: false
},
admin: {
email: 'superadmin1@example.com'
},
+ contactForm: {
+ enabled: false
+ },
user: {
- videoQuota: 5242881
+ videoQuota: 5242881,
+ videoQuotaDaily: 318742
},
transcoding: {
enabled: true,
+ allowAdditionalExtensions: true,
threads: 1,
resolutions: {
'240p': false,
'480p': true,
'720p': false,
'1080p': false
+ },
+ hls: {
+ enabled: false
+ }
+ },
+ import: {
+ videos: {
+ http: {
+ enabled: false
+ },
+ torrent: {
+ enabled: false
+ }
}
}
}
})
})
+ it('Should fail with a bad default NSFW policy', async function () {
+ const newUpdateParams = immutableAssign(updateParams, {
+ instance: {
+ defaultNSFWPolicy: 'hello'
+ }
+ })
+
+ await makePutBodyRequest({
+ url: server.url,
+ path,
+ fields: newUpdateParams,
+ token: server.accessToken,
+ statusCodeExpected: 400
+ })
+ })
+
it('Should success with the correct parameters', async function () {
await makePutBodyRequest({
url: server.url,