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/api/check-params/live.ts | 75 +++++++++++++++----------- server/tests/api/check-params/search.ts | 25 +++++---- server/tests/api/check-params/video-imports.ts | 53 +++++++++--------- 3 files changed, 83 insertions(+), 70 deletions(-) (limited to 'server/tests/api/check-params') diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index 933d8abf2..7a623c169 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts @@ -19,7 +19,6 @@ import { ServerInfo, setAccessTokensToServers, stopFfmpeg, - updateCustomSubConfig, updateLive, uploadVideoAndGetId, userLogin, @@ -43,12 +42,14 @@ describe('Test video lives API validator', function () { await setAccessTokensToServers([ server ]) - await updateCustomSubConfig(server.url, server.accessToken, { - live: { - enabled: true, - maxInstanceLives: 20, - maxUserLives: 20, - allowReplay: true + await server.configCommand.updateCustomSubConfig({ + newConfig: { + live: { + enabled: true, + maxInstanceLives: 20, + maxUserLives: 20, + allowReplay: true + } } }) @@ -234,9 +235,11 @@ describe('Test video lives API validator', function () { }) it('Should forbid if live is disabled', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - live: { - enabled: false + await server.configCommand.updateCustomSubConfig({ + newConfig: { + live: { + enabled: false + } } }) @@ -252,10 +255,12 @@ describe('Test video lives API validator', function () { it('Should forbid to save replay if not enabled by the admin', async function () { const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) - await updateCustomSubConfig(server.url, server.accessToken, { - live: { - enabled: true, - allowReplay: false + await server.configCommand.updateCustomSubConfig({ + newConfig: { + live: { + enabled: true, + allowReplay: false + } } }) @@ -271,10 +276,12 @@ describe('Test video lives API validator', function () { it('Should allow to save replay if enabled by the admin', async function () { const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) - await updateCustomSubConfig(server.url, server.accessToken, { - live: { - enabled: true, - allowReplay: true + await server.configCommand.updateCustomSubConfig({ + newConfig: { + live: { + enabled: true, + allowReplay: true + } } }) @@ -288,10 +295,12 @@ describe('Test video lives API validator', function () { }) it('Should not allow live if max instance lives is reached', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - live: { - enabled: true, - maxInstanceLives: 1 + await server.configCommand.updateCustomSubConfig({ + newConfig: { + live: { + enabled: true, + maxInstanceLives: 1 + } } }) @@ -305,11 +314,13 @@ describe('Test video lives API validator', function () { }) it('Should not allow live if max user lives is reached', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - live: { - enabled: true, - maxInstanceLives: 20, - maxUserLives: 1 + await server.configCommand.updateCustomSubConfig({ + newConfig: { + live: { + enabled: true, + maxInstanceLives: 20, + maxUserLives: 1 + } } }) @@ -393,10 +404,12 @@ describe('Test video lives API validator', function () { }) it('Should fail to update replay status if replay is not allowed on the instance', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - live: { - enabled: true, - allowReplay: false + await server.configCommand.updateCustomSubConfig({ + newConfig: { + live: { + enabled: true, + allowReplay: false + } } }) diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index 20ad46cff..4a2fc1197 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts @@ -1,28 +1,27 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { HttpStatusCode } from '@shared/core-utils' import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination, cleanupTests, flushAndRunServer, immutableAssign, makeGetRequest, ServerInfo, - updateCustomSubConfig, setAccessTokensToServers -} from '../../../../shared/extra-utils' -import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination -} from '../../../../shared/extra-utils/requests/check-api-params' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +} from '@shared/extra-utils' function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) { - return updateCustomSubConfig(server.url, server.accessToken, { - search: { - searchIndex: { - enabled, - disableLocalSearch + return server.configCommand.updateCustomSubConfig({ + newConfig: { + search: { + searchIndex: { + enabled, + disableLocalSearch + } } } }) diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index a27b624d0..dae3860ef 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts @@ -2,9 +2,12 @@ import 'mocha' import { omit } from 'lodash' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/core-utils' import { buildAbsoluteFixturePath, + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination, cleanupTests, createUser, flushAndRunServer, @@ -15,16 +18,10 @@ import { makeUploadRequest, ServerInfo, setAccessTokensToServers, - updateCustomSubConfig, userLogin -} from '../../../../shared/extra-utils' -import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination -} from '../../../../shared/extra-utils/requests/check-api-params' -import { getGoodVideoUrl, getMagnetURI } from '../../../../shared/extra-utils/videos/video-imports' -import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' +} from '@shared/extra-utils' +import { getGoodVideoUrl, getMagnetURI } from '@shared/extra-utils/videos/video-imports' +import { VideoPrivacy } from '@shared/models' describe('Test video imports API validator', function () { const path = '/api/v1/videos/imports' @@ -263,14 +260,16 @@ describe('Test video imports API validator', function () { }) it('Should forbid to import http videos', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - import: { - videos: { - http: { - enabled: false - }, - torrent: { - enabled: true + await server.configCommand.updateCustomSubConfig({ + newConfig: { + import: { + videos: { + http: { + enabled: false + }, + torrent: { + enabled: true + } } } } @@ -286,14 +285,16 @@ describe('Test video imports API validator', function () { }) it('Should forbid to import torrent videos', async function () { - await updateCustomSubConfig(server.url, server.accessToken, { - import: { - videos: { - http: { - enabled: true - }, - torrent: { - enabled: false + await server.configCommand.updateCustomSubConfig({ + newConfig: { + import: { + videos: { + http: { + enabled: true + }, + torrent: { + enabled: false + } } } } -- cgit v1.2.3