Skip to content

Commit bdaf4b8

Browse files
committed
Fix wrong initialization of AuthPlugin for keystone v3
Ceilometerclient doesn't pass domain related arguments to AuthPlugin, which will cause keystoneclient v3 cannot be used properly. Change-Id: I2554a36f214c0eae61b7ba6b8580c41b8f8c6370 Closes-Bug: #1391122
1 parent 6222ee5 commit bdaf4b8

2 files changed

Lines changed: 42 additions & 7 deletions

File tree

‎ceilometerclient/client.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ def get_client(version, **kwargs):
261261
'cert_file': kwargs.get('os_cert'),
262262
'key_file': kwargs.get('os_key'),
263263
'token': kwargs.get('os_auth_token'),
264+
'user_domain_name': kwargs.get('os_user_domain_name'),
265+
'user_domain_id': kwargs.get('os_user_domain_id'),
266+
'project_domain_name': kwargs.get('os_project_domain_name'),
267+
'project_domain_id': kwargs.get('os_project_domain_id'),
264268
}
265269

266270
cli_kwargs.update(kwargs)
@@ -279,5 +283,9 @@ def get_auth_plugin(endpoint, **kwargs):
279283
username=kwargs.get('username'),
280284
password=kwargs.get('password'),
281285
tenant_name=kwargs.get('tenant_name'),
286+
user_domain_name=kwargs.get('user_domain_name'),
287+
user_domain_id=kwargs.get('user_domain_id'),
288+
project_domain_name=kwargs.get('project_domain_name'),
289+
project_domain_id=kwargs.get('project_domain_id')
282290
)
283291
return auth_plugin

‎ceilometerclient/tests/test_client.py‎

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
from ceilometerclient.v1 import client as v1client
2121
from ceilometerclient.v2 import client as v2client
2222

23-
FAKE_ENV = {'username': 'username',
24-
'password': 'password',
25-
'tenant_name': 'tenant_name',
26-
'auth_url': 'http://no.where',
27-
'ceilometer_url': 'http://no.where',
28-
'auth_plugin': 'fake_auth',
29-
'token': '1234'}
23+
FAKE_ENV = {
24+
'username': 'username',
25+
'password': 'password',
26+
'tenant_name': 'tenant_name',
27+
'auth_url': 'http://no.where',
28+
'ceilometer_url': 'http://no.where',
29+
'auth_plugin': 'fake_auth',
30+
'token': '1234',
31+
'user_domain_name': 'default',
32+
'project_domain_name': 'default',
33+
}
3034

3135

3236
class ClientTest(utils.BaseTestCase):
@@ -69,6 +73,29 @@ def test_client_without_auth_plugin(self):
6973
c = self.create_client(env, api_version=2, endpoint='fake_endpoint')
7074
self.assertIsInstance(c.auth_plugin, client.AuthPlugin)
7175

76+
def test_client_without_auth_plugin_keystone_v3(self):
77+
env = FAKE_ENV.copy()
78+
del env['auth_plugin']
79+
expected = {
80+
'username': 'username',
81+
'endpoint': None,
82+
'tenant_name': 'tenant_name',
83+
'service_type': None,
84+
'token': '1234',
85+
'endpoint_type': None,
86+
'auth_url': 'http://no.where',
87+
'tenant_id': None,
88+
'cacert': None,
89+
'password': 'password',
90+
'user_domain_name': 'default',
91+
'user_domain_id': None,
92+
'project_domain_name': 'default',
93+
'project_domain_id': None,
94+
}
95+
with mock.patch('ceilometerclient.client.AuthPlugin') as auth_plugin:
96+
self.create_client(env, api_version=2)
97+
auth_plugin.assert_called_with(**expected)
98+
7299
def test_client_with_auth_plugin(self):
73100
c = self.create_client(FAKE_ENV, api_version=2)
74101
self.assertIsInstance(c.auth_plugin, str)

0 commit comments

Comments
 (0)