-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsession_setup_response_test.go
55 lines (51 loc) · 1.81 KB
/
session_setup_response_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
package simba
import (
"encoding/hex"
"testing"
)
func TestSessionSetupResponse(t *testing.T) {
cases := []struct {
name string
input []byte
expected map[string]interface{}
}{
{
name: "test",
input: func() []byte {
r, _ := hex.DecodeString("0900000000000000")
return r
}(),
expected: map[string]interface{}{
"StructureSize": 0x09,
"SessionFlags": 0,
"SecurityBufferOffset": 0x0,
"SecurityBufferLength": 0,
"Buffer": "",
},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
ssr := SessionSetupResponse(c.input)
if ssr.IsInvalid() {
t.Errorf("SessionSetupRequest.IsInvalid() = true, want false")
}
if ssr.StructureSize() != uint16(c.expected["StructureSize"].(int)) {
t.Errorf("SessionSetupRequest.StructureSize() = %v, want %v", ssr.StructureSize(), c.expected["StructureSize"])
}
if ssr.SessionFlags() != SessionSetupSessionFlags(c.expected["SessionFlags"].(int)) {
t.Errorf("SessionSetupRequest.SessionFlags() = %v, want %v", ssr.SessionFlags(), c.expected["SessionFlags"])
}
if ssr.SecurityBufferOffset() != uint16(c.expected["SecurityBufferOffset"].(int)) {
t.Errorf("SessionSetupRequest.SecurityBufferOffset() = %v, want %v", ssr.SecurityBufferOffset(), c.expected["SecurityBufferOffset"])
}
if ssr.SecurityBufferLength() != uint16(c.expected["SecurityBufferLength"].(int)) {
t.Errorf("SessionSetupRequest.SecurityBufferLength() = %v, want %v", ssr.SecurityBufferLength(), c.expected["SecurityBufferLength"])
}
if hex.EncodeToString(ssr.Buffer()) != c.expected["Buffer"].(string) {
t.Errorf("SessionSetupRequest.Buffer() = %v, want %v", hex.EncodeToString(ssr.Buffer()), c.expected["Buffer"])
}
// TODO
})
}
}