(t *testing.T)
| 386 | } |
| 387 | |
| 388 | func TestAuthFastCleartextPasswordEmpty(t *testing.T) { |
| 389 | conn, mc := newRWMockConn(1) |
| 390 | mc.cfg.User = "root" |
| 391 | mc.cfg.Passwd = "" |
| 392 | mc.cfg.AllowCleartextPasswords = true |
| 393 | |
| 394 | authData := []byte{70, 114, 92, 94, 1, 38, 11, 116, 63, 114, 23, 101, 126, |
| 395 | 103, 26, 95, 81, 17, 24, 21} |
| 396 | plugin := "mysql_clear_password" |
| 397 | |
| 398 | // Send Client Authentication Packet |
| 399 | authResp, err := mc.auth(authData, plugin) |
| 400 | if err != nil { |
| 401 | t.Fatal(err) |
| 402 | } |
| 403 | err = mc.writeHandshakeResponsePacket(authResp, plugin) |
| 404 | if err != nil { |
| 405 | t.Fatal(err) |
| 406 | } |
| 407 | |
| 408 | // check written auth response |
| 409 | authRespStart := 4 + 4 + 4 + 1 + 23 + len(mc.cfg.User) + 1 |
| 410 | authRespEnd := authRespStart + 1 + len(authResp) |
| 411 | writtenAuthRespLen := conn.written[authRespStart] |
| 412 | writtenAuthResp := conn.written[authRespStart+1 : authRespEnd] |
| 413 | expectedAuthResp := []byte{0} |
| 414 | if writtenAuthRespLen != 1 || !bytes.Equal(writtenAuthResp, expectedAuthResp) { |
| 415 | t.Fatalf("unexpected written auth response (%d bytes): %v", writtenAuthRespLen, writtenAuthResp) |
| 416 | } |
| 417 | conn.written = nil |
| 418 | |
| 419 | // auth response |
| 420 | conn.data = []byte{ |
| 421 | 7, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, // OK |
| 422 | } |
| 423 | conn.maxReads = 1 |
| 424 | |
| 425 | // Handle response to auth packet |
| 426 | if err := mc.handleAuthResult(authData, plugin); err != nil { |
| 427 | t.Errorf("got error: %v", err) |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | func TestAuthFastNativePasswordNotAllowed(t *testing.T) { |
| 432 | _, mc := newRWMockConn(1) |
nothing calls this directly
no test coverage detected