mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
Merge pull request #1147 from GNS3/fix_docker_permission
Fix permission on exited container
This commit is contained in:
commit
8a028a6dce
2 files changed
+40
-10
No files matched your search
@@ -934,6 +934,7 @@ def test_create_network_interfaces(vm):
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
def test_fix_permission(vm, loop):
|
||||
vm._volumes = ["/etc"]
|
||||
vm._get_container_state = AsyncioMagicMock(return_value="running")
|
||||
process = MagicMock()
|
||||
with asyncio_patch("asyncio.subprocess.create_subprocess_exec", return_value=process) as mock_exec:
|
||||
loop.run_until_complete(vm._fix_permissions())
|
||||
@@ -941,6 +942,19 @@ def test_fix_permission(vm, loop):
|
||||
assert process.wait.called
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
def test_fix_permission_not_running(vm, loop):
|
||||
vm._volumes = ["/etc"]
|
||||
vm._get_container_state = AsyncioMagicMock(return_value="stopped")
|
||||
process = MagicMock()
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_start:
|
||||
with asyncio_patch("asyncio.subprocess.create_subprocess_exec", return_value=process) as mock_exec:
|
||||
loop.run_until_complete(vm._fix_permissions())
|
||||
mock_exec.assert_called_with('docker', 'exec', 'e90e34656842', '/gns3/bin/busybox', 'sh', '-c', '(/gns3/bin/busybox find "/etc" -depth -print0 | /gns3/bin/busybox xargs -0 /gns3/bin/busybox stat -c \'%a:%u:%g:%n\' > "/etc/.gns3_perms") && /gns3/bin/busybox chmod -R u+rX "/etc" && /gns3/bin/busybox chown {}:{} -R "/etc"'.format(os.getuid(), os.getgid()))
|
||||
assert mock_start.called
|
||||
assert process.wait.called
|
||||
|
||||
|
||||
def test_read_console_output_with_binary_mode(vm, loop):
|
||||
class InputStreamMock(object):
|
||||
def __init__(self):
|
||||
|
||||
Reference in new issue
Block a user