mirror of https://github.com/docker/compose.git
Fix subnet config test for windows
Signed-off-by: Drew Romanyk <drewiswaycool@gmail.com>
This commit is contained in:
parent
cf782a3dbb
commit
fa61a91cb5
|
@ -72,22 +72,24 @@ def format_expose(instance):
|
|||
def format_subnet_ip_address(instance):
|
||||
if isinstance(instance, six.string_types):
|
||||
if '/' not in instance:
|
||||
raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'")
|
||||
raise ValidationError("'{0}' 75 should be of the format 'IP_ADDRESS/CIDR'".format(instance))
|
||||
|
||||
ip_address, cidr = instance.split('/')
|
||||
|
||||
if re.match(VALID_IPV4_FORMAT, ip_address):
|
||||
if not (re.match(VALID_IPV4_CIDR_FORMAT, cidr) and
|
||||
all(0 <= int(component) <= 255 for component in ip_address.split("."))):
|
||||
raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'")
|
||||
raise ValidationError(
|
||||
"'{0}' 83 should be of the format 'IP_ADDRESS/CIDR'".format(instance))
|
||||
elif re.match(VALID_IPV6_CIDR_FORMAT, cidr) and hasattr(socket, "inet_pton"):
|
||||
try:
|
||||
if not (socket.inet_pton(socket.AF_INET6, ip_address)):
|
||||
raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'")
|
||||
raise ValidationError(
|
||||
"'{0}' 88 should be of the format 'IP_ADDRESS/CIDR'".format(instance))
|
||||
except socket.error as e:
|
||||
raise ValidationError(six.text_type(e))
|
||||
else:
|
||||
raise ValidationError("should be of the format 'IP_ADDRESS/CIDR'")
|
||||
raise ValidationError("'{0}' 92 should be of the format 'IP_ADDRESS/CIDR'".format(instance))
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -2896,8 +2896,11 @@ class SubnetTest(unittest.TestCase):
|
|||
for invalid_subnet in self.ILLEGAL_SUBNET_MAPPINGS:
|
||||
with pytest.raises(ConfigurationError) as exc:
|
||||
self.check_config(invalid_subnet)
|
||||
|
||||
assert "illegal IP address string" in exc.value.msg
|
||||
if IS_WINDOWS_PLATFORM:
|
||||
assert "An invalid argument was supplied" in exc.value.msg or \
|
||||
"illegal IP address string" in exc.value.msg
|
||||
else:
|
||||
assert "illegal IP address string" in exc.value.msg
|
||||
|
||||
def test_config_valid_subnet_format_validation(self):
|
||||
for valid_subnet in self.VALID_SUBNET_MAPPINGS:
|
||||
|
|
Loading…
Reference in New Issue