From 575dfdc637e7f833a85fe46a927609c244caf8bb Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Mon, 23 Nov 2015 16:20:38 -0600 Subject: [PATCH] Set "password" as default auth plugin Currently, when None gets passed through a Connection, None gets sent to keystoneauth to find the None plugin, which doesn't exist. As "password" is the likely default, we should send "password" through unless otherwise specified. Change-Id: Iafe526d88a1b2ceb8b975f01dddb808f43821f0f --- openstack/connection.py | 10 ++++------ openstack/tests/unit/test_connection.py | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/openstack/connection.py b/openstack/connection.py index 5b25919f..29404eb1 100644 --- a/openstack/connection.py +++ b/openstack/connection.py @@ -148,7 +148,8 @@ def from_config(cloud_name=None, cloud_config=None, options=None): class Connection(object): 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. 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`. The resulting ``user_agent`` value is used for the ``User-Agent`` HTTP header. - :param str auth_plugin: The name of authentication plugin to use. If - the authentication plugin name is not provided, the connection will - 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 str auth_plugin: The name of authentication plugin to use. + The default value is ``password``. :param auth_args: The rest of the parameters provided are assumed to be authentication arguments that are used by the authentication plugin. diff --git a/openstack/tests/unit/test_connection.py b/openstack/tests/unit/test_connection.py index dcdfa802..9fd3378a 100644 --- a/openstack/tests/unit/test_connection.py +++ b/openstack/tests/unit/test_connection.py @@ -73,6 +73,12 @@ class TestConnection(base.TestCase): mock_loader.load_from_options.assert_called_with(**auth_args) 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") def test_pass_authenticator(self, mock_get_plugin): mock_plugin = mock.Mock()