-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathdescribe_client_quotas_request_test.go
84 lines (75 loc) · 2.28 KB
/
describe_client_quotas_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package sarama
import "testing"
var (
describeClientQuotasRequestAll = []byte{
0, 0, 0, 0, // components len
0, // strict
}
describeClientQuotasRequestDefaultUser = []byte{
0, 0, 0, 1, // components len
0, 4, 'u', 's', 'e', 'r', // entity type
1, // match type (default)
0, 0, // match *string
0, // strict
}
describeClientQuotasRequestOnlySpecificUser = []byte{
0, 0, 0, 1, // components len
0, 4, 'u', 's', 'e', 'r', // entity type
0, // match type (exact)
0, 6, 's', 'a', 'r', 'a', 'm', 'a', // match *string
1, // strict
}
describeClientQuotasRequestMultiComponents = []byte{
0, 0, 0, 2, // components len
0, 4, 'u', 's', 'e', 'r', // entity type
2, // match type (any)
255, 255, // match *string
0, 9, 'c', 'l', 'i', 'e', 'n', 't', '-', 'i', 'd', // entity type
1, // match type (default)
0, 0, // match *string
0, // strict
}
)
func TestDescribeClientQuotasRequest(t *testing.T) {
// Match All
req := &DescribeClientQuotasRequest{
Components: []QuotaFilterComponent{},
Strict: false,
}
testRequest(t, "Match All", req, describeClientQuotasRequestAll)
// Match Default User
defaultUser := QuotaFilterComponent{
EntityType: QuotaEntityUser,
MatchType: QuotaMatchDefault,
}
req = &DescribeClientQuotasRequest{
Components: []QuotaFilterComponent{defaultUser},
Strict: false,
}
testRequest(t, "Match Default User", req, describeClientQuotasRequestDefaultUser)
// Match Only Specific User
specificUser := QuotaFilterComponent{
EntityType: QuotaEntityUser,
MatchType: QuotaMatchExact,
Match: "sarama",
}
req = &DescribeClientQuotasRequest{
Components: []QuotaFilterComponent{specificUser},
Strict: true,
}
testRequest(t, "Match Only Specific User", req, describeClientQuotasRequestOnlySpecificUser)
// Match default client-id of any user
anyUser := QuotaFilterComponent{
EntityType: QuotaEntityUser,
MatchType: QuotaMatchAny,
}
defaultClientId := QuotaFilterComponent{
EntityType: QuotaEntityClientID,
MatchType: QuotaMatchDefault,
}
req = &DescribeClientQuotasRequest{
Components: []QuotaFilterComponent{anyUser, defaultClientId},
Strict: false,
}
testRequest(t, "Match default client-id of any user", req, describeClientQuotasRequestMultiComponents)
}