Audited attribute for policy update not changing

Updating firewall policy with shared, name or description is not changing the
audited attribute to false. Modified firewall policy update to make audited
to false.

Change-Id: Ic3f3e08190dcdaa8f4ecda729bdb2fdf1bdadc52
Closes-bug: 1327063
This commit is contained in:
Shivakumar M 2014-07-22 06:22:01 -07:00
parent 732c99ee12
commit bf3750175a
3 changed files with 24 additions and 5 deletions

View File

@ -312,6 +312,8 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
self._set_rules_for_policy(context, fwp_db,
fwp['firewall_rules'])
del fwp['firewall_rules']
if 'audited' not in fwp or fwp['audited']:
fwp['audited'] = False
fwp_db.update(fwp)
return self._make_firewall_policy_dict(fwp_db)

View File

@ -131,13 +131,14 @@ class FirewallPluginDbTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
'enabled': ENABLED}
return attrs
def _get_test_firewall_policy_attrs(self, name='firewall_policy1'):
def _get_test_firewall_policy_attrs(self, name='firewall_policy1',
audited=AUDITED):
attrs = {'name': name,
'description': DESCRIPTION,
'tenant_id': self._tenant_id,
'shared': SHARED,
'firewall_rules': [],
'audited': AUDITED}
'audited': audited}
return attrs
def _get_test_firewall_attrs(self, name='firewall_1'):
@ -373,7 +374,7 @@ class TestFirewallDBPlugin(FirewallPluginDbTestCase):
def test_update_firewall_policy(self):
name = "new_firewall_policy1"
attrs = self._get_test_firewall_policy_attrs(name)
attrs = self._get_test_firewall_policy_attrs(name, audited=False)
with self.firewall_policy(shared=SHARED,
firewall_rules=None,
@ -385,6 +386,22 @@ class TestFirewallDBPlugin(FirewallPluginDbTestCase):
for k, v in attrs.iteritems():
self.assertEqual(res['firewall_policy'][k], v)
def test_update_firewall_policy_set_audited_false(self):
attrs = self._get_test_firewall_policy_attrs(audited=False)
with self.firewall_policy(name='firewall_policy1',
description='fwp',
audited=AUDITED) as fwp:
data = {'firewall_policy':
{'description': 'fw_p1'}}
req = self.new_update_request('firewall_policies', data,
fwp['firewall_policy']['id'])
res = self.deserialize(self.fmt,
req.get_response(self.ext_api))
attrs['description'] = 'fw_p1'
for k, v in attrs.iteritems():
self.assertEqual(res['firewall_policy'][k], v)
def test_update_firewall_policy_with_rules(self):
attrs = self._get_test_firewall_policy_attrs()

View File

@ -291,7 +291,7 @@ class FirewallPluginTestCase(test_db_firewall.FirewallPluginDbTestCase,
def test_update_firewall_policy_with_no_firewall(self):
name = "new_firewall_policy1"
attrs = self._get_test_firewall_policy_attrs(name)
attrs = self._get_test_firewall_policy_attrs(name, audited=False)
with self.firewall_policy(shared=test_db_firewall.SHARED,
firewall_rules=None,
@ -305,7 +305,7 @@ class FirewallPluginTestCase(test_db_firewall.FirewallPluginDbTestCase,
def test_update_firewall_policy_with_firewall(self):
name = "new_firewall_policy1"
attrs = self._get_test_firewall_policy_attrs(name)
attrs = self._get_test_firewall_policy_attrs(name, audited=False)
with self.firewall_policy(shared=test_db_firewall.SHARED,
firewall_rules=None,