This repository was archived by the owner on Jul 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +8
-20
lines changed Expand file tree Collapse file tree 3 files changed +8
-20
lines changed Original file line number Diff line number Diff line change @@ -489,10 +489,10 @@ func TestJSONUnmarshalQuery(t *testing.T) {
489
489
}
490
490
491
491
func TestJSONUnmarshalSASLInitialResponse (t * testing.T ) {
492
- data := []byte (`{"Type":"SASLInitialResponse", "AuthMechanism":"SCRAM-SHA-256", "Data": "6D "}` )
492
+ data := []byte (`{"Type":"SASLInitialResponse", "AuthMechanism":"SCRAM-SHA-256", "Data": "abc "}` )
493
493
want := SASLInitialResponse {
494
494
AuthMechanism : "SCRAM-SHA-256" ,
495
- Data : []byte { 109 } ,
495
+ Data : []byte ( "abc" ) ,
496
496
}
497
497
498
498
var got SASLInitialResponse
@@ -505,8 +505,10 @@ func TestJSONUnmarshalSASLInitialResponse(t *testing.T) {
505
505
}
506
506
507
507
func TestJSONUnmarshalSASLResponse (t * testing.T ) {
508
- data := []byte (`{"Type":"SASLResponse","Message":"abc"}` )
509
- want := SASLResponse {}
508
+ data := []byte (`{"Type":"SASLResponse","Data":"abc"}` )
509
+ want := SASLResponse {
510
+ Data : []byte ("abc" ),
511
+ }
510
512
511
513
var got SASLResponse
512
514
if err := json .Unmarshal (data , & got ); err != nil {
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package pgproto3
2
2
3
3
import (
4
4
"bytes"
5
- "encoding/hex"
6
5
"encoding/json"
7
6
"errors"
8
7
@@ -83,12 +82,6 @@ func (dst *SASLInitialResponse) UnmarshalJSON(data []byte) error {
83
82
return err
84
83
}
85
84
dst .AuthMechanism = msg .AuthMechanism
86
- if msg .Data != "" {
87
- decoded , err := hex .DecodeString (msg .Data )
88
- if err != nil {
89
- return err
90
- }
91
- dst .Data = decoded
92
- }
85
+ dst .Data = []byte (msg .Data )
93
86
return nil
94
87
}
Original file line number Diff line number Diff line change 1
1
package pgproto3
2
2
3
3
import (
4
- "encoding/hex"
5
4
"encoding/json"
6
5
7
6
"github.com/jackc/pgio"
@@ -50,12 +49,6 @@ func (dst *SASLResponse) UnmarshalJSON(data []byte) error {
50
49
if err := json .Unmarshal (data , & msg ); err != nil {
51
50
return err
52
51
}
53
- if msg .Data != "" {
54
- decoded , err := hex .DecodeString (msg .Data )
55
- if err != nil {
56
- return err
57
- }
58
- dst .Data = decoded
59
- }
52
+ dst .Data = []byte (msg .Data )
60
53
return nil
61
54
}
You can’t perform that action at this time.
0 commit comments