mirror of https://github.com/docker/docker-py.git
				
				
				
			Merge pull request #1501 from max8899/fix/split_port
fix: Missing exception handling in split_port when no container port
This commit is contained in:
		
						commit
						12f1a6957e
					
				|  | @ -85,8 +85,13 @@ def split_port(port): | |||
|         return internal_range, external_range | ||||
| 
 | ||||
|     external_ip, external_port, internal_port = parts | ||||
| 
 | ||||
|     if not internal_port: | ||||
|         _raise_invalid_port(port) | ||||
| 
 | ||||
|     internal_range = to_port_range(internal_port) | ||||
|     external_range = to_port_range(external_port, len(internal_range) == 1) | ||||
| 
 | ||||
|     if not external_range: | ||||
|         external_range = [None] * len(internal_range) | ||||
| 
 | ||||
|  |  | |||
|  | @ -574,6 +574,10 @@ class PortsTest(unittest.TestCase): | |||
|         self.assertRaises(ValueError, | ||||
|                           lambda: split_port("localhost:")) | ||||
| 
 | ||||
|     def test_with_no_container_port(self): | ||||
|         self.assertRaises(ValueError, | ||||
|                           lambda: split_port("localhost:80:")) | ||||
| 
 | ||||
|     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")]) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue