mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
enhancement(auth): better error message handling
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
ca9836d691
commit
408d82e280
1 changed files with 10 additions and 6 deletions
|
@ -25,7 +25,7 @@ describe('Auth', () => {
|
||||||
let displayName: string;
|
let displayName: string;
|
||||||
let password: string;
|
let password: string;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeAll(async () => {
|
||||||
testSetup = await TestSetupBuilder.create().build();
|
testSetup = await TestSetupBuilder.create().build();
|
||||||
await testSetup.app.init();
|
await testSetup.app.init();
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ describe('Auth', () => {
|
||||||
password = 'test_password';
|
password = 'test_password';
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterAll(async () => {
|
||||||
// Yes, this is a bad hack, but there is a race somewhere and I have
|
// Yes, this is a bad hack, but there is a race somewhere and I have
|
||||||
// no idea how to fix it.
|
// no idea how to fix it.
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
|
@ -70,18 +70,22 @@ describe('Auth', () => {
|
||||||
});
|
});
|
||||||
describe('fails', () => {
|
describe('fails', () => {
|
||||||
it('when the user already exits', async () => {
|
it('when the user already exits', async () => {
|
||||||
const username2 = 'already_existing';
|
const conflictingUserName = 'already_existing';
|
||||||
await testSetup.userService.createUser(username2, displayName);
|
const conflictingUser = await testSetup.userService.createUser(
|
||||||
|
conflictingUserName,
|
||||||
|
displayName,
|
||||||
|
);
|
||||||
const registrationDto: RegisterDto = {
|
const registrationDto: RegisterDto = {
|
||||||
displayName: displayName,
|
displayName: displayName,
|
||||||
password: password,
|
password: password,
|
||||||
username: username2,
|
username: conflictingUserName,
|
||||||
};
|
};
|
||||||
await request(testSetup.app.getHttpServer())
|
await request(testSetup.app.getHttpServer())
|
||||||
.post('/api/private/auth/local')
|
.post('/api/private/auth/local')
|
||||||
.set('Content-Type', 'application/json')
|
.set('Content-Type', 'application/json')
|
||||||
.send(JSON.stringify(registrationDto))
|
.send(JSON.stringify(registrationDto))
|
||||||
.expect(409);
|
.expect(409);
|
||||||
|
await testSetup.userService.deleteUser(conflictingUser);
|
||||||
});
|
});
|
||||||
it('when registration is disabled', async () => {
|
it('when registration is disabled', async () => {
|
||||||
testSetup.configService.get('authConfig').local.enableRegister = false;
|
testSetup.configService.get('authConfig').local.enableRegister = false;
|
||||||
|
@ -98,7 +102,7 @@ describe('Auth', () => {
|
||||||
testSetup.configService.get('authConfig').local.enableRegister = true;
|
testSetup.configService.get('authConfig').local.enableRegister = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('correctly deletes a user if the PasswordTooWeakError is encountered', async () => {
|
it('does not create a user if the PasswordTooWeakError is encountered', async () => {
|
||||||
const registrationDto: RegisterDto = {
|
const registrationDto: RegisterDto = {
|
||||||
displayName: displayName,
|
displayName: displayName,
|
||||||
password: 'test1234',
|
password: 'test1234',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue