From 817f754c22ff328003fa052573f9407def63844a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Mar 2024 09:10:36 +0100 Subject: [PATCH] Remove difficult to maintain config update method --- config/test.yaml | 4 + .../src/server/config-command.ts | 282 ++---------------- packages/tests/src/api/check-params/live.ts | 57 +--- .../src/api/check-params/registrations.ts | 2 +- packages/tests/src/api/check-params/search.ts | 2 +- .../tests/src/api/check-params/user-export.ts | 4 +- .../api/check-params/video-channel-syncs.ts | 2 +- .../src/api/check-params/video-imports.ts | 4 +- .../src/api/check-params/video-passwords.ts | 2 +- .../src/api/check-params/video-studio.ts | 6 +- .../tests/src/api/live/live-constraints.ts | 19 +- packages/tests/src/api/live/live-permanent.ts | 13 +- packages/tests/src/api/live/live-rtmps.ts | 17 +- .../tests/src/api/live/live-save-replay.ts | 13 +- .../src/api/live/live-socket-messages.ts | 17 +- packages/tests/src/api/live/live.ts | 8 +- .../notifications/moderation-notifications.ts | 8 +- packages/tests/src/api/search/search-index.ts | 8 +- .../tests/src/api/search/search-videos.ts | 2 +- packages/tests/src/api/server/auto-follows.ts | 8 +- .../tests/src/api/server/config-defaults.ts | 4 +- .../src/api/server/follows-moderation.ts | 12 +- packages/tests/src/api/server/plugins.ts | 2 +- packages/tests/src/api/server/stats.ts | 2 +- .../src/api/transcoding/create-transcoding.ts | 4 +- packages/tests/src/api/transcoding/hls.ts | 2 +- .../tests/src/api/transcoding/transcoder.ts | 12 +- .../transcoding/update-while-transcoding.ts | 2 +- .../tests/src/api/transcoding/video-studio.ts | 2 +- packages/tests/src/api/users/user-export.ts | 2 +- packages/tests/src/api/users/user-videos.ts | 2 +- .../src/api/users/users-email-verification.ts | 6 +- .../src/api/videos/video-change-ownership.ts | 2 +- .../tests/src/api/videos/video-channels.ts | 2 +- .../tests/src/api/videos/video-imports.ts | 23 +- .../tests/src/api/videos/video-storyboard.ts | 2 +- packages/tests/src/client/index-html.ts | 2 +- .../tests/src/external-plugins/akismet.ts | 2 +- .../src/peertube-runner/vod-transcoding.ts | 2 +- packages/tests/src/plugins/filter-hooks.ts | 29 +- .../tests/src/plugins/plugin-transcoding.ts | 5 +- 41 files changed, 148 insertions(+), 451 deletions(-) diff --git a/config/test.yaml b/config/test.yaml index cc642327c..74b4524a0 100644 --- a/config/test.yaml +++ b/config/test.yaml @@ -162,3 +162,7 @@ open_telemetry: metrics: prometheus_exporter: port: 9092 + +search: + search_index: + url: 'https://search.joinpeertube.org/' diff --git a/packages/server-commands/src/server/config-command.ts b/packages/server-commands/src/server/config-command.ts index 20d1d350c..874fb3c5a 100644 --- a/packages/server-commands/src/server/config-command.ts +++ b/packages/server-commands/src/server/config-command.ts @@ -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 }) { const existing = await this.getCustomConfig({ ...options, expectedStatus: HttpStatusCode.OK_200 }) return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) }) } - - updateCustomSubConfig (options: OverrideCommandOptions & { - newConfig: DeepPartial - }) { - 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 }) - } } diff --git a/packages/tests/src/api/check-params/live.ts b/packages/tests/src/api/check-params/live.ts index 5900823ea..f879ba5d4 100644 --- a/packages/tests/src/api/check-params/live.ts +++ b/packages/tests/src/api/check-params/live.ts @@ -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) }) diff --git a/packages/tests/src/api/check-params/registrations.ts b/packages/tests/src/api/check-params/registrations.ts index e4e46da2a..1e78bdae3 100644 --- a/packages/tests/src/api/check-params/registrations.ts +++ b/packages/tests/src/api/check-params/registrations.ts @@ -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 diff --git a/packages/tests/src/api/check-params/search.ts b/packages/tests/src/api/check-params/search.ts index b886cbc82..0dfe6317f 100644 --- a/packages/tests/src/api/check-params/search.ts +++ b/packages/tests/src/api/check-params/search.ts @@ -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: { diff --git a/packages/tests/src/api/check-params/user-export.ts b/packages/tests/src/api/check-params/user-export.ts index 498975c74..5e44e2eb1 100644 --- a/packages/tests/src/api/check-params/user-export.ts +++ b/packages/tests/src/api/check-params/user-export.ts @@ -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 } diff --git a/packages/tests/src/api/check-params/video-channel-syncs.ts b/packages/tests/src/api/check-params/video-channel-syncs.ts index 00c3f3b66..e6231298c 100644 --- a/packages/tests/src/api/check-params/video-channel-syncs.ts +++ b/packages/tests/src/api/check-params/video-channel-syncs.ts @@ -36,7 +36,7 @@ describe('Test video channel sync API validator', () => { async function withMaxSyncsPerUser (maxSync: number, callback: () => Promise): Promise { const origConfig = await server.config.getCustomConfig() - await server.config.updateExistingSubConfig({ + await server.config.updateExistingConfig({ newConfig: { import: { videoChannelSynchronization: { diff --git a/packages/tests/src/api/check-params/video-imports.ts b/packages/tests/src/api/check-params/video-imports.ts index 1ac60fa8c..effae487e 100644 --- a/packages/tests/src/api/check-params/video-imports.ts +++ b/packages/tests/src/api/check-params/video-imports.ts @@ -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: { diff --git a/packages/tests/src/api/check-params/video-passwords.ts b/packages/tests/src/api/check-params/video-passwords.ts index 69b3f50a3..c6e893172 100644 --- a/packages/tests/src/api/check-params/video-passwords.ts +++ b/packages/tests/src/api/check-params/video-passwords.ts @@ -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, diff --git a/packages/tests/src/api/check-params/video-studio.ts b/packages/tests/src/api/check-params/video-studio.ts index 9931f7872..bc5f6998d 100644 --- a/packages/tests/src/api/check-params/video-studio.ts +++ b/packages/tests/src/api/check-params/video-studio.ts @@ -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 diff --git a/packages/tests/src/api/live/live-constraints.ts b/packages/tests/src/api/live/live-constraints.ts index 32ef944a8..b96a7ceb2 100644 --- a/packages/tests/src/api/live/live-constraints.ts +++ b/packages/tests/src/api/live/live-constraints.ts @@ -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, diff --git a/packages/tests/src/api/live/live-permanent.ts b/packages/tests/src/api/live/live-permanent.ts index 4ffcc7ed4..b6ad0b012 100644 --- a/packages/tests/src/api/live/live-permanent.ts +++ b/packages/tests/src/api/live/live-permanent.ts @@ -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, diff --git a/packages/tests/src/api/live/live-rtmps.ts b/packages/tests/src/api/live/live-rtmps.ts index 4ab59ed4c..cd16460c3 100644 --- a/packages/tests/src/api/live/live-rtmps.ts +++ b/packages/tests/src/api/live/live-rtmps.ts @@ -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' diff --git a/packages/tests/src/api/live/live-save-replay.ts b/packages/tests/src/api/live/live-save-replay.ts index e439f2397..6fc049f4d 100644 --- a/packages/tests/src/api/live/live-save-replay.ts +++ b/packages/tests/src/api/live/live-save-replay.ts @@ -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, diff --git a/packages/tests/src/api/live/live-socket-messages.ts b/packages/tests/src/api/live/live-socket-messages.ts index dbf1f6a6f..d055ba605 100644 --- a/packages/tests/src/api/live/live-socket-messages.ts +++ b/packages/tests/src/api/live/live-socket-messages.ts @@ -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]) diff --git a/packages/tests/src/api/live/live.ts b/packages/tests/src/api/live/live.ts index ea05ccc3c..1bb850a28 100644 --- a/packages/tests/src/api/live/live.ts +++ b/packages/tests/src/api/live/live.ts @@ -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: { diff --git a/packages/tests/src/api/notifications/moderation-notifications.ts b/packages/tests/src/api/notifications/moderation-notifications.ts index 6c726162c..fe2d443cd 100644 --- a/packages/tests/src/api/notifications/moderation-notifications.ts +++ b/packages/tests/src/api/notifications/moderation-notifications.ts @@ -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] }) }) }) diff --git a/packages/tests/src/api/search/search-index.ts b/packages/tests/src/api/search/search-index.ts index 5a070f6f3..f0f1914fa 100644 --- a/packages/tests/src/api/search/search-index.ts +++ b/packages/tests/src/api/search/search-index.ts @@ -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' } } diff --git a/packages/tests/src/api/search/search-videos.ts b/packages/tests/src/api/search/search-videos.ts index 0739f0886..3559c4fbf 100644 --- a/packages/tests/src/api/search/search-videos.ts +++ b/packages/tests/src/api/search/search-videos.ts @@ -534,7 +534,7 @@ describe('Test videos search', function () { }, live: { enabled: true } } - await server.config.updateCustomSubConfig({ newConfig }) + await server.config.updateExistingConfig({ newConfig }) } { diff --git a/packages/tests/src/api/server/auto-follows.ts b/packages/tests/src/api/server/auto-follows.ts index 678a142bd..dc5da5711 100644 --- a/packages/tests/src/api/server/auto-follows.ts +++ b/packages/tests/src/api/server/auto-follows.ts @@ -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) diff --git a/packages/tests/src/api/server/config-defaults.ts b/packages/tests/src/api/server/config-defaults.ts index c50bd686b..35ac89fdf 100644 --- a/packages/tests/src/api/server/config-defaults.ts +++ b/packages/tests/src/api/server/config-defaults.ts @@ -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: { diff --git a/packages/tests/src/api/server/follows-moderation.ts b/packages/tests/src/api/server/follows-moderation.ts index 811dd5c22..54cc14167 100644 --- a/packages/tests/src/api/server/follows-moderation.ts +++ b/packages/tests/src/api/server/follows-moderation.ts @@ -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() }) diff --git a/packages/tests/src/api/server/plugins.ts b/packages/tests/src/api/server/plugins.ts index a78cea025..f6905fe7e 100644 --- a/packages/tests/src/api/server/plugins.ts +++ b/packages/tests/src/api/server/plugins.ts @@ -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' } } diff --git a/packages/tests/src/api/server/stats.ts b/packages/tests/src/api/server/stats.ts index 604664611..3afe2156f 100644 --- a/packages/tests/src/api/server/stats.ts +++ b/packages/tests/src/api/server/stats.ts @@ -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, diff --git a/packages/tests/src/api/transcoding/create-transcoding.ts b/packages/tests/src/api/transcoding/create-transcoding.ts index b0a9c7556..7b37c5279 100644 --- a/packages/tests/src/api/transcoding/create-transcoding.ts +++ b/packages/tests/src/api/transcoding/create-transcoding.ts @@ -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, diff --git a/packages/tests/src/api/transcoding/hls.ts b/packages/tests/src/api/transcoding/hls.ts index a52531c00..2b81e63c7 100644 --- a/packages/tests/src/api/transcoding/hls.ts +++ b/packages/tests/src/api/transcoding/hls.ts @@ -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, diff --git a/packages/tests/src/api/transcoding/transcoder.ts b/packages/tests/src/api/transcoding/transcoder.ts index dd4948ee6..0af196286 100644 --- a/packages/tests/src/api/transcoding/transcoder.ts +++ b/packages/tests/src/api/transcoding/transcoder.ts @@ -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: { diff --git a/packages/tests/src/api/transcoding/update-while-transcoding.ts b/packages/tests/src/api/transcoding/update-while-transcoding.ts index 9990bc745..792b7bc3e 100644 --- a/packages/tests/src/api/transcoding/update-while-transcoding.ts +++ b/packages/tests/src/api/transcoding/update-while-transcoding.ts @@ -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, diff --git a/packages/tests/src/api/transcoding/video-studio.ts b/packages/tests/src/api/transcoding/video-studio.ts index 8a3788aa6..698a9db30 100644 --- a/packages/tests/src/api/transcoding/video-studio.ts +++ b/packages/tests/src/api/transcoding/video-studio.ts @@ -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: { diff --git a/packages/tests/src/api/users/user-export.ts b/packages/tests/src/api/users/user-export.ts index fc95d1bc1..06013d863 100644 --- a/packages/tests/src/api/users/user-export.ts +++ b/packages/tests/src/api/users/user-export.ts @@ -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: { diff --git a/packages/tests/src/api/users/user-videos.ts b/packages/tests/src/api/users/user-videos.ts index 7b075d040..47310e75e 100644 --- a/packages/tests/src/api/users/user-videos.ts +++ b/packages/tests/src/api/users/user-videos.ts @@ -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 }) } { diff --git a/packages/tests/src/api/users/users-email-verification.ts b/packages/tests/src/api/users/users-email-verification.ts index 689e3c4bb..ed87fb0da 100644 --- a/packages/tests/src/api/users/users-email-verification.ts +++ b/packages/tests/src/api/users/users-email-verification.ts @@ -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 diff --git a/packages/tests/src/api/videos/video-change-ownership.ts b/packages/tests/src/api/videos/video-change-ownership.ts index 717c37469..358fed7a0 100644 --- a/packages/tests/src/api/videos/video-change-ownership.ts +++ b/packages/tests/src/api/videos/video-change-ownership.ts @@ -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 diff --git a/packages/tests/src/api/videos/video-channels.ts b/packages/tests/src/api/videos/video-channels.ts index 34c2563e1..03aadabbb 100644 --- a/packages/tests/src/api/videos/video-channels.ts +++ b/packages/tests/src/api/videos/video-channels.ts @@ -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` diff --git a/packages/tests/src/api/videos/video-imports.ts b/packages/tests/src/api/videos/video-imports.ts index 90d9e2174..e25095edd 100644 --- a/packages/tests/src/api/videos/video-imports.ts +++ b/packages/tests/src/api/videos/video-imports.ts @@ -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', diff --git a/packages/tests/src/api/videos/video-storyboard.ts b/packages/tests/src/api/videos/video-storyboard.ts index efcb2295b..ebac297ca 100644 --- a/packages/tests/src/api/videos/video-storyboard.ts +++ b/packages/tests/src/api/videos/video-storyboard.ts @@ -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 diff --git a/packages/tests/src/client/index-html.ts b/packages/tests/src/client/index-html.ts index 4cb9a41c5..5f33955dc 100644 --- a/packages/tests/src/client/index-html.ts +++ b/packages/tests/src/client/index-html.ts @@ -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', diff --git a/packages/tests/src/external-plugins/akismet.ts b/packages/tests/src/external-plugins/akismet.ts index c6d3b7752..89d778471 100644 --- a/packages/tests/src/external-plugins/akismet.ts +++ b/packages/tests/src/external-plugins/akismet.ts @@ -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 diff --git a/packages/tests/src/peertube-runner/vod-transcoding.ts b/packages/tests/src/peertube-runner/vod-transcoding.ts index f3987faf1..da0f26079 100644 --- a/packages/tests/src/peertube-runner/vod-transcoding.ts +++ b/packages/tests/src/peertube-runner/vod-transcoding.ts @@ -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, diff --git a/packages/tests/src/plugins/filter-hooks.ts b/packages/tests/src/plugins/filter-hooks.ts index 7f868f62b..efa9a0f50 100644 --- a/packages/tests/src/plugins/filter-hooks.ts +++ b/packages/tests/src/plugins/filter-hooks.ts @@ -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: { diff --git a/packages/tests/src/plugins/plugin-transcoding.ts b/packages/tests/src/plugins/plugin-transcoding.ts index 2f50f65ff..b36d32289 100644 --- a/packages/tests/src/plugins/plugin-transcoding.ts +++ b/packages/tests/src/plugins/plugin-transcoding.ts @@ -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,