Remove difficult to maintain config update method

This commit is contained in:
Chocobozzz 2024-03-28 09:10:36 +01:00
parent 5ef0430dfb
commit 817f754c22
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
41 changed files with 148 additions and 451 deletions

View File

@ -162,3 +162,7 @@ open_telemetry:
metrics:
prometheus_exporter:
port: 9092
search:
search_index:
url: 'https://search.joinpeertube.org/'

View File

@ -1,6 +1,6 @@
import merge from 'lodash-es/merge.js'
import { About, ActorImageType, ActorImageType_Type, CustomConfig, HttpStatusCode, ServerConfig } from '@peertube/peertube-models'
import { DeepPartial } from '@peertube/peertube-typescript-utils'
import merge from 'lodash-es/merge.js'
import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command.js'
export class ConfigCommand extends AbstractCommand {
@ -43,7 +43,7 @@ export class ConfigCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
enableSignup (requiresApproval: boolean, limit = -1) {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
signup: {
enabled: true,
@ -65,7 +65,7 @@ export class ConfigCommand extends AbstractCommand {
}
private setVideoImportsEnabled (enabled: boolean) {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
import: {
videos: {
@ -93,7 +93,7 @@ export class ConfigCommand extends AbstractCommand {
}
private setFileUpdateEnabled (enabled: boolean) {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
videoFile: {
update: {
@ -107,7 +107,7 @@ export class ConfigCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
keepSourceFile () {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
transcoding: {
originalFile: {
@ -128,7 +128,7 @@ export class ConfigCommand extends AbstractCommand {
}
private setChannelSyncEnabled (enabled: boolean) {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
import: {
videoChannelSynchronization: {
@ -150,7 +150,7 @@ export class ConfigCommand extends AbstractCommand {
}
private setAutoblacklistEnabled (enabled: boolean) {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
autoBlacklist: {
videos: {
@ -174,7 +174,7 @@ export class ConfigCommand extends AbstractCommand {
}
private setUserImportEnabled (enabled: boolean) {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
import: {
users: {
@ -196,7 +196,7 @@ export class ConfigCommand extends AbstractCommand {
}
private setUserExportEnabled (enabled: boolean) {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
export: {
users: {
@ -216,7 +216,7 @@ export class ConfigCommand extends AbstractCommand {
} = {}) {
const { allowReplay, transcoding, resolutions = 'max' } = options
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
live: {
enabled: true,
@ -231,7 +231,7 @@ export class ConfigCommand extends AbstractCommand {
}
disableTranscoding () {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
transcoding: {
enabled: false
@ -251,7 +251,7 @@ export class ConfigCommand extends AbstractCommand {
} = {}) {
const { webVideo = true, hls = true, with0p = false, keepOriginal = false } = options
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,
@ -282,7 +282,7 @@ export class ConfigCommand extends AbstractCommand {
} = {}) {
const { webVideo = true, hls = true, keepOriginal = false } = options
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,
@ -311,7 +311,7 @@ export class ConfigCommand extends AbstractCommand {
}
enableRemoteTranscoding () {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
transcoding: {
remoteRunners: {
@ -330,7 +330,7 @@ export class ConfigCommand extends AbstractCommand {
}
enableRemoteStudio () {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
videoStudio: {
remoteRunners: {
@ -344,7 +344,7 @@ export class ConfigCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
enableStudio () {
return this.updateExistingSubConfig({
return this.updateExistingConfig({
newConfig: {
videoStudio: {
enabled: true
@ -480,259 +480,11 @@ export class ConfigCommand extends AbstractCommand {
})
}
async updateExistingSubConfig (options: OverrideCommandOptions & {
async updateExistingConfig (options: OverrideCommandOptions & {
newConfig: DeepPartial<CustomConfig>
}) {
const existing = await this.getCustomConfig({ ...options, expectedStatus: HttpStatusCode.OK_200 })
return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) })
}
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'
}
},
client: {
videos: {
miniature: {
preferAuthorDisplayName: false
}
},
menu: {
login: {
redirectOnSingleExternalAuth: false
}
}
},
cache: {
previews: {
size: 2
},
captions: {
size: 3
},
torrents: {
size: 4
},
storyboards: {
size: 5
}
},
signup: {
enabled: false,
limit: 5,
requiresApproval: true,
requiresEmailVerification: false,
minimumAge: 16
},
admin: {
email: 'superadmin1@example.com'
},
contactForm: {
enabled: true
},
user: {
history: {
videos: {
enabled: true
}
},
videoQuota: 5242881,
videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
},
videoChannels: {
maxPerUser: 20
},
transcoding: {
enabled: true,
originalFile: {
keep: false
},
remoteRunners: {
enabled: false
},
allowAdditionalExtensions: true,
allowAudioFiles: true,
threads: 1,
concurrency: 3,
profile: 'default',
resolutions: {
'0p': false,
'144p': false,
'240p': false,
'360p': true,
'480p': true,
'720p': false,
'1080p': false,
'1440p': false,
'2160p': false
},
alwaysTranscodeOriginalResolution: true,
webVideos: {
enabled: true
},
hls: {
enabled: false
}
},
live: {
enabled: true,
allowReplay: false,
latencySetting: {
enabled: false
},
maxDuration: -1,
maxInstanceLives: -1,
maxUserLives: 50,
transcoding: {
enabled: true,
remoteRunners: {
enabled: false
},
threads: 4,
profile: 'default',
resolutions: {
'144p': true,
'240p': true,
'360p': true,
'480p': true,
'720p': true,
'1080p': true,
'1440p': true,
'2160p': true
},
alwaysTranscodeOriginalResolution: true
}
},
videoStudio: {
enabled: false,
remoteRunners: {
enabled: false
}
},
videoFile: {
update: {
enabled: false
}
},
import: {
videos: {
concurrency: 3,
http: {
enabled: false
},
torrent: {
enabled: false
}
},
videoChannelSynchronization: {
enabled: false,
maxPerUser: 10
},
users: {
enabled: true
}
},
export: {
users: {
enabled: true,
maxUserVideoQuota: 5242881,
exportExpiration: 1000 * 3600
}
},
trending: {
videos: {
algorithms: {
enabled: [ '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
}
},
storyboards: {
enabled: true
}
}
merge(newCustomConfig, options.newConfig)
return this.updateCustomConfig({ ...options, newCustomConfig })
}
}

View File

@ -1,20 +1,20 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { omit } from '@peertube/peertube-core-utils'
import { HttpStatusCode, LiveVideoLatencyMode, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models'
import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import {
LiveCommand,
PeerTubeServer,
cleanupTests,
createSingleServer,
LiveCommand,
makePostBodyRequest,
makeUploadRequest,
PeerTubeServer,
sendRTMPStream,
setAccessTokensToServers,
stopFfmpeg
} from '@peertube/peertube-server-commands'
import { expect } from 'chai'
describe('Test video lives API validator', function () {
const path = '/api/v1/videos/live'
@ -34,7 +34,8 @@ describe('Test video lives API validator', function () {
await setAccessTokensToServers([ server ])
await server.config.updateCustomSubConfig({
await server.config.enableMinimumTranscoding()
await server.config.updateExistingConfig({
newConfig: {
live: {
enabled: true,
@ -85,7 +86,7 @@ describe('Test video lives API validator', function () {
channelId,
saveReplay: false,
replaySettings: undefined,
permanentLive: false,
permanentLive: true,
latencyMode: LiveVideoLatencyMode.DEFAULT
}
})
@ -246,7 +247,7 @@ describe('Test video lives API validator', function () {
})
it('Should forbid if live is disabled', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
live: {
enabled: false
@ -266,14 +267,7 @@ describe('Test video lives API validator', function () {
it('Should forbid to save replay if not enabled by the admin', async function () {
const fields = { ...baseCorrectParams, saveReplay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }
await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: false
}
}
})
await server.config.enableLive({ allowReplay: false, transcoding: false })
await makePostBodyRequest({
url: server.url,
@ -287,14 +281,7 @@ describe('Test video lives API validator', function () {
it('Should allow to save replay if enabled by the admin', async function () {
const fields = { ...baseCorrectParams, saveReplay: true, replaySettings: { privacy: VideoPrivacy.PUBLIC } }
await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true
}
}
})
await server.config.enableLive({ allowReplay: true, transcoding: false })
await makePostBodyRequest({
url: server.url,
@ -306,7 +293,7 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max instance lives is reached', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
live: {
enabled: true,
@ -325,7 +312,7 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max user lives is reached', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
live: {
enabled: true,
@ -479,14 +466,7 @@ describe('Test video lives API validator', function () {
})
it('Should fail with save replay enabled but without replay settings', async function () {
await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true
}
}
})
await server.config.enableLive({ allowReplay: true, transcoding: false })
const fields = { saveReplay: true }
@ -521,19 +501,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 server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: false
}
}
})
await server.config.enableLive({ allowReplay: false, transcoding: false })
await command.update({ videoId: video.id, fields: { saveReplay: true }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail to update a live if it has already started', async function () {
it('Should succeed to live attributes if it has already started', async function () {
this.timeout(40000)
const live = await command.get({ videoId: video.id })
@ -541,7 +514,7 @@ describe('Test video lives API validator', function () {
const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey })
await command.waitUntilPublished({ videoId: video.id })
await command.update({ videoId: video.id, fields: {}, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await command.update({ videoId: video.id, fields: { permanentLive: false }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await stopFfmpeg(ffmpegCommand)
})

View File

@ -152,7 +152,7 @@ describe('Test registrations API validators', function () {
it('Should fail on a server with registration disabled', async function () {
this.timeout(60000)
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
signup: {
enabled: false

View File

@ -11,7 +11,7 @@ import {
} from '@peertube/peertube-server-commands'
function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) {
return server.config.updateCustomSubConfig({
return server.config.updateExistingConfig({
newConfig: {
search: {
searchIndex: {

View File

@ -86,7 +86,7 @@ describe('Test user export API validators', function () {
it('Should fail if user quota is too big', async function () {
const { videoQuotaUsed } = await server.users.getMyQuotaUsed()
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
export: {
users: { maxUserVideoQuota: videoQuotaUsed - 1 }
@ -101,7 +101,7 @@ describe('Test user export API validators', function () {
await server.userExports.waitForCreation({ userId: rootId })
await server.userExports.deleteAllArchives({ userId: rootId })
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
export: {
users: { maxUserVideoQuota: 1000 * 1000 * 1000 * 1000 }

View File

@ -36,7 +36,7 @@ describe('Test video channel sync API validator', () => {
async function withMaxSyncsPerUser<T> (maxSync: number, callback: () => Promise<T>): Promise<void> {
const origConfig = await server.config.getCustomConfig()
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
import: {
videoChannelSynchronization: {

View File

@ -299,7 +299,7 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import http videos', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
import: {
videos: {
@ -324,7 +324,7 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import torrent videos', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
import: {
videos: {

View File

@ -36,7 +36,7 @@ describe('Test video passwords validator', function () {
await setAccessTokensToServers([ server ])
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
live: {
enabled: true,

View File

@ -41,7 +41,7 @@ describe('Test video studio API validator', function () {
describe('Config settings', function () {
it('Should fail if studio is disabled', async function () {
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
videoStudio: {
enabled: false
@ -57,7 +57,7 @@ describe('Test video studio API validator', function () {
})
it('Should fail to enable studio if transcoding is disabled', async function () {
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
videoStudio: {
enabled: true
@ -71,7 +71,7 @@ describe('Test video studio API validator', function () {
})
it('Should succeed to enable video studio', async function () {
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
videoStudio: {
enabled: true

View File

@ -1,12 +1,11 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { wait } from '@peertube/peertube-core-utils'
import { LiveVideoError, UserVideoQuota, VideoPrivacy } from '@peertube/peertube-models'
import {
PeerTubeServer,
cleanupTests, createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
@ -14,6 +13,7 @@ import {
waitUntilLiveReplacedByReplayOnAllServers,
waitUntilLiveWaitingOnAllServers
} from '@peertube/peertube-server-commands'
import { expect } from 'chai'
import { checkLiveCleanup } from '../../shared/live.js'
describe('Test live constraints', function () {
@ -65,17 +65,8 @@ describe('Test live constraints', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
await servers[0].config.enableMinimumTranscoding()
await servers[0].config.enableLive({ allowReplay: true, transcoding: false })
{
const res = await servers[0].users.generate('user1')
@ -203,7 +194,7 @@ describe('Test live constraints', function () {
it('Should have max duration limit', async function () {
this.timeout(240000)
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
live: {
enabled: true,

View File

@ -1,20 +1,20 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { wait } from '@peertube/peertube-core-utils'
import { LiveVideoCreate, VideoPrivacy, VideoState, VideoStateType } from '@peertube/peertube-models'
import { checkLiveCleanup } from '@tests/shared/live.js'
import {
cleanupTests,
ConfigCommand,
PeerTubeServer,
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
waitJobs
} from '@peertube/peertube-server-commands'
import { checkLiveCleanup } from '@tests/shared/live.js'
import { expect } from 'chai'
describe('Permanent live', function () {
let servers: PeerTubeServer[] = []
@ -52,7 +52,8 @@ describe('Permanent live', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
await servers[0].config.updateCustomSubConfig({
await servers[0].config.enableMinimumTranscoding()
await servers[0].config.updateExistingConfig({
newConfig: {
live: {
enabled: true,
@ -143,7 +144,7 @@ describe('Permanent live', function () {
it('Should be able to stream again in the permanent live', async function () {
this.timeout(60000)
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
live: {
enabled: true,

View File

@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import { VideoPrivacy } from '@peertube/peertube-models'
import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import {
cleanupTests,
createSingleServer,
@ -14,6 +13,7 @@ import {
testFfmpegStreamError,
waitUntilLivePublishedOnAllServers
} from '@peertube/peertube-server-commands'
import { expect } from 'chai'
describe('Test live RTMPS', function () {
let server: PeerTubeServer
@ -45,17 +45,8 @@ describe('Test live RTMPS', function () {
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
await server.config.enableMinimumTranscoding()
await server.config.enableLive({ allowReplay: true, transcoding: false })
rtmpUrl = 'rtmp://' + server.hostname + ':' + server.rtmpPort + '/live'
rtmpsUrl = 'rtmps://' + server.hostname + ':' + server.rtmpsPort + '/live'

View File

@ -1,7 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
import { wait } from '@peertube/peertube-core-utils'
import {
HttpStatusCode,
@ -13,14 +11,13 @@ import {
VideoState,
VideoStateType
} from '@peertube/peertube-models'
import { checkLiveCleanup } from '@tests/shared/live.js'
import {
cleanupTests,
ConfigCommand,
PeerTubeServer,
cleanupTests,
createMultipleServers,
doubleFollow,
findExternalSavedVideo,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
@ -30,6 +27,9 @@ import {
waitUntilLiveReplacedByReplayOnAllServers,
waitUntilLiveWaitingOnAllServers
} from '@peertube/peertube-server-commands'
import { checkLiveCleanup } from '@tests/shared/live.js'
import { expect } from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
describe('Save replay setting', function () {
let servers: PeerTubeServer[] = []
@ -146,7 +146,8 @@ describe('Save replay setting', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
await servers[0].config.updateCustomSubConfig({
await servers[0].config.enableMinimumTranscoding()
await servers[0].config.updateExistingConfig({
newConfig: {
live: {
enabled: true,

View File

@ -1,19 +1,19 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { wait } from '@peertube/peertube-core-utils'
import { LiveVideoEventPayload, VideoPrivacy, VideoState, VideoStateType } from '@peertube/peertube-models'
import {
PeerTubeServer,
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
waitJobs,
waitUntilLivePublishedOnAllServers
} from '@peertube/peertube-server-commands'
import { expect } from 'chai'
describe('Test live socket messages', function () {
let servers: PeerTubeServer[] = []
@ -27,17 +27,8 @@ describe('Test live socket messages', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
transcoding: {
enabled: false
}
}
}
})
await servers[0].config.enableMinimumTranscoding()
await servers[0].config.enableLive({ allowReplay: true, transcoding: false })
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])

View File

@ -48,11 +48,13 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await servers[0].config.updateCustomSubConfig({
await servers[0].config.enableMinimumTranscoding()
await servers[0].config.updateExistingConfig({
newConfig: {
live: {
enabled: true,
allowReplay: true,
maxUserLives: -1,
latencySetting: {
enabled: true
},
@ -396,7 +398,7 @@ describe('Test live', function () {
}
function updateConf (resolutions: number[]) {
return servers[0].config.updateCustomSubConfig({
return servers[0].config.updateExistingConfig({
newConfig: {
live: {
enabled: true,
@ -602,7 +604,7 @@ describe('Test live', function () {
const resolutions = [ 240, 480 ]
await updateConf(resolutions)
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
live: {
transcoding: {

View File

@ -380,7 +380,7 @@ describe('Test moderation notifications', function () {
}
}
}
await servers[0].config.updateCustomSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
await servers[2].follows.follow({ hosts: [ servers[0].url ] })
@ -394,7 +394,7 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' })
config.followings.instance.autoFollowBack.enabled = false
await servers[0].config.updateCustomSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
await servers[0].follows.unfollow({ target: servers[2] })
await servers[2].follows.unfollow({ target: servers[0] })
})
@ -403,7 +403,7 @@ describe('Test moderation notifications', function () {
this.timeout(30000)
await servers[0].follows.unfollow({ target: servers[1] })
await servers[0].config.updateCustomSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
@ -413,7 +413,7 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' })
config.followings.instance.autoFollowIndex.enabled = false
await servers[0].config.updateCustomSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
await servers[0].follows.unfollow({ target: servers[1] })
})
})

View File

@ -38,7 +38,7 @@ describe('Test index search', function () {
describe('Default search', async function () {
it('Should make a local videos search by default', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
search: {
searchIndex: {
@ -65,7 +65,7 @@ describe('Test index search', function () {
})
it('Should make an index videos search by default', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
search: {
searchIndex: {
@ -243,7 +243,7 @@ describe('Test index search', function () {
let nsfwUUID: string
{
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'display' }
}
@ -259,7 +259,7 @@ describe('Test index search', function () {
}
{
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'do_not_list' }
}

View File

@ -534,7 +534,7 @@ describe('Test videos search', function () {
},
live: { enabled: true }
}
await server.config.updateCustomSubConfig({ newConfig })
await server.config.updateExistingConfig({ newConfig })
}
{

View File

@ -77,7 +77,7 @@ describe('Test auto follows', function () {
}
}
}
await servers[1].config.updateCustomSubConfig({ newConfig: config })
await servers[1].config.updateExistingConfig({ newConfig: config })
await server1Follows2(servers)
@ -102,7 +102,7 @@ describe('Test auto follows', function () {
}
}
}
await servers[1].config.updateCustomSubConfig({ newConfig: config })
await servers[1].config.updateExistingConfig({ newConfig: config })
await server1Follows2(servers)
@ -119,7 +119,7 @@ describe('Test auto follows', function () {
config.followings.instance.autoFollowBack.enabled = false
config.followers.instance.manualApproval = false
await servers[1].config.updateCustomSubConfig({ newConfig: config })
await servers[1].config.updateExistingConfig({ newConfig: config })
})
})
@ -156,7 +156,7 @@ describe('Test auto follows', function () {
}
}
}
await servers[0].config.updateCustomSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)

View File

@ -212,7 +212,7 @@ describe('Test config defaults', function () {
describe('Default user attributes', function () {
it('Should create a user and register a user with the default config', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
user: {
history: {
@ -252,7 +252,7 @@ describe('Test config defaults', function () {
})
it('Should update config and create a user and register a user with the new default config', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
user: {
history: {

View File

@ -133,7 +133,7 @@ describe('Test follows moderation', function () {
}
}
await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
await servers[1].config.updateExistingConfig({ newConfig: subConfig })
await commands[0].follow({ hosts: [ servers[1].url ] })
await waitJobs(servers)
@ -151,7 +151,7 @@ describe('Test follows moderation', function () {
}
}
await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
await servers[1].config.updateExistingConfig({ newConfig: subConfig })
await commands[0].follow({ hosts: [ servers[1].url ] })
await waitJobs(servers)
@ -177,8 +177,8 @@ describe('Test follows moderation', function () {
}
}
await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
await servers[2].config.updateCustomSubConfig({ newConfig: subConfig })
await servers[1].config.updateExistingConfig({ newConfig: subConfig })
await servers[2].config.updateExistingConfig({ newConfig: subConfig })
await commands[0].follow({ hosts: [ servers[1].url ] })
await waitJobs(servers)
@ -271,10 +271,10 @@ describe('Test follows moderation', function () {
})
}
await servers[2].config.updateExistingSubConfig({ newConfig: { followers: { instance: { manualApproval: false } } } })
await servers[2].config.updateExistingConfig({ newConfig: { followers: { instance: { manualApproval: false } } } })
await run()
await servers[2].config.updateExistingSubConfig({ newConfig: { followers: { instance: { manualApproval: true } } } })
await servers[2].config.updateExistingConfig({ newConfig: { followers: { instance: { manualApproval: true } } } })
await run()
})

View File

@ -111,7 +111,7 @@ describe('Test plugins', function () {
})
it('Should update the default theme in the configuration', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
theme: { default: 'background-red' }
}

View File

@ -206,7 +206,7 @@ describe('Test stats (excluding redundancy)', function () {
it('Should correctly count video file sizes if transcoding is enabled', async function () {
this.timeout(120000)
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,

View File

@ -160,7 +160,7 @@ function runTests (enableObjectStorage: boolean) {
it('Should correctly update HLS playlist on resolution change', async function () {
this.timeout(120000)
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,
@ -196,7 +196,7 @@ function runTests (enableObjectStorage: boolean) {
]
}
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,

View File

@ -119,7 +119,7 @@ describe('Test HLS videos', function () {
describe('With only HLS enabled', function () {
before(async function () {
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,

View File

@ -26,7 +26,7 @@ import { generateVideoWithFramerate, generateHighBitrateVideo } from '@tests/sha
import { checkWebTorrentWorks } from '@tests/shared/webtorrent.js'
function updateConfigForTranscoding (server: PeerTubeServer) {
return server.config.updateCustomSubConfig({
return server.config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,
@ -331,7 +331,7 @@ describe('Test video transcoding', function () {
function runSuite (mode: 'legacy' | 'resumable') {
before(async function () {
await servers[1].config.updateCustomSubConfig({
await servers[1].config.updateExistingConfig({
newConfig: {
transcoding: {
hls: { enabled: true },
@ -403,7 +403,7 @@ describe('Test video transcoding', function () {
it('Should upload an audio file and create an audio version only', async function () {
this.timeout(60_000)
await servers[1].config.updateCustomSubConfig({
await servers[1].config.updateExistingConfig({
newConfig: {
transcoding: {
hls: { enabled: true },
@ -592,7 +592,7 @@ describe('Test video transcoding', function () {
hls: { enabled: true }
}
}
await servers[1].config.updateCustomSubConfig({ newConfig })
await servers[1].config.updateExistingConfig({ newConfig })
const attributes = {
name: 'low bitrate',
@ -725,7 +725,7 @@ describe('Test video transcoding', function () {
it('Should not generate an upper resolution than original file', async function () {
this.timeout(120_000)
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,
@ -764,7 +764,7 @@ describe('Test video transcoding', function () {
it('Should only keep the original resolution if all resolutions are disabled', async function () {
this.timeout(120_000)
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
resolutions: {

View File

@ -104,7 +104,7 @@ describe('Test update video privacy while transcoding', function () {
describe('With only HLS enabled', function () {
before(async function () {
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,

View File

@ -276,7 +276,7 @@ describe('Test video studio', function () {
before(async function () {
// Disable Web Videos
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
webVideos: {

View File

@ -791,7 +791,7 @@ function runTest (withObjectStorage: boolean) {
await checkExportFileExists({ exists: true, server, userExport, withObjectStorage, redirectedUrl })
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
export: {
users: {

View File

@ -192,7 +192,7 @@ describe('Test user videos', function () {
config.transcoding.webVideos.enabled = false
config.transcoding.hls.enabled = true
config.transcoding.enabled = true
await server.config.updateCustomSubConfig({ newConfig: config })
await server.config.updateExistingConfig({ newConfig: config })
}
{

View File

@ -40,7 +40,7 @@ describe('Test users email verification', function () {
it('Should register user and send verification email if verification required', async function () {
this.timeout(30000)
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
signup: {
enabled: true,
@ -126,7 +126,7 @@ describe('Test users email verification', function () {
it('Should register user not requiring email verification if setting not enabled', async function () {
this.timeout(5000)
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
signup: {
requiresEmailVerification: false
@ -146,7 +146,7 @@ describe('Test users email verification', function () {
})
it('Should allow login for user with unverified email when setting later enabled', async function () {
await server.config.updateCustomSubConfig({
await server.config.updateExistingConfig({
newConfig: {
signup: {
requiresEmailVerification: true

View File

@ -39,7 +39,7 @@ describe('Test video change ownership - nominal', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: false

View File

@ -553,7 +553,7 @@ describe('Test video channels', function () {
it('Should apply another default channel name', async function () {
this.timeout(15000)
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
user: {
defaultChannelName: `$1's channel`

View File

@ -1,18 +1,13 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import { pathExists, remove } from 'fs-extra/esm'
import { readdir } from 'fs/promises'
import { join } from 'path'
import { areHttpImportTestsDisabled } from '@peertube/peertube-node-utils'
import { CustomConfig, HttpStatusCode, Video, VideoImportState, VideoPrivacy, VideoResolution, VideoState } from '@peertube/peertube-models'
import { areHttpImportTestsDisabled } from '@peertube/peertube-node-utils'
import {
cleanupTests,
createMultipleServers,
PeerTubeServer,
cleanupTests, createMultipleServers,
createSingleServer,
doubleFollow,
getServerImportConfig,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
waitJobs
@ -21,6 +16,10 @@ import { DeepPartial } from '@peertube/peertube-typescript-utils'
import { testCaptionFile } from '@tests/shared/captions.js'
import { testImageGeneratedByFFmpeg } from '@tests/shared/checks.js'
import { FIXTURE_URLS } from '@tests/shared/fixture-urls.js'
import { expect } from 'chai'
import { pathExists, remove } from 'fs-extra/esm'
import { readdir } from 'fs/promises'
import { join } from 'path'
async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) {
const videoHttp = await server.videos.get({ id: idHttp })
@ -96,7 +95,7 @@ describe('Test video imports', function () {
await setDefaultVideoChannel(servers)
for (const server of servers) {
await server.config.updateExistingSubConfig({
await server.config.updateExistingConfig({
newConfig: {
transcoding: {
alwaysTranscodeOriginalResolution: false
@ -346,7 +345,7 @@ describe('Test video imports', function () {
hls: { enabled: false }
}
}
await servers[0].config.updateExistingSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
const attributes = {
name: 'hdr video',
@ -386,7 +385,7 @@ describe('Test video imports', function () {
alwaysTranscodeOriginalResolution: false
}
}
await servers[0].config.updateExistingSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
const attributes = {
name: 'small resolution video',
@ -414,7 +413,7 @@ describe('Test video imports', function () {
alwaysTranscodeOriginalResolution: true
}
}
await servers[0].config.updateExistingSubConfig({ newConfig: config })
await servers[0].config.updateExistingConfig({ newConfig: config })
const attributes = {
name: 'bigger resolution video',

View File

@ -213,7 +213,7 @@ describe('Test video storyboard', function () {
it('Should not generate storyboards if disabled by the admin', async function () {
this.timeout(60000)
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
storyboards: {
enabled: false

View File

@ -50,7 +50,7 @@ describe('Test index HTML generation', function () {
})
it('Should update the customized configuration and have the correct index html tags', async function () {
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
instance: {
name: 'PeerTube updated',

View File

@ -128,7 +128,7 @@ describe('Official plugin Akismet', function () {
describe('Signup', function () {
before(async function () {
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
signup: {
enabled: true

View File

@ -236,7 +236,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {
it('Should not generate an upper resolution than original file', async function () {
this.timeout(120_000)
await servers[0].config.updateExistingSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,

View File

@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
import {
HttpStatusCode,
MyUser,
@ -12,20 +11,21 @@ import {
VideoPrivacy
} from '@peertube/peertube-models'
import {
PeerTubeServer,
PluginsCommand,
cleanupTests,
createMultipleServers,
doubleFollow,
makeActivityPubGetRequest,
makeGetRequest,
makeRawRequest,
PeerTubeServer,
PluginsCommand,
setAccessTokensToServers,
setDefaultVideoChannel,
waitJobs
} from '@peertube/peertube-server-commands'
import { FIXTURE_URLS } from '../shared/fixture-urls.js'
import { expectEndWith } from '@tests/shared/checks.js'
import { expect } from 'chai'
import { FIXTURE_URLS } from '../shared/fixture-urls.js'
describe('Test plugin filter hooks', function () {
let servers: PeerTubeServer[]
@ -63,7 +63,7 @@ describe('Test plugin filter hooks', function () {
const { data } = await servers[0].videos.list()
videoUUID = data[0].uuid
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
live: { enabled: true },
signup: { enabled: true },
@ -481,7 +481,7 @@ describe('Test plugin filter hooks', function () {
describe('Should run filter:api.user.signup.allowed.result', function () {
before(async function () {
await servers[0].config.updateExistingSubConfig({ newConfig: { signup: { requiresApproval: false } } })
await servers[0].config.updateExistingConfig({ newConfig: { signup: { requiresApproval: false } } })
})
it('Should run on config endpoint', async function () {
@ -506,7 +506,7 @@ describe('Test plugin filter hooks', function () {
describe('Should run filter:api.user.request-signup.allowed.result', function () {
before(async function () {
await servers[0].config.updateExistingSubConfig({ newConfig: { signup: { requiresApproval: true } } })
await servers[0].config.updateExistingConfig({ newConfig: { signup: { requiresApproval: true } } })
})
it('Should run on config endpoint', async function () {
@ -536,18 +536,7 @@ describe('Test plugin filter hooks', function () {
before(async function () {
this.timeout(120000)
await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
webVideos: {
enabled: true
},
hls: {
enabled: true
}
}
}
})
await servers[0].config.enableMinimumTranscoding({ hls: true, webVideo: true })
const uuids: string[] = []
@ -675,7 +664,7 @@ describe('Test plugin filter hooks', function () {
describe('Search filters', function () {
before(async function () {
await servers[0].config.updateCustomSubConfig({
await servers[0].config.updateExistingConfig({
newConfig: {
search: {
searchIndex: {

View File

@ -27,7 +27,7 @@ async function createLiveWrapper (server: PeerTubeServer) {
}
function updateConf (server: PeerTubeServer, vodProfile: string, liveProfile: string) {
return server.config.updateCustomSubConfig({
return server.config.updateExistingConfig({
newConfig: {
transcoding: {
enabled: true,
@ -46,6 +46,9 @@ function updateConf (server: PeerTubeServer, vodProfile: string, liveProfile: st
}
},
live: {
enabled: true,
maxInstanceLives: -1,
maxUserLives: -1,
transcoding: {
profile: liveProfile,
enabled: true,