aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/external-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/external-plugins
parent9c6327f803aaf4200672f1fc40b2f43786daca47 (diff)
downloadPeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.gz
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.zst
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.zip
Introduce plugins command
Diffstat (limited to 'server/tests/external-plugins')
-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
3 files changed, 21 insertions, 66 deletions
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,