Skip to content

Commit

Permalink
Re-instate security group delete test case
Browse files Browse the repository at this point in the history
While fixing lp#956366, we realized that it's fine to delete a security
group referenced by an ingress rule of another security group because
the ingress rule gets deleted.

Re-instate the test for this specific case, but test that the ingress
rule gets deleted rather than an exception being thrown.

Change-Id: I81ad16431f5f8f13561dfcb320213366e1e8864e
  • Loading branch information
markmc authored and vishvananda committed Mar 27, 2012
1 parent 11644a2 commit fd0ea77
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nova/tests/api/ec2/test_cloud.py
Expand Up @@ -496,6 +496,25 @@ def test_revoke_security_group_ingress_missing_group_name_or_id(self):
self.assertRaises(exception.EC2APIError, revoke,
self.context, **kwargs)

def test_delete_security_group_in_use_by_group(self):
group1 = self.cloud.create_security_group(self.context, 'testgrp1',
"test group 1")
group2 = self.cloud.create_security_group(self.context, 'testgrp2',
"test group 2")
kwargs = {'groups': {'1': {'user_id': u'%s' % self.context.user_id,
'group_name': u'testgrp2'}},
}
self.cloud.authorize_security_group_ingress(self.context,
group_name='testgrp1', **kwargs)

group1 = db.security_group_get_by_name(self.context,
self.project_id, 'testgrp1')
get_rules = db.security_group_rule_get_by_security_group

self.assertTrue(get_rules(self.context, group1.id))
self.cloud.delete_security_group(self.context, 'testgrp2')
self.assertFalse(get_rules(self.context, group1.id))

def test_delete_security_group_in_use_by_instance(self):
"""Ensure that a group can not be deleted if in use by an instance."""
image_uuid = 'cedef40a-ed67-4d10-800e-17455edce175'
Expand Down

0 comments on commit fd0ea77

Please sign in to comment.