/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
import 'mocha'
+import * as chai from 'chai'
import {
addVideoToBlacklist,
askResetPassword,
createUser,
flushAndRunServer,
removeVideoFromBlacklist,
- reportVideoAbuse,
+ reportAbuse,
resetPassword,
ServerInfo,
setAccessTokensToServers,
} from '../../../../shared/extra-utils'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
let userId: number
let userId2: number
let userAccessToken: string
+
let videoUUID: string
+ let videoId: number
+
let videoUserUUID: string
+
let verificationString: string
let verificationString2: string
+
const emails: object[] = []
const user = {
username: 'user_1',
}
const res = await uploadVideo(server.url, server.accessToken, attributes)
videoUUID = res.body.video.uuid
+ videoId = res.body.video.id
}
})
})
it('Should not reset the password with an invalid verification string', async function () {
- await resetPassword(server.url, userId, verificationString + 'b', 'super_password2', 403)
+ await resetPassword(server.url, userId, verificationString + 'b', 'super_password2', HttpStatusCode.FORBIDDEN_403)
})
it('Should reset the password', async function () {
await resetPassword(server.url, userId, verificationString, 'super_password2')
})
+ it('Should not reset the password with the same verification string', async function () {
+ await resetPassword(server.url, userId, verificationString, 'super_password3', HttpStatusCode.FORBIDDEN_403)
+ })
+
it('Should login with this new password', async function () {
user.password = 'super_password2'
})
it('Should not reset the password with an invalid verification string', async function () {
- await resetPassword(server.url, userId2, verificationString2 + 'c', 'newly_created_password', 403)
+ await resetPassword(server.url, userId2, verificationString2 + 'c', 'newly_created_password', HttpStatusCode.FORBIDDEN_403)
})
it('Should reset the password', async function () {
})
})
- describe('When creating a video abuse', function () {
+ describe('When creating an abuse', function () {
it('Should send the notification email', async function () {
this.timeout(10000)
const reason = 'my super bad reason'
- await reportVideoAbuse(server.url, server.accessToken, videoUUID, reason)
+ await reportAbuse({ url: server.url, token: server.accessToken, videoId, reason })
await waitJobs(server)
expect(emails).to.have.lengthOf(3)
this.timeout(10000)
const reason = 'my super bad reason'
- await blockUser(server.url, userId, server.accessToken, 204, reason)
+ await blockUser(server.url, userId, server.accessToken, HttpStatusCode.NO_CONTENT_204, reason)
await waitJobs(server)
expect(emails).to.have.lengthOf(4)
it('Should send the notification email when unblocking a user', async function () {
this.timeout(10000)
- await unblockUser(server.url, userId, server.accessToken, 204)
+ await unblockUser(server.url, userId, server.accessToken, HttpStatusCode.NO_CONTENT_204)
await waitJobs(server)
expect(emails).to.have.lengthOf(5)
expect(email['subject']).contains(' unblacklisted')
expect(email['text']).contains('my super user video')
})
+
+ it('Should have the manage preferences link in the email', async function () {
+ const email = emails[6]
+ expect(email['text']).to.contain('Manage your notification preferences')
+ })
})
describe('When verifying a user email', function () {
})
it('Should not verify the email with an invalid verification string', async function () {
- await verifyEmail(server.url, userId, verificationString + 'b', false, 403)
+ await verifyEmail(server.url, userId, verificationString + 'b', false, HttpStatusCode.FORBIDDEN_403)
})
it('Should verify the email', async function () {