diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-02-10 19:39:53 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-02-10 19:39:53 +0000 |
commit | 84d110c63ecf671377d4b2338060e9b00da44a4f (patch) | |
tree | ba6a9ec1770977f63e43cb0959d23527ae2e421a | |
parent | d2ee01bfe4bc8ac864d8f10ef657e6ce45168d9c (diff) | |
parent | a175689418208e1c72d8db03d6b59893c73b2445 (diff) | |
download | python-swiftclient-84d110c63ecf671377d4b2338060e9b00da44a4f.tar.gz |
Merge "Accept token and tenant_id for authenticating against KS"
-rw-r--r-- | swiftclient/client.py | 1 | ||||
-rw-r--r-- | tests/unit/test_swiftclient.py | 7 | ||||
-rw-r--r-- | tests/unit/utils.py | 8 |
3 files changed, 11 insertions, 5 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py index 8844a53..4367fdc 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -457,6 +457,7 @@ def get_auth_keystone(auth_url, user, key, os_options, **kwargs): _ksclient = ksclient.Client( username=user, password=key, + token=os_options.get('auth_token'), tenant_name=os_options.get('tenant_name'), tenant_id=os_options.get('tenant_id'), user_id=os_options.get('user_id'), diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py index 5a6cbfa..95a46a5 100644 --- a/tests/unit/test_swiftclient.py +++ b/tests/unit/test_swiftclient.py @@ -1804,9 +1804,10 @@ class TestConnection(MockHttpTest): # v2 auth timeouts = [] + os_options = {'tenant_name': 'tenant', 'auth_token': 'meta-token'} conn = c.Connection( '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') with mock.patch('swiftclient.client._import_keystone_client', _make_fake_import_keystone_client(fake_ks)): @@ -1821,6 +1822,10 @@ class TestConnection(MockHttpTest): # check timeout passed to HEAD for account 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): class LocalContents(object): diff --git a/tests/unit/utils.py b/tests/unit/utils.py index 17e07ac..f8f5e90 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -499,8 +499,8 @@ class FakeKeystone(object): self.token = token class _Client(object): - def __init__(self, endpoint, token, **kwargs): - self.auth_token = token + def __init__(self, endpoint, auth_token, **kwargs): + self.auth_token = auth_token self.endpoint = endpoint self.service_catalog = self.ServiceCatalog(endpoint) @@ -515,8 +515,8 @@ class FakeKeystone(object): def Client(self, **kwargs): self.calls.append(kwargs) - self.client = self._Client(endpoint=self.endpoint, token=self.token, - **kwargs) + self.client = self._Client( + endpoint=self.endpoint, auth_token=self.token, **kwargs) return self.client class Unauthorized(Exception): |