From 897e62325256f04980ece03e0f490353a35eb88a Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 20 Apr 2017 12:16:44 -0500 Subject: [PATCH] Add token auth test Add a ClientManager test for Token authentication (specifically keystoneauth's admin_token) that got dropped in the move from OSC because OSC uses its own token_endpoint plugin loader, but creates the same AdminToken object. This would have prevented the issues seen with the merging of https://review.openstack.org/452711 that were subsequently reverted in https://review.openstack.org/458586. Change-Id: I516682057d759d4becd8f6675cf7fa262d224eb9 --- osc_lib/tests/test_clientmanager.py | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/osc_lib/tests/test_clientmanager.py b/osc_lib/tests/test_clientmanager.py index 7ebe1a6..22789fe 100644 --- a/osc_lib/tests/test_clientmanager.py +++ b/osc_lib/tests/test_clientmanager.py @@ -21,6 +21,7 @@ from keystoneauth1 import exceptions as ksa_exceptions from keystoneauth1.identity import generic as generic_plugin from keystoneauth1.identity.v3 import k2k from keystoneauth1 import loading +from keystoneauth1 import token_endpoint from os_client_config import cloud_config from osc_lib.api import auth @@ -71,6 +72,35 @@ class TestClientCache(utils.TestCase): class TestClientManager(utils.TestClientManager): + def test_client_manager_admin_token(self): + token_auth = { + 'endpoint': fakes.AUTH_URL, + 'token': fakes.AUTH_TOKEN, + } + client_manager = self._make_clientmanager( + auth_args=token_auth, + auth_plugin_name='admin_token', + ) + + self.assertEqual( + fakes.AUTH_URL, + client_manager._cli_options.config['auth']['endpoint'], + ) + self.assertEqual( + fakes.AUTH_TOKEN, + client_manager.auth.get_token(None), + ) + self.assertIsInstance( + client_manager.auth, + token_endpoint.Token, + ) + # NOTE(dtroyer): This is intentionally not assertFalse() as the return + # value from is_service_available() may be == None + self.assertNotEqual( + False, + client_manager.is_service_available('network'), + ) + def test_client_manager_password(self): client_manager = self._make_clientmanager()