forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saslhandshake_test.go
59 lines (52 loc) · 1.14 KB
/
saslhandshake_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package kafka
import (
"bufio"
"bytes"
"reflect"
"testing"
)
func TestSASLHandshakeRequestV0(t *testing.T) {
item := saslHandshakeRequestV0{
Mechanism: "SCRAM-SHA-512",
}
b := bytes.NewBuffer(nil)
w := &writeBuffer{w: b}
item.writeTo(w)
var found saslHandshakeRequestV0
remain, err := (&found).readFrom(bufio.NewReader(b), b.Len())
if err != nil {
t.Error(err)
t.FailNow()
}
if remain != 0 {
t.Errorf("expected 0 remain, got %v", remain)
t.FailNow()
}
if !reflect.DeepEqual(item, found) {
t.Error("expected item and found to be the same")
t.FailNow()
}
}
func TestSASLHandshakeResponseV0(t *testing.T) {
item := saslHandshakeResponseV0{
ErrorCode: 2,
EnabledMechanisms: []string{"PLAIN", "SCRAM-SHA-512"},
}
b := bytes.NewBuffer(nil)
w := &writeBuffer{w: b}
item.writeTo(w)
var found saslHandshakeResponseV0
remain, err := (&found).readFrom(bufio.NewReader(b), b.Len())
if err != nil {
t.Error(err)
t.FailNow()
}
if remain != 0 {
t.Errorf("expected 0 remain, got %v", remain)
t.FailNow()
}
if !reflect.DeepEqual(item, found) {
t.Error("expected item and found to be the same")
t.FailNow()
}
}