aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:47:51 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit254d3579f5338f5fd775c17d15cdfc37078bcfb4 (patch)
treeeaeb13fda16c16e98cd6991d202b0ca6a4cbdb63 /server/tests/plugins
parent89d241a79c262b9775c233b73cff080043ebb5e6 (diff)
downloadPeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.gz
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.zst
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.zip
Use an object to represent a server
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/action-hooks.ts11
-rw-r--r--server/tests/plugins/external-auth.ts10
-rw-r--r--server/tests/plugins/filter-hooks.ts8
-rw-r--r--server/tests/plugins/html-injection.ts8
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts6
-rw-r--r--server/tests/plugins/plugin-helpers.ts10
-rw-r--r--server/tests/plugins/plugin-router.ts8
-rw-r--r--server/tests/plugins/plugin-storage.ts13
-rw-r--r--server/tests/plugins/plugin-transcoding.ts12
-rw-r--r--server/tests/plugins/plugin-unloading.ts13
-rw-r--r--server/tests/plugins/translations.ts7
-rw-r--r--server/tests/plugins/video-constants.ts6
12 files changed, 62 insertions, 50 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 12d5c23c5..b96de4e90 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -3,18 +3,17 @@
3import 'mocha' 3import 'mocha'
4import { 4import {
5 cleanupTests, 5 cleanupTests,
6 flushAndRunMultipleServers, 6 createMultipleServers,
7 killallServers, 7 killallServers,
8 PeerTubeServer,
8 PluginsCommand, 9 PluginsCommand,
9 reRunServer,
10 ServerInfo,
11 setAccessTokensToServers, 10 setAccessTokensToServers,
12 setDefaultVideoChannel 11 setDefaultVideoChannel
13} from '@shared/extra-utils' 12} from '@shared/extra-utils'
14import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' 13import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
15 14
16describe('Test plugin action hooks', function () { 15describe('Test plugin action hooks', function () {
17 let servers: ServerInfo[] 16 let servers: PeerTubeServer[]
18 let videoUUID: string 17 let videoUUID: string
19 let threadId: number 18 let threadId: number
20 19
@@ -25,7 +24,7 @@ describe('Test plugin action hooks', function () {
25 before(async function () { 24 before(async function () {
26 this.timeout(30000) 25 this.timeout(30000)
27 26
28 servers = await flushAndRunMultipleServers(2) 27 servers = await createMultipleServers(2)
29 await setAccessTokensToServers(servers) 28 await setAccessTokensToServers(servers)
30 await setDefaultVideoChannel(servers) 29 await setDefaultVideoChannel(servers)
31 30
@@ -33,7 +32,7 @@ describe('Test plugin action hooks', function () {
33 32
34 await killallServers([ servers[0] ]) 33 await killallServers([ servers[0] ])
35 34
36 await reRunServer(servers[0], { 35 await servers[0].run({
37 live: { 36 live: {
38 enabled: true 37 enabled: true
39 } 38 }
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index 48f942f7f..c0834a14c 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -6,16 +6,16 @@ import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 decodeQueryString, 8 decodeQueryString,
9 flushAndRunServer, 9 createSingleServer,
10 PluginsCommand, 10 PluginsCommand,
11 ServerInfo, 11 PeerTubeServer,
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 wait 13 wait
14} from '@shared/extra-utils' 14} from '@shared/extra-utils'
15import { UserRole } from '@shared/models' 15import { UserRole } from '@shared/models'
16 16
17async function loginExternal (options: { 17async function loginExternal (options: {
18 server: ServerInfo 18 server: PeerTubeServer
19 npmName: string 19 npmName: string
20 authName: string 20 authName: string
21 username: string 21 username: string
@@ -46,7 +46,7 @@ async function loginExternal (options: {
46} 46}
47 47
48describe('Test external auth plugins', function () { 48describe('Test external auth plugins', function () {
49 let server: ServerInfo 49 let server: PeerTubeServer
50 50
51 let cyanAccessToken: string 51 let cyanAccessToken: string
52 let cyanRefreshToken: string 52 let cyanRefreshToken: string
@@ -59,7 +59,7 @@ describe('Test external auth plugins', function () {
59 before(async function () { 59 before(async function () {
60 this.timeout(30000) 60 this.timeout(30000)
61 61
62 server = await flushAndRunServer(1) 62 server = await createSingleServer(1)
63 await setAccessTokensToServers([ server ]) 63 await setAccessTokensToServers([ server ])
64 64
65 for (const suffix of [ 'one', 'two', 'three' ]) { 65 for (const suffix of [ 'one', 'two', 'three' ]) {
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 18479dcf5..5d94303a9 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -6,11 +6,11 @@ import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 createMultipleServers,
10 ImportsCommand, 10 ImportsCommand,
11 makeRawRequest, 11 makeRawRequest,
12 PluginsCommand, 12 PluginsCommand,
13 ServerInfo, 13 PeerTubeServer,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 setDefaultVideoChannel, 15 setDefaultVideoChannel,
16 waitJobs 16 waitJobs
@@ -20,14 +20,14 @@ import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, Vi
20const expect = chai.expect 20const expect = chai.expect
21 21
22describe('Test plugin filter hooks', function () { 22describe('Test plugin filter hooks', function () {
23 let servers: ServerInfo[] 23 let servers: PeerTubeServer[]
24 let videoUUID: string 24 let videoUUID: string
25 let threadId: number 25 let threadId: number
26 26
27 before(async function () { 27 before(async function () {
28 this.timeout(60000) 28 this.timeout(60000)
29 29
30 servers = await flushAndRunMultipleServers(2) 30 servers = await createMultipleServers(2)
31 await setAccessTokensToServers(servers) 31 await setAccessTokensToServers(servers)
32 await setDefaultVideoChannel(servers) 32 await setDefaultVideoChannel(servers)
33 await doubleFollow(servers[0], servers[1]) 33 await doubleFollow(servers[0], servers[1])
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts
index 0cb89f511..2902c39b7 100644
--- a/server/tests/plugins/html-injection.ts
+++ b/server/tests/plugins/html-injection.ts
@@ -4,23 +4,23 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunServer, 7 createSingleServer,
8 makeHTMLRequest, 8 makeHTMLRequest,
9 PluginsCommand, 9 PluginsCommand,
10 ServerInfo, 10 PeerTubeServer,
11 setAccessTokensToServers 11 setAccessTokensToServers
12} from '../../../shared/extra-utils' 12} from '../../../shared/extra-utils'
13 13
14const expect = chai.expect 14const expect = chai.expect
15 15
16describe('Test plugins HTML injection', function () { 16describe('Test plugins HTML injection', function () {
17 let server: ServerInfo = null 17 let server: PeerTubeServer = null
18 let command: PluginsCommand 18 let command: PluginsCommand
19 19
20 before(async function () { 20 before(async function () {
21 this.timeout(30000) 21 this.timeout(30000)
22 22
23 server = await flushAndRunServer(1) 23 server = await createSingleServer(1)
24 await setAccessTokensToServers([ server ]) 24 await setAccessTokensToServers([ server ])
25 25
26 command = server.plugins 26 command = server.plugins
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts
index 203996af8..981bcad91 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -3,11 +3,11 @@
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { cleanupTests, flushAndRunServer, PluginsCommand, ServerInfo, setAccessTokensToServers, wait } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils'
7import { UserRole } from '@shared/models' 7import { UserRole } from '@shared/models'
8 8
9describe('Test id and pass auth plugins', function () { 9describe('Test id and pass auth plugins', function () {
10 let server: ServerInfo 10 let server: PeerTubeServer
11 11
12 let crashAccessToken: string 12 let crashAccessToken: string
13 let crashRefreshToken: string 13 let crashRefreshToken: string
@@ -18,7 +18,7 @@ describe('Test id and pass auth plugins', function () {
18 before(async function () { 18 before(async function () {
19 this.timeout(30000) 19 this.timeout(30000)
20 20
21 server = await flushAndRunServer(1) 21 server = await createSingleServer(1)
22 await setAccessTokensToServers([ server ]) 22 await setAccessTokensToServers([ server ])
23 23
24 for (const suffix of [ 'one', 'two', 'three' ]) { 24 for (const suffix of [ 'one', 'two', 'three' ]) {
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index cf16aaa9d..1d87b84ae 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -7,16 +7,16 @@ import {
7 checkVideoFilesWereRemoved, 7 checkVideoFilesWereRemoved,
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 createMultipleServers,
11 makeGetRequest, 11 makeGetRequest,
12 makePostBodyRequest, 12 makePostBodyRequest,
13 PluginsCommand, 13 PluginsCommand,
14 ServerInfo, 14 PeerTubeServer,
15 setAccessTokensToServers, 15 setAccessTokensToServers,
16 waitJobs 16 waitJobs
17} from '@shared/extra-utils' 17} from '@shared/extra-utils'
18 18
19function postCommand (server: ServerInfo, command: string, bodyArg?: object) { 19function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) {
20 const body = { command } 20 const body = { command }
21 if (bodyArg) Object.assign(body, bodyArg) 21 if (bodyArg) Object.assign(body, bodyArg)
22 22
@@ -29,12 +29,12 @@ function postCommand (server: ServerInfo, command: string, bodyArg?: object) {
29} 29}
30 30
31describe('Test plugin helpers', function () { 31describe('Test plugin helpers', function () {
32 let servers: ServerInfo[] 32 let servers: PeerTubeServer[]
33 33
34 before(async function () { 34 before(async function () {
35 this.timeout(60000) 35 this.timeout(60000)
36 36
37 servers = await flushAndRunMultipleServers(2) 37 servers = await createMultipleServers(2)
38 await setAccessTokensToServers(servers) 38 await setAccessTokensToServers(servers)
39 39
40 await doubleFollow(servers[0], servers[1]) 40 await doubleFollow(servers[0], servers[1])
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts
index 1c53dd80c..dec8ca4bb 100644
--- a/server/tests/plugins/plugin-router.ts
+++ b/server/tests/plugins/plugin-router.ts
@@ -5,16 +5,16 @@ import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 flushAndRunServer, 8 createSingleServer,
9 makeGetRequest, 9 makeGetRequest,
10 makePostBodyRequest, 10 makePostBodyRequest,
11 PluginsCommand, 11 PluginsCommand,
12 ServerInfo, 12 PeerTubeServer,
13 setAccessTokensToServers 13 setAccessTokensToServers
14} from '@shared/extra-utils' 14} from '@shared/extra-utils'
15 15
16describe('Test plugin helpers', function () { 16describe('Test plugin helpers', function () {
17 let server: ServerInfo 17 let server: PeerTubeServer
18 const basePaths = [ 18 const basePaths = [
19 '/plugins/test-five/router/', 19 '/plugins/test-five/router/',
20 '/plugins/test-five/0.0.1/router/' 20 '/plugins/test-five/0.0.1/router/'
@@ -23,7 +23,7 @@ describe('Test plugin helpers', function () {
23 before(async function () { 23 before(async function () {
24 this.timeout(30000) 24 this.timeout(30000)
25 25
26 server = await flushAndRunServer(1) 26 server = await createSingleServer(1)
27 await setAccessTokensToServers([ server ]) 27 await setAccessTokensToServers([ server ])
28 28
29 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') }) 29 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 30e231439..5745914a5 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -5,15 +5,22 @@ import { expect } from 'chai'
5import { pathExists, readdir, readFile } from 'fs-extra' 5import { pathExists, readdir, readFile } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/core-utils'
8import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' 8import {
9 cleanupTests,
10 createSingleServer,
11 makeGetRequest,
12 PeerTubeServer,
13 PluginsCommand,
14 setAccessTokensToServers
15} from '@shared/extra-utils'
9 16
10describe('Test plugin storage', function () { 17describe('Test plugin storage', function () {
11 let server: ServerInfo 18 let server: PeerTubeServer
12 19
13 before(async function () { 20 before(async function () {
14 this.timeout(30000) 21 this.timeout(30000)
15 22
16 server = await flushAndRunServer(1) 23 server = await createSingleServer(1)
17 await setAccessTokensToServers([ server ]) 24 await setAccessTokensToServers([ server ])
18 25
19 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') }) 26 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts
index 3a03065b0..3c54d3796 100644
--- a/server/tests/plugins/plugin-transcoding.ts
+++ b/server/tests/plugins/plugin-transcoding.ts
@@ -6,9 +6,9 @@ import { join } from 'path'
6import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' 6import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
9 flushAndRunServer, 9 createSingleServer,
10 PluginsCommand, 10 PluginsCommand,
11 ServerInfo, 11 PeerTubeServer,
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 setDefaultVideoChannel, 13 setDefaultVideoChannel,
14 testFfmpegStreamError, 14 testFfmpegStreamError,
@@ -16,7 +16,7 @@ import {
16} from '@shared/extra-utils' 16} from '@shared/extra-utils'
17import { VideoPrivacy } from '@shared/models' 17import { VideoPrivacy } from '@shared/models'
18 18
19async function createLiveWrapper (server: ServerInfo) { 19async function createLiveWrapper (server: PeerTubeServer) {
20 const liveAttributes = { 20 const liveAttributes = {
21 name: 'live video', 21 name: 'live video',
22 channelId: server.store.channel.id, 22 channelId: server.store.channel.id,
@@ -28,7 +28,7 @@ async function createLiveWrapper (server: ServerInfo) {
28 return uuid 28 return uuid
29} 29}
30 30
31function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) { 31function updateConf (server: PeerTubeServer, vodProfile: string, liveProfile: string) {
32 return server.config.updateCustomSubConfig({ 32 return server.config.updateCustomSubConfig({
33 newConfig: { 33 newConfig: {
34 transcoding: { 34 transcoding: {
@@ -64,12 +64,12 @@ function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string
64} 64}
65 65
66describe('Test transcoding plugins', function () { 66describe('Test transcoding plugins', function () {
67 let server: ServerInfo 67 let server: PeerTubeServer
68 68
69 before(async function () { 69 before(async function () {
70 this.timeout(60000) 70 this.timeout(60000)
71 71
72 server = await flushAndRunServer(1) 72 server = await createSingleServer(1)
73 await setAccessTokensToServers([ server ]) 73 await setAccessTokensToServers([ server ])
74 await setDefaultVideoChannel([ server ]) 74 await setDefaultVideoChannel([ server ])
75 75
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts
index 26a27abca..6c405b7f5 100644
--- a/server/tests/plugins/plugin-unloading.ts
+++ b/server/tests/plugins/plugin-unloading.ts
@@ -3,17 +3,24 @@
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' 6import {
7 cleanupTests,
8 createSingleServer,
9 makeGetRequest,
10 PeerTubeServer,
11 PluginsCommand,
12 setAccessTokensToServers
13} from '@shared/extra-utils'
7 14
8describe('Test plugins module unloading', function () { 15describe('Test plugins module unloading', function () {
9 let server: ServerInfo = null 16 let server: PeerTubeServer = null
10 const requestPath = '/plugins/test-unloading/router/get' 17 const requestPath = '/plugins/test-unloading/router/get'
11 let value: string = null 18 let value: string = null
12 19
13 before(async function () { 20 before(async function () {
14 this.timeout(30000) 21 this.timeout(30000)
15 22
16 server = await flushAndRunServer(1) 23 server = await createSingleServer(1)
17 await setAccessTokensToServers([ server ]) 24 await setAccessTokensToServers([ server ])
18 25
19 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) 26 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts
index d8d878026..8b25c6b75 100644
--- a/server/tests/plugins/translations.ts
+++ b/server/tests/plugins/translations.ts
@@ -2,19 +2,18 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils' 5import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils'
6import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
7 6
8const expect = chai.expect 7const expect = chai.expect
9 8
10describe('Test plugin translations', function () { 9describe('Test plugin translations', function () {
11 let server: ServerInfo 10 let server: PeerTubeServer
12 let command: PluginsCommand 11 let command: PluginsCommand
13 12
14 before(async function () { 13 before(async function () {
15 this.timeout(30000) 14 this.timeout(30000)
16 15
17 server = await flushAndRunServer(1) 16 server = await createSingleServer(1)
18 await setAccessTokensToServers([ server ]) 17 await setAccessTokensToServers([ server ])
19 18
20 command = server.plugins 19 command = server.plugins
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index facc6bbc1..953916e8e 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -3,18 +3,18 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { cleanupTests, flushAndRunServer, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
7import { VideoPlaylistPrivacy } from '@shared/models' 7import { VideoPlaylistPrivacy } from '@shared/models'
8 8
9const expect = chai.expect 9const expect = chai.expect
10 10
11describe('Test plugin altering video constants', function () { 11describe('Test plugin altering video constants', function () {
12 let server: ServerInfo 12 let server: PeerTubeServer
13 13
14 before(async function () { 14 before(async function () {
15 this.timeout(30000) 15 this.timeout(30000)
16 16
17 server = await flushAndRunServer(1) 17 server = await createSingleServer(1)
18 await setAccessTokensToServers([ server ]) 18 await setAccessTokensToServers([ server ])
19 19
20 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') }) 20 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })