aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-07 11:51:09 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commit65e6e2602c0d5521f3a6740f7469bb92830ecb53 (patch)
treef89024ffff1dafb0281ee2fe028e89b95101bd44 /server/tests/api/check-params
parentbc8090411ddaa8d742ce4de3c83f9dba7bc18e2a (diff)
downloadPeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.tar.gz
PeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.tar.zst
PeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.zip
Introduce config command
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/live.ts75
-rw-r--r--server/tests/api/check-params/search.ts25
-rw-r--r--server/tests/api/check-params/video-imports.ts53
3 files changed, 83 insertions, 70 deletions
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 {
19 ServerInfo, 19 ServerInfo,
20 setAccessTokensToServers, 20 setAccessTokensToServers,
21 stopFfmpeg, 21 stopFfmpeg,
22 updateCustomSubConfig,
23 updateLive, 22 updateLive,
24 uploadVideoAndGetId, 23 uploadVideoAndGetId,
25 userLogin, 24 userLogin,
@@ -43,12 +42,14 @@ describe('Test video lives API validator', function () {
43 42
44 await setAccessTokensToServers([ server ]) 43 await setAccessTokensToServers([ server ])
45 44
46 await updateCustomSubConfig(server.url, server.accessToken, { 45 await server.configCommand.updateCustomSubConfig({
47 live: { 46 newConfig: {
48 enabled: true, 47 live: {
49 maxInstanceLives: 20, 48 enabled: true,
50 maxUserLives: 20, 49 maxInstanceLives: 20,
51 allowReplay: true 50 maxUserLives: 20,
51 allowReplay: true
52 }
52 } 53 }
53 }) 54 })
54 55
@@ -234,9 +235,11 @@ describe('Test video lives API validator', function () {
234 }) 235 })
235 236
236 it('Should forbid if live is disabled', async function () { 237 it('Should forbid if live is disabled', async function () {
237 await updateCustomSubConfig(server.url, server.accessToken, { 238 await server.configCommand.updateCustomSubConfig({
238 live: { 239 newConfig: {
239 enabled: false 240 live: {
241 enabled: false
242 }
240 } 243 }
241 }) 244 })
242 245
@@ -252,10 +255,12 @@ describe('Test video lives API validator', function () {
252 it('Should forbid to save replay if not enabled by the admin', async function () { 255 it('Should forbid to save replay if not enabled by the admin', async function () {
253 const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) 256 const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
254 257
255 await updateCustomSubConfig(server.url, server.accessToken, { 258 await server.configCommand.updateCustomSubConfig({
256 live: { 259 newConfig: {
257 enabled: true, 260 live: {
258 allowReplay: false 261 enabled: true,
262 allowReplay: false
263 }
259 } 264 }
260 }) 265 })
261 266
@@ -271,10 +276,12 @@ describe('Test video lives API validator', function () {
271 it('Should allow to save replay if enabled by the admin', async function () { 276 it('Should allow to save replay if enabled by the admin', async function () {
272 const fields = immutableAssign(baseCorrectParams, { saveReplay: true }) 277 const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
273 278
274 await updateCustomSubConfig(server.url, server.accessToken, { 279 await server.configCommand.updateCustomSubConfig({
275 live: { 280 newConfig: {
276 enabled: true, 281 live: {
277 allowReplay: true 282 enabled: true,
283 allowReplay: true
284 }
278 } 285 }
279 }) 286 })
280 287
@@ -288,10 +295,12 @@ describe('Test video lives API validator', function () {
288 }) 295 })
289 296
290 it('Should not allow live if max instance lives is reached', async function () { 297 it('Should not allow live if max instance lives is reached', async function () {
291 await updateCustomSubConfig(server.url, server.accessToken, { 298 await server.configCommand.updateCustomSubConfig({
292 live: { 299 newConfig: {
293 enabled: true, 300 live: {
294 maxInstanceLives: 1 301 enabled: true,
302 maxInstanceLives: 1
303 }
295 } 304 }
296 }) 305 })
297 306
@@ -305,11 +314,13 @@ describe('Test video lives API validator', function () {
305 }) 314 })
306 315
307 it('Should not allow live if max user lives is reached', async function () { 316 it('Should not allow live if max user lives is reached', async function () {
308 await updateCustomSubConfig(server.url, server.accessToken, { 317 await server.configCommand.updateCustomSubConfig({
309 live: { 318 newConfig: {
310 enabled: true, 319 live: {
311 maxInstanceLives: 20, 320 enabled: true,
312 maxUserLives: 1 321 maxInstanceLives: 20,
322 maxUserLives: 1
323 }
313 } 324 }
314 }) 325 })
315 326
@@ -393,10 +404,12 @@ describe('Test video lives API validator', function () {
393 }) 404 })
394 405
395 it('Should fail to update replay status if replay is not allowed on the instance', async function () { 406 it('Should fail to update replay status if replay is not allowed on the instance', async function () {
396 await updateCustomSubConfig(server.url, server.accessToken, { 407 await server.configCommand.updateCustomSubConfig({
397 live: { 408 newConfig: {
398 enabled: true, 409 live: {
399 allowReplay: false 410 enabled: true,
411 allowReplay: false
412 }
400 } 413 }
401 }) 414 })
402 415
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 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils'
4import { 5import {
6 checkBadCountPagination,
7 checkBadSortPagination,
8 checkBadStartPagination,
5 cleanupTests, 9 cleanupTests,
6 flushAndRunServer, 10 flushAndRunServer,
7 immutableAssign, 11 immutableAssign,
8 makeGetRequest, 12 makeGetRequest,
9 ServerInfo, 13 ServerInfo,
10 updateCustomSubConfig,
11 setAccessTokensToServers 14 setAccessTokensToServers
12} from '../../../../shared/extra-utils' 15} from '@shared/extra-utils'
13import {
14 checkBadCountPagination,
15 checkBadSortPagination,
16 checkBadStartPagination
17} from '../../../../shared/extra-utils/requests/check-api-params'
18import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 16
20function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) { 17function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
21 return updateCustomSubConfig(server.url, server.accessToken, { 18 return server.configCommand.updateCustomSubConfig({
22 search: { 19 newConfig: {
23 searchIndex: { 20 search: {
24 enabled, 21 searchIndex: {
25 disableLocalSearch 22 enabled,
23 disableLocalSearch
24 }
26 } 25 }
27 } 26 }
28 }) 27 })
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 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 checkBadCountPagination,
9 checkBadSortPagination,
10 checkBadStartPagination,
8 cleanupTests, 11 cleanupTests,
9 createUser, 12 createUser,
10 flushAndRunServer, 13 flushAndRunServer,
@@ -15,16 +18,10 @@ import {
15 makeUploadRequest, 18 makeUploadRequest,
16 ServerInfo, 19 ServerInfo,
17 setAccessTokensToServers, 20 setAccessTokensToServers,
18 updateCustomSubConfig,
19 userLogin 21 userLogin
20} from '../../../../shared/extra-utils' 22} from '@shared/extra-utils'
21import { 23import { getGoodVideoUrl, getMagnetURI } from '@shared/extra-utils/videos/video-imports'
22 checkBadCountPagination, 24import { VideoPrivacy } from '@shared/models'
23 checkBadSortPagination,
24 checkBadStartPagination
25} from '../../../../shared/extra-utils/requests/check-api-params'
26import { getGoodVideoUrl, getMagnetURI } from '../../../../shared/extra-utils/videos/video-imports'
27import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
28 25
29describe('Test video imports API validator', function () { 26describe('Test video imports API validator', function () {
30 const path = '/api/v1/videos/imports' 27 const path = '/api/v1/videos/imports'
@@ -263,14 +260,16 @@ describe('Test video imports API validator', function () {
263 }) 260 })
264 261
265 it('Should forbid to import http videos', async function () { 262 it('Should forbid to import http videos', async function () {
266 await updateCustomSubConfig(server.url, server.accessToken, { 263 await server.configCommand.updateCustomSubConfig({
267 import: { 264 newConfig: {
268 videos: { 265 import: {
269 http: { 266 videos: {
270 enabled: false 267 http: {
271 }, 268 enabled: false
272 torrent: { 269 },
273 enabled: true 270 torrent: {
271 enabled: true
272 }
274 } 273 }
275 } 274 }
276 } 275 }
@@ -286,14 +285,16 @@ describe('Test video imports API validator', function () {
286 }) 285 })
287 286
288 it('Should forbid to import torrent videos', async function () { 287 it('Should forbid to import torrent videos', async function () {
289 await updateCustomSubConfig(server.url, server.accessToken, { 288 await server.configCommand.updateCustomSubConfig({
290 import: { 289 newConfig: {
291 videos: { 290 import: {
292 http: { 291 videos: {
293 enabled: true 292 http: {
294 }, 293 enabled: true
295 torrent: { 294 },
296 enabled: false 295 torrent: {
296 enabled: false
297 }
297 } 298 }
298 } 299 }
299 } 300 }