Merge "Accept token and tenant_id for authenticating against KS"
This commit is contained in:
commit
84d110c63e
@ -457,6 +457,7 @@ def get_auth_keystone(auth_url, user, key, os_options, **kwargs):
|
|||||||
_ksclient = ksclient.Client(
|
_ksclient = ksclient.Client(
|
||||||
username=user,
|
username=user,
|
||||||
password=key,
|
password=key,
|
||||||
|
token=os_options.get('auth_token'),
|
||||||
tenant_name=os_options.get('tenant_name'),
|
tenant_name=os_options.get('tenant_name'),
|
||||||
tenant_id=os_options.get('tenant_id'),
|
tenant_id=os_options.get('tenant_id'),
|
||||||
user_id=os_options.get('user_id'),
|
user_id=os_options.get('user_id'),
|
||||||
|
@ -1804,9 +1804,10 @@ class TestConnection(MockHttpTest):
|
|||||||
|
|
||||||
# v2 auth
|
# v2 auth
|
||||||
timeouts = []
|
timeouts = []
|
||||||
|
os_options = {'tenant_name': 'tenant', 'auth_token': 'meta-token'}
|
||||||
conn = c.Connection(
|
conn = c.Connection(
|
||||||
'http://auth.example.com', 'user', 'password', timeout=33.0,
|
'http://auth.example.com', 'user', 'password', timeout=33.0,
|
||||||
os_options=dict(tenant_name='tenant'), auth_version=2.0)
|
os_options=os_options, auth_version=2.0)
|
||||||
fake_ks = FakeKeystone(endpoint='http://some_url', token='secret')
|
fake_ks = FakeKeystone(endpoint='http://some_url', token='secret')
|
||||||
with mock.patch('swiftclient.client._import_keystone_client',
|
with mock.patch('swiftclient.client._import_keystone_client',
|
||||||
_make_fake_import_keystone_client(fake_ks)):
|
_make_fake_import_keystone_client(fake_ks)):
|
||||||
@ -1821,6 +1822,10 @@ class TestConnection(MockHttpTest):
|
|||||||
# check timeout passed to HEAD for account
|
# check timeout passed to HEAD for account
|
||||||
self.assertEqual(timeouts, [33.0])
|
self.assertEqual(timeouts, [33.0])
|
||||||
|
|
||||||
|
# check token passed to keystone client
|
||||||
|
self.assertIn('token', fake_ks.calls[0])
|
||||||
|
self.assertEqual('meta-token', fake_ks.calls[0].get('token'))
|
||||||
|
|
||||||
def test_reset_stream(self):
|
def test_reset_stream(self):
|
||||||
|
|
||||||
class LocalContents(object):
|
class LocalContents(object):
|
||||||
|
@ -499,8 +499,8 @@ class FakeKeystone(object):
|
|||||||
self.token = token
|
self.token = token
|
||||||
|
|
||||||
class _Client(object):
|
class _Client(object):
|
||||||
def __init__(self, endpoint, token, **kwargs):
|
def __init__(self, endpoint, auth_token, **kwargs):
|
||||||
self.auth_token = token
|
self.auth_token = auth_token
|
||||||
self.endpoint = endpoint
|
self.endpoint = endpoint
|
||||||
self.service_catalog = self.ServiceCatalog(endpoint)
|
self.service_catalog = self.ServiceCatalog(endpoint)
|
||||||
|
|
||||||
@ -515,8 +515,8 @@ class FakeKeystone(object):
|
|||||||
|
|
||||||
def Client(self, **kwargs):
|
def Client(self, **kwargs):
|
||||||
self.calls.append(kwargs)
|
self.calls.append(kwargs)
|
||||||
self.client = self._Client(endpoint=self.endpoint, token=self.token,
|
self.client = self._Client(
|
||||||
**kwargs)
|
endpoint=self.endpoint, auth_token=self.token, **kwargs)
|
||||||
return self.client
|
return self.client
|
||||||
|
|
||||||
class Unauthorized(Exception):
|
class Unauthorized(Exception):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user