diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-01 11:08:10 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-01 11:08:29 +0100 |
commit | ba75d268596bc7b289bacf1cc4cb53493d6ad444 (patch) | |
tree | f631ed9a871ce078cd94afb0b4fcfc1e356944ec /server/tests | |
parent | 09c93c2031ce4d7dee15f247b194f21346c7e615 (diff) | |
download | PeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.tar.gz PeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.tar.zst PeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.zip |
Send an email on video abuse report
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/server/email.ts | 36 | ||||
-rw-r--r-- | server/tests/utils/videos/video-abuses.ts | 2 |
2 files changed, 34 insertions, 4 deletions
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 8eb9c0fa4..068e820c8 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { askResetPassword, createUser, resetPassword, runServer, userLogin, wait } from '../../utils' | 5 | import { askResetPassword, createUser, reportVideoAbuse, resetPassword, runServer, uploadVideo, userLogin, wait } from '../../utils' |
6 | import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' | 6 | import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' |
7 | import { mockSmtpServer } from '../../utils/miscs/email' | 7 | import { mockSmtpServer } from '../../utils/miscs/email' |
8 | 8 | ||
@@ -11,6 +11,7 @@ const expect = chai.expect | |||
11 | describe('Test emails', function () { | 11 | describe('Test emails', function () { |
12 | let server: ServerInfo | 12 | let server: ServerInfo |
13 | let userId: number | 13 | let userId: number |
14 | let videoUUID: string | ||
14 | let verificationString: string | 15 | let verificationString: string |
15 | const emails: object[] = [] | 16 | const emails: object[] = [] |
16 | const user = { | 17 | const user = { |
@@ -35,8 +36,18 @@ describe('Test emails', function () { | |||
35 | await wait(5000) | 36 | await wait(5000) |
36 | await setAccessTokensToServers([ server ]) | 37 | await setAccessTokensToServers([ server ]) |
37 | 38 | ||
38 | const res = await createUser(server.url, server.accessToken, user.username, user.password) | 39 | { |
39 | userId = res.body.user.id | 40 | const res = await createUser(server.url, server.accessToken, user.username, user.password) |
41 | userId = res.body.user.id | ||
42 | } | ||
43 | |||
44 | { | ||
45 | const attributes = { | ||
46 | name: 'my super name' | ||
47 | } | ||
48 | const res = await uploadVideo(server.url, server.accessToken, attributes) | ||
49 | videoUUID = res.body.video.uuid | ||
50 | } | ||
40 | }) | 51 | }) |
41 | 52 | ||
42 | describe('When resetting user password', function () { | 53 | describe('When resetting user password', function () { |
@@ -83,6 +94,25 @@ describe('Test emails', function () { | |||
83 | }) | 94 | }) |
84 | }) | 95 | }) |
85 | 96 | ||
97 | describe('When creating a video abuse', function () { | ||
98 | it('Should send the notification email', async function () { | ||
99 | this.timeout(10000) | ||
100 | |||
101 | const reason = 'my super bad reason' | ||
102 | await reportVideoAbuse(server.url, server.accessToken, videoUUID, reason) | ||
103 | |||
104 | await wait(3000) | ||
105 | expect(emails).to.have.lengthOf(2) | ||
106 | |||
107 | const email = emails[1] | ||
108 | |||
109 | expect(email['from'][0]['address']).equal('test-admin@localhost') | ||
110 | expect(email['to'][0]['address']).equal('admin1@example.com') | ||
111 | expect(email['subject']).contains('abuse') | ||
112 | expect(email['text']).contains(videoUUID) | ||
113 | }) | ||
114 | }) | ||
115 | |||
86 | after(async function () { | 116 | after(async function () { |
87 | killallServers([ server ]) | 117 | killallServers([ server ]) |
88 | 118 | ||
diff --git a/server/tests/utils/videos/video-abuses.ts b/server/tests/utils/videos/video-abuses.ts index f00809234..0d72bf457 100644 --- a/server/tests/utils/videos/video-abuses.ts +++ b/server/tests/utils/videos/video-abuses.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | 2 | ||
3 | function reportVideoAbuse (url: string, token: string, videoId: number, reason: string, specialStatus = 204) { | 3 | function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 204) { |
4 | const path = '/api/v1/videos/' + videoId + '/abuse' | 4 | const path = '/api/v1/videos/' + videoId + '/abuse' |
5 | 5 | ||
6 | return request(url) | 6 | return request(url) |