Cache a new token when the existing token expires
The client.keyring_saver attribute was not being reliably set so the client._save_keys function was not storing any new tokens in the keyring. Add a unit test to ensure keyring_saver is being property set. Closes-Bug: #1397732 Change-Id: If0df24c819d71b4df302309d049079a867a11c76
This commit is contained in:
parent
773eea811d
commit
784a8b4a91
@ -703,6 +703,7 @@ class OpenStackComputeShell(object):
|
||||
# identifying keyring key can come from the underlying client
|
||||
if must_auth:
|
||||
helper = SecretsHelper(args, self.cs.client)
|
||||
self.cs.client.keyring_saver = helper
|
||||
if (auth_plugin and auth_plugin.opts and
|
||||
"os_password" not in auth_plugin.opts):
|
||||
use_pw = False
|
||||
@ -724,7 +725,6 @@ class OpenStackComputeShell(object):
|
||||
# We're missing something, so auth with user/pass and save
|
||||
# the result in our helper.
|
||||
self.cs.client.password = helper.password
|
||||
self.cs.client.keyring_saver = helper
|
||||
|
||||
try:
|
||||
# This does a couple of bits which are useful even if we've
|
||||
|
@ -379,6 +379,26 @@ class ShellTest(utils.TestCase):
|
||||
exc = self.assertRaises(RuntimeError, self.shell, '--timings list')
|
||||
self.assertEqual('Boom!', str(exc))
|
||||
|
||||
@mock.patch('novaclient.shell.SecretsHelper.tenant_id',
|
||||
return_value=True)
|
||||
@mock.patch('novaclient.shell.SecretsHelper.auth_token',
|
||||
return_value=True)
|
||||
@mock.patch('novaclient.shell.SecretsHelper.management_url',
|
||||
return_value=True)
|
||||
@mock.patch('novaclient.client.Client')
|
||||
@requests_mock.Mocker()
|
||||
def test_keyring_saver_helper(self, mock_client,
|
||||
sh_management_url_function,
|
||||
sh_auth_token_function,
|
||||
sh_tenant_id_function,
|
||||
m_requests):
|
||||
self.make_env(fake_env=FAKE_ENV)
|
||||
self.register_keystone_discovery_fixture(m_requests)
|
||||
self.shell('list')
|
||||
mock_client_instance = mock_client.return_value
|
||||
keyring_saver = mock_client_instance.client.keyring_saver
|
||||
self.assertIsInstance(keyring_saver, novaclient.shell.SecretsHelper)
|
||||
|
||||
|
||||
class ShellTestKeystoneV3(ShellTest):
|
||||
def make_env(self, exclude=None, fake_env=FAKE_ENV):
|
||||
|
Loading…
x
Reference in New Issue
Block a user