github.com/streamdal/segmentio-kafka-go@v0.4.47-streamdal/protocol/describeacls/describeacls_test.go (about) 1 package describeacls_test 2 3 import ( 4 "testing" 5 6 "github.com/segmentio/kafka-go/protocol/describeacls" 7 "github.com/segmentio/kafka-go/protocol/prototest" 8 ) 9 10 const ( 11 v0 = 0 12 v1 = 1 13 v2 = 2 14 v3 = 3 15 ) 16 17 func TestDescribeACLsRequest(t *testing.T) { 18 prototest.TestRequest(t, v0, &describeacls.Request{ 19 Filter: describeacls.ACLFilter{ 20 ResourceTypeFilter: 2, 21 ResourceNameFilter: "fake-topic-for-alice", 22 PrincipalFilter: "User:alice", 23 HostFilter: "*", 24 Operation: 3, 25 PermissionType: 3, 26 }, 27 }) 28 29 prototest.TestRequest(t, v1, &describeacls.Request{ 30 Filter: describeacls.ACLFilter{ 31 ResourceTypeFilter: 2, 32 ResourceNameFilter: "fake-topic-for-alice", 33 ResourcePatternTypeFilter: 0, 34 PrincipalFilter: "User:alice", 35 HostFilter: "*", 36 Operation: 3, 37 PermissionType: 3, 38 }, 39 }) 40 41 prototest.TestRequest(t, v2, &describeacls.Request{ 42 Filter: describeacls.ACLFilter{ 43 ResourceTypeFilter: 2, 44 ResourceNameFilter: "fake-topic-for-alice", 45 ResourcePatternTypeFilter: 0, 46 PrincipalFilter: "User:alice", 47 HostFilter: "*", 48 Operation: 3, 49 PermissionType: 3, 50 }, 51 }) 52 53 prototest.TestRequest(t, v3, &describeacls.Request{ 54 Filter: describeacls.ACLFilter{ 55 ResourceTypeFilter: 2, 56 ResourceNameFilter: "fake-topic-for-alice", 57 ResourcePatternTypeFilter: 0, 58 PrincipalFilter: "User:alice", 59 HostFilter: "*", 60 Operation: 3, 61 PermissionType: 3, 62 }, 63 }) 64 } 65 66 func TestDescribeACLsResponse(t *testing.T) { 67 prototest.TestResponse(t, v0, &describeacls.Response{ 68 ThrottleTimeMs: 1, 69 ErrorCode: 1, 70 ErrorMessage: "foo", 71 Resources: []describeacls.Resource{ 72 { 73 ResourceType: 2, 74 ResourceName: "fake-topic-for-alice", 75 ACLs: []describeacls.ResponseACL{ 76 { 77 Principal: "User:alice", 78 Host: "*", 79 Operation: 3, 80 PermissionType: 3, 81 }, 82 }, 83 }, 84 }, 85 }) 86 87 prototest.TestResponse(t, v1, &describeacls.Response{ 88 ThrottleTimeMs: 1, 89 ErrorCode: 1, 90 ErrorMessage: "foo", 91 Resources: []describeacls.Resource{ 92 { 93 ResourceType: 2, 94 ResourceName: "fake-topic-for-alice", 95 PatternType: 3, 96 ACLs: []describeacls.ResponseACL{ 97 { 98 Principal: "User:alice", 99 Host: "*", 100 Operation: 3, 101 PermissionType: 3, 102 }, 103 }, 104 }, 105 }, 106 }) 107 108 prototest.TestResponse(t, v2, &describeacls.Response{ 109 ThrottleTimeMs: 1, 110 ErrorCode: 1, 111 ErrorMessage: "foo", 112 Resources: []describeacls.Resource{ 113 { 114 ResourceType: 2, 115 ResourceName: "fake-topic-for-alice", 116 PatternType: 3, 117 ACLs: []describeacls.ResponseACL{ 118 { 119 Principal: "User:alice", 120 Host: "*", 121 Operation: 3, 122 PermissionType: 3, 123 }, 124 }, 125 }, 126 }, 127 }) 128 129 prototest.TestResponse(t, v3, &describeacls.Response{ 130 ThrottleTimeMs: 1, 131 ErrorCode: 1, 132 ErrorMessage: "foo", 133 Resources: []describeacls.Resource{ 134 { 135 ResourceType: 2, 136 ResourceName: "fake-topic-for-alice", 137 PatternType: 3, 138 ACLs: []describeacls.ResponseACL{ 139 { 140 Principal: "User:alice", 141 Host: "*", 142 Operation: 3, 143 PermissionType: 3, 144 }, 145 }, 146 }, 147 }, 148 }) 149 }