Skip to content

Commit

Permalink
Update TestSASLResponses()
Browse files Browse the repository at this point in the history
  • Loading branch information
cybergarage committed Sep 2, 2024
1 parent 3b9aeef commit 01c3769
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions mongotest/server_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,18 @@ import (
"github.com/cybergarage/go-mongo/mongo/sasl"
)

type sasleResponse struct {
ConversationID int `bson:"conversationId"`
Code int `bson:"code"`
Done bool `bson:"done"`
Payload []byte `bson:"payload"`
}

func TestSASLResponses(t *testing.T) {
t.Run("first", func(t *testing.T) {
tests := []struct {
mech string
c1 string
s1 string
c2 string
}{
{
"SCRAM-SHA-256",
"n,,n=test,r=Tle5kok6ColhgwXvl72Syw9whtQXCV3K",
// Tle5kok6ColhgwXvl72Syw9whtQXCV3KCNh9jrFMXbvK21UV,s=YlBCelc3V2xPR0hpN21Rag==,i=4096"
"r=Tle5kok6ColhgwXvl72Syw9whtQXCV3KCNh9jrFMXbvK21UV,s=YlBCelc3V2xPR0hpN21Rag==,i=4096",
"c=biws,r=Tle5kok6ColhgwXvl72Syw9whtQXCV3KCNh9jrFMXbvK21UV,p=4txwzovBCq0pFM4J3OA2iG9WBw+ClylRRRqcRwZSEiQ=",
},
}
Expand Down Expand Up @@ -66,7 +60,18 @@ func TestSASLResponses(t *testing.T) {
return
}

_, err = ctx.Next(sasl.SASLPayload(test.c1))
f1, err := ctx.Next(sasl.SASLPayload(test.c1))
if err != nil {
t.Error(err)
return
}

if f1.String() != test.s1 {
t.Errorf("Unexpected response : %s != %s", f1.String(), test.s1)
return
}

_, err = ctx.Next(sasl.SASLPayload(test.c2))
if err != nil {
t.Error(err)
return
Expand Down

0 comments on commit 01c3769

Please sign in to comment.