aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/moderation/abuses.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:04:35 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit89d241a79c262b9775c233b73cff080043ebb5e6 (patch)
treecb3b6cb431d25d891ef4e02f66c61d252d17048f /server/tests/api/moderation/abuses.ts
parentd23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff)
downloadPeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip
Shorter server command names
Diffstat (limited to 'server/tests/api/moderation/abuses.ts')
-rw-r--r--server/tests/api/moderation/abuses.ts96
1 files changed, 48 insertions, 48 deletions
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index 7574b8f4a..97a0d95c4 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -33,7 +33,7 @@ describe('Test abuses', function () {
33 // Server 1 and server 2 follow each other 33 // Server 1 and server 2 follow each other
34 await doubleFollow(servers[0], servers[1]) 34 await doubleFollow(servers[0], servers[1])
35 35
36 commands = servers.map(s => s.abusesCommand) 36 commands = servers.map(s => s.abuses)
37 }) 37 })
38 38
39 describe('Video abuses', function () { 39 describe('Video abuses', function () {
@@ -47,7 +47,7 @@ describe('Test abuses', function () {
47 name: 'my super name for server 1', 47 name: 'my super name for server 1',
48 description: 'my super description for server 1' 48 description: 'my super description for server 1'
49 } 49 }
50 await servers[0].videosCommand.upload({ attributes }) 50 await servers[0].videos.upload({ attributes })
51 } 51 }
52 52
53 { 53 {
@@ -55,17 +55,17 @@ describe('Test abuses', function () {
55 name: 'my super name for server 2', 55 name: 'my super name for server 2',
56 description: 'my super description for server 2' 56 description: 'my super description for server 2'
57 } 57 }
58 await servers[1].videosCommand.upload({ attributes }) 58 await servers[1].videos.upload({ attributes })
59 } 59 }
60 60
61 // Wait videos propagation, server 2 has transcoding enabled 61 // Wait videos propagation, server 2 has transcoding enabled
62 await waitJobs(servers) 62 await waitJobs(servers)
63 63
64 const { data } = await servers[0].videosCommand.list() 64 const { data } = await servers[0].videos.list()
65 expect(data.length).to.equal(2) 65 expect(data.length).to.equal(2)
66 66
67 servers[0].video = data.find(video => video.name === 'my super name for server 1') 67 servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
68 servers[1].video = data.find(video => video.name === 'my super name for server 2') 68 servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
69 }) 69 })
70 70
71 it('Should not have abuses', async function () { 71 it('Should not have abuses', async function () {
@@ -80,7 +80,7 @@ describe('Test abuses', function () {
80 this.timeout(15000) 80 this.timeout(15000)
81 81
82 const reason = 'my super bad reason' 82 const reason = 'my super bad reason'
83 await commands[0].report({ videoId: servers[0].video.id, reason }) 83 await commands[0].report({ videoId: servers[0].store.video.id, reason })
84 84
85 // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2 85 // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2
86 await waitJobs(servers) 86 await waitJobs(servers)
@@ -100,7 +100,7 @@ describe('Test abuses', function () {
100 expect(abuse.reporterAccount.name).to.equal('root') 100 expect(abuse.reporterAccount.name).to.equal('root')
101 expect(abuse.reporterAccount.host).to.equal(servers[0].host) 101 expect(abuse.reporterAccount.host).to.equal(servers[0].host)
102 102
103 expect(abuse.video.id).to.equal(servers[0].video.id) 103 expect(abuse.video.id).to.equal(servers[0].store.video.id)
104 expect(abuse.video.channel).to.exist 104 expect(abuse.video.channel).to.exist
105 105
106 expect(abuse.comment).to.be.null 106 expect(abuse.comment).to.be.null
@@ -127,7 +127,7 @@ describe('Test abuses', function () {
127 this.timeout(10000) 127 this.timeout(10000)
128 128
129 const reason = 'my super bad reason 2' 129 const reason = 'my super bad reason 2'
130 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid }) 130 const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
131 await commands[0].report({ videoId, reason }) 131 await commands[0].report({ videoId, reason })
132 132
133 // We wait requests propagation 133 // We wait requests propagation
@@ -146,7 +146,7 @@ describe('Test abuses', function () {
146 expect(abuse1.reporterAccount.name).to.equal('root') 146 expect(abuse1.reporterAccount.name).to.equal('root')
147 expect(abuse1.reporterAccount.host).to.equal(servers[0].host) 147 expect(abuse1.reporterAccount.host).to.equal(servers[0].host)
148 148
149 expect(abuse1.video.id).to.equal(servers[0].video.id) 149 expect(abuse1.video.id).to.equal(servers[0].store.video.id)
150 expect(abuse1.video.countReports).to.equal(1) 150 expect(abuse1.video.countReports).to.equal(1)
151 expect(abuse1.video.nthReport).to.equal(1) 151 expect(abuse1.video.nthReport).to.equal(1)
152 152
@@ -165,7 +165,7 @@ describe('Test abuses', function () {
165 expect(abuse2.reporterAccount.name).to.equal('root') 165 expect(abuse2.reporterAccount.name).to.equal('root')
166 expect(abuse2.reporterAccount.host).to.equal(servers[0].host) 166 expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
167 167
168 expect(abuse2.video.id).to.equal(servers[1].video.id) 168 expect(abuse2.video.id).to.equal(servers[1].store.video.id)
169 169
170 expect(abuse2.comment).to.be.null 170 expect(abuse2.comment).to.be.null
171 171
@@ -200,7 +200,7 @@ describe('Test abuses', function () {
200 this.timeout(10000) 200 this.timeout(10000)
201 201
202 { 202 {
203 const videoId = await servers[1].videosCommand.getId({ uuid: servers[0].video.uuid }) 203 const videoId = await servers[1].videos.getId({ uuid: servers[0].store.video.uuid })
204 await commands[1].report({ videoId, reason: 'will mute this' }) 204 await commands[1].report({ videoId, reason: 'will mute this' })
205 await waitJobs(servers) 205 await waitJobs(servers)
206 206
@@ -211,7 +211,7 @@ describe('Test abuses', function () {
211 const accountToBlock = 'root@' + servers[1].host 211 const accountToBlock = 'root@' + servers[1].host
212 212
213 { 213 {
214 await servers[0].blocklistCommand.addToServerBlocklist({ account: accountToBlock }) 214 await servers[0].blocklist.addToServerBlocklist({ account: accountToBlock })
215 215
216 const body = await commands[0].getAdminList() 216 const body = await commands[0].getAdminList()
217 expect(body.total).to.equal(2) 217 expect(body.total).to.equal(2)
@@ -221,7 +221,7 @@ describe('Test abuses', function () {
221 } 221 }
222 222
223 { 223 {
224 await servers[0].blocklistCommand.removeFromServerBlocklist({ account: accountToBlock }) 224 await servers[0].blocklist.removeFromServerBlocklist({ account: accountToBlock })
225 225
226 const body = await commands[0].getAdminList() 226 const body = await commands[0].getAdminList()
227 expect(body.total).to.equal(3) 227 expect(body.total).to.equal(3)
@@ -232,7 +232,7 @@ describe('Test abuses', function () {
232 const serverToBlock = servers[1].host 232 const serverToBlock = servers[1].host
233 233
234 { 234 {
235 await servers[0].blocklistCommand.addToServerBlocklist({ server: serverToBlock }) 235 await servers[0].blocklist.addToServerBlocklist({ server: serverToBlock })
236 236
237 const body = await commands[0].getAdminList() 237 const body = await commands[0].getAdminList()
238 expect(body.total).to.equal(2) 238 expect(body.total).to.equal(2)
@@ -242,7 +242,7 @@ describe('Test abuses', function () {
242 } 242 }
243 243
244 { 244 {
245 await servers[0].blocklistCommand.removeFromServerBlocklist({ server: serverToBlock }) 245 await servers[0].blocklist.removeFromServerBlocklist({ server: serverToBlock })
246 246
247 const body = await commands[0].getAdminList() 247 const body = await commands[0].getAdminList()
248 expect(body.total).to.equal(3) 248 expect(body.total).to.equal(3)
@@ -252,7 +252,7 @@ describe('Test abuses', function () {
252 it('Should keep the video abuse when deleting the video', async function () { 252 it('Should keep the video abuse when deleting the video', async function () {
253 this.timeout(10000) 253 this.timeout(10000)
254 254
255 await servers[1].videosCommand.remove({ id: abuseServer2.video.uuid }) 255 await servers[1].videos.remove({ id: abuseServer2.video.uuid })
256 256
257 await waitJobs(servers) 257 await waitJobs(servers)
258 258
@@ -272,15 +272,15 @@ describe('Test abuses', function () {
272 272
273 // register a second user to have two reporters/reportees 273 // register a second user to have two reporters/reportees
274 const user = { username: 'user2', password: 'password' } 274 const user = { username: 'user2', password: 'password' }
275 await servers[0].usersCommand.create({ ...user }) 275 await servers[0].users.create({ ...user })
276 const userAccessToken = await servers[0].loginCommand.getAccessToken(user) 276 const userAccessToken = await servers[0].login.getAccessToken(user)
277 277
278 // upload a third video via this user 278 // upload a third video via this user
279 const attributes = { 279 const attributes = {
280 name: 'my second super name for server 1', 280 name: 'my second super name for server 1',
281 description: 'my second super description for server 1' 281 description: 'my second super description for server 1'
282 } 282 }
283 const { id } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) 283 const { id } = await servers[0].videos.upload({ token: userAccessToken, attributes })
284 const video3Id = id 284 const video3Id = id
285 285
286 // resume with the test 286 // resume with the test
@@ -288,7 +288,7 @@ describe('Test abuses', function () {
288 await commands[0].report({ videoId: video3Id, reason: reason3 }) 288 await commands[0].report({ videoId: video3Id, reason: reason3 })
289 289
290 const reason4 = 'my super bad reason 4' 290 const reason4 = 'my super bad reason 4'
291 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: reason4 }) 291 await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: reason4 })
292 292
293 { 293 {
294 const body = await commands[0].getAdminList() 294 const body = await commands[0].getAdminList()
@@ -301,7 +301,7 @@ describe('Test abuses', function () {
301 expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse") 301 expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse")
302 expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse") 302 expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse")
303 303
304 const abuseServer1 = abuses.find(a => a.video.id === servers[0].video.id) 304 const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.video.id)
305 expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse") 305 expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse")
306 } 306 }
307 }) 307 })
@@ -312,7 +312,7 @@ describe('Test abuses', function () {
312 const reason5 = 'my super bad reason 5' 312 const reason5 = 'my super bad reason 5'
313 const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ] 313 const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ]
314 const createRes = await commands[0].report({ 314 const createRes = await commands[0].report({
315 videoId: servers[0].video.id, 315 videoId: servers[0].store.video.id,
316 reason: reason5, 316 reason: reason5,
317 predefinedReasons: predefinedReasons5, 317 predefinedReasons: predefinedReasons5,
318 startAt: 1, 318 startAt: 1,
@@ -391,10 +391,10 @@ describe('Test abuses', function () {
391 391
392 async function getComment (server: ServerInfo, videoIdArg: number | string) { 392 async function getComment (server: ServerInfo, videoIdArg: number | string) {
393 const videoId = typeof videoIdArg === 'string' 393 const videoId = typeof videoIdArg === 'string'
394 ? await server.videosCommand.getId({ uuid: videoIdArg }) 394 ? await server.videos.getId({ uuid: videoIdArg })
395 : videoIdArg 395 : videoIdArg
396 396
397 const { data } = await server.commentsCommand.listThreads({ videoId }) 397 const { data } = await server.comments.listThreads({ videoId })
398 398
399 return data[0] 399 return data[0]
400 } 400 }
@@ -402,11 +402,11 @@ describe('Test abuses', function () {
402 before(async function () { 402 before(async function () {
403 this.timeout(50000) 403 this.timeout(50000)
404 404
405 servers[0].video = await await servers[0].videosCommand.quickUpload({ name: 'server 1' }) 405 servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' })
406 servers[1].video = await await servers[1].videosCommand.quickUpload({ name: 'server 2' }) 406 servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' })
407 407
408 await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' }) 408 await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
409 await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' }) 409 await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' })
410 410
411 await waitJobs(servers) 411 await waitJobs(servers)
412 }) 412 })
@@ -414,7 +414,7 @@ describe('Test abuses', function () {
414 it('Should report abuse on a comment', async function () { 414 it('Should report abuse on a comment', async function () {
415 this.timeout(15000) 415 this.timeout(15000)
416 416
417 const comment = await getComment(servers[0], servers[0].video.id) 417 const comment = await getComment(servers[0], servers[0].store.video.id)
418 418
419 const reason = 'it is a bad comment' 419 const reason = 'it is a bad comment'
420 await commands[0].report({ commentId: comment.id, reason }) 420 await commands[0].report({ commentId: comment.id, reason })
@@ -424,7 +424,7 @@ describe('Test abuses', function () {
424 424
425 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () { 425 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () {
426 { 426 {
427 const comment = await getComment(servers[0], servers[0].video.id) 427 const comment = await getComment(servers[0], servers[0].store.video.id)
428 const body = await commands[0].getAdminList({ filter: 'comment' }) 428 const body = await commands[0].getAdminList({ filter: 'comment' })
429 429
430 expect(body.total).to.equal(1) 430 expect(body.total).to.equal(1)
@@ -442,8 +442,8 @@ describe('Test abuses', function () {
442 expect(abuse.comment.id).to.equal(comment.id) 442 expect(abuse.comment.id).to.equal(comment.id)
443 expect(abuse.comment.text).to.equal(comment.text) 443 expect(abuse.comment.text).to.equal(comment.text)
444 expect(abuse.comment.video.name).to.equal('server 1') 444 expect(abuse.comment.video.name).to.equal('server 1')
445 expect(abuse.comment.video.id).to.equal(servers[0].video.id) 445 expect(abuse.comment.video.id).to.equal(servers[0].store.video.id)
446 expect(abuse.comment.video.uuid).to.equal(servers[0].video.uuid) 446 expect(abuse.comment.video.uuid).to.equal(servers[0].store.video.uuid)
447 447
448 expect(abuse.countReportsForReporter).to.equal(5) 448 expect(abuse.countReportsForReporter).to.equal(5)
449 expect(abuse.countReportsForReportee).to.equal(5) 449 expect(abuse.countReportsForReportee).to.equal(5)
@@ -459,7 +459,7 @@ describe('Test abuses', function () {
459 it('Should report abuse on a remote comment', async function () { 459 it('Should report abuse on a remote comment', async function () {
460 this.timeout(10000) 460 this.timeout(10000)
461 461
462 const comment = await getComment(servers[0], servers[1].video.uuid) 462 const comment = await getComment(servers[0], servers[1].store.video.uuid)
463 463
464 const reason = 'it is a really bad comment' 464 const reason = 'it is a really bad comment'
465 await commands[0].report({ commentId: comment.id, reason }) 465 await commands[0].report({ commentId: comment.id, reason })
@@ -468,7 +468,7 @@ describe('Test abuses', function () {
468 }) 468 })
469 469
470 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () { 470 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () {
471 const commentServer2 = await getComment(servers[0], servers[1].video.id) 471 const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
472 472
473 { 473 {
474 const body = await commands[0].getAdminList({ filter: 'comment' }) 474 const body = await commands[0].getAdminList({ filter: 'comment' })
@@ -493,7 +493,7 @@ describe('Test abuses', function () {
493 expect(abuse2.comment.id).to.equal(commentServer2.id) 493 expect(abuse2.comment.id).to.equal(commentServer2.id)
494 expect(abuse2.comment.text).to.equal(commentServer2.text) 494 expect(abuse2.comment.text).to.equal(commentServer2.text)
495 expect(abuse2.comment.video.name).to.equal('server 2') 495 expect(abuse2.comment.video.name).to.equal('server 2')
496 expect(abuse2.comment.video.uuid).to.equal(servers[1].video.uuid) 496 expect(abuse2.comment.video.uuid).to.equal(servers[1].store.video.uuid)
497 497
498 expect(abuse2.state.id).to.equal(AbuseState.PENDING) 498 expect(abuse2.state.id).to.equal(AbuseState.PENDING)
499 expect(abuse2.state.label).to.equal('Pending') 499 expect(abuse2.state.label).to.equal('Pending')
@@ -527,9 +527,9 @@ describe('Test abuses', function () {
527 it('Should keep the comment abuse when deleting the comment', async function () { 527 it('Should keep the comment abuse when deleting the comment', async function () {
528 this.timeout(10000) 528 this.timeout(10000)
529 529
530 const commentServer2 = await getComment(servers[0], servers[1].video.id) 530 const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
531 531
532 await servers[0].commentsCommand.delete({ videoId: servers[1].video.uuid, commentId: commentServer2.id }) 532 await servers[0].comments.delete({ videoId: servers[1].store.video.uuid, commentId: commentServer2.id })
533 533
534 await waitJobs(servers) 534 await waitJobs(servers)
535 535
@@ -592,16 +592,16 @@ describe('Test abuses', function () {
592 describe('Account abuses', function () { 592 describe('Account abuses', function () {
593 593
594 function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) { 594 function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
595 return server.accountsCommand.get({ accountName: targetName + '@' + targetServer.host }) 595 return server.accounts.get({ accountName: targetName + '@' + targetServer.host })
596 } 596 }
597 597
598 before(async function () { 598 before(async function () {
599 this.timeout(50000) 599 this.timeout(50000)
600 600
601 await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' }) 601 await servers[0].users.create({ username: 'user_1', password: 'donald' })
602 602
603 const token = await servers[1].usersCommand.generateUserAndToken('user_2') 603 const token = await servers[1].users.generateUserAndToken('user_2')
604 await servers[1].videosCommand.upload({ token, attributes: { name: 'super video' } }) 604 await servers[1].videos.upload({ token, attributes: { name: 'super video' } })
605 605
606 await waitJobs(servers) 606 await waitJobs(servers)
607 }) 607 })
@@ -702,7 +702,7 @@ describe('Test abuses', function () {
702 this.timeout(10000) 702 this.timeout(10000)
703 703
704 const account = await getAccountFromServer(servers[1], 'user_2', servers[1]) 704 const account = await getAccountFromServer(servers[1], 'user_2', servers[1])
705 await servers[1].usersCommand.remove({ userId: account.userId }) 705 await servers[1].users.remove({ userId: account.userId })
706 706
707 await waitJobs(servers) 707 await waitJobs(servers)
708 708
@@ -759,11 +759,11 @@ describe('Test abuses', function () {
759 let userAccessToken: string 759 let userAccessToken: string
760 760
761 before(async function () { 761 before(async function () {
762 userAccessToken = await servers[0].usersCommand.generateUserAndToken('user_42') 762 userAccessToken = await servers[0].users.generateUserAndToken('user_42')
763 763
764 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' }) 764 await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: 'user reason 1' })
765 765
766 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid }) 766 const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
767 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' }) 767 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' })
768 }) 768 })
769 769
@@ -830,9 +830,9 @@ describe('Test abuses', function () {
830 let abuseMessageModerationId: number 830 let abuseMessageModerationId: number
831 831
832 before(async function () { 832 before(async function () {
833 userToken = await servers[0].usersCommand.generateUserAndToken('user_43') 833 userToken = await servers[0].users.generateUserAndToken('user_43')
834 834
835 const body = await commands[0].report({ token: userToken, videoId: servers[0].video.id, reason: 'user 43 reason 1' }) 835 const body = await commands[0].report({ token: userToken, videoId: servers[0].store.video.id, reason: 'user 43 reason 1' })
836 abuseId = body.abuse.id 836 abuseId = body.abuse.id
837 }) 837 })
838 838