diff options
Diffstat (limited to 'server/tests/api/moderation')
-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 |
3 files changed, 59 insertions, 96 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 () { |