diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-07 16:02:46 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | 5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c (patch) | |
tree | 02d056121540652b0867fc2ef56699138afe6271 /server/tests/api | |
parent | 9fff08cf83f34339df7ed4ac770e1dee536adf9d (diff) | |
download | PeerTube-5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c.tar.gz PeerTube-5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c.tar.zst PeerTube-5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c.zip |
Introduce blocklist command
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/moderation/abuses.ts | 14 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist-notification.ts | 41 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist.ts | 100 | ||||
-rw-r--r-- | server/tests/api/notifications/comments-notifications.ts | 10 | ||||
-rw-r--r-- | server/tests/api/videos/video-playlists.ts | 26 | ||||
-rw-r--r-- | server/tests/api/videos/videos-overview.ts | 3 |
6 files changed, 74 insertions, 120 deletions
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index 124833cf6..a2bd07b12 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts | |||
@@ -4,8 +4,6 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | AbusesCommand, | 6 | AbusesCommand, |
7 | addAccountToServerBlocklist, | ||
8 | addServerToServerBlocklist, | ||
9 | addVideoCommentThread, | 7 | addVideoCommentThread, |
10 | cleanupTests, | 8 | cleanupTests, |
11 | createUser, | 9 | createUser, |
@@ -16,8 +14,6 @@ import { | |||
16 | getVideoCommentThreads, | 14 | getVideoCommentThreads, |
17 | getVideoIdFromUUID, | 15 | getVideoIdFromUUID, |
18 | getVideosList, | 16 | getVideosList, |
19 | removeAccountFromServerBlocklist, | ||
20 | removeServerFromServerBlocklist, | ||
21 | removeUser, | 17 | removeUser, |
22 | removeVideo, | 18 | removeVideo, |
23 | ServerInfo, | 19 | ServerInfo, |
@@ -27,7 +23,7 @@ import { | |||
27 | userLogin, | 23 | userLogin, |
28 | waitJobs | 24 | waitJobs |
29 | } from '@shared/extra-utils' | 25 | } from '@shared/extra-utils' |
30 | import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, Account, AdminAbuse, UserAbuse, VideoComment } from '@shared/models' | 26 | import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse, VideoComment } from '@shared/models' |
31 | 27 | ||
32 | const expect = chai.expect | 28 | const expect = chai.expect |
33 | 29 | ||
@@ -225,7 +221,7 @@ describe('Test abuses', function () { | |||
225 | const accountToBlock = 'root@' + servers[1].host | 221 | const accountToBlock = 'root@' + servers[1].host |
226 | 222 | ||
227 | { | 223 | { |
228 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) | 224 | await servers[0].blocklistCommand.addToServerBlocklist({ account: accountToBlock }) |
229 | 225 | ||
230 | const body = await commands[0].getAdminList() | 226 | const body = await commands[0].getAdminList() |
231 | expect(body.total).to.equal(2) | 227 | expect(body.total).to.equal(2) |
@@ -235,7 +231,7 @@ describe('Test abuses', function () { | |||
235 | } | 231 | } |
236 | 232 | ||
237 | { | 233 | { |
238 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) | 234 | await servers[0].blocklistCommand.removeFromServerBlocklist({ account: accountToBlock }) |
239 | 235 | ||
240 | const body = await commands[0].getAdminList() | 236 | const body = await commands[0].getAdminList() |
241 | expect(body.total).to.equal(3) | 237 | expect(body.total).to.equal(3) |
@@ -246,7 +242,7 @@ describe('Test abuses', function () { | |||
246 | const serverToBlock = servers[1].host | 242 | const serverToBlock = servers[1].host |
247 | 243 | ||
248 | { | 244 | { |
249 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, servers[1].host) | 245 | await servers[0].blocklistCommand.addToServerBlocklist({ server: serverToBlock }) |
250 | 246 | ||
251 | const body = await commands[0].getAdminList() | 247 | const body = await commands[0].getAdminList() |
252 | expect(body.total).to.equal(2) | 248 | expect(body.total).to.equal(2) |
@@ -256,7 +252,7 @@ describe('Test abuses', function () { | |||
256 | } | 252 | } |
257 | 253 | ||
258 | { | 254 | { |
259 | await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, serverToBlock) | 255 | await servers[0].blocklistCommand.removeFromServerBlocklist({ server: serverToBlock }) |
260 | 256 | ||
261 | const body = await commands[0].getAdminList() | 257 | const body = await commands[0].getAdminList() |
262 | expect(body.total).to.equal(3) | 258 | expect(body.total).to.equal(3) |
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts index 4fb3c95f2..99da64a2d 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/server/tests/api/moderation/blocklist-notification.ts | |||
@@ -2,30 +2,23 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { getUserNotifications, markAsReadAllNotifications } from '@shared/extra-utils/users/user-notifications' | ||
6 | import { addUserSubscription, removeUserSubscription } from '@shared/extra-utils/users/user-subscriptions' | ||
7 | import { UserNotification, UserNotificationType } from '@shared/models' | ||
8 | import { | 5 | import { |
6 | addUserSubscription, | ||
7 | addVideoCommentThread, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createUser, | 9 | createUser, |
11 | doubleFollow, | 10 | doubleFollow, |
12 | flushAndRunMultipleServers, | 11 | flushAndRunMultipleServers, |
12 | getUserNotifications, | ||
13 | markAsReadAllNotifications, | ||
14 | removeUserSubscription, | ||
13 | ServerInfo, | 15 | ServerInfo, |
16 | setAccessTokensToServers, | ||
14 | uploadVideo, | 17 | uploadVideo, |
15 | userLogin | 18 | userLogin, |
16 | } from '../../../../shared/extra-utils/index' | 19 | waitJobs |
17 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 20 | } from '@shared/extra-utils' |
18 | import { | 21 | import { UserNotification, UserNotificationType } from '@shared/models' |
19 | addAccountToAccountBlocklist, | ||
20 | addAccountToServerBlocklist, | ||
21 | addServerToAccountBlocklist, | ||
22 | addServerToServerBlocklist, | ||
23 | removeAccountFromAccountBlocklist, | ||
24 | removeAccountFromServerBlocklist, | ||
25 | removeServerFromAccountBlocklist | ||
26 | } from '../../../../shared/extra-utils/users/blocklist' | ||
27 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' | ||
28 | import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' | ||
29 | 22 | ||
30 | const expect = chai.expect | 23 | const expect = chai.expect |
31 | 24 | ||
@@ -134,7 +127,7 @@ describe('Test blocklist', function () { | |||
134 | it('Should block an account', async function () { | 127 | it('Should block an account', async function () { |
135 | this.timeout(10000) | 128 | this.timeout(10000) |
136 | 129 | ||
137 | await addAccountToAccountBlocklist(servers[0].url, userToken1, 'user3@' + servers[1].host) | 130 | await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }) |
138 | await waitJobs(servers) | 131 | await waitJobs(servers) |
139 | }) | 132 | }) |
140 | 133 | ||
@@ -147,7 +140,7 @@ describe('Test blocklist', function () { | |||
147 | 140 | ||
148 | await checkNotifications(servers[0].url, userToken2, notifs) | 141 | await checkNotifications(servers[0].url, userToken2, notifs) |
149 | 142 | ||
150 | await removeAccountFromAccountBlocklist(servers[0].url, userToken1, 'user3@' + servers[1].host) | 143 | await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }) |
151 | }) | 144 | }) |
152 | }) | 145 | }) |
153 | 146 | ||
@@ -167,7 +160,7 @@ describe('Test blocklist', function () { | |||
167 | it('Should block an account', async function () { | 160 | it('Should block an account', async function () { |
168 | this.timeout(10000) | 161 | this.timeout(10000) |
169 | 162 | ||
170 | await addServerToAccountBlocklist(servers[0].url, userToken1, servers[1].host) | 163 | await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, server: servers[1].host }) |
171 | await waitJobs(servers) | 164 | await waitJobs(servers) |
172 | }) | 165 | }) |
173 | 166 | ||
@@ -180,7 +173,7 @@ describe('Test blocklist', function () { | |||
180 | 173 | ||
181 | await checkNotifications(servers[0].url, userToken2, notifs) | 174 | await checkNotifications(servers[0].url, userToken2, notifs) |
182 | 175 | ||
183 | await removeServerFromAccountBlocklist(servers[0].url, userToken1, servers[1].host) | 176 | await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, server: servers[1].host }) |
184 | }) | 177 | }) |
185 | }) | 178 | }) |
186 | 179 | ||
@@ -207,7 +200,7 @@ describe('Test blocklist', function () { | |||
207 | it('Should block an account', async function () { | 200 | it('Should block an account', async function () { |
208 | this.timeout(10000) | 201 | this.timeout(10000) |
209 | 202 | ||
210 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user3@' + servers[1].host) | 203 | await servers[0].blocklistCommand.addToServerBlocklist({ account: 'user3@' + servers[1].host }) |
211 | await waitJobs(servers) | 204 | await waitJobs(servers) |
212 | }) | 205 | }) |
213 | 206 | ||
@@ -215,7 +208,7 @@ describe('Test blocklist', function () { | |||
215 | await checkNotifications(servers[0].url, userToken1, []) | 208 | await checkNotifications(servers[0].url, userToken1, []) |
216 | await checkNotifications(servers[0].url, userToken2, []) | 209 | await checkNotifications(servers[0].url, userToken2, []) |
217 | 210 | ||
218 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user3@' + servers[1].host) | 211 | await servers[0].blocklistCommand.removeFromServerBlocklist({ account: 'user3@' + servers[1].host }) |
219 | }) | 212 | }) |
220 | }) | 213 | }) |
221 | 214 | ||
@@ -242,7 +235,7 @@ describe('Test blocklist', function () { | |||
242 | it('Should block an account', async function () { | 235 | it('Should block an account', async function () { |
243 | this.timeout(10000) | 236 | this.timeout(10000) |
244 | 237 | ||
245 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, servers[1].host) | 238 | await servers[0].blocklistCommand.addToServerBlocklist({ server: servers[1].host }) |
246 | await waitJobs(servers) | 239 | await waitJobs(servers) |
247 | }) | 240 | }) |
248 | 241 | ||
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index 9ca6324c2..1b8860571 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -3,46 +3,27 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | addAccountToAccountBlocklist, | ||
7 | addAccountToServerBlocklist, | ||
8 | addServerToAccountBlocklist, | ||
9 | addServerToServerBlocklist, | ||
10 | addVideoCommentReply, | 6 | addVideoCommentReply, |
11 | addVideoCommentThread, | 7 | addVideoCommentThread, |
8 | BlocklistCommand, | ||
12 | cleanupTests, | 9 | cleanupTests, |
13 | createUser, | 10 | createUser, |
14 | deleteVideoComment, | 11 | deleteVideoComment, |
15 | doubleFollow, | 12 | doubleFollow, |
16 | findCommentId, | 13 | findCommentId, |
17 | flushAndRunMultipleServers, | 14 | flushAndRunMultipleServers, |
18 | getAccountBlocklistByAccount, | ||
19 | getAccountBlocklistByServer, | ||
20 | getServerBlocklistByAccount, | ||
21 | getServerBlocklistByServer, | ||
22 | getUserNotifications, | 15 | getUserNotifications, |
23 | getVideoCommentThreads, | 16 | getVideoCommentThreads, |
24 | getVideosList, | 17 | getVideosList, |
25 | getVideosListWithToken, | 18 | getVideosListWithToken, |
26 | getVideoThreadComments, | 19 | getVideoThreadComments, |
27 | removeAccountFromAccountBlocklist, | ||
28 | removeAccountFromServerBlocklist, | ||
29 | removeServerFromAccountBlocklist, | ||
30 | removeServerFromServerBlocklist, | ||
31 | ServerInfo, | 20 | ServerInfo, |
32 | setAccessTokensToServers, | 21 | setAccessTokensToServers, |
33 | uploadVideo, | 22 | uploadVideo, |
34 | userLogin, | 23 | userLogin, |
35 | waitJobs | 24 | waitJobs |
36 | } from '@shared/extra-utils' | 25 | } from '@shared/extra-utils' |
37 | import { | 26 | import { UserNotification, UserNotificationType, Video, VideoComment, VideoCommentThreadTree } from '@shared/models' |
38 | AccountBlock, | ||
39 | ServerBlock, | ||
40 | UserNotification, | ||
41 | UserNotificationType, | ||
42 | Video, | ||
43 | VideoComment, | ||
44 | VideoCommentThreadTree | ||
45 | } from '@shared/models' | ||
46 | 27 | ||
47 | const expect = chai.expect | 28 | const expect = chai.expect |
48 | 29 | ||
@@ -108,6 +89,8 @@ describe('Test blocklist', function () { | |||
108 | let userModeratorToken: string | 89 | let userModeratorToken: string |
109 | let userToken2: string | 90 | let userToken2: string |
110 | 91 | ||
92 | let command: BlocklistCommand | ||
93 | |||
111 | before(async function () { | 94 | before(async function () { |
112 | this.timeout(120000) | 95 | this.timeout(120000) |
113 | 96 | ||
@@ -167,6 +150,8 @@ describe('Test blocklist', function () { | |||
167 | } | 150 | } |
168 | 151 | ||
169 | await waitJobs(servers) | 152 | await waitJobs(servers) |
153 | |||
154 | command = servers[0].blocklistCommand | ||
170 | }) | 155 | }) |
171 | 156 | ||
172 | describe('User blocklist', function () { | 157 | describe('User blocklist', function () { |
@@ -181,7 +166,7 @@ describe('Test blocklist', function () { | |||
181 | }) | 166 | }) |
182 | 167 | ||
183 | it('Should block a remote account', async function () { | 168 | it('Should block a remote account', async function () { |
184 | await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port) | 169 | await command.addToMyBlocklist({ account: 'user2@localhost:' + servers[1].port }) |
185 | }) | 170 | }) |
186 | 171 | ||
187 | it('Should hide its videos', async function () { | 172 | it('Should hide its videos', async function () { |
@@ -195,7 +180,7 @@ describe('Test blocklist', function () { | |||
195 | }) | 180 | }) |
196 | 181 | ||
197 | it('Should block a local account', async function () { | 182 | it('Should block a local account', async function () { |
198 | await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1') | 183 | await command.addToMyBlocklist({ account: 'user1' }) |
199 | }) | 184 | }) |
200 | 185 | ||
201 | it('Should hide its videos', async function () { | 186 | it('Should hide its videos', async function () { |
@@ -251,12 +236,10 @@ describe('Test blocklist', function () { | |||
251 | 236 | ||
252 | it('Should list blocked accounts', async function () { | 237 | it('Should list blocked accounts', async function () { |
253 | { | 238 | { |
254 | const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt') | 239 | const body = await command.listMyAccountBlocklist({ start: 0, count: 1, sort: 'createdAt' }) |
255 | const blocks: AccountBlock[] = res.body.data | 240 | expect(body.total).to.equal(2) |
256 | 241 | ||
257 | expect(res.body.total).to.equal(2) | 242 | const block = body.data[0] |
258 | |||
259 | const block = blocks[0] | ||
260 | expect(block.byAccount.displayName).to.equal('root') | 243 | expect(block.byAccount.displayName).to.equal('root') |
261 | expect(block.byAccount.name).to.equal('root') | 244 | expect(block.byAccount.name).to.equal('root') |
262 | expect(block.blockedAccount.displayName).to.equal('user2') | 245 | expect(block.blockedAccount.displayName).to.equal('user2') |
@@ -265,12 +248,10 @@ describe('Test blocklist', function () { | |||
265 | } | 248 | } |
266 | 249 | ||
267 | { | 250 | { |
268 | const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt') | 251 | const body = await command.listMyAccountBlocklist({ start: 1, count: 2, sort: 'createdAt' }) |
269 | const blocks: AccountBlock[] = res.body.data | 252 | expect(body.total).to.equal(2) |
270 | |||
271 | expect(res.body.total).to.equal(2) | ||
272 | 253 | ||
273 | const block = blocks[0] | 254 | const block = body.data[0] |
274 | expect(block.byAccount.displayName).to.equal('root') | 255 | expect(block.byAccount.displayName).to.equal('root') |
275 | expect(block.byAccount.name).to.equal('root') | 256 | expect(block.byAccount.name).to.equal('root') |
276 | expect(block.blockedAccount.displayName).to.equal('user1') | 257 | expect(block.blockedAccount.displayName).to.equal('user1') |
@@ -335,7 +316,7 @@ describe('Test blocklist', function () { | |||
335 | }) | 316 | }) |
336 | 317 | ||
337 | it('Should unblock the remote account', async function () { | 318 | it('Should unblock the remote account', async function () { |
338 | await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port) | 319 | await command.removeFromMyBlocklist({ account: 'user2@localhost:' + servers[1].port }) |
339 | }) | 320 | }) |
340 | 321 | ||
341 | it('Should display its videos', async function () { | 322 | it('Should display its videos', async function () { |
@@ -374,7 +355,7 @@ describe('Test blocklist', function () { | |||
374 | }) | 355 | }) |
375 | 356 | ||
376 | it('Should unblock the local account', async function () { | 357 | it('Should unblock the local account', async function () { |
377 | await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1') | 358 | await command.removeFromMyBlocklist({ account: 'user1' }) |
378 | }) | 359 | }) |
379 | 360 | ||
380 | it('Should display its comments', function () { | 361 | it('Should display its comments', function () { |
@@ -402,6 +383,7 @@ describe('Test blocklist', function () { | |||
402 | }) | 383 | }) |
403 | 384 | ||
404 | describe('When managing server blocklist', function () { | 385 | describe('When managing server blocklist', function () { |
386 | |||
405 | it('Should list all videos', function () { | 387 | it('Should list all videos', function () { |
406 | return checkAllVideos(servers[0].url, servers[0].accessToken) | 388 | return checkAllVideos(servers[0].url, servers[0].accessToken) |
407 | }) | 389 | }) |
@@ -411,7 +393,7 @@ describe('Test blocklist', function () { | |||
411 | }) | 393 | }) |
412 | 394 | ||
413 | it('Should block a remote server', async function () { | 395 | it('Should block a remote server', async function () { |
414 | await addServerToAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) | 396 | await command.addToMyBlocklist({ server: 'localhost:' + servers[1].port }) |
415 | }) | 397 | }) |
416 | 398 | ||
417 | it('Should hide its videos', async function () { | 399 | it('Should hide its videos', async function () { |
@@ -464,19 +446,17 @@ describe('Test blocklist', function () { | |||
464 | }) | 446 | }) |
465 | 447 | ||
466 | it('Should list blocked servers', async function () { | 448 | it('Should list blocked servers', async function () { |
467 | const res = await getServerBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt') | 449 | const body = await command.listMyServerBlocklist({ start: 0, count: 1, sort: 'createdAt' }) |
468 | const blocks: ServerBlock[] = res.body.data | 450 | expect(body.total).to.equal(1) |
469 | |||
470 | expect(res.body.total).to.equal(1) | ||
471 | 451 | ||
472 | const block = blocks[0] | 452 | const block = body.data[0] |
473 | expect(block.byAccount.displayName).to.equal('root') | 453 | expect(block.byAccount.displayName).to.equal('root') |
474 | expect(block.byAccount.name).to.equal('root') | 454 | expect(block.byAccount.name).to.equal('root') |
475 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 455 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
476 | }) | 456 | }) |
477 | 457 | ||
478 | it('Should unblock the remote server', async function () { | 458 | it('Should unblock the remote server', async function () { |
479 | await removeServerFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) | 459 | await command.removeFromMyBlocklist({ server: 'localhost:' + servers[1].port }) |
480 | }) | 460 | }) |
481 | 461 | ||
482 | it('Should display its videos', function () { | 462 | it('Should display its videos', function () { |
@@ -524,7 +504,7 @@ describe('Test blocklist', function () { | |||
524 | }) | 504 | }) |
525 | 505 | ||
526 | it('Should block a remote account', async function () { | 506 | it('Should block a remote account', async function () { |
527 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port) | 507 | await command.addToServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) |
528 | }) | 508 | }) |
529 | 509 | ||
530 | it('Should hide its videos', async function () { | 510 | it('Should hide its videos', async function () { |
@@ -540,7 +520,7 @@ describe('Test blocklist', function () { | |||
540 | }) | 520 | }) |
541 | 521 | ||
542 | it('Should block a local account', async function () { | 522 | it('Should block a local account', async function () { |
543 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user1') | 523 | await command.addToServerBlocklist({ account: 'user1' }) |
544 | }) | 524 | }) |
545 | 525 | ||
546 | it('Should hide its videos', async function () { | 526 | it('Should hide its videos', async function () { |
@@ -598,12 +578,10 @@ describe('Test blocklist', function () { | |||
598 | 578 | ||
599 | it('Should list blocked accounts', async function () { | 579 | it('Should list blocked accounts', async function () { |
600 | { | 580 | { |
601 | const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt') | 581 | const body = await command.listServerAccountBlocklist({ start: 0, count: 1, sort: 'createdAt' }) |
602 | const blocks: AccountBlock[] = res.body.data | 582 | expect(body.total).to.equal(2) |
603 | |||
604 | expect(res.body.total).to.equal(2) | ||
605 | 583 | ||
606 | const block = blocks[0] | 584 | const block = body.data[0] |
607 | expect(block.byAccount.displayName).to.equal('peertube') | 585 | expect(block.byAccount.displayName).to.equal('peertube') |
608 | expect(block.byAccount.name).to.equal('peertube') | 586 | expect(block.byAccount.name).to.equal('peertube') |
609 | expect(block.blockedAccount.displayName).to.equal('user2') | 587 | expect(block.blockedAccount.displayName).to.equal('user2') |
@@ -612,12 +590,10 @@ describe('Test blocklist', function () { | |||
612 | } | 590 | } |
613 | 591 | ||
614 | { | 592 | { |
615 | const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt') | 593 | const body = await command.listServerAccountBlocklist({ start: 1, count: 2, sort: 'createdAt' }) |
616 | const blocks: AccountBlock[] = res.body.data | 594 | expect(body.total).to.equal(2) |
617 | 595 | ||
618 | expect(res.body.total).to.equal(2) | 596 | const block = body.data[0] |
619 | |||
620 | const block = blocks[0] | ||
621 | expect(block.byAccount.displayName).to.equal('peertube') | 597 | expect(block.byAccount.displayName).to.equal('peertube') |
622 | expect(block.byAccount.name).to.equal('peertube') | 598 | expect(block.byAccount.name).to.equal('peertube') |
623 | expect(block.blockedAccount.displayName).to.equal('user1') | 599 | expect(block.blockedAccount.displayName).to.equal('user1') |
@@ -627,7 +603,7 @@ describe('Test blocklist', function () { | |||
627 | }) | 603 | }) |
628 | 604 | ||
629 | it('Should unblock the remote account', async function () { | 605 | it('Should unblock the remote account', async function () { |
630 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port) | 606 | await command.removeFromServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) |
631 | }) | 607 | }) |
632 | 608 | ||
633 | it('Should display its videos', async function () { | 609 | it('Should display its videos', async function () { |
@@ -643,7 +619,7 @@ describe('Test blocklist', function () { | |||
643 | }) | 619 | }) |
644 | 620 | ||
645 | it('Should unblock the local account', async function () { | 621 | it('Should unblock the local account', async function () { |
646 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user1') | 622 | await command.removeFromServerBlocklist({ account: 'user1' }) |
647 | }) | 623 | }) |
648 | 624 | ||
649 | it('Should display its comments', async function () { | 625 | it('Should display its comments', async function () { |
@@ -686,7 +662,7 @@ describe('Test blocklist', function () { | |||
686 | }) | 662 | }) |
687 | 663 | ||
688 | it('Should block a remote server', async function () { | 664 | it('Should block a remote server', async function () { |
689 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) | 665 | await command.addToServerBlocklist({ server: 'localhost:' + servers[1].port }) |
690 | }) | 666 | }) |
691 | 667 | ||
692 | it('Should hide its videos', async function () { | 668 | it('Should hide its videos', async function () { |
@@ -758,19 +734,17 @@ describe('Test blocklist', function () { | |||
758 | }) | 734 | }) |
759 | 735 | ||
760 | it('Should list blocked servers', async function () { | 736 | it('Should list blocked servers', async function () { |
761 | const res = await getServerBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt') | 737 | const body = await command.listServerServerBlocklist({ start: 0, count: 1, sort: 'createdAt' }) |
762 | const blocks: ServerBlock[] = res.body.data | 738 | expect(body.total).to.equal(1) |
763 | |||
764 | expect(res.body.total).to.equal(1) | ||
765 | 739 | ||
766 | const block = blocks[0] | 740 | const block = body.data[0] |
767 | expect(block.byAccount.displayName).to.equal('peertube') | 741 | expect(block.byAccount.displayName).to.equal('peertube') |
768 | expect(block.byAccount.name).to.equal('peertube') | 742 | expect(block.byAccount.name).to.equal('peertube') |
769 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 743 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
770 | }) | 744 | }) |
771 | 745 | ||
772 | it('Should unblock the remote server', async function () { | 746 | it('Should unblock the remote server', async function () { |
773 | await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) | 747 | await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) |
774 | }) | 748 | }) |
775 | 749 | ||
776 | it('Should list all videos', async function () { | 750 | it('Should list all videos', async function () { |
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index d2badf237..13fcee843 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts | |||
@@ -3,7 +3,6 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | addAccountToAccountBlocklist, | ||
7 | addVideoCommentReply, | 6 | addVideoCommentReply, |
8 | addVideoCommentThread, | 7 | addVideoCommentThread, |
9 | checkCommentMention, | 8 | checkCommentMention, |
@@ -14,7 +13,6 @@ import { | |||
14 | getVideoThreadComments, | 13 | getVideoThreadComments, |
15 | MockSmtpServer, | 14 | MockSmtpServer, |
16 | prepareNotificationsTest, | 15 | prepareNotificationsTest, |
17 | removeAccountFromAccountBlocklist, | ||
18 | ServerInfo, | 16 | ServerInfo, |
19 | updateMyUser, | 17 | updateMyUser, |
20 | uploadVideo, | 18 | uploadVideo, |
@@ -86,7 +84,7 @@ describe('Test comments notifications', function () { | |||
86 | it('Should not send a new comment notification if the account is muted', async function () { | 84 | it('Should not send a new comment notification if the account is muted', async function () { |
87 | this.timeout(20000) | 85 | this.timeout(20000) |
88 | 86 | ||
89 | await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root') | 87 | await servers[0].blocklistCommand.addToMyBlocklist({ token: userAccessToken, account: 'root' }) |
90 | 88 | ||
91 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 89 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) |
92 | const uuid = resVideo.body.video.uuid | 90 | const uuid = resVideo.body.video.uuid |
@@ -97,7 +95,7 @@ describe('Test comments notifications', function () { | |||
97 | await waitJobs(servers) | 95 | await waitJobs(servers) |
98 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') | 96 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') |
99 | 97 | ||
100 | await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root') | 98 | await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userAccessToken, account: 'root' }) |
101 | }) | 99 | }) |
102 | 100 | ||
103 | it('Should send a new comment notification after a local comment on my video', async function () { | 101 | it('Should send a new comment notification after a local comment on my video', async function () { |
@@ -244,7 +242,7 @@ describe('Test comments notifications', function () { | |||
244 | it('Should not send a new mention notification if the account is muted', async function () { | 242 | it('Should not send a new mention notification if the account is muted', async function () { |
245 | this.timeout(10000) | 243 | this.timeout(10000) |
246 | 244 | ||
247 | await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root') | 245 | await servers[0].blocklistCommand.addToMyBlocklist({ token: userAccessToken, account: 'root' }) |
248 | 246 | ||
249 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 247 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) |
250 | const uuid = resVideo.body.video.uuid | 248 | const uuid = resVideo.body.video.uuid |
@@ -255,7 +253,7 @@ describe('Test comments notifications', function () { | |||
255 | await waitJobs(servers) | 253 | await waitJobs(servers) |
256 | await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') | 254 | await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') |
257 | 255 | ||
258 | await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root') | 256 | await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userAccessToken, account: 'root' }) |
259 | }) | 257 | }) |
260 | 258 | ||
261 | it('Should not send a new mention notification if the remote account mention a local account', async function () { | 259 | it('Should not send a new mention notification if the remote account mention a local account', async function () { |
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 28f68dcfe..90189721a 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -4,10 +4,6 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/core-utils' |
6 | import { | 6 | import { |
7 | addAccountToAccountBlocklist, | ||
8 | addAccountToServerBlocklist, | ||
9 | addServerToAccountBlocklist, | ||
10 | addServerToServerBlocklist, | ||
11 | addVideoChannel, | 7 | addVideoChannel, |
12 | addVideoInPlaylist, | 8 | addVideoInPlaylist, |
13 | addVideoToBlacklist, | 9 | addVideoToBlacklist, |
@@ -31,10 +27,6 @@ import { | |||
31 | getVideoPlaylistPrivacies, | 27 | getVideoPlaylistPrivacies, |
32 | getVideoPlaylistsList, | 28 | getVideoPlaylistsList, |
33 | getVideoPlaylistWithToken, | 29 | getVideoPlaylistWithToken, |
34 | removeAccountFromAccountBlocklist, | ||
35 | removeAccountFromServerBlocklist, | ||
36 | removeServerFromAccountBlocklist, | ||
37 | removeServerFromServerBlocklist, | ||
38 | removeUser, | 30 | removeUser, |
39 | removeVideoFromBlacklist, | 31 | removeVideoFromBlacklist, |
40 | removeVideoFromPlaylist, | 32 | removeVideoFromPlaylist, |
@@ -760,56 +752,58 @@ describe('Test video playlists', function () { | |||
760 | it('Should update the element type if the account or server of the video is blocked', async function () { | 752 | it('Should update the element type if the account or server of the video is blocked', async function () { |
761 | this.timeout(90000) | 753 | this.timeout(90000) |
762 | 754 | ||
755 | const command = servers[0].blocklistCommand | ||
756 | |||
763 | const name = 'video 90' | 757 | const name = 'video 90' |
764 | const position = 2 | 758 | const position = 2 |
765 | 759 | ||
766 | { | 760 | { |
767 | await addAccountToAccountBlocklist(servers[0].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port) | 761 | await command.addToMyBlocklist({ token: userAccessTokenServer1, account: 'root@localhost:' + servers[1].port }) |
768 | await waitJobs(servers) | 762 | await waitJobs(servers) |
769 | 763 | ||
770 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 764 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
771 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 765 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
772 | 766 | ||
773 | await removeAccountFromAccountBlocklist(servers[0].url, userAccessTokenServer1, 'root@localhost:' + servers[1].port) | 767 | await command.removeFromMyBlocklist({ token: userAccessTokenServer1, account: 'root@localhost:' + servers[1].port }) |
774 | await waitJobs(servers) | 768 | await waitJobs(servers) |
775 | 769 | ||
776 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 770 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
777 | } | 771 | } |
778 | 772 | ||
779 | { | 773 | { |
780 | await addServerToAccountBlocklist(servers[0].url, userAccessTokenServer1, 'localhost:' + servers[1].port) | 774 | await command.addToMyBlocklist({ token: userAccessTokenServer1, server: 'localhost:' + servers[1].port }) |
781 | await waitJobs(servers) | 775 | await waitJobs(servers) |
782 | 776 | ||
783 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 777 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
784 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 778 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
785 | 779 | ||
786 | await removeServerFromAccountBlocklist(servers[0].url, userAccessTokenServer1, 'localhost:' + servers[1].port) | 780 | await command.removeFromMyBlocklist({ token: userAccessTokenServer1, server: 'localhost:' + servers[1].port }) |
787 | await waitJobs(servers) | 781 | await waitJobs(servers) |
788 | 782 | ||
789 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 783 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
790 | } | 784 | } |
791 | 785 | ||
792 | { | 786 | { |
793 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port) | 787 | await command.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }) |
794 | await waitJobs(servers) | 788 | await waitJobs(servers) |
795 | 789 | ||
796 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 790 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
797 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 791 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
798 | 792 | ||
799 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'root@localhost:' + servers[1].port) | 793 | await command.removeFromServerBlocklist({ account: 'root@localhost:' + servers[1].port }) |
800 | await waitJobs(servers) | 794 | await waitJobs(servers) |
801 | 795 | ||
802 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 796 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
803 | } | 797 | } |
804 | 798 | ||
805 | { | 799 | { |
806 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) | 800 | await command.addToServerBlocklist({ server: 'localhost:' + servers[1].port }) |
807 | await waitJobs(servers) | 801 | await waitJobs(servers) |
808 | 802 | ||
809 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) | 803 | await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) |
810 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 804 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
811 | 805 | ||
812 | await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port) | 806 | await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) |
813 | await waitJobs(servers) | 807 | await waitJobs(servers) |
814 | 808 | ||
815 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) | 809 | await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) |
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index b3ab9e070..ccbc6f4a4 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts | |||
@@ -3,7 +3,6 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | addAccountToAccountBlocklist, | ||
7 | cleanupTests, | 6 | cleanupTests, |
8 | flushAndRunServer, | 7 | flushAndRunServer, |
9 | generateUserAccessToken, | 8 | generateUserAccessToken, |
@@ -115,7 +114,7 @@ describe('Test a videos overview', function () { | |||
115 | it('Should hide muted accounts', async function () { | 114 | it('Should hide muted accounts', async function () { |
116 | const token = await generateUserAccessToken(server, 'choco') | 115 | const token = await generateUserAccessToken(server, 'choco') |
117 | 116 | ||
118 | await addAccountToAccountBlocklist(server.url, token, 'root@' + server.host) | 117 | await server.blocklistCommand.addToMyBlocklist({ token, account: 'root@' + server.host }) |
119 | 118 | ||
120 | { | 119 | { |
121 | const body = await server.overviewsCommand.getVideos({ page: 1 }) | 120 | const body = await server.overviewsCommand.getVideos({ page: 1 }) |