Skip to content

Commit 7f5bcb5

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "add functional tests for identity v2"
2 parents f16fab7 + cc52282 commit 7f5bcb5

3 files changed

Lines changed: 125 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
from functional.tests.identity.v2 import test_identity
14+
15+
16+
class EndpointTests(test_identity.IdentityTests):
17+
18+
def test_endpoint_create(self):
19+
self._create_dummy_endpoint()
20+
21+
def test_endpoint_delete(self):
22+
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
23+
raw_output = self.openstack(
24+
'endpoint delete %s' % endpoint_id)
25+
self.assertEqual(0, len(raw_output))
26+
27+
def test_endpoint_list(self):
28+
endpoint_id = self._create_dummy_endpoint()
29+
raw_output = self.openstack('endpoint list')
30+
self.assertInOutput(endpoint_id, raw_output)
31+
items = self.parse_listing(raw_output)
32+
self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
33+
34+
def test_endpoint_show(self):
35+
endpoint_id = self._create_dummy_endpoint()
36+
raw_output = self.openstack('endpoint show %s' % endpoint_id)
37+
items = self.parse_show(raw_output)
38+
self.assert_show_fields(items, self.ENDPOINT_FIELDS)

‎functional/tests/identity/v2/test_identity.py‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ class IdentityTests(test.TestCase):
2525
PROJECT_FIELDS = ['enabled', 'id', 'name', 'description', 'domain_id']
2626
TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id']
2727
ROLE_FIELDS = ['id', 'name', 'links']
28+
SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
29+
ENDPOINT_FIELDS = ['id', 'region', 'service_id', 'service_name',
30+
'service_type', 'enabled', 'publicurl',
31+
'adminurl', 'internalurl']
2832

2933
EC2_CREDENTIALS_FIELDS = ['access', 'project_id', 'secret',
3034
'trust_id', 'user_id']
3135
EC2_CREDENTIALS_LIST_HEADERS = ['Access', 'Secret',
3236
'Project ID', 'User ID']
3337
CATALOG_LIST_HEADERS = ['Name', 'Type', 'Endpoints']
38+
ENDPOINT_LIST_HEADERS = ['ID', 'Region', 'Service Name', 'Service Type']
3439

3540
@classmethod
3641
def setUpClass(cls):
@@ -127,3 +132,48 @@ def _create_dummy_token(self, add_clean_up=True):
127132
self.addCleanup(self.openstack,
128133
'token revoke %s' % token['id'])
129134
return token['id']
135+
136+
def _create_dummy_service(self, add_clean_up=True):
137+
service_name = data_utils.rand_name('TestService')
138+
description = data_utils.rand_name('description')
139+
type_name = data_utils.rand_name('TestType')
140+
raw_output = self.openstack(
141+
'service create '
142+
'--name %(name)s '
143+
'--description %(description)s '
144+
'%(type)s' % {'name': service_name,
145+
'description': description,
146+
'type': type_name})
147+
items = self.parse_show(raw_output)
148+
self.assert_show_fields(items, self.SERVICE_FIELDS)
149+
if add_clean_up:
150+
service = self.parse_show_as_object(raw_output)
151+
self.addCleanup(self.openstack,
152+
'service delete %s' % service['id'])
153+
return service_name
154+
155+
def _create_dummy_endpoint(self, add_clean_up=True):
156+
region_id = data_utils.rand_name('TestRegion')
157+
service_name = self._create_dummy_service()
158+
public_url = data_utils.rand_url()
159+
admin_url = data_utils.rand_url()
160+
internal_url = data_utils.rand_url()
161+
raw_output = self.openstack(
162+
'endpoint create '
163+
'--publicurl %(publicurl)s '
164+
'--adminurl %(adminurl)s '
165+
'--internalurl %(internalurl)s '
166+
'--region %(region)s '
167+
'%(service)s' % {'publicurl': public_url,
168+
'adminurl': admin_url,
169+
'internalurl': internal_url,
170+
'region': region_id,
171+
'service': service_name})
172+
items = self.parse_show(raw_output)
173+
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
174+
endpoint = self.parse_show_as_object(raw_output)
175+
if add_clean_up:
176+
self.addCleanup(
177+
self.openstack,
178+
'endpoint delete %s' % endpoint['id'])
179+
return endpoint['id']
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
from functional.tests.identity.v2 import test_identity
14+
15+
16+
class ServiceTests(test_identity.IdentityTests):
17+
18+
def test_service_create(self):
19+
self._create_dummy_service()
20+
21+
def test_service_delete(self):
22+
service_name = self._create_dummy_service(add_clean_up=False)
23+
raw_output = self.openstack('service delete %s' % service_name)
24+
self.assertEqual(0, len(raw_output))
25+
26+
def test_service_list(self):
27+
self._create_dummy_service()
28+
raw_output = self.openstack('service list')
29+
items = self.parse_listing(raw_output)
30+
self.assert_table_structure(items, test_identity.BASIC_LIST_HEADERS)
31+
32+
def test_service_show(self):
33+
service_name = self._create_dummy_service()
34+
raw_output = self.openstack(
35+
'service show %s' % service_name)
36+
items = self.parse_show(raw_output)
37+
self.assert_show_fields(items, self.SERVICE_FIELDS)

0 commit comments

Comments
 (0)