Merge "Revert "Neutron: fix ICMP code and type validators""
This commit is contained in:
commit
0229266b92
@ -218,18 +218,6 @@ class ValidatorsTests(test.TestCase):
|
||||
validators.validate_ip_protocol,
|
||||
proto)
|
||||
|
||||
def test_icmp_code_type(self):
|
||||
VALID_VALUE = (0, 255)
|
||||
INVALID_VALUE = (-1, 256)
|
||||
|
||||
for value in VALID_VALUE:
|
||||
self.assertIsNone(validators.validate_icmp(value))
|
||||
|
||||
for value in INVALID_VALUE:
|
||||
self.assertRaises(ValidationError,
|
||||
validators.validate_icmp,
|
||||
value)
|
||||
|
||||
def test_port_range_validator(self):
|
||||
VALID_RANGE = ('1:65535',
|
||||
'1:1')
|
||||
|
@ -62,12 +62,6 @@ def validate_metadata(value):
|
||||
if not len(keyval) == 2 or not keyval[0]:
|
||||
raise ValidationError(error_msg)
|
||||
|
||||
|
||||
def validate_icmp(code_or_type):
|
||||
if code_or_type not in range(0, 256):
|
||||
raise ValidationError(_("Not a valid ICMP code or type"))
|
||||
|
||||
|
||||
# Same as POSIX [:print:]. Accordingly, diacritics are disallowed.
|
||||
PRINT_REGEX = re.compile(r'^[\x20-\x7E]*$')
|
||||
|
||||
|
@ -186,7 +186,7 @@ class AddRule(forms.SelfHandlingForm):
|
||||
'data-switch-on': 'rule_menu',
|
||||
'data-rule_menu-icmp': _('Type')}),
|
||||
validators=[
|
||||
utils_validators.validate_icmp])
|
||||
utils_validators.validate_port_range])
|
||||
|
||||
icmp_code = forms.IntegerField(label=_("Code"),
|
||||
required=False,
|
||||
@ -197,7 +197,7 @@ class AddRule(forms.SelfHandlingForm):
|
||||
'data-switch-on': 'rule_menu',
|
||||
'data-rule_menu-icmp': _('Code')}),
|
||||
validators=[
|
||||
utils_validators.validate_icmp])
|
||||
utils_validators.validate_port_range])
|
||||
|
||||
remote = forms.ChoiceField(label=_('Remote'),
|
||||
choices=[('cidr', _('CIDR')),
|
||||
|
@ -500,7 +500,7 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
'remote': 'cidr'}
|
||||
res = self.client.post(self.edit_url, formData)
|
||||
self.assertNoMessages()
|
||||
self.assertContains(res, "Not a valid ICMP code or type")
|
||||
self.assertContains(res, "The ICMP type not in range (-1, 255)")
|
||||
|
||||
formData = {'method': 'AddRule',
|
||||
'id': sec_group.id,
|
||||
@ -512,7 +512,7 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
'remote': 'cidr'}
|
||||
res = self.client.post(self.edit_url, formData)
|
||||
self.assertNoMessages()
|
||||
self.assertContains(res, "Not a valid ICMP code or type")
|
||||
self.assertContains(res, "The ICMP code not in range (-1, 255)")
|
||||
|
||||
formData = {'method': 'AddRule',
|
||||
'id': sec_group.id,
|
||||
|
Loading…
Reference in New Issue
Block a user