Introduce config command

This commit is contained in:
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, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
stopFfmpeg, stopFfmpeg,
updateCustomSubConfig,
updateLive, updateLive,
uploadVideoAndGetId, uploadVideoAndGetId,
userLogin, userLogin,
@ -43,12 +42,14 @@ describe('Test video lives API validator', function () {
await setAccessTokensToServers([ server ]) await setAccessTokensToServers([ server ])
await updateCustomSubConfig(server.url, server.accessToken, { await server.configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
maxInstanceLives: 20, enabled: true,
maxUserLives: 20, maxInstanceLives: 20,
allowReplay: true maxUserLives: 20,
allowReplay: true
}
} }
}) })
@ -234,9 +235,11 @@ describe('Test video lives API validator', function () {
}) })
it('Should forbid if live is disabled', async function () { it('Should forbid if live is disabled', async function () {
await updateCustomSubConfig(server.url, server.accessToken, { await server.configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: false 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 () { it('Should forbid to save replay if not enabled by the admin', async function () {
const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
await updateCustomSubConfig(server.url, server.accessToken, { await server.configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: false 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 () { it('Should allow to save replay if enabled by the admin', async function () {
const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
await updateCustomSubConfig(server.url, server.accessToken, { await server.configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: true 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 () { it('Should not allow live if max instance lives is reached', async function () {
await updateCustomSubConfig(server.url, server.accessToken, { await server.configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
maxInstanceLives: 1 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 () { it('Should not allow live if max user lives is reached', async function () {
await updateCustomSubConfig(server.url, server.accessToken, { await server.configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
maxInstanceLives: 20, enabled: true,
maxUserLives: 1 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 () { it('Should fail to update replay status if replay is not allowed on the instance', async function () {
await updateCustomSubConfig(server.url, server.accessToken, { await server.configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: false enabled: true,
allowReplay: false
}
} }
}) })

View File

@ -1,28 +1,27 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha' import 'mocha'
import { HttpStatusCode } from '@shared/core-utils'
import { import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination,
cleanupTests, cleanupTests,
flushAndRunServer, flushAndRunServer,
immutableAssign, immutableAssign,
makeGetRequest, makeGetRequest,
ServerInfo, ServerInfo,
updateCustomSubConfig,
setAccessTokensToServers setAccessTokensToServers
} from '../../../../shared/extra-utils' } 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'
function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) { function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
return updateCustomSubConfig(server.url, server.accessToken, { return server.configCommand.updateCustomSubConfig({
search: { newConfig: {
searchIndex: { search: {
enabled, searchIndex: {
disableLocalSearch enabled,
disableLocalSearch
}
} }
} }
}) })

View File

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

View File

@ -6,17 +6,16 @@ import { VideoDetails, VideoPrivacy } from '@shared/models'
import { import {
checkLiveCleanup, checkLiveCleanup,
cleanupTests, cleanupTests,
ConfigCommand,
createLive, createLive,
doubleFollow, doubleFollow,
flushAndRunMultipleServers, flushAndRunMultipleServers,
generateUser, generateUser,
getCustomConfigResolutions,
getVideo, getVideo,
runAndTestFfmpegStreamError, runAndTestFfmpegStreamError,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
setDefaultVideoChannel, setDefaultVideoChannel,
updateCustomSubConfig,
updateUser, updateUser,
wait, wait,
waitJobs, waitJobs,
@ -80,12 +79,14 @@ describe('Test live constraints', function () {
await setAccessTokensToServers(servers) await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers) await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { await servers[0].configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: true, enabled: true,
transcoding: { allowReplay: true,
enabled: false transcoding: {
enabled: false
}
} }
} }
}) })
@ -157,14 +158,16 @@ describe('Test live constraints', function () {
it('Should have max duration limit', async function () { it('Should have max duration limit', async function () {
this.timeout(60000) this.timeout(60000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { await servers[0].configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: true,
maxDuration: 1,
transcoding: {
enabled: true, 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 { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
import { import {
cleanupTests, cleanupTests,
ConfigCommand,
createLive, createLive,
doubleFollow, doubleFollow,
flushAndRunMultipleServers, flushAndRunMultipleServers,
getCustomConfigResolutions,
getLive, getLive,
getPlaylistsCount, getPlaylistsCount,
getVideo, getVideo,
@ -17,7 +17,6 @@ import {
setAccessTokensToServers, setAccessTokensToServers,
setDefaultVideoChannel, setDefaultVideoChannel,
stopFfmpeg, stopFfmpeg,
updateCustomSubConfig,
updateLive, updateLive,
wait, wait,
waitJobs, waitJobs,
@ -63,14 +62,16 @@ describe('Permanent live', function () {
// Server 1 and server 2 follow each other // Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1]) await doubleFollow(servers[0], servers[1])
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { await servers[0].configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true, 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 () { it('Should be able to stream again in the permanent live', async function () {
this.timeout(20000) this.timeout(20000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { await servers[0].configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true, enabled: true,
resolutions: getCustomConfigResolutions(false) allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(false)
}
} }
} }
}) })

View File

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

View File

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

View File

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

View File

@ -34,7 +34,6 @@ import {
stopFfmpeg, stopFfmpeg,
testFfmpegStreamError, testFfmpegStreamError,
testImage, testImage,
updateCustomSubConfig,
updateLive, updateLive,
uploadVideoAndGetId, uploadVideoAndGetId,
wait, wait,
@ -59,12 +58,14 @@ describe('Test live', function () {
await setAccessTokensToServers(servers) await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers) await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { await servers[0].configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: true, enabled: true,
transcoding: { allowReplay: true,
enabled: false transcoding: {
enabled: false
}
} }
} }
}) })
@ -422,20 +423,22 @@ describe('Test live', function () {
} }
function updateConf (resolutions: number[]) { function updateConf (resolutions: number[]) {
return updateCustomSubConfig(servers[0].url, servers[0].accessToken, { return servers[0].configCommand.updateCustomSubConfig({
live: { newConfig: {
enabled: true, live: {
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true, enabled: true,
resolutions: { allowReplay: true,
'240p': resolutions.includes(240), maxDuration: -1,
'360p': resolutions.includes(360), transcoding: {
'480p': resolutions.includes(480), enabled: true,
'720p': resolutions.includes(720), resolutions: {
'1080p': resolutions.includes(1080), '240p': resolutions.includes(240),
'2160p': resolutions.includes(2160) '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, createUser,
generateUserAccessToken, generateUserAccessToken,
getAccount, getAccount,
getCustomConfig,
getVideoCommentThreads, getVideoCommentThreads,
getVideoIdFromUUID, getVideoIdFromUUID,
immutableAssign, immutableAssign,
@ -34,8 +33,6 @@ import {
removeUserSubscription, removeUserSubscription,
removeVideoFromBlacklist, removeVideoFromBlacklist,
ServerInfo, ServerInfo,
updateCustomConfig,
updateCustomSubConfig,
uploadVideo, uploadVideo,
wait, wait,
waitJobs 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 ] }) 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') await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence')
config.followings.instance.autoFollowBack.enabled = false 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[0].followsCommand.unfollow({ target: servers[2] })
await servers[2].followsCommand.unfollow({ target: servers[0] }) await servers[2].followsCommand.unfollow({ target: servers[0] })
}) })
@ -430,7 +427,7 @@ describe('Test moderation notifications', function () {
this.timeout(30000) this.timeout(30000)
await servers[0].followsCommand.unfollow({ target: servers[1] }) 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 wait(5000)
await waitJobs(servers) await waitJobs(servers)
@ -440,7 +437,7 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
config.followings.instance.autoFollowIndex.enabled = false 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] }) await servers[0].followsCommand.unfollow({ target: servers[1] })
}) })
}) })
@ -476,8 +473,8 @@ describe('Test moderation notifications', function () {
token: userAccessToken token: userAccessToken
} }
const resCustomConfig = await getCustomConfig(servers[0].url, servers[0].accessToken) currentCustomConfig = await servers[0].configCommand.getCustomConfig()
currentCustomConfig = resCustomConfig.body
const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, { const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, {
autoBlacklist: { autoBlacklist: {
videos: { videos: {
@ -487,9 +484,10 @@ describe('Test moderation notifications', function () {
} }
} }
}) })
// enable transcoding otherwise own publish notification after transcoding not expected // enable transcoding otherwise own publish notification after transcoding not expected
autoBlacklistTestsCustomConfig.transcoding.enabled = true 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[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) 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 () => { 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[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) await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)

View File

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

View File

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

View File

@ -8,7 +8,6 @@ import {
MockInstancesIndex, MockInstancesIndex,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
updateCustomSubConfig,
wait, wait,
waitJobs waitJobs
} from '@shared/extra-utils' } 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) 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) await server1Follows2(servers)
@ -129,7 +128,7 @@ describe('Test auto follows', function () {
config.followings.instance.autoFollowBack.enabled = false config.followings.instance.autoFollowBack.enabled = false
config.followers.instance.manualApproval = 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 wait(5000)
await waitJobs(servers) await waitJobs(servers)

View File

@ -2,15 +2,10 @@
import 'mocha' import 'mocha'
import * as chai from 'chai' import * as chai from 'chai'
import { About } from '../../../../shared/models/server/about.model' import { HttpStatusCode } from '@shared/core-utils'
import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
import { import {
cleanupTests, cleanupTests,
deleteCustomConfig,
flushAndRunServer, flushAndRunServer,
getAbout,
getConfig,
getCustomConfig,
killallServers, killallServers,
makeGetRequest, makeGetRequest,
parallelTests, parallelTests,
@ -18,11 +13,9 @@ import {
reRunServer, reRunServer,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
updateCustomConfig,
uploadVideo uploadVideo
} from '../../../../shared/extra-utils' } from '@shared/extra-utils'
import { ServerConfig } from '../../../../shared/models' import { CustomConfig } from '@shared/models'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect const expect = chai.expect
@ -213,7 +206,7 @@ function checkUpdatedConfig (data: CustomConfig) {
} }
describe('Test config', function () { describe('Test config', function () {
let server = null let server: ServerInfo = null
before(async function () { before(async function () {
this.timeout(30000) 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 () { it('Should have a correct config on a server with registration enabled', async function () {
const res = await getConfig(server.url) const data = await server.configCommand.getConfig()
const data: ServerConfig = res.body
expect(data.signup.allowed).to.be.true expect(data.signup.allowed).to.be.true
}) })
@ -238,15 +230,13 @@ describe('Test config', function () {
registerUser(server.url, 'user3', 'super password') registerUser(server.url, 'user3', 'super password')
]) ])
const res = await getConfig(server.url) const data = await server.configCommand.getConfig()
const data: ServerConfig = res.body
expect(data.signup.allowed).to.be.false expect(data.signup.allowed).to.be.false
}) })
it('Should have the correct video allowed extensions', async function () { it('Should have the correct video allowed extensions', async function () {
const res = await getConfig(server.url) const data = await server.configCommand.getConfig()
const data: ServerConfig = res.body
expect(data.video.file.extensions).to.have.lengthOf(3) expect(data.video.file.extensions).to.have.lengthOf(3)
expect(data.video.file.extensions).to.contain('.mp4') expect(data.video.file.extensions).to.contain('.mp4')
@ -260,8 +250,7 @@ describe('Test config', function () {
}) })
it('Should get the customized configuration', async function () { it('Should get the customized configuration', async function () {
const res = await getCustomConfig(server.url, server.accessToken) const data = await server.configCommand.getCustomConfig()
const data = res.body as CustomConfig
checkInitialConfig(server, data) checkInitialConfig(server, data)
}) })
@ -438,19 +427,16 @@ describe('Test config', function () {
} }
} }
} }
await updateCustomConfig(server.url, server.accessToken, newCustomConfig) await server.configCommand.updateCustomConfig({ newCustomConfig })
const res = await getCustomConfig(server.url, server.accessToken)
const data = res.body
const data = await server.configCommand.getCustomConfig()
checkUpdatedConfig(data) checkUpdatedConfig(data)
}) })
it('Should have the correct updated video allowed extensions', async function () { it('Should have the correct updated video allowed extensions', async function () {
this.timeout(10000) this.timeout(10000)
const res = await getConfig(server.url) const data = await server.configCommand.getConfig()
const data: ServerConfig = res.body
expect(data.video.file.extensions).to.have.length.above(4) expect(data.video.file.extensions).to.have.length.above(4)
expect(data.video.file.extensions).to.contain('.mp4') expect(data.video.file.extensions).to.contain('.mp4')
@ -474,15 +460,13 @@ describe('Test config', function () {
await reRunServer(server) await reRunServer(server)
const res = await getCustomConfig(server.url, server.accessToken) const data = await server.configCommand.getCustomConfig()
const data = res.body
checkUpdatedConfig(data) checkUpdatedConfig(data)
}) })
it('Should fetch the about information', async function () { it('Should fetch the about information', async function () {
const res = await getAbout(server.url) const data = await server.configCommand.getAbout()
const data: About = res.body
expect(data.instance.name).to.equal('PeerTube updated') expect(data.instance.name).to.equal('PeerTube updated')
expect(data.instance.shortDescription).to.equal('my short description') 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 () { it('Should remove the custom configuration', async function () {
this.timeout(10000) this.timeout(10000)
await deleteCustomConfig(server.url, server.accessToken) await server.configCommand.deleteCustomConfig()
const res = await getCustomConfig(server.url, server.accessToken)
const data = res.body
const data = await server.configCommand.getCustomConfig()
checkInitialConfig(server, data) checkInitialConfig(server, data)
}) })

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,6 @@ import {
flushAndRunServer, flushAndRunServer,
getAccountRatings, getAccountRatings,
getBlacklistedVideosList, getBlacklistedVideosList,
getCustomConfig,
getMyUserInformation, getMyUserInformation,
getMyUserVideoQuotaUsed, getMyUserVideoQuotaUsed,
getMyUserVideoRating, getMyUserVideoRating,
@ -38,7 +37,6 @@ import {
setTokenField, setTokenField,
testImage, testImage,
unblockUser, unblockUser,
updateCustomSubConfig,
updateMyAvatar, updateMyAvatar,
updateMyUser, updateMyUser,
updateUser, updateUser,
@ -46,7 +44,7 @@ import {
userLogin, userLogin,
waitJobs waitJobs
} from '@shared/extra-utils' } 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 const expect = chai.expect
@ -418,12 +416,11 @@ describe('Test users', function () {
this.timeout(60000) this.timeout(60000)
{ {
const res = await getCustomConfig(server.url, server.accessToken) const config = await server.configCommand.getCustomConfig()
const config = res.body as CustomConfig
config.transcoding.webtorrent.enabled = false config.transcoding.webtorrent.enabled = false
config.transcoding.hls.enabled = true config.transcoding.hls.enabled = true
config.transcoding.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, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
setDefaultVideoChannel, setDefaultVideoChannel,
updateCustomSubConfig,
uploadVideo, uploadVideo,
userLogin userLogin
} from '../../../../shared/extra-utils' } from '../../../../shared/extra-utils'
@ -58,12 +57,14 @@ describe('Test video change ownership - nominal', function () {
await setAccessTokensToServers(servers) await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers) await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { await servers[0].configCommand.updateCustomSubConfig({
transcoding: { newConfig: {
enabled: false transcoding: {
}, enabled: false
live: { },
enabled: true live: {
enabled: true
}
} }
}) })

View File

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

View File

@ -14,8 +14,7 @@ import {
listVideoCaptions, listVideoCaptions,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
testCaptionFile, testCaptionFile
updateCustomSubConfig
} from '../../../../shared/extra-utils' } from '../../../../shared/extra-utils'
import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs' import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 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 = { const attributes = {
name: 'hdr video', name: 'hdr video',

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ import 'mocha'
import * as chai from 'chai' import * as chai from 'chai'
import { omit } from 'lodash' import { omit } from 'lodash'
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 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 { import {
addVideoInPlaylist, addVideoInPlaylist,
cleanupTests, cleanupTests,
@ -12,16 +12,12 @@ import {
doubleFollow, doubleFollow,
flushAndRunMultipleServers, flushAndRunMultipleServers,
getAccount, getAccount,
getConfig,
getCustomConfig,
getVideosList, getVideosList,
makeGetRequest, makeGetRequest,
makeHTMLRequest, makeHTMLRequest,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
setDefaultVideoChannel, setDefaultVideoChannel,
updateCustomConfig,
updateCustomSubConfig,
updateMyUser, updateMyUser,
updateVideoChannel, updateVideoChannel,
uploadVideo, uploadVideo,
@ -307,14 +303,13 @@ describe('Test a client controllers', function () {
describe('Whitelisted', function () { describe('Whitelisted', function () {
before(async function () { before(async function () {
const res = await getCustomConfig(servers[0].url, servers[0].accessToken) const config = await servers[0].configCommand.getCustomConfig()
const config = res.body as CustomConfig
config.services.twitter = { config.services.twitter = {
username: '@Kuja', username: '@Kuja',
whitelisted: true whitelisted: true
} }
await updateCustomConfig(servers[0].url, servers[0].accessToken, config) await servers[0].configCommand.updateCustomConfig({ newCustomConfig: config })
}) })
async function accountPageTest (path: string) { async function accountPageTest (path: string) {
@ -382,40 +377,42 @@ describe('Test a client controllers', function () {
describe('Index HTML', function () { describe('Index HTML', function () {
it('Should have valid index html tags (title, description...)', async 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 res = await makeHTMLRequest(servers[0].url, '/videos/trending')
const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' 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 () { it('Should update the customized configuration and have the correct index html tags', async function () {
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { await servers[0].configCommand.updateCustomSubConfig({
instance: { newConfig: {
name: 'PeerTube updated', instance: {
shortDescription: 'my short description', name: 'PeerTube updated',
description: 'my super description', shortDescription: 'my short description',
terms: 'my super terms', description: 'my super description',
defaultNSFWPolicy: 'blur', terms: 'my super terms',
defaultClientRoute: '/videos/recently-added', defaultNSFWPolicy: 'blur',
customizations: { defaultClientRoute: '/videos/recently-added',
javascript: 'alert("coucou")', customizations: {
css: 'body { background-color: red; }' 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') 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 () { 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') 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 () { 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 () { 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" />`) 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 () { 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" />`) 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 () { describe('Embed HTML', function () {
it('Should have the correct embed html tags', async 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) 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, createUser,
decodeQueryString, decodeQueryString,
flushAndRunServer, flushAndRunServer,
getConfig,
getMyUserInformation, getMyUserInformation,
loginUsingExternalToken, loginUsingExternalToken,
logout, logout,
@ -21,7 +20,7 @@ import {
wait, wait,
waitUntilLog waitUntilLog
} from '@shared/extra-utils' } from '@shared/extra-utils'
import { ServerConfig, User, UserRole } from '@shared/models' import { User, UserRole } from '@shared/models'
async function loginExternal (options: { async function loginExternal (options: {
server: ServerInfo server: ServerInfo
@ -78,9 +77,7 @@ describe('Test external auth plugins', function () {
}) })
it('Should display the correct configuration', async function () { it('Should display the correct configuration', async function () {
const res = await getConfig(server.url) const config = await server.configCommand.getConfig()
const config: ServerConfig = res.body
const auths = config.plugin.registeredExternalAuths const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(8) expect(auths).to.have.lengthOf(8)
@ -288,9 +285,7 @@ describe('Test external auth plugins', function () {
}) })
it('Should have disabled this auth', async function () { it('Should have disabled this auth', async function () {
const res = await getConfig(server.url) const config = await server.configCommand.getConfig()
const config: ServerConfig = res.body
const auths = config.plugin.registeredExternalAuths const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(7) expect(auths).to.have.lengthOf(7)
@ -354,9 +349,7 @@ describe('Test external auth plugins', function () {
}) })
it('Should display the correct configuration', async function () { it('Should display the correct configuration', async function () {
const res = await getConfig(server.url) const config = await server.configCommand.getConfig()
const config: ServerConfig = res.body
const auths = config.plugin.registeredExternalAuths const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(6) expect(auths).to.have.lengthOf(6)

View File

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

View File

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

View File

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

View File

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