Use generic auth plugin instead of specific version
Switch both client and functional test to use generic auth plugin. Also keep keystone auth_uri as one option so we needn't add extra version to the endpoint and let keystoneauth handle this. Change-Id: I5535d4d459496eec9052131b43615e6056e249e8 Closes-bug: #1691480
This commit is contained in:
@@ -26,8 +26,7 @@ from cliff import command
|
||||
from cliff import commandmanager
|
||||
from cliff import complete
|
||||
from cliff import help
|
||||
from keystoneauth1.identity import v2
|
||||
from keystoneauth1.identity import v3
|
||||
from keystoneauth1 import identity
|
||||
from keystoneauth1 import loading
|
||||
from keystoneauth1 import session
|
||||
|
||||
@@ -132,19 +131,17 @@ class Barbican(app.App):
|
||||
kwargs = self.build_kwargs_based_on_version(args, api_version)
|
||||
kwargs.update(kwargs_dict)
|
||||
|
||||
if api_version in _IDENTITY_API_VERSION_2:
|
||||
method = v2.Token if auth_type == 'token' else v2.Password
|
||||
else:
|
||||
if not api_version or api_version not in _IDENTITY_API_VERSION_3:
|
||||
self.stderr.write(
|
||||
"WARNING: The identity version <{0}> is not in supported "
|
||||
"versions <{1}>, falling back to <{2}>.".format(
|
||||
api_version,
|
||||
_IDENTITY_API_VERSION_2 + _IDENTITY_API_VERSION_3,
|
||||
_DEFAULT_IDENTITY_API_VERSION
|
||||
)
|
||||
_supported_version = _IDENTITY_API_VERSION_2 + _IDENTITY_API_VERSION_3
|
||||
if not api_version or api_version not in _supported_version:
|
||||
self.stderr.write(
|
||||
"WARNING: The identity version <{0}> is not in supported "
|
||||
"versions <{1}>, falling back to <{2}>.".format(
|
||||
api_version,
|
||||
_IDENTITY_API_VERSION_2 + _IDENTITY_API_VERSION_3,
|
||||
_DEFAULT_IDENTITY_API_VERSION
|
||||
)
|
||||
method = v3.Token if auth_type == 'token' else v3.Password
|
||||
)
|
||||
method = identity.Token if auth_type == 'token' else identity.Password
|
||||
|
||||
auth = method(**kwargs)
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ project_domain_name=Default
|
||||
|
||||
[identity]
|
||||
# Replace these with values that represent your identity configuration
|
||||
uri=http://localhost/identity/v2.0
|
||||
uri_v3=http://localhost/identity/v3
|
||||
uri=http://localhost/identity
|
||||
auth_version=v3
|
||||
|
||||
username=admin
|
||||
|
||||
@@ -48,7 +48,6 @@ class BaseBehaviors(object):
|
||||
"""
|
||||
|
||||
if 'v3' in CONF.identity.auth_version.lower():
|
||||
arg_list.extend(['--os-auth-url', CONF.identity.uri_v3])
|
||||
arg_list.extend(['--os-project-name',
|
||||
CONF.keymanager.project_name])
|
||||
# NOTE(jaosorior): Should we add the user_domain_name to the
|
||||
@@ -60,10 +59,10 @@ class BaseBehaviors(object):
|
||||
CONF.keymanager.project_domain_name])
|
||||
arg_list.extend(['--os-identity-api-version', '3'])
|
||||
else:
|
||||
arg_list.extend(['--os-auth-url', CONF.identity.uri])
|
||||
arg_list.extend(['--os-tenant-name', CONF.keymanager.project_name])
|
||||
arg_list.extend(['--os-identity-api-version', '2.0'])
|
||||
|
||||
arg_list.extend(['--os-auth-url', CONF.identity.uri])
|
||||
arg_list.extend(['--os-username', CONF.keymanager.username,
|
||||
'--os-password', CONF.keymanager.password])
|
||||
|
||||
|
||||
@@ -30,14 +30,14 @@ class TestCase(BaseTestCase):
|
||||
super(TestCase, self).setUp()
|
||||
|
||||
if 'v2' in CONF.identity.auth_version:
|
||||
self.auth = identity.v2.Password(
|
||||
self.auth = identity.Password(
|
||||
auth_url=CONF.identity.uri,
|
||||
username=CONF.keymanager.username,
|
||||
password=CONF.keymanager.password,
|
||||
tenant_name=CONF.keymanager.project_name)
|
||||
else:
|
||||
self.auth = identity.v3.Password(
|
||||
auth_url=CONF.identity.uri_v3,
|
||||
self.auth = identity.Password(
|
||||
auth_url=CONF.identity.uri,
|
||||
username=CONF.keymanager.username,
|
||||
user_domain_name=CONF.identity.domain_name,
|
||||
password=CONF.keymanager.password,
|
||||
|
||||
@@ -30,14 +30,14 @@ class WhenTestingClientConnectivity(BaseTestCase):
|
||||
def setUpClass(cls):
|
||||
super(WhenTestingClientConnectivity, cls).setUpClass()
|
||||
if 'v2' in CONF.identity.auth_version:
|
||||
cls.auth = identity.v2.Password(
|
||||
cls.auth = identity.Password(
|
||||
auth_url=CONF.identity.uri,
|
||||
username=CONF.keymanager.username,
|
||||
password=CONF.keymanager.password,
|
||||
tenant_name=CONF.keymanager.project_name)
|
||||
else:
|
||||
cls.auth = identity.v3.Password(
|
||||
auth_url=CONF.identity.uri_v3,
|
||||
cls.auth = identity.Password(
|
||||
auth_url=CONF.identity.uri,
|
||||
username=CONF.keymanager.username,
|
||||
user_domain_name=CONF.identity.domain_name,
|
||||
password=CONF.keymanager.password,
|
||||
|
||||
@@ -26,8 +26,7 @@ def setup_config(config_file=''):
|
||||
|
||||
identity_group = cfg.OptGroup(name='identity')
|
||||
identity_options = [
|
||||
cfg.StrOpt('uri', default='http://localhost/identity/v2.0'),
|
||||
cfg.StrOpt('uri_v3', default='http://localhost/identity/v3'),
|
||||
cfg.StrOpt('uri', default='http://localhost/identity'),
|
||||
cfg.StrOpt('auth_version', default='v3'),
|
||||
cfg.StrOpt('username', default='admin'),
|
||||
cfg.StrOpt('password', default='secretadmin'),
|
||||
|
||||
Reference in New Issue
Block a user