From 2e6366a766dcfbde80e2facee53b66353eaa6314 Mon Sep 17 00:00:00 2001 From: ziajka Date: Tue, 20 Jun 2017 13:46:03 +0200 Subject: [PATCH 1/3] Fix tests on windows --- tests/compute/vpcs/test_vpcs_vm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/compute/vpcs/test_vpcs_vm.py b/tests/compute/vpcs/test_vpcs_vm.py index e08f537f..edeea297 100644 --- a/tests/compute/vpcs/test_vpcs_vm.py +++ b/tests/compute/vpcs/test_vpcs_vm.py @@ -254,7 +254,7 @@ def test_update_startup_script_h(vm): def test_update_startup_script_with_escaping_characters_in_name(vm): vm.startup_script = "set pcname initial-name\n" vm.name = "test\\" - assert vm.startup_script == "set pcname test\\\n" + assert vm.startup_script == "set pcname test\\{}".format(os.linesep) def test_get_startup_script(vm): From ea9f0e52c8335c87911d202534acf24bd79140b1 Mon Sep 17 00:00:00 2001 From: ziajka Date: Wed, 21 Jun 2017 10:26:36 +0200 Subject: [PATCH 2/3] Fixes #2108 (gns3-gui): getting project file with leading slashes issue (#1078) --- gns3server/handlers/api/controller/project_handler.py | 2 +- tests/handlers/api/controller/test_project.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gns3server/handlers/api/controller/project_handler.py b/gns3server/handlers/api/controller/project_handler.py index 232147f6..4c45955d 100644 --- a/gns3server/handlers/api/controller/project_handler.py +++ b/gns3server/handlers/api/controller/project_handler.py @@ -396,7 +396,7 @@ class ProjectHandler: controller = Controller.instance() project = yield from controller.get_loaded_project(request.match_info["project_id"]) path = request.match_info["path"] - path = os.path.normpath(path) + path = os.path.normpath(path).strip('/') # Raise error if user try to escape if path[0] == ".": diff --git a/tests/handlers/api/controller/test_project.py b/tests/handlers/api/controller/test_project.py index d8aecd25..7d0f3584 100644 --- a/tests/handlers/api/controller/test_project.py +++ b/tests/handlers/api/controller/test_project.py @@ -218,6 +218,15 @@ def test_write_file(http_controller, tmpdir, project): assert response.status == 403 +def test_write_and_get_file_with_leading_slashes_in_filename(http_controller, tmpdir, loop, project): + response = http_controller.post("/projects/{project_id}/files//hello".format(project_id=project.id), body="world", raw=True) + assert response.status == 200 + + response = http_controller.get("/projects/{project_id}/files//hello".format(project_id=project.id), raw=True) + assert response.status == 200 + assert response.body == b"world" + + def test_import(http_controller, tmpdir, controller): with zipfile.ZipFile(str(tmpdir / "test.zip"), 'w') as myzip: From 36dc264a6cecc4078f6f6c75e6985e2cd0849ed3 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 21 Jun 2017 10:32:28 +0200 Subject: [PATCH 3/3] Revert "Spice feature" --- gns3server/compute/qemu/qemu_vm.py | 10 ---------- gns3server/schemas/node.py | 2 +- gns3server/schemas/qemu.py | 6 +++--- tests/compute/qemu/test_qemu_vm.py | 14 -------------- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index b703943c..21e761df 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1304,14 +1304,6 @@ class QemuVM(BaseNode): else: return [] - def _spice_options(self): - - if self._console: - return ["-spice", - "addr={},port={},disable-ticketing".format(self._manager.port_manager.console_host, self._console)] - else: - return [] - def _monitor_options(self): if self._monitor: @@ -1571,8 +1563,6 @@ class QemuVM(BaseNode): command.extend(self._serial_options()) elif self._console_type == "vnc": command.extend(self._vnc_options()) - elif self._console_type == "spice": - command.extend(self._spice_options()) else: raise QemuError("Console type {} is unknown".format(self._console_type)) command.extend(self._monitor_options()) diff --git a/gns3server/schemas/node.py b/gns3server/schemas/node.py index 28add3ef..6e8f4e2a 100644 --- a/gns3server/schemas/node.py +++ b/gns3server/schemas/node.py @@ -144,7 +144,7 @@ NODE_OBJECT_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["vnc", "telnet", "http", "spice", None] + "enum": ["vnc", "telnet", "http", None] }, "properties": { "description": "Properties specific to an emulator", diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index f821f2c9..bdf3e55c 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -63,7 +63,7 @@ QEMU_CREATE_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet", "vnc", "spice"] + "enum": ["telnet", "vnc"] }, "hda_disk_image": { "description": "QEMU hda disk image path", @@ -244,7 +244,7 @@ QEMU_UPDATE_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet", "vnc", "spice"] + "enum": ["telnet", "vnc"] }, "linked_clone": { "description": "Whether the VM is a linked clone or not", @@ -541,7 +541,7 @@ QEMU_OBJECT_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet", "vnc", "spice"] + "enum": ["telnet", "vnc"] }, "initrd": { "description": "QEMU initrd path", diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index d83b2121..71ba1f71 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -359,20 +359,6 @@ def test_bios_option(vm, tmpdir, loop, fake_qemu_img_binary): assert ' '.join(['-bios', str(tmpdir / "test.img")]) in ' '.join(options) -def test_vnc_option(vm, tmpdir, loop, fake_qemu_img_binary): - vm._console_type = 'vnc' - vm._console = 5905 - options = loop.run_until_complete(asyncio.async(vm._build_command())) - assert '-vnc 127.0.0.1:5' in ' '.join(options) - - -def test_spice_option(vm, tmpdir, loop, fake_qemu_img_binary): - vm._console_type = 'spice' - vm._console = 5905 - options = loop.run_until_complete(asyncio.async(vm._build_command())) - assert '-spice addr=127.0.0.1,port=5905,disable-ticketing' in ' '.join(options) - - def test_disk_options_multiple_disk(vm, tmpdir, loop, fake_qemu_img_binary): vm._hda_disk_image = str(tmpdir / "test0.qcow2")