ServerInfo,
setAccessTokensToServers,
stopFfmpeg,
- updateCustomSubConfig,
updateLive,
uploadVideoAndGetId,
userLogin,
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
+ }
}
})
})
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
+ }
}
})
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
+ }
}
})
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
+ }
}
})
})
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
+ }
}
})
})
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
+ }
}
})
})
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
+ }
}
})
/* 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
+ }
}
}
})
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,
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'
})
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
+ }
}
}
}
})
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
+ }
}
}
}
import {
checkLiveCleanup,
cleanupTests,
+ ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
generateUser,
- getCustomConfigResolutions,
getVideo,
runAndTestFfmpegStreamError,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
- updateCustomSubConfig,
updateUser,
wait,
waitJobs,
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
+ }
}
}
})
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)
+ }
}
}
})
import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
import {
cleanupTests,
+ ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
- getCustomConfigResolutions,
getLive,
getPlaylistsCount,
getVideo,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
- updateCustomSubConfig,
updateLive,
wait,
waitJobs,
// 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)
+ }
}
}
})
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)
+ }
}
}
})
addVideoToBlacklist,
checkLiveCleanup,
cleanupTests,
+ ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
- getCustomConfigResolutions,
getVideo,
getVideosList,
removeVideo,
setDefaultVideoChannel,
stopFfmpeg,
testFfmpegStreamError,
- updateCustomSubConfig,
updateVideo,
wait,
waitJobs,
// 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)
+ }
}
}
})
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
- updateCustomSubConfig,
viewVideo,
wait,
waitJobs,
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
+ }
}
}
})
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
- updateCustomSubConfig,
viewVideo,
wait,
waitJobs,
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
+ }
}
}
})
stopFfmpeg,
testFfmpegStreamError,
testImage,
- updateCustomSubConfig,
updateLive,
uploadVideoAndGetId,
wait,
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
+ }
}
}
})
}
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)
+ }
}
}
}
createUser,
generateUserAccessToken,
getAccount,
- getCustomConfig,
getVideoCommentThreads,
getVideoIdFromUUID,
immutableAssign,
removeUserSubscription,
removeVideoFromBlacklist,
ServerInfo,
- updateCustomConfig,
- updateCustomSubConfig,
uploadVideo,
wait,
waitJobs
}
}
}
- 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 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] })
})
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)
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] })
})
})
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: {
}
}
})
+
// 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)
})
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)
SearchCommand,
ServerInfo,
setAccessTokensToServers,
- updateCustomSubConfig,
uploadVideo
} from '@shared/extra-utils'
import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
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
+ }
}
}
})
})
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
+ }
}
}
})
})
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
+ }
}
}
})
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)
}
{
- 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' })
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
- updateCustomSubConfig,
uploadVideo,
wait,
waitUntilLivePublished
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 })
}
{
MockInstancesIndex,
ServerInfo,
setAccessTokensToServers,
- updateCustomSubConfig,
wait,
waitJobs
} from '@shared/extra-utils'
}
}
}
- await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
+ await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
}
}
}
- await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
+ await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
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 })
})
})
}
}
}
- await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
+ await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
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,
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
}
describe('Test config', function () {
- let server = null
+ let server: ServerInfo = null
before(async function () {
this.timeout(30000)
})
it('Should have a correct config on a server with registration enabled', async function () {
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.signup.allowed).to.be.true
})
registerUser(server.url, 'user3', 'super password')
])
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.signup.allowed).to.be.false
})
it('Should have the correct video allowed extensions', async function () {
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.video.file.extensions).to.have.lengthOf(3)
expect(data.video.file.extensions).to.contain('.mp4')
})
it('Should get the customized configuration', async function () {
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body as CustomConfig
+ const data = await server.configCommand.getCustomConfig()
checkInitialConfig(server, data)
})
}
}
}
- await updateCustomConfig(server.url, server.accessToken, newCustomConfig)
-
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body
+ await server.configCommand.updateCustomConfig({ newCustomConfig })
+ const data = await server.configCommand.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should have the correct updated video allowed extensions', async function () {
this.timeout(10000)
- const res = await getConfig(server.url)
- const data: ServerConfig = res.body
+ const data = await server.configCommand.getConfig()
expect(data.video.file.extensions).to.have.length.above(4)
expect(data.video.file.extensions).to.contain('.mp4')
await reRunServer(server)
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body
+ const data = await server.configCommand.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should fetch the about information', async function () {
- const res = await getAbout(server.url)
- const data: About = res.body
+ const data = await server.configCommand.getAbout()
expect(data.instance.name).to.equal('PeerTube updated')
expect(data.instance.shortDescription).to.equal('my short description')
it('Should remove the custom configuration', async function () {
this.timeout(10000)
- await deleteCustomConfig(server.url, server.accessToken)
-
- const res = await getCustomConfig(server.url, server.accessToken)
- const data = res.body
+ await server.configCommand.deleteCustomConfig()
+ const data = await server.configCommand.getCustomConfig()
checkInitialConfig(server, data)
})
FollowsCommand,
ServerInfo,
setAccessTokensToServers,
- updateCustomSubConfig,
waitJobs
} from '@shared/extra-utils'
}
}
- 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)
}
}
- 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)
}
}
- 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)
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,
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
}
cleanupTests,
closeAllSequelize,
flushAndRunServer,
- getConfig,
getMyUserInformation,
killallServers,
PluginsCommand,
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
})
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
})
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')
})
})
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')
flushAndRunMultipleServers,
ServerInfo,
setAccessTokensToServers,
- updateCustomSubConfig,
uploadVideo,
userLogin,
viewVideo,
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
+ }
}
}
})
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
+ }
}
})
login,
registerUser,
ServerInfo,
- updateCustomSubConfig,
updateMyUser,
userLogin,
verifyEmail
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
+ }
}
})
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
+ }
}
})
})
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
+ }
}
})
flushAndRunServer,
getAccountRatings,
getBlacklistedVideosList,
- getCustomConfig,
getMyUserInformation,
getMyUserVideoQuotaUsed,
getMyUserVideoRating,
setTokenField,
testImage,
unblockUser,
- updateCustomSubConfig,
updateMyAvatar,
updateMyUser,
updateUser,
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
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 })
}
{
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
- updateCustomSubConfig,
uploadVideo,
userLogin
} from '../../../../shared/extra-utils'
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
+ }
}
})
import 'mocha'
import * as chai from 'chai'
import { join } from 'path'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
checkDirectoryIsEmpty,
checkResolutionsInMasterPlaylist,
removeVideo,
ServerInfo,
setAccessTokensToServers,
- updateCustomSubConfig,
updateVideo,
uploadVideo,
waitJobs,
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
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
+ }
}
}
})
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'
}
}
}
- await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
+ await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
const attributes = {
name: 'hdr video',
createUser,
flushAndRunServer,
getAccountVideos,
- getConfig,
- getCustomConfig,
getMyUserInformation,
getMyVideos,
getVideoChannelVideos,
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
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()) {
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()) {
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()) {
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)
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 {
makeGetRequest,
ServerInfo,
setAccessTokensToServers,
- updateCustomSubConfig,
uploadVideo,
uploadVideoAndGetId,
waitJobs,
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
+ }
}
}
})
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
+ }
}
}
})
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
+ }
}
}
})
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: {
hls: { enabled: true }
}
}
- await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
+ await servers[1].configCommand.updateCustomSubConfig({ newConfig })
const videoAttributes = {
name: 'low bitrate',
getVideosList,
ServerInfo,
setAccessTokensToServers,
- updateCustomSubConfig,
uploadVideo
} from '../../../shared/extra-utils'
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
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])
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]}`)
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
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')
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')
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,
doubleFollow,
flushAndRunMultipleServers,
getAccount,
- getConfig,
- getCustomConfig,
getVideosList,
makeGetRequest,
makeHTMLRequest,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
- updateCustomConfig,
- updateCustomSubConfig,
updateMyUser,
updateVideoChannel,
uploadVideo,
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) {
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 () {
})
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" />`)
}
})
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" />`)
}
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)
})
})
createUser,
decodeQueryString,
flushAndRunServer,
- getConfig,
getMyUserInformation,
loginUsingExternalToken,
logout,
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
})
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)
})
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)
})
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)
doubleFollow,
flushAndRunMultipleServers,
getAccountVideos,
- getConfig,
getMyVideos,
getVideo,
getVideoChannelVideos,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
- updateCustomSubConfig,
updateVideo,
uploadVideo,
uploadVideoAndGetId,
} from '@shared/extra-utils'
import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports'
import {
- ServerConfig,
VideoCommentThreadTree,
VideoDetails,
VideoImport,
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 }
+ }
}
}
})
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 () {
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
+ }
}
}
})
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
+ }
}
})
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
+ }
}
}
})
import {
cleanupTests,
flushAndRunServer,
- getConfig,
getMyUserInformation,
getUsersList,
login,
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
})
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)
})
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)
})
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)
cleanupTests,
createLive,
flushAndRunServer,
- getConfig,
getVideo,
PluginsCommand,
sendRTMPStreamInVideo,
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 = {
}
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
+ }
+ }
}
}
})
})
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' ])
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' ])
--- /dev/null
+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 })
+ }
+}
+++ /dev/null
-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
-}
-export * from './config'
+export * from './config-command'
export * from './contact-form-command'
export * from './debug-command'
export * from './follows-command'
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'
pluginsCommand?: PluginsCommand
redundancyCommand?: RedundancyCommand
statsCommand?: StatsCommand
+ configCommand?: ConfigCommand
}
function parallelTests () {
server.pluginsCommand = new PluginsCommand(server)
server.redundancyCommand = new RedundancyCommand(server)
server.statsCommand = new StatsCommand(server)
+ server.configCommand = new ConfigCommand(server)
res(server)
})