Kaydet (Commit) b3657964 authored tarafından Patrick Hensley's avatar Patrick Hensley

Use shlex for exec string cmd, added integration testcase.

üst 3ac4c788
......@@ -548,8 +548,8 @@ class Client(requests.Session):
raise Exception('Exec is not supported in API < 1.15!')
if isinstance(container, dict):
container = container.get('Id')
if not isinstance(cmd, (list, tuple)):
cmd = [cmd]
if isinstance(cmd, six.string_types):
cmd = shlex.split(str(cmd))
data = {
'Container': container,
......
......@@ -630,7 +630,8 @@ class TestRestartingContainer(BaseTestCase):
class TestExecuteCommand(BaseTestCase):
def runTest(self):
container = self.client.create_container('busybox', ['false'])
container = self.client.create_container('busybox', 'cat',
detach=True, stdin_open=True)
id = container['Id']
self.client.start(id)
self.tmp_containers.append(id)
......@@ -640,9 +641,23 @@ class TestExecuteCommand(BaseTestCase):
self.assertEqual(res, expected)
class TestExecuteCommandString(BaseTestCase):
def runTest(self):
container = self.client.create_container('busybox', 'cat',
detach=True, stdin_open=True)
id = container['Id']
self.client.start(id)
self.tmp_containers.append(id)
res = self.client.execute(id, 'echo hello world', stdout=True)
expected = b'hello world\n' if six.PY3 else 'hello world\n'
self.assertEqual(res, expected)
class TestExecuteCommandStreaming(BaseTestCase):
def runTest(self):
container = self.client.create_container('busybox', ['false'])
container = self.client.create_container('busybox', 'cat',
detach=True, stdin_open=True)
id = container['Id']
self.client.start(id)
self.tmp_containers.append(id)
......
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