aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/external-plugins/auto-mute.ts83
-rw-r--r--server/tests/external-plugins/index.ts4
2 files changed, 79 insertions, 8 deletions
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts
index 2f2c9102d..bfdbee80a 100644
--- a/server/tests/external-plugins/auto-mute.ts
+++ b/server/tests/external-plugins/auto-mute.ts
@@ -2,11 +2,16 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { removeAccountFromServerBlocklist } from '@shared/extra-utils/users/blocklist' 5import {
6 addAccountToServerBlocklist,
7 addServerToAccountBlocklist,
8 removeAccountFromServerBlocklist
9} from '@shared/extra-utils/users/blocklist'
6import { 10import {
7 doubleFollow, 11 doubleFollow,
8 getVideosList, 12 getVideosList,
9 installPlugin, 13 installPlugin,
14 makeGetRequest,
10 MockBlocklist, 15 MockBlocklist,
11 setAccessTokensToServers, 16 setAccessTokensToServers,
12 updatePluginSettings, 17 updatePluginSettings,
@@ -22,6 +27,7 @@ import {
22} from '../../../shared/extra-utils/server/servers' 27} from '../../../shared/extra-utils/server/servers'
23 28
24describe('Official plugin auto-mute', function () { 29describe('Official plugin auto-mute', function () {
30 const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list'
25 let servers: ServerInfo[] 31 let servers: ServerInfo[]
26 let blocklistServer: MockBlocklist 32 let blocklistServer: MockBlocklist
27 33
@@ -31,11 +37,13 @@ describe('Official plugin auto-mute', function () {
31 servers = await flushAndRunMultipleServers(2) 37 servers = await flushAndRunMultipleServers(2)
32 await setAccessTokensToServers(servers) 38 await setAccessTokensToServers(servers)
33 39
34 await installPlugin({ 40 for (const server of servers) {
35 url: servers[0].url, 41 await installPlugin({
36 accessToken: servers[0].accessToken, 42 url: server.url,
37 npmName: 'peertube-plugin-auto-mute' 43 accessToken: server.accessToken,
38 }) 44 npmName: 'peertube-plugin-auto-mute'
45 })
46 }
39 47
40 blocklistServer = new MockBlocklist() 48 blocklistServer = new MockBlocklist()
41 await blocklistServer.initialize() 49 await blocklistServer.initialize()
@@ -166,6 +174,69 @@ describe('Official plugin auto-mute', function () {
166 } 174 }
167 }) 175 })
168 176
177 it('Should not expose the auto mute list', async function () {
178 await makeGetRequest({
179 url: servers[0].url,
180 path: '/plugins/auto-mute/router/api/v1/mute-list',
181 statusCodeExpected: 403
182 })
183 })
184
185 it('Should enable auto mute list', async function () {
186 await updatePluginSettings({
187 url: servers[0].url,
188 accessToken: servers[0].accessToken,
189 npmName: 'peertube-plugin-auto-mute',
190 settings: {
191 'blocklist-urls': '',
192 'check-seconds-interval': 1,
193 'expose-mute-list': true
194 }
195 })
196
197 await makeGetRequest({
198 url: servers[0].url,
199 path: '/plugins/auto-mute/router/api/v1/mute-list',
200 statusCodeExpected: 200
201 })
202 })
203
204 it('Should mute an account on server 1, and server 2 auto mutes it', async function () {
205 this.timeout(20000)
206
207 await updatePluginSettings({
208 url: servers[1].url,
209 accessToken: servers[1].accessToken,
210 npmName: 'peertube-plugin-auto-mute',
211 settings: {
212 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath,
213 'check-seconds-interval': 1,
214 'expose-mute-list': false
215 }
216 })
217
218 await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port)
219 await addServerToAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
220
221 const res = await makeGetRequest({
222 url: servers[0].url,
223 path: '/plugins/auto-mute/router/api/v1/mute-list',
224 statusCodeExpected: 200
225 })
226
227 const data = res.body.data
228 expect(data).to.have.lengthOf(1)
229 expect(data[0].updatedAt).to.exist
230 expect(data[0].value).to.equal('root@localhost:' + servers[1].port)
231
232 await wait(2000)
233
234 for (const server of servers) {
235 const res = await getVideosList(server.url)
236 expect(res.body.total).to.equal(1)
237 }
238 })
239
169 after(async function () { 240 after(async function () {
170 await cleanupTests(servers) 241 await cleanupTests(servers)
171 }) 242 })
diff --git a/server/tests/external-plugins/index.ts b/server/tests/external-plugins/index.ts
index 352d38de9..d17894c15 100644
--- a/server/tests/external-plugins/index.ts
+++ b/server/tests/external-plugins/index.ts
@@ -1,2 +1,2 @@
1export * from './auth-ldap' 1import './auth-ldap'
2export * from './auto-mute' 2import './auto-mute'