github.com/segmentio/kafka-go@v0.4.48-0.20240318174348-3f6244eb34fd/protocol/createacls/createacls_test.go (about) 1 package createacls_test 2 3 import ( 4 "testing" 5 6 "github.com/segmentio/kafka-go/protocol/createacls" 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 TestCreateACLsRequest(t *testing.T) { 18 prototest.TestRequest(t, v0, &createacls.Request{ 19 Creations: []createacls.RequestACLs{ 20 { 21 Principal: "User:alice", 22 PermissionType: 3, 23 Operation: 3, 24 ResourceType: 2, 25 ResourceName: "fake-topic-for-alice", 26 Host: "*", 27 }, 28 }, 29 }) 30 31 prototest.TestRequest(t, v1, &createacls.Request{ 32 Creations: []createacls.RequestACLs{ 33 { 34 Principal: "User:alice", 35 PermissionType: 3, 36 Operation: 3, 37 ResourceType: 2, 38 ResourcePatternType: 3, 39 ResourceName: "fake-topic-for-alice", 40 Host: "*", 41 }, 42 }, 43 }) 44 45 prototest.TestRequest(t, v2, &createacls.Request{ 46 Creations: []createacls.RequestACLs{ 47 { 48 Principal: "User:alice", 49 PermissionType: 3, 50 Operation: 3, 51 ResourceType: 2, 52 ResourcePatternType: 3, 53 ResourceName: "fake-topic-for-alice", 54 Host: "*", 55 }, 56 }, 57 }) 58 59 prototest.TestRequest(t, v3, &createacls.Request{ 60 Creations: []createacls.RequestACLs{ 61 { 62 Principal: "User:alice", 63 PermissionType: 3, 64 Operation: 3, 65 ResourceType: 2, 66 ResourcePatternType: 3, 67 ResourceName: "fake-topic-for-alice", 68 Host: "*", 69 }, 70 }, 71 }) 72 } 73 74 func TestCreateACLsResponse(t *testing.T) { 75 prototest.TestResponse(t, v0, &createacls.Response{ 76 ThrottleTimeMs: 1, 77 Results: []createacls.ResponseACLs{ 78 { 79 ErrorCode: 1, 80 ErrorMessage: "foo", 81 }, 82 }, 83 }) 84 85 prototest.TestResponse(t, v1, &createacls.Response{ 86 ThrottleTimeMs: 1, 87 Results: []createacls.ResponseACLs{ 88 { 89 ErrorCode: 1, 90 ErrorMessage: "foo", 91 }, 92 }, 93 }) 94 95 prototest.TestResponse(t, v2, &createacls.Response{ 96 ThrottleTimeMs: 1, 97 Results: []createacls.ResponseACLs{ 98 { 99 ErrorCode: 1, 100 ErrorMessage: "foo", 101 }, 102 }, 103 }) 104 105 prototest.TestResponse(t, v3, &createacls.Response{ 106 ThrottleTimeMs: 1, 107 Results: []createacls.ResponseACLs{ 108 { 109 ErrorCode: 1, 110 ErrorMessage: "foo", 111 }, 112 }, 113 }) 114 115 }