Skip to content

Commit 66f8d59

Browse files
committed
auth: add empty old_password test
1 parent fa931ce commit 66f8d59

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

auth_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,31 @@ func TestAuthSwitchOldPassword(t *testing.T) {
9494
t.Errorf("got unexpected data: %v", conn.written)
9595
}
9696
}
97+
98+
func TestAuthSwitchOldPasswordEmpty(t *testing.T) {
99+
conn, mc := newRWMockConn(2)
100+
mc.cfg.AllowOldPasswords = true
101+
mc.cfg.Passwd = ""
102+
103+
// auth switch request
104+
conn.data = []byte{41, 0, 0, 2, 254, 109, 121, 115, 113, 108, 95, 111, 108,
105+
100, 95, 112, 97, 115, 115, 119, 111, 114, 100, 0, 95, 84, 103, 43, 61,
106+
49, 123, 61, 91, 50, 40, 113, 35, 84, 96, 101, 92, 123, 121, 107, 0}
107+
108+
// auth response
109+
conn.queuedReplies = [][]byte{{8, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0}}
110+
conn.maxReads = 2
111+
112+
authData := []byte{95, 84, 103, 43, 61, 49, 123, 61, 91, 50, 40, 113, 35,
113+
84, 96, 101, 92, 123, 121, 107}
114+
plugin := "mysql_native_password"
115+
116+
if err := mc.handleAuthResult(authData, plugin); err != nil {
117+
t.Errorf("got error: %v", err)
118+
}
119+
120+
expectedReply := []byte{0, 0, 0, 3}
121+
if !bytes.Equal(conn.written, expectedReply) {
122+
t.Errorf("got unexpected data: %v", conn.written)
123+
}
124+
}

driver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func maybeSkip(t *testing.T, err error, skipErrno uint16) {
189189
}
190190

191191
func TestEmptyQuery(t *testing.T) {
192-
runTests(t, dsn, func(dbt *DBTest) {
192+
runTests(t, dsn+"&allowOldPasswords=1", func(dbt *DBTest) {
193193
// just a comment, no query
194194
rows := dbt.mustQuery("--")
195195
// will hang before #255

0 commit comments

Comments
 (0)