Allow for authentication in functional tests

Allow for authenticating when running zaqarclient's functional tests so
that they can also be used in the gate and keystone mechanism can be
tested functionally

Change-Id: I0f1fd4374125d4b489f3804b79a672b39c714421
This commit is contained in:
Flavio Percoco 2015-09-08 09:27:43 +02:00
parent b35689d749
commit 863371ba46
2 changed files with 28 additions and 2 deletions

View File

@ -23,4 +23,4 @@ class QueuesV1_1PoolHttpFunctionalTest(pool.QueuesV1_1PoolFunctionalTest):
is_functional = True
transport_cls = http.HttpTransport
url = 'http://127.0.0.1:8888'
version = 1
version = 1.1

View File

@ -18,7 +18,9 @@ import os
import fixtures
import testtools
_RUN_FUNCTIONAL = os.environ.get('ZAQARCLIENT_TEST_FUNCTIONAL', False)
_USE_AUTHENTICATION = os.environ.get('ZAQARCLIENT_AUTH_FUNCTIONAL', False)
_RUN_FUNCTIONAL = os.environ.get('ZAQARCLIENT_TEST_FUNCTIONAL',
_USE_AUTHENTICATION)
class TestBase(testtools.TestCase):
@ -45,6 +47,30 @@ class TestBase(testtools.TestCase):
if not _RUN_FUNCTIONAL and self.is_functional:
self.skipTest('Functional tests disabled')
elif self.is_functional and _USE_AUTHENTICATION:
self._setup_auth_params()
def _setup_auth_params(self):
# NOTE(flaper87): Hard-code the backend for now since it's the
# only one we support
self.conf['auth_opts']['backend'] = 'keystone'
if 'OS_TOKEN' in os.environ and 'OS_AUTH_URL' in os.environ:
options = {'os_token': os.environ['OS_TOKEN'],
'os_auth_url': os.environ['OS_AUTH_URL']}
else:
project_id = os.environ.get('OS_PROJECT_ID',
os.environ.get('OS_TENANT_ID', ''))
project_name = os.environ.get('OS_PROJECT_NAME',
os.environ.get('OS_TENANT_NAME', ''))
options = {'os_username': os.environ['OS_USERNAME'],
'os_password': os.environ['OS_PASSWORD'],
'os_project_id': project_id,
'os_project_name': project_name,
'os_auth_url': os.environ['OS_AUTH_URL'],
'insecure': ''}
self.conf['auth_opts'].setdefault('options', {}).update(options)
def config(self, group=None, **kw):
"""Override some configuration values.