2015-07-14 21:41:07 +08: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.
|
|
|
|
|
2016-04-28 15:15:12 -05:00
|
|
|
from tempest.lib.common.utils import data_utils
|
2015-07-14 21:41:07 +08:00
|
|
|
|
2016-09-05 20:35:06 -07:00
|
|
|
from openstackclient.tests.functional.identity.v3 import common
|
2015-07-14 21:41:07 +08:00
|
|
|
|
|
|
|
|
2016-06-20 17:12:44 -04:00
|
|
|
class EndpointTests(common.IdentityTests):
|
2015-07-14 21:41:07 +08:00
|
|
|
def test_endpoint_create(self):
|
|
|
|
self._create_dummy_endpoint(interface='public')
|
|
|
|
self._create_dummy_endpoint(interface='admin')
|
|
|
|
self._create_dummy_endpoint(interface='internal')
|
|
|
|
|
|
|
|
def test_endpoint_delete(self):
|
|
|
|
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
2024-09-12 17:57:14 +01:00
|
|
|
raw_output = self.openstack(f'endpoint delete {endpoint_id}')
|
2015-07-14 21:41:07 +08:00
|
|
|
self.assertEqual(0, len(raw_output))
|
|
|
|
|
2016-07-12 12:44:55 +08:00
|
|
|
def test_endpoint_multi_delete(self):
|
|
|
|
endpoint_1 = self._create_dummy_endpoint(add_clean_up=False)
|
|
|
|
endpoint_2 = self._create_dummy_endpoint(add_clean_up=False)
|
|
|
|
raw_output = self.openstack(
|
2023-05-08 11:32:01 +01:00
|
|
|
f'endpoint delete {endpoint_1} {endpoint_2}'
|
|
|
|
)
|
2016-07-12 12:44:55 +08:00
|
|
|
self.assertEqual(0, len(raw_output))
|
|
|
|
|
2015-07-14 21:41:07 +08:00
|
|
|
def test_endpoint_list(self):
|
|
|
|
endpoint_id = self._create_dummy_endpoint()
|
|
|
|
raw_output = self.openstack('endpoint list')
|
2016-04-06 01:12:40 +02:00
|
|
|
self.assertIn(endpoint_id, raw_output)
|
2015-07-14 21:41:07 +08:00
|
|
|
items = self.parse_listing(raw_output)
|
|
|
|
self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
|
|
|
|
|
2017-10-25 15:39:44 +02:00
|
|
|
def test_endpoint_list_filter(self):
|
|
|
|
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
|
|
|
project_id = self._create_dummy_project(add_clean_up=False)
|
|
|
|
raw_output = self.openstack(
|
2024-09-12 17:57:14 +01:00
|
|
|
'endpoint add project ' f'{endpoint_id} ' f'{project_id}'
|
2023-05-08 11:32:01 +01:00
|
|
|
)
|
2017-10-25 15:39:44 +02:00
|
|
|
self.assertEqual(0, len(raw_output))
|
2024-09-12 17:57:14 +01:00
|
|
|
raw_output = self.openstack(f'endpoint list --endpoint {endpoint_id}')
|
2017-10-25 15:39:44 +02:00
|
|
|
self.assertIn(project_id, raw_output)
|
|
|
|
items = self.parse_listing(raw_output)
|
2023-05-08 11:32:01 +01:00
|
|
|
self.assert_table_structure(items, self.ENDPOINT_LIST_PROJECT_HEADERS)
|
2017-10-25 15:39:44 +02:00
|
|
|
|
2024-09-12 17:57:14 +01:00
|
|
|
raw_output = self.openstack(f'endpoint list --project {project_id}')
|
2017-10-25 15:39:44 +02:00
|
|
|
self.assertIn(endpoint_id, raw_output)
|
|
|
|
items = self.parse_listing(raw_output)
|
|
|
|
self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
|
|
|
|
|
2015-07-14 21:41:07 +08:00
|
|
|
def test_endpoint_set(self):
|
|
|
|
endpoint_id = self._create_dummy_endpoint()
|
|
|
|
new_endpoint_url = data_utils.rand_url()
|
|
|
|
raw_output = self.openstack(
|
|
|
|
'endpoint set '
|
2024-09-12 17:57:14 +01:00
|
|
|
'--interface {interface} '
|
|
|
|
'--url {url} '
|
2015-07-14 21:41:07 +08:00
|
|
|
'--disable '
|
2024-09-12 17:57:14 +01:00
|
|
|
'{endpoint_id}'.format(
|
|
|
|
interface='admin',
|
|
|
|
url=new_endpoint_url,
|
|
|
|
endpoint_id=endpoint_id,
|
|
|
|
)
|
2023-05-08 11:32:01 +01:00
|
|
|
)
|
2015-07-14 21:41:07 +08:00
|
|
|
self.assertEqual(0, len(raw_output))
|
2024-09-12 17:57:14 +01:00
|
|
|
raw_output = self.openstack(f'endpoint show {endpoint_id}')
|
2015-07-14 21:41:07 +08:00
|
|
|
endpoint = self.parse_show_as_object(raw_output)
|
|
|
|
self.assertEqual('admin', endpoint['interface'])
|
|
|
|
self.assertEqual(new_endpoint_url, endpoint['url'])
|
|
|
|
self.assertEqual('False', endpoint['enabled'])
|
|
|
|
|
|
|
|
def test_endpoint_show(self):
|
|
|
|
endpoint_id = self._create_dummy_endpoint()
|
2024-09-12 17:57:14 +01:00
|
|
|
raw_output = self.openstack(f'endpoint show {endpoint_id}')
|
2015-07-14 21:41:07 +08:00
|
|
|
items = self.parse_show(raw_output)
|
|
|
|
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
2017-10-25 15:39:44 +02:00
|
|
|
|
|
|
|
def test_endpoint_add_remove_project(self):
|
|
|
|
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
|
|
|
project_id = self._create_dummy_project(add_clean_up=False)
|
|
|
|
raw_output = self.openstack(
|
2024-09-12 17:57:14 +01:00
|
|
|
'endpoint add project ' f'{endpoint_id} ' f'{project_id}'
|
2023-05-08 11:32:01 +01:00
|
|
|
)
|
2017-10-25 15:39:44 +02:00
|
|
|
self.assertEqual(0, len(raw_output))
|
|
|
|
|
|
|
|
raw_output = self.openstack(
|
2024-09-12 17:57:14 +01:00
|
|
|
'endpoint remove project ' f'{endpoint_id} ' f'{project_id}'
|
2023-05-08 11:32:01 +01:00
|
|
|
)
|
2017-10-25 15:39:44 +02:00
|
|
|
self.assertEqual(0, len(raw_output))
|