@@ -89,11 +89,12 @@ func TestAuthFastCachingSHA256PasswordCached(t *testing.T) {
89
89
plugin := "caching_sha2_password"
90
90
91
91
// Send Client Authentication Packet
92
- authResp , err := mc .auth (authData , plugin )
92
+ authResp , addNUL , err := mc .auth (authData , plugin )
93
93
if err != nil {
94
94
t .Fatal (err )
95
95
}
96
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
96
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
97
+ if err != nil {
97
98
t .Fatal (err )
98
99
}
99
100
@@ -133,11 +134,12 @@ func TestAuthFastCachingSHA256PasswordEmpty(t *testing.T) {
133
134
plugin := "caching_sha2_password"
134
135
135
136
// Send Client Authentication Packet
136
- authResp , err := mc .auth (authData , plugin )
137
+ authResp , addNUL , err := mc .auth (authData , plugin )
137
138
if err != nil {
138
139
t .Fatal (err )
139
140
}
140
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
141
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
142
+ if err != nil {
141
143
t .Fatal (err )
142
144
}
143
145
@@ -174,11 +176,12 @@ func TestAuthFastCachingSHA256PasswordFullRSA(t *testing.T) {
174
176
plugin := "caching_sha2_password"
175
177
176
178
// Send Client Authentication Packet
177
- authResp , err := mc .auth (authData , plugin )
179
+ authResp , addNUL , err := mc .auth (authData , plugin )
178
180
if err != nil {
179
181
t .Fatal (err )
180
182
}
181
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
183
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
184
+ if err != nil {
182
185
t .Fatal (err )
183
186
}
184
187
@@ -228,11 +231,12 @@ func TestAuthFastCachingSHA256PasswordFullSecure(t *testing.T) {
228
231
plugin := "caching_sha2_password"
229
232
230
233
// Send Client Authentication Packet
231
- authResp , err := mc .auth (authData , plugin )
234
+ authResp , addNUL , err := mc .auth (authData , plugin )
232
235
if err != nil {
233
236
t .Fatal (err )
234
237
}
235
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
238
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
239
+ if err != nil {
236
240
t .Fatal (err )
237
241
}
238
242
@@ -268,7 +272,7 @@ func TestAuthFastCachingSHA256PasswordFullSecure(t *testing.T) {
268
272
t .Errorf ("got error: %v" , err )
269
273
}
270
274
271
- if ! bytes .Equal (conn .written , []byte {6 , 0 , 0 , 3 , 115 , 101 , 99 , 114 , 101 , 116 }) {
275
+ if ! bytes .Equal (conn .written , []byte {7 , 0 , 0 , 3 , 115 , 101 , 99 , 114 , 101 , 116 , 0 }) {
272
276
t .Errorf ("unexpected written data: %v" , conn .written )
273
277
}
274
278
}
@@ -283,7 +287,7 @@ func TestAuthFastCleartextPasswordNotAllowed(t *testing.T) {
283
287
plugin := "mysql_clear_password"
284
288
285
289
// Send Client Authentication Packet
286
- _ , err := mc .auth (authData , plugin )
290
+ _ , _ , err := mc .auth (authData , plugin )
287
291
if err != ErrCleartextPassword {
288
292
t .Errorf ("expected ErrCleartextPassword, got %v" , err )
289
293
}
@@ -300,11 +304,12 @@ func TestAuthFastCleartextPassword(t *testing.T) {
300
304
plugin := "mysql_clear_password"
301
305
302
306
// Send Client Authentication Packet
303
- authResp , err := mc .auth (authData , plugin )
307
+ authResp , addNUL , err := mc .auth (authData , plugin )
304
308
if err != nil {
305
309
t .Fatal (err )
306
310
}
307
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
311
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
312
+ if err != nil {
308
313
t .Fatal (err )
309
314
}
310
315
@@ -342,11 +347,12 @@ func TestAuthFastCleartextPasswordEmpty(t *testing.T) {
342
347
plugin := "mysql_clear_password"
343
348
344
349
// Send Client Authentication Packet
345
- authResp , err := mc .auth (authData , plugin )
350
+ authResp , addNUL , err := mc .auth (authData , plugin )
346
351
if err != nil {
347
352
t .Fatal (err )
348
353
}
349
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
354
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
355
+ if err != nil {
350
356
t .Fatal (err )
351
357
}
352
358
@@ -384,7 +390,7 @@ func TestAuthFastNativePasswordNotAllowed(t *testing.T) {
384
390
plugin := "mysql_native_password"
385
391
386
392
// Send Client Authentication Packet
387
- _ , err := mc .auth (authData , plugin )
393
+ _ , _ , err := mc .auth (authData , plugin )
388
394
if err != ErrNativePassword {
389
395
t .Errorf ("expected ErrNativePassword, got %v" , err )
390
396
}
@@ -400,11 +406,12 @@ func TestAuthFastNativePassword(t *testing.T) {
400
406
plugin := "mysql_native_password"
401
407
402
408
// Send Client Authentication Packet
403
- authResp , err := mc .auth (authData , plugin )
409
+ authResp , addNUL , err := mc .auth (authData , plugin )
404
410
if err != nil {
405
411
t .Fatal (err )
406
412
}
407
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
413
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
414
+ if err != nil {
408
415
t .Fatal (err )
409
416
}
410
417
@@ -442,11 +449,12 @@ func TestAuthFastNativePasswordEmpty(t *testing.T) {
442
449
plugin := "mysql_native_password"
443
450
444
451
// Send Client Authentication Packet
445
- authResp , err := mc .auth (authData , plugin )
452
+ authResp , addNUL , err := mc .auth (authData , plugin )
446
453
if err != nil {
447
454
t .Fatal (err )
448
455
}
449
- if err = mc .writeHandshakeResponsePacket (authResp , plugin ); err != nil {
456
+ err = mc .writeHandshakeResponsePacket (authResp , addNUL , plugin )
457
+ if err != nil {
450
458
t .Fatal (err )
451
459
}
452
460
@@ -530,7 +538,7 @@ func TestAuthSwitchCachingSHA256PasswordEmpty(t *testing.T) {
530
538
t .Errorf ("got error: %v" , err )
531
539
}
532
540
533
- expectedReply := []byte {0 , 0 , 0 , 3 }
541
+ expectedReply := []byte {1 , 0 , 0 , 3 , 0 }
534
542
if ! bytes .Equal (conn .written , expectedReply ) {
535
543
t .Errorf ("got unexpected data: %v" , conn .written )
536
544
}
@@ -619,7 +627,7 @@ func TestAuthSwitchCachingSHA256PasswordFullSecure(t *testing.T) {
619
627
153 , 9 , 130 ,
620
628
621
629
// 2. Packet: Cleartext password
622
- 6 , 0 , 0 , 5 , 115 , 101 , 99 , 114 , 101 , 116 ,
630
+ 7 , 0 , 0 , 5 , 115 , 101 , 99 , 114 , 101 , 116 , 0 ,
623
631
}
624
632
if ! bytes .Equal (conn .written , expectedReply ) {
625
633
t .Errorf ("got unexpected data: %v" , conn .written )
@@ -662,7 +670,7 @@ func TestAuthSwitchCleartextPassword(t *testing.T) {
662
670
t .Errorf ("got error: %v" , err )
663
671
}
664
672
665
- expectedReply := []byte {6 , 0 , 0 , 3 , 115 , 101 , 99 , 114 , 101 , 116 }
673
+ expectedReply := []byte {7 , 0 , 0 , 3 , 115 , 101 , 99 , 114 , 101 , 116 , 0 }
666
674
if ! bytes .Equal (conn .written , expectedReply ) {
667
675
t .Errorf ("got unexpected data: %v" , conn .written )
668
676
}
@@ -689,7 +697,7 @@ func TestAuthSwitchCleartextPasswordEmpty(t *testing.T) {
689
697
t .Errorf ("got error: %v" , err )
690
698
}
691
699
692
- expectedReply := []byte {0 , 0 , 0 , 3 }
700
+ expectedReply := []byte {1 , 0 , 0 , 3 , 0 }
693
701
if ! bytes .Equal (conn .written , expectedReply ) {
694
702
t .Errorf ("got unexpected data: %v" , conn .written )
695
703
}
@@ -766,7 +774,7 @@ func TestAuthSwitchNativePasswordEmpty(t *testing.T) {
766
774
t .Errorf ("got error: %v" , err )
767
775
}
768
776
769
- expectedReply := []byte {0 , 0 , 0 , 3 }
777
+ expectedReply := []byte {1 , 0 , 0 , 3 , 0 }
770
778
if ! bytes .Equal (conn .written , expectedReply ) {
771
779
t .Errorf ("got unexpected data: %v" , conn .written )
772
780
}
@@ -810,7 +818,7 @@ func TestAuthSwitchOldPassword(t *testing.T) {
810
818
t .Errorf ("got error: %v" , err )
811
819
}
812
820
813
- expectedReply := []byte {8 , 0 , 0 , 3 , 86 , 83 , 83 , 79 , 74 , 78 , 65 , 66 }
821
+ expectedReply := []byte {9 , 0 , 0 , 3 , 86 , 83 , 83 , 79 , 74 , 78 , 65 , 66 , 0 }
814
822
if ! bytes .Equal (conn .written , expectedReply ) {
815
823
t .Errorf ("got unexpected data: %v" , conn .written )
816
824
}
@@ -838,7 +846,7 @@ func TestAuthSwitchOldPasswordEmpty(t *testing.T) {
838
846
t .Errorf ("got error: %v" , err )
839
847
}
840
848
841
- expectedReply := []byte {0 , 0 , 0 , 3 }
849
+ expectedReply := []byte {1 , 0 , 0 , 3 , 0 }
842
850
if ! bytes .Equal (conn .written , expectedReply ) {
843
851
t .Errorf ("got unexpected data: %v" , conn .written )
844
852
}
0 commit comments