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
This commit is contained in:
Dean Troyer 2017-04-20 12:16:44 -05:00
parent aec3f4a831
commit 897e623252
1 changed files with 30 additions and 0 deletions

View File

@ -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()