use keystone test and change config during setUp

Also fixes this traceback which I keep getting on devstack:

ERROR: test_create_certs (tests.test_cert_setup.CertSetupTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/stack/keystone/tests/test_cert_setup.py", line 52, in tearDown
    shutil.rmtree(rootdir(SSLDIR))
  File "/usr/lib/python2.7/shutil.py", line 237, in rmtree
    onerror(os.listdir, path, sys.exc_info())
  File "/usr/lib/python2.7/shutil.py", line 235, in rmtree
    names = os.listdir(path)
OSError: [Errno 2] No such file or directory: '/opt/stack/keystone/tests/ssl/'

Fixes bug 1086812

Change-Id: Iba10822aaf1284549d610bb1172df03ffc48f363
This commit is contained in:
Ionuț Arțăriși 2012-12-03 11:59:20 +01:00
parent 75277cf1ae
commit 77dee93763

View File

@ -16,15 +16,14 @@
# limitations under the License.
import os
import unittest2 as test
import shutil
from keystone import config
from keystone.common import openssl
from keystone import test
ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SSLDIR = "%s/tests/ssl/" % ROOTDIR
CONF = config.CONF
CONF = test.CONF
def rootdir(*p):
@ -34,13 +33,15 @@ def rootdir(*p):
CERTDIR = rootdir("certs")
KEYDIR = rootdir("private")
CONF.signing.certfile = os.path.join(CERTDIR, 'signing_cert.pem')
CONF.signing.ca_certs = os.path.join(CERTDIR, "ca.pem")
CONF.signing.keyfile = os.path.join(KEYDIR, "signing_key.pem")
class CertSetupTestCase(test.TestCase):
def setUp(self):
super(CertSetupTestCase, self).setUp()
CONF.signing.certfile = os.path.join(CERTDIR, 'signing_cert.pem')
CONF.signing.ca_certs = os.path.join(CERTDIR, "ca.pem")
CONF.signing.keyfile = os.path.join(KEYDIR, "signing_key.pem")
def test_create_certs(self):
ssl = openssl.ConfigurePKI()
ssl.run()
@ -50,3 +51,4 @@ class CertSetupTestCase(test.TestCase):
def tearDown(self):
shutil.rmtree(rootdir(SSLDIR))
super(CertSetupTestCase, self).tearDown()