Fix add policy missing rule issue
In firewalls/workflows.py retrieve 'rule' instead of 'firewall_rules' from AddPolciy post message. In test_add_policy_post, we need to ensure 'firewall_policy_id' field is not set before added to policy. Change-Id: I5f9ff81f42f4f8c7ce5c638c9074cc2dec4e1434 Closes-Bug: #1231235
This commit is contained in:
parent
e7fa1da5b9
commit
37f2916b33
@ -264,6 +264,21 @@ class FirewallTests(test.TestCase):
|
|||||||
'shared': policy.shared,
|
'shared': policy.shared,
|
||||||
'audited': policy.audited
|
'audited': policy.audited
|
||||||
}
|
}
|
||||||
|
post_data = {'name': policy.name,
|
||||||
|
'description': policy.description,
|
||||||
|
'rule': policy.firewall_rules,
|
||||||
|
'shared': policy.shared,
|
||||||
|
'audited': policy.audited
|
||||||
|
}
|
||||||
|
|
||||||
|
# NOTE: SelectRulesAction.populate_rule_choices() lists rule not
|
||||||
|
# associated with any policy. We need to ensure that rules specified
|
||||||
|
# in policy.firewall_rules in post_data (above) are not associated
|
||||||
|
# with any policy. Test data in neutron_data is data in a stable state,
|
||||||
|
# so we need to modify here.
|
||||||
|
for rule in rules:
|
||||||
|
if rule.id in policy.firewall_rules:
|
||||||
|
rule.firewall_policy_id = rule.policy = None
|
||||||
api.fwaas.rules_list(
|
api.fwaas.rules_list(
|
||||||
IsA(http.HttpRequest), tenant_id=tenant_id).AndReturn(rules)
|
IsA(http.HttpRequest), tenant_id=tenant_id).AndReturn(rules)
|
||||||
api.fwaas.policy_create(
|
api.fwaas.policy_create(
|
||||||
@ -271,7 +286,7 @@ class FirewallTests(test.TestCase):
|
|||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
res = self.client.post(reverse(self.ADDPOLICY_PATH), form_data)
|
res = self.client.post(reverse(self.ADDPOLICY_PATH), post_data)
|
||||||
|
|
||||||
self.assertNoFormErrors(res)
|
self.assertNoFormErrors(res)
|
||||||
self.assertRedirectsNoFollow(res, str(self.INDEX_URL))
|
self.assertRedirectsNoFollow(res, str(self.INDEX_URL))
|
||||||
|
@ -170,7 +170,7 @@ class SelectRulesStep(workflows.Step):
|
|||||||
|
|
||||||
def contribute(self, data, context):
|
def contribute(self, data, context):
|
||||||
if data:
|
if data:
|
||||||
rules = self.workflow.request.POST.getlist("firewall_rules")
|
rules = self.workflow.request.POST.getlist("rule")
|
||||||
if rules:
|
if rules:
|
||||||
rules = [r for r in rules if r != '']
|
rules = [r for r in rules if r != '']
|
||||||
context['firewall_rules'] = rules
|
context['firewall_rules'] = rules
|
||||||
|
Loading…
Reference in New Issue
Block a user