Skip to content

Commit 0a760e2

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Added functional tests for 'service provider' v3 commands"
2 parents 9d65abc + add0e10 commit 0a760e2

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

functional/tests/identity/v3/test_identity.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class IdentityTests(test.TestCase):
4444
IDENTITY_PROVIDER_FIELDS = ['description', 'enabled', 'id', 'remote_ids']
4545
IDENTITY_PROVIDER_LIST_HEADERS = ['ID', 'Enabled', 'Description']
4646

47+
SERVICE_PROVIDER_FIELDS = ['auth_url', 'description', 'enabled',
48+
'id', 'relay_state_prefix', 'sp_url']
49+
SERVICE_PROVIDER_LIST_HEADERS = ['ID', 'Enabled', 'Description',
50+
'Auth URL']
51+
4752
@classmethod
4853
def setUpClass(cls):
4954
if hasattr(super(IdentityTests, cls), 'setUpClass'):
@@ -269,3 +274,22 @@ def _create_dummy_idp(self, add_clean_up=True):
269274
self.openstack,
270275
'identity provider delete %s' % identity_provider)
271276
return identity_provider
277+
278+
def _create_dummy_sp(self, add_clean_up=True):
279+
service_provider = data_utils.rand_name('ServiceProvider')
280+
description = data_utils.rand_name('description')
281+
raw_output = self.openstack(
282+
'service provider create '
283+
' %(name)s '
284+
'--description %(description)s '
285+
'--auth-url https://sp.example.com:35357 '
286+
'--service-provider-url https://sp.example.com:5000 '
287+
'--enable ' % {'name': service_provider,
288+
'description': description})
289+
items = self.parse_show(raw_output)
290+
self.assert_show_fields(items, self.SERVICE_PROVIDER_FIELDS)
291+
if add_clean_up:
292+
self.addCleanup(
293+
self.openstack,
294+
'service provider delete %s' % service_provider)
295+
return service_provider
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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.v3 import test_identity
14+
from tempest_lib.common.utils import data_utils
15+
16+
17+
class ServiceProviderTests(test_identity.IdentityTests):
18+
# Introduce functional test cases for command 'Service Provider'
19+
20+
def test_sp_create(self):
21+
self._create_dummy_sp(add_clean_up=True)
22+
23+
def test_sp_delete(self):
24+
service_provider = self._create_dummy_sp(add_clean_up=False)
25+
raw_output = self.openstack('service provider delete %s'
26+
% service_provider)
27+
self.assertEqual(0, len(raw_output))
28+
29+
def test_sp_show(self):
30+
service_provider = self._create_dummy_sp(add_clean_up=True)
31+
raw_output = self.openstack('service provider show %s'
32+
% service_provider)
33+
items = self.parse_show(raw_output)
34+
self.assert_show_fields(items, self.SERVICE_PROVIDER_FIELDS)
35+
36+
def test_sp_list(self):
37+
self._create_dummy_sp(add_clean_up=True)
38+
raw_output = self.openstack('service provider list')
39+
items = self.parse_listing(raw_output)
40+
self.assert_table_structure(items, self.SERVICE_PROVIDER_LIST_HEADERS)
41+
42+
def test_sp_set(self):
43+
service_provider = self._create_dummy_sp(add_clean_up=True)
44+
new_description = data_utils.rand_name('newDescription')
45+
raw_output = self.openstack('service provider set '
46+
'%(service-provider)s '
47+
'--description %(description)s '
48+
% {'service-provider': service_provider,
49+
'description': new_description})
50+
self.assertEqual(0, len(raw_output))
51+
raw_output = self.openstack('service provider show %s'
52+
% service_provider)
53+
updated_value = self.parse_show_as_object(raw_output)
54+
self.assertIn(new_description, updated_value['description'])

0 commit comments

Comments
 (0)