Add test for root user as default exec_create behaviour

This commit is contained in:
Stephen Newey 2015-07-02 13:24:51 +01:00
parent a12818a8a8
commit 7bbec93f64
1 changed files with 17 additions and 0 deletions

View File

@ -846,6 +846,23 @@ class TestExecuteCommandStringAsUser(BaseTestCase):
self.assertEqual(exec_log, expected)
@unittest.skipIf(not EXEC_DRIVER_IS_NATIVE, 'Exec driver not native')
class TestExecuteCommandStringAsRoot(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.exec_create(id, 'whoami')
self.assertIn('Id', res)
exec_log = self.client.exec_start(res)
expected = b'root' if six.PY3 else 'root\n'
self.assertEqual(exec_log, expected)
@unittest.skipIf(not EXEC_DRIVER_IS_NATIVE, 'Exec driver not native')
class TestExecuteCommandStreaming(BaseTestCase):
def runTest(self):