[Negative] Create share with non allowed share type

This test was created due to a bug [1] that was found when
creating a share type with non allowed share type.
When creating a share using a private share from other tenant, i.e.
the tenant has no access to the share type. As expected it failed
with 404, but the share stuck on "creating" status.

Note: This issue happens only when the share type name is used
for creating the share.
Creating a share using share type id works as expected.

[1] https://bugs.launchpad.net/manila/+bug/1885956

Depends-On: https://review.opendev.org/#/c/738941/
Change-Id: I567abccdaa622193b44a9b70bc0481842d8d55f1
Related-Bug: #1885956
This commit is contained in:
lkuchlan 2020-07-12 09:31:52 +03:00
parent 2e12123d97
commit a98919f25f
1 changed files with 32 additions and 0 deletions

View File

@ -128,3 +128,35 @@ class ShareTypesAdminNegativeTest(base.BaseSharesMixedTest):
self.admin_shares_v2_client.remove_access_from_share_type,
data_utils.rand_name("fake"),
self.admin_shares_v2_client.tenant_id)
@decorators.idempotent_id('0fd53c51-e1ba-4392-9f4c-5d3bdd157163')
@tc.attr(base.TAG_NEGATIVE, base.TAG_BACKEND)
def test_create_share_with_non_allowed_share_type(self):
# Create a private share type
name = data_utils.rand_name('share-type')
share_type = self.create_share_type(
client=self.admin_shares_v2_client,
name=name, is_public=False,
extra_specs=self.add_extra_specs_to_dict())['share_type']
# The share type should not be listed without access
share_type_list = (
self.admin_shares_v2_client.list_share_types()['share_types'])
self.assertFalse(
any(share_type['id'] in st['id'] for st in share_type_list))
# List projects that have access for share type - none expected
access = self.admin_shares_v2_client.list_access_to_share_type(
share_type['id'])
self.assertEmpty(access)
# Although the share type should not be found on alt project,
# try to create a share with it by using the share type name
self.assertRaises(lib_exc.NotFound,
self.alt_shares_v2_client.create_share,
share_type_id=share_type['name'])
# The share should not be listed
share_list = self.alt_shares_v2_client.list_shares(detailed=True)
self.assertFalse(
any(share_type['id'] in s['share_type'] for s in share_list))