aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/tests/external-plugins/auto-mute.ts120
-rw-r--r--server/tests/external-plugins/index.ts1
2 files changed, 121 insertions, 0 deletions
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts
new file mode 100644
index 000000000..49b104882
--- /dev/null
+++ b/server/tests/external-plugins/auto-mute.ts
@@ -0,0 +1,120 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4
5
6import { installPlugin, MockBlocklist, setAccessTokensToServers, uploadVideoAndGetId, updatePluginSettings, doubleFollow, getVideosList, wait } from '../../../shared/extra-utils'
7import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers'
8import { expect } from 'chai'
9
10describe('Official plugin auto-mute', function () {
11 let servers: ServerInfo[]
12 let blocklistServer: MockBlocklist
13
14 before(async function () {
15 this.timeout(30000)
16
17 servers = await flushAndRunMultipleServers(2)
18 await setAccessTokensToServers(servers)
19
20 await installPlugin({
21 url: servers[0].url,
22 accessToken: servers[0].accessToken,
23 npmName: 'peertube-plugin-auto-mute'
24 })
25
26 blocklistServer = new MockBlocklist()
27 await blocklistServer.initialize()
28
29 await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' })
30 await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' })
31
32 await doubleFollow(servers[0], servers[1])
33 })
34
35 it('Should update plugin settings', async function () {
36 await updatePluginSettings({
37 url: servers[0].url,
38 accessToken: servers[0].accessToken,
39 npmName: 'peertube-plugin-auto-mute',
40 settings: {
41 'blocklist-urls': 'http://localhost:42100/blocklist',
42 'check-seconds-interval': 1
43 }
44 })
45 })
46
47 it('Should add a server blocklist', async function () {
48 this.timeout(10000)
49
50 blocklistServer.replace({
51 data: [
52 {
53 value: 'localhost:' + servers[1].port
54 }
55 ]
56 })
57
58 await wait(2000)
59
60 const res = await getVideosList(servers[0].url)
61 expect(res.body.total).to.equal(1)
62 })
63
64 it('Should remove a server blocklist', async function () {
65 this.timeout(10000)
66
67 blocklistServer.replace({
68 data: [
69 {
70 value: 'localhost:' + servers[1].port,
71 action: 'remove'
72 }
73 ]
74 })
75
76 await wait(2000)
77
78 const res = await getVideosList(servers[0].url)
79 expect(res.body.total).to.equal(2)
80 })
81
82 it('Should add an account blocklist', async function () {
83 this.timeout(10000)
84
85 blocklistServer.replace({
86 data: [
87 {
88 value: 'root@localhost:' + servers[1].port
89 }
90 ]
91 })
92
93 await wait(2000)
94
95 const res = await getVideosList(servers[0].url)
96 expect(res.body.total).to.equal(1)
97 })
98
99 it('Should remove an account blocklist', async function () {
100 this.timeout(10000)
101
102 blocklistServer.replace({
103 data: [
104 {
105 value: 'root@localhost:' + servers[1].port,
106 action: 'remove'
107 }
108 ]
109 })
110
111 await wait(2000)
112
113 const res = await getVideosList(servers[0].url)
114 expect(res.body.total).to.equal(2)
115 })
116
117 after(async function () {
118 await cleanupTests(servers)
119 })
120})
diff --git a/server/tests/external-plugins/index.ts b/server/tests/external-plugins/index.ts
index 1f1236c69..352d38de9 100644
--- a/server/tests/external-plugins/index.ts
+++ b/server/tests/external-plugins/index.ts
@@ -1 +1,2 @@
1export * from './auth-ldap' 1export * from './auth-ldap'
2export * from './auto-mute'