Run functional tests using keystone auth options
Makes the existing functional tests run using three auth modes: tempauth (v1), keystone v2 and keystone v3. The latter uses an account in a non-default domain (which exists in devstack setup). This should help avoid regressions in handling different auth options. Change-Id: Ifee6a4fa418242892bf73eda5e2cad7b803b1bee
This commit is contained in:
parent
259b434ae2
commit
f0aad4c364
tests
@ -45,6 +45,7 @@ class TestFunctional(testtools.TestCase):
|
|||||||
'/etc/swift/test.conf')
|
'/etc/swift/test.conf')
|
||||||
config = configparser.SafeConfigParser({'auth_version': '1'})
|
config = configparser.SafeConfigParser({'auth_version': '1'})
|
||||||
config.read(config_file)
|
config.read(config_file)
|
||||||
|
self.config = config
|
||||||
if config.has_section('func_test'):
|
if config.has_section('func_test'):
|
||||||
auth_host = config.get('func_test', 'auth_host')
|
auth_host = config.get('func_test', 'auth_host')
|
||||||
auth_port = config.getint('func_test', 'auth_port')
|
auth_port = config.getint('func_test', 'auth_port')
|
||||||
@ -71,15 +72,20 @@ class TestFunctional(testtools.TestCase):
|
|||||||
else:
|
else:
|
||||||
self.skip_tests = True
|
self.skip_tests = True
|
||||||
|
|
||||||
|
def _get_connection(self):
|
||||||
|
"""
|
||||||
|
Subclasses may override to use different connection setup
|
||||||
|
"""
|
||||||
|
return swiftclient.Connection(
|
||||||
|
self.auth_url, self.account_username, self.password,
|
||||||
|
auth_version=self.auth_version)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestFunctional, self).setUp()
|
super(TestFunctional, self).setUp()
|
||||||
if self.skip_tests:
|
if self.skip_tests:
|
||||||
self.skipTest('SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG')
|
self.skipTest('SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG')
|
||||||
|
|
||||||
self.conn = swiftclient.Connection(
|
self.conn = self._get_connection()
|
||||||
self.auth_url, self.account_username, self.password,
|
|
||||||
auth_version=self.auth_version)
|
|
||||||
|
|
||||||
self.conn.put_container(self.containername)
|
self.conn.put_container(self.containername)
|
||||||
self.conn.put_container(self.containername_2)
|
self.conn.put_container(self.containername_2)
|
||||||
self.conn.put_object(
|
self.conn.put_object(
|
||||||
@ -286,3 +292,58 @@ class TestFunctional(testtools.TestCase):
|
|||||||
def test_get_capabilities(self):
|
def test_get_capabilities(self):
|
||||||
resp = self.conn.get_capabilities()
|
resp = self.conn.get_capabilities()
|
||||||
self.assertTrue(resp.get('swift'))
|
self.assertTrue(resp.get('swift'))
|
||||||
|
|
||||||
|
|
||||||
|
class TestUsingKeystone(TestFunctional):
|
||||||
|
"""
|
||||||
|
Repeat tests using os_options parameter to Connection.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _get_connection(self):
|
||||||
|
account = username = password = None
|
||||||
|
if self.auth_version not in ('2', '3'):
|
||||||
|
self.skipTest('SKIPPING KEYSTONE-SPECIFIC FUNCTIONAL TESTS')
|
||||||
|
try:
|
||||||
|
account = self.config.get('func_test', 'account')
|
||||||
|
username = self.config.get('func_test', 'username')
|
||||||
|
password = self.config.get('func_test', 'password')
|
||||||
|
except Exception:
|
||||||
|
self.skipTest('SKIPPING KEYSTONE-SPECIFIC FUNCTIONAL TESTS' +
|
||||||
|
' - NO CONFIG')
|
||||||
|
os_options = {'tenant_name': account}
|
||||||
|
return swiftclient.Connection(
|
||||||
|
self.auth_url, username, password, auth_version=self.auth_version,
|
||||||
|
os_options=os_options)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestUsingKeystone, self).setUp()
|
||||||
|
|
||||||
|
|
||||||
|
class TestUsingKeystoneV3(TestFunctional):
|
||||||
|
"""
|
||||||
|
Repeat tests using a keystone user with domain specified.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _get_connection(self):
|
||||||
|
account = username = password = project_domain = user_domain = None
|
||||||
|
if self.auth_version != '3':
|
||||||
|
self.skipTest('SKIPPING KEYSTONE-V3-SPECIFIC FUNCTIONAL TESTS')
|
||||||
|
try:
|
||||||
|
account = self.config.get('func_test', 'account4')
|
||||||
|
username = self.config.get('func_test', 'username4')
|
||||||
|
user_domain = self.config.get('func_test', 'domain4')
|
||||||
|
project_domain = self.config.get('func_test', 'domain4')
|
||||||
|
password = self.config.get('func_test', 'password4')
|
||||||
|
except Exception:
|
||||||
|
self.skipTest('SKIPPING KEYSTONE-V3-SPECIFIC FUNCTIONAL TESTS' +
|
||||||
|
' - NO CONFIG')
|
||||||
|
|
||||||
|
os_options = {'project_name': account,
|
||||||
|
'project_domain_name': project_domain,
|
||||||
|
'user_domain_name': user_domain}
|
||||||
|
return swiftclient.Connection(self.auth_url, username, password,
|
||||||
|
auth_version=self.auth_version,
|
||||||
|
os_options=os_options)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestUsingKeystoneV3, self).setUp()
|
||||||
|
@ -16,3 +16,11 @@ auth_prefix = /auth/
|
|||||||
account = test
|
account = test
|
||||||
username = tester
|
username = tester
|
||||||
password = testing
|
password = testing
|
||||||
|
|
||||||
|
# Another user is required for keystone v3 specific tests.
|
||||||
|
# Account must be in a non-default domain.
|
||||||
|
# (Suffix '4' is used to be consistent with swift functional test config).
|
||||||
|
#account4 = test4
|
||||||
|
#username4 = tester4
|
||||||
|
#password4 = testing4
|
||||||
|
#domain4 = test-domain
|
||||||
|
Loading…
x
Reference in New Issue
Block a user