github.com/segmentio/kafka-go@v0.4.48-0.20240318174348-3f6244eb34fd/protocol/deleteacls/deleteacls_test.go (about) 1 package deleteacls_test 2 3 import ( 4 "testing" 5 6 "github.com/segmentio/kafka-go/protocol/deleteacls" 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 TestDeleteACLsRequest(t *testing.T) { 18 prototest.TestRequest(t, v0, &deleteacls.Request{ 19 Filters: []deleteacls.RequestFilter{ 20 { 21 ResourceTypeFilter: 2, 22 ResourceNameFilter: "fake-topic-for-alice", 23 PrincipalFilter: "User:alice", 24 HostFilter: "*", 25 Operation: 3, 26 PermissionType: 3, 27 }, 28 }, 29 }) 30 31 prototest.TestRequest(t, v1, &deleteacls.Request{ 32 Filters: []deleteacls.RequestFilter{ 33 { 34 ResourceTypeFilter: 2, 35 ResourceNameFilter: "fake-topic-for-alice", 36 ResourcePatternTypeFilter: 0, 37 PrincipalFilter: "User:alice", 38 HostFilter: "*", 39 Operation: 3, 40 PermissionType: 3, 41 }, 42 }, 43 }) 44 45 prototest.TestRequest(t, v2, &deleteacls.Request{ 46 Filters: []deleteacls.RequestFilter{ 47 { 48 ResourceTypeFilter: 2, 49 ResourceNameFilter: "fake-topic-for-alice", 50 ResourcePatternTypeFilter: 0, 51 PrincipalFilter: "User:alice", 52 HostFilter: "*", 53 Operation: 3, 54 PermissionType: 3, 55 }, 56 }, 57 }) 58 59 prototest.TestRequest(t, v3, &deleteacls.Request{ 60 Filters: []deleteacls.RequestFilter{ 61 { 62 ResourceTypeFilter: 2, 63 ResourceNameFilter: "fake-topic-for-alice", 64 ResourcePatternTypeFilter: 0, 65 PrincipalFilter: "User:alice", 66 HostFilter: "*", 67 Operation: 3, 68 PermissionType: 3, 69 }, 70 }, 71 }) 72 } 73 74 func TestDeleteACLsResponse(t *testing.T) { 75 prototest.TestResponse(t, v0, &deleteacls.Response{ 76 ThrottleTimeMs: 1, 77 FilterResults: []deleteacls.FilterResult{ 78 { 79 ErrorCode: 1, 80 ErrorMessage: "foo", 81 MatchingACLs: []deleteacls.MatchingACL{ 82 { 83 ErrorCode: 1, 84 ErrorMessage: "bar", 85 ResourceType: 2, 86 ResourceName: "fake-topic-for-alice", 87 Principal: "User:alice", 88 Host: "*", 89 Operation: 3, 90 PermissionType: 3, 91 }, 92 }, 93 }, 94 }, 95 }) 96 97 prototest.TestResponse(t, v1, &deleteacls.Response{ 98 ThrottleTimeMs: 1, 99 FilterResults: []deleteacls.FilterResult{ 100 { 101 ErrorCode: 1, 102 ErrorMessage: "foo", 103 MatchingACLs: []deleteacls.MatchingACL{ 104 { 105 ErrorCode: 1, 106 ErrorMessage: "bar", 107 ResourceType: 2, 108 ResourceName: "fake-topic-for-alice", 109 ResourcePatternType: 0, 110 Principal: "User:alice", 111 Host: "*", 112 Operation: 3, 113 PermissionType: 3, 114 }, 115 }, 116 }, 117 }, 118 }) 119 120 prototest.TestResponse(t, v2, &deleteacls.Response{ 121 ThrottleTimeMs: 1, 122 FilterResults: []deleteacls.FilterResult{ 123 { 124 ErrorCode: 1, 125 ErrorMessage: "foo", 126 MatchingACLs: []deleteacls.MatchingACL{ 127 { 128 ErrorCode: 1, 129 ErrorMessage: "bar", 130 ResourceType: 2, 131 ResourceName: "fake-topic-for-alice", 132 ResourcePatternType: 0, 133 Principal: "User:alice", 134 Host: "*", 135 Operation: 3, 136 PermissionType: 3, 137 }, 138 }, 139 }, 140 }, 141 }) 142 143 prototest.TestResponse(t, v3, &deleteacls.Response{ 144 ThrottleTimeMs: 1, 145 FilterResults: []deleteacls.FilterResult{ 146 { 147 ErrorCode: 1, 148 ErrorMessage: "foo", 149 MatchingACLs: []deleteacls.MatchingACL{ 150 { 151 ErrorCode: 1, 152 ErrorMessage: "bar", 153 ResourceType: 2, 154 ResourceName: "fake-topic-for-alice", 155 ResourcePatternType: 0, 156 Principal: "User:alice", 157 Host: "*", 158 Operation: 3, 159 PermissionType: 3, 160 }, 161 }, 162 }, 163 }, 164 }) 165 }