diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2014-08-22 17:26:07 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2014-09-08 00:06:52 -0500 |
| commit | ae957b176e5918f41024c00cbc39ea371a0c37c6 (patch) | |
| tree | f087abc03197bdbfbfe07ab46cefde083a487c56 /openstackclient/tests/common/test_clientmanager.py | |
| parent | 3317e0abf694c56cb3b24bdf2b2b10577ea47f6b (diff) | |
| download | python-openstackclient-ae957b176e5918f41024c00cbc39ea371a0c37c6.tar.gz | |
Use Keystone client session.Session
This replaces the restapi requests wrapper with the one from Keystone client so
we can take advantage of the auth plugins.
As a first step only the v2 and v3 token and password plugins are supported.
This maintainis no changes to the command options or environment variables.
The next steps will include reworking the other API client interfaces to
fully utilize the single auth session.
Blueprint: ksc-session-auth
Change-Id: I47ec63291e4c3cf36c8061299a4764f60b36ab89
Diffstat (limited to 'openstackclient/tests/common/test_clientmanager.py')
| -rw-r--r-- | openstackclient/tests/common/test_clientmanager.py | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/openstackclient/tests/common/test_clientmanager.py b/openstackclient/tests/common/test_clientmanager.py index 5a25fa2c..0bb657ad 100644 --- a/openstackclient/tests/common/test_clientmanager.py +++ b/openstackclient/tests/common/test_clientmanager.py @@ -13,8 +13,10 @@ # under the License. # +import mock + +from keystoneclient.auth.identity import v2 as auth_v2 from openstackclient.common import clientmanager -from openstackclient.common import restapi from openstackclient.tests import utils @@ -25,6 +27,10 @@ USERNAME = "itchy" PASSWORD = "scratchy" SERVICE_CATALOG = {'sc': '123'} +API_VERSION = { + 'identity': '2.0', +} + def FakeMakeClient(instance): return FakeClient() @@ -52,6 +58,7 @@ class TestClientCache(utils.TestCase): self.assertEqual(c.attr, c.attr) +@mock.patch('keystoneclient.session.Session') class TestClientManager(utils.TestCase): def setUp(self): super(TestClientManager, self).setUp() @@ -59,12 +66,13 @@ class TestClientManager(utils.TestCase): clientmanager.ClientManager.identity = \ clientmanager.ClientCache(FakeMakeClient) - def test_client_manager_token(self): + def test_client_manager_token(self, mock): client_manager = clientmanager.ClientManager( token=AUTH_TOKEN, url=AUTH_URL, verify=True, + api_version=API_VERSION, ) self.assertEqual( @@ -76,19 +84,20 @@ class TestClientManager(utils.TestCase): client_manager._url, ) self.assertIsInstance( - client_manager.session, - restapi.RESTApi, + client_manager.auth, + auth_v2.Token, ) self.assertFalse(client_manager._insecure) self.assertTrue(client_manager._verify) - def test_client_manager_password(self): + def test_client_manager_password(self, mock): client_manager = clientmanager.ClientManager( auth_url=AUTH_URL, username=USERNAME, password=PASSWORD, verify=False, + api_version=API_VERSION, ) self.assertEqual( @@ -104,33 +113,20 @@ class TestClientManager(utils.TestCase): client_manager._password, ) self.assertIsInstance( - client_manager.session, - restapi.RESTApi, + client_manager.auth, + auth_v2.Password, ) self.assertTrue(client_manager._insecure) self.assertFalse(client_manager._verify) - # These need to stick around until the old-style clients are gone - self.assertEqual( - AUTH_REF, - client_manager.auth_ref, - ) - self.assertEqual( - AUTH_TOKEN, - client_manager._token, - ) - self.assertEqual( - SERVICE_CATALOG, - client_manager._service_catalog, - ) - - def test_client_manager_password_verify_ca(self): + def test_client_manager_password_verify_ca(self, mock): client_manager = clientmanager.ClientManager( auth_url=AUTH_URL, username=USERNAME, password=PASSWORD, verify='cafile', + api_version=API_VERSION, ) self.assertFalse(client_manager._insecure) |
