mirror of https://github.com/docker/compose.git
Merge pull request #1852 from mnowster/fix-testsuite-post-some-merges
Fix ports validation
This commit is contained in:
commit
2134800cad
|
@ -75,13 +75,9 @@
|
||||||
"pid": {"type": "string"},
|
"pid": {"type": "string"},
|
||||||
|
|
||||||
"ports": {
|
"ports": {
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {"type": "string"},
|
"items": {
|
||||||
"uniqueItems": true,
|
"oneOf": [
|
||||||
"format": "ports"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "ports"
|
"format": "ports"
|
||||||
|
@ -92,6 +88,8 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"uniqueItems": true
|
||||||
|
},
|
||||||
|
|
||||||
"privileged": {"type": "string"},
|
"privileged": {"type": "string"},
|
||||||
"read_only": {"type": "boolean"},
|
"read_only": {"type": "boolean"},
|
||||||
|
|
|
@ -77,7 +77,7 @@ class ConfigTest(unittest.TestCase):
|
||||||
def test_config_invalid_ports_format_validation(self):
|
def test_config_invalid_ports_format_validation(self):
|
||||||
expected_error_msg = "Service 'web' configuration key 'ports' contains an invalid type"
|
expected_error_msg = "Service 'web' configuration key 'ports' contains an invalid type"
|
||||||
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
||||||
for invalid_ports in [{"1": "8000"}, False, 0]:
|
for invalid_ports in [{"1": "8000"}, False, 0, "8000", 8000, ["8000", "8000"]]:
|
||||||
config.load(
|
config.load(
|
||||||
config.ConfigDetails(
|
config.ConfigDetails(
|
||||||
{'web': {'image': 'busybox', 'ports': invalid_ports}},
|
{'web': {'image': 'busybox', 'ports': invalid_ports}},
|
||||||
|
@ -87,7 +87,7 @@ class ConfigTest(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_config_valid_ports_format_validation(self):
|
def test_config_valid_ports_format_validation(self):
|
||||||
valid_ports = [["8000", "9000"], ["8000/8050"], ["8000"], "8000", 8000]
|
valid_ports = [["8000", "9000"], ["8000/8050"], ["8000"], [8000], ["49153-49154:3002-3003"]]
|
||||||
for ports in valid_ports:
|
for ports in valid_ports:
|
||||||
config.load(
|
config.load(
|
||||||
config.ConfigDetails(
|
config.ConfigDetails(
|
||||||
|
|
Loading…
Reference in New Issue