(t *testing.T)
| 489 | } |
| 490 | |
| 491 | func TestAuthFastNativePasswordEmpty(t *testing.T) { |
| 492 | conn, mc := newRWMockConn(1) |
| 493 | mc.cfg.User = "root" |
| 494 | mc.cfg.Passwd = "" |
| 495 | |
| 496 | authData := []byte{70, 114, 92, 94, 1, 38, 11, 116, 63, 114, 23, 101, 126, |
| 497 | 103, 26, 95, 81, 17, 24, 21} |
| 498 | plugin := "mysql_native_password" |
| 499 | |
| 500 | // Send Client Authentication Packet |
| 501 | authResp, err := mc.auth(authData, plugin) |
| 502 | if err != nil { |
| 503 | t.Fatal(err) |
| 504 | } |
| 505 | err = mc.writeHandshakeResponsePacket(authResp, plugin) |
| 506 | if err != nil { |
| 507 | t.Fatal(err) |
| 508 | } |
| 509 | |
| 510 | // check written auth response |
| 511 | authRespStart := 4 + 4 + 4 + 1 + 23 + len(mc.cfg.User) + 1 |
| 512 | authRespEnd := authRespStart + 1 + len(authResp) |
| 513 | writtenAuthRespLen := conn.written[authRespStart] |
| 514 | writtenAuthResp := conn.written[authRespStart+1 : authRespEnd] |
| 515 | if writtenAuthRespLen != 0 { |
| 516 | t.Fatalf("unexpected written auth response (%d bytes): %v", |
| 517 | writtenAuthRespLen, writtenAuthResp) |
| 518 | } |
| 519 | conn.written = nil |
| 520 | |
| 521 | // auth response |
| 522 | conn.data = []byte{ |
| 523 | 7, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, // OK |
| 524 | } |
| 525 | conn.maxReads = 1 |
| 526 | |
| 527 | // Handle response to auth packet |
| 528 | if err := mc.handleAuthResult(authData, plugin); err != nil { |
| 529 | t.Errorf("got error: %v", err) |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | func TestAuthFastSHA256PasswordEmpty(t *testing.T) { |
| 534 | conn, mc := newRWMockConn(1) |
nothing calls this directly
no test coverage detected