Merge "Fix add policy missing rule issue"

This commit is contained in:
Jenkins 2013-10-02 10:59:44 +00:00 committed by Gerrit Code Review
commit 92708aef2c
2 changed files with 17 additions and 2 deletions

View File

@ -264,6 +264,21 @@ class FirewallTests(test.TestCase):
'shared': policy.shared,
'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(
IsA(http.HttpRequest), tenant_id=tenant_id).AndReturn(rules)
api.fwaas.policy_create(
@ -271,7 +286,7 @@ class FirewallTests(test.TestCase):
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.assertRedirectsNoFollow(res, str(self.INDEX_URL))

View File

@ -166,7 +166,7 @@ class SelectRulesStep(workflows.Step):
def contribute(self, data, context):
if data:
rules = self.workflow.request.POST.getlist("firewall_rules")
rules = self.workflow.request.POST.getlist("rule")
if rules:
rules = [r for r in rules if r != '']
context['firewall_rules'] = rules