diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-05-24 20:21:56 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-05-24 20:21:56 +0000 |
commit | deffa995a6bab78fd53ea1f0c31f7ae817759bbb (patch) | |
tree | 0eead358c8342ca4d3295c6f64cee1a9ab720fb8 | |
parent | 2a8d18adde149012d0094860e5c804a6f0185817 (diff) | |
parent | 4cc14178ef68d9f49e53fc7a71b053509a763592 (diff) | |
download | oslo-policy-deffa995a6bab78fd53ea1f0c31f7ae817759bbb.tar.gz |
Merge "Simplify message of exception PolicyNotAuthorized"1.23.0
-rw-r--r-- | oslo_policy/policy.py | 4 | ||||
-rw-r--r-- | oslo_policy/tests/test_policy.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/oslo_policy/policy.py b/oslo_policy/policy.py index 211d6c9..6480767 100644 --- a/oslo_policy/policy.py +++ b/oslo_policy/policy.py @@ -296,9 +296,7 @@ class PolicyNotAuthorized(Exception): """Default exception raised for policy enforcement failure.""" def __init__(self, rule, target, creds): - msg = (_('%(target)s is disallowed by policy rule %(rule)s ' - 'with %(creds)s ') % - {'rule': rule, 'target': target, 'creds': creds}) + msg = _("%(rule)s is disallowed by policy") % {'rule': rule} super(PolicyNotAuthorized, self).__init__(msg) diff --git a/oslo_policy/tests/test_policy.py b/oslo_policy/tests/test_policy.py index 744b2d9..c0506df 100644 --- a/oslo_policy/tests/test_policy.py +++ b/oslo_policy/tests/test_policy.py @@ -724,8 +724,10 @@ class CheckFunctionTestCase(base.PolicyBaseTestCase): # raised. self.enforcer.set_rules(dict(default=_checks.FalseCheck())) - self.assertRaises(policy.PolicyNotAuthorized, self.enforcer.enforce, - 'rule', 'target', 'creds', True) + self.assertRaisesRegex(policy.PolicyNotAuthorized, + " is disallowed by policy", + self.enforcer.enforce, + 'rule', 'target', 'creds', True) def test_check_raise_custom_exception(self): self.enforcer.set_rules(dict(default=_checks.FalseCheck())) |