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))
def build_baton_user(username, zone): return User(username, zone)
def to_baton(acl): permission = getattr(AccessControl.Level, acl.permission) return AccessControl(User(acl.user, acl.zone), permission)
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)
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)
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)