aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-07 10:33:49 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commitae2abfd3aed3e75d39a316b49b914d187faa7475 (patch)
tree4d5060dc310f3d8cdcd5829779522f49b3d10e71 /server/tests/plugins
parent9c6327f803aaf4200672f1fc40b2f43786daca47 (diff)
downloadPeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.gz
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.zst
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.zip
Introduce plugins command
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/action-hooks.ts9
-rw-r--r--server/tests/plugins/external-auth.ts47
-rw-r--r--server/tests/plugins/filter-hooks.ts16
-rw-r--r--server/tests/plugins/html-injection.ts33
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts36
-rw-r--r--server/tests/plugins/plugin-helpers.ts24
-rw-r--r--server/tests/plugins/plugin-router.ts27
-rw-r--r--server/tests/plugins/plugin-storage.ts29
-rw-r--r--server/tests/plugins/plugin-transcoding.ts26
-rw-r--r--server/tests/plugins/plugin-unloading.ts32
-rw-r--r--server/tests/plugins/translations.ts46
-rw-r--r--server/tests/plugins/video-constants.ts28
12 files changed, 125 insertions, 228 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 0f57ef7fe..0de5b523b 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -11,8 +11,7 @@ import {
11 createUser, 11 createUser,
12 createVideoPlaylist, 12 createVideoPlaylist,
13 deleteVideoComment, 13 deleteVideoComment,
14 getPluginTestPath, 14 PluginsCommand,
15 installPlugin,
16 registerUser, 15 registerUser,
17 removeUser, 16 removeUser,
18 setAccessTokensToServers, 17 setAccessTokensToServers,
@@ -49,11 +48,7 @@ describe('Test plugin action hooks', function () {
49 await setAccessTokensToServers(servers) 48 await setAccessTokensToServers(servers)
50 await setDefaultVideoChannel(servers) 49 await setDefaultVideoChannel(servers)
51 50
52 await installPlugin({ 51 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() })
53 url: servers[0].url,
54 accessToken: servers[0].accessToken,
55 path: getPluginTestPath()
56 })
57 52
58 killallServers([ servers[0] ]) 53 killallServers([ servers[0] ])
59 54
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index 5addb45c7..424302786 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -2,27 +2,26 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { ServerConfig, User, UserRole } from '@shared/models' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests,
8 createUser,
7 decodeQueryString, 9 decodeQueryString,
10 flushAndRunServer,
8 getConfig, 11 getConfig,
9 getExternalAuth,
10 getMyUserInformation, 12 getMyUserInformation,
11 getPluginTestPath,
12 installPlugin,
13 loginUsingExternalToken, 13 loginUsingExternalToken,
14 logout, 14 logout,
15 PluginsCommand,
15 refreshToken, 16 refreshToken,
17 ServerInfo,
16 setAccessTokensToServers, 18 setAccessTokensToServers,
17 uninstallPlugin,
18 updateMyUser, 19 updateMyUser,
19 wait,
20 userLogin, 20 userLogin,
21 updatePluginSettings, 21 wait,
22 createUser 22 waitUntilLog
23} from '../../../shared/extra-utils' 23} from '@shared/extra-utils'
24import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' 24import { ServerConfig, User, UserRole } from '@shared/models'
25import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
26 25
27async function loginExternal (options: { 26async function loginExternal (options: {
28 server: ServerInfo 27 server: ServerInfo
@@ -33,13 +32,12 @@ async function loginExternal (options: {
33 statusCodeExpected?: HttpStatusCode 32 statusCodeExpected?: HttpStatusCode
34 statusCodeExpectedStep2?: HttpStatusCode 33 statusCodeExpectedStep2?: HttpStatusCode
35}) { 34}) {
36 const res = await getExternalAuth({ 35 const res = await options.server.pluginsCommand.getExternalAuth({
37 url: options.server.url,
38 npmName: options.npmName, 36 npmName: options.npmName,
39 npmVersion: '0.0.1', 37 npmVersion: '0.0.1',
40 authName: options.authName, 38 authName: options.authName,
41 query: options.query, 39 query: options.query,
42 statusCodeExpected: options.statusCodeExpected || HttpStatusCode.FOUND_302 40 expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302
43 }) 41 })
44 42
45 if (res.status !== HttpStatusCode.FOUND_302) return 43 if (res.status !== HttpStatusCode.FOUND_302) return
@@ -75,11 +73,7 @@ describe('Test external auth plugins', function () {
75 await setAccessTokensToServers([ server ]) 73 await setAccessTokensToServers([ server ])
76 74
77 for (const suffix of [ 'one', 'two', 'three' ]) { 75 for (const suffix of [ 'one', 'two', 'three' ]) {
78 await installPlugin({ 76 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) })
79 url: server.url,
80 accessToken: server.accessToken,
81 path: getPluginTestPath('-external-auth-' + suffix)
82 })
83 } 77 }
84 }) 78 })
85 79
@@ -98,15 +92,14 @@ describe('Test external auth plugins', function () {
98 }) 92 })
99 93
100 it('Should redirect for a Cyan login', async function () { 94 it('Should redirect for a Cyan login', async function () {
101 const res = await getExternalAuth({ 95 const res = await server.pluginsCommand.getExternalAuth({
102 url: server.url,
103 npmName: 'test-external-auth-one', 96 npmName: 'test-external-auth-one',
104 npmVersion: '0.0.1', 97 npmVersion: '0.0.1',
105 authName: 'external-auth-1', 98 authName: 'external-auth-1',
106 query: { 99 query: {
107 username: 'cyan' 100 username: 'cyan'
108 }, 101 },
109 statusCodeExpected: HttpStatusCode.FOUND_302 102 expectedStatus: HttpStatusCode.FOUND_302
110 }) 103 })
111 104
112 const location = res.header.location 105 const location = res.header.location
@@ -275,9 +268,7 @@ describe('Test external auth plugins', function () {
275 }) 268 })
276 269
277 it('Should unregister external-auth-2 and do not login existing Kefka', async function () { 270 it('Should unregister external-auth-2 and do not login existing Kefka', async function () {
278 await updatePluginSettings({ 271 await server.pluginsCommand.updateSettings({
279 url: server.url,
280 accessToken: server.accessToken,
281 npmName: 'peertube-plugin-test-external-auth-one', 272 npmName: 'peertube-plugin-test-external-auth-one',
282 settings: { disableKefka: true } 273 settings: { disableKefka: true }
283 }) 274 })
@@ -309,11 +300,7 @@ describe('Test external auth plugins', function () {
309 }) 300 })
310 301
311 it('Should uninstall the plugin one and do not login Cyan', async function () { 302 it('Should uninstall the plugin one and do not login Cyan', async function () {
312 await uninstallPlugin({ 303 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' })
313 url: server.url,
314 accessToken: server.accessToken,
315 npmName: 'peertube-plugin-test-external-auth-one'
316 })
317 304
318 await loginExternal({ 305 await loginExternal({
319 server, 306 server,
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index e2ec5457b..c51e96ab7 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -14,7 +14,6 @@ import {
14 getAccountVideos, 14 getAccountVideos,
15 getConfig, 15 getConfig,
16 getMyVideos, 16 getMyVideos,
17 getPluginTestPath,
18 getVideo, 17 getVideo,
19 getVideoChannelVideos, 18 getVideoChannelVideos,
20 getVideoCommentThreads, 19 getVideoCommentThreads,
@@ -23,8 +22,8 @@ import {
23 getVideosListPagination, 22 getVideosListPagination,
24 getVideoThreadComments, 23 getVideoThreadComments,
25 getVideoWithToken, 24 getVideoWithToken,
26 installPlugin,
27 makeRawRequest, 25 makeRawRequest,
26 PluginsCommand,
28 registerUser, 27 registerUser,
29 ServerInfo, 28 ServerInfo,
30 setAccessTokensToServers, 29 setAccessTokensToServers,
@@ -63,17 +62,8 @@ describe('Test plugin filter hooks', function () {
63 await setDefaultVideoChannel(servers) 62 await setDefaultVideoChannel(servers)
64 await doubleFollow(servers[0], servers[1]) 63 await doubleFollow(servers[0], servers[1])
65 64
66 await installPlugin({ 65 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() })
67 url: servers[0].url, 66 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
68 accessToken: servers[0].accessToken,
69 path: getPluginTestPath()
70 })
71
72 await installPlugin({
73 url: servers[0].url,
74 accessToken: servers[0].accessToken,
75 path: getPluginTestPath('-filter-translations')
76 })
77 67
78 for (let i = 0; i < 10; i++) { 68 for (let i = 0; i < 10; i++) {
79 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'default video ' + i }) 69 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'default video ' + i })
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts
index 4fa8caa3a..80d67ae0e 100644
--- a/server/tests/plugins/html-injection.ts
+++ b/server/tests/plugins/html-injection.ts
@@ -5,30 +5,31 @@ import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunServer, 7 flushAndRunServer,
8 getPluginsCSS,
9 installPlugin,
10 makeHTMLRequest, 8 makeHTMLRequest,
9 PluginsCommand,
11 ServerInfo, 10 ServerInfo,
12 setAccessTokensToServers, 11 setAccessTokensToServers
13 uninstallPlugin
14} from '../../../shared/extra-utils' 12} from '../../../shared/extra-utils'
15 13
16const expect = chai.expect 14const expect = chai.expect
17 15
18describe('Test plugins HTML injection', function () { 16describe('Test plugins HTML injection', function () {
19 let server: ServerInfo = null 17 let server: ServerInfo = null
18 let command: PluginsCommand
20 19
21 before(async function () { 20 before(async function () {
22 this.timeout(30000) 21 this.timeout(30000)
23 22
24 server = await flushAndRunServer(1) 23 server = await flushAndRunServer(1)
25 await setAccessTokensToServers([ server ]) 24 await setAccessTokensToServers([ server ])
25
26 command = server.pluginsCommand
26 }) 27 })
27 28
28 it('Should not inject global css file in HTML', async function () { 29 it('Should not inject global css file in HTML', async function () {
29 { 30 {
30 const res = await getPluginsCSS(server.url) 31 const text = await command.getCSS()
31 expect(res.text).to.be.empty 32 expect(text).to.be.empty
32 } 33 }
33 34
34 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { 35 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
@@ -40,17 +41,13 @@ describe('Test plugins HTML injection', function () {
40 it('Should install a plugin and a theme', async function () { 41 it('Should install a plugin and a theme', async function () {
41 this.timeout(30000) 42 this.timeout(30000)
42 43
43 await installPlugin({ 44 await command.install({ npmName: 'peertube-plugin-hello-world' })
44 url: server.url,
45 accessToken: server.accessToken,
46 npmName: 'peertube-plugin-hello-world'
47 })
48 }) 45 })
49 46
50 it('Should have the correct global css', async function () { 47 it('Should have the correct global css', async function () {
51 { 48 {
52 const res = await getPluginsCSS(server.url) 49 const text = await command.getCSS()
53 expect(res.text).to.contain('background-color: red') 50 expect(text).to.contain('background-color: red')
54 } 51 }
55 52
56 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { 53 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
@@ -60,15 +57,11 @@ describe('Test plugins HTML injection', function () {
60 }) 57 })
61 58
62 it('Should have an empty global css on uninstall', async function () { 59 it('Should have an empty global css on uninstall', async function () {
63 await uninstallPlugin({ 60 await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
64 url: server.url,
65 accessToken: server.accessToken,
66 npmName: 'peertube-plugin-hello-world'
67 })
68 61
69 { 62 {
70 const res = await getPluginsCSS(server.url) 63 const text = await command.getCSS()
71 expect(res.text).to.be.empty 64 expect(text).to.be.empty
72 } 65 }
73 66
74 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) { 67 for (const path of [ '/', '/videos/embed/1', '/video-playlists/embed/1' ]) {
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts
index cbba638c2..545968040 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -1,21 +1,25 @@
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 { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' 4import { expect } from 'chai'
5import { 5import {
6 cleanupTests,
7 flushAndRunServer,
8 getConfig,
6 getMyUserInformation, 9 getMyUserInformation,
7 getPluginTestPath, 10 getUsersList,
8 installPlugin, 11 login,
9 logout, 12 logout,
13 PluginsCommand,
14 refreshToken,
15 ServerInfo,
10 setAccessTokensToServers, 16 setAccessTokensToServers,
11 uninstallPlugin,
12 updateMyUser, 17 updateMyUser,
13 userLogin, 18 userLogin,
14 wait, 19 wait,
15 login, refreshToken, getConfig, updatePluginSettings, getUsersList 20 waitUntilLog
16} from '../../../shared/extra-utils' 21} from '@shared/extra-utils'
17import { User, UserRole, ServerConfig } from '@shared/models' 22import { ServerConfig, User, UserRole } from '@shared/models'
18import { expect } from 'chai'
19 23
20describe('Test id and pass auth plugins', function () { 24describe('Test id and pass auth plugins', function () {
21 let server: ServerInfo 25 let server: ServerInfo
@@ -33,11 +37,7 @@ describe('Test id and pass auth plugins', function () {
33 await setAccessTokensToServers([ server ]) 37 await setAccessTokensToServers([ server ])
34 38
35 for (const suffix of [ 'one', 'two', 'three' ]) { 39 for (const suffix of [ 'one', 'two', 'three' ]) {
36 await installPlugin({ 40 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) })
37 url: server.url,
38 accessToken: server.accessToken,
39 path: getPluginTestPath('-id-pass-auth-' + suffix)
40 })
41 } 41 }
42 }) 42 })
43 43
@@ -180,9 +180,7 @@ describe('Test id and pass auth plugins', function () {
180 }) 180 })
181 181
182 it('Should unregister spyro-auth and do not login existing Spyro', async function () { 182 it('Should unregister spyro-auth and do not login existing Spyro', async function () {
183 await updatePluginSettings({ 183 await server.pluginsCommand.updateSettings({
184 url: server.url,
185 accessToken: server.accessToken,
186 npmName: 'peertube-plugin-test-id-pass-auth-one', 184 npmName: 'peertube-plugin-test-id-pass-auth-one',
187 settings: { disableSpyro: true } 185 settings: { disableSpyro: true }
188 }) 186 })
@@ -204,11 +202,7 @@ describe('Test id and pass auth plugins', function () {
204 }) 202 })
205 203
206 it('Should uninstall the plugin one and do not login existing Crash', async function () { 204 it('Should uninstall the plugin one and do not login existing Crash', async function () {
207 await uninstallPlugin({ 205 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
208 url: server.url,
209 accessToken: server.accessToken,
210 npmName: 'peertube-plugin-test-id-pass-auth-one'
211 })
212 206
213 await userLogin(server, { username: 'crash', password: 'crash password' }, 400) 207 await userLogin(server, { username: 'crash', password: 'crash password' }, 400)
214 }) 208 })
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 0296d6eb7..0e0f61638 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -1,23 +1,25 @@
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 { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
4import { 6import {
5 checkVideoFilesWereRemoved, 7 checkVideoFilesWereRemoved,
8 cleanupTests,
6 doubleFollow, 9 doubleFollow,
7 getPluginTestPath, 10 flushAndRunMultipleServers,
8 getVideo, 11 getVideo,
9 installPlugin, 12 getVideosList,
13 makeGetRequest,
10 makePostBodyRequest, 14 makePostBodyRequest,
15 PluginsCommand,
16 ServerInfo,
11 setAccessTokensToServers, 17 setAccessTokensToServers,
12 uploadVideoAndGetId, 18 uploadVideoAndGetId,
13 viewVideo, 19 viewVideo,
14 getVideosList,
15 waitJobs, 20 waitJobs,
16 makeGetRequest 21 waitUntilLog
17} from '../../../shared/extra-utils' 22} from '@shared/extra-utils'
18import { cleanupTests, flushAndRunMultipleServers, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers'
19import { expect } from 'chai'
20import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
21 23
22function postCommand (server: ServerInfo, command: string, bodyArg?: object) { 24function postCommand (server: ServerInfo, command: string, bodyArg?: object) {
23 const body = { command } 25 const body = { command }
@@ -42,11 +44,7 @@ describe('Test plugin helpers', function () {
42 44
43 await doubleFollow(servers[0], servers[1]) 45 await doubleFollow(servers[0], servers[1])
44 46
45 await installPlugin({ 47 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-four') })
46 url: servers[0].url,
47 accessToken: servers[0].accessToken,
48 path: getPluginTestPath('-four')
49 })
50 }) 48 })
51 49
52 describe('Logger', function () { 50 describe('Logger', function () {
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts
index 24e6a1e83..81e18dabd 100644
--- a/server/tests/plugins/plugin-router.ts
+++ b/server/tests/plugins/plugin-router.ts
@@ -1,16 +1,17 @@
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 { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
5import { 6import {
6 getPluginTestPath, 7 cleanupTests,
7 installPlugin, 8 flushAndRunServer,
8 makeGetRequest, 9 makeGetRequest,
9 makePostBodyRequest, 10 makePostBodyRequest,
10 setAccessTokensToServers, uninstallPlugin 11 PluginsCommand,
11} from '../../../shared/extra-utils' 12 ServerInfo,
12import { expect } from 'chai' 13 setAccessTokensToServers
13import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 14} from '@shared/extra-utils'
14 15
15describe('Test plugin helpers', function () { 16describe('Test plugin helpers', function () {
16 let server: ServerInfo 17 let server: ServerInfo
@@ -25,11 +26,7 @@ describe('Test plugin helpers', function () {
25 server = await flushAndRunServer(1) 26 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ]) 27 await setAccessTokensToServers([ server ])
27 28
28 await installPlugin({ 29 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-five') })
29 url: server.url,
30 accessToken: server.accessToken,
31 path: getPluginTestPath('-five')
32 })
33 }) 30 })
34 31
35 it('Should answer "pong"', async function () { 32 it('Should answer "pong"', async function () {
@@ -85,11 +82,7 @@ describe('Test plugin helpers', function () {
85 }) 82 })
86 83
87 it('Should remove the plugin and remove the routes', async function () { 84 it('Should remove the plugin and remove the routes', async function () {
88 await uninstallPlugin({ 85 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-five' })
89 url: server.url,
90 accessToken: server.accessToken,
91 npmName: 'peertube-plugin-test-five'
92 })
93 86
94 for (const path of basePaths) { 87 for (const path of basePaths) {
95 await makeGetRequest({ 88 await makeGetRequest({
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 3c46b2585..4c65463f2 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -7,13 +7,14 @@ import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/core-utils'
8import { 8import {
9 buildServerDirectory, 9 buildServerDirectory,
10 getPluginTestPath, 10 cleanupTests,
11 installPlugin, 11 flushAndRunServer,
12 makeGetRequest, 12 makeGetRequest,
13 PluginsCommand,
14 ServerInfo,
13 setAccessTokensToServers, 15 setAccessTokensToServers,
14 uninstallPlugin 16 waitUntilLog
15} from '../../../shared/extra-utils' 17} from '@shared/extra-utils'
16import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers'
17 18
18describe('Test plugin storage', function () { 19describe('Test plugin storage', function () {
19 let server: ServerInfo 20 let server: ServerInfo
@@ -24,11 +25,7 @@ describe('Test plugin storage', function () {
24 server = await flushAndRunServer(1) 25 server = await flushAndRunServer(1)
25 await setAccessTokensToServers([ server ]) 26 await setAccessTokensToServers([ server ])
26 27
27 await installPlugin({ 28 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') })
28 url: server.url,
29 accessToken: server.accessToken,
30 path: getPluginTestPath('-six')
31 })
32 }) 29 })
33 30
34 describe('DB storage', function () { 31 describe('DB storage', function () {
@@ -76,22 +73,14 @@ describe('Test plugin storage', function () {
76 }) 73 })
77 74
78 it('Should still have the file after an uninstallation', async function () { 75 it('Should still have the file after an uninstallation', async function () {
79 await uninstallPlugin({ 76 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-six' })
80 url: server.url,
81 accessToken: server.accessToken,
82 npmName: 'peertube-plugin-test-six'
83 })
84 77
85 const content = await getFileContent() 78 const content = await getFileContent()
86 expect(content).to.equal('Prince Ali') 79 expect(content).to.equal('Prince Ali')
87 }) 80 })
88 81
89 it('Should still have the file after the reinstallation', async function () { 82 it('Should still have the file after the reinstallation', async function () {
90 await installPlugin({ 83 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') })
91 url: server.url,
92 accessToken: server.accessToken,
93 path: getPluginTestPath('-six')
94 })
95 84
96 const content = await getFileContent() 85 const content = await getFileContent()
97 expect(content).to.equal('Prince Ali') 86 expect(content).to.equal('Prince Ali')
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts
index eefb2294d..f1ff91077 100644
--- a/server/tests/plugins/plugin-transcoding.ts
+++ b/server/tests/plugins/plugin-transcoding.ts
@@ -4,25 +4,25 @@ import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' 6import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
7import { ServerConfig, VideoDetails, VideoPrivacy } from '@shared/models'
8import { 7import {
9 buildServerDirectory, 8 buildServerDirectory,
9 cleanupTests,
10 createLive, 10 createLive,
11 flushAndRunServer,
11 getConfig, 12 getConfig,
12 getPluginTestPath,
13 getVideo, 13 getVideo,
14 installPlugin, 14 PluginsCommand,
15 sendRTMPStreamInVideo, 15 sendRTMPStreamInVideo,
16 ServerInfo,
16 setAccessTokensToServers, 17 setAccessTokensToServers,
17 setDefaultVideoChannel, 18 setDefaultVideoChannel,
18 testFfmpegStreamError, 19 testFfmpegStreamError,
19 uninstallPlugin,
20 updateCustomSubConfig, 20 updateCustomSubConfig,
21 uploadVideoAndGetId, 21 uploadVideoAndGetId,
22 waitJobs, 22 waitJobs,
23 waitUntilLivePublished 23 waitUntilLivePublished
24} from '../../../shared/extra-utils' 24} from '@shared/extra-utils'
25import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' 25import { ServerConfig, VideoDetails, VideoPrivacy } from '@shared/models'
26 26
27async function createLiveWrapper (server: ServerInfo) { 27async function createLiveWrapper (server: ServerInfo) {
28 const liveAttributes = { 28 const liveAttributes = {
@@ -109,11 +109,7 @@ describe('Test transcoding plugins', function () {
109 } 109 }
110 110
111 before(async function () { 111 before(async function () {
112 await installPlugin({ 112 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') })
113 url: server.url,
114 accessToken: server.accessToken,
115 path: getPluginTestPath('-transcoding-one')
116 })
117 }) 113 })
118 114
119 it('Should have the appropriate available profiles', async function () { 115 it('Should have the appropriate available profiles', async function () {
@@ -225,7 +221,7 @@ describe('Test transcoding plugins', function () {
225 it('Should default to the default profile if the specified profile does not exist', async function () { 221 it('Should default to the default profile if the specified profile does not exist', async function () {
226 this.timeout(240000) 222 this.timeout(240000)
227 223
228 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-transcoding-one' }) 224 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
229 225
230 const res = await getConfig(server.url) 226 const res = await getConfig(server.url)
231 const config = res.body as ServerConfig 227 const config = res.body as ServerConfig
@@ -244,11 +240,7 @@ describe('Test transcoding plugins', function () {
244 describe('When using a plugin adding new encoders', function () { 240 describe('When using a plugin adding new encoders', function () {
245 241
246 before(async function () { 242 before(async function () {
247 await installPlugin({ 243 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') })
248 url: server.url,
249 accessToken: server.accessToken,
250 path: getPluginTestPath('-transcoding-two')
251 })
252 244
253 await updateConf(server, 'test-vod-profile', 'test-live-profile') 245 await updateConf(server, 'test-vod-profile', 'test-live-profile')
254 }) 246 })
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts
index 74ca82e2f..f430f82b8 100644
--- a/server/tests/plugins/plugin-unloading.ts
+++ b/server/tests/plugins/plugin-unloading.ts
@@ -1,18 +1,9 @@
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 {
5 cleanupTests,
6 flushAndRunServer,
7 getPluginTestPath,
8 makeGetRequest,
9 installPlugin,
10 uninstallPlugin,
11 ServerInfo,
12 setAccessTokensToServers
13} from '../../../shared/extra-utils'
14import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
15import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
6import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
16 7
17describe('Test plugins module unloading', function () { 8describe('Test plugins module unloading', function () {
18 let server: ServerInfo = null 9 let server: ServerInfo = null
@@ -25,11 +16,7 @@ describe('Test plugins module unloading', function () {
25 server = await flushAndRunServer(1) 16 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ]) 17 await setAccessTokensToServers([ server ])
27 18
28 await installPlugin({ 19 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
29 url: server.url,
30 accessToken: server.accessToken,
31 path: getPluginTestPath('-unloading')
32 })
33 }) 20 })
34 21
35 it('Should return a numeric value', async function () { 22 it('Should return a numeric value', async function () {
@@ -54,11 +41,7 @@ describe('Test plugins module unloading', function () {
54 }) 41 })
55 42
56 it('Should uninstall the plugin and free the route', async function () { 43 it('Should uninstall the plugin and free the route', async function () {
57 await uninstallPlugin({ 44 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' })
58 url: server.url,
59 accessToken: server.accessToken,
60 npmName: 'peertube-plugin-test-unloading'
61 })
62 45
63 await makeGetRequest({ 46 await makeGetRequest({
64 url: server.url, 47 url: server.url,
@@ -68,11 +51,8 @@ describe('Test plugins module unloading', function () {
68 }) 51 })
69 52
70 it('Should return a different numeric value', async function () { 53 it('Should return a different numeric value', async function () {
71 await installPlugin({ 54 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
72 url: server.url, 55
73 accessToken: server.accessToken,
74 path: getPluginTestPath('-unloading')
75 })
76 const res = await makeGetRequest({ 56 const res = await makeGetRequest({
77 url: server.url, 57 url: server.url,
78 path: requestPath, 58 path: requestPath,
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts
index 9fd2ba1c5..0e11a0b53 100644
--- a/server/tests/plugins/translations.ts
+++ b/server/tests/plugins/translations.ts
@@ -1,20 +1,15 @@
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 * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils'
5import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' 6import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
6import {
7 getPluginTestPath,
8 getPluginTranslations,
9 installPlugin,
10 setAccessTokensToServers,
11 uninstallPlugin
12} from '../../../shared/extra-utils'
13 7
14const expect = chai.expect 8const expect = chai.expect
15 9
16describe('Test plugin translations', function () { 10describe('Test plugin translations', function () {
17 let server: ServerInfo 11 let server: ServerInfo
12 let command: PluginsCommand
18 13
19 before(async function () { 14 before(async function () {
20 this.timeout(30000) 15 this.timeout(30000)
@@ -22,29 +17,22 @@ describe('Test plugin translations', function () {
22 server = await flushAndRunServer(1) 17 server = await flushAndRunServer(1)
23 await setAccessTokensToServers([ server ]) 18 await setAccessTokensToServers([ server ])
24 19
25 await installPlugin({ 20 command = server.pluginsCommand
26 url: server.url,
27 accessToken: server.accessToken,
28 path: getPluginTestPath()
29 })
30 21
31 await installPlugin({ 22 await command.install({ path: PluginsCommand.getPluginTestPath() })
32 url: server.url, 23 await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
33 accessToken: server.accessToken,
34 path: getPluginTestPath('-filter-translations')
35 })
36 }) 24 })
37 25
38 it('Should not have translations for locale pt', async function () { 26 it('Should not have translations for locale pt', async function () {
39 const res = await getPluginTranslations({ url: server.url, locale: 'pt' }) 27 const body = await command.getTranslations({ locale: 'pt' })
40 28
41 expect(res.body).to.deep.equal({}) 29 expect(body).to.deep.equal({})
42 }) 30 })
43 31
44 it('Should have translations for locale fr', async function () { 32 it('Should have translations for locale fr', async function () {
45 const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) 33 const body = await command.getTranslations({ locale: 'fr-FR' })
46 34
47 expect(res.body).to.deep.equal({ 35 expect(body).to.deep.equal({
48 'peertube-plugin-test': { 36 'peertube-plugin-test': {
49 Hi: 'Coucou' 37 Hi: 'Coucou'
50 }, 38 },
@@ -55,9 +43,9 @@ describe('Test plugin translations', function () {
55 }) 43 })
56 44
57 it('Should have translations of locale it', async function () { 45 it('Should have translations of locale it', async function () {
58 const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) 46 const body = await command.getTranslations({ locale: 'it-IT' })
59 47
60 expect(res.body).to.deep.equal({ 48 expect(body).to.deep.equal({
61 'peertube-plugin-test-filter-translations': { 49 'peertube-plugin-test-filter-translations': {
62 'Hello world': 'Ciao, mondo!' 50 'Hello world': 'Ciao, mondo!'
63 } 51 }
@@ -65,12 +53,12 @@ describe('Test plugin translations', function () {
65 }) 53 })
66 54
67 it('Should remove the plugin and remove the locales', async function () { 55 it('Should remove the plugin and remove the locales', async function () {
68 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-filter-translations' }) 56 await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' })
69 57
70 { 58 {
71 const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) 59 const body = await command.getTranslations({ locale: 'fr-FR' })
72 60
73 expect(res.body).to.deep.equal({ 61 expect(body).to.deep.equal({
74 'peertube-plugin-test': { 62 'peertube-plugin-test': {
75 Hi: 'Coucou' 63 Hi: 'Coucou'
76 } 64 }
@@ -78,9 +66,9 @@ describe('Test plugin translations', function () {
78 } 66 }
79 67
80 { 68 {
81 const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) 69 const body = await command.getTranslations({ locale: 'it-IT' })
82 70
83 expect(res.body).to.deep.equal({}) 71 expect(body).to.deep.equal({})
84 } 72 }
85 }) 73 })
86 74
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index eb014c596..4124e8a52 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -1,22 +1,24 @@
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 * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests,
7 createVideoPlaylist, 8 createVideoPlaylist,
8 getPluginTestPath, 9 flushAndRunServer,
9 getVideo, 10 getVideo,
10 getVideoCategories, 11 getVideoCategories,
11 getVideoLanguages, 12 getVideoLanguages,
12 getVideoLicences, getVideoPlaylistPrivacies, getVideoPrivacies, 13 getVideoLicences,
13 installPlugin, 14 getVideoPlaylistPrivacies,
15 getVideoPrivacies,
16 PluginsCommand,
17 ServerInfo,
14 setAccessTokensToServers, 18 setAccessTokensToServers,
15 uninstallPlugin,
16 uploadVideo 19 uploadVideo
17} from '../../../shared/extra-utils' 20} from '@shared/extra-utils'
18import { VideoDetails, VideoPlaylistPrivacy } from '../../../shared/models/videos' 21import { VideoDetails, VideoPlaylistPrivacy } from '@shared/models'
19import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
20 22
21const expect = chai.expect 23const expect = chai.expect
22 24
@@ -29,11 +31,7 @@ describe('Test plugin altering video constants', function () {
29 server = await flushAndRunServer(1) 31 server = await flushAndRunServer(1)
30 await setAccessTokensToServers([ server ]) 32 await setAccessTokensToServers([ server ])
31 33
32 await installPlugin({ 34 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
33 url: server.url,
34 accessToken: server.accessToken,
35 path: getPluginTestPath('-video-constants')
36 })
37 }) 35 })
38 36
39 it('Should have updated languages', async function () { 37 it('Should have updated languages', async function () {
@@ -117,7 +115,7 @@ describe('Test plugin altering video constants', function () {
117 }) 115 })
118 116
119 it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () { 117 it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () {
120 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-video-constants' }) 118 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-video-constants' })
121 119
122 { 120 {
123 const res = await getVideoLanguages(server.url) 121 const res = await getVideoLanguages(server.url)