From 65e6e2602c0d5521f3a6740f7469bb92830ecb53 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 11:51:09 +0200 Subject: Introduce config command --- server/tests/plugins/external-auth.ts | 15 ++------ server/tests/plugins/filter-hooks.ts | 61 ++++++++++++++++-------------- server/tests/plugins/id-and-pass-auth.ts | 15 ++------ server/tests/plugins/plugin-transcoding.ts | 50 ++++++++++++------------ 4 files changed, 65 insertions(+), 76 deletions(-) (limited to 'server/tests/plugins') diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index 424302786..09a107ca2 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts @@ -8,7 +8,6 @@ import { createUser, decodeQueryString, flushAndRunServer, - getConfig, getMyUserInformation, loginUsingExternalToken, logout, @@ -21,7 +20,7 @@ import { wait, waitUntilLog } from '@shared/extra-utils' -import { ServerConfig, User, UserRole } from '@shared/models' +import { User, UserRole } from '@shared/models' async function loginExternal (options: { server: ServerInfo @@ -78,9 +77,7 @@ describe('Test external auth plugins', function () { }) it('Should display the correct configuration', async function () { - const res = await getConfig(server.url) - - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const auths = config.plugin.registeredExternalAuths expect(auths).to.have.lengthOf(8) @@ -288,9 +285,7 @@ describe('Test external auth plugins', function () { }) it('Should have disabled this auth', async function () { - const res = await getConfig(server.url) - - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const auths = config.plugin.registeredExternalAuths expect(auths).to.have.lengthOf(7) @@ -354,9 +349,7 @@ describe('Test external auth plugins', function () { }) it('Should display the correct configuration', async function () { - const res = await getConfig(server.url) - - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const auths = config.plugin.registeredExternalAuths expect(auths).to.have.lengthOf(6) diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index c51e96ab7..e254046bf 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -12,7 +12,6 @@ import { doubleFollow, flushAndRunMultipleServers, getAccountVideos, - getConfig, getMyVideos, getVideo, getVideoChannelVideos, @@ -28,7 +27,6 @@ import { ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, - updateCustomSubConfig, updateVideo, uploadVideo, uploadVideoAndGetId, @@ -37,7 +35,6 @@ import { } from '@shared/extra-utils' import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports' import { - ServerConfig, VideoCommentThreadTree, VideoDetails, VideoImport, @@ -72,13 +69,15 @@ describe('Test plugin filter hooks', function () { const res = await getVideosList(servers[0].url) videoUUID = res.body.data[0].uuid - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - live: { enabled: true }, - signup: { enabled: true }, - import: { - videos: { - http: { enabled: true }, - torrent: { enabled: true } + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + live: { enabled: true }, + signup: { enabled: true }, + import: { + videos: { + http: { enabled: true }, + torrent: { enabled: true } + } } } }) @@ -344,8 +343,8 @@ describe('Test plugin filter hooks', function () { describe('Should run filter:api.user.signup.allowed.result', function () { it('Should run on config endpoint', async function () { - const res = await getConfig(servers[0].url) - expect((res.body as ServerConfig).signup.allowed).to.be.true + const body = await servers[0].configCommand.getConfig() + expect(body.signup.allowed).to.be.true }) it('Should allow a signup', async function () { @@ -365,13 +364,15 @@ describe('Test plugin filter hooks', function () { before(async function () { this.timeout(120000) - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - transcoding: { - webtorrent: { - enabled: true - }, - hls: { - enabled: true + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + transcoding: { + webtorrent: { + enabled: true + }, + hls: { + enabled: true + } } } }) @@ -427,9 +428,11 @@ describe('Test plugin filter hooks', function () { before(async function () { this.timeout(60000) - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - transcoding: { - enabled: false + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + transcoding: { + enabled: false + } } }) @@ -464,12 +467,14 @@ describe('Test plugin filter hooks', function () { describe('Search filters', function () { before(async function () { - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - search: { - searchIndex: { - enabled: true, - isDefaultSearch: false, - disableLocalSearch: false + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + search: { + searchIndex: { + enabled: true, + isDefaultSearch: false, + disableLocalSearch: false + } } } }) diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 545968040..99de28d3f 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts @@ -5,7 +5,6 @@ import { expect } from 'chai' import { cleanupTests, flushAndRunServer, - getConfig, getMyUserInformation, getUsersList, login, @@ -19,7 +18,7 @@ import { wait, waitUntilLog } from '@shared/extra-utils' -import { ServerConfig, User, UserRole } from '@shared/models' +import { User, UserRole } from '@shared/models' describe('Test id and pass auth plugins', function () { let server: ServerInfo @@ -42,9 +41,7 @@ describe('Test id and pass auth plugins', function () { }) it('Should display the correct configuration', async function () { - const res = await getConfig(server.url) - - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const auths = config.plugin.registeredIdAndPassAuths expect(auths).to.have.lengthOf(8) @@ -190,9 +187,7 @@ describe('Test id and pass auth plugins', function () { }) it('Should have disabled this auth', async function () { - const res = await getConfig(server.url) - - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const auths = config.plugin.registeredIdAndPassAuths expect(auths).to.have.lengthOf(7) @@ -208,9 +203,7 @@ describe('Test id and pass auth plugins', function () { }) it('Should display the correct configuration', async function () { - const res = await getConfig(server.url) - - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const auths = config.plugin.registeredIdAndPassAuths expect(auths).to.have.lengthOf(6) diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index f1ff91077..71c2adc72 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts @@ -9,7 +9,6 @@ import { cleanupTests, createLive, flushAndRunServer, - getConfig, getVideo, PluginsCommand, sendRTMPStreamInVideo, @@ -17,12 +16,11 @@ import { setAccessTokensToServers, setDefaultVideoChannel, testFfmpegStreamError, - updateCustomSubConfig, uploadVideoAndGetId, waitJobs, waitUntilLivePublished } from '@shared/extra-utils' -import { ServerConfig, VideoDetails, VideoPrivacy } from '@shared/models' +import { VideoDetails, VideoPrivacy } from '@shared/models' async function createLiveWrapper (server: ServerInfo) { const liveAttributes = { @@ -36,33 +34,35 @@ async function createLiveWrapper (server: ServerInfo) { } function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) { - return updateCustomSubConfig(server.url, server.accessToken, { - transcoding: { - enabled: true, - profile: vodProfile, - hls: { - enabled: true - }, - webtorrent: { - enabled: true - }, - resolutions: { - '240p': true, - '360p': false, - '480p': false, - '720p': true - } - }, - live: { + return server.configCommand.updateCustomSubConfig({ + newConfig: { transcoding: { - profile: liveProfile, enabled: true, + profile: vodProfile, + hls: { + enabled: true + }, + webtorrent: { + enabled: true + }, resolutions: { '240p': true, '360p': false, '480p': false, '720p': true } + }, + live: { + transcoding: { + profile: liveProfile, + enabled: true, + resolutions: { + '240p': true, + '360p': false, + '480p': false, + '720p': true + } + } } } }) @@ -113,8 +113,7 @@ describe('Test transcoding plugins', function () { }) it('Should have the appropriate available profiles', async function () { - const res = await getConfig(server.url) - const config = res.body as ServerConfig + const config = await server.configCommand.getConfig() expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ]) expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ]) @@ -223,8 +222,7 @@ describe('Test transcoding plugins', function () { await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' }) - const res = await getConfig(server.url) - const config = res.body as ServerConfig + const config = await server.configCommand.getConfig() expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ]) expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ]) -- cgit v1.2.3