chore(auth): #331 add tests for sign in

This commit is contained in:
2024-12-23 22:26:46 +01:00
parent 7a9d34d464
commit 96b4cc6889
5 changed files with 202 additions and 12 deletions

View File

@@ -47,7 +47,7 @@ func TestSignIn(t *testing.T) {
underTest := NewAuthImpl(mockAuthDb, mockRandom, mockClock, mockMail, &types.Settings{})
actualSession, actualUser, err := underTest.SignIn(user.Email, "password")
actualSession, actualUser, err := underTest.SignIn(nil, user.Email, "password")
assert.Nil(t, err)
assert.Equal(t, session, actualSession)
@@ -78,7 +78,7 @@ func TestSignIn(t *testing.T) {
underTest := NewAuthImpl(mockAuthDb, mockRandom, mockClock, mockMail, &types.Settings{})
_, _, err := underTest.SignIn("test@test.de", "wrong password")
_, _, err := underTest.SignIn(nil, "test@test.de", "wrong password")
assert.Equal(t, ErrInvalidCredentials, err)
})
@@ -93,7 +93,7 @@ func TestSignIn(t *testing.T) {
underTest := NewAuthImpl(mockAuthDb, mockRandom, mockClock, mockMail, &types.Settings{})
_, _, err := underTest.SignIn("test", "test")
_, _, err := underTest.SignIn(nil, "test", "test")
assert.Equal(t, ErrInvalidCredentials, err)
})
t.Run("should forward ErrInternal on any other error", func(t *testing.T) {
@@ -107,7 +107,7 @@ func TestSignIn(t *testing.T) {
underTest := NewAuthImpl(mockAuthDb, mockRandom, mockClock, mockMail, &types.Settings{})
_, _, err := underTest.SignIn("test", "test")
_, _, err := underTest.SignIn(nil, "test", "test")
assert.Equal(t, types.ErrInternal, err)
})