aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/abuses.ts52
-rw-r--r--server/tests/api/moderation/abuses.ts19
2 files changed, 61 insertions, 10 deletions
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 5e1d66c25..0ef8f6cac 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -3,21 +3,26 @@
3import 'mocha' 3import 'mocha'
4import { AbuseCreate, AbuseState } from '@shared/models' 4import { AbuseCreate, AbuseState } from '@shared/models'
5import { 5import {
6 addAbuseMessage,
6 cleanupTests, 7 cleanupTests,
7 createUser, 8 createUser,
8 deleteAbuse, 9 deleteAbuse,
10 deleteAbuseMessage,
11 doubleFollow,
9 flushAndRunServer, 12 flushAndRunServer,
13 generateUserAccessToken,
14 getAdminAbusesList,
15 getVideoIdFromUUID,
16 listAbuseMessages,
10 makeGetRequest, 17 makeGetRequest,
11 makePostBodyRequest, 18 makePostBodyRequest,
19 reportAbuse,
12 ServerInfo, 20 ServerInfo,
13 setAccessTokensToServers, 21 setAccessTokensToServers,
14 updateAbuse, 22 updateAbuse,
15 uploadVideo, 23 uploadVideo,
16 userLogin, 24 userLogin,
17 generateUserAccessToken, 25 waitJobs
18 addAbuseMessage,
19 listAbuseMessages,
20 deleteAbuseMessage
21} from '../../../../shared/extra-utils' 26} from '../../../../shared/extra-utils'
22import { 27import {
23 checkBadCountPagination, 28 checkBadCountPagination,
@@ -29,6 +34,7 @@ describe('Test abuses API validators', function () {
29 const basePath = '/api/v1/abuses/' 34 const basePath = '/api/v1/abuses/'
30 35
31 let server: ServerInfo 36 let server: ServerInfo
37
32 let userAccessToken = '' 38 let userAccessToken = ''
33 let userAccessToken2 = '' 39 let userAccessToken2 = ''
34 let abuseId: number 40 let abuseId: number
@@ -321,7 +327,7 @@ describe('Test abuses API validators', function () {
321 }) 327 })
322 }) 328 })
323 329
324 describe('When listing abuse message', function () { 330 describe('When listing abuse messages', function () {
325 331
326 it('Should fail with an invalid abuse id', async function () { 332 it('Should fail with an invalid abuse id', async function () {
327 await listAbuseMessages(server.url, userAccessToken, 888, 404) 333 await listAbuseMessages(server.url, userAccessToken, 888, 404)
@@ -382,7 +388,43 @@ describe('Test abuses API validators', function () {
382 }) 388 })
383 }) 389 })
384 390
391 describe('When trying to manage messages of a remote abuse', function () {
392 let remoteAbuseId: number
393 let anotherServer: ServerInfo
394
395 before(async function () {
396 this.timeout(20000)
397
398 anotherServer = await flushAndRunServer(2)
399 await setAccessTokensToServers([ anotherServer ])
400
401 await doubleFollow(anotherServer, server)
402
403 const server2VideoId = await getVideoIdFromUUID(anotherServer.url, server.video.uuid)
404 await reportAbuse({
405 url: anotherServer.url,
406 token: anotherServer.accessToken,
407 reason: 'remote server',
408 videoId: server2VideoId
409 })
410
411 await waitJobs([ server, anotherServer ])
412
413 const res = await getAdminAbusesList({ url: server.url, token: server.accessToken, sort: '-createdAt' })
414 remoteAbuseId = res.body.data[0].id
415 })
416
417 it('Should fail when listing abuse messages of a remote abuse', async function () {
418 await listAbuseMessages(server.url, server.accessToken, remoteAbuseId, 400)
419 })
420
421 it('Should fail when creating abuse message of a remote abuse', async function () {
422 await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', 400)
423 })
424 })
425
385 after(async function () { 426 after(async function () {
386 await cleanupTests([ server ]) 427 await cleanupTests([ server ])
387 }) 428 })
388}) 429})
430
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index 601125fdf..fb765e7e3 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -2,12 +2,23 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { AbuseFilter, AbusePredefinedReasonsString, AbuseState, Account, AdminAbuse, UserAbuse, VideoComment, AbuseMessage } from '@shared/models'
6import { 5import {
6 AbuseFilter,
7 AbuseMessage,
8 AbusePredefinedReasonsString,
9 AbuseState,
10 Account,
11 AdminAbuse,
12 UserAbuse,
13 VideoComment
14} from '@shared/models'
15import {
16 addAbuseMessage,
7 addVideoCommentThread, 17 addVideoCommentThread,
8 cleanupTests, 18 cleanupTests,
9 createUser, 19 createUser,
10 deleteAbuse, 20 deleteAbuse,
21 deleteAbuseMessage,
11 deleteVideoComment, 22 deleteVideoComment,
12 flushAndRunMultipleServers, 23 flushAndRunMultipleServers,
13 generateUserAccessToken, 24 generateUserAccessToken,
@@ -18,6 +29,7 @@ import {
18 getVideoIdFromUUID, 29 getVideoIdFromUUID,
19 getVideosList, 30 getVideosList,
20 immutableAssign, 31 immutableAssign,
32 listAbuseMessages,
21 removeUser, 33 removeUser,
22 removeVideo, 34 removeVideo,
23 reportAbuse, 35 reportAbuse,
@@ -26,10 +38,7 @@ import {
26 updateAbuse, 38 updateAbuse,
27 uploadVideo, 39 uploadVideo,
28 uploadVideoAndGetId, 40 uploadVideoAndGetId,
29 userLogin, 41 userLogin
30 addAbuseMessage,
31 listAbuseMessages,
32 deleteAbuseMessage
33} from '../../../../shared/extra-utils/index' 42} from '../../../../shared/extra-utils/index'
34import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 43import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
35import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 44import { waitJobs } from '../../../../shared/extra-utils/server/jobs'