diff options
Diffstat (limited to 'server/tests/external-plugins')
-rw-r--r-- | server/tests/external-plugins/auth-ldap.ts | 69 | ||||
-rw-r--r-- | server/tests/external-plugins/auto-block-videos.ts | 75 | ||||
-rw-r--r-- | server/tests/external-plugins/auto-mute.ts | 98 |
3 files changed, 93 insertions, 149 deletions
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index e4eae7e8c..acec69df5 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts | |||
@@ -2,46 +2,29 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { User } from '@shared/models/users/user.model' | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
6 | import { | 6 | import { HttpStatusCode } from '@shared/models' |
7 | blockUser, | ||
8 | getMyUserInformation, | ||
9 | installPlugin, | ||
10 | setAccessTokensToServers, | ||
11 | unblockUser, | ||
12 | uninstallPlugin, | ||
13 | updatePluginSettings, | ||
14 | uploadVideo, | ||
15 | userLogin | ||
16 | } from '../../../shared/extra-utils' | ||
17 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' | ||
18 | 7 | ||
19 | describe('Official plugin auth-ldap', function () { | 8 | describe('Official plugin auth-ldap', function () { |
20 | let server: ServerInfo | 9 | let server: PeerTubeServer |
21 | let accessToken: string | 10 | let accessToken: string |
22 | let userId: number | 11 | let userId: number |
23 | 12 | ||
24 | before(async function () { | 13 | before(async function () { |
25 | this.timeout(30000) | 14 | this.timeout(30000) |
26 | 15 | ||
27 | server = await flushAndRunServer(1) | 16 | server = await createSingleServer(1) |
28 | await setAccessTokensToServers([ server ]) | 17 | await setAccessTokensToServers([ server ]) |
29 | 18 | ||
30 | await installPlugin({ | 19 | await server.plugins.install({ npmName: 'peertube-plugin-auth-ldap' }) |
31 | url: server.url, | ||
32 | accessToken: server.accessToken, | ||
33 | npmName: 'peertube-plugin-auth-ldap' | ||
34 | }) | ||
35 | }) | 20 | }) |
36 | 21 | ||
37 | it('Should not login with without LDAP settings', async function () { | 22 | it('Should not login with without LDAP settings', async function () { |
38 | await userLogin(server, { username: 'fry', password: 'fry' }, 400) | 23 | await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
39 | }) | 24 | }) |
40 | 25 | ||
41 | it('Should not login with bad LDAP settings', async function () { | 26 | it('Should not login with bad LDAP settings', async function () { |
42 | await updatePluginSettings({ | 27 | await server.plugins.updateSettings({ |
43 | url: server.url, | ||
44 | accessToken: server.accessToken, | ||
45 | npmName: 'peertube-plugin-auth-ldap', | 28 | npmName: 'peertube-plugin-auth-ldap', |
46 | settings: { | 29 | settings: { |
47 | 'bind-credentials': 'GoodNewsEveryone', | 30 | 'bind-credentials': 'GoodNewsEveryone', |
@@ -55,13 +38,11 @@ describe('Official plugin auth-ldap', function () { | |||
55 | } | 38 | } |
56 | }) | 39 | }) |
57 | 40 | ||
58 | await userLogin(server, { username: 'fry', password: 'fry' }, 400) | 41 | await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
59 | }) | 42 | }) |
60 | 43 | ||
61 | it('Should not login with good LDAP settings but wrong username/password', async function () { | 44 | it('Should not login with good LDAP settings but wrong username/password', async function () { |
62 | await updatePluginSettings({ | 45 | await server.plugins.updateSettings({ |
63 | url: server.url, | ||
64 | accessToken: server.accessToken, | ||
65 | npmName: 'peertube-plugin-auth-ldap', | 46 | npmName: 'peertube-plugin-auth-ldap', |
66 | settings: { | 47 | settings: { |
67 | 'bind-credentials': 'GoodNewsEveryone', | 48 | 'bind-credentials': 'GoodNewsEveryone', |
@@ -75,22 +56,20 @@ describe('Official plugin auth-ldap', function () { | |||
75 | } | 56 | } |
76 | }) | 57 | }) |
77 | 58 | ||
78 | await userLogin(server, { username: 'fry', password: 'bad password' }, 400) | 59 | await server.login.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
79 | await userLogin(server, { username: 'fryr', password: 'fry' }, 400) | 60 | await server.login.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
80 | }) | 61 | }) |
81 | 62 | ||
82 | it('Should login with the appropriate username/password', async function () { | 63 | it('Should login with the appropriate username/password', async function () { |
83 | accessToken = await userLogin(server, { username: 'fry', password: 'fry' }) | 64 | accessToken = await server.login.getAccessToken({ username: 'fry', password: 'fry' }) |
84 | }) | 65 | }) |
85 | 66 | ||
86 | it('Should login with the appropriate email/password', async function () { | 67 | it('Should login with the appropriate email/password', async function () { |
87 | accessToken = await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }) | 68 | accessToken = await server.login.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' }) |
88 | }) | 69 | }) |
89 | 70 | ||
90 | it('Should login get my profile', async function () { | 71 | it('Should login get my profile', async function () { |
91 | const res = await getMyUserInformation(server.url, accessToken) | 72 | const body = await server.users.getMyInfo({ token: accessToken }) |
92 | const body: User = res.body | ||
93 | |||
94 | expect(body.username).to.equal('fry') | 73 | expect(body.username).to.equal('fry') |
95 | expect(body.email).to.equal('fry@planetexpress.com') | 74 | expect(body.email).to.equal('fry@planetexpress.com') |
96 | 75 | ||
@@ -98,25 +77,31 @@ describe('Official plugin auth-ldap', function () { | |||
98 | }) | 77 | }) |
99 | 78 | ||
100 | it('Should upload a video', async function () { | 79 | it('Should upload a video', async function () { |
101 | await uploadVideo(server.url, accessToken, { name: 'my super video' }) | 80 | await server.videos.upload({ token: accessToken, attributes: { name: 'my super video' } }) |
102 | }) | 81 | }) |
103 | 82 | ||
104 | it('Should not be able to login if the user is banned', async function () { | 83 | it('Should not be able to login if the user is banned', async function () { |
105 | await blockUser(server.url, userId, server.accessToken) | 84 | await server.users.banUser({ userId }) |
106 | 85 | ||
107 | await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400) | 86 | await server.login.login({ |
87 | user: { username: 'fry@planetexpress.com', password: 'fry' }, | ||
88 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
89 | }) | ||
108 | }) | 90 | }) |
109 | 91 | ||
110 | it('Should be able to login if the user is unbanned', async function () { | 92 | it('Should be able to login if the user is unbanned', async function () { |
111 | await unblockUser(server.url, userId, server.accessToken) | 93 | await server.users.unbanUser({ userId }) |
112 | 94 | ||
113 | await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }) | 95 | await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } }) |
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.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' }) |
118 | 100 | ||
119 | await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400) | 101 | await server.login.login({ |
102 | user: { username: 'fry@planetexpress.com', password: 'fry' }, | ||
103 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
104 | }) | ||
120 | }) | 105 | }) |
121 | 106 | ||
122 | after(async function () { | 107 | after(async function () { |
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts index 18ea17d78..0eb4bda9a 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/server/tests/external-plugins/auto-block-videos.ts | |||
@@ -2,41 +2,29 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { Video, VideoBlacklist } from '@shared/models' | ||
6 | import { | 5 | import { |
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
7 | doubleFollow, | 8 | doubleFollow, |
8 | getBlacklistedVideosList, | 9 | killallServers, |
9 | getVideosList, | ||
10 | installPlugin, | ||
11 | MockBlocklist, | 10 | MockBlocklist, |
12 | removeVideoFromBlacklist, | 11 | PeerTubeServer, |
13 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
14 | updatePluginSettings, | ||
15 | uploadVideoAndGetId, | ||
16 | wait | 13 | wait |
17 | } from '../../../shared/extra-utils' | 14 | } from '@shared/extra-utils' |
18 | import { | 15 | import { Video } from '@shared/models' |
19 | cleanupTests, | ||
20 | flushAndRunMultipleServers, | ||
21 | killallServers, | ||
22 | reRunServer, | ||
23 | ServerInfo | ||
24 | } from '../../../shared/extra-utils/server/servers' | ||
25 | 16 | ||
26 | async function check (server: ServerInfo, videoUUID: string, exists = true) { | 17 | async function check (server: PeerTubeServer, videoUUID: string, exists = true) { |
27 | const res = await getVideosList(server.url) | 18 | const { data } = await server.videos.list() |
28 | 19 | ||
29 | const video = res.body.data.find(v => v.uuid === videoUUID) | 20 | const video = data.find(v => v.uuid === videoUUID) |
30 | 21 | ||
31 | if (exists) { | 22 | if (exists) expect(video).to.not.be.undefined |
32 | expect(video).to.not.be.undefined | 23 | else expect(video).to.be.undefined |
33 | } else { | ||
34 | expect(video).to.be.undefined | ||
35 | } | ||
36 | } | 24 | } |
37 | 25 | ||
38 | describe('Official plugin auto-block videos', function () { | 26 | describe('Official plugin auto-block videos', function () { |
39 | let servers: ServerInfo[] | 27 | let servers: PeerTubeServer[] |
40 | let blocklistServer: MockBlocklist | 28 | let blocklistServer: MockBlocklist |
41 | let server1Videos: Video[] = [] | 29 | let server1Videos: Video[] = [] |
42 | let server2Videos: Video[] = [] | 30 | let server2Videos: Video[] = [] |
@@ -45,42 +33,36 @@ describe('Official plugin auto-block videos', function () { | |||
45 | before(async function () { | 33 | before(async function () { |
46 | this.timeout(60000) | 34 | this.timeout(60000) |
47 | 35 | ||
48 | servers = await flushAndRunMultipleServers(2) | 36 | servers = await createMultipleServers(2) |
49 | await setAccessTokensToServers(servers) | 37 | await setAccessTokensToServers(servers) |
50 | 38 | ||
51 | for (const server of servers) { | 39 | for (const server of servers) { |
52 | await installPlugin({ | 40 | await server.plugins.install({ npmName: 'peertube-plugin-auto-block-videos' }) |
53 | url: server.url, | ||
54 | accessToken: server.accessToken, | ||
55 | npmName: 'peertube-plugin-auto-block-videos' | ||
56 | }) | ||
57 | } | 41 | } |
58 | 42 | ||
59 | blocklistServer = new MockBlocklist() | 43 | blocklistServer = new MockBlocklist() |
60 | port = await blocklistServer.initialize() | 44 | port = await blocklistServer.initialize() |
61 | 45 | ||
62 | await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) | 46 | await servers[0].videos.quickUpload({ name: 'video server 1' }) |
63 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' }) | 47 | await servers[1].videos.quickUpload({ name: 'video server 2' }) |
64 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video 2 server 2' }) | 48 | await servers[1].videos.quickUpload({ name: 'video 2 server 2' }) |
65 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3 server 2' }) | 49 | await servers[1].videos.quickUpload({ name: 'video 3 server 2' }) |
66 | 50 | ||
67 | { | 51 | { |
68 | const res = await getVideosList(servers[0].url) | 52 | const { data } = await servers[0].videos.list() |
69 | server1Videos = res.body.data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid })) | 53 | server1Videos = data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid })) |
70 | } | 54 | } |
71 | 55 | ||
72 | { | 56 | { |
73 | const res = await getVideosList(servers[1].url) | 57 | const { data } = await servers[1].videos.list() |
74 | server2Videos = res.body.data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })) | 58 | server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })) |
75 | } | 59 | } |
76 | 60 | ||
77 | await doubleFollow(servers[0], servers[1]) | 61 | await doubleFollow(servers[0], servers[1]) |
78 | }) | 62 | }) |
79 | 63 | ||
80 | it('Should update plugin settings', async function () { | 64 | it('Should update plugin settings', async function () { |
81 | await updatePluginSettings({ | 65 | await servers[0].plugins.updateSettings({ |
82 | url: servers[0].url, | ||
83 | accessToken: servers[0].accessToken, | ||
84 | npmName: 'peertube-plugin-auto-block-videos', | 66 | npmName: 'peertube-plugin-auto-block-videos', |
85 | settings: { | 67 | settings: { |
86 | 'blocklist-urls': `http://localhost:${port}/blocklist`, | 68 | 'blocklist-urls': `http://localhost:${port}/blocklist`, |
@@ -108,10 +90,9 @@ describe('Official plugin auto-block videos', function () { | |||
108 | }) | 90 | }) |
109 | 91 | ||
110 | it('Should have video in blacklists', async function () { | 92 | it('Should have video in blacklists', async function () { |
111 | const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken }) | 93 | const body = await servers[0].blacklist.list() |
112 | |||
113 | const videoBlacklists = res.body.data as VideoBlacklist[] | ||
114 | 94 | ||
95 | const videoBlacklists = body.data | ||
115 | expect(videoBlacklists).to.have.lengthOf(1) | 96 | expect(videoBlacklists).to.have.lengthOf(1) |
116 | expect(videoBlacklists[0].reason).to.contains('Automatically blocked from auto block plugin') | 97 | expect(videoBlacklists[0].reason).to.contains('Automatically blocked from auto block plugin') |
117 | expect(videoBlacklists[0].video.name).to.equal(server2Videos[0].name) | 98 | expect(videoBlacklists[0].video.name).to.equal(server2Videos[0].name) |
@@ -174,12 +155,12 @@ describe('Official plugin auto-block videos', function () { | |||
174 | 155 | ||
175 | await check(servers[0], video.uuid, false) | 156 | await check(servers[0], video.uuid, false) |
176 | 157 | ||
177 | await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, video.uuid) | 158 | await servers[0].blacklist.remove({ videoId: video.uuid }) |
178 | 159 | ||
179 | await check(servers[0], video.uuid, true) | 160 | await check(servers[0], video.uuid, true) |
180 | 161 | ||
181 | killallServers([ servers[0] ]) | 162 | await killallServers([ servers[0] ]) |
182 | await reRunServer(servers[0]) | 163 | await servers[0].run() |
183 | await wait(2000) | 164 | await wait(2000) |
184 | 165 | ||
185 | await check(servers[0], video.uuid, true) | 166 | await check(servers[0], video.uuid, true) |
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index 09355d932..271779dd4 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts | |||
@@ -3,63 +3,45 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { | 5 | import { |
6 | addAccountToServerBlocklist, | 6 | cleanupTests, |
7 | addServerToAccountBlocklist, | 7 | createMultipleServers, |
8 | removeAccountFromServerBlocklist | ||
9 | } from '@shared/extra-utils/users/blocklist' | ||
10 | import { | ||
11 | doubleFollow, | 8 | doubleFollow, |
12 | getVideosList, | 9 | killallServers, |
13 | installPlugin, | ||
14 | makeGetRequest, | 10 | makeGetRequest, |
15 | MockBlocklist, | 11 | MockBlocklist, |
12 | PeerTubeServer, | ||
16 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
17 | updatePluginSettings, | ||
18 | uploadVideoAndGetId, | ||
19 | wait | 14 | wait |
20 | } from '../../../shared/extra-utils' | 15 | } from '@shared/extra-utils' |
21 | import { | 16 | import { HttpStatusCode } from '@shared/models' |
22 | cleanupTests, | ||
23 | flushAndRunMultipleServers, | ||
24 | killallServers, | ||
25 | reRunServer, | ||
26 | ServerInfo | ||
27 | } from '../../../shared/extra-utils/server/servers' | ||
28 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
29 | 17 | ||
30 | describe('Official plugin auto-mute', function () { | 18 | describe('Official plugin auto-mute', function () { |
31 | const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list' | 19 | const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list' |
32 | let servers: ServerInfo[] | 20 | let servers: PeerTubeServer[] |
33 | let blocklistServer: MockBlocklist | 21 | let blocklistServer: MockBlocklist |
34 | let port: number | 22 | let port: number |
35 | 23 | ||
36 | before(async function () { | 24 | before(async function () { |
37 | this.timeout(30000) | 25 | this.timeout(30000) |
38 | 26 | ||
39 | servers = await flushAndRunMultipleServers(2) | 27 | servers = await createMultipleServers(2) |
40 | await setAccessTokensToServers(servers) | 28 | await setAccessTokensToServers(servers) |
41 | 29 | ||
42 | for (const server of servers) { | 30 | for (const server of servers) { |
43 | await installPlugin({ | 31 | await server.plugins.install({ npmName: 'peertube-plugin-auto-mute' }) |
44 | url: server.url, | ||
45 | accessToken: server.accessToken, | ||
46 | npmName: 'peertube-plugin-auto-mute' | ||
47 | }) | ||
48 | } | 32 | } |
49 | 33 | ||
50 | blocklistServer = new MockBlocklist() | 34 | blocklistServer = new MockBlocklist() |
51 | port = await blocklistServer.initialize() | 35 | port = await blocklistServer.initialize() |
52 | 36 | ||
53 | await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) | 37 | await servers[0].videos.quickUpload({ name: 'video server 1' }) |
54 | await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' }) | 38 | await servers[1].videos.quickUpload({ name: 'video server 2' }) |
55 | 39 | ||
56 | await doubleFollow(servers[0], servers[1]) | 40 | await doubleFollow(servers[0], servers[1]) |
57 | }) | 41 | }) |
58 | 42 | ||
59 | it('Should update plugin settings', async function () { | 43 | it('Should update plugin settings', async function () { |
60 | await updatePluginSettings({ | 44 | await servers[0].plugins.updateSettings({ |
61 | url: servers[0].url, | ||
62 | accessToken: servers[0].accessToken, | ||
63 | npmName: 'peertube-plugin-auto-mute', | 45 | npmName: 'peertube-plugin-auto-mute', |
64 | settings: { | 46 | settings: { |
65 | 'blocklist-urls': `http://localhost:${port}/blocklist`, | 47 | 'blocklist-urls': `http://localhost:${port}/blocklist`, |
@@ -81,8 +63,8 @@ describe('Official plugin auto-mute', function () { | |||
81 | 63 | ||
82 | await wait(2000) | 64 | await wait(2000) |
83 | 65 | ||
84 | const res = await getVideosList(servers[0].url) | 66 | const { total } = await servers[0].videos.list() |
85 | expect(res.body.total).to.equal(1) | 67 | expect(total).to.equal(1) |
86 | }) | 68 | }) |
87 | 69 | ||
88 | it('Should remove a server blocklist', async function () { | 70 | it('Should remove a server blocklist', async function () { |
@@ -99,8 +81,8 @@ describe('Official plugin auto-mute', function () { | |||
99 | 81 | ||
100 | await wait(2000) | 82 | await wait(2000) |
101 | 83 | ||
102 | const res = await getVideosList(servers[0].url) | 84 | const { total } = await servers[0].videos.list() |
103 | expect(res.body.total).to.equal(2) | 85 | expect(total).to.equal(2) |
104 | }) | 86 | }) |
105 | 87 | ||
106 | it('Should add an account blocklist', async function () { | 88 | it('Should add an account blocklist', async function () { |
@@ -116,8 +98,8 @@ describe('Official plugin auto-mute', function () { | |||
116 | 98 | ||
117 | await wait(2000) | 99 | await wait(2000) |
118 | 100 | ||
119 | const res = await getVideosList(servers[0].url) | 101 | const { total } = await servers[0].videos.list() |
120 | expect(res.body.total).to.equal(1) | 102 | expect(total).to.equal(1) |
121 | }) | 103 | }) |
122 | 104 | ||
123 | it('Should remove an account blocklist', async function () { | 105 | it('Should remove an account blocklist', async function () { |
@@ -134,8 +116,8 @@ describe('Official plugin auto-mute', function () { | |||
134 | 116 | ||
135 | await wait(2000) | 117 | await wait(2000) |
136 | 118 | ||
137 | const res = await getVideosList(servers[0].url) | 119 | const { total } = await servers[0].videos.list() |
138 | expect(res.body.total).to.equal(2) | 120 | expect(total).to.equal(2) |
139 | }) | 121 | }) |
140 | 122 | ||
141 | it('Should auto mute an account, manually unmute it and do not remute it automatically', async function () { | 123 | it('Should auto mute an account, manually unmute it and do not remute it automatically', async function () { |
@@ -155,24 +137,24 @@ describe('Official plugin auto-mute', function () { | |||
155 | await wait(2000) | 137 | await wait(2000) |
156 | 138 | ||
157 | { | 139 | { |
158 | const res = await getVideosList(servers[0].url) | 140 | const { total } = await servers[0].videos.list() |
159 | expect(res.body.total).to.equal(1) | 141 | expect(total).to.equal(1) |
160 | } | 142 | } |
161 | 143 | ||
162 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, account) | 144 | await servers[0].blocklist.removeFromServerBlocklist({ account }) |
163 | 145 | ||
164 | { | 146 | { |
165 | const res = await getVideosList(servers[0].url) | 147 | const { total } = await servers[0].videos.list() |
166 | expect(res.body.total).to.equal(2) | 148 | expect(total).to.equal(2) |
167 | } | 149 | } |
168 | 150 | ||
169 | killallServers([ servers[0] ]) | 151 | await killallServers([ servers[0] ]) |
170 | await reRunServer(servers[0]) | 152 | await servers[0].run() |
171 | await wait(2000) | 153 | await wait(2000) |
172 | 154 | ||
173 | { | 155 | { |
174 | const res = await getVideosList(servers[0].url) | 156 | const { total } = await servers[0].videos.list() |
175 | expect(res.body.total).to.equal(2) | 157 | expect(total).to.equal(2) |
176 | } | 158 | } |
177 | }) | 159 | }) |
178 | 160 | ||
@@ -180,14 +162,12 @@ describe('Official plugin auto-mute', function () { | |||
180 | await makeGetRequest({ | 162 | await makeGetRequest({ |
181 | url: servers[0].url, | 163 | url: servers[0].url, |
182 | path: '/plugins/auto-mute/router/api/v1/mute-list', | 164 | path: '/plugins/auto-mute/router/api/v1/mute-list', |
183 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 165 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
184 | }) | 166 | }) |
185 | }) | 167 | }) |
186 | 168 | ||
187 | it('Should enable auto mute list', async function () { | 169 | it('Should enable auto mute list', async function () { |
188 | await updatePluginSettings({ | 170 | await servers[0].plugins.updateSettings({ |
189 | url: servers[0].url, | ||
190 | accessToken: servers[0].accessToken, | ||
191 | npmName: 'peertube-plugin-auto-mute', | 171 | npmName: 'peertube-plugin-auto-mute', |
192 | settings: { | 172 | settings: { |
193 | 'blocklist-urls': '', | 173 | 'blocklist-urls': '', |
@@ -199,16 +179,14 @@ describe('Official plugin auto-mute', function () { | |||
199 | await makeGetRequest({ | 179 | await makeGetRequest({ |
200 | url: servers[0].url, | 180 | url: servers[0].url, |
201 | path: '/plugins/auto-mute/router/api/v1/mute-list', | 181 | path: '/plugins/auto-mute/router/api/v1/mute-list', |
202 | statusCodeExpected: HttpStatusCode.OK_200 | 182 | expectedStatus: HttpStatusCode.OK_200 |
203 | }) | 183 | }) |
204 | }) | 184 | }) |
205 | 185 | ||
206 | it('Should mute an account on server 1, and server 2 auto mutes it', async function () { | 186 | it('Should mute an account on server 1, and server 2 auto mutes it', async function () { |
207 | this.timeout(20000) | 187 | this.timeout(20000) |
208 | 188 | ||
209 | await updatePluginSettings({ | 189 | await servers[1].plugins.updateSettings({ |
210 | url: servers[1].url, | ||
211 | accessToken: servers[1].accessToken, | ||
212 | npmName: 'peertube-plugin-auto-mute', | 190 | npmName: 'peertube-plugin-auto-mute', |
213 | settings: { | 191 | settings: { |
214 | 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath, | 192 | 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath, |
@@ -217,13 +195,13 @@ describe('Official plugin auto-mute', function () { | |||
217 | } | 195 | } |
218 | }) | 196 | }) |
219 | 197 | ||
220 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port) | 198 | await servers[0].blocklist.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }) |
221 | await addServerToAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) | 199 | await servers[0].blocklist.addToMyBlocklist({ server: 'localhost:' + servers[1].port }) |
222 | 200 | ||
223 | const res = await makeGetRequest({ | 201 | const res = await makeGetRequest({ |
224 | url: servers[0].url, | 202 | url: servers[0].url, |
225 | path: '/plugins/auto-mute/router/api/v1/mute-list', | 203 | path: '/plugins/auto-mute/router/api/v1/mute-list', |
226 | statusCodeExpected: HttpStatusCode.OK_200 | 204 | expectedStatus: HttpStatusCode.OK_200 |
227 | }) | 205 | }) |
228 | 206 | ||
229 | const data = res.body.data | 207 | const data = res.body.data |
@@ -234,8 +212,8 @@ describe('Official plugin auto-mute', function () { | |||
234 | await wait(2000) | 212 | await wait(2000) |
235 | 213 | ||
236 | for (const server of servers) { | 214 | for (const server of servers) { |
237 | const res = await getVideosList(server.url) | 215 | const { total } = await server.videos.list() |
238 | expect(res.body.total).to.equal(1) | 216 | expect(total).to.equal(1) |
239 | } | 217 | } |
240 | }) | 218 | }) |
241 | 219 | ||