def _check_permissions(self, msg): allowed = permissions.get(config.controller['permissions_path']) perms = permissions.check(allowed, self.sender, msg['collection'], msg['id']) if self.body['action'] not in perms: raise ValueError("You don't have permission to do that.")
def test_lines_order_matter_success(self): fp = self._get_fp('permissions.conf') perm_list = permissions.get(fp) user = '******' collection = 'files' res_id = '/etc/hosts' action = 'update' perms = permissions.check(perm_list, user, collection, res_id) self.assertTrue(action in perms)
def test_lines_order_matter_fail(self): fp = self._get_fp('permissions.conf') perm_list = permissions.get(fp) user = '******' collection = 'executables' res_id = 'rm -rf /' action = 'update' perms = permissions.check(perm_list, user, collection, res_id) self.assertFalse(action in perms)
def __init__(self, scheduler=None, tasks_queue=None, publish_queue=None): self.logger.debug("Initializing the controller...") Thread.__init__(self, name="CONTROLLER") permissions_path = config.controller['permissions_path'] try: self.permissions = permissions.get(permissions_path) except (IOError, OSError) as err: self.logger.critical(err) raise SystemExit self.uuid = config.rabbitmq['uuid'] self.tasks_queue = tasks_queue self.publish_queue = publish_queue self.locator = ResourceLocator(scheduler, publish_queue) self.logger.debug("Controller successfully initialized.")
def __init__(self, scheduler=None, tq=None, pq=None): self.logger.debug("Initializing the controller...") Thread.__init__(self, name="CONTROLLER") permissions_path = config.controller['permissions_path'] try: self.permissions = permissions.get(permissions_path) except (IOError, OSError) as err: self.logger.critical(err) raise SystemExit self.uuid = config.rabbitmq['uuid'] self.tq = tq self.pq = pq self.locator = ResourceLocator(scheduler, pq) self.logger.debug("Controller successfully initialized.")
def test_blank_lines_dont_matter(self): fp = self._get_fp('permissions.conf') permissions.get(fp)