mirror of
https://github.com/docker/compose.git
synced 2025-07-20 20:24:30 +02:00
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):
|
def format_subnet_ip_address(instance):
|
||||||
if isinstance(instance, six.string_types):
|
if isinstance(instance, six.string_types):
|
||||||
if '/' not in instance:
|
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('/')
|
ip_address, cidr = instance.split('/')
|
||||||
|
|
||||||
if re.match(VALID_IPV4_FORMAT, ip_address):
|
if re.match(VALID_IPV4_FORMAT, ip_address):
|
||||||
if not (re.match(VALID_IPV4_CIDR_FORMAT, cidr) and
|
if not (re.match(VALID_IPV4_CIDR_FORMAT, cidr) and
|
||||||
all(0 <= int(component) <= 255 for component in ip_address.split("."))):
|
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"):
|
elif re.match(VALID_IPV6_CIDR_FORMAT, cidr) and hasattr(socket, "inet_pton"):
|
||||||
try:
|
try:
|
||||||
if not (socket.inet_pton(socket.AF_INET6, ip_address)):
|
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:
|
except socket.error as e:
|
||||||
raise ValidationError(six.text_type(e))
|
raise ValidationError(six.text_type(e))
|
||||||
else:
|
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
|
return True
|
||||||
|
|
||||||
|
@ -2896,8 +2896,11 @@ class SubnetTest(unittest.TestCase):
|
|||||||
for invalid_subnet in self.ILLEGAL_SUBNET_MAPPINGS:
|
for invalid_subnet in self.ILLEGAL_SUBNET_MAPPINGS:
|
||||||
with pytest.raises(ConfigurationError) as exc:
|
with pytest.raises(ConfigurationError) as exc:
|
||||||
self.check_config(invalid_subnet)
|
self.check_config(invalid_subnet)
|
||||||
|
if IS_WINDOWS_PLATFORM:
|
||||||
assert "illegal IP address string" in exc.value.msg
|
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):
|
def test_config_valid_subnet_format_validation(self):
|
||||||
for valid_subnet in self.VALID_SUBNET_MAPPINGS:
|
for valid_subnet in self.VALID_SUBNET_MAPPINGS:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user