diff options
author | Joffrey F <joffrey@docker.com> | 2018-11-01 14:57:29 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-11-01 15:44:43 -0700 |
commit | f302756599a61d6775fbdf2beab8f1de7e0022c4 (patch) | |
tree | 306d5ed162f68fc86cd6acb9a78043b830787cdd /tests/unit/utils_test.py | |
parent | 6bfe2005e0a700621c094a01b42db39e7c6408de (diff) | |
download | docker-py-ssh_protocol_support.tar.gz |
Rewrite utils.parse_host to detect more invalid addresses.ssh_protocol_support
The method now uses parsing methods from urllib to better split provided URLs.
Addresses containing query strings, parameters, passwords or fragments no longer fail silently.
SSH addresses containing paths are no longer accepted.
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/unit/utils_test.py')
-rw-r--r-- | tests/unit/utils_test.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 8880cfe..c862a1c 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -272,6 +272,11 @@ class ParseHostTest(unittest.TestCase): 'tcp://', 'udp://127.0.0.1', 'udp://127.0.0.1:2375', + 'ssh://:22/path', + 'tcp://netloc:3333/path?q=1', + 'unix:///sock/path#fragment', + 'https://netloc:3333/path;params', + 'ssh://:clearpassword@host:22', ] valid_hosts = { @@ -281,7 +286,7 @@ class ParseHostTest(unittest.TestCase): 'http://:7777': 'http://127.0.0.1:7777', 'https://kokia.jp:2375': 'https://kokia.jp:2375', 'unix:///var/run/docker.sock': 'http+unix:///var/run/docker.sock', - 'unix://': 'http+unix://var/run/docker.sock', + 'unix://': 'http+unix:///var/run/docker.sock', '12.234.45.127:2375/docker/engine': ( 'http://12.234.45.127:2375/docker/engine' ), @@ -294,6 +299,9 @@ class ParseHostTest(unittest.TestCase): '[fd12::82d1]:2375/docker/engine': ( 'http://[fd12::82d1]:2375/docker/engine' ), + 'ssh://': 'ssh://127.0.0.1:22', + 'ssh://user@localhost:22': 'ssh://user@localhost:22', + 'ssh://user@remote': 'ssh://user@remote:22', } for host in invalid_hosts: @@ -304,7 +312,7 @@ class ParseHostTest(unittest.TestCase): assert parse_host(host, None) == expected def test_parse_host_empty_value(self): - unix_socket = 'http+unix://var/run/docker.sock' + unix_socket = 'http+unix:///var/run/docker.sock' npipe = 'npipe:////./pipe/docker_engine' for val in [None, '']: |