From 0b5ff2424a66c5745581a7ddb7a9654196fa34d1 Mon Sep 17 00:00:00 2001 From: Roee Agiman <ragiman@redhat.com> Date: Wed, 1 Nov 2017 17:44:59 +0200 Subject: [PATCH] tests: delete in-use security group The new test added is a negative test that verifies the inability of deleting in-use security group. Change-Id: I118f1998df2184f9a688213cbaf01006f0426909 --- .../api/test_security_groups_negative.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/neutron/tests/tempest/api/test_security_groups_negative.py b/neutron/tests/tempest/api/test_security_groups_negative.py index e381748e67d..44452a82b1f 100644 --- a/neutron/tests/tempest/api/test_security_groups_negative.py +++ b/neutron/tests/tempest/api/test_security_groups_negative.py @@ -27,6 +27,11 @@ class NegativeSecGroupTest(base.BaseSecGroupTest): required_extensions = ['security-group'] + @classmethod + def resource_setup(cls): + super(NegativeSecGroupTest, cls).resource_setup() + cls.network = cls.create_network() + @decorators.attr(type='negative') @decorators.idempotent_id('594edfa8-9a5b-438e-9344-49aece337d49') def test_create_security_group_with_too_long_name(self): @@ -67,6 +72,20 @@ class NegativeSecGroupTest(base.BaseSecGroupTest): self.client.update_security_group, sg['id'], name=True) + @decorators.attr(type='negative') + @decorators.idempotent_id('3200b1a8-d73b-48e9-b03f-e891a4abe2d3') + def test_delete_in_use_sec_group(self): + sgroup = self.os_primary.network_client.create_security_group( + name='sgroup') + self.security_groups.append(sgroup['security_group']) + port = self.client.create_port( + network_id=self.network['id'], + security_groups=[sgroup['security_group']['id']]) + self.ports.append(port['port']) + self.assertRaises(lib_exc.Conflict, + self.os_primary.network_client.delete_security_group, + security_group_id=sgroup['security_group']['id']) + class NegativeSecGroupIPv6Test(NegativeSecGroupTest): _ip_version = constants.IP_VERSION_6