diff options
author | Jeremy Liu <liujiong@gohighsec.com> | 2017-05-17 22:42:26 +0800 |
---|---|---|
committer | Jeremy Liu <liujiong@gohighsec.com> | 2017-05-18 10:32:07 +0800 |
commit | ac10cb7ff1c2807fc3729f7ed5815e105a02c7f4 (patch) | |
tree | 99dbe32d4fd00085aaea490551c71fade5b6573a | |
parent | ab2684f5d07caec4c36c84f790ee28f8094a32ff (diff) | |
download | python-barbicanclient-ac10cb7ff1c2807fc3729f7ed5815e105a02c7f4.tar.gz |
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
-rw-r--r-- | barbicanclient/barbican.py | 25 | ||||
-rw-r--r-- | etc/functional_tests.conf | 3 | ||||
-rw-r--r-- | functionaltests/cli/v1/behaviors/base_behaviors.py | 3 | ||||
-rw-r--r-- | functionaltests/client/base.py | 6 | ||||
-rw-r--r-- | functionaltests/client/test_client_connectivity.py | 6 | ||||
-rw-r--r-- | functionaltests/common/config.py | 3 |
6 files changed, 20 insertions, 26 deletions
diff --git a/barbicanclient/barbican.py b/barbicanclient/barbican.py index edc13f5..e26eb34 100644 --- a/barbicanclient/barbican.py +++ b/barbicanclient/barbican.py @@ -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) diff --git a/etc/functional_tests.conf b/etc/functional_tests.conf index a0612ac..9bff4ad 100644 --- a/etc/functional_tests.conf +++ b/etc/functional_tests.conf @@ -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 diff --git a/functionaltests/cli/v1/behaviors/base_behaviors.py b/functionaltests/cli/v1/behaviors/base_behaviors.py index a3da5ae..4d24c5b 100644 --- a/functionaltests/cli/v1/behaviors/base_behaviors.py +++ b/functionaltests/cli/v1/behaviors/base_behaviors.py @@ -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]) diff --git a/functionaltests/client/base.py b/functionaltests/client/base.py index 2664b15..dbec9d1 100644 --- a/functionaltests/client/base.py +++ b/functionaltests/client/base.py @@ -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, diff --git a/functionaltests/client/test_client_connectivity.py b/functionaltests/client/test_client_connectivity.py index a3c01bb..5f3df4f 100644 --- a/functionaltests/client/test_client_connectivity.py +++ b/functionaltests/client/test_client_connectivity.py @@ -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, diff --git a/functionaltests/common/config.py b/functionaltests/common/config.py index 39f7b0a..4cee242 100644 --- a/functionaltests/common/config.py +++ b/functionaltests/common/config.py @@ -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'), |