Merge "Don't return 404 when deleting a non-existant FWG"
This commit is contained in:
commit
0b44edec7c
|
@ -802,10 +802,9 @@ class Firewall_db_mixin_v2(fw_ext.Firewallv2PluginBase, base_db.CommonDbMixin):
|
|||
with context.session.begin(subtransactions=True):
|
||||
# Note: Plugin should ensure that it's okay to delete if the
|
||||
# firewall is active
|
||||
count = context.session.query(
|
||||
context.session.query(
|
||||
FirewallGroup).filter_by(id=id).delete()
|
||||
if not count:
|
||||
raise f_exc.FirewallGroupNotFound(firewall_id=id)
|
||||
# No need to check if FWG exists -- if it's deleted it's deleted
|
||||
|
||||
def get_firewall_group(self, context, id, fields=None):
|
||||
LOG.debug("get_firewall_group() called")
|
||||
|
|
|
@ -1290,7 +1290,7 @@ class TestFirewallDBPluginV2(FirewallPluginV2DbTestCase):
|
|||
res = req.get_response(self.ext_api)
|
||||
self.assertEqual(404, res.status_int)
|
||||
|
||||
def test_delete_firewall(self):
|
||||
def test_delete_firewall_group(self):
|
||||
ctx = context.get_admin_context()
|
||||
with self.firewall_policy() as fwp:
|
||||
fwp_id = fwp['firewall_policy']['id']
|
||||
|
@ -1304,6 +1304,14 @@ class TestFirewallDBPluginV2(FirewallPluginV2DbTestCase):
|
|||
self.plugin.get_firewall_group,
|
||||
ctx, fw_id)
|
||||
|
||||
def test_delete_firewall_group_already_deleted(self):
|
||||
ctx = context.get_admin_context()
|
||||
deleted_id = uuidutils.generate_uuid()
|
||||
with self.firewall_group(do_delete=False) as fwg:
|
||||
fwg_id = fwg['firewall_group']['id']
|
||||
self.assertIsNone(self.plugin.delete_firewall_group(ctx, fwg_id))
|
||||
self.assertIsNone(self.plugin.delete_firewall_group(ctx, deleted_id))
|
||||
|
||||
def test_insert_rule_in_policy_with_prior_rules_added_via_update(self):
|
||||
attrs = self._get_test_firewall_policy_attrs()
|
||||
attrs['audited'] = False
|
||||
|
|
Loading…
Reference in New Issue