示例#1
0
 def test_add_delete_get_policy_rule(self):
     id = uuidutils.generate_uuid()
     rule_str = "p(x) :- q(x)"
     policy_name = "classification"
     comment = "None"
     db_policy_rules.add_policy_rule(id=id,
                                     policy_name=policy_name,
                                     rule=rule_str,
                                     comment=comment)
     db_policy_rules.delete_policy_rule(id)
     rule = db_policy_rules.get_policy_rule(id, policy_name)
     self.assertIsNone(rule)
示例#2
0
 def test_add_delete_get_policy_rule(self):
     id = uuidutils.generate_uuid()
     rule_str = "p(x) :- q(x)"
     policy_name = "classification"
     comment = "None"
     db_policy_rules.add_policy_rule(id=id,
                                     policy_name=policy_name,
                                     rule=rule_str,
                                     comment=comment)
     db_policy_rules.delete_policy_rule(id)
     rule = db_policy_rules.get_policy_rule(id, policy_name)
     self.assertEqual(rule, None)
示例#3
0
 def test_add_delete_get_deleted_policy_rule(self):
     id = uuidutils.generate_uuid()
     rule_str = "p(x) :- q(x)"
     policy_name = "classification"
     comment = "None"
     rule1 = db_policy_rules.add_policy_rule(id=id,
                                             policy_name=policy_name,
                                             rule=rule_str,
                                             comment=comment)
     db_policy_rules.delete_policy_rule(id)
     rule2 = db_policy_rules.get_policy_rule(id, policy_name, deleted=True)
     self.assertEqual(rule1.id, rule2.id)
     self.assertNotEqual(rule1.deleted, rule2.deleted)
示例#4
0
    def delete_item(self, id_, params, context=None):
        """Remove item from model.

        Args:
            id_: The ID of the item to be removed
            params: A dict-like object containing parameters
                    from the request query string and body.
            context: Key-values providing frame of reference of request

        Returns:
             The removed item.

        Raises:
            KeyError: Item with specified id_ not present.
        """
        item = self.get_item(id_, params, context)
        if item is None:
            raise KeyError('ID %s does not exist', id_)
        rule = self.engine.parse1(item['rule'])
        self.change_rule(rule, context, insert=False)
        db_policy_rules.delete_policy_rule(id_)
        return item
示例#5
0
    def delete_item(self, id_, params, context=None):
        """Remove item from model.

        Args:
            id_: The ID of the item to be removed
            params: A dict-like object containing parameters
                    from the request query string and body.
            context: Key-values providing frame of reference of request

        Returns:
             The removed item.

        Raises:
            KeyError: Item with specified id_ not present.
        """
        item = self.get_item(id_, params, context)
        if item is None:
            raise KeyError('ID %s does not exist', id_)
        rule = self.engine.parse1(item['rule'])
        self.change_rule(rule, context, insert=False)
        db_policy_rules.delete_policy_rule(id_)
        return item