Add functional tests for group type access
This change tests the positive scenarios for share group type access commands. Co-authored-by: Vida Haririan <vhariria@redhat.com> Change-Id: I244a9526832cf683d9a2b466aeae6c09f2073a25
This commit is contained in:
parent
f3eea6bbea
commit
27a8a06dd9
@ -348,3 +348,41 @@ class OSCClientTestBase(base.ClientTestBase):
|
|||||||
cmd = (f'replica export location list {replica}')
|
cmd = (f'replica export location list {replica}')
|
||||||
export_locations = self.listing_result('share', cmd)
|
export_locations = self.listing_result('share', cmd)
|
||||||
return export_locations
|
return export_locations
|
||||||
|
|
||||||
|
def create_share_group_type(self, name=None, share_types=None,
|
||||||
|
group_specs=None, public=True,
|
||||||
|
add_cleanup=True):
|
||||||
|
|
||||||
|
name = name or data_utils.rand_name('autotest_share_group_types_name')
|
||||||
|
share_types = share_types or 'None'
|
||||||
|
|
||||||
|
cmd = (f'group type create '
|
||||||
|
f'{name} '
|
||||||
|
f'{share_types} ')
|
||||||
|
|
||||||
|
if group_specs:
|
||||||
|
cmd = cmd + f' --group_specs {group_specs} '
|
||||||
|
if not public:
|
||||||
|
cmd = cmd + f' --public {public} '
|
||||||
|
|
||||||
|
share_object = self.dict_result('share', cmd)
|
||||||
|
|
||||||
|
if add_cleanup:
|
||||||
|
self.addCleanup(
|
||||||
|
self.openstack,
|
||||||
|
'share group type delete %s' % share_object['id'])
|
||||||
|
return share_object
|
||||||
|
|
||||||
|
def share_group_type_access_create(self, group_type, project):
|
||||||
|
cmd = (f'group type access create '
|
||||||
|
f'{group_type} '
|
||||||
|
f'{project} ')
|
||||||
|
|
||||||
|
self.dict_result('share', cmd)
|
||||||
|
|
||||||
|
def share_group_type_access_delete(self, group_type, access_id):
|
||||||
|
cmd = (f'group type access delete '
|
||||||
|
f'{group_type} '
|
||||||
|
f'{access_id} ')
|
||||||
|
|
||||||
|
self.dict_result('share', cmd)
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
# 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 oslo_serialization import jsonutils
|
||||||
|
|
||||||
|
from manilaclient.tests.functional.osc import base
|
||||||
|
|
||||||
|
|
||||||
|
class SharesGroupTypeAccessCLITest(base.OSCClientTestBase):
|
||||||
|
|
||||||
|
def test_share_group_type_access_create(self):
|
||||||
|
share_group_type_name = self.create_share_group_type(
|
||||||
|
share_types='dhss_false', public=False)['name']
|
||||||
|
|
||||||
|
access_list = self.listing_result(
|
||||||
|
'share', f'group type access list {share_group_type_name}')
|
||||||
|
self.assertEqual(0, len(access_list))
|
||||||
|
|
||||||
|
cmd_output = jsonutils.loads(self.openstack('token issue -f json '))
|
||||||
|
auth_project_id = cmd_output['project_id']
|
||||||
|
|
||||||
|
self.share_group_type_access_create(
|
||||||
|
share_group_type_name, auth_project_id)
|
||||||
|
|
||||||
|
share_group_type_access_list = self.listing_result(
|
||||||
|
'share', f'group type access list {share_group_type_name}')
|
||||||
|
|
||||||
|
self.assertEqual(1, len(share_group_type_access_list))
|
||||||
|
|
||||||
|
def test_share_group_type_access_delete(self):
|
||||||
|
share_group_type_name = self.create_share_group_type(
|
||||||
|
share_types='dhss_false', public=False)['name']
|
||||||
|
|
||||||
|
access_list = self.listing_result(
|
||||||
|
'share', f'group type access list {share_group_type_name}')
|
||||||
|
self.assertEqual(0, len(access_list))
|
||||||
|
|
||||||
|
cmd_output = jsonutils.loads(self.openstack('token issue -f json '))
|
||||||
|
auth_project_id = cmd_output['project_id']
|
||||||
|
|
||||||
|
# Create using name to ensure that we are "translating" the
|
||||||
|
# name into the actual ID in the CLI
|
||||||
|
self.share_group_type_access_create(
|
||||||
|
share_group_type_name, auth_project_id)
|
||||||
|
|
||||||
|
share_group_type_access_list = self.listing_result(
|
||||||
|
'share', f'group type access list {share_group_type_name}')
|
||||||
|
|
||||||
|
self.assertEqual(1, len(share_group_type_access_list))
|
||||||
|
self.assertEqual(
|
||||||
|
share_group_type_access_list[0]['Project ID'], auth_project_id)
|
||||||
|
|
||||||
|
self.share_group_type_access_delete(
|
||||||
|
share_group_type_name, auth_project_id)
|
||||||
|
|
||||||
|
access_list = self.listing_result(
|
||||||
|
'share', f'group type access list {share_group_type_name}')
|
||||||
|
self.assertEqual(0, len(access_list))
|
||||||
|
|
||||||
|
def test_share_group_type_access_list(self):
|
||||||
|
share_group_type_name = self.create_share_group_type(
|
||||||
|
share_types='dhss_false', public=False)['name']
|
||||||
|
|
||||||
|
access_list = self.listing_result(
|
||||||
|
'share', f'group type access list {share_group_type_name}')
|
||||||
|
self.assertEqual(0, len(access_list))
|
||||||
|
|
||||||
|
cmd_output = jsonutils.loads(self.openstack('token issue -f json '))
|
||||||
|
auth_project_id = cmd_output['project_id']
|
||||||
|
|
||||||
|
self.share_group_type_access_create(
|
||||||
|
share_group_type_name, auth_project_id)
|
||||||
|
|
||||||
|
share_group_type_access_list = self.listing_result(
|
||||||
|
'share', f'group type access list {share_group_type_name}')
|
||||||
|
|
||||||
|
self.assertEqual(1, len(share_group_type_access_list))
|
||||||
|
self.assertTableStruct(access_list, ['Project ID'])
|
Loading…
Reference in New Issue
Block a user