Kaydet (Commit) 81edb398 authored tarafından Aanand Prasad's avatar Aanand Prasad

Merge pull request #999 from docker/tcp-to-https-parsehost

If TCP host is provided while TLS is enabled, convert to https
......@@ -400,11 +400,12 @@ def parse_host(addr, platform=None, tls=False):
if addr == 'tcp://':
raise errors.DockerException(
"Invalid bind address format: {0}".format(addr))
"Invalid bind address format: {0}".format(addr)
)
elif addr.startswith('unix://'):
addr = addr[7:]
elif addr.startswith('tcp://'):
proto = "http"
proto = 'http{0}'.format('s' if tls else '')
addr = addr[6:]
elif addr.startswith('https://'):
proto = "https"
......
......@@ -412,7 +412,12 @@ class ParseHostTest(base.BaseTestCase):
def test_parse_host_tls(self):
host_value = 'myhost.docker.net:3348'
expected_result = 'https://myhost.docker.net:3348'
self.assertEqual(parse_host(host_value, None, True), expected_result)
assert parse_host(host_value, tls=True) == expected_result
def test_parse_host_tls_tcp_proto(self):
host_value = 'tcp://myhost.docker.net:3348'
expected_result = 'https://myhost.docker.net:3348'
assert parse_host(host_value, tls=True) == expected_result
class ParseRepositoryTagTest(base.BaseTestCase):
......
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