def revoke(self, paths: Union[str, Iterable[str]], users: Union[str, Iterable[str], User, Iterable[User]]):
        if isinstance(paths, str):
            paths = [paths]
        if isinstance(users, str) or isinstance(users, User):
            users = [users]

        for i in range(len(users)):
            if not isinstance(users[i], User):
                assert isinstance(users[i], str)
                user = User.create_from_str(users[i])
                users[i] = user

        no_access_controls = [AccessControl(users, AccessControl.Level.NONE) for users in users]
        self.add_or_replace(paths, no_access_controls)
 def test_create_from_str(self):
     user = User.create_from_str("%s#%s" % (_NAME, _ZONE))
     self.assertEqual(user, User(_NAME, _ZONE))
示例#3
0
 def build_baton_user(username, zone):
     return User(username, zone)
示例#4
0
 def to_baton(acl):
     permission = getattr(AccessControl.Level, acl.permission)
     return AccessControl(User(acl.user, acl.zone), permission)
示例#5
0
 def test_to_baton_when_ok(self):
     acl = ACL(user='******', zone='Sanger1', permission='OWN')
     result = ACLMapping.to_baton(acl)
     expected = AccessControl(User('ic4', 'Sanger1'),
                              AccessControl.Level.OWN)
     self.assertEqual(result, expected)
示例#6
0
 def test_from_baton_when_more_acls(self):
     baton_acl = AccessControl(User('ic4', 'Sanger1'),
                               AccessControl.Level.WRITE)
     result = ACLMapping.from_baton(baton_acl)
     expected = ACL(user='******', zone='Sanger1', permission='WRITE')
     self.assertEqual(result, expected)
示例#7
0
 def test_from_baton_when_ok(self):
     baton_acl = AccessControl(User('ic4', 'humgen'),
                               AccessControl.Level.READ)
     serapis_acl = ACLMapping.from_baton(baton_acl)
     expected = ACL(user='******', zone='humgen', permission='READ')
     self.assertEqual(serapis_acl, expected)