summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2016-01-13 13:37:14 -0500
committerMonty Taylor <mordred@inaugust.com>2016-01-13 13:43:59 -0500
commita8532f6c8d221628b697ddb0d134e2a000ef61d6 (patch)
treed88ba59e9227451f88ff98b296606cf1dc671c43
parent7e5496763522475bb07a377359d69454f1942e1b (diff)
downloados-client-config-a8532f6c8d221628b697ddb0d134e2a000ef61d6.tar.gz
Fix a precedence problem with auth arguments
With the current code, OS_TENANT_NAME will take precednece over --os-project-name beause OS_TENANT_NAME gets early-moved to config['auth']['project_name'], then when the argparse value gets put into config['project_name'] the auth fixing sees auth['project_name'] and thinks it should win. Change-Id: I97084ea221eb963f14d98cf550a04bbd5c7d954c
-rw-r--r--os_client_config/config.py4
-rw-r--r--os_client_config/tests/test_config.py10
2 files changed, 13 insertions, 1 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index d366307..7e56f61 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -447,7 +447,7 @@ class OpenStackConfig(object):
if 'cloud' in cloud:
del cloud['cloud']
- return self._fix_backwards_madness(cloud)
+ return cloud
def _expand_vendor_profile(self, name, cloud, our_cloud):
# Expand a profile if it exists. 'cloud' is an old confusing name
@@ -896,6 +896,8 @@ class OpenStackConfig(object):
if 'endpoint_type' in config:
config['interface'] = config.pop('endpoint_type')
+ config = self._fix_backwards_madness(config)
+
for key in BOOL_KEYS:
if key in config:
if type(config[key]) is not bool:
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py
index dce436a..1a16bd8 100644
--- a/os_client_config/tests/test_config.py
+++ b/os_client_config/tests/test_config.py
@@ -473,6 +473,16 @@ class TestConfigArgparse(base.TestCase):
opts, _remain = parser.parse_known_args(['--os-cloud', 'foo'])
self.assertEqual(opts.os_cloud, 'foo')
+ def test_env_argparse_precedence(self):
+ self.useFixture(fixtures.EnvironmentVariable(
+ 'OS_TENANT_NAME', 'tenants-are-bad'))
+ c = config.OpenStackConfig(config_files=[self.cloud_yaml],
+ vendor_files=[self.vendor_yaml])
+
+ cc = c.get_one_cloud(
+ cloud='envvars', argparse=self.options)
+ self.assertEqual(cc.auth['project_name'], 'project')
+
def test_argparse_default_no_token(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
vendor_files=[self.vendor_yaml])