From 0339a9a7f8c004b7e6df5c3d9dc49a69fcc3b357 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Wed, 16 Sep 2015 17:22:39 -0700 Subject: Convert auth kwargs '-' to '_' When passing in kwargs to _get_one_cloud we do not dive into the auth dict to convert '-' to '_'. Change-Id: I8ce12370b5fd4444ba17d724e7f8036a7b0d2784 --- os_client_config/config.py | 5 +++++ os_client_config/tests/test_config.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/os_client_config/config.py b/os_client_config/config.py index e8e76a5..100cf73 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -382,6 +382,11 @@ class OpenStackConfig(object): os_args = dict() new_args = dict() for (key, val) in iter(args.items()): + if type(args[key]) == dict: + # dive into the auth dict + new_args[key] = self._fix_args(args[key]) + continue + key = key.replace('-', '_') if key.startswith('os'): os_args[key[3:]] = val diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py index 36fe15d..9c9451d 100644 --- a/os_client_config/tests/test_config.py +++ b/os_client_config/tests/test_config.py @@ -106,6 +106,21 @@ class TestConfig(base.TestCase): cc = c.get_one_cloud('_test_cloud_hyphenated') self.assertEqual('12345', cc.auth['project_id']) + def test_get_one_cloud_with_hyphenated_kwargs(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + args = { + 'auth': { + 'username': 'testuser', + 'password': 'testpass', + 'project-id': '12345', + 'auth-url': 'http://example.com/v2', + }, + 'region_name': 'test-region', + } + cc = c.get_one_cloud(**args) + self.assertEqual('http://example.com/v2', cc.auth['auth_url']) + def test_no_environ(self): c = config.OpenStackConfig(config_files=[self.cloud_yaml], vendor_files=[self.vendor_yaml]) -- cgit v1.2.1