2013-09-05 12:54:14 -05:00
|
|
|
# Copyright 2012-2013 OpenStack Foundation
|
2013-01-24 12:00:30 -06:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
#
|
2015-05-26 17:40:01 -04:00
|
|
|
|
2016-05-13 16:53:44 -05:00
|
|
|
import copy
|
2014-08-22 17:26:07 -05:00
|
|
|
|
2016-02-04 16:45:38 +00:00
|
|
|
from keystoneauth1 import token_endpoint
|
2016-05-13 16:53:44 -05:00
|
|
|
from osc_lib.tests import utils as osc_lib_test_utils
|
2014-07-18 19:18:25 +02:00
|
|
|
|
2012-05-02 17:02:08 -04:00
|
|
|
from openstackclient.common import clientmanager
|
2016-09-05 22:14:33 -07:00
|
|
|
from openstackclient.tests.unit import fakes
|
2012-05-02 17:02:08 -04:00
|
|
|
|
|
|
|
|
2016-05-13 16:53:44 -05:00
|
|
|
class TestClientManager(osc_lib_test_utils.TestClientManager):
|
|
|
|
def _clientmanager_class(self):
|
|
|
|
"""Allow subclasses to override the ClientManager class"""
|
|
|
|
return clientmanager.ClientManager
|
2014-07-18 19:18:25 +02:00
|
|
|
|
2019-08-21 12:20:41 -05:00
|
|
|
def test_client_manager_admin_token(self):
|
2016-05-13 16:53:44 -05:00
|
|
|
token_auth = {
|
2019-08-21 12:20:41 -05:00
|
|
|
'endpoint': fakes.AUTH_URL,
|
2016-05-13 16:53:44 -05:00
|
|
|
'token': fakes.AUTH_TOKEN,
|
|
|
|
}
|
|
|
|
client_manager = self._make_clientmanager(
|
|
|
|
auth_args=token_auth,
|
2019-08-21 12:20:41 -05:00
|
|
|
auth_plugin_name='admin_token',
|
2014-10-09 15:16:07 -05:00
|
|
|
)
|
2015-02-27 09:19:12 -06:00
|
|
|
|
2014-10-09 15:16:07 -05:00
|
|
|
self.assertEqual(
|
|
|
|
fakes.AUTH_URL,
|
2019-08-21 12:20:41 -05:00
|
|
|
client_manager._cli_options.config['auth']['endpoint'],
|
2014-10-09 15:16:07 -05:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
fakes.AUTH_TOKEN,
|
2014-10-17 22:26:57 -05:00
|
|
|
client_manager.auth.get_token(None),
|
2014-10-09 15:16:07 -05:00
|
|
|
)
|
|
|
|
self.assertIsInstance(
|
|
|
|
client_manager.auth,
|
2016-02-04 16:45:38 +00:00
|
|
|
token_endpoint.Token,
|
2014-10-09 15:16:07 -05:00
|
|
|
)
|
2015-12-02 14:43:01 -06:00
|
|
|
self.assertTrue(client_manager.is_network_endpoint_enabled())
|
|
|
|
|
|
|
|
def test_client_manager_network_endpoint_disabled(self):
|
2016-05-13 16:53:44 -05:00
|
|
|
auth_args = copy.deepcopy(self.default_password_auth)
|
2023-05-08 11:35:45 +01:00
|
|
|
auth_args.update(
|
|
|
|
{
|
|
|
|
'user_domain_name': 'default',
|
|
|
|
'project_domain_name': 'default',
|
|
|
|
}
|
|
|
|
)
|
2016-05-13 16:53:44 -05:00
|
|
|
# v3 fake doesn't have network endpoint
|
|
|
|
client_manager = self._make_clientmanager(
|
|
|
|
auth_args=auth_args,
|
|
|
|
identity_api_version='3',
|
|
|
|
auth_plugin_name='v3password',
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertFalse(client_manager.is_service_available('network'))
|
2017-04-24 18:57:05 -05:00
|
|
|
# This is True because ClientManager.auth_ref returns None in this
|
|
|
|
# test; "no service catalog" means use Network API by default now
|
|
|
|
self.assertTrue(client_manager.is_network_endpoint_enabled())
|