Make policy file support in fixture optional
The ksfixtures.Policy object used to accept two arguments. One was the path of the policy file and the other was the test fixture. Since policy is now kept in code and the default policy file has been removed from keystone source, we can simplify the fixture to optionally deal with a file path, instead of passing a non-existant file to it all the time. Change-Id: I9d8c4cbf963099fe73e39dbf46e03f66f9a79f43
This commit is contained in:
parent
f872a40290
commit
a394558dc4
|
@ -682,7 +682,7 @@ class TestCase(BaseTestCase):
|
|||
return []
|
||||
|
||||
def _policy_fixture(self):
|
||||
return ksfixtures.Policy(dirs.etc('policy.json'), self.config_fixture)
|
||||
return ksfixtures.Policy(self.config_fixture)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def make_request(self, path='/', **kwargs):
|
||||
|
|
|
@ -20,7 +20,7 @@ from keystone.common.rbac_enforcer import policy
|
|||
class Policy(fixtures.Fixture):
|
||||
"""A fixture for working with policy configuration."""
|
||||
|
||||
def __init__(self, policy_file, config_fixture):
|
||||
def __init__(self, config_fixture, policy_file=None):
|
||||
self._policy_file = policy_file
|
||||
self._config_fixture = config_fixture
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ class PolicyFileTestCase(unit.TestCase):
|
|||
self.target = {}
|
||||
|
||||
def _policy_fixture(self):
|
||||
return ksfixtures.Policy(self.tmpfilename, self.config_fixture)
|
||||
return ksfixtures.Policy(
|
||||
self.config_fixture, policy_file=self.tmpfilename
|
||||
)
|
||||
|
||||
def test_modified_policy_reloads(self):
|
||||
action = "example:test"
|
||||
|
|
|
@ -2600,8 +2600,10 @@ class TestTokenRevokeSelfAndAdmin(test_v3.RestfulTestCase):
|
|||
)
|
||||
|
||||
def _policy_fixture(self):
|
||||
return ksfixtures.Policy(unit.dirs.etc('policy.v3cloudsample.json'),
|
||||
self.config_fixture)
|
||||
return ksfixtures.Policy(
|
||||
self.config_fixture,
|
||||
policy_file=unit.dirs.etc('policy.v3cloudsample.json')
|
||||
)
|
||||
|
||||
def test_user_revokes_own_token(self):
|
||||
user_token = self.get_requested_token(
|
||||
|
|
|
@ -39,7 +39,9 @@ class IdentityTestFilteredCase(filtering.FilterTests,
|
|||
"""Test filter enforcement on the v3 Identity API."""
|
||||
|
||||
def _policy_fixture(self):
|
||||
return ksfixtures.Policy(self.tmpfilename, self.config_fixture)
|
||||
return ksfixtures.Policy(
|
||||
self.config_fixture, policy_file=self.tmpfilename
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
"""Setup for Identity Filter Test Cases."""
|
||||
|
|
|
@ -37,7 +37,9 @@ class IdentityTestProtectedCase(test_v3.RestfulTestCase):
|
|||
"""Test policy enforcement on the v3 Identity API."""
|
||||
|
||||
def _policy_fixture(self):
|
||||
return ksfixtures.Policy(self.tmpfilename, self.config_fixture)
|
||||
return ksfixtures.Policy(
|
||||
self.config_fixture, policy_file=self.tmpfilename
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
"""Setup for Identity Protection Test Cases.
|
||||
|
@ -643,8 +645,10 @@ class IdentityTestv3CloudPolicySample(test_v3.RestfulTestCase,
|
|||
"""Test policy enforcement of the sample v3 cloud policy file."""
|
||||
|
||||
def _policy_fixture(self):
|
||||
return ksfixtures.Policy(unit.dirs.etc('policy.v3cloudsample.json'),
|
||||
self.config_fixture)
|
||||
return ksfixtures.Policy(
|
||||
self.config_fixture,
|
||||
policy_file=unit.dirs.etc('policy.v3cloudsample.json')
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
"""Setup for v3 Cloud Policy Sample Test Cases.
|
||||
|
|
Loading…
Reference in New Issue