diff options
author | Gregory Haynes <greg@greghaynes.net> | 2015-06-22 05:40:40 +0000 |
---|---|---|
committer | Gregory Haynes <greg@greghaynes.net> | 2015-06-22 05:40:40 +0000 |
commit | b631da86fee360533111eb9993e215d6cb64f522 (patch) | |
tree | 5edffa009680447299fbde8b54d7e42c3e043829 | |
parent | c66eaec73dcc2171fa733300242391a812885144 (diff) | |
download | os-client-config-b631da86fee360533111eb9993e215d6cb64f522.tar.gz |
Normalize project_name aliases
We arent normalizing keys before we check for project_name aliases,
therefore using hyphenated versions of the aliases fail.
Change-Id: I3e0aa9dc38bbafc3c3a205f08b65abbd4528e874
-rw-r--r-- | os_client_config/config.py | 6 | ||||
-rw-r--r-- | os_client_config/tests/base.py | 8 | ||||
-rw-r--r-- | os_client_config/tests/test_config.py | 7 |
3 files changed, 19 insertions, 2 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index bc8ab1e..d2bc816 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -253,8 +253,10 @@ class OpenStackConfig(object): def _fix_backwards_project(self, cloud): # Do the lists backwards so that project_name is the ultimate winner mappings = { - 'project_name': ('tenant_id', 'project_id', - 'tenant_name', 'project_name'), + 'project_name': ('tenant_id', 'tenant-id', + 'project_id', 'project-id', + 'tenant_name', 'tenant-name', + 'project_name', 'project-name'), } for target_key, possible_values in mappings.items(): target = None diff --git a/os_client_config/tests/base.py b/os_client_config/tests/base.py index 967f119..0a4f456 100644 --- a/os_client_config/tests/base.py +++ b/os_client_config/tests/base.py @@ -64,6 +64,14 @@ USER_CONF = { }, 'region_name': 'test-region', }, + '_test_cloud_hyphenated': { + 'auth': { + 'username': 'testuser', + 'password': 'testpass', + 'project-id': '12345', + }, + 'region_name': 'test-region', + } }, 'cache': {'max_age': 1}, } diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py index a6ba2ee..f23a6b9 100644 --- a/os_client_config/tests/test_config.py +++ b/os_client_config/tests/test_config.py @@ -87,6 +87,12 @@ class TestConfig(base.TestCase): cc = c.get_one_cloud('_test-cloud-int-project_') self.assertEqual('12345', cc.auth['project_name']) + def test_get_one_cloud_with_hyphenated_project_id(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + cc = c.get_one_cloud('_test_cloud_hyphenated') + self.assertEqual('12345', cc.auth['project_name']) + def test_no_environ(self): c = config.OpenStackConfig(config_files=[self.cloud_yaml], vendor_files=[self.vendor_yaml]) @@ -112,6 +118,7 @@ class TestConfig(base.TestCase): self.assertEqual( ['_test-cloud-int-project_', '_test-cloud_', + '_test_cloud_hyphenated', '_test_cloud_no_vendor', ], sorted(c.get_cloud_names())) |