Reference identity plugins from __init__.py
Add the identity plugins to the __init__.py so they can be used without specifically importing the v2, v3 or generic files. This changes some usages of keystoneclient.discover to keystoneclient._discover as the generic plugins are available at the same time as other versioned plugins when keystoneclient.Client is imported. This is the reason we have _discover in the first place. Change-Id: I7b9bbc123aeac11d22b3a58395391d01af0427eb
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from keystoneclient.auth.identity import base
|
||||
from keystoneclient.auth.identity import generic
|
||||
from keystoneclient.auth.identity import v2
|
||||
from keystoneclient.auth.identity import v3
|
||||
|
||||
|
||||
BaseIdentityPlugin = base.BaseIdentityPlugin
|
||||
|
||||
V2Password = v2.Password
|
||||
V2Token = v2.Token
|
||||
|
||||
V3Password = v3.Password
|
||||
V3Token = v3.Token
|
||||
|
||||
Password = generic.Password
|
||||
Token = generic.Token
|
||||
|
||||
|
||||
__all__ = ['BaseIdentityPlugin',
|
||||
'Password',
|
||||
'Token',
|
||||
'V2Password',
|
||||
'V2Token',
|
||||
'V3Password',
|
||||
'V3Token']
|
||||
|
@@ -17,8 +17,8 @@ from oslo.config import cfg
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from keystoneclient import _discover
|
||||
from keystoneclient.auth.identity import base
|
||||
from keystoneclient import discover
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient.i18n import _, _LW
|
||||
|
||||
@@ -147,7 +147,7 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
|
||||
for data in disc_data:
|
||||
version = data['version']
|
||||
|
||||
if (discover.version_match((2,), version) and
|
||||
if (_discover.version_match((2,), version) and
|
||||
self._has_domain_scope):
|
||||
# NOTE(jamielennox): if there are domain parameters there
|
||||
# is no point even trying against v2 APIs.
|
||||
|
@@ -14,10 +14,10 @@ import logging
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from keystoneclient import _discover
|
||||
from keystoneclient.auth.identity.generic import base
|
||||
from keystoneclient.auth.identity import v2
|
||||
from keystoneclient.auth.identity import v3
|
||||
from keystoneclient import discover
|
||||
from keystoneclient import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -57,7 +57,7 @@ class Password(base.BaseGenericPlugin):
|
||||
self._user_domain_name = user_domain_name
|
||||
|
||||
def create_plugin(self, session, version, url, raw_status=None):
|
||||
if discover.version_match((2,), version):
|
||||
if _discover.version_match((2,), version):
|
||||
if self._user_domain_id or self._user_domain_name:
|
||||
# If you specify any domain parameters it won't work so quit.
|
||||
return None
|
||||
@@ -68,7 +68,7 @@ class Password(base.BaseGenericPlugin):
|
||||
password=self._password,
|
||||
**self._v2_params)
|
||||
|
||||
elif discover.version_match((3,), version):
|
||||
elif _discover.version_match((3,), version):
|
||||
return v3.Password(auth_url=url,
|
||||
user_id=self._user_id,
|
||||
username=self._username,
|
||||
|
@@ -14,10 +14,10 @@ import logging
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from keystoneclient import _discover
|
||||
from keystoneclient.auth.identity.generic import base
|
||||
from keystoneclient.auth.identity import v2
|
||||
from keystoneclient.auth.identity import v3
|
||||
from keystoneclient import discover
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@@ -39,10 +39,10 @@ class Token(base.BaseGenericPlugin):
|
||||
self._token = token
|
||||
|
||||
def create_plugin(self, session, version, url, raw_status=None):
|
||||
if discover.version_match((2,), version):
|
||||
if _discover.version_match((2,), version):
|
||||
return v2.Token(url, self._token, **self._v2_params)
|
||||
|
||||
elif discover.version_match((3,), version):
|
||||
elif _discover.version_match((3,), version):
|
||||
return v3.Token(url, self._token, **self._v3_params)
|
||||
|
||||
@classmethod
|
||||
|
@@ -19,8 +19,7 @@ import six
|
||||
|
||||
from keystoneclient import access
|
||||
from keystoneclient.auth import base
|
||||
from keystoneclient.auth.identity import v2
|
||||
from keystoneclient.auth.identity import v3
|
||||
from keystoneclient.auth import identity
|
||||
from keystoneclient import fixture
|
||||
from keystoneclient import session
|
||||
from keystoneclient.tests import utils
|
||||
@@ -254,7 +253,7 @@ class V3(CommonIdentityTests, utils.TestCase):
|
||||
kwargs.setdefault('auth_url', self.TEST_URL)
|
||||
kwargs.setdefault('username', self.TEST_USER)
|
||||
kwargs.setdefault('password', self.TEST_PASS)
|
||||
return v3.Password(**kwargs)
|
||||
return identity.V3Password(**kwargs)
|
||||
|
||||
|
||||
class V2(CommonIdentityTests, utils.TestCase):
|
||||
@@ -267,7 +266,7 @@ class V2(CommonIdentityTests, utils.TestCase):
|
||||
kwargs.setdefault('auth_url', self.TEST_URL)
|
||||
kwargs.setdefault('username', self.TEST_USER)
|
||||
kwargs.setdefault('password', self.TEST_PASS)
|
||||
return v2.Password(**kwargs)
|
||||
return identity.V2Password(**kwargs)
|
||||
|
||||
def get_auth_data(self, **kwargs):
|
||||
token = fixture.V2Token(**kwargs)
|
||||
@@ -317,9 +316,9 @@ class CatalogHackTests(utils.TestCase):
|
||||
base_url=self.V2_URL,
|
||||
json=token)
|
||||
|
||||
v2_auth = v2.Password(self.V2_URL,
|
||||
username=uuid.uuid4().hex,
|
||||
password=uuid.uuid4().hex)
|
||||
v2_auth = identity.V2Password(self.V2_URL,
|
||||
username=uuid.uuid4().hex,
|
||||
password=uuid.uuid4().hex)
|
||||
|
||||
sess = session.Session(auth=v2_auth)
|
||||
|
||||
@@ -343,9 +342,9 @@ class CatalogHackTests(utils.TestCase):
|
||||
|
||||
self.stub_url('GET', [], base_url=self.BASE_URL, status_code=404)
|
||||
|
||||
v2_auth = v2.Password(self.V2_URL,
|
||||
username=uuid.uuid4().hex,
|
||||
password=uuid.uuid4().hex)
|
||||
v2_auth = identity.V2Password(self.V2_URL,
|
||||
username=uuid.uuid4().hex,
|
||||
password=uuid.uuid4().hex)
|
||||
|
||||
sess = session.Session(auth=v2_auth)
|
||||
|
||||
|
Reference in New Issue
Block a user