Merge "Add name parameter to NoMatchingPlugin exception"
This commit is contained in:
@@ -17,7 +17,6 @@ import six
|
|||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
from keystoneclient.i18n import _
|
|
||||||
|
|
||||||
|
|
||||||
# NOTE(jamielennox): The AUTH_INTERFACE is a special value that can be
|
# NOTE(jamielennox): The AUTH_INTERFACE is a special value that can be
|
||||||
@@ -44,8 +43,7 @@ def get_plugin_class(name):
|
|||||||
name=name,
|
name=name,
|
||||||
invoke_on_load=False)
|
invoke_on_load=False)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
msg = _('The plugin %s could not be found') % name
|
raise exceptions.NoMatchingPlugin(name)
|
||||||
raise exceptions.NoMatchingPlugin(msg)
|
|
||||||
|
|
||||||
return mgr.driver
|
return mgr.driver
|
||||||
|
|
||||||
|
@@ -81,8 +81,19 @@ class MissingAuthPlugin(ClientException):
|
|||||||
class NoMatchingPlugin(ClientException):
|
class NoMatchingPlugin(ClientException):
|
||||||
"""There were no auth plugins that could be created from the parameters
|
"""There were no auth plugins that could be created from the parameters
|
||||||
provided.
|
provided.
|
||||||
|
|
||||||
|
:param str name: The name of the plugin that was attempted to load.
|
||||||
|
|
||||||
|
.. py:attribute:: name
|
||||||
|
|
||||||
|
The name of the plugin that was attempted to load.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, name):
|
||||||
|
self.name = name
|
||||||
|
msg = _('The plugin %s could not be found') % name
|
||||||
|
super(NoMatchingPlugin, self).__init__(msg)
|
||||||
|
|
||||||
|
|
||||||
class InvalidResponse(ClientException):
|
class InvalidResponse(ClientException):
|
||||||
"""The response from the server is not valid for this request."""
|
"""The response from the server is not valid for this request."""
|
||||||
|
@@ -92,14 +92,17 @@ class ConfTests(utils.TestCase):
|
|||||||
self.assertEqual(project_domain_name, a.project_domain_name)
|
self.assertEqual(project_domain_name, a.project_domain_name)
|
||||||
|
|
||||||
def test_loading_invalid_plugin(self):
|
def test_loading_invalid_plugin(self):
|
||||||
self.conf_fixture.config(auth_plugin=uuid.uuid4().hex,
|
auth_plugin = uuid.uuid4().hex
|
||||||
|
self.conf_fixture.config(auth_plugin=auth_plugin,
|
||||||
group=self.GROUP)
|
group=self.GROUP)
|
||||||
|
|
||||||
self.assertRaises(exceptions.NoMatchingPlugin,
|
e = self.assertRaises(exceptions.NoMatchingPlugin,
|
||||||
conf.load_from_conf_options,
|
conf.load_from_conf_options,
|
||||||
self.conf_fixture.conf,
|
self.conf_fixture.conf,
|
||||||
self.GROUP)
|
self.GROUP)
|
||||||
|
|
||||||
|
self.assertEqual(auth_plugin, e.name)
|
||||||
|
|
||||||
def test_loading_with_no_data(self):
|
def test_loading_with_no_data(self):
|
||||||
self.assertIsNone(conf.load_from_conf_options(self.conf_fixture.conf,
|
self.assertIsNone(conf.load_from_conf_options(self.conf_fixture.conf,
|
||||||
self.GROUP))
|
self.GROUP))
|
||||||
|
Reference in New Issue
Block a user