summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-04 17:10:54 +0000
committerGerrit Code Review <review@openstack.org>2017-03-04 17:10:54 +0000
commitd6908f93a732adfb289d7902988f2ce0c2dd23de (patch)
tree154609da75c4fac55f6787b5bcc7e4b2e588d630
parent474db2d18bb28b297eaebea4a2cf54994d3bb2e9 (diff)
parente6755872ada4978f585bdf15edf623dbcf72c4ee (diff)
downloados-client-config-d6908f93a732adfb289d7902988f2ce0c2dd23de.tar.gz
Merge "Remove the keystoneclient auth fallback"
-rw-r--r--os_client_config/config.py71
-rw-r--r--os_client_config/tests/test_config.py12
-rw-r--r--os_client_config/tests/test_init.py6
-rw-r--r--test-requirements.txt1
4 files changed, 13 insertions, 77 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index 9b4a709..de8dd38 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -861,59 +861,6 @@ class OpenStackConfig(object):
config['auth_type'] = 'admin_token'
return loading.get_plugin_loader(config['auth_type'])
- def _validate_auth_ksc(self, config, cloud):
- try:
- import keystoneclient.auth as ksc_auth
- except ImportError:
- return config
-
- # May throw a keystoneclient.exceptions.NoMatchingPlugin
- plugin_options = ksc_auth.get_plugin_class(
- config['auth_type']).get_options()
-
- for p_opt in plugin_options:
- # if it's in config.auth, win, kill it from config dict
- # if it's in config and not in config.auth, move it
- # deprecated loses to current
- # provided beats default, deprecated or not
- winning_value = self._find_winning_auth_value(
- p_opt,
- config['auth'],
- )
- if not winning_value:
- winning_value = self._find_winning_auth_value(
- p_opt,
- config,
- )
-
- # if the plugin tells us that this value is required
- # then error if it's doesn't exist now
- if not winning_value and p_opt.required:
- raise exceptions.OpenStackConfigException(
- 'Unable to find auth information for cloud'
- ' {cloud} in config files {files}'
- ' or environment variables. Missing value {auth_key}'
- ' required for auth plugin {plugin}'.format(
- cloud=cloud, files=','.join(self._config_files),
- auth_key=p_opt.name, plugin=config.get('auth_type')))
-
- # Clean up after ourselves
- for opt in [p_opt.name] + [o.name for o in p_opt.deprecated_opts]:
- opt = opt.replace('-', '_')
- config.pop(opt, None)
- config['auth'].pop(opt, None)
-
- if winning_value:
- # Prefer the plugin configuration dest value if the value's key
- # is marked as depreciated.
- if p_opt.dest is None:
- config['auth'][p_opt.name.replace('-', '_')] = (
- winning_value)
- else:
- config['auth'][p_opt.dest] = winning_value
-
- return config
-
def _validate_auth(self, config, loader):
# May throw a keystoneauth1.exceptions.NoMatchingPlugin
@@ -1107,21 +1054,9 @@ class OpenStackConfig(object):
config = self.auth_config_hook(config)
if validate:
- try:
- loader = self._get_auth_loader(config)
- config = self._validate_auth(config, loader)
- auth_plugin = loader.load_from_options(**config['auth'])
- except Exception as e:
- # We WANT the ksa exception normally
- # but OSC can't handle it right now, so we try deferring
- # to ksc. If that ALSO fails, it means there is likely
- # a deeper issue, so we assume the ksa error was correct
- self.log.debug("Deferring keystone exception: {e}".format(e=e))
- auth_plugin = None
- try:
- config = self._validate_auth_ksc(config, cloud)
- except Exception:
- raise e
+ loader = self._get_auth_loader(config)
+ config = self._validate_auth(config, loader)
+ auth_plugin = loader.load_from_options(**config['auth'])
else:
auth_plugin = None
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py
index ad3685a..aa5935a 100644
--- a/os_client_config/tests/test_config.py
+++ b/os_client_config/tests/test_config.py
@@ -226,7 +226,7 @@ class TestConfig(base.TestCase):
c = config.OpenStackConfig(config_files=['nonexistent'],
vendor_files=['nonexistent'],
secure_files=[self.secure_yaml])
- cc = c.get_one_cloud(cloud='_test_cloud_no_vendor')
+ cc = c.get_one_cloud(cloud='_test_cloud_no_vendor', validate=False)
self.assertEqual('testpass', cc.auth['password'])
def test_get_cloud_names(self):
@@ -384,7 +384,7 @@ class TestConfigArgparse(base.TestCase):
vendor_files=[self.vendor_yaml])
cc = c.get_one_cloud(
- cloud='_test_cloud_regions', argparse=self.options)
+ cloud='_test_cloud_regions', argparse=self.options, validate=False)
self.assertEqual(cc.region_name, 'region2')
self.assertEqual(cc.snack_type, 'cookie')
@@ -481,7 +481,7 @@ class TestConfigArgparse(base.TestCase):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
vendor_files=[self.vendor_yaml])
- cc = c.get_one_cloud(argparse=self.options)
+ cc = c.get_one_cloud(argparse=self.options, validate=False)
self.assertIsNone(cc.cloud)
self.assertEqual(cc.region_name, 'region2')
self.assertEqual(cc.snack_type, 'cookie')
@@ -490,7 +490,7 @@ class TestConfigArgparse(base.TestCase):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
vendor_files=[self.vendor_yaml])
- cc = c.get_one_cloud(**self.args)
+ cc = c.get_one_cloud(validate=False, **self.args)
self.assertIsNone(cc.cloud)
self.assertEqual(cc.region_name, 'region2')
self.assertEqual(cc.snack_type, 'cookie')
@@ -622,7 +622,7 @@ class TestConfigArgparse(base.TestCase):
vendor_files=[self.vendor_yaml])
cc = c.get_one_cloud(
- cloud='envvars', argparse=self.options)
+ cloud='envvars', argparse=self.options, validate=False)
self.assertEqual(cc.auth['project_name'], 'project')
def test_argparse_default_no_token(self):
@@ -650,7 +650,7 @@ class TestConfigArgparse(base.TestCase):
opts, _remain = parser.parse_known_args(
['--os-auth-token', 'very-bad-things',
'--os-auth-type', 'token'])
- cc = c.get_one_cloud(argparse=opts)
+ cc = c.get_one_cloud(argparse=opts, validate=False)
self.assertEqual(cc.config['auth_type'], 'token')
self.assertEqual(cc.config['auth']['token'], 'very-bad-things')
diff --git a/os_client_config/tests/test_init.py b/os_client_config/tests/test_init.py
index 15d57f7..5b4fab9 100644
--- a/os_client_config/tests/test_init.py
+++ b/os_client_config/tests/test_init.py
@@ -18,7 +18,8 @@ from os_client_config.tests import base
class TestInit(base.TestCase):
def test_get_config_without_arg_parser(self):
- cloud_config = os_client_config.get_config(options=None)
+ cloud_config = os_client_config.get_config(
+ options=None, validate=False)
self.assertIsInstance(
cloud_config,
os_client_config.cloud_config.CloudConfig
@@ -26,7 +27,8 @@ class TestInit(base.TestCase):
def test_get_config_with_arg_parser(self):
cloud_config = os_client_config.get_config(
- options=argparse.ArgumentParser())
+ options=argparse.ArgumentParser(),
+ validate=False)
self.assertIsInstance(
cloud_config,
os_client_config.cloud_config.CloudConfig
diff --git a/test-requirements.txt b/test-requirements.txt
index 6208fb5..572dcc6 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -11,7 +11,6 @@ fixtures>=0.3.14
jsonschema>=2.0.0,<3.0.0,!=2.5.0
mock>=1.2
python-glanceclient>=0.18.0
-python-keystoneclient>=1.1.0
python-subunit>=0.0.18
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
oslosphinx>=2.5.0,<2.6.0 # Apache-2.0