Kaydet (Commit) 54b3c364 authored tarafından Joffrey F's avatar Joffrey F

Raise an error when passing an empty string to split_port

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst c2d114c0
......@@ -67,6 +67,8 @@ def split_port(port):
if len(parts) == 1:
internal_port, = parts
if not internal_port:
_raise_invalid_port(port)
return to_port_range(internal_port), None
if len(parts) == 2:
external_port, internal_port = parts
......
......@@ -23,8 +23,6 @@ class InformationTest(BaseAPIIntegrationTest):
self.assertIn('Containers', res)
self.assertIn('Images', res)
self.assertIn('Debug', res)
print(res)
self.fail()
class LoadConfigTest(BaseAPIIntegrationTest):
......
......@@ -578,6 +578,9 @@ class PortsTest(unittest.TestCase):
self.assertRaises(ValueError,
lambda: split_port("localhost:80:"))
def test_split_port_empty_string(self):
self.assertRaises(ValueError, lambda: split_port(""))
def test_build_port_bindings_with_one_port(self):
port_bindings = build_port_bindings(["127.0.0.1:1000:1000"])
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000")])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment