From e92f09f3228a118071a757f41bf294688091d692 Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Thu, 16 Mar 2017 17:25:47 +0300 Subject: [PATCH] [Share Groups] Fix creation of share group types with wrong specs values If we provide some other type than None or dict as group specs creating share group type, then we get error 500 caused by unhandled exception. So, avoid it by explicitly checking type of provided group specs. Change-Id: I81312617f37a8f559b3c9201b03cf8be31761365 Closes-Bug: #1673446 --- .../tests/api/admin/test_share_group_types_negative.py | 9 +++++++++ manila_tempest_tests/tests/api/base.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/manila_tempest_tests/tests/api/admin/test_share_group_types_negative.py b/manila_tempest_tests/tests/api/admin/test_share_group_types_negative.py index 18e8cdde..6dfe2045 100644 --- a/manila_tempest_tests/tests/api/admin/test_share_group_types_negative.py +++ b/manila_tempest_tests/tests/api/admin/test_share_group_types_negative.py @@ -69,6 +69,15 @@ class ShareGroupTypesAdminNegativeTest(base.BaseSharesMixedTest): self.create_share_group_type, "x" * 256, client=self.admin_shares_v2_client) + @tc.attr(base.TAG_NEGATIVE, base.TAG_API) + def test_create_share_group_type_with_wrong_value_for_group_specs(self): + self.assertRaises( + lib_exc.BadRequest, + self.admin_shares_v2_client.create_share_group_type, + name=data_utils.rand_name("tempest_manila"), + share_types=[self.share_type['share_type']['id']], + group_specs="expecting_error_code_400") + @tc.attr(base.TAG_NEGATIVE, base.TAG_API) def test_get_share_group_type_using_nonexistent_id(self): self.assertRaises( diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py index 236351dd..3df71537 100644 --- a/manila_tempest_tests/tests/api/base.py +++ b/manila_tempest_tests/tests/api/base.py @@ -595,7 +595,8 @@ class BaseSharesTest(test.BaseTestCase): group_specs=None, client=None, cleanup_in_class=True, **kwargs): client = client or cls.shares_v2_client - if group_specs is None: + if (group_specs is None and + CONF.share.capability_sg_consistent_snapshot_support): group_specs = { 'consistent_snapshot_support': ( CONF.share.capability_sg_consistent_snapshot_support),