Remove Rackspace auth references from troveclient
Removing the Rackspace Auth references that are not supported by an openstack deployment. Co-Authored-By: Craig Vyvial <cp16net@gmail.com> Change-Id: I7e630a77eaeb31de0962b31bc2f86becf2975dd8 Closes-Bug: #1401804
This commit is contained in:
parent
f7031a7e9a
commit
7f2f18ab33
|
@ -76,7 +76,6 @@ call to the constructor.
|
|||
client.authenticate()
|
||||
|
||||
The default authentication strategy assumes a Keystone compliant auth system.
|
||||
For Rackspace auth, use the keyword argument "auth_strategy='rax'".
|
||||
|
||||
|
||||
Versions
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- Remove all the rax references in the client. Use the rackspace plugin for
|
||||
auth if you want to use rax auth with troveclient. Bug 1401804
|
|
@ -24,10 +24,6 @@ def get_authenticator_cls(cls_or_name):
|
|||
elif isinstance(cls_or_name, six.string_types):
|
||||
if cls_or_name == "keystone":
|
||||
return KeyStoneV2Authenticator
|
||||
elif cls_or_name == "rax":
|
||||
return RaxAuthenticator
|
||||
elif cls_or_name == "rax2":
|
||||
return RaxAuthenticator2
|
||||
elif cls_or_name == "auth1.1":
|
||||
return Auth1_1
|
||||
elif cls_or_name == "fake":
|
||||
|
@ -133,37 +129,6 @@ class Auth1_1(Authenticator):
|
|||
return self._authenticate(auth_url, body, root_key='auth')
|
||||
|
||||
|
||||
class RaxAuthenticator(Authenticator):
|
||||
def authenticate(self):
|
||||
if self.url is None:
|
||||
raise exceptions.AuthUrlNotGiven()
|
||||
return self._rax_auth(self.url)
|
||||
|
||||
def _rax_auth(self, url):
|
||||
"""Authenticate against the Rackspace auth service."""
|
||||
body = {'auth': {
|
||||
'RAX-KSKEY:apiKeyCredentials': {
|
||||
'username': self.username,
|
||||
'apiKey': self.password,
|
||||
'tenantName': self.tenant}
|
||||
}
|
||||
}
|
||||
|
||||
return self._authenticate(self.url, body)
|
||||
|
||||
|
||||
class RaxAuthenticator2(RaxAuthenticator):
|
||||
"""Rax specific authenticator.
|
||||
|
||||
Necessary to be able to call using the same auth url as the new client
|
||||
uses for Rax auth.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RaxAuthenticator2, self).__init__(*args, **kwargs)
|
||||
self.url = "%s/tokens" % self.url
|
||||
|
||||
|
||||
class FakeAuth(Authenticator):
|
||||
"""Useful for faking auth."""
|
||||
|
||||
|
|
|
@ -161,8 +161,8 @@ class CliOptions(object):
|
|||
add_option("tenant_id",
|
||||
help="Tenant Id associated with the account.")
|
||||
add_option("auth_type",
|
||||
help="Auth type to support different auth environments, \
|
||||
Supported values are 'keystone', 'rax'.")
|
||||
help="Auth type to support different auth environments, "
|
||||
"Supported value are 'keystone'.")
|
||||
add_option("service_type",
|
||||
help="Service type is a name associated for the catalog.")
|
||||
add_option("service_name",
|
||||
|
|
|
@ -51,7 +51,6 @@ class AuthenticatorTest(testtools.TestCase):
|
|||
|
||||
def test_get_authenticator_cls(self):
|
||||
class_list = (auth.KeyStoneV2Authenticator,
|
||||
auth.RaxAuthenticator,
|
||||
auth.Auth1_1,
|
||||
auth.FakeAuth)
|
||||
|
||||
|
@ -59,7 +58,6 @@ class AuthenticatorTest(testtools.TestCase):
|
|||
self.assertEqual(c, auth.get_authenticator_cls(c))
|
||||
|
||||
class_names = {"keystone": auth.KeyStoneV2Authenticator,
|
||||
"rax": auth.RaxAuthenticator,
|
||||
"auth1.1": auth.Auth1_1,
|
||||
"fake": auth.FakeAuth}
|
||||
|
||||
|
@ -200,55 +198,6 @@ class Auth1_1Test(testtools.TestCase):
|
|||
self.assertEqual('auth', root_key)
|
||||
|
||||
|
||||
class RaxAuthenticatorTest(testtools.TestCase):
|
||||
|
||||
def test_authenticate(self):
|
||||
# url is None
|
||||
check_url_none(self, auth.RaxAuthenticator)
|
||||
|
||||
# url is not None, so it must not throw exception
|
||||
url = "test_url"
|
||||
authObj = auth.RaxAuthenticator(url=url,
|
||||
type=auth.RaxAuthenticator,
|
||||
client=None, username=None,
|
||||
password=None, tenant=None)
|
||||
|
||||
def side_effect_func(url):
|
||||
return url
|
||||
|
||||
mock_obj = mock.Mock()
|
||||
mock_obj.side_effect = side_effect_func
|
||||
authObj._rax_auth = mock_obj
|
||||
r = authObj.authenticate()
|
||||
self.assertEqual(url, r)
|
||||
|
||||
def test__rax_auth(self):
|
||||
username = "trove_user"
|
||||
password = "trove_password"
|
||||
tenant = "tenant"
|
||||
authObj = auth.RaxAuthenticator(url=None,
|
||||
type=auth.RaxAuthenticator,
|
||||
client=None, username=username,
|
||||
password=password, tenant=tenant)
|
||||
|
||||
def side_effect_func(url, body):
|
||||
return body
|
||||
|
||||
mock_obj = mock.Mock()
|
||||
mock_obj.side_effect = side_effect_func
|
||||
authObj._authenticate = mock_obj
|
||||
body = authObj._rax_auth(mock.Mock())
|
||||
|
||||
v = body['auth']['RAX-KSKEY:apiKeyCredentials']['username']
|
||||
self.assertEqual(username, v)
|
||||
|
||||
v = body['auth']['RAX-KSKEY:apiKeyCredentials']['apiKey']
|
||||
self.assertEqual(password, v)
|
||||
|
||||
v = body['auth']['RAX-KSKEY:apiKeyCredentials']['tenantName']
|
||||
self.assertEqual(tenant, v)
|
||||
|
||||
|
||||
class FakeAuthTest(testtools.TestCase):
|
||||
|
||||
def test_authenticate(self):
|
||||
|
|
Loading…
Reference in New Issue