diff options
Diffstat (limited to 'oslo_policy/tests/test_policy.py')
-rw-r--r-- | oslo_policy/tests/test_policy.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/oslo_policy/tests/test_policy.py b/oslo_policy/tests/test_policy.py index 56d8f76..12d0c85 100644 --- a/oslo_policy/tests/test_policy.py +++ b/oslo_policy/tests/test_policy.py @@ -841,7 +841,7 @@ class EnforcerCheckRulesTest(base.PolicyBaseTestCase): def test_no_violations(self): self.create_config_file('policy.json', POLICY_JSON_CONTENTS) self.enforcer.load_rules(True) - self.assertTrue(self.enforcer.check_rules()) + self.assertTrue(self.enforcer.check_rules(raise_on_violation=True)) def test_undefined_rule(self): rules = jsonutils.dumps({'foo': 'rule:bar'}) @@ -850,6 +850,14 @@ class EnforcerCheckRulesTest(base.PolicyBaseTestCase): self.assertFalse(self.enforcer.check_rules()) + def test_undefined_rule_raises(self): + rules = jsonutils.dumps({'foo': 'rule:bar'}) + self.create_config_file('policy.json', rules) + self.enforcer.load_rules(True) + + self.assertRaises(policy.InvalidDefinitionError, + self.enforcer.check_rules, raise_on_violation=True) + def test_cyclical_rules(self): rules = jsonutils.dumps({'foo': 'rule:bar', 'bar': 'rule:foo'}) self.create_config_file('policy.json', rules) @@ -857,6 +865,14 @@ class EnforcerCheckRulesTest(base.PolicyBaseTestCase): self.assertFalse(self.enforcer.check_rules()) + def test_cyclical_rules_raises(self): + rules = jsonutils.dumps({'foo': 'rule:bar', 'bar': 'rule:foo'}) + self.create_config_file('policy.json', rules) + self.enforcer.load_rules(True) + + self.assertRaises(policy.InvalidDefinitionError, + self.enforcer.check_rules, raise_on_violation=True) + def test_complex_cyclical_rules_false(self): rules = jsonutils.dumps({'foo': 'rule:bar', 'bar': 'rule:baz and role:admin', |