Merge "Fix incorrect url request for share group type extra specs"

This commit is contained in:
Zuul 2022-11-30 20:40:46 +00:00 committed by Gerrit Code Review
commit 8dc1658881
3 changed files with 65 additions and 4 deletions

View File

@ -1299,7 +1299,7 @@ class SharesV2Client(shares_client.SharesClient):
def get_share_group_type_spec(self, share_group_type_id, group_spec_key,
version=LATEST_MICROVERSION):
uri = "group-types/%s/group_specs/%s" % (
uri = "share-group-types/%s/group-specs/%s" % (
share_group_type_id, group_spec_key)
headers, extra_headers = utils.get_extra_headers(
version, constants.SHARE_GROUPS_GRADUATION_VERSION)
@ -1309,9 +1309,9 @@ class SharesV2Client(shares_client.SharesClient):
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
def list_share_group_type_specs(self, share_group_type_id, params=None,
version=LATEST_MICROVERSION):
uri = "share-group-types/%s/group_specs" % share_group_type_id
def get_share_group_type_specs(self, share_group_type_id, params=None,
version=LATEST_MICROVERSION):
uri = "share-group-types/%s/group-specs" % share_group_type_id
headers, extra_headers = utils.get_extra_headers(
version, constants.SHARE_GROUPS_GRADUATION_VERSION)
if params is not None:

View File

@ -142,6 +142,42 @@ class ShareGroupTypesTest(base.BaseSharesAdminTest):
self.assertDictMatch(group_specs, sg_type['group_specs'])
@decorators.idempotent_id('dd620bfd-197b-4675-ace6-e26f809bb26e')
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_get_one_share_group_type_extra_spec(self):
name = data_utils.rand_name('share-group-type')
group_specs = {'key1': 'value1', 'key2': 'value2'}
sg_type = self.create_share_group_type(
name=name,
share_types=self.share_type['id'],
group_specs=group_specs,
cleanup_in_class=False,
version=constants.MIN_SHARE_GROUP_MICROVERSION)
extra_spec = self.shares_v2_client.get_share_group_type_spec(
sg_type['id'], 'key1')
self.assertEqual({'key1': group_specs['key1']}, extra_spec)
@decorators.idempotent_id('eef69171-9757-423c-8cd4-487cbd84ca24')
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_get_all_share_group_type_extra_specs(self):
name = data_utils.rand_name('share-group-type')
group_specs = {'key': 'value'}
sg_type = self.create_share_group_type(
name=name,
share_types=self.share_type['id'],
group_specs=group_specs,
cleanup_in_class=False,
version=constants.MIN_SHARE_GROUP_MICROVERSION)
extra_specs = self.shares_v2_client.get_share_group_type_specs(
sg_type['id'])
self.assertDictMatch(group_specs, extra_specs['group_specs'])
@decorators.idempotent_id('15b44580-a34d-4e0d-a77b-0e76b45d6199')
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@ddt.data(

View File

@ -44,6 +44,7 @@ class ShareGroupTypesAdminNegativeTest(base.BaseSharesMixedTest):
cls.share_group_type = cls.create_share_group_type(
data_utils.rand_name("unique_sgt_name"),
share_types=[cls.share_type['id']],
group_specs={"key": "value"},
client=cls.admin_shares_v2_client)
@decorators.idempotent_id('1f8e3f98-4df7-4383-94d6-4ad058ef79c1')
@ -163,3 +164,27 @@ class ShareGroupTypesAdminNegativeTest(base.BaseSharesMixedTest):
self.admin_shares_v2_client.remove_access_from_share_group_type,
data_utils.rand_name("fake"),
self.admin_shares_v2_client.tenant_id)
@decorators.idempotent_id('3e763f5b-6663-4620-9471-ed3050da6201')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_get_share_group_type_extra_specs_with_user(self):
self.assertRaises(
lib_exc.Forbidden,
self.shares_v2_client.get_share_group_type_specs,
self.share_group_type['id'])
@decorators.idempotent_id('2264f7eb-3ff0-47e9-8ab0-54694113db3d')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_get_extra_specs_from_nonexistent_share_group_type(self):
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_group_type_specs,
data_utils.rand_name('fake'))
@decorators.idempotent_id('2be79455-0ce7-4ca6-818f-40651ba79c6e')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_get_extra_spec_with_nonexistent_key(self):
self.assertRaises(
lib_exc.NotFound,
self.admin_shares_v2_client.get_share_group_type_spec,
self.share_group_type['id'], 'fake_key')