acl_describe_request_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package sarama
  2. import (
  3. "testing"
  4. )
  5. var (
  6. aclDescribeRequest = []byte{
  7. 2, // resource type
  8. 0, 5, 't', 'o', 'p', 'i', 'c',
  9. 0, 9, 'p', 'r', 'i', 'n', 'c', 'i', 'p', 'a', 'l',
  10. 0, 4, 'h', 'o', 's', 't',
  11. 5, // acl operation
  12. 3, // acl permission type
  13. }
  14. aclDescribeRequestV1 = []byte{
  15. 2, // resource type
  16. 0, 5, 't', 'o', 'p', 'i', 'c',
  17. 1, // any Type
  18. 0, 9, 'p', 'r', 'i', 'n', 'c', 'i', 'p', 'a', 'l',
  19. 0, 4, 'h', 'o', 's', 't',
  20. 5, // acl operation
  21. 3, // acl permission type
  22. }
  23. )
  24. func TestAclDescribeRequestV0(t *testing.T) {
  25. resourcename := "topic"
  26. principal := "principal"
  27. host := "host"
  28. req := &DescribeAclsRequest{
  29. AclFilter: AclFilter{
  30. ResourceType: AclResourceTopic,
  31. ResourceName: &resourcename,
  32. Principal: &principal,
  33. Host: &host,
  34. Operation: AclOperationCreate,
  35. PermissionType: AclPermissionAllow,
  36. },
  37. }
  38. testRequest(t, "", req, aclDescribeRequest)
  39. }
  40. func TestAclDescribeRequestV1(t *testing.T) {
  41. resourcename := "topic"
  42. principal := "principal"
  43. host := "host"
  44. req := &DescribeAclsRequest{
  45. Version: 1,
  46. AclFilter: AclFilter{
  47. ResourceType: AclResourceTopic,
  48. ResourceName: &resourcename,
  49. ResourcePatternTypeFilter: AclPatternAny,
  50. Principal: &principal,
  51. Host: &host,
  52. Operation: AclOperationCreate,
  53. PermissionType: AclPermissionAllow,
  54. },
  55. }
  56. testRequest(t, "", req, aclDescribeRequestV1)
  57. }