Merge "Make policy file support in fixture optional"

This commit is contained in:
Zuul 2018-10-14 00:19:22 +00:00 committed by Gerrit Code Review
commit b0536db02a
6 changed files with 19 additions and 9 deletions

View File

@ -682,7 +682,7 @@ class TestCase(BaseTestCase):
return [] return []
def _policy_fixture(self): def _policy_fixture(self):
return ksfixtures.Policy(dirs.etc('policy.json'), self.config_fixture) return ksfixtures.Policy(self.config_fixture)
@contextlib.contextmanager @contextlib.contextmanager
def make_request(self, path='/', **kwargs): def make_request(self, path='/', **kwargs):

View File

@ -20,7 +20,7 @@ from keystone.common.rbac_enforcer import policy
class Policy(fixtures.Fixture): class Policy(fixtures.Fixture):
"""A fixture for working with policy configuration.""" """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._policy_file = policy_file
self._config_fixture = config_fixture self._config_fixture = config_fixture

View File

@ -46,7 +46,9 @@ class PolicyFileTestCase(unit.TestCase):
self.target = {} self.target = {}
def _policy_fixture(self): 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): def test_modified_policy_reloads(self):
action = "example:test" action = "example:test"

View File

@ -2600,8 +2600,10 @@ class TestTokenRevokeSelfAndAdmin(test_v3.RestfulTestCase):
) )
def _policy_fixture(self): def _policy_fixture(self):
return ksfixtures.Policy(unit.dirs.etc('policy.v3cloudsample.json'), return ksfixtures.Policy(
self.config_fixture) self.config_fixture,
policy_file=unit.dirs.etc('policy.v3cloudsample.json')
)
def test_user_revokes_own_token(self): def test_user_revokes_own_token(self):
user_token = self.get_requested_token( user_token = self.get_requested_token(

View File

@ -39,7 +39,9 @@ class IdentityTestFilteredCase(filtering.FilterTests,
"""Test filter enforcement on the v3 Identity API.""" """Test filter enforcement on the v3 Identity API."""
def _policy_fixture(self): 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): def setUp(self):
"""Setup for Identity Filter Test Cases.""" """Setup for Identity Filter Test Cases."""

View File

@ -37,7 +37,9 @@ class IdentityTestProtectedCase(test_v3.RestfulTestCase):
"""Test policy enforcement on the v3 Identity API.""" """Test policy enforcement on the v3 Identity API."""
def _policy_fixture(self): 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): def setUp(self):
"""Setup for Identity Protection Test Cases. """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.""" """Test policy enforcement of the sample v3 cloud policy file."""
def _policy_fixture(self): def _policy_fixture(self):
return ksfixtures.Policy(unit.dirs.etc('policy.v3cloudsample.json'), return ksfixtures.Policy(
self.config_fixture) self.config_fixture,
policy_file=unit.dirs.etc('policy.v3cloudsample.json')
)
def setUp(self): def setUp(self):
"""Setup for v3 Cloud Policy Sample Test Cases. """Setup for v3 Cloud Policy Sample Test Cases.