feat: sqlite driver for auth service (#572)

* wip: initial sqlite bootstrap

* wip: switch to sqlite3 as default db type

* wip: boilerplate data

* fix(auth): case sensitive register and login

* fix(auth): refactor username validations

* fix(auth): allow changing username to both username and email:

* fix(auth): lock middleware for recovery log in

* fix(domain-core): specs for invalid types

* fix(auth): lock middleware specs

* fix(auth): typeorm code arrangements

* fix: running e2e on both mysql and sqlite in ci
This commit is contained in:
Karol Sójko
2023-04-27 11:17:01 +02:00
committed by GitHub
parent 34018ae7eb
commit 3aef5998df
238 changed files with 526592 additions and 205 deletions
@@ -24,7 +24,7 @@ describe('GetUserKeyParams', () => {
user = {} as jest.Mocked<User>
userRepository = {} as jest.Mocked<UserRepositoryInterface>
userRepository.findOneByEmail = jest.fn().mockReturnValue(user)
userRepository.findOneByUsernameOrEmail = jest.fn().mockReturnValue(user)
userRepository.findOneByUuid = jest.fn().mockReturnValue(user)
logger = {} as jest.Mocked<Logger>
@@ -46,6 +46,12 @@ describe('GetUserKeyParams', () => {
expect(keyParamsFactory.create).toHaveBeenCalledWith(user, true)
})
it('should throw an error when searching by email and the email is invalid', async () => {
await expect(createUseCase().execute({ email: '', authenticated: false })).rejects.toThrowError(
'Username cannot be empty',
)
})
it('should get key params for an unauthenticated user - searching by email', async () => {
expect(await createUseCase().execute({ email: '[email protected]', authenticated: false })).toEqual({
keyParams: {
@@ -87,7 +93,7 @@ describe('GetUserKeyParams', () => {
})
it('should get pseudo key params for a non existing user - when searching by email', async () => {
userRepository.findOneByEmail = jest.fn().mockReturnValue(null)
userRepository.findOneByUsernameOrEmail = jest.fn().mockReturnValue(null)
expect(await createUseCase().execute({ email: '[email protected]', authenticated: false })).toEqual({
keyParams: {