aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
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
parent9c6327f803aaf4200672f1fc40b2f43786daca47 (diff)
downloadPeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.gz
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.zst
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.zip
Introduce plugins command
Diffstat (limited to 'server')
-rw-r--r--server/tests/api/check-params/plugins.ts5
-rw-r--r--server/tests/api/notifications/admin-notifications.ts31
-rw-r--r--server/tests/api/server/plugins.ts188
-rw-r--r--server/tests/api/users/users.ts3
-rw-r--r--server/tests/cli/plugins.ts4
-rw-r--r--server/tests/external-plugins/auth-ldap.ts28
-rw-r--r--server/tests/external-plugins/auto-block-videos.ts19
-rw-r--r--server/tests/external-plugins/auto-mute.ts40
-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
20 files changed, 212 insertions, 459 deletions
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index a833fe6ff..d372221d0 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -10,7 +10,6 @@ import {
10 createUser, 10 createUser,
11 flushAndRunServer, 11 flushAndRunServer,
12 immutableAssign, 12 immutableAssign,
13 installPlugin,
14 makeGetRequest, 13 makeGetRequest,
15 makePostBodyRequest, 14 makePostBodyRequest,
16 makePutBodyRequest, 15 makePutBodyRequest,
@@ -50,13 +49,13 @@ describe('Test server plugins API validators', function () {
50 userAccessToken = await userLogin(server, user) 49 userAccessToken = await userLogin(server, user)
51 50
52 { 51 {
53 const res = await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: npmPlugin }) 52 const res = await server.pluginsCommand.install({ npmName: npmPlugin })
54 const plugin = res.body as PeerTubePlugin 53 const plugin = res.body as PeerTubePlugin
55 npmVersion = plugin.version 54 npmVersion = plugin.version
56 } 55 }
57 56
58 { 57 {
59 const res = await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: themePlugin }) 58 const res = await server.pluginsCommand.install({ npmName: themePlugin })
60 const plugin = res.body as PeerTubePlugin 59 const plugin = res.body as PeerTubePlugin
61 themeVersion = plugin.version 60 themeVersion = plugin.version
62 } 61 }
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts
index 91681c9d6..da9767b74 100644
--- a/server/tests/api/notifications/admin-notifications.ts
+++ b/server/tests/api/notifications/admin-notifications.ts
@@ -2,18 +2,20 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { MockJoinPeerTubeVersions } from '@shared/extra-utils'
6import { PluginType } from '@shared/models'
7import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils'
8import { ServerInfo } from '../../../../shared/extra-utils/index'
9import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
10import { 5import {
11 CheckerBaseParams, 6 CheckerBaseParams,
12 checkNewPeerTubeVersion, 7 checkNewPeerTubeVersion,
13 checkNewPluginVersion, 8 checkNewPluginVersion,
14 prepareNotificationsTest 9 cleanupTests,
15} from '../../../../shared/extra-utils/users/user-notifications' 10 MockJoinPeerTubeVersions,
16import { UserNotification, UserNotificationType } from '../../../../shared/models/users' 11 MockSmtpServer,
12 prepareNotificationsTest,
13 ServerInfo,
14 setPluginLatestVersion,
15 setPluginVersion,
16 wait
17} from '@shared/extra-utils'
18import { PluginType, UserNotification, UserNotificationType } from '@shared/models'
17 19
18describe('Test admin notifications', function () { 20describe('Test admin notifications', function () {
19 let server: ServerInfo 21 let server: ServerInfo
@@ -58,17 +60,8 @@ describe('Test admin notifications', function () {
58 token: server.accessToken 60 token: server.accessToken
59 } 61 }
60 62
61 await installPlugin({ 63 await server.pluginsCommand.install({ npmName: 'peertube-plugin-hello-world' })
62 url: server.url, 64 await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' })
63 accessToken: server.accessToken,
64 npmName: 'peertube-plugin-hello-world'
65 })
66
67 await installPlugin({
68 url: server.url,
69 accessToken: server.accessToken,
70 npmName: 'peertube-theme-background-red'
71 })
72 }) 65 })
73 66
74 describe('Latest PeerTube version notification', function () { 67 describe('Latest PeerTube version notification', function () {
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index 6b61c7c33..1536997d5 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -9,34 +9,25 @@ import {
9 flushAndRunServer, 9 flushAndRunServer,
10 getConfig, 10 getConfig,
11 getMyUserInformation, 11 getMyUserInformation,
12 getPlugin,
13 getPluginPackageJSON,
14 getPluginTestPath,
15 getPublicSettings,
16 installPlugin,
17 killallServers, 12 killallServers,
18 listAvailablePlugins, 13 PluginsCommand,
19 listPlugins,
20 reRunServer, 14 reRunServer,
21 ServerInfo, 15 ServerInfo,
22 setAccessTokensToServers, 16 setAccessTokensToServers,
23 setPluginVersion, 17 setPluginVersion,
24 testHelloWorldRegisteredSettings, 18 testHelloWorldRegisteredSettings,
25 uninstallPlugin,
26 updateCustomSubConfig, 19 updateCustomSubConfig,
27 updateMyUser, 20 updateMyUser,
28 updatePlugin,
29 updatePluginPackageJSON,
30 updatePluginSettings,
31 wait, 21 wait,
32 waitUntilLog 22 waitUntilLog
33} from '@shared/extra-utils' 23} from '@shared/extra-utils'
34import { PeerTubePlugin, PeerTubePluginIndex, PluginPackageJson, PluginType, PublicServerSetting, ServerConfig, User } from '@shared/models' 24import { PluginType, ServerConfig, User } from '@shared/models'
35 25
36const expect = chai.expect 26const expect = chai.expect
37 27
38describe('Test plugins', function () { 28describe('Test plugins', function () {
39 let server: ServerInfo = null 29 let server: ServerInfo = null
30 let command: PluginsCommand
40 31
41 before(async function () { 32 before(async function () {
42 this.timeout(30000) 33 this.timeout(30000)
@@ -54,60 +45,51 @@ describe('Test plugins', function () {
54 this.timeout(30000) 45 this.timeout(30000)
55 46
56 { 47 {
57 const res = await listAvailablePlugins({ 48 const body = await command.listAvailable({
58 url: server.url,
59 accessToken: server.accessToken,
60 count: 1, 49 count: 1,
61 start: 0, 50 start: 0,
62 pluginType: PluginType.THEME, 51 pluginType: PluginType.THEME,
63 search: 'background-red' 52 search: 'background-red'
64 }) 53 })
65 54
66 expect(res.body.total).to.be.at.least(1) 55 expect(body.total).to.be.at.least(1)
67 expect(res.body.data).to.have.lengthOf(1) 56 expect(body.data).to.have.lengthOf(1)
68 } 57 }
69 58
70 { 59 {
71 const res1 = await listAvailablePlugins({ 60 const body1 = await command.listAvailable({
72 url: server.url,
73 accessToken: server.accessToken,
74 count: 2, 61 count: 2,
75 start: 0, 62 start: 0,
76 sort: 'npmName' 63 sort: 'npmName'
77 }) 64 })
78 const data1: PeerTubePluginIndex[] = res1.body.data 65 expect(body1.total).to.be.at.least(2)
79 66
80 expect(res1.body.total).to.be.at.least(2) 67 const data1 = body1.data
81 expect(data1).to.have.lengthOf(2) 68 expect(data1).to.have.lengthOf(2)
82 69
83 const res2 = await listAvailablePlugins({ 70 const body2 = await command.listAvailable({
84 url: server.url,
85 accessToken: server.accessToken,
86 count: 2, 71 count: 2,
87 start: 0, 72 start: 0,
88 sort: '-npmName' 73 sort: '-npmName'
89 }) 74 })
90 const data2: PeerTubePluginIndex[] = res2.body.data 75 expect(body2.total).to.be.at.least(2)
91 76
92 expect(res2.body.total).to.be.at.least(2) 77 const data2 = body2.data
93 expect(data2).to.have.lengthOf(2) 78 expect(data2).to.have.lengthOf(2)
94 79
95 expect(data1[0].npmName).to.not.equal(data2[0].npmName) 80 expect(data1[0].npmName).to.not.equal(data2[0].npmName)
96 } 81 }
97 82
98 { 83 {
99 const res = await listAvailablePlugins({ 84 const body = await command.listAvailable({
100 url: server.url,
101 accessToken: server.accessToken,
102 count: 10, 85 count: 10,
103 start: 0, 86 start: 0,
104 pluginType: PluginType.THEME, 87 pluginType: PluginType.THEME,
105 search: 'background-red', 88 search: 'background-red',
106 currentPeerTubeEngine: '1.0.0' 89 currentPeerTubeEngine: '1.0.0'
107 }) 90 })
108 const data: PeerTubePluginIndex[] = res.body.data
109 91
110 const p = data.find(p => p.npmName === 'peertube-theme-background-red') 92 const p = body.data.find(p => p.npmName === 'peertube-theme-background-red')
111 expect(p).to.be.undefined 93 expect(p).to.be.undefined
112 } 94 }
113 }) 95 })
@@ -115,17 +97,8 @@ describe('Test plugins', function () {
115 it('Should install a plugin and a theme', async function () { 97 it('Should install a plugin and a theme', async function () {
116 this.timeout(30000) 98 this.timeout(30000)
117 99
118 await installPlugin({ 100 await command.install({ npmName: 'peertube-plugin-hello-world' })
119 url: server.url, 101 await command.install({ npmName: 'peertube-theme-background-red' })
120 accessToken: server.accessToken,
121 npmName: 'peertube-plugin-hello-world'
122 })
123
124 await installPlugin({
125 url: server.url,
126 accessToken: server.accessToken,
127 npmName: 'peertube-theme-background-red'
128 })
129 }) 102 })
130 103
131 it('Should have the plugin loaded in the configuration', async function () { 104 it('Should have the plugin loaded in the configuration', async function () {
@@ -161,45 +134,38 @@ describe('Test plugins', function () {
161 134
162 it('Should list plugins and themes', async function () { 135 it('Should list plugins and themes', async function () {
163 { 136 {
164 const res = await listPlugins({ 137 const body = await command.list({
165 url: server.url,
166 accessToken: server.accessToken,
167 count: 1, 138 count: 1,
168 start: 0, 139 start: 0,
169 pluginType: PluginType.THEME 140 pluginType: PluginType.THEME
170 }) 141 })
171 const data: PeerTubePlugin[] = res.body.data 142 expect(body.total).to.be.at.least(1)
172 143
173 expect(res.body.total).to.be.at.least(1) 144 const data = body.data
174 expect(data).to.have.lengthOf(1) 145 expect(data).to.have.lengthOf(1)
175 expect(data[0].name).to.equal('background-red') 146 expect(data[0].name).to.equal('background-red')
176 } 147 }
177 148
178 { 149 {
179 const res = await listPlugins({ 150 const body = await command.list({
180 url: server.url,
181 accessToken: server.accessToken,
182 count: 2, 151 count: 2,
183 start: 0, 152 start: 0,
184 sort: 'name' 153 sort: 'name'
185 }) 154 })
186 const data: PeerTubePlugin[] = res.body.data
187 155
156 const data = body
188 expect(data[0].name).to.equal('background-red') 157 expect(data[0].name).to.equal('background-red')
189 expect(data[1].name).to.equal('hello-world') 158 expect(data[1].name).to.equal('hello-world')
190 } 159 }
191 160
192 { 161 {
193 const res = await listPlugins({ 162 const body = await command.list({
194 url: server.url,
195 accessToken: server.accessToken,
196 count: 2, 163 count: 2,
197 start: 1, 164 start: 1,
198 sort: 'name' 165 sort: 'name'
199 }) 166 })
200 const data: PeerTubePlugin[] = res.body.data
201 167
202 expect(data[0].name).to.equal('hello-world') 168 expect(body.data[0].name).to.equal('hello-world')
203 } 169 }
204 }) 170 })
205 171
@@ -208,9 +174,8 @@ describe('Test plugins', function () {
208 }) 174 })
209 175
210 it('Should get public settings', async function () { 176 it('Should get public settings', async function () {
211 const res = await getPublicSettings({ url: server.url, npmName: 'peertube-plugin-hello-world' }) 177 const body = await command.getPublicSettings({ npmName: 'peertube-plugin-hello-world' })
212 178 const publicSettings = body.publicSettings
213 const publicSettings = (res.body as PublicServerSetting).publicSettings
214 179
215 expect(Object.keys(publicSettings)).to.have.lengthOf(1) 180 expect(Object.keys(publicSettings)).to.have.lengthOf(1)
216 expect(Object.keys(publicSettings)).to.deep.equal([ 'user-name' ]) 181 expect(Object.keys(publicSettings)).to.deep.equal([ 'user-name' ])
@@ -222,9 +187,7 @@ describe('Test plugins', function () {
222 'admin-name': 'Cid' 187 'admin-name': 'Cid'
223 } 188 }
224 189
225 await updatePluginSettings({ 190 await command.updateSettings({
226 url: server.url,
227 accessToken: server.accessToken,
228 npmName: 'peertube-plugin-hello-world', 191 npmName: 'peertube-plugin-hello-world',
229 settings 192 settings
230 }) 193 })
@@ -238,13 +201,7 @@ describe('Test plugins', function () {
238 201
239 it('Should get a plugin and a theme', async function () { 202 it('Should get a plugin and a theme', async function () {
240 { 203 {
241 const res = await getPlugin({ 204 const plugin = await command.get({ npmName: 'peertube-plugin-hello-world' })
242 url: server.url,
243 accessToken: server.accessToken,
244 npmName: 'peertube-plugin-hello-world'
245 })
246
247 const plugin: PeerTubePlugin = res.body
248 205
249 expect(plugin.type).to.equal(PluginType.PLUGIN) 206 expect(plugin.type).to.equal(PluginType.PLUGIN)
250 expect(plugin.name).to.equal('hello-world') 207 expect(plugin.name).to.equal('hello-world')
@@ -262,13 +219,7 @@ describe('Test plugins', function () {
262 } 219 }
263 220
264 { 221 {
265 const res = await getPlugin({ 222 const plugin = await command.get({ npmName: 'peertube-theme-background-red' })
266 url: server.url,
267 accessToken: server.accessToken,
268 npmName: 'peertube-theme-background-red'
269 })
270
271 const plugin: PeerTubePlugin = res.body
272 223
273 expect(plugin.type).to.equal(PluginType.THEME) 224 expect(plugin.type).to.equal(PluginType.THEME)
274 expect(plugin.name).to.equal('background-red') 225 expect(plugin.name).to.equal('background-red')
@@ -295,92 +246,59 @@ describe('Test plugins', function () {
295 await setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1') 246 await setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1')
296 247
297 // Fake update package.json 248 // Fake update package.json
298 const packageJSON: PluginPackageJson = await getPluginPackageJSON(server, 'peertube-plugin-hello-world') 249 const packageJSON = await command.getPackageJSON('peertube-plugin-hello-world')
299 const oldVersion = packageJSON.version 250 const oldVersion = packageJSON.version
300 251
301 packageJSON.version = '0.0.1' 252 packageJSON.version = '0.0.1'
302 await updatePluginPackageJSON(server, 'peertube-plugin-hello-world', packageJSON) 253 await command.updatePackageJSON('peertube-plugin-hello-world', packageJSON)
303 254
304 // Restart the server to take into account this change 255 // Restart the server to take into account this change
305 killallServers([ server ]) 256 killallServers([ server ])
306 await reRunServer(server) 257 await reRunServer(server)
307 258
308 { 259 {
309 const res = await listPlugins({ 260 const body = await command.list({ pluginType: PluginType.PLUGIN })
310 url: server.url,
311 accessToken: server.accessToken,
312 pluginType: PluginType.PLUGIN
313 })
314
315 const plugin: PeerTubePlugin = res.body.data[0]
316 261
262 const plugin = body.data[0]
317 expect(plugin.version).to.equal('0.0.1') 263 expect(plugin.version).to.equal('0.0.1')
318 expect(plugin.latestVersion).to.exist 264 expect(plugin.latestVersion).to.exist
319 expect(plugin.latestVersion).to.not.equal('0.0.1') 265 expect(plugin.latestVersion).to.not.equal('0.0.1')
320 } 266 }
321 267
322 { 268 {
323 await updatePlugin({ 269 await command.update({ npmName: 'peertube-plugin-hello-world' })
324 url: server.url,
325 accessToken: server.accessToken,
326 npmName: 'peertube-plugin-hello-world'
327 })
328
329 const res = await listPlugins({
330 url: server.url,
331 accessToken: server.accessToken,
332 pluginType: PluginType.PLUGIN
333 })
334 270
335 const plugin: PeerTubePlugin = res.body.data[0] 271 const body = await command.list({ pluginType: PluginType.PLUGIN })
336 272
273 const plugin = body.data[0]
337 expect(plugin.version).to.equal(oldVersion) 274 expect(plugin.version).to.equal(oldVersion)
338 275
339 const updatedPackageJSON: PluginPackageJson = await getPluginPackageJSON(server, 'peertube-plugin-hello-world') 276 const updatedPackageJSON = await command.getPackageJSON('peertube-plugin-hello-world')
340 expect(updatedPackageJSON.version).to.equal(oldVersion) 277 expect(updatedPackageJSON.version).to.equal(oldVersion)
341 } 278 }
342 }) 279 })
343 280
344 it('Should uninstall the plugin', async function () { 281 it('Should uninstall the plugin', async function () {
345 await uninstallPlugin({ 282 await command.uninstall({ npmName: 'peertube-plugin-hello-world' })
346 url: server.url,
347 accessToken: server.accessToken,
348 npmName: 'peertube-plugin-hello-world'
349 })
350
351 const res = await listPlugins({
352 url: server.url,
353 accessToken: server.accessToken,
354 pluginType: PluginType.PLUGIN
355 })
356 283
357 expect(res.body.total).to.equal(0) 284 const body = await command.list({ pluginType: PluginType.PLUGIN })
358 expect(res.body.data).to.have.lengthOf(0) 285 expect(body.total).to.equal(0)
286 expect(body.data).to.have.lengthOf(0)
359 }) 287 })
360 288
361 it('Should list uninstalled plugins', async function () { 289 it('Should list uninstalled plugins', async function () {
362 const res = await listPlugins({ 290 const body = await command.list({ pluginType: PluginType.PLUGIN, uninstalled: true })
363 url: server.url, 291 expect(body.total).to.equal(1)
364 accessToken: server.accessToken, 292 expect(body.data).to.have.lengthOf(1)
365 pluginType: PluginType.PLUGIN,
366 uninstalled: true
367 })
368 293
369 expect(res.body.total).to.equal(1) 294 const plugin = body.data[0]
370 expect(res.body.data).to.have.lengthOf(1)
371
372 const plugin: PeerTubePlugin = res.body.data[0]
373 expect(plugin.name).to.equal('hello-world') 295 expect(plugin.name).to.equal('hello-world')
374 expect(plugin.enabled).to.be.false 296 expect(plugin.enabled).to.be.false
375 expect(plugin.uninstalled).to.be.true 297 expect(plugin.uninstalled).to.be.true
376 }) 298 })
377 299
378 it('Should uninstall the theme', async function () { 300 it('Should uninstall the theme', async function () {
379 await uninstallPlugin({ 301 await command.uninstall({ npmName: 'peertube-theme-background-red' })
380 url: server.url,
381 accessToken: server.accessToken,
382 npmName: 'peertube-theme-background-red'
383 })
384 }) 302 })
385 303
386 it('Should have updated the configuration', async function () { 304 it('Should have updated the configuration', async function () {
@@ -406,21 +324,13 @@ describe('Test plugins', function () {
406 this.timeout(60000) 324 this.timeout(60000)
407 325
408 async function check () { 326 async function check () {
409 const res = await listPlugins({ 327 const body = await command.list({ pluginType: PluginType.PLUGIN })
410 url: server.url, 328 const plugins = body.data
411 accessToken: server.accessToken,
412 pluginType: PluginType.PLUGIN
413 })
414
415 const plugins: PeerTubePlugin[] = res.body.data
416
417 expect(plugins.find(p => p.name === 'test-broken')).to.not.exist 329 expect(plugins.find(p => p.name === 'test-broken')).to.not.exist
418 } 330 }
419 331
420 await installPlugin({ 332 await command.install({
421 url: server.url, 333 path: PluginsCommand.getPluginTestPath('-broken'),
422 accessToken: server.accessToken,
423 path: getPluginTestPath('-broken'),
424 expectedStatus: HttpStatusCode.BAD_REQUEST_400 334 expectedStatus: HttpStatusCode.BAD_REQUEST_400
425 }) 335 })
426 336
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 92927ea97..ba4183e08 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -23,7 +23,6 @@ import {
23 getUsersListPaginationAndSort, 23 getUsersListPaginationAndSort,
24 getVideoChannel, 24 getVideoChannel,
25 getVideosList, 25 getVideosList,
26 installPlugin,
27 killallServers, 26 killallServers,
28 login, 27 login,
29 logout, 28 logout,
@@ -75,7 +74,7 @@ describe('Test users', function () {
75 74
76 await setAccessTokensToServers([ server ]) 75 await setAccessTokensToServers([ server ])
77 76
78 await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-theme-background-red' }) 77 await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' })
79 }) 78 })
80 79
81 describe('OAuth client', function () { 80 describe('OAuth client', function () {
diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts
index efdc20748..7b8746a5d 100644
--- a/server/tests/cli/plugins.ts
+++ b/server/tests/cli/plugins.ts
@@ -6,8 +6,8 @@ import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunServer, 7 flushAndRunServer,
8 getConfig, 8 getConfig,
9 getPluginTestPath,
10 killallServers, 9 killallServers,
10 PluginsCommand,
11 reRunServer, 11 reRunServer,
12 ServerInfo, 12 ServerInfo,
13 setAccessTokensToServers 13 setAccessTokensToServers
@@ -27,7 +27,7 @@ describe('Test plugin scripts', function () {
27 it('Should install a plugin from stateless CLI', async function () { 27 it('Should install a plugin from stateless CLI', async function () {
28 this.timeout(60000) 28 this.timeout(60000)
29 29
30 const packagePath = getPluginTestPath() 30 const packagePath = PluginsCommand.getPluginTestPath()
31 31
32 await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`) 32 await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
33 }) 33 })
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts
index e4eae7e8c..0d4edbee0 100644
--- a/server/tests/external-plugins/auth-ldap.ts
+++ b/server/tests/external-plugins/auth-ldap.ts
@@ -3,17 +3,7 @@
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { User } from '@shared/models/users/user.model' 5import { User } from '@shared/models/users/user.model'
6import { 6import { blockUser, getMyUserInformation, setAccessTokensToServers, unblockUser, uploadVideo, userLogin } from '../../../shared/extra-utils'
7 blockUser,
8 getMyUserInformation,
9 installPlugin,
10 setAccessTokensToServers,
11 unblockUser,
12 uninstallPlugin,
13 updatePluginSettings,
14 uploadVideo,
15 userLogin
16} from '../../../shared/extra-utils'
17import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' 7import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
18 8
19describe('Official plugin auth-ldap', function () { 9describe('Official plugin auth-ldap', function () {
@@ -27,11 +17,7 @@ describe('Official plugin auth-ldap', function () {
27 server = await flushAndRunServer(1) 17 server = await flushAndRunServer(1)
28 await setAccessTokensToServers([ server ]) 18 await setAccessTokensToServers([ server ])
29 19
30 await installPlugin({ 20 await server.pluginsCommand.install({ npmName: 'peertube-plugin-auth-ldap' })
31 url: server.url,
32 accessToken: server.accessToken,
33 npmName: 'peertube-plugin-auth-ldap'
34 })
35 }) 21 })
36 22
37 it('Should not login with without LDAP settings', async function () { 23 it('Should not login with without LDAP settings', async function () {
@@ -39,9 +25,7 @@ describe('Official plugin auth-ldap', function () {
39 }) 25 })
40 26
41 it('Should not login with bad LDAP settings', async function () { 27 it('Should not login with bad LDAP settings', async function () {
42 await updatePluginSettings({ 28 await server.pluginsCommand.updateSettings({
43 url: server.url,
44 accessToken: server.accessToken,
45 npmName: 'peertube-plugin-auth-ldap', 29 npmName: 'peertube-plugin-auth-ldap',
46 settings: { 30 settings: {
47 'bind-credentials': 'GoodNewsEveryone', 31 'bind-credentials': 'GoodNewsEveryone',
@@ -59,9 +43,7 @@ describe('Official plugin auth-ldap', function () {
59 }) 43 })
60 44
61 it('Should not login with good LDAP settings but wrong username/password', async function () { 45 it('Should not login with good LDAP settings but wrong username/password', async function () {
62 await updatePluginSettings({ 46 await server.pluginsCommand.updateSettings({
63 url: server.url,
64 accessToken: server.accessToken,
65 npmName: 'peertube-plugin-auth-ldap', 47 npmName: 'peertube-plugin-auth-ldap',
66 settings: { 48 settings: {
67 'bind-credentials': 'GoodNewsEveryone', 49 'bind-credentials': 'GoodNewsEveryone',
@@ -114,7 +96,7 @@ describe('Official plugin auth-ldap', function () {
114 }) 96 })
115 97
116 it('Should not login if the plugin is uninstalled', async function () { 98 it('Should not login if the plugin is uninstalled', async function () {
117 await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-auth-ldap' }) 99 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
118 100
119 await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400) 101 await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400)
120 }) 102 })
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts
index 18ea17d78..6baf37566 100644
--- a/server/tests/external-plugins/auto-block-videos.ts
+++ b/server/tests/external-plugins/auto-block-videos.ts
@@ -7,11 +7,9 @@ import {
7 doubleFollow, 7 doubleFollow,
8 getBlacklistedVideosList, 8 getBlacklistedVideosList,
9 getVideosList, 9 getVideosList,
10 installPlugin,
11 MockBlocklist, 10 MockBlocklist,
12 removeVideoFromBlacklist, 11 removeVideoFromBlacklist,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
14 updatePluginSettings,
15 uploadVideoAndGetId, 13 uploadVideoAndGetId,
16 wait 14 wait
17} from '../../../shared/extra-utils' 15} from '../../../shared/extra-utils'
@@ -28,11 +26,8 @@ async function check (server: ServerInfo, videoUUID: string, exists = true) {
28 26
29 const video = res.body.data.find(v => v.uuid === videoUUID) 27 const video = res.body.data.find(v => v.uuid === videoUUID)
30 28
31 if (exists) { 29 if (exists) expect(video).to.not.be.undefined
32 expect(video).to.not.be.undefined 30 else expect(video).to.be.undefined
33 } else {
34 expect(video).to.be.undefined
35 }
36} 31}
37 32
38describe('Official plugin auto-block videos', function () { 33describe('Official plugin auto-block videos', function () {
@@ -49,11 +44,7 @@ describe('Official plugin auto-block videos', function () {
49 await setAccessTokensToServers(servers) 44 await setAccessTokensToServers(servers)
50 45
51 for (const server of servers) { 46 for (const server of servers) {
52 await installPlugin({ 47 await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-block-videos' })
53 url: server.url,
54 accessToken: server.accessToken,
55 npmName: 'peertube-plugin-auto-block-videos'
56 })
57 } 48 }
58 49
59 blocklistServer = new MockBlocklist() 50 blocklistServer = new MockBlocklist()
@@ -78,9 +69,7 @@ describe('Official plugin auto-block videos', function () {
78 }) 69 })
79 70
80 it('Should update plugin settings', async function () { 71 it('Should update plugin settings', async function () {
81 await updatePluginSettings({ 72 await servers[0].pluginsCommand.updateSettings({
82 url: servers[0].url,
83 accessToken: servers[0].accessToken,
84 npmName: 'peertube-plugin-auto-block-videos', 73 npmName: 'peertube-plugin-auto-block-videos',
85 settings: { 74 settings: {
86 'blocklist-urls': `http://localhost:${port}/blocklist`, 75 'blocklist-urls': `http://localhost:${port}/blocklist`,
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts
index 09355d932..8fcf94452 100644
--- a/server/tests/external-plugins/auto-mute.ts
+++ b/server/tests/external-plugins/auto-mute.ts
@@ -2,30 +2,24 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
5import { 6import {
6 addAccountToServerBlocklist, 7 addAccountToServerBlocklist,
7 addServerToAccountBlocklist, 8 addServerToAccountBlocklist,
8 removeAccountFromServerBlocklist 9 cleanupTests,
9} from '@shared/extra-utils/users/blocklist'
10import {
11 doubleFollow, 10 doubleFollow,
11 flushAndRunMultipleServers,
12 getVideosList, 12 getVideosList,
13 installPlugin, 13 killallServers,
14 makeGetRequest, 14 makeGetRequest,
15 MockBlocklist, 15 MockBlocklist,
16 removeAccountFromServerBlocklist,
17 reRunServer,
18 ServerInfo,
16 setAccessTokensToServers, 19 setAccessTokensToServers,
17 updatePluginSettings,
18 uploadVideoAndGetId, 20 uploadVideoAndGetId,
19 wait 21 wait
20} from '../../../shared/extra-utils' 22} from '@shared/extra-utils'
21import {
22 cleanupTests,
23 flushAndRunMultipleServers,
24 killallServers,
25 reRunServer,
26 ServerInfo
27} from '../../../shared/extra-utils/server/servers'
28import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
29 23
30describe('Official plugin auto-mute', function () { 24describe('Official plugin auto-mute', function () {
31 const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list' 25 const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list'
@@ -40,11 +34,7 @@ describe('Official plugin auto-mute', function () {
40 await setAccessTokensToServers(servers) 34 await setAccessTokensToServers(servers)
41 35
42 for (const server of servers) { 36 for (const server of servers) {
43 await installPlugin({ 37 await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-mute' })
44 url: server.url,
45 accessToken: server.accessToken,
46 npmName: 'peertube-plugin-auto-mute'
47 })
48 } 38 }
49 39
50 blocklistServer = new MockBlocklist() 40 blocklistServer = new MockBlocklist()
@@ -57,9 +47,7 @@ describe('Official plugin auto-mute', function () {
57 }) 47 })
58 48
59 it('Should update plugin settings', async function () { 49 it('Should update plugin settings', async function () {
60 await updatePluginSettings({ 50 await servers[0].pluginsCommand.updateSettings({
61 url: servers[0].url,
62 accessToken: servers[0].accessToken,
63 npmName: 'peertube-plugin-auto-mute', 51 npmName: 'peertube-plugin-auto-mute',
64 settings: { 52 settings: {
65 'blocklist-urls': `http://localhost:${port}/blocklist`, 53 'blocklist-urls': `http://localhost:${port}/blocklist`,
@@ -185,9 +173,7 @@ describe('Official plugin auto-mute', function () {
185 }) 173 })
186 174
187 it('Should enable auto mute list', async function () { 175 it('Should enable auto mute list', async function () {
188 await updatePluginSettings({ 176 await servers[0].pluginsCommand.updateSettings({
189 url: servers[0].url,
190 accessToken: servers[0].accessToken,
191 npmName: 'peertube-plugin-auto-mute', 177 npmName: 'peertube-plugin-auto-mute',
192 settings: { 178 settings: {
193 'blocklist-urls': '', 179 'blocklist-urls': '',
@@ -206,9 +192,7 @@ describe('Official plugin auto-mute', function () {
206 it('Should mute an account on server 1, and server 2 auto mutes it', async function () { 192 it('Should mute an account on server 1, and server 2 auto mutes it', async function () {
207 this.timeout(20000) 193 this.timeout(20000)
208 194
209 await updatePluginSettings({ 195 await servers[1].pluginsCommand.updateSettings({
210 url: servers[1].url,
211 accessToken: servers[1].accessToken,
212 npmName: 'peertube-plugin-auto-mute', 196 npmName: 'peertube-plugin-auto-mute',
213 settings: { 197 settings: {
214 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath, 198 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath,
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)