add functional tests for identity v2
add tests for endpoint and service. Change-Id: Iec80106d6e4c310cea1c5af262d145ac1f56525e Implements: blueprint identity-functional-tests
This commit is contained in:
parent
83edde0ec9
commit
cc522821f6
38
functional/tests/identity/v2/test_endpoint.py
Normal file
38
functional/tests/identity/v2/test_endpoint.py
Normal file
@ -0,0 +1,38 @@
|
||||
# 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 functional.tests.identity.v2 import test_identity
|
||||
|
||||
|
||||
class EndpointTests(test_identity.IdentityTests):
|
||||
|
||||
def test_endpoint_create(self):
|
||||
self._create_dummy_endpoint()
|
||||
|
||||
def test_endpoint_delete(self):
|
||||
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
|
||||
raw_output = self.openstack(
|
||||
'endpoint delete %s' % endpoint_id)
|
||||
self.assertEqual(0, len(raw_output))
|
||||
|
||||
def test_endpoint_list(self):
|
||||
endpoint_id = self._create_dummy_endpoint()
|
||||
raw_output = self.openstack('endpoint list')
|
||||
self.assertInOutput(endpoint_id, raw_output)
|
||||
items = self.parse_listing(raw_output)
|
||||
self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
|
||||
|
||||
def test_endpoint_show(self):
|
||||
endpoint_id = self._create_dummy_endpoint()
|
||||
raw_output = self.openstack('endpoint show %s' % endpoint_id)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
@ -25,12 +25,17 @@ class IdentityTests(test.TestCase):
|
||||
PROJECT_FIELDS = ['enabled', 'id', 'name', 'description', 'domain_id']
|
||||
TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id']
|
||||
ROLE_FIELDS = ['id', 'name', 'links']
|
||||
SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
|
||||
ENDPOINT_FIELDS = ['id', 'region', 'service_id', 'service_name',
|
||||
'service_type', 'enabled', 'publicurl',
|
||||
'adminurl', 'internalurl']
|
||||
|
||||
EC2_CREDENTIALS_FIELDS = ['access', 'project_id', 'secret',
|
||||
'trust_id', 'user_id']
|
||||
EC2_CREDENTIALS_LIST_HEADERS = ['Access', 'Secret',
|
||||
'Project ID', 'User ID']
|
||||
CATALOG_LIST_HEADERS = ['Name', 'Type', 'Endpoints']
|
||||
ENDPOINT_LIST_HEADERS = ['ID', 'Region', 'Service Name', 'Service Type']
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@ -127,3 +132,48 @@ class IdentityTests(test.TestCase):
|
||||
self.addCleanup(self.openstack,
|
||||
'token revoke %s' % token['id'])
|
||||
return token['id']
|
||||
|
||||
def _create_dummy_service(self, add_clean_up=True):
|
||||
service_name = data_utils.rand_name('TestService')
|
||||
description = data_utils.rand_name('description')
|
||||
type_name = data_utils.rand_name('TestType')
|
||||
raw_output = self.openstack(
|
||||
'service create '
|
||||
'--name %(name)s '
|
||||
'--description %(description)s '
|
||||
'%(type)s' % {'name': service_name,
|
||||
'description': description,
|
||||
'type': type_name})
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
||||
if add_clean_up:
|
||||
service = self.parse_show_as_object(raw_output)
|
||||
self.addCleanup(self.openstack,
|
||||
'service delete %s' % service['id'])
|
||||
return service_name
|
||||
|
||||
def _create_dummy_endpoint(self, add_clean_up=True):
|
||||
region_id = data_utils.rand_name('TestRegion')
|
||||
service_name = self._create_dummy_service()
|
||||
public_url = data_utils.rand_url()
|
||||
admin_url = data_utils.rand_url()
|
||||
internal_url = data_utils.rand_url()
|
||||
raw_output = self.openstack(
|
||||
'endpoint create '
|
||||
'--publicurl %(publicurl)s '
|
||||
'--adminurl %(adminurl)s '
|
||||
'--internalurl %(internalurl)s '
|
||||
'--region %(region)s '
|
||||
'%(service)s' % {'publicurl': public_url,
|
||||
'adminurl': admin_url,
|
||||
'internalurl': internal_url,
|
||||
'region': region_id,
|
||||
'service': service_name})
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
|
||||
endpoint = self.parse_show_as_object(raw_output)
|
||||
if add_clean_up:
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'endpoint delete %s' % endpoint['id'])
|
||||
return endpoint['id']
|
||||
|
37
functional/tests/identity/v2/test_service.py
Normal file
37
functional/tests/identity/v2/test_service.py
Normal file
@ -0,0 +1,37 @@
|
||||
# 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 functional.tests.identity.v2 import test_identity
|
||||
|
||||
|
||||
class ServiceTests(test_identity.IdentityTests):
|
||||
|
||||
def test_service_create(self):
|
||||
self._create_dummy_service()
|
||||
|
||||
def test_service_delete(self):
|
||||
service_name = self._create_dummy_service(add_clean_up=False)
|
||||
raw_output = self.openstack('service delete %s' % service_name)
|
||||
self.assertEqual(0, len(raw_output))
|
||||
|
||||
def test_service_list(self):
|
||||
self._create_dummy_service()
|
||||
raw_output = self.openstack('service list')
|
||||
items = self.parse_listing(raw_output)
|
||||
self.assert_table_structure(items, test_identity.BASIC_LIST_HEADERS)
|
||||
|
||||
def test_service_show(self):
|
||||
service_name = self._create_dummy_service()
|
||||
raw_output = self.openstack(
|
||||
'service show %s' % service_name)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.SERVICE_FIELDS)
|
Loading…
Reference in New Issue
Block a user