From f557170404ec2b7f5c562e55ad212b6e444655c8 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Wed, 24 Aug 2016 17:37:07 +1000 Subject: [PATCH] Use AUTH_INTERFACE object from keystoneauth As keystoneclient and other services rely more on keystoneauth we should assume that keystoneauth is our base auth library, not keystoneclient and start to default to the objects provided from there. This will make it easier to remove these objects when the time comes. Use the AUTH_INTERFACE special object from keystoneauth in most places. This uses it everywhere that is actually session independant. For example it is not changed within the keystoneclient auth plugins themselves as they are directly compatible with keystoneauth. Change-Id: Ibc1224fca98c852106feb78c624b0b2f22b3a19d --- keystoneclient/base.py | 4 ++-- keystoneclient/discover.py | 4 ++-- keystoneclient/tests/unit/auth/test_access.py | 8 ++++---- keystoneclient/tests/unit/auth/test_identity_common.py | 5 +++-- keystoneclient/v2_0/tenants.py | 4 ++-- keystoneclient/v2_0/tokens.py | 4 ++-- keystoneclient/v3/auth.py | 7 ++++--- keystoneclient/v3/contrib/federation/base.py | 4 ++-- keystoneclient/v3/contrib/oauth1/access_tokens.py | 5 +++-- keystoneclient/v3/contrib/oauth1/request_tokens.py | 4 ++-- 10 files changed, 26 insertions(+), 23 deletions(-) diff --git a/keystoneclient/base.py b/keystoneclient/base.py index 3f13a6cc9..fc16298e0 100644 --- a/keystoneclient/base.py +++ b/keystoneclient/base.py @@ -22,11 +22,11 @@ import copy import functools import warnings +from keystoneauth1 import plugin from oslo_utils import strutils import six from six.moves import urllib -from keystoneclient import auth from keystoneclient import exceptions from keystoneclient.i18n import _ @@ -389,7 +389,7 @@ class CrudManager(Manager): return self._list( url_query, self.collection_key, - endpoint_filter={'interface': auth.AUTH_INTERFACE}) + endpoint_filter={'interface': plugin.AUTH_INTERFACE}) else: raise diff --git a/keystoneclient/discover.py b/keystoneclient/discover.py index d316fdc4f..85b0875ad 100644 --- a/keystoneclient/discover.py +++ b/keystoneclient/discover.py @@ -14,11 +14,11 @@ import logging import warnings from debtcollector import removals +from keystoneauth1 import plugin from positional import positional import six from keystoneclient import _discover -from keystoneclient.auth import base from keystoneclient import exceptions from keystoneclient.i18n import _ from keystoneclient import session as client_session @@ -173,7 +173,7 @@ class Discover(_discover.Discover): url = auth_url elif session.auth: self._use_endpoint = False - url = session.get_endpoint(interface=base.AUTH_INTERFACE) + url = session.get_endpoint(interface=plugin.AUTH_INTERFACE) if not url: raise exceptions.DiscoveryFailure( diff --git a/keystoneclient/tests/unit/auth/test_access.py b/keystoneclient/tests/unit/auth/test_access.py index 640fb7d94..f5f5843a8 100644 --- a/keystoneclient/tests/unit/auth/test_access.py +++ b/keystoneclient/tests/unit/auth/test_access.py @@ -13,9 +13,9 @@ import uuid from keystoneauth1 import fixture +from keystoneauth1 import plugin from keystoneclient import access -from keystoneclient import auth from keystoneclient.auth.identity import access as access_plugin from keystoneclient import session from keystoneclient.tests.unit import utils @@ -49,11 +49,11 @@ class AccessInfoPluginTests(utils.TestCase): def test_auth_url(self): auth_url = 'http://keystone.test.url' - plugin = self._plugin(auth_url=auth_url) + plug = self._plugin(auth_url=auth_url) self.assertEqual(auth_url, - plugin.get_endpoint(self.session, - interface=auth.AUTH_INTERFACE)) + plug.get_endpoint(self.session, + interface=plugin.AUTH_INTERFACE)) def test_invalidate(self): plugin = self._plugin() diff --git a/keystoneclient/tests/unit/auth/test_identity_common.py b/keystoneclient/tests/unit/auth/test_identity_common.py index 9fb0357f5..579367245 100644 --- a/keystoneclient/tests/unit/auth/test_identity_common.py +++ b/keystoneclient/tests/unit/auth/test_identity_common.py @@ -15,6 +15,7 @@ import datetime import uuid from keystoneauth1 import fixture +from keystoneauth1 import plugin import mock from oslo_utils import timeutils import six @@ -191,7 +192,7 @@ class CommonIdentityTests(object): s = session.Session(auth=a) auth_url = s.get_endpoint(service_type='compute', - interface=base.AUTH_INTERFACE) + interface=plugin.AUTH_INTERFACE) self.assertEqual(self.TEST_URL, auth_url) @@ -402,7 +403,7 @@ class CatalogHackTests(utils.TestCase): sess = session.Session(auth=v2_auth) - endpoint = sess.get_endpoint(interface=base.AUTH_INTERFACE, + endpoint = sess.get_endpoint(interface=plugin.AUTH_INTERFACE, version=(3, 0)) self.assertEqual(self.V3_URL, endpoint) diff --git a/keystoneclient/v2_0/tenants.py b/keystoneclient/v2_0/tenants.py index ff40acab9..d375da611 100644 --- a/keystoneclient/v2_0/tenants.py +++ b/keystoneclient/v2_0/tenants.py @@ -14,10 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. +from keystoneauth1 import plugin import six from six.moves import urllib -from keystoneclient import auth from keystoneclient import base from keystoneclient import exceptions @@ -124,7 +124,7 @@ class TenantManager(base.ManagerWithFind): try: tenant_list = self._list('/tenants%s' % query, 'tenants') except exceptions.EndpointNotFound: - endpoint_filter = {'interface': auth.AUTH_INTERFACE} + endpoint_filter = {'interface': plugin.AUTH_INTERFACE} tenant_list = self._list('/tenants%s' % query, 'tenants', endpoint_filter=endpoint_filter) diff --git a/keystoneclient/v2_0/tokens.py b/keystoneclient/v2_0/tokens.py index 2e185078f..b5f965724 100644 --- a/keystoneclient/v2_0/tokens.py +++ b/keystoneclient/v2_0/tokens.py @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. +from keystoneauth1 import plugin from positional import positional from keystoneclient import access -from keystoneclient import auth from keystoneclient import base from keystoneclient import exceptions from keystoneclient.i18n import _ @@ -65,7 +65,7 @@ class TokenManager(base.Manager): try: token_ref = self._post(*args, **kwargs) except exceptions.EndpointNotFound: - kwargs['endpoint_filter'] = {'interface': auth.AUTH_INTERFACE} + kwargs['endpoint_filter'] = {'interface': plugin.AUTH_INTERFACE} token_ref = self._post(*args, **kwargs) return token_ref diff --git a/keystoneclient/v3/auth.py b/keystoneclient/v3/auth.py index caad4acdb..6272dbc1a 100644 --- a/keystoneclient/v3/auth.py +++ b/keystoneclient/v3/auth.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -from keystoneclient import auth +from keystoneauth1 import plugin + from keystoneclient import base from keystoneclient import exceptions from keystoneclient.v3 import domains @@ -43,7 +44,7 @@ class AuthManager(base.Manager): 'projects', obj_class=Project) except exceptions.EndpointNotFound: - endpoint_filter = {'interface': auth.AUTH_INTERFACE} + endpoint_filter = {'interface': plugin.AUTH_INTERFACE} return self._list(self._PROJECTS_URL, 'projects', obj_class=Project, @@ -61,7 +62,7 @@ class AuthManager(base.Manager): 'domains', obj_class=Domain) except exceptions.EndpointNotFound: - endpoint_filter = {'interface': auth.AUTH_INTERFACE} + endpoint_filter = {'interface': plugin.AUTH_INTERFACE} return self._list(self._DOMAINS_URL, 'domains', obj_class=Domain, diff --git a/keystoneclient/v3/contrib/federation/base.py b/keystoneclient/v3/contrib/federation/base.py index 99c8d5a92..5e2e9e77e 100644 --- a/keystoneclient/v3/contrib/federation/base.py +++ b/keystoneclient/v3/contrib/federation/base.py @@ -12,9 +12,9 @@ import abc +from keystoneauth1 import plugin import six -from keystoneclient.auth import base as base_auth from keystoneclient import base from keystoneclient import exceptions @@ -34,7 +34,7 @@ class EntityManager(base.Manager): try: tenant_list = self._list(url, self.object_type) except exceptions.EndpointException: - endpoint_filter = {'interface': base_auth.AUTH_INTERFACE} + endpoint_filter = {'interface': plugin.AUTH_INTERFACE} tenant_list = self._list(url, self.object_type, endpoint_filter=endpoint_filter) return tenant_list diff --git a/keystoneclient/v3/contrib/oauth1/access_tokens.py b/keystoneclient/v3/contrib/oauth1/access_tokens.py index b2d0e31d6..37f194153 100644 --- a/keystoneclient/v3/contrib/oauth1/access_tokens.py +++ b/keystoneclient/v3/contrib/oauth1/access_tokens.py @@ -13,7 +13,8 @@ from __future__ import unicode_literals -from keystoneclient import auth +from keystoneauth1 import plugin + from keystoneclient import base from keystoneclient.v3.contrib.oauth1 import utils @@ -41,7 +42,7 @@ class AccessTokenManager(base.CrudManager): resource_owner_secret=request_secret, signature_method=oauth1.SIGNATURE_HMAC, verifier=verifier) - url = self.client.get_endpoint(interface=auth.AUTH_INTERFACE).rstrip( + url = self.client.get_endpoint(interface=plugin.AUTH_INTERFACE).rstrip( '/') url, headers, body = oauth_client.sign(url + endpoint, http_method='POST') diff --git a/keystoneclient/v3/contrib/oauth1/request_tokens.py b/keystoneclient/v3/contrib/oauth1/request_tokens.py index b33dd2e83..59f06bcba 100644 --- a/keystoneclient/v3/contrib/oauth1/request_tokens.py +++ b/keystoneclient/v3/contrib/oauth1/request_tokens.py @@ -13,9 +13,9 @@ from __future__ import unicode_literals +from keystoneauth1 import plugin from six.moves.urllib import parse as urlparse -from keystoneclient import auth from keystoneclient import base from keystoneclient.v3.contrib.oauth1 import utils @@ -63,7 +63,7 @@ class RequestTokenManager(base.CrudManager): client_secret=consumer_secret, signature_method=oauth1.SIGNATURE_HMAC, callback_uri="oob") - url = self.client.get_endpoint(interface=auth.AUTH_INTERFACE).rstrip( + url = self.client.get_endpoint(interface=plugin.AUTH_INTERFACE).rstrip( "/") url, headers, body = oauth_client.sign(url + endpoint, http_method='POST',