Skip to content

Commit 1540102

Browse files
committed
add empty password test
1 parent 4bcaa02 commit 1540102

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

driver_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -2046,3 +2046,30 @@ func TestPing(t *testing.T) {
20462046
}
20472047
})
20482048
}
2049+
2050+
// See Issue #799
2051+
func TestEmptyPassword(t *testing.T) {
2052+
if !available {
2053+
t.Skipf("MySQL server not running on %s", netAddr)
2054+
}
2055+
2056+
dsn := fmt.Sprintf("%s:%s@%s/%s?timeout=30s", user, "", netAddr, dbname)
2057+
db, err := sql.Open("mysql", dsn)
2058+
if err == nil {
2059+
defer db.Close()
2060+
err = db.Ping()
2061+
}
2062+
2063+
if pass == "" {
2064+
if err != nil {
2065+
t.Fatal(err.Error())
2066+
}
2067+
} else {
2068+
if err == nil {
2069+
t.Fatal("expected authentication error")
2070+
}
2071+
if !strings.HasPrefix(err.Error(), "Error 1045") {
2072+
t.Fatal(err.Error())
2073+
}
2074+
}
2075+
}

0 commit comments

Comments
 (0)