Merge "Set "password" as default auth plugin"

This commit is contained in:
Jenkins
2015-11-23 22:53:33 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 6 deletions

View File

@@ -148,7 +148,8 @@ def from_config(cloud_name=None, cloud_config=None, options=None):
class Connection(object): class Connection(object):
def __init__(self, session=None, authenticator=None, profile=None, def __init__(self, session=None, authenticator=None, profile=None,
verify=True, user_agent=None, auth_plugin=None, **auth_args): verify=True, user_agent=None, auth_plugin="password",
**auth_args):
"""Create a context for a connection to a cloud provider. """Create a context for a connection to a cloud provider.
A connection needs a transport and an authenticator. The user may pass A connection needs a transport and an authenticator. The user may pass
@@ -184,11 +185,8 @@ class Connection(object):
specified in :attr:`~openstack.transport.USER_AGENT`. specified in :attr:`~openstack.transport.USER_AGENT`.
The resulting ``user_agent`` value is used for the ``User-Agent`` The resulting ``user_agent`` value is used for the ``User-Agent``
HTTP header. HTTP header.
:param str auth_plugin: The name of authentication plugin to use. If :param str auth_plugin: The name of authentication plugin to use.
the authentication plugin name is not provided, the connection will The default value is ``password``.
try to guess what plugin to use based on the *auth_url* in the
*auth_args*. Two common values for the plugin would be
``v3password`` and ``v3token``.
:param auth_args: The rest of the parameters provided are assumed to be :param auth_args: The rest of the parameters provided are assumed to be
authentication arguments that are used by the authentication authentication arguments that are used by the authentication
plugin. plugin.

View File

@@ -73,6 +73,12 @@ class TestConnection(base.TestCase):
mock_loader.load_from_options.assert_called_with(**auth_args) mock_loader.load_from_options.assert_called_with(**auth_args)
self.assertEqual(mock_plugin, conn.authenticator) self.assertEqual(mock_plugin, conn.authenticator)
@mock.patch("keystoneauth1.loading.base.get_plugin_loader")
def test_default_plugin(self, mock_get_plugin):
connection.Connection()
self.assertTrue(mock_get_plugin.called)
self.assertEqual(mock_get_plugin.call_args, mock.call("password"))
@mock.patch("keystoneauth1.loading.base.get_plugin_loader") @mock.patch("keystoneauth1.loading.base.get_plugin_loader")
def test_pass_authenticator(self, mock_get_plugin): def test_pass_authenticator(self, mock_get_plugin):
mock_plugin = mock.Mock() mock_plugin = mock.Mock()