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
This commit is contained in:
parent
ef5dc3211d
commit
f7dc91dc11
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue