Ensure keystone unittests do not leave CONF.policyfile in bad state
A few of the tests overwrite the name of the policy file (so they can use a temp file instead). However, if it is left that way, subsequent tests that rely on it may fail. A separate patch will look at doing a more comprehensive reset in the setup of test_v3 - ensuring we always start from a completely clean slate for all confirguration parameters. Fixes Bug #1131819 Change-Id: Ibe5ee12f44310de00b12ddd405c83f59b2d840b7
This commit is contained in:
parent
95815708eb
commit
1f7f1bd3c8
@ -32,6 +32,7 @@ CONF = config.CONF
|
|||||||
class PolicyFileTestCase(test.TestCase):
|
class PolicyFileTestCase(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(PolicyFileTestCase, self).setUp()
|
super(PolicyFileTestCase, self).setUp()
|
||||||
|
self.orig_policy_file = CONF.policy_file
|
||||||
rules.reset()
|
rules.reset()
|
||||||
_unused, self.tmpfilename = tempfile.mkstemp()
|
_unused, self.tmpfilename = tempfile.mkstemp()
|
||||||
self.opt(policy_file=self.tmpfilename)
|
self.opt(policy_file=self.tmpfilename)
|
||||||
@ -40,6 +41,7 @@ class PolicyFileTestCase(test.TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(PolicyFileTestCase, self).tearDown()
|
super(PolicyFileTestCase, self).tearDown()
|
||||||
rules.reset()
|
rules.reset()
|
||||||
|
self.opt(policy_file=self.orig_policy_file)
|
||||||
|
|
||||||
def test_modified_policy_reloads(self):
|
def test_modified_policy_reloads(self):
|
||||||
action = "example:test"
|
action = "example:test"
|
||||||
|
@ -20,11 +20,15 @@ import uuid
|
|||||||
|
|
||||||
import nose.exc
|
import nose.exc
|
||||||
|
|
||||||
|
from keystone import config
|
||||||
from keystone.policy.backends import rules
|
from keystone.policy.backends import rules
|
||||||
|
|
||||||
import test_v3
|
import test_v3
|
||||||
|
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
class IdentityTestProtectedCase(test_v3.RestfulTestCase):
|
class IdentityTestProtectedCase(test_v3.RestfulTestCase):
|
||||||
"""Test policy protection of a sample of v3 identity apis"""
|
"""Test policy protection of a sample of v3 identity apis"""
|
||||||
|
|
||||||
@ -71,6 +75,7 @@ class IdentityTestProtectedCase(test_v3.RestfulTestCase):
|
|||||||
|
|
||||||
# Initialize the policy engine and allow us to write to a temp
|
# Initialize the policy engine and allow us to write to a temp
|
||||||
# file in each test to create the policies
|
# file in each test to create the policies
|
||||||
|
self.orig_policy_file = CONF.policy_file
|
||||||
rules.reset()
|
rules.reset()
|
||||||
_unused, self.tmpfilename = tempfile.mkstemp()
|
_unused, self.tmpfilename = tempfile.mkstemp()
|
||||||
self.opt(policy_file=self.tmpfilename)
|
self.opt(policy_file=self.tmpfilename)
|
||||||
@ -85,6 +90,11 @@ class IdentityTestProtectedCase(test_v3.RestfulTestCase):
|
|||||||
self.auth['authentication']['password']['user']['password'] = (
|
self.auth['authentication']['password']['user']['password'] = (
|
||||||
self.user1['password'])
|
self.user1['password'])
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(IdentityTestProtectedCase, self).tearDown()
|
||||||
|
rules.reset()
|
||||||
|
self.opt(policy_file=self.orig_policy_file)
|
||||||
|
|
||||||
def _get_id_list_from_ref_list(self, ref_list):
|
def _get_id_list_from_ref_list(self, ref_list):
|
||||||
result_list = []
|
result_list = []
|
||||||
for x in ref_list:
|
for x in ref_list:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user