Introduce config command

pull/4271/head
Chocobozzz 2021-07-07 11:51:09 +02:00
parent bc8090411d
commit 65e6e2602c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
36 changed files with 740 additions and 746 deletions

View File

@ -19,7 +19,6 @@ import {
ServerInfo,
setAccessTokensToServers,
stopFfmpeg,
updateCustomSubConfig,
updateLive,
uploadVideoAndGetId,
userLogin,
@ -43,12 +42,14 @@ describe('Test video lives API validator', function () {
await setAccessTokensToServers([ server ])
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 20,
allowReplay: true
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 20,
allowReplay: true
}
}
})
@ -234,9 +235,11 @@ describe('Test video lives API validator', function () {
})
it('Should forbid if live is disabled', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: false
}
}
})
@ -252,10 +255,12 @@ describe('Test video lives API validator', function () {
it('Should forbid to save replay if not enabled by the admin', async function () {
const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
allowReplay: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: false
}
}
})
@ -271,10 +276,12 @@ describe('Test video lives API validator', function () {
it('Should allow to save replay if enabled by the admin', async function () {
const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
allowReplay: true
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true
}
}
})
@ -288,10 +295,12 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max instance lives is reached', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
maxInstanceLives: 1
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
maxInstanceLives: 1
}
}
})
@ -305,11 +314,13 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max user lives is reached', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 1
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 1
}
}
})
@ -393,10 +404,12 @@ describe('Test video lives API validator', function () {
})
it('Should fail to update replay status if replay is not allowed on the instance', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
allowReplay: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: false
}
}
})

View File

@ -1,28 +1,27 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import { HttpStatusCode } from '@shared/core-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination,
cleanupTests,
flushAndRunServer,
immutableAssign,
makeGetRequest,
ServerInfo,
updateCustomSubConfig,
setAccessTokensToServers
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
} from '@shared/extra-utils'
function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
return updateCustomSubConfig(server.url, server.accessToken, {
search: {
searchIndex: {
enabled,
disableLocalSearch
return server.configCommand.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
enabled,
disableLocalSearch
}
}
}
})

View File

@ -2,9 +2,12 @@
import 'mocha'
import { omit } from 'lodash'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import { HttpStatusCode } from '@shared/core-utils'
import {
buildAbsoluteFixturePath,
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination,
cleanupTests,
createUser,
flushAndRunServer,
@ -15,16 +18,10 @@ import {
makeUploadRequest,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
userLogin
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
import { getGoodVideoUrl, getMagnetURI } from '../../../../shared/extra-utils/videos/video-imports'
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
} from '@shared/extra-utils'
import { getGoodVideoUrl, getMagnetURI } from '@shared/extra-utils/videos/video-imports'
import { VideoPrivacy } from '@shared/models'
describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
@ -263,14 +260,16 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import http videos', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
import: {
videos: {
http: {
enabled: false
},
torrent: {
enabled: true
await server.configCommand.updateCustomSubConfig({
newConfig: {
import: {
videos: {
http: {
enabled: false
},
torrent: {
enabled: true
}
}
}
}
@ -286,14 +285,16 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import torrent videos', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
import: {
videos: {
http: {
enabled: true
},
torrent: {
enabled: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
import: {
videos: {
http: {
enabled: true
},
torrent: {
enabled: false
}
}
}
}

View File

@ -6,17 +6,16 @@ import { VideoDetails, VideoPrivacy } from '@shared/models'
import {
checkLiveCleanup,
cleanupTests,
ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
generateUser,
getCustomConfigResolutions,
getVideo,
runAndTestFfmpegStreamError,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
updateCustomSubConfig,
updateUser,
wait,
waitJobs,
@ -80,12 +79,14 @@ describe('Test live constraints', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
@ -157,14 +158,16 @@ describe('Test live constraints', function () {
it('Should have max duration limit', async function () {
this.timeout(60000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: 1,
transcoding: {
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: getCustomConfigResolutions(true)
allowReplay: true,
maxDuration: 1,
transcoding: {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(true)
}
}
}
})

View File

@ -5,10 +5,10 @@ import * as chai from 'chai'
import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
import {
cleanupTests,
ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
getCustomConfigResolutions,
getLive,
getPlaylistsCount,
getVideo,
@ -17,7 +17,6 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
updateCustomSubConfig,
updateLive,
wait,
waitJobs,
@ -63,14 +62,16 @@ describe('Permanent live', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: getCustomConfigResolutions(true)
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(true)
}
}
}
})
@ -145,14 +146,16 @@ describe('Permanent live', function () {
it('Should be able to stream again in the permanent live', async function () {
this.timeout(20000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: getCustomConfigResolutions(false)
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(false)
}
}
}
})

View File

@ -9,10 +9,10 @@ import {
addVideoToBlacklist,
checkLiveCleanup,
cleanupTests,
ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
getCustomConfigResolutions,
getVideo,
getVideosList,
removeVideo,
@ -22,7 +22,6 @@ import {
setDefaultVideoChannel,
stopFfmpeg,
testFfmpegStreamError,
updateCustomSubConfig,
updateVideo,
wait,
waitJobs,
@ -102,14 +101,16 @@ describe('Save replay setting', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: false,
resolutions: getCustomConfigResolutions(true)
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: false,
resolutions: ConfigCommand.getCustomConfigResolutions(true)
}
}
}
})

View File

@ -15,7 +15,6 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
updateCustomSubConfig,
viewVideo,
wait,
waitJobs,
@ -37,12 +36,14 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})

View File

@ -15,7 +15,6 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
updateCustomSubConfig,
viewVideo,
wait,
waitJobs,
@ -36,12 +35,14 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})

View File

@ -34,7 +34,6 @@ import {
stopFfmpeg,
testFfmpegStreamError,
testImage,
updateCustomSubConfig,
updateLive,
uploadVideoAndGetId,
wait,
@ -59,12 +58,14 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
@ -422,20 +423,22 @@ describe('Test live', function () {
}
function updateConf (resolutions: number[]) {
return updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
return servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: {
'240p': resolutions.includes(240),
'360p': resolutions.includes(360),
'480p': resolutions.includes(480),
'720p': resolutions.includes(720),
'1080p': resolutions.includes(1080),
'2160p': resolutions.includes(2160)
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true,
resolutions: {
'240p': resolutions.includes(240),
'360p': resolutions.includes(360),
'480p': resolutions.includes(480),
'720p': resolutions.includes(720),
'1080p': resolutions.includes(1080),
'2160p': resolutions.includes(2160)
}
}
}
}

View File

@ -23,7 +23,6 @@ import {
createUser,
generateUserAccessToken,
getAccount,
getCustomConfig,
getVideoCommentThreads,
getVideoIdFromUUID,
immutableAssign,
@ -34,8 +33,6 @@ import {
removeUserSubscription,
removeVideoFromBlacklist,
ServerInfo,
updateCustomConfig,
updateCustomSubConfig,
uploadVideo,
wait,
waitJobs
@ -407,7 +404,7 @@ describe('Test moderation notifications', function () {
}
}
}
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
@ -421,7 +418,7 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence')
config.followings.instance.autoFollowBack.enabled = false
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await servers[0].followsCommand.unfollow({ target: servers[2] })
await servers[2].followsCommand.unfollow({ target: servers[0] })
})
@ -430,7 +427,7 @@ describe('Test moderation notifications', function () {
this.timeout(30000)
await servers[0].followsCommand.unfollow({ target: servers[1] })
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
@ -440,7 +437,7 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
config.followings.instance.autoFollowIndex.enabled = false
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await servers[0].followsCommand.unfollow({ target: servers[1] })
})
})
@ -476,8 +473,8 @@ describe('Test moderation notifications', function () {
token: userAccessToken
}
const resCustomConfig = await getCustomConfig(servers[0].url, servers[0].accessToken)
currentCustomConfig = resCustomConfig.body
currentCustomConfig = await servers[0].configCommand.getCustomConfig()
const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, {
autoBlacklist: {
videos: {
@ -487,9 +484,10 @@ describe('Test moderation notifications', function () {
}
}
})
// enable transcoding otherwise own publish notification after transcoding not expected
autoBlacklistTestsCustomConfig.transcoding.enabled = true
await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig)
await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
@ -612,7 +610,7 @@ describe('Test moderation notifications', function () {
})
after(async () => {
await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig)
await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig })
await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)

View File

@ -9,7 +9,6 @@ import {
SearchCommand,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
uploadVideo
} from '@shared/extra-utils'
import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
@ -39,12 +38,14 @@ describe('Test videos search', function () {
it('Should make a local videos search by default', async function () {
this.timeout(10000)
await updateCustomSubConfig(server.url, server.accessToken, {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: false,
disableLocalSearch: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: false,
disableLocalSearch: false
}
}
}
})
@ -64,12 +65,14 @@ describe('Test videos search', function () {
})
it('Should make an index videos search by default', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: true,
disableLocalSearch: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: true,
disableLocalSearch: false
}
}
}
})
@ -84,12 +87,14 @@ describe('Test videos search', function () {
})
it('Should make an index videos search if local search is disabled', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: false,
disableLocalSearch: true
await server.configCommand.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: false,
disableLocalSearch: true
}
}
}
})
@ -216,7 +221,11 @@ describe('Test videos search', function () {
let nsfwUUID: string
{
await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'display' } })
await server.configCommand.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'display' }
}
})
const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' })
expect(body.data).to.have.length.greaterThan(0)
@ -228,7 +237,11 @@ describe('Test videos search', function () {
}
{
await updateCustomSubConfig(server.url, server.accessToken, { instance: { defaultNSFWPolicy: 'do_not_list' } })
await server.configCommand.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'do_not_list' }
}
})
const body = await command.searchVideos({ search: 'NSFW search index', sort: '-match' })

View File

@ -14,7 +14,6 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
updateCustomSubConfig,
uploadVideo,
wait,
waitUntilLivePublished
@ -486,13 +485,13 @@ describe('Test videos search', function () {
this.timeout(30000)
{
const options = {
const newConfig = {
search: {
searchIndex: { enabled: false }
},
live: { enabled: true }
}
await updateCustomSubConfig(server.url, server.accessToken, options)
await server.configCommand.updateCustomSubConfig({ newConfig })
}
{

View File

@ -8,7 +8,6 @@ import {
MockInstancesIndex,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
wait,
waitJobs
} from '@shared/extra-utils'
@ -87,7 +86,7 @@ describe('Test auto follows', function () {
}
}
}
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
@ -112,7 +111,7 @@ describe('Test auto follows', function () {
}
}
}
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
@ -129,7 +128,7 @@ describe('Test auto follows', function () {
config.followings.instance.autoFollowBack.enabled = false
config.followers.instance.manualApproval = false
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
})
})
@ -166,7 +165,7 @@ describe('Test auto follows', function () {
}
}
}
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)

View File

@ -2,15 +2,10 @@
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,
@ -18,11 +13,9 @@ import {
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
@ -213,7 +206,7 @@ function checkUpdatedConfig (data: CustomConfig) {
}
describe('Test config', function () {
let server = null
let server: ServerInfo = null
before(async function () {
this.timeout(30000)
@ -223,8 +216,7 @@ describe('Test config', function () {
})
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
})
@ -238,15 +230,13 @@ describe('Test config', function () {
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')
@ -260,8 +250,7 @@ describe('Test config', function () {
})
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)
})
@ -438,19 +427,16 @@ describe('Test config', function () {
}
}
}
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')
@ -474,15 +460,13 @@ describe('Test config', function () {
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')
@ -504,11 +488,9 @@ describe('Test config', function () {
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)
})

View File

@ -8,7 +8,6 @@ import {
FollowsCommand,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
waitJobs
} from '@shared/extra-utils'
@ -94,7 +93,7 @@ describe('Test follows moderation', function () {
}
}
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
@ -114,7 +113,7 @@ describe('Test follows moderation', function () {
}
}
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
@ -137,8 +136,8 @@ describe('Test follows moderation', function () {
}
}
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
await updateCustomSubConfig(servers[2].url, servers[2].accessToken, subConfig)
await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
await servers[2].configCommand.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)

View File

@ -3,12 +3,10 @@
import 'mocha'
import * as chai from 'chai'
import { HttpStatusCode } from '@shared/core-utils'
import { ServerConfig } from '@shared/models'
import {
cleanupTests,
CustomPagesCommand,
flushAndRunServer,
getConfig,
killallServers,
reRunServer,
ServerInfo,
@ -18,9 +16,8 @@ import {
const expect = chai.expect
async function getHomepageState (server: ServerInfo) {
const res = await getConfig(server.url)
const config = await server.configCommand.getConfig()
const config = res.body as ServerConfig
return config.homepage.enabled
}

View File

@ -7,7 +7,6 @@ import {
cleanupTests,
closeAllSequelize,
flushAndRunServer,
getConfig,
getMyUserInformation,
killallServers,
PluginsCommand,
@ -16,12 +15,11 @@ import {
setAccessTokensToServers,
setPluginVersion,
testHelloWorldRegisteredSettings,
updateCustomSubConfig,
updateMyUser,
wait,
waitUntilLog
} from '@shared/extra-utils'
import { PluginType, ServerConfig, User } from '@shared/models'
import { PluginType, User } from '@shared/models'
const expect = chai.expect
@ -102,8 +100,7 @@ describe('Test plugins', function () {
})
it('Should have the plugin loaded in the configuration', async function () {
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const theme = config.theme.registered.find(r => r.name === 'background-red')
expect(theme).to.not.be.undefined
@ -113,11 +110,13 @@ describe('Test plugins', function () {
})
it('Should update the default theme in the configuration', async function () {
await updateCustomSubConfig(server.url, server.accessToken, { theme: { default: 'background-red' } })
const res = await getConfig(server.url)
const config: ServerConfig = res.body
await server.configCommand.updateCustomSubConfig({
newConfig: {
theme: { default: 'background-red' }
}
})
const config = await server.configCommand.getConfig()
expect(config.theme.default).to.equal('background-red')
})
@ -302,9 +301,7 @@ describe('Test plugins', function () {
})
it('Should have updated the configuration', async function () {
// get /config (default theme + registered themes + registered plugins)
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
expect(config.theme.default).to.equal('default')

View File

@ -12,7 +12,6 @@ import {
flushAndRunMultipleServers,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
uploadVideo,
userLogin,
viewVideo,
@ -197,24 +196,26 @@ describe('Test stats (excluding redundancy)', function () {
it('Should correctly count video file sizes if transcoding is enabled', async function () {
this.timeout(60000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
transcoding: {
enabled: true,
webtorrent: {
enabled: true
},
hls: {
enabled: true
},
resolutions: {
'0p': false,
'240p': false,
'360p': false,
'480p': false,
'720p': false,
'1080p': false,
'1440p': false,
'2160p': false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
webtorrent: {
enabled: true
},
hls: {
enabled: true
},
resolutions: {
'0p': false,
'240p': false,
'360p': false,
'480p': false,
'720p': false,
'1080p': false,
'1440p': false,
'2160p': false
}
}
}
})
@ -238,9 +239,11 @@ describe('Test stats (excluding redundancy)', function () {
it('Should have the correct AP stats', async function () {
this.timeout(60000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
}
}
})

View File

@ -11,7 +11,6 @@ import {
login,
registerUser,
ServerInfo,
updateCustomSubConfig,
updateMyUser,
userLogin,
verifyEmail
@ -58,11 +57,13 @@ describe('Test users account verification', function () {
it('Should register user and send verification email if verification required', async function () {
this.timeout(30000)
await updateCustomSubConfig(server.url, server.accessToken, {
signup: {
enabled: true,
requiresEmailVerification: true,
limit: 10
await server.configCommand.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
requiresEmailVerification: true,
limit: 10
}
}
})
@ -148,11 +149,13 @@ describe('Test users account verification', function () {
it('Should register user not requiring email verification if setting not enabled', async function () {
this.timeout(5000)
await updateCustomSubConfig(server.url, server.accessToken, {
signup: {
enabled: true,
requiresEmailVerification: false,
limit: 10
await server.configCommand.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
requiresEmailVerification: false,
limit: 10
}
}
})
@ -168,11 +171,13 @@ describe('Test users account verification', function () {
})
it('Should allow login for user with unverified email when setting later enabled', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
signup: {
enabled: true,
requiresEmailVerification: true,
limit: 10
await server.configCommand.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
requiresEmailVerification: true,
limit: 10
}
}
})

View File

@ -13,7 +13,6 @@ import {
flushAndRunServer,
getAccountRatings,
getBlacklistedVideosList,
getCustomConfig,
getMyUserInformation,
getMyUserVideoQuotaUsed,
getMyUserVideoRating,
@ -38,7 +37,6 @@ import {
setTokenField,
testImage,
unblockUser,
updateCustomSubConfig,
updateMyAvatar,
updateMyUser,
updateUser,
@ -46,7 +44,7 @@ import {
userLogin,
waitJobs
} from '@shared/extra-utils'
import { AbuseState, CustomConfig, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
import { AbuseState, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
const expect = chai.expect
@ -418,12 +416,11 @@ describe('Test users', function () {
this.timeout(60000)
{
const res = await getCustomConfig(server.url, server.accessToken)
const config = res.body as CustomConfig
const config = await server.configCommand.getCustomConfig()
config.transcoding.webtorrent.enabled = false
config.transcoding.hls.enabled = true
config.transcoding.enabled = true
await updateCustomSubConfig(server.url, server.accessToken, config)
await server.configCommand.updateCustomSubConfig({ newConfig: config })
}
{

View File

@ -20,7 +20,6 @@ import {
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
updateCustomSubConfig,
uploadVideo,
userLogin
} from '../../../../shared/extra-utils'
@ -58,12 +57,14 @@ describe('Test video change ownership - nominal', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
transcoding: {
enabled: false
},
live: {
enabled: true
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
},
live: {
enabled: true
}
}
})

View File

@ -3,6 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import { join } from 'path'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
checkDirectoryIsEmpty,
checkResolutionsInMasterPlaylist,
@ -17,7 +18,6 @@ import {
removeVideo,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
updateVideo,
uploadVideo,
waitJobs,
@ -26,7 +26,6 @@ import {
import { VideoDetails } from '../../../../shared/models/videos'
import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
@ -192,24 +191,26 @@ describe('Test HLS videos', function () {
describe('With only HLS enabled', function () {
before(async function () {
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
transcoding: {
enabled: true,
allowAudioFiles: true,
resolutions: {
'240p': true,
'360p': true,
'480p': true,
'720p': true,
'1080p': true,
'1440p': true,
'2160p': true
},
hls: {
enabled: true
},
webtorrent: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
allowAudioFiles: true,
resolutions: {
'240p': true,
'360p': true,
'480p': true,
'720p': true,
'1080p': true,
'1440p': true,
'2160p': true
},
hls: {
enabled: true
},
webtorrent: {
enabled: false
}
}
}
})

View File

@ -14,8 +14,7 @@ import {
listVideoCaptions,
ServerInfo,
setAccessTokensToServers,
testCaptionFile,
updateCustomSubConfig
testCaptionFile
} from '../../../../shared/extra-utils'
import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
@ -333,7 +332,7 @@ Ajouter un sous-titre est vraiment facile`)
}
}
}
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
const attributes = {
name: 'hdr video',

View File

@ -7,8 +7,6 @@ import {
createUser,
flushAndRunServer,
getAccountVideos,
getConfig,
getCustomConfig,
getMyUserInformation,
getMyVideos,
getVideoChannelVideos,
@ -16,12 +14,11 @@ import {
getVideosListWithToken,
ServerInfo,
setAccessTokensToServers,
updateCustomConfig,
updateMyUser,
uploadVideo,
userLogin
} from '@shared/extra-utils'
import { BooleanBothQuery, CustomConfig, ServerConfig, User, VideosOverview } from '@shared/models'
import { BooleanBothQuery, CustomConfig, User, VideosOverview } from '@shared/models'
const expect = chai.expect
@ -97,16 +94,12 @@ describe('Test video NSFW policy', function () {
await uploadVideo(server.url, server.accessToken, attributes)
}
{
const res = await getCustomConfig(server.url, server.accessToken)
customConfig = res.body
}
customConfig = await server.configCommand.getCustomConfig()
})
describe('Instance default NSFW policy', function () {
it('Should display NSFW videos with display default NSFW policy', async function () {
const resConfig = await getConfig(server.url)
const serverConfig: ServerConfig = resConfig.body
const serverConfig = await server.configCommand.getConfig()
expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display')
for (const res of await getVideosFunctions()) {
@ -121,10 +114,9 @@ describe('Test video NSFW policy', function () {
it('Should not display NSFW videos with do_not_list default NSFW policy', async function () {
customConfig.instance.defaultNSFWPolicy = 'do_not_list'
await updateCustomConfig(server.url, server.accessToken, customConfig)
await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig })
const resConfig = await getConfig(server.url)
const serverConfig: ServerConfig = resConfig.body
const serverConfig = await server.configCommand.getConfig()
expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list')
for (const res of await getVideosFunctions()) {
@ -138,10 +130,9 @@ describe('Test video NSFW policy', function () {
it('Should display NSFW videos with blur default NSFW policy', async function () {
customConfig.instance.defaultNSFWPolicy = 'blur'
await updateCustomConfig(server.url, server.accessToken, customConfig)
await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig })
const resConfig = await getConfig(server.url)
const serverConfig: ServerConfig = resConfig.body
const serverConfig = await server.configCommand.getConfig()
expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur')
for (const res of await getVideosFunctions()) {
@ -172,7 +163,7 @@ describe('Test video NSFW policy', function () {
it('Should display NSFW videos with blur user NSFW policy', async function () {
customConfig.instance.defaultNSFWPolicy = 'do_not_list'
await updateCustomConfig(server.url, server.accessToken, customConfig)
await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig })
for (const res of await getVideosFunctions(userAccessToken)) {
expect(res.body.total).to.equal(2)

View File

@ -5,7 +5,6 @@ import * as chai from 'chai'
import { FfprobeData } from 'fluent-ffmpeg'
import { omit } from 'lodash'
import { join } from 'path'
import { Job } from '@shared/models'
import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
@ -24,7 +23,6 @@ import {
makeGetRequest,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
uploadVideo,
uploadVideoAndGetId,
waitJobs,
@ -43,22 +41,24 @@ import {
const expect = chai.expect
function updateConfigForTranscoding (server: ServerInfo) {
return updateCustomSubConfig(server.url, server.accessToken, {
transcoding: {
enabled: true,
allowAdditionalExtensions: true,
allowAudioFiles: true,
hls: { enabled: true },
webtorrent: { enabled: true },
resolutions: {
'0p': false,
'240p': true,
'360p': true,
'480p': true,
'720p': true,
'1080p': true,
'1440p': true,
'2160p': true
return server.configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
allowAdditionalExtensions: true,
allowAudioFiles: true,
hls: { enabled: true },
webtorrent: { enabled: true },
resolutions: {
'0p': false,
'240p': true,
'360p': true,
'480p': true,
'720p': true,
'1080p': true,
'1440p': true,
'2160p': true
}
}
}
})
@ -363,19 +363,21 @@ describe('Test video transcoding', function () {
function runSuite (mode: 'legacy' | 'resumable') {
before(async function () {
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
transcoding: {
hls: { enabled: true },
webtorrent: { enabled: true },
resolutions: {
'0p': false,
'240p': false,
'360p': false,
'480p': false,
'720p': false,
'1080p': false,
'1440p': false,
'2160p': false
await servers[1].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
hls: { enabled: true },
webtorrent: { enabled: true },
resolutions: {
'0p': false,
'240p': false,
'360p': false,
'480p': false,
'720p': false,
'1080p': false,
'1440p': false,
'2160p': false
}
}
}
})
@ -434,14 +436,16 @@ describe('Test video transcoding', function () {
it('Should upload an audio file and create an audio version only', async function () {
this.timeout(60_000)
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
transcoding: {
hls: { enabled: true },
webtorrent: { enabled: true },
resolutions: {
'0p': true,
'240p': false,
'360p': false
await servers[1].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
hls: { enabled: true },
webtorrent: { enabled: true },
resolutions: {
'0p': true,
'240p': false,
'360p': false
}
}
}
})
@ -601,7 +605,7 @@ describe('Test video transcoding', function () {
it('Should not transcode to an higher bitrate than the original file', async function () {
this.timeout(160_000)
const config = {
const newConfig = {
transcoding: {
enabled: true,
resolutions: {
@ -617,7 +621,7 @@ describe('Test video transcoding', function () {
hls: { enabled: true }
}
}
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
await servers[1].configCommand.updateCustomSubConfig({ newConfig })
const videoAttributes = {
name: 'low bitrate',

View File

@ -10,7 +10,6 @@ import {
getVideosList,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
uploadVideo
} from '../../../shared/extra-utils'
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
@ -47,7 +46,7 @@ describe('Test create transcoding jobs', function () {
servers = await flushAndRunMultipleServers(2)
await setAccessTokensToServers(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await doubleFollow(servers[0], servers[1])
@ -199,7 +198,7 @@ describe('Test create transcoding jobs', function () {
this.timeout(120000)
config.transcoding.hls.enabled = true
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)

View File

@ -5,14 +5,12 @@ import { expect } from 'chai'
import {
cleanupTests,
flushAndRunServer,
getConfig,
killallServers,
PluginsCommand,
reRunServer,
ServerInfo,
setAccessTokensToServers
} from '../../../shared/extra-utils'
import { ServerConfig } from '../../../shared/models/server'
describe('Test plugin scripts', function () {
let server: ServerInfo
@ -44,8 +42,7 @@ describe('Test plugin scripts', function () {
killallServers([ server ])
await reRunServer(server)
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const plugin = config.plugin.registered
.find(p => p.name === 'test')
@ -68,8 +65,7 @@ describe('Test plugin scripts', function () {
killallServers([ server ])
await reRunServer(server)
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const plugin = config.plugin.registered
.find(p => p.name === 'test')

View File

@ -4,7 +4,7 @@ import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
import { Account, CustomConfig, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models'
import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models'
import {
addVideoInPlaylist,
cleanupTests,
@ -12,16 +12,12 @@ import {
doubleFollow,
flushAndRunMultipleServers,
getAccount,
getConfig,
getCustomConfig,
getVideosList,
makeGetRequest,
makeHTMLRequest,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
updateCustomConfig,
updateCustomSubConfig,
updateMyUser,
updateVideoChannel,
uploadVideo,
@ -307,14 +303,13 @@ describe('Test a client controllers', function () {
describe('Whitelisted', function () {
before(async function () {
const res = await getCustomConfig(servers[0].url, servers[0].accessToken)
const config = res.body as CustomConfig
const config = await servers[0].configCommand.getCustomConfig()
config.services.twitter = {
username: '@Kuja',
whitelisted: true
}
await updateCustomConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomConfig({ newCustomConfig: config })
})
async function accountPageTest (path: string) {
@ -382,40 +377,42 @@ describe('Test a client controllers', function () {
describe('Index HTML', function () {
it('Should have valid index html tags (title, description...)', async function () {
const resConfig = await getConfig(servers[0].url)
const config = await servers[0].configCommand.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
checkIndexTags(res.text, 'PeerTube', description, '', resConfig.body)
checkIndexTags(res.text, 'PeerTube', description, '', config)
})
it('Should update the customized configuration and have the correct index html tags', async function () {
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
instance: {
name: 'PeerTube updated',
shortDescription: 'my short description',
description: 'my super description',
terms: 'my super terms',
defaultNSFWPolicy: 'blur',
defaultClientRoute: '/videos/recently-added',
customizations: {
javascript: 'alert("coucou")',
css: 'body { background-color: red; }'
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
instance: {
name: 'PeerTube updated',
shortDescription: 'my short description',
description: 'my super description',
terms: 'my super terms',
defaultNSFWPolicy: 'blur',
defaultClientRoute: '/videos/recently-added',
customizations: {
javascript: 'alert("coucou")',
css: 'body { background-color: red; }'
}
}
}
})
const resConfig = await getConfig(servers[0].url)
const config = await servers[0].configCommand.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
})
it('Should have valid index html updated tags (title, description...)', async function () {
const resConfig = await getConfig(servers[0].url)
const config = await servers[0].configCommand.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
})
it('Should use the original video URL for the canonical tag', async function () {
@ -428,7 +425,7 @@ describe('Test a client controllers', function () {
})
it('Should use the original account URL for the canonical tag', async function () {
const accountURLtest = (res) => {
const accountURLtest = res => {
expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/accounts/root" />`)
}
@ -438,7 +435,7 @@ describe('Test a client controllers', function () {
})
it('Should use the original channel URL for the canonical tag', async function () {
const channelURLtests = (res) => {
const channelURLtests = res => {
expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/video-channels/root_channel" />`)
}
@ -460,10 +457,10 @@ describe('Test a client controllers', function () {
describe('Embed HTML', function () {
it('Should have the correct embed html tags', async function () {
const resConfig = await getConfig(servers[0].url)
const config = await servers[0].configCommand.getConfig()
const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath)
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', resConfig.body)
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
})
})

View File

@ -8,7 +8,6 @@ import {
createUser,
decodeQueryString,
flushAndRunServer,
getConfig,
getMyUserInformation,
loginUsingExternalToken,
logout,
@ -21,7 +20,7 @@ import {
wait,
waitUntilLog
} from '@shared/extra-utils'
import { ServerConfig, User, UserRole } from '@shared/models'
import { User, UserRole } from '@shared/models'
async function loginExternal (options: {
server: ServerInfo
@ -78,9 +77,7 @@ describe('Test external auth plugins', function () {
})
it('Should display the correct configuration', async function () {
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(8)
@ -288,9 +285,7 @@ describe('Test external auth plugins', function () {
})
it('Should have disabled this auth', async function () {
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(7)
@ -354,9 +349,7 @@ describe('Test external auth plugins', function () {
})
it('Should display the correct configuration', async function () {
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(6)

View File

@ -12,7 +12,6 @@ import {
doubleFollow,
flushAndRunMultipleServers,
getAccountVideos,
getConfig,
getMyVideos,
getVideo,
getVideoChannelVideos,
@ -28,7 +27,6 @@ import {
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
updateCustomSubConfig,
updateVideo,
uploadVideo,
uploadVideoAndGetId,
@ -37,7 +35,6 @@ import {
} from '@shared/extra-utils'
import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports'
import {
ServerConfig,
VideoCommentThreadTree,
VideoDetails,
VideoImport,
@ -72,13 +69,15 @@ describe('Test plugin filter hooks', function () {
const res = await getVideosList(servers[0].url)
videoUUID = res.body.data[0].uuid
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: { enabled: true },
signup: { enabled: true },
import: {
videos: {
http: { enabled: true },
torrent: { enabled: true }
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: { enabled: true },
signup: { enabled: true },
import: {
videos: {
http: { enabled: true },
torrent: { enabled: true }
}
}
}
})
@ -344,8 +343,8 @@ describe('Test plugin filter hooks', function () {
describe('Should run filter:api.user.signup.allowed.result', function () {
it('Should run on config endpoint', async function () {
const res = await getConfig(servers[0].url)
expect((res.body as ServerConfig).signup.allowed).to.be.true
const body = await servers[0].configCommand.getConfig()
expect(body.signup.allowed).to.be.true
})
it('Should allow a signup', async function () {
@ -365,13 +364,15 @@ describe('Test plugin filter hooks', function () {
before(async function () {
this.timeout(120000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
transcoding: {
webtorrent: {
enabled: true
},
hls: {
enabled: true
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
webtorrent: {
enabled: true
},
hls: {
enabled: true
}
}
}
})
@ -427,9 +428,11 @@ describe('Test plugin filter hooks', function () {
before(async function () {
this.timeout(60000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
}
}
})
@ -464,12 +467,14 @@ describe('Test plugin filter hooks', function () {
describe('Search filters', function () {
before(async function () {
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: false,
disableLocalSearch: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
enabled: true,
isDefaultSearch: false,
disableLocalSearch: false
}
}
}
})

View File

@ -5,7 +5,6 @@ import { expect } from 'chai'
import {
cleanupTests,
flushAndRunServer,
getConfig,
getMyUserInformation,
getUsersList,
login,
@ -19,7 +18,7 @@ import {
wait,
waitUntilLog
} from '@shared/extra-utils'
import { ServerConfig, User, UserRole } from '@shared/models'
import { User, UserRole } from '@shared/models'
describe('Test id and pass auth plugins', function () {
let server: ServerInfo
@ -42,9 +41,7 @@ describe('Test id and pass auth plugins', function () {
})
it('Should display the correct configuration', async function () {
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(8)
@ -190,9 +187,7 @@ describe('Test id and pass auth plugins', function () {
})
it('Should have disabled this auth', async function () {
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(7)
@ -208,9 +203,7 @@ describe('Test id and pass auth plugins', function () {
})
it('Should display the correct configuration', async function () {
const res = await getConfig(server.url)
const config: ServerConfig = res.body
const config = await server.configCommand.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(6)

View File

@ -9,7 +9,6 @@ import {
cleanupTests,
createLive,
flushAndRunServer,
getConfig,
getVideo,
PluginsCommand,
sendRTMPStreamInVideo,
@ -17,12 +16,11 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
testFfmpegStreamError,
updateCustomSubConfig,
uploadVideoAndGetId,
waitJobs,
waitUntilLivePublished
} from '@shared/extra-utils'
import { ServerConfig, VideoDetails, VideoPrivacy } from '@shared/models'
import { VideoDetails, VideoPrivacy } from '@shared/models'
async function createLiveWrapper (server: ServerInfo) {
const liveAttributes = {
@ -36,33 +34,35 @@ async function createLiveWrapper (server: ServerInfo) {
}
function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) {
return updateCustomSubConfig(server.url, server.accessToken, {
transcoding: {
enabled: true,
profile: vodProfile,
hls: {
enabled: true
},
webtorrent: {
enabled: true
},
resolutions: {
'240p': true,
'360p': false,
'480p': false,
'720p': true
}
},
live: {
return server.configCommand.updateCustomSubConfig({
newConfig: {
transcoding: {
profile: liveProfile,
enabled: true,
profile: vodProfile,
hls: {
enabled: true
},
webtorrent: {
enabled: true
},
resolutions: {
'240p': true,
'360p': false,
'480p': false,
'720p': true
}
},
live: {
transcoding: {
profile: liveProfile,
enabled: true,
resolutions: {
'240p': true,
'360p': false,
'480p': false,
'720p': true
}
}
}
}
})
@ -113,8 +113,7 @@ describe('Test transcoding plugins', function () {
})
it('Should have the appropriate available profiles', async function () {
const res = await getConfig(server.url)
const config = res.body as ServerConfig
const config = await server.configCommand.getConfig()
expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ])
expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ])
@ -223,8 +222,7 @@ describe('Test transcoding plugins', function () {
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
const res = await getConfig(server.url)
const config = res.body as ServerConfig
const config = await server.configCommand.getConfig()
expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])

View File

@ -0,0 +1,260 @@
import { merge } from 'lodash'
import { DeepPartial, HttpStatusCode } from '@shared/core-utils'
import { About, ServerConfig } from '@shared/models'
import { CustomConfig } from '../../models/server/custom-config.model'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class ConfigCommand extends AbstractCommand {
static getCustomConfigResolutions (enabled: boolean) {
return {
'240p': enabled,
'360p': enabled,
'480p': enabled,
'720p': enabled,
'1080p': enabled,
'1440p': enabled,
'2160p': enabled
}
}
getConfig (options: OverrideCommandOptions = {}) {
const path = '/api/v1/config'
return this.getRequestBody<ServerConfig>({
...options,
token: null,
path,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getAbout (options: OverrideCommandOptions = {}) {
const path = '/api/v1/config/about'
return this.getRequestBody<About>({
...options,
token: null,
path,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getCustomConfig (options: OverrideCommandOptions = {}) {
const path = '/api/v1/config/custom'
return this.getRequestBody<CustomConfig>({
...options,
path,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
updateCustomConfig (options: OverrideCommandOptions & {
newCustomConfig: CustomConfig
}) {
const path = '/api/v1/config/custom'
return this.putBodyRequest({
...options,
path,
fields: options.newCustomConfig,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
deleteCustomConfig (options: OverrideCommandOptions = {}) {
const path = '/api/v1/config/custom'
return this.deleteRequest({
...options,
path,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
updateCustomSubConfig (options: OverrideCommandOptions & {
newConfig: DeepPartial<CustomConfig>
}) {
const newCustomConfig: CustomConfig = {
instance: {
name: 'PeerTube updated',
shortDescription: 'my short description',
description: 'my super description',
terms: 'my super terms',
codeOfConduct: 'my super coc',
creationReason: 'my super creation reason',
moderationInformation: 'my super moderation information',
administrator: 'Kuja',
maintenanceLifetime: 'forever',
businessModel: 'my super business model',
hardwareInformation: '2vCore 3GB RAM',
languages: [ 'en', 'es' ],
categories: [ 1, 2 ],
isNSFW: true,
defaultNSFWPolicy: 'blur',
defaultClientRoute: '/videos/recently-added',
customizations: {
javascript: 'alert("coucou")',
css: 'body { background-color: red; }'
}
},
theme: {
default: 'default'
},
services: {
twitter: {
username: '@MySuperUsername',
whitelisted: true
}
},
cache: {
previews: {
size: 2
},
captions: {
size: 3
},
torrents: {
size: 4
}
},
signup: {
enabled: false,
limit: 5,
requiresEmailVerification: false,
minimumAge: 16
},
admin: {
email: 'superadmin1@example.com'
},
contactForm: {
enabled: true
},
user: {
videoQuota: 5242881,
videoQuotaDaily: 318742
},
transcoding: {
enabled: true,
allowAdditionalExtensions: true,
allowAudioFiles: true,
threads: 1,
concurrency: 3,
profile: 'default',
resolutions: {
'0p': false,
'240p': false,
'360p': true,
'480p': true,
'720p': false,
'1080p': false,
'1440p': false,
'2160p': false
},
webtorrent: {
enabled: true
},
hls: {
enabled: false
}
},
live: {
enabled: true,
allowReplay: false,
maxDuration: -1,
maxInstanceLives: -1,
maxUserLives: 50,
transcoding: {
enabled: true,
threads: 4,
profile: 'default',
resolutions: {
'240p': true,
'360p': true,
'480p': true,
'720p': true,
'1080p': true,
'1440p': true,
'2160p': true
}
}
},
import: {
videos: {
concurrency: 3,
http: {
enabled: false
},
torrent: {
enabled: false
}
}
},
trending: {
videos: {
algorithms: {
enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ],
default: 'hot'
}
}
},
autoBlacklist: {
videos: {
ofUsers: {
enabled: false
}
}
},
followers: {
instance: {
enabled: true,
manualApproval: false
}
},
followings: {
instance: {
autoFollowBack: {
enabled: false
},
autoFollowIndex: {
indexUrl: 'https://instances.joinpeertube.org/api/v1/instances/hosts',
enabled: false
}
}
},
broadcastMessage: {
enabled: true,
level: 'warning',
message: 'hello',
dismissable: true
},
search: {
remoteUri: {
users: true,
anonymous: true
},
searchIndex: {
enabled: true,
url: 'https://search.joinpeertube.org',
disableLocalSearch: true,
isDefaultSearch: true
}
}
}
merge(newCustomConfig, options.newConfig)
return this.updateCustomConfig({ ...options, newCustomConfig })
}
}

View File

@ -1,260 +0,0 @@
import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
import { CustomConfig } from '../../models/server/custom-config.model'
import { DeepPartial, HttpStatusCode } from '@shared/core-utils'
import { merge } from 'lodash'
function getConfig (url: string) {
const path = '/api/v1/config'
return makeGetRequest({
url,
path,
statusCodeExpected: HttpStatusCode.OK_200
})
}
function getAbout (url: string) {
const path = '/api/v1/config/about'
return makeGetRequest({
url,
path,
statusCodeExpected: HttpStatusCode.OK_200
})
}
function getCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) {
const path = '/api/v1/config/custom'
return makeGetRequest({
url,
token,
path,
statusCodeExpected
})
}
function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = HttpStatusCode.OK_200) {
const path = '/api/v1/config/custom'
return makePutBodyRequest({
url,
token,
path,
fields: newCustomConfig,
statusCodeExpected
})
}
function updateCustomSubConfig (url: string, token: string, newConfig: DeepPartial<CustomConfig>) {
const updateParams: CustomConfig = {
instance: {
name: 'PeerTube updated',
shortDescription: 'my short description',
description: 'my super description',
terms: 'my super terms',
codeOfConduct: 'my super coc',
creationReason: 'my super creation reason',
moderationInformation: 'my super moderation information',
administrator: 'Kuja',
maintenanceLifetime: 'forever',
businessModel: 'my super business model',
hardwareInformation: '2vCore 3GB RAM',
languages: [ 'en', 'es' ],
categories: [ 1, 2 ],
isNSFW: true,
defaultNSFWPolicy: 'blur',
defaultClientRoute: '/videos/recently-added',
customizations: {
javascript: 'alert("coucou")',
css: 'body { background-color: red; }'
}
},
theme: {
default: 'default'
},
services: {
twitter: {
username: '@MySuperUsername',
whitelisted: true
}
},
cache: {
previews: {
size: 2
},
captions: {
size: 3
},
torrents: {
size: 4
}
},
signup: {
enabled: false,
limit: 5,
requiresEmailVerification: false,
minimumAge: 16
},
admin: {
email: 'superadmin1@example.com'
},
contactForm: {
enabled: true
},
user: {
videoQuota: 5242881,
videoQuotaDaily: 318742
},
transcoding: {
enabled: true,
allowAdditionalExtensions: true,
allowAudioFiles: true,
threads: 1,
concurrency: 3,
profile: 'default',
resolutions: {
'0p': false,
'240p': false,
'360p': true,
'480p': true,
'720p': false,
'1080p': false,
'1440p': false,
'2160p': false
},
webtorrent: {
enabled: true
},
hls: {
enabled: false
}
},
live: {
enabled: true,
allowReplay: false,
maxDuration: -1,
maxInstanceLives: -1,
maxUserLives: 50,
transcoding: {
enabled: true,
threads: 4,
profile: 'default',
resolutions: {
'240p': true,
'360p': true,
'480p': true,
'720p': true,
'1080p': true,
'1440p': true,
'2160p': true
}
}
},
import: {
videos: {
concurrency: 3,
http: {
enabled: false
},
torrent: {
enabled: false
}
}
},
trending: {
videos: {
algorithms: {
enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ],
default: 'hot'
}
}
},
autoBlacklist: {
videos: {
ofUsers: {
enabled: false
}
}
},
followers: {
instance: {
enabled: true,
manualApproval: false
}
},
followings: {
instance: {
autoFollowBack: {
enabled: false
},
autoFollowIndex: {
indexUrl: 'https://instances.joinpeertube.org/api/v1/instances/hosts',
enabled: false
}
}
},
broadcastMessage: {
enabled: true,
level: 'warning',
message: 'hello',
dismissable: true
},
search: {
remoteUri: {
users: true,
anonymous: true
},
searchIndex: {
enabled: true,
url: 'https://search.joinpeertube.org',
disableLocalSearch: true,
isDefaultSearch: true
}
}
}
merge(updateParams, newConfig)
return updateCustomConfig(url, token, updateParams)
}
function getCustomConfigResolutions (enabled: boolean) {
return {
'240p': enabled,
'360p': enabled,
'480p': enabled,
'720p': enabled,
'1080p': enabled,
'1440p': enabled,
'2160p': enabled
}
}
function deleteCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) {
const path = '/api/v1/config/custom'
return makeDeleteRequest({
url,
token,
path,
statusCodeExpected
})
}
// ---------------------------------------------------------------------------
export {
getConfig,
getCustomConfig,
updateCustomConfig,
getAbout,
deleteCustomConfig,
updateCustomSubConfig,
getCustomConfigResolutions
}

View File

@ -1,4 +1,4 @@
export * from './config'
export * from './config-command'
export * from './contact-form-command'
export * from './debug-command'
export * from './follows-command'

View File

@ -16,6 +16,7 @@ import { AbusesCommand } from '../moderation'
import { OverviewsCommand } from '../overviews'
import { makeGetRequest } from '../requests/requests'
import { SearchCommand } from '../search'
import { ConfigCommand } from './config-command'
import { ContactFormCommand } from './contact-form-command'
import { DebugCommand } from './debug-command'
import { FollowsCommand } from './follows-command'
@ -91,6 +92,7 @@ interface ServerInfo {
pluginsCommand?: PluginsCommand
redundancyCommand?: RedundancyCommand
statsCommand?: StatsCommand
configCommand?: ConfigCommand
}
function parallelTests () {
@ -311,6 +313,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
server.pluginsCommand = new PluginsCommand(server)
server.redundancyCommand = new RedundancyCommand(server)
server.statsCommand = new StatsCommand(server)
server.configCommand = new ConfigCommand(server)
res(server)
})