acl_delete_request_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package sarama
  2. import "testing"
  3. var (
  4. aclDeleteRequestNulls = []byte{
  5. 0, 0, 0, 1,
  6. 1,
  7. 255, 255,
  8. 255, 255,
  9. 255, 255,
  10. 11,
  11. 3,
  12. }
  13. aclDeleteRequest = []byte{
  14. 0, 0, 0, 1,
  15. 1, // any
  16. 0, 6, 'f', 'i', 'l', 't', 'e', 'r',
  17. 0, 9, 'p', 'r', 'i', 'n', 'c', 'i', 'p', 'a', 'l',
  18. 0, 4, 'h', 'o', 's', 't',
  19. 4, // write
  20. 3, // allow
  21. }
  22. aclDeleteRequestArray = []byte{
  23. 0, 0, 0, 2,
  24. 1,
  25. 0, 6, 'f', 'i', 'l', 't', 'e', 'r',
  26. 0, 9, 'p', 'r', 'i', 'n', 'c', 'i', 'p', 'a', 'l',
  27. 0, 4, 'h', 'o', 's', 't',
  28. 4, // write
  29. 3, // allow
  30. 2,
  31. 0, 5, 't', 'o', 'p', 'i', 'c',
  32. 255, 255,
  33. 255, 255,
  34. 6,
  35. 2,
  36. }
  37. )
  38. func TestDeleteAclsRequest(t *testing.T) {
  39. req := &DeleteAclsRequest{
  40. Filters: []*AclFilter{{
  41. ResourceType: AclResourceAny,
  42. Operation: AclOperationAlterConfigs,
  43. PermissionType: AclPermissionAllow,
  44. }},
  45. }
  46. testRequest(t, "delete request nulls", req, aclDeleteRequestNulls)
  47. req.Filters[0].ResourceName = nullString("filter")
  48. req.Filters[0].Principal = nullString("principal")
  49. req.Filters[0].Host = nullString("host")
  50. req.Filters[0].Operation = AclOperationWrite
  51. testRequest(t, "delete request", req, aclDeleteRequest)
  52. req.Filters = append(req.Filters, &AclFilter{
  53. ResourceType: AclResourceTopic,
  54. ResourceName: nullString("topic"),
  55. Operation: AclOperationDelete,
  56. PermissionType: AclPermissionDeny,
  57. })
  58. testRequest(t, "delete request array", req, aclDeleteRequestArray)
  59. }