mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 18:55:19 -04:00
refactor: Remove randomString function
This was done because it was only a wrapper for a nodejs function to check if the given parameter is a positive number. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
69a2a24511
commit
875e848b80
2 changed files with 5 additions and 17 deletions
|
@ -17,6 +17,7 @@ import { NotInDBError, TokenNotValidError } from '../errors/errors';
|
|||
import { Repository } from 'typeorm';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import appConfigMock from '../config/mock/app.config.mock';
|
||||
import { randomBytes } from 'crypto';
|
||||
|
||||
describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
@ -79,7 +80,7 @@ describe('AuthService', () => {
|
|||
.then((result) => expect(result).toBeTruthy());
|
||||
});
|
||||
it('fails, if secret is too short', async () => {
|
||||
const secret = service.bufferToBase64Url(service.randomString(54));
|
||||
const secret = service.bufferToBase64Url(randomBytes(54));
|
||||
const hash = await service.hashPassword(secret);
|
||||
await service
|
||||
.checkPassword(secret, hash)
|
||||
|
@ -328,10 +329,4 @@ describe('AuthService', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
describe('randomString', () => {
|
||||
it('throws on invalid lenght parameter', () => {
|
||||
expect(() => service.randomString(0)).toThrow();
|
||||
expect(() => service.randomString(-1)).toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue