acl_create_request_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package sarama
  2. import "testing"
  3. var (
  4. aclCreateRequest = []byte{
  5. 0, 0, 0, 1,
  6. 3, // resource type = group
  7. 0, 5, 'g', 'r', 'o', 'u', 'p',
  8. 0, 9, 'p', 'r', 'i', 'n', 'c', 'i', 'p', 'a', 'l',
  9. 0, 4, 'h', 'o', 's', 't',
  10. 2, // all
  11. 2, // deny
  12. }
  13. aclCreateRequestv1 = []byte{
  14. 0, 0, 0, 1,
  15. 3, // resource type = group
  16. 0, 5, 'g', 'r', 'o', 'u', 'p',
  17. 3, // resource pattten type = literal
  18. 0, 9, 'p', 'r', 'i', 'n', 'c', 'i', 'p', 'a', 'l',
  19. 0, 4, 'h', 'o', 's', 't',
  20. 2, // all
  21. 2, // deny
  22. }
  23. )
  24. func TestCreateAclsRequestv0(t *testing.T) {
  25. req := &CreateAclsRequest{
  26. Version: 0,
  27. AclCreations: []*AclCreation{{
  28. Resource: Resource{
  29. ResourceType: AclResourceGroup,
  30. ResourceName: "group",
  31. },
  32. Acl: Acl{
  33. Principal: "principal",
  34. Host: "host",
  35. Operation: AclOperationAll,
  36. PermissionType: AclPermissionDeny,
  37. }},
  38. },
  39. }
  40. testRequest(t, "create request", req, aclCreateRequest)
  41. }
  42. func TestCreateAclsRequestv1(t *testing.T) {
  43. req := &CreateAclsRequest{
  44. Version: 1,
  45. AclCreations: []*AclCreation{{
  46. Resource: Resource{
  47. ResourceType: AclResourceGroup,
  48. ResourceName: "group",
  49. ResourcePatternType: AclPatternLiteral,
  50. },
  51. Acl: Acl{
  52. Principal: "principal",
  53. Host: "host",
  54. Operation: AclOperationAll,
  55. PermissionType: AclPermissionDeny,
  56. }},
  57. },
  58. }
  59. testRequest(t, "create request v1", req, aclCreateRequestv1)
  60. }