summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compose/cli/docker_client.py7
-rw-r--r--compose/cli/utils.py8
-rw-r--r--tests/unit/cli/docker_client_test.py13
-rw-r--r--tests/unit/cli/utils_test.py23
4 files changed, 48 insertions, 3 deletions
diff --git a/compose/cli/docker_client.py b/compose/cli/docker_client.py
index ce191fbf..b196d303 100644
--- a/compose/cli/docker_client.py
+++ b/compose/cli/docker_client.py
@@ -11,15 +11,16 @@ from docker.utils import kwargs_from_env
from ..const import HTTP_TIMEOUT
from .errors import UserError
from .utils import generate_user_agent
+from .utils import unquote_path
log = logging.getLogger(__name__)
def tls_config_from_options(options):
tls = options.get('--tls', False)
- ca_cert = options.get('--tlscacert')
- cert = options.get('--tlscert')
- key = options.get('--tlskey')
+ ca_cert = unquote_path(options.get('--tlscacert'))
+ cert = unquote_path(options.get('--tlscert'))
+ key = unquote_path(options.get('--tlskey'))
verify = options.get('--tlsverify')
skip_hostname_check = options.get('--skip-hostname-check', False)
diff --git a/compose/cli/utils.py b/compose/cli/utils.py
index f60f61cd..e10a3674 100644
--- a/compose/cli/utils.py
+++ b/compose/cli/utils.py
@@ -122,3 +122,11 @@ def generate_user_agent():
else:
parts.append("{}/{}".format(p_system, p_release))
return " ".join(parts)
+
+
+def unquote_path(s):
+ if not s:
+ return s
+ if s[0] == '"' and s[-1] == '"':
+ return s[1:-1]
+ return s
diff --git a/tests/unit/cli/docker_client_test.py b/tests/unit/cli/docker_client_test.py
index 3430c25c..aaa935af 100644
--- a/tests/unit/cli/docker_client_test.py
+++ b/tests/unit/cli/docker_client_test.py
@@ -144,3 +144,16 @@ class TLSConfigTestCase(unittest.TestCase):
result = tls_config_from_options(options)
assert isinstance(result, docker.tls.TLSConfig)
assert result.assert_hostname is False
+
+ def test_tls_client_and_ca_quoted_paths(self):
+ options = {
+ '--tlscacert': '"{0}"'.format(self.ca_cert),
+ '--tlscert': '"{0}"'.format(self.client_cert),
+ '--tlskey': '"{0}"'.format(self.key),
+ '--tlsverify': True
+ }
+ result = tls_config_from_options(options)
+ assert isinstance(result, docker.tls.TLSConfig)
+ assert result.cert == (self.client_cert, self.key)
+ assert result.ca_cert == self.ca_cert
+ assert result.verify is True
diff --git a/tests/unit/cli/utils_test.py b/tests/unit/cli/utils_test.py
new file mode 100644
index 00000000..066fb359
--- /dev/null
+++ b/tests/unit/cli/utils_test.py
@@ -0,0 +1,23 @@
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
+import unittest
+
+from compose.cli.utils import unquote_path
+
+
+class UnquotePathTest(unittest.TestCase):
+ def test_no_quotes(self):
+ assert unquote_path('hello') == 'hello'
+
+ def test_simple_quotes(self):
+ assert unquote_path('"hello"') == 'hello'
+
+ def test_uneven_quotes(self):
+ assert unquote_path('"hello') == '"hello'
+ assert unquote_path('hello"') == 'hello"'
+
+ def test_nested_quotes(self):
+ assert unquote_path('""hello""') == '"hello"'
+ assert unquote_path('"hel"lo"') == 'hel"lo'
+ assert unquote_path('"hello""') == 'hello"'