Merge "Distinguish between name not provided and incorrect"
This commit is contained in:
@@ -13,7 +13,6 @@
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from keystoneclient.auth import base
|
from keystoneclient.auth import base
|
||||||
from keystoneclient import exceptions
|
|
||||||
|
|
||||||
_AUTH_PLUGIN_OPT = cfg.StrOpt('auth_plugin', help='Name of the plugin to load')
|
_AUTH_PLUGIN_OPT = cfg.StrOpt('auth_plugin', help='Name of the plugin to load')
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ def load_from_conf_options(conf, group, **kwargs):
|
|||||||
:param conf: An oslo.config conf object.
|
:param conf: An oslo.config conf object.
|
||||||
:param string group: The group name that options should be read from.
|
:param string group: The group name that options should be read from.
|
||||||
|
|
||||||
:returns plugin: An authentication Plugin.
|
:returns plugin: An authentication Plugin or None if a name is not provided
|
||||||
|
|
||||||
:raises exceptions.NoMatchingPlugin: if a plugin cannot be created.
|
:raises exceptions.NoMatchingPlugin: if a plugin cannot be created.
|
||||||
"""
|
"""
|
||||||
@@ -101,7 +100,7 @@ def load_from_conf_options(conf, group, **kwargs):
|
|||||||
|
|
||||||
name = conf[group].auth_plugin
|
name = conf[group].auth_plugin
|
||||||
if not name:
|
if not name:
|
||||||
raise exceptions.NoMatchingPlugin('No plugin name provided for config')
|
return None
|
||||||
|
|
||||||
plugin_class = base.get_plugin_class(name)
|
plugin_class = base.get_plugin_class(name)
|
||||||
plugin_class.register_conf_options(conf, group)
|
plugin_class.register_conf_options(conf, group)
|
||||||
|
@@ -101,10 +101,8 @@ class ConfTests(utils.TestCase):
|
|||||||
self.GROUP)
|
self.GROUP)
|
||||||
|
|
||||||
def test_loading_with_no_data(self):
|
def test_loading_with_no_data(self):
|
||||||
self.assertRaises(exceptions.NoMatchingPlugin,
|
self.assertIsNone(conf.load_from_conf_options(self.conf_fixture.conf,
|
||||||
conf.load_from_conf_options,
|
self.GROUP))
|
||||||
self.conf_fixture.conf,
|
|
||||||
self.GROUP)
|
|
||||||
|
|
||||||
@mock.patch('stevedore.DriverManager')
|
@mock.patch('stevedore.DriverManager')
|
||||||
def test_other_params(self, m):
|
def test_other_params(self, m):
|
||||||
|
Reference in New Issue
Block a user