1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Creating a user with an empty password will send an email to let him set his password (#2479)

* Creating a user with an empty password will send an email to let him set his password

* Consideration of Chocobozzz's comments

* Tips for optional password

* API documentation

* Fix circular imports

* Tests
This commit is contained in:
John Livingston 2020-02-17 10:16:52 +01:00 committed by GitHub
parent c5621bd23b
commit 45f1bd72a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 201 additions and 18 deletions

View file

@ -16,12 +16,14 @@ import {
getMyUserVideoRating,
getUsersList,
immutableAssign,
killallServers,
makeGetRequest,
makePostBodyRequest,
makePutBodyRequest,
makeUploadRequest,
registerUser,
removeUser,
reRunServer,
ServerInfo,
setAccessTokensToServers,
unblockUser,
@ -39,6 +41,7 @@ import { VideoPrivacy } from '../../../../shared/models/videos'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { expect } from 'chai'
import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
describe('Test users API validators', function () {
const path = '/api/v1/users/'
@ -50,6 +53,8 @@ describe('Test users API validators', function () {
let serverWithRegistrationDisabled: ServerInfo
let userAccessToken = ''
let moderatorAccessToken = ''
let emailPort: number
let overrideConfig: Object
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let channelId: number
@ -58,9 +63,14 @@ describe('Test users API validators', function () {
before(async function () {
this.timeout(30000)
const emails: object[] = []
emailPort = await MockSmtpServer.Instance.collectEmails(emails)
overrideConfig = { signup: { limit: 8 } }
{
const res = await Promise.all([
flushAndRunServer(1, { signup: { limit: 7 } }),
flushAndRunServer(1, overrideConfig),
flushAndRunServer(2)
])
@ -229,6 +239,40 @@ describe('Test users API validators', function () {
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
it('Should fail with empty password and no smtp configured', async function () {
const fields = immutableAssign(baseCorrectParams, { password: '' })
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
it('Should succeed with no password on a server with smtp enabled', async function () {
this.timeout(10000)
killallServers([ server ])
const config = immutableAssign(overrideConfig, {
smtp: {
hostname: 'localhost',
port: emailPort
}
})
await reRunServer(server, config)
const fields = immutableAssign(baseCorrectParams, {
password: '',
username: 'create_password',
email: 'create_password@example.com'
})
await makePostBodyRequest({
url: server.url,
path: path,
token: server.accessToken,
fields,
statusCodeExpected: 200
})
})
it('Should fail with invalid admin flags', async function () {
const fields = immutableAssign(baseCorrectParams, { adminFlags: 'toto' })
@ -1102,6 +1146,8 @@ describe('Test users API validators', function () {
})
after(async function () {
MockSmtpServer.Instance.kill()
await cleanupTests([ server, serverWithRegistrationDisabled ])
})
})