summaryrefslogtreecommitdiff
path: root/tests/functional/test_swiftclient.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hp.com>2014-09-23 17:52:51 +0100
committerChristian Schwede <cschwede@redhat.com>2015-06-04 12:54:43 +0000
commitf0aad4c364cb280c29033f7ac777a3a1b2e3bec0 (patch)
tree7c8f6c7480399f69b78d8ae5235214075349777d /tests/functional/test_swiftclient.py
parent259b434ae25e894e66f6561c5bbc3f34603f8fab (diff)
downloadpython-swiftclient-f0aad4c364cb280c29033f7ac777a3a1b2e3bec0.tar.gz
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
Diffstat (limited to 'tests/functional/test_swiftclient.py')
-rw-r--r--tests/functional/test_swiftclient.py69
1 files changed, 65 insertions, 4 deletions
diff --git a/tests/functional/test_swiftclient.py b/tests/functional/test_swiftclient.py
index 4b57f1d..f9965c5 100644
--- a/tests/functional/test_swiftclient.py
+++ b/tests/functional/test_swiftclient.py
@@ -45,6 +45,7 @@ class TestFunctional(testtools.TestCase):
'/etc/swift/test.conf')
config = configparser.SafeConfigParser({'auth_version': '1'})
config.read(config_file)
+ self.config = config
if config.has_section('func_test'):
auth_host = config.get('func_test', 'auth_host')
auth_port = config.getint('func_test', 'auth_port')
@@ -71,15 +72,20 @@ class TestFunctional(testtools.TestCase):
else:
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):
super(TestFunctional, self).setUp()
if self.skip_tests:
self.skipTest('SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG')
- self.conn = swiftclient.Connection(
- self.auth_url, self.account_username, self.password,
- auth_version=self.auth_version)
-
+ self.conn = self._get_connection()
self.conn.put_container(self.containername)
self.conn.put_container(self.containername_2)
self.conn.put_object(
@@ -286,3 +292,58 @@ class TestFunctional(testtools.TestCase):
def test_get_capabilities(self):
resp = self.conn.get_capabilities()
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()