From b764efc46fcee48394761620672a3a1e117aa3db Mon Sep 17 00:00:00 2001 From: Vladyslav Drok Date: Tue, 17 Oct 2017 19:21:53 +0300 Subject: [PATCH] Allow to use the none auth plugin This change allows to use the none auth plugin in CLI without having to specify --os-cloud file with basically a single endpoint parameter. Closes-Bug: #1724283 Depends-On: I3e477895ba0c989ffd0c91c45791e9f74173a3d6 Depends-On: I3de32193f41d9d1012043b43ae8080f3b1e828e5 Change-Id: I6cf4e22d676f4a55f84863125aee7318915a7404 --- osc_lib/clientmanager.py | 3 ++- osc_lib/tests/test_clientmanager.py | 24 +++++++++++++++++++ .../notes/none-auth-cli-48ab0e48d4852941.yaml | 7 ++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/none-auth-cli-48ab0e48d4852941.yaml diff --git a/osc_lib/clientmanager.py b/osc_lib/clientmanager.py index 6723287..3c13d01 100644 --- a/osc_lib/clientmanager.py +++ b/osc_lib/clientmanager.py @@ -247,7 +247,8 @@ class ClientManager(object): @property def auth_ref(self): """Dereference will trigger an auth if it hasn't already""" - if not self._auth_required: + if (not self._auth_required or + self._cli_options.config['auth_type'] == 'none'): # Forcibly skip auth if we know we do not need it return None if not self._auth_ref: diff --git a/osc_lib/tests/test_clientmanager.py b/osc_lib/tests/test_clientmanager.py index 152e579..e261bdd 100644 --- a/osc_lib/tests/test_clientmanager.py +++ b/osc_lib/tests/test_clientmanager.py @@ -21,6 +21,7 @@ from keystoneauth1 import exceptions as ksa_exceptions from keystoneauth1.identity import generic as generic_plugin from keystoneauth1.identity.v3 import k2k from keystoneauth1 import loading +from keystoneauth1 import noauth from keystoneauth1 import token_endpoint try: @@ -81,6 +82,29 @@ class TestClientCache(utils.TestCase): class TestClientManager(utils.TestClientManager): + def test_client_manager_none(self): + none_auth = { + 'endpoint': fakes.AUTH_URL, + } + client_manager = self._make_clientmanager( + auth_args=none_auth, + auth_plugin_name='none', + ) + + self.assertEqual( + fakes.AUTH_URL, + client_manager._cli_options.config['auth']['endpoint'], + ) + self.assertIsInstance( + client_manager.auth, + noauth.NoAuth, + ) + # Check that the endpoint option works as the override + self.assertEqual( + fakes.AUTH_URL, + client_manager.get_endpoint_for_service_type('baremetal'), + ) + def test_client_manager_admin_token(self): token_auth = { 'endpoint': fakes.AUTH_URL, diff --git a/releasenotes/notes/none-auth-cli-48ab0e48d4852941.yaml b/releasenotes/notes/none-auth-cli-48ab0e48d4852941.yaml new file mode 100644 index 0000000..58f5912 --- /dev/null +++ b/releasenotes/notes/none-auth-cli-48ab0e48d4852941.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + It is now possible to specify the ``none`` auth type (via ``--os-auth-type`` CLI argument or + ``OS_AUTH_TYPE`` environment variable). To use it, ``--os-endpoint`` CLI argument or + ``OS_ENDPOINT`` environment variable must be specified. See `the bug + `_ for more detail. \ No newline at end of file