Hacking: enable extensions H106, H203 and H904
[H106] Don't put vim configuration in source files. [H203] Use assertIs(Not)None to check for None. [H904] Delay string interpolations at logging calls. This change makes Patrole's hacking consistent with Tempest's [0][1]. [0] https://review.openstack.org/#/c/408211/ [1] https://review.openstack.org/#/c/408066/ Change-Id: Ia56f66b4ab7e1eea6a8bfea05bf52865be13430c
This commit is contained in:
parent
4791c4b11b
commit
4bf66a2285
|
@ -81,7 +81,7 @@ class RbacPolicyParser(object):
|
||||||
path = getattr(CONF.rbac, '%s_policy_file' % str(service), None)
|
path = getattr(CONF.rbac, '%s_policy_file' % str(service), None)
|
||||||
if not path:
|
if not path:
|
||||||
LOG.info("No config option found for %s,"
|
LOG.info("No config option found for %s,"
|
||||||
" using default path" % str(service))
|
" using default path", str(service))
|
||||||
path = os.path.join('/etc', service, 'policy.json')
|
path = os.path.join('/etc', service, 'policy.json')
|
||||||
self.path = path
|
self.path = path
|
||||||
self.rules = policy.Rules.load(self._get_policy_data(service),
|
self.rules = policy.Rules.load(self._get_policy_data(service),
|
||||||
|
|
|
@ -104,7 +104,7 @@ def action(service, rule='', admin_only=False, expected_error_code=403,
|
||||||
(role, rule))
|
(role, rule))
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exceptions.Forbidden(
|
raise exceptions.Forbidden(
|
||||||
"%s exception was: %s" % (msg, e))
|
"%s Exception was: %s" % (msg, e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
error_details = exc_info[1].__str__()
|
error_details = exc_info[1].__str__()
|
||||||
|
@ -115,7 +115,7 @@ def action(service, rule='', admin_only=False, expected_error_code=403,
|
||||||
six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
|
six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
|
||||||
else:
|
else:
|
||||||
if not allowed:
|
if not allowed:
|
||||||
LOG.error("Role %s was allowed to perform %s" %
|
LOG.error("Role %s was allowed to perform %s",
|
||||||
(role, rule))
|
(role, rule))
|
||||||
raise rbac_exceptions.RbacOverPermission(
|
raise rbac_exceptions.RbacOverPermission(
|
||||||
"OverPermission: Role %s was allowed to perform %s" %
|
"OverPermission: Role %s was allowed to perform %s" %
|
||||||
|
|
|
@ -255,7 +255,8 @@ class RBACRuleValidationTest(base.TestCase):
|
||||||
"sentinel.action"), e.__str__())
|
"sentinel.action"), e.__str__())
|
||||||
|
|
||||||
mock_log.error.assert_called_once_with(
|
mock_log.error.assert_called_once_with(
|
||||||
"Role Member was allowed to perform sentinel.action")
|
'Role %s was allowed to perform %s', ('Member',
|
||||||
|
mock.sentinel.action))
|
||||||
|
|
||||||
@mock.patch.object(rbac_rv, 'rbac_policy_parser', autospec=True)
|
@mock.patch.object(rbac_rv, 'rbac_policy_parser', autospec=True)
|
||||||
def test_invalid_policy_rule_throws_parsing_exception(
|
def test_invalid_policy_rule_throws_parsing_exception(
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -53,9 +53,9 @@ commands =
|
||||||
commands = oslo_debug_helper -t patrole_tempest_plugin/tests {posargs}
|
commands = oslo_debug_helper -t patrole_tempest_plugin/tests {posargs}
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
enable-extensions = H106,H203,H904
|
||||||
|
|
||||||
show-source = True
|
show-source = True
|
||||||
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
ignore = E123,E125
|
ignore = E123,E125
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||||
|
|
Loading…
Reference in New Issue