aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
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/plugins
parentbc8090411ddaa8d742ce4de3c83f9dba7bc18e2a (diff)
downloadPeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.tar.gz
PeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.tar.zst
PeerTube-65e6e2602c0d5521f3a6740f7469bb92830ecb53.zip
Introduce config command
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/external-auth.ts15
-rw-r--r--server/tests/plugins/filter-hooks.ts61
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts15
-rw-r--r--server/tests/plugins/plugin-transcoding.ts50
4 files changed, 65 insertions, 76 deletions
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 {
8 createUser, 8 createUser,
9 decodeQueryString, 9 decodeQueryString,
10 flushAndRunServer, 10 flushAndRunServer,
11 getConfig,
12 getMyUserInformation, 11 getMyUserInformation,
13 loginUsingExternalToken, 12 loginUsingExternalToken,
14 logout, 13 logout,
@@ -21,7 +20,7 @@ import {
21 wait, 20 wait,
22 waitUntilLog 21 waitUntilLog
23} from '@shared/extra-utils' 22} from '@shared/extra-utils'
24import { ServerConfig, User, UserRole } from '@shared/models' 23import { User, UserRole } from '@shared/models'
25 24
26async function loginExternal (options: { 25async function loginExternal (options: {
27 server: ServerInfo 26 server: ServerInfo
@@ -78,9 +77,7 @@ describe('Test external auth plugins', function () {
78 }) 77 })
79 78
80 it('Should display the correct configuration', async function () { 79 it('Should display the correct configuration', async function () {
81 const res = await getConfig(server.url) 80 const config = await server.configCommand.getConfig()
82
83 const config: ServerConfig = res.body
84 81
85 const auths = config.plugin.registeredExternalAuths 82 const auths = config.plugin.registeredExternalAuths
86 expect(auths).to.have.lengthOf(8) 83 expect(auths).to.have.lengthOf(8)
@@ -288,9 +285,7 @@ describe('Test external auth plugins', function () {
288 }) 285 })
289 286
290 it('Should have disabled this auth', async function () { 287 it('Should have disabled this auth', async function () {
291 const res = await getConfig(server.url) 288 const config = await server.configCommand.getConfig()
292
293 const config: ServerConfig = res.body
294 289
295 const auths = config.plugin.registeredExternalAuths 290 const auths = config.plugin.registeredExternalAuths
296 expect(auths).to.have.lengthOf(7) 291 expect(auths).to.have.lengthOf(7)
@@ -354,9 +349,7 @@ describe('Test external auth plugins', function () {
354 }) 349 })
355 350
356 it('Should display the correct configuration', async function () { 351 it('Should display the correct configuration', async function () {
357 const res = await getConfig(server.url) 352 const config = await server.configCommand.getConfig()
358
359 const config: ServerConfig = res.body
360 353
361 const auths = config.plugin.registeredExternalAuths 354 const auths = config.plugin.registeredExternalAuths
362 expect(auths).to.have.lengthOf(6) 355 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 {
12 doubleFollow, 12 doubleFollow,
13 flushAndRunMultipleServers, 13 flushAndRunMultipleServers,
14 getAccountVideos, 14 getAccountVideos,
15 getConfig,
16 getMyVideos, 15 getMyVideos,
17 getVideo, 16 getVideo,
18 getVideoChannelVideos, 17 getVideoChannelVideos,
@@ -28,7 +27,6 @@ import {
28 ServerInfo, 27 ServerInfo,
29 setAccessTokensToServers, 28 setAccessTokensToServers,
30 setDefaultVideoChannel, 29 setDefaultVideoChannel,
31 updateCustomSubConfig,
32 updateVideo, 30 updateVideo,
33 uploadVideo, 31 uploadVideo,
34 uploadVideoAndGetId, 32 uploadVideoAndGetId,
@@ -37,7 +35,6 @@ import {
37} from '@shared/extra-utils' 35} from '@shared/extra-utils'
38import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports' 36import { getGoodVideoUrl, getMyVideoImports, importVideo } from '@shared/extra-utils/videos/video-imports'
39import { 37import {
40 ServerConfig,
41 VideoCommentThreadTree, 38 VideoCommentThreadTree,
42 VideoDetails, 39 VideoDetails,
43 VideoImport, 40 VideoImport,
@@ -72,13 +69,15 @@ describe('Test plugin filter hooks', function () {
72 const res = await getVideosList(servers[0].url) 69 const res = await getVideosList(servers[0].url)
73 videoUUID = res.body.data[0].uuid 70 videoUUID = res.body.data[0].uuid
74 71
75 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { 72 await servers[0].configCommand.updateCustomSubConfig({
76 live: { enabled: true }, 73 newConfig: {
77 signup: { enabled: true }, 74 live: { enabled: true },
78 import: { 75 signup: { enabled: true },
79 videos: { 76 import: {
80 http: { enabled: true }, 77 videos: {
81 torrent: { enabled: true } 78 http: { enabled: true },
79 torrent: { enabled: true }
80 }
82 } 81 }
83 } 82 }
84 }) 83 })
@@ -344,8 +343,8 @@ describe('Test plugin filter hooks', function () {
344 describe('Should run filter:api.user.signup.allowed.result', function () { 343 describe('Should run filter:api.user.signup.allowed.result', function () {
345 344
346 it('Should run on config endpoint', async function () { 345 it('Should run on config endpoint', async function () {
347 const res = await getConfig(servers[0].url) 346 const body = await servers[0].configCommand.getConfig()
348 expect((res.body as ServerConfig).signup.allowed).to.be.true 347 expect(body.signup.allowed).to.be.true
349 }) 348 })
350 349
351 it('Should allow a signup', async function () { 350 it('Should allow a signup', async function () {
@@ -365,13 +364,15 @@ describe('Test plugin filter hooks', function () {
365 before(async function () { 364 before(async function () {
366 this.timeout(120000) 365 this.timeout(120000)
367 366
368 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { 367 await servers[0].configCommand.updateCustomSubConfig({
369 transcoding: { 368 newConfig: {
370 webtorrent: { 369 transcoding: {
371 enabled: true 370 webtorrent: {
372 }, 371 enabled: true
373 hls: { 372 },
374 enabled: true 373 hls: {
374 enabled: true
375 }
375 } 376 }
376 } 377 }
377 }) 378 })
@@ -427,9 +428,11 @@ describe('Test plugin filter hooks', function () {
427 before(async function () { 428 before(async function () {
428 this.timeout(60000) 429 this.timeout(60000)
429 430
430 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { 431 await servers[0].configCommand.updateCustomSubConfig({
431 transcoding: { 432 newConfig: {
432 enabled: false 433 transcoding: {
434 enabled: false
435 }
433 } 436 }
434 }) 437 })
435 438
@@ -464,12 +467,14 @@ describe('Test plugin filter hooks', function () {
464 describe('Search filters', function () { 467 describe('Search filters', function () {
465 468
466 before(async function () { 469 before(async function () {
467 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { 470 await servers[0].configCommand.updateCustomSubConfig({
468 search: { 471 newConfig: {
469 searchIndex: { 472 search: {
470 enabled: true, 473 searchIndex: {
471 isDefaultSearch: false, 474 enabled: true,
472 disableLocalSearch: false 475 isDefaultSearch: false,
476 disableLocalSearch: false
477 }
473 } 478 }
474 } 479 }
475 }) 480 })
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'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunServer, 7 flushAndRunServer,
8 getConfig,
9 getMyUserInformation, 8 getMyUserInformation,
10 getUsersList, 9 getUsersList,
11 login, 10 login,
@@ -19,7 +18,7 @@ import {
19 wait, 18 wait,
20 waitUntilLog 19 waitUntilLog
21} from '@shared/extra-utils' 20} from '@shared/extra-utils'
22import { ServerConfig, User, UserRole } from '@shared/models' 21import { User, UserRole } from '@shared/models'
23 22
24describe('Test id and pass auth plugins', function () { 23describe('Test id and pass auth plugins', function () {
25 let server: ServerInfo 24 let server: ServerInfo
@@ -42,9 +41,7 @@ describe('Test id and pass auth plugins', function () {
42 }) 41 })
43 42
44 it('Should display the correct configuration', async function () { 43 it('Should display the correct configuration', async function () {
45 const res = await getConfig(server.url) 44 const config = await server.configCommand.getConfig()
46
47 const config: ServerConfig = res.body
48 45
49 const auths = config.plugin.registeredIdAndPassAuths 46 const auths = config.plugin.registeredIdAndPassAuths
50 expect(auths).to.have.lengthOf(8) 47 expect(auths).to.have.lengthOf(8)
@@ -190,9 +187,7 @@ describe('Test id and pass auth plugins', function () {
190 }) 187 })
191 188
192 it('Should have disabled this auth', async function () { 189 it('Should have disabled this auth', async function () {
193 const res = await getConfig(server.url) 190 const config = await server.configCommand.getConfig()
194
195 const config: ServerConfig = res.body
196 191
197 const auths = config.plugin.registeredIdAndPassAuths 192 const auths = config.plugin.registeredIdAndPassAuths
198 expect(auths).to.have.lengthOf(7) 193 expect(auths).to.have.lengthOf(7)
@@ -208,9 +203,7 @@ describe('Test id and pass auth plugins', function () {
208 }) 203 })
209 204
210 it('Should display the correct configuration', async function () { 205 it('Should display the correct configuration', async function () {
211 const res = await getConfig(server.url) 206 const config = await server.configCommand.getConfig()
212
213 const config: ServerConfig = res.body
214 207
215 const auths = config.plugin.registeredIdAndPassAuths 208 const auths = config.plugin.registeredIdAndPassAuths
216 expect(auths).to.have.lengthOf(6) 209 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 {
9 cleanupTests, 9 cleanupTests,
10 createLive, 10 createLive,
11 flushAndRunServer, 11 flushAndRunServer,
12 getConfig,
13 getVideo, 12 getVideo,
14 PluginsCommand, 13 PluginsCommand,
15 sendRTMPStreamInVideo, 14 sendRTMPStreamInVideo,
@@ -17,12 +16,11 @@ import {
17 setAccessTokensToServers, 16 setAccessTokensToServers,
18 setDefaultVideoChannel, 17 setDefaultVideoChannel,
19 testFfmpegStreamError, 18 testFfmpegStreamError,
20 updateCustomSubConfig,
21 uploadVideoAndGetId, 19 uploadVideoAndGetId,
22 waitJobs, 20 waitJobs,
23 waitUntilLivePublished 21 waitUntilLivePublished
24} from '@shared/extra-utils' 22} from '@shared/extra-utils'
25import { ServerConfig, VideoDetails, VideoPrivacy } from '@shared/models' 23import { VideoDetails, VideoPrivacy } from '@shared/models'
26 24
27async function createLiveWrapper (server: ServerInfo) { 25async function createLiveWrapper (server: ServerInfo) {
28 const liveAttributes = { 26 const liveAttributes = {
@@ -36,33 +34,35 @@ async function createLiveWrapper (server: ServerInfo) {
36} 34}
37 35
38function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) { 36function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) {
39 return updateCustomSubConfig(server.url, server.accessToken, { 37 return server.configCommand.updateCustomSubConfig({
40 transcoding: { 38 newConfig: {
41 enabled: true,
42 profile: vodProfile,
43 hls: {
44 enabled: true
45 },
46 webtorrent: {
47 enabled: true
48 },
49 resolutions: {
50 '240p': true,
51 '360p': false,
52 '480p': false,
53 '720p': true
54 }
55 },
56 live: {
57 transcoding: { 39 transcoding: {
58 profile: liveProfile,
59 enabled: true, 40 enabled: true,
41 profile: vodProfile,
42 hls: {
43 enabled: true
44 },
45 webtorrent: {
46 enabled: true
47 },
60 resolutions: { 48 resolutions: {
61 '240p': true, 49 '240p': true,
62 '360p': false, 50 '360p': false,
63 '480p': false, 51 '480p': false,
64 '720p': true 52 '720p': true
65 } 53 }
54 },
55 live: {
56 transcoding: {
57 profile: liveProfile,
58 enabled: true,
59 resolutions: {
60 '240p': true,
61 '360p': false,
62 '480p': false,
63 '720p': true
64 }
65 }
66 } 66 }
67 } 67 }
68 }) 68 })
@@ -113,8 +113,7 @@ describe('Test transcoding plugins', function () {
113 }) 113 })
114 114
115 it('Should have the appropriate available profiles', async function () { 115 it('Should have the appropriate available profiles', async function () {
116 const res = await getConfig(server.url) 116 const config = await server.configCommand.getConfig()
117 const config = res.body as ServerConfig
118 117
119 expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ]) 118 expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ])
120 expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ]) 119 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 () {
223 222
224 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' }) 223 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
225 224
226 const res = await getConfig(server.url) 225 const config = await server.configCommand.getConfig()
227 const config = res.body as ServerConfig
228 226
229 expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ]) 227 expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
230 expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ]) 228 expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])