From b547a3da506c049ceabe50895c01fb0e2f63fcfe Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Wed, 9 Sep 2015 14:19:09 -0500 Subject: [PATCH] make sure os_password is set for auth_plugins os_password is not set anywhere for auth_plugins. It is only set for keystone sessions. This makes sure that it gets set before being passed to Client. Closes-Bug: #1493977 Change-Id: I94421fd6fa58be391dfe8a9a14479bb4c17c5231 --- novaclient/shell.py | 3 +++ novaclient/tests/unit/test_shell.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/novaclient/shell.py b/novaclient/shell.py index 0f1dd98e1..93f7bbe0a 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -683,6 +683,9 @@ class OpenStackComputeShell(object): project_name=project_name, project_domain_id=args.os_project_domain_id, project_domain_name=args.os_project_domain_name) + else: + # set password for auth plugins + os_password = args.os_password if not do_help and not any([args.os_tenant_id, args.os_tenant_name, args.os_project_id, args.os_project_name]): diff --git a/novaclient/tests/unit/test_shell.py b/novaclient/tests/unit/test_shell.py index 56eb7f0c3..866d94ac0 100644 --- a/novaclient/tests/unit/test_shell.py +++ b/novaclient/tests/unit/test_shell.py @@ -58,6 +58,13 @@ FAKE_ENV4 = {'OS_USER_ID': 'user_id', 'OS_ENDPOINT_TYPE': 'osURL', 'OS_COMPUTE_API_VERSION': '2'} +FAKE_ENV5 = {'OS_USERNAME': 'username', + 'OS_PASSWORD': 'password', + 'OS_TENANT_NAME': 'tenant_name', + 'OS_AUTH_URL': 'http://no.where/v2.0', + 'OS_COMPUTE_API_VERSION': '2', + 'OS_AUTH_SYSTEM': 'rackspace'} + def _create_ver_list(versions): return {'versions': {'values': versions}} @@ -495,6 +502,15 @@ class ShellTest(utils.TestCase): self.shell, '--os-compute-api-version 2.3 list') + @mock.patch('novaclient.client.Client') + def test_custom_auth_plugin(self, mock_client): + self.make_env(fake_env=FAKE_ENV5) + self.shell('list') + password = mock_client.call_args_list[0][0][2] + client_kwargs = mock_client.call_args_list[0][1] + self.assertEqual(password, 'password') + self.assertIs(client_kwargs['session'], None) + class TestLoadVersionedActions(utils.TestCase):