Verified Commit 65e6e260 authored by Chocobozzz's avatar Chocobozzz
Browse files

Introduce config command

parent bc809041
......@@ -19,7 +19,6 @@ import {
ServerInfo,
setAccessTokensToServers,
stopFfmpeg,
updateCustomSubConfig,
updateLive,
uploadVideoAndGetId,
userLogin,
......@@ -43,12 +42,14 @@ describe('Test video lives API validator', function () {
await setAccessTokensToServers([ server ])
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 20,
allowReplay: true
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 20,
allowReplay: true
}
}
})
......@@ -234,9 +235,11 @@ describe('Test video lives API validator', function () {
})
it('Should forbid if live is disabled', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: false
}
}
})
......@@ -252,10 +255,12 @@ describe('Test video lives API validator', function () {
it('Should forbid to save replay if not enabled by the admin', async function () {
const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
allowReplay: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: false
}
}
})
......@@ -271,10 +276,12 @@ describe('Test video lives API validator', function () {
it('Should allow to save replay if enabled by the admin', async function () {
const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
allowReplay: true
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true
}
}
})
......@@ -288,10 +295,12 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max instance lives is reached', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
maxInstanceLives: 1
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
maxInstanceLives: 1
}
}
})
......@@ -305,11 +314,13 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max user lives is reached', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 1
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
maxInstanceLives: 20,
maxUserLives: 1
}
}
})
......@@ -393,10 +404,12 @@ describe('Test video lives API validator', function () {
})
it('Should fail to update replay status if replay is not allowed on the instance', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
live: {
enabled: true,
allowReplay: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: false
}
}
})
......
/* 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
}
}
}
})
......
......@@ -2,9 +2,12 @@
import 'mocha'
import { omit } from 'lodash'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import { HttpStatusCode } from '@shared/core-utils'
import {
buildAbsoluteFixturePath,
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination,
cleanupTests,
createUser,
flushAndRunServer,
......@@ -15,16 +18,10 @@ import {
makeUploadRequest,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
userLogin
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
import { getGoodVideoUrl, getMagnetURI } from '../../../../shared/extra-utils/videos/video-imports'
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
} from '@shared/extra-utils'
import { getGoodVideoUrl, getMagnetURI } from '@shared/extra-utils/videos/video-imports'
import { VideoPrivacy } from '@shared/models'
describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
......@@ -263,14 +260,16 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import http videos', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
import: {
videos: {
http: {
enabled: false
},
torrent: {
enabled: true
await server.configCommand.updateCustomSubConfig({
newConfig: {
import: {
videos: {
http: {
enabled: false
},
torrent: {
enabled: true
}
}
}
}
......@@ -286,14 +285,16 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import torrent videos', async function () {
await updateCustomSubConfig(server.url, server.accessToken, {
import: {
videos: {
http: {
enabled: true
},
torrent: {
enabled: false
await server.configCommand.updateCustomSubConfig({
newConfig: {
import: {
videos: {
http: {
enabled: true
},
torrent: {
enabled: false
}
}
}
}
......
......@@ -6,17 +6,16 @@ import { VideoDetails, VideoPrivacy } from '@shared/models'
import {
checkLiveCleanup,
cleanupTests,
ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
generateUser,
getCustomConfigResolutions,
getVideo,
runAndTestFfmpegStreamError,
ServerInfo,
setAccessTokensToServers,
setDefaultVideoChannel,
updateCustomSubConfig,
updateUser,
wait,
waitJobs,
......@@ -80,12 +79,14 @@ describe('Test live constraints', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
......@@ -157,14 +158,16 @@ describe('Test live constraints', function () {
it('Should have max duration limit', async function () {
this.timeout(60000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: 1,
transcoding: {
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: getCustomConfigResolutions(true)
allowReplay: true,
maxDuration: 1,
transcoding: {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(true)
}
}
}
})
......
......@@ -5,10 +5,10 @@ import * as chai from 'chai'
import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
import {
cleanupTests,
ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
getCustomConfigResolutions,
getLive,
getPlaylistsCount,
getVideo,
......@@ -17,7 +17,6 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
updateCustomSubConfig,
updateLive,
wait,
waitJobs,
......@@ -63,14 +62,16 @@ describe('Permanent live', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: getCustomConfigResolutions(true)
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(true)
}
}
}
})
......@@ -145,14 +146,16 @@ describe('Permanent live', function () {
it('Should be able to stream again in the permanent live', async function () {
this.timeout(20000)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: getCustomConfigResolutions(false)
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(false)
}
}
}
})
......
......@@ -9,10 +9,10 @@ import {
addVideoToBlacklist,
checkLiveCleanup,
cleanupTests,
ConfigCommand,
createLive,
doubleFollow,
flushAndRunMultipleServers,
getCustomConfigResolutions,
getVideo,
getVideosList,
removeVideo,
......@@ -22,7 +22,6 @@ import {
setDefaultVideoChannel,
stopFfmpeg,
testFfmpegStreamError,
updateCustomSubConfig,
updateVideo,
wait,
waitJobs,
......@@ -102,14 +101,16 @@ describe('Save replay setting', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: false,
resolutions: getCustomConfigResolutions(true)
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: false,
resolutions: ConfigCommand.getCustomConfigResolutions(true)
}
}
}
})
......
......@@ -15,7 +15,6 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
updateCustomSubConfig,
viewVideo,
wait,
waitJobs,
......@@ -37,12 +36,14 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
......
......@@ -15,7 +15,6 @@ import {
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
updateCustomSubConfig,
viewVideo,
wait,
waitJobs,
......@@ -36,12 +35,14 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
......
......@@ -34,7 +34,6 @@ import {
stopFfmpeg,
testFfmpegStreamError,
testImage,
updateCustomSubConfig,
updateLive,
uploadVideoAndGetId,
wait,
......@@ -59,12 +58,14 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
await servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
......@@ -422,20 +423,22 @@ describe('Test live', function () {
}
function updateConf (resolutions: number[]) {
return updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
live: {
enabled: true,
allowReplay: true,
maxDuration: -1,
transcoding: {
return servers[0].configCommand.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
resolutions: {
'240p': resolutions.includes(240),
'360p': resolutions.includes(360),
'480p': resolutions.includes(480),
'720p': resolutions.includes(720),
'1080p': resolutions.includes(1080),
'2160p': resolutions.includes(2160)
allowReplay: true,
maxDuration: -1,
transcoding: {
enabled: true,
resolutions: {
'240p': resolutions.includes(240),
'360p': resolutions.includes(360),
'480p': resolutions.includes(480),
'720p': resolutions.includes(720),
'1080p': resolutions.includes(1080),
'2160p': resolutions.includes(2160)
}
}
}
}
......
......@@ -23,7 +23,6 @@ import {
createUser,
generateUserAccessToken,
getAccount,
getCustomConfig,
getVideoCommentThreads,
getVideoIdFromUUID,
immutableAssign,
......@@ -34,8 +33,6 @@ import {
removeUserSubscription,
removeVideoFromBlacklist,
ServerInfo,
updateCustomConfig,
updateCustomSubConfig,
uploadVideo,
wait,
waitJobs
......@@ -407,7 +404,7 @@ describe('Test moderation notifications', function () {
}
}
}
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
......@@ -421,7 +418,7 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence')
config.followings.instance.autoFollowBack.enabled = false
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await servers[0].followsCommand.unfollow({ target: servers[2] })
await servers[2].followsCommand.unfollow({ target: servers[0] })
})
......@@ -430,7 +427,7 @@ describe('Test moderation notifications', function () {
this.timeout(30000)
await servers[0].followsCommand.unfollow({ target: servers[1] })
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
......@@ -440,7 +437,7 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
config.followings.instance.autoFollowIndex.enabled = false
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await servers[0].followsCommand.unfollow({ target: servers[1] })
})
})
......@@ -476,8 +473,8 @@ describe('Test moderation notifications', function () {
token: userAccessToken
}
const resCustomConfig = await getCustomConfig(servers[0].url, servers[0].accessToken)
currentCustomConfig = resCustomConfig.body
currentCustomConfig = await servers[0].configCommand.getCustomConfig()
const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, {