diff --git a/horizon/test/tests/utils.py b/horizon/test/tests/utils.py index d71710912..7077bfcdd 100644 --- a/horizon/test/tests/utils.py +++ b/horizon/test/tests/utils.py @@ -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') diff --git a/horizon/utils/validators.py b/horizon/utils/validators.py index e8dd3f1a5..d2103bf0c 100644 --- a/horizon/utils/validators.py +++ b/horizon/utils/validators.py @@ -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]*$') diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py index 4437dd039..f38227c8f 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py @@ -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')), diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py index d2386c26b..606171301 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py @@ -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,