Be explicit about which conf is being used by policy enforcer
We've got a tradition of avoiding global config where possible, so extract a _get_enforcer private method which allows us to do some testing without relying on the implicit global config. Change-Id: Icb2198ebedb2ff29347ebafda46690a908bf9d27
This commit is contained in:
parent
ce1589235f
commit
98f722a603
@ -52,7 +52,11 @@ def get_enforcer():
|
||||
# files from overrides on disk and defaults in code. We can just pass an
|
||||
# empty list and let oslo do the config lifting for us.
|
||||
cfg.CONF([], project='placement')
|
||||
init(cfg.CONF)
|
||||
return _get_enforcer(cfg.CONF)
|
||||
|
||||
|
||||
def _get_enforcer(conf):
|
||||
init(conf)
|
||||
return _ENFORCER
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ class PlacementPolicyTestCase(testtools.TestCase):
|
||||
policy.authorize, self.ctxt, action, self.target)
|
||||
|
||||
# Load the default action and rule (defaults to "any").
|
||||
enforcer = policy.get_enforcer()
|
||||
enforcer = policy._get_enforcer(self.conf_fixture.conf)
|
||||
rule = oslo_policy.RuleDefault(action, '')
|
||||
enforcer.register_default(rule)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user