图片解析应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3 KiB

  1. import unittest
  2. from kazoo.security import Permissions
  3. class TestACL(unittest.TestCase):
  4. def _makeOne(self, *args, **kwargs):
  5. from kazoo.security import make_acl
  6. return make_acl(*args, **kwargs)
  7. def test_read_acl(self):
  8. acl = self._makeOne("digest", ":", read=True)
  9. assert acl.perms & Permissions.READ == Permissions.READ
  10. def test_all_perms(self):
  11. acl = self._makeOne(
  12. "digest",
  13. ":",
  14. read=True,
  15. write=True,
  16. create=True,
  17. delete=True,
  18. admin=True,
  19. )
  20. for perm in [
  21. Permissions.READ,
  22. Permissions.CREATE,
  23. Permissions.WRITE,
  24. Permissions.DELETE,
  25. Permissions.ADMIN,
  26. ]:
  27. assert acl.perms & perm == perm
  28. def test_perm_listing(self):
  29. from kazoo.security import ACL
  30. f = ACL(15, "fred")
  31. assert "READ" in f.acl_list
  32. assert "WRITE" in f.acl_list
  33. assert "CREATE" in f.acl_list
  34. assert "DELETE" in f.acl_list
  35. f = ACL(16, "fred")
  36. assert "ADMIN" in f.acl_list
  37. f = ACL(31, "george")
  38. assert "ALL" in f.acl_list
  39. def test_perm_repr(self):
  40. from kazoo.security import ACL
  41. f = ACL(16, "fred")
  42. assert "ACL(perms=16, acl_list=['ADMIN']" in repr(f)