Merge "Making IP protocol field required"

This commit is contained in:
Zuul 2025-05-06 13:44:15 +00:00 committed by Gerrit Code Review
commit dbafbae3f8
2 changed files with 9 additions and 9 deletions

View File

@ -126,8 +126,9 @@ class AddRule(forms.SelfHandlingForm):
}))
ip_protocol = forms.IntegerField(
label=_('IP Protocol'), required=False,
help_text=_("Enter an integer value between 0 and 255."),
label=_('IP Protocol'), required=True,
help_text=_("Enter an integer value between -1 and 255 "
"(-1 means wild card)."),
validators=[utils_validators.validate_ip_protocol],
widget=forms.TextInput(attrs={
'class': 'switched',
@ -283,10 +284,6 @@ class AddRule(forms.SelfHandlingForm):
self.fields['direction'].choices = [('ingress', _('Ingress')),
('egress', _('Egress'))]
self.fields['ip_protocol'].help_text = _(
"Enter an integer value between -1 and 255 "
"(-1 means wild card)."
)
self.fields['port_or_range'].choices = [
('port', _('Port')),

View File

@ -461,7 +461,8 @@ class SecurityGroupsViewTests(test.TestCase):
'rule_menu': 'http',
'port_or_range': 'port',
'cidr': rule.ip_range['cidr'],
'remote': 'cidr'}
'remote': 'cidr',
'ip_protocol': 6}
res = self.client.post(self.edit_url, formData)
self.assertRedirectsNoFollow(res, self.detail_url)
@ -544,7 +545,8 @@ class SecurityGroupsViewTests(test.TestCase):
'port_or_range': 'port',
'cidr': '0.0.0.0/0',
'security_group': sec_group.id,
'remote': 'sg'}
'remote': 'sg',
'ip_protocol': 6}
res = self.client.post(self.edit_url, formData)
self.assertRedirectsNoFollow(res, self.detail_url)
@ -931,7 +933,8 @@ class SecurityGroupsViewTests(test.TestCase):
'port_or_range': 'range',
'rule_menu': 'all_tcp',
'cidr': rule.ip_range['cidr'],
'remote': 'cidr'}
'remote': 'cidr',
'ip_protocol': 6}
res = self.client.post(self.edit_url, formData)
self.assertRedirectsNoFollow(res, self.detail_url)