Authn: Prevent empty username and email during sync (#76330)
* Move errors to error file * Move check for both empty username and email to user service * Move check for empty email and username to user service Update * Wrap inner error * Set username in test
This commit is contained in:
@@ -38,6 +38,16 @@ func TestUserService(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("create user should fail when username and email are empty", func(t *testing.T) {
|
||||
_, err := userService.Create(context.Background(), &user.CreateUserCommand{
|
||||
Email: "",
|
||||
Login: "",
|
||||
Name: "name",
|
||||
})
|
||||
|
||||
require.ErrorIs(t, err, user.ErrEmptyUsernameAndEmail)
|
||||
})
|
||||
|
||||
t.Run("get user by ID", func(t *testing.T) {
|
||||
userService.cfg = setting.NewCfg()
|
||||
userService.cfg.CaseInsensitiveLogin = false
|
||||
@@ -88,6 +98,16 @@ func TestUserService(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("update user should fail with empty username and password", func(t *testing.T) {
|
||||
err := userService.Update(context.Background(), &user.UpdateUserCommand{
|
||||
Email: "",
|
||||
Login: "",
|
||||
Name: "name",
|
||||
})
|
||||
|
||||
require.ErrorIs(t, err, user.ErrEmptyUsernameAndEmail)
|
||||
})
|
||||
|
||||
t.Run("GetByID - email conflict", func(t *testing.T) {
|
||||
userService.cfg.CaseInsensitiveLogin = true
|
||||
userStore.ExpectedError = errors.New("email conflict")
|
||||
|
||||
Reference in New Issue
Block a user