diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-27 11:40:30 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-31 11:35:19 +0200 |
commit | 94148c9028829b5576a5dcbfba2c7fb9cf6443d3 (patch) | |
tree | 2774f272329111abd03e8441ff936da11fb1a3f3 /server/tests/api/check-params | |
parent | 441e453ae53e491b09c9b09b00b041788176ce64 (diff) | |
download | PeerTube-94148c9028829b5576a5dcbfba2c7fb9cf6443d3.tar.gz PeerTube-94148c9028829b5576a5dcbfba2c7fb9cf6443d3.tar.zst PeerTube-94148c9028829b5576a5dcbfba2c7fb9cf6443d3.zip |
Add abuse messages management in my account
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/abuses.ts | 52 |
1 files changed, 47 insertions, 5 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 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { AbuseCreate, AbuseState } from '@shared/models' | 4 | import { AbuseCreate, AbuseState } from '@shared/models' |
5 | import { | 5 | import { |
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' |
22 | import { | 27 | import { |
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 | |||