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