diff options
author | Thiago Paiva <thiagop@lsd.ufcg.edu.br> | 2015-10-29 12:45:48 -0300 |
---|---|---|
committer | Pavel Kholkin <pkholkin@mirantis.com> | 2016-08-26 11:41:12 +0300 |
commit | f7dc91dc110f6526886ba9bb27215f6078c94455 (patch) | |
tree | adbf95c91ab114693955b51e397ce360a1da3c8d | |
parent | ef5dc3211dc5393c5e050f5b607b9c7884e508d2 (diff) | |
download | python-novaclient-f7dc91dc110f6526886ba9bb27215f6078c94455.tar.gz |
Fixes TypeError on Client instantiation
When instantiating novaclient with kwargs or named attributes, the 'password'
field is duplicated due to an overwrite on the __init__ method of Client v2.
This patch pops out the password field when it's passed and no api_key is
provided.
Co-Authored-By: Pavel Kholkin <pkholkin@mirantis.com>
Closes-bug: #1511417
Change-Id: Id8310eccef5f0f9a2983e25dd35541d1eb0efe86
-rw-r--r-- | novaclient/tests/unit/test_client.py | 6 | ||||
-rw-r--r-- | novaclient/v2/client.py | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/novaclient/tests/unit/test_client.py b/novaclient/tests/unit/test_client.py index bf89a00e..b256f8f7 100644 --- a/novaclient/tests/unit/test_client.py +++ b/novaclient/tests/unit/test_client.py @@ -229,6 +229,12 @@ class ClientTest(utils.TestCase): self.assertTrue(fake_client.open_session.called) self.assertTrue(fake_client.close_session.called) + def test_client_with_password_in_args_and_kwargs(self): + # check that TypeError is not raised during instantiation of Client + cs = novaclient.client.Client("2", "user", "password", "project_id", + password='pass') + self.assertEqual('pass', cs.client.password) + def test_get_password_simple(self): cs = novaclient.client.HTTPClient("user", "password", "", "") cs.password_func = mock.Mock() diff --git a/novaclient/v2/client.py b/novaclient/v2/client.py index a43a3825..d37ebb62 100644 --- a/novaclient/v2/client.py +++ b/novaclient/v2/client.py @@ -125,7 +125,7 @@ class Client(object): # tenant name) and tenant_id is a UUID (what the Nova API # often refers to as a project_id or tenant_id). - password = api_key + password = kwargs.pop('password', api_key) self.projectid = project_id self.tenant_id = tenant_id self.user_id = user_id |