-
Notifications
You must be signed in to change notification settings - Fork 18
/
create_acls_request_test.go
63 lines (55 loc) · 1.41 KB
/
create_acls_request_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
60
61
62
63
package healer
import (
"testing"
"github.com/smartystreets/goconvey/convey"
)
func TestAclCreationLengthEncodeDecode(t *testing.T) {
convey.Convey("Test AclCreation encode and decode", t, func() {
var version uint16 = 0
var clientID string = "healer"
for _, version = range availableVersions[API_CreateAcls] {
original := CreateAclsRequest{
RequestHeader: RequestHeader{
APIKey: API_CreateAcls,
APIVersion: version,
CorrelationID: 1000,
ClientID: &clientID,
TaggedFields: nil,
},
Creations: []AclCreation{
{
ResourceType: 1,
ResourceName: "testResource",
PatternType: 2,
Principal: "testPrincipal",
Host: "testHost",
Operation: 3,
PermissionType: 4,
},
{
ResourceType: 2,
ResourceName: "testResource_2",
PatternType: 3,
Principal: "testPrincipal_2",
Host: "testHost_2",
Operation: 4,
PermissionType: 5,
},
},
TaggedFields: nil,
}
if version < 1 {
for i := range original.Creations {
original.Creations[i].PatternType = 0
}
}
t.Logf("reqeust version: %+v", version)
encoded := original.Encode(version)
decoded, err := DecodeCreateAclsRequest(encoded)
if err != nil {
t.Fatalf("decode error: %v", err)
}
convey.So(original, convey.ShouldResemble, decoded)
}
})
}