Skip to content

Commit

Permalink
Allow empty passwords
Browse files Browse the repository at this point in the history
Empty passwords are allowed for UNIX socket connections and when using
TLS auth.

Fixes: #686

Signed-off-by: SuperQ <superq@gmail.com>
  • Loading branch information
SuperQ committed Jun 15, 2023
1 parent 7667e7f commit d867de4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 0 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ func (m MySqlConfig) validateConfig() error {
if m.User == "" {
return fmt.Errorf("no user specified in section or parent")
}
if m.Password == "" {
return fmt.Errorf("no password specified in section or parent")
}

return nil
}
Expand Down
14 changes: 8 additions & 6 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ func TestValidateConfig(t *testing.T) {
Config: &Config{},
}
os.Clearenv()
err := c.ReloadConfig("testdata/missing_password.cnf", "localhost:3306", "", true, log.NewNopLogger())
convey.So(
err,
convey.ShouldResemble,
fmt.Errorf("no configuration found"),
)
if err := c.ReloadConfig("testdata/missing_password.cnf", "localhost:3306", "", true, log.NewNopLogger()); err != nil {
t.Error(err)
}

cfg := c.GetConfig()
section := cfg.Sections["client"]
convey.So(section.User, convey.ShouldEqual, "abc")
convey.So(section.Password, convey.ShouldEqual, "")
})
}

Expand Down

0 comments on commit d867de4

Please sign in to comment.