diff --git a/releasenotes/notes/tempest-identity-catalog-client-f5c8589a9d7c1eb5.yaml b/releasenotes/notes/tempest-identity-catalog-client-f5c8589a9d7c1eb5.yaml new file mode 100644 index 000000000..dcaaceb5f --- /dev/null +++ b/releasenotes/notes/tempest-identity-catalog-client-f5c8589a9d7c1eb5.yaml @@ -0,0 +1,5 @@ +--- +features: + - Add a new identity catalog client. At this point, the new client + contains a single functionality, "show_catalog", which returns a + catalog object. diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py index 4495cbf75..30d2a366a 100644 --- a/tempest/api/identity/base.py +++ b/tempest/api/identity/base.py @@ -187,6 +187,7 @@ class BaseIdentityV3Test(BaseIdentityTest): cls.non_admin_users_client = cls.os_primary.users_v3_client cls.non_admin_token = cls.os_primary.token_v3_client cls.non_admin_projects_client = cls.os_primary.projects_client + cls.non_admin_catalog_client = cls.os_primary.catalog_client cls.non_admin_versions_client =\ cls.os_primary.identity_versions_v3_client diff --git a/tempest/api/identity/v3/test_catalog.py b/tempest/api/identity/v3/test_catalog.py new file mode 100755 index 000000000..deec2dcf1 --- /dev/null +++ b/tempest/api/identity/v3/test_catalog.py @@ -0,0 +1,41 @@ +# 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. + +from tempest.api.identity import base +from tempest import config +from tempest.lib import decorators + + +CONF = config.CONF + + +class IdentityCatalogTest(base.BaseIdentityV3Test): + + @decorators.idempotent_id('56b57ced-22b8-4127-9b8a-565dfb0207e2') + def test_catalog_standardization(self): + # http://git.openstack.org/cgit/openstack/service-types-authority + # /tree/service-types.yaml + standard_service_values = [{'name': 'keystone', 'type': 'identity'}, + {'name': 'nova', 'type': 'compute'}, + {'name': 'glance', 'type': 'image'}, + {'name': 'swift', 'type': 'object-store'}] + # next, we need to GET the catalog using the catalog client + catalog = self.non_admin_catalog_client.show_catalog()['catalog'] + # get list of the service types present in the catalog + catalog_services = [] + for service in catalog: + catalog_services.append(service['type']) + for service in standard_service_values: + # if service enabled, check if it has a standard typevalue + if service['name'] == 'keystone' or\ + getattr(CONF.service_available, service['name']): + self.assertIn(service['type'], catalog_services) diff --git a/tempest/clients.py b/tempest/clients.py index c3357bba1..3f206b0b7 100644 --- a/tempest/clients.py +++ b/tempest/clients.py @@ -208,6 +208,7 @@ class Manager(clients.ServiceClients): self.identity_v3.EndPointsFilterClient(**params_v3) self.endpoint_groups_client = self.identity_v3.EndPointGroupsClient( **params_v3) + self.catalog_client = self.identity_v3.CatalogClient(**params_v3) # Token clients do not use the catalog. They only need default_params. # They read auth_url, so they should only be set if the corresponding diff --git a/tempest/lib/services/identity/v3/__init__.py b/tempest/lib/services/identity/v3/__init__.py index e271a58e1..a539d08c0 100644 --- a/tempest/lib/services/identity/v3/__init__.py +++ b/tempest/lib/services/identity/v3/__init__.py @@ -12,6 +12,8 @@ # License for the specific language governing permissions and limitations under # the License. +from tempest.lib.services.identity.v3.catalog_client import \ + CatalogClient from tempest.lib.services.identity.v3.credentials_client import \ CredentialsClient from tempest.lib.services.identity.v3.domain_configuration_client \ @@ -42,10 +44,11 @@ from tempest.lib.services.identity.v3.trusts_client import TrustsClient from tempest.lib.services.identity.v3.users_client import UsersClient from tempest.lib.services.identity.v3.versions_client import VersionsClient -__all__ = ['CredentialsClient', 'DomainsClient', 'DomainConfigurationClient', - 'EndPointGroupsClient', 'EndPointsClient', 'EndPointsFilterClient', - 'GroupsClient', 'IdentityClient', 'InheritedRolesClient', - 'OAUTHConsumerClient', 'OAUTHTokenClient', 'PoliciesClient', - 'ProjectsClient', 'RegionsClient', 'RoleAssignmentsClient', - 'RolesClient', 'ServicesClient', 'V3TokenClient', 'TrustsClient', - 'UsersClient', 'VersionsClient'] +__all__ = ['CatalogClient', 'CredentialsClient', 'DomainsClient', + 'DomainConfigurationClient', 'EndPointGroupsClient', + 'EndPointsClient', 'EndPointsFilterClient', 'GroupsClient', + 'IdentityClient', 'InheritedRolesClient', 'OAUTHConsumerClient', + 'OAUTHTokenClient', 'PoliciesClient', 'ProjectsClient', + 'RegionsClient', 'RoleAssignmentsClient', 'RolesClient', + 'ServicesClient', 'V3TokenClient', 'TrustsClient', 'UsersClient', + 'VersionsClient'] diff --git a/tempest/lib/services/identity/v3/catalog_client.py b/tempest/lib/services/identity/v3/catalog_client.py new file mode 100644 index 000000000..0f9d48543 --- /dev/null +++ b/tempest/lib/services/identity/v3/catalog_client.py @@ -0,0 +1,30 @@ +# 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. + +""" +https://developer.openstack.org/api-ref/identity/v3/index.html#\ +get-service-catalog +""" + +from oslo_serialization import jsonutils as json + +from tempest.lib.common import rest_client + + +class CatalogClient(rest_client.RestClient): + api_version = "v3" + + def show_catalog(self): + resp, body = self.get('auth/catalog') + self.expected_success(200, resp.status) + body = json.loads(body) + return rest_client.ResponseBody(resp, body) diff --git a/tempest/tests/lib/services/identity/v3/test_catalog_client.py b/tempest/tests/lib/services/identity/v3/test_catalog_client.py new file mode 100644 index 000000000..0ac8fe426 --- /dev/null +++ b/tempest/tests/lib/services/identity/v3/test_catalog_client.py @@ -0,0 +1,86 @@ +# 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. + +from tempest.lib.services.identity.v3 import catalog_client +from tempest.tests.lib import fake_auth_provider +from tempest.tests.lib.services import base + + +class TestCatalogClient(base.BaseServiceTest): + FAKE_CATALOG_INFO = { + 'catalog': [ + { + 'endpoints': [ + { + 'id': '39dc322ce86c4111b4f06c2eeae0841b', + 'interface': 'public', + 'region': 'RegionOne', + 'url': 'http://localhost:5000' + }, + ], + 'id': 'ac58672276f848a7b1727850b3ebe826', + 'type': 'compute', + 'name': 'nova' + }, + { + 'endpoints': [ + { + 'id': '39dc322ce86c4111b4f06c2eeae0841b', + 'interface': 'public', + 'region': 'RegionOne', + 'url': 'http://localhost:5000' + }, + ], + 'id': 'b7c5ed2b486a46dbb4c221499d22991c', + 'type': 'image', + 'name': 'glance' + }, + { + 'endpoints': [ + { + 'id': '39dc322ce86c4111b4f06c2eeae0841b', + 'interface': 'public', + 'region': 'RegionOne', + 'url': 'http://localhost:5000' + }, + ], + 'id': '4363ae44bdf34a3981fde3b823cb9aa2', + 'type': 'identity', + 'name': 'keystone' + } + + ], + 'links': { + 'self': 'http://localhost/identity/v3/catalog', + 'previous': None, + 'next': None + } + } + + def setUp(self): + super(TestCatalogClient, self).setUp() + fake_auth = fake_auth_provider.FakeAuthProvider() + self.client = catalog_client.CatalogClient(fake_auth, 'identity', + 'RegionOne') + + def test_show_catalog_with_bytes_body(self): + self._test_show_catalog(bytes_body=True) + + def test_show_catalog_with_str_body(self): + self._test_show_catalog() + + def _test_show_catalog(self, bytes_body=False): + self.check_service_client_function( + self.client.show_catalog, + 'tempest.lib.common.rest_client.RestClient.get', + self.FAKE_CATALOG_INFO, + bytes_body)