summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2016-08-11 08:14:39 -0500
committerMonty Taylor <mordred@inaugust.com>2016-08-11 08:14:39 -0500
commita6840f69ff5644065816309776365adccf017772 (patch)
tree6a2a767aa1eb4493ceecd5f54235db81ca185e51
parent600a638e74d89af55fceaf4017f70269ae6e4f3c (diff)
downloados-client-config-a6840f69ff5644065816309776365adccf017772.tar.gz
Pop domain-id from the config if we infer values
If the user specifies a project_{name,id}, then we currently infer that a domain_{name,id} is meant to be shorthand for user_domain_{name,id} and project_domain_{name,id}. However, in other contexts, domain_id is a perfectly valid value to pass to the auth plugins - such as when doing domain-scoped activities. The problem that was uncovered by the correction of argument precedence is that we didn't pop the domain-id out of the root config dict, so if a user set OS_DOMAIN_ID in the environment, we were happily setting the user and project versions, but then leaving domain_id set as well. This then meant that when we do the pass to pull valid arguments from the root dict to the auth dict, we also pulled in domain_id - which led to the error: AuthorizationFailure: Authentication cannot be scoped to multiple targets. Pick one of: project, domain, trust or unscoped Popping the value from the root dict causes the things to work as documented. Change-Id: I6d208e5ec4115d2e72d30b2fedc90a81ea754d5a
-rw-r--r--os_client_config/config.py1
-rw-r--r--os_client_config/tests/test_config.py2
2 files changed, 3 insertions, 0 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index 37a31f8..7fa670f 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -562,6 +562,7 @@ class OpenStackConfig(object):
for key in possible_values:
if target_key in cloud['auth'] and key not in cloud['auth']:
cloud['auth'][key] = cloud['auth'][target_key]
+ cloud.pop(target_key, None)
cloud['auth'].pop(target_key, None)
return cloud
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py
index 5008878..baa35cd 100644
--- a/os_client_config/tests/test_config.py
+++ b/os_client_config/tests/test_config.py
@@ -102,6 +102,7 @@ class TestConfig(base.TestCase):
self.assertEqual('123456789', cc.auth['project_domain_id'])
self.assertNotIn('domain_id', cc.auth)
self.assertNotIn('domain-id', cc.auth)
+ self.assertNotIn('domain_id', cc)
def test_get_one_cloud_domain_scoped(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
@@ -118,6 +119,7 @@ class TestConfig(base.TestCase):
self.assertEqual('awesome-domain', cc.auth['user_domain_id'])
self.assertEqual('awesome-domain', cc.auth['project_domain_id'])
self.assertNotIn('domain_id', cc.auth)
+ self.assertNotIn('domain_id', cc)
def test_get_one_cloud_with_hyphenated_project_id(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],