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) {
489489}
490490
491491func 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 "}` )
493493 want := SASLInitialResponse {
494494 AuthMechanism : "SCRAM-SHA-256" ,
495- Data : []byte { 109 } ,
495+ Data : []byte ( "abc" ) ,
496496 }
497497
498498 var got SASLInitialResponse
@@ -505,8 +505,10 @@ func TestJSONUnmarshalSASLInitialResponse(t *testing.T) {
505505}
506506
507507func 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+ }
510512
511513 var got SASLResponse
512514 if err := json .Unmarshal (data , & got ); err != nil {
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package pgproto3
22
33import (
44 "bytes"
5- "encoding/hex"
65 "encoding/json"
76 "errors"
87
@@ -83,12 +82,6 @@ func (dst *SASLInitialResponse) UnmarshalJSON(data []byte) error {
8382 return err
8483 }
8584 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 )
9386 return nil
9487}
Original file line number Diff line number Diff line change 11package pgproto3
22
33import (
4- "encoding/hex"
54 "encoding/json"
65
76 "github.com/jackc/pgio"
@@ -50,12 +49,6 @@ func (dst *SASLResponse) UnmarshalJSON(data []byte) error {
5049 if err := json .Unmarshal (data , & msg ); err != nil {
5150 return err
5251 }
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 )
6053 return nil
6154}
You can’t perform that action at this time.
0 commit comments