mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Impoved docker volumes user input validation
This commit is contained in:
1 parent
0c19bc8d43
commit
81ddb0cfe6
2 files changed
+44
-4
No files matched your search
@@ -483,6 +483,18 @@ def test_create_with_extra_volumes_invalid_format_2(loop, project, manager):
|
||||
with pytest.raises(DockerError):
|
||||
loop.run_until_complete(asyncio.ensure_future(vm.create()))
|
||||
|
||||
def test_create_with_extra_volumes_invalid_format_3(loop, project, manager):
|
||||
|
||||
response = {
|
||||
"Id": "e90e34656806",
|
||||
"Warnings": []
|
||||
}
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
|
||||
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu:latest", extra_volumes=["/vol1/.."])
|
||||
with pytest.raises(DockerError):
|
||||
loop.run_until_complete(asyncio.ensure_future(vm.create()))
|
||||
|
||||
def test_create_with_extra_volumes_duplicate_1_image(loop, project, manager):
|
||||
|
||||
response = {
|
||||
@@ -512,6 +524,30 @@ def test_create_with_extra_volumes_duplicate_2_user(loop, project, manager):
|
||||
with pytest.raises(DockerError):
|
||||
loop.run_until_complete(asyncio.ensure_future(vm.create()))
|
||||
|
||||
def test_create_with_extra_volumes_duplicate_3_subdir(loop, project, manager):
|
||||
|
||||
response = {
|
||||
"Id": "e90e34656806",
|
||||
"Warnings": [],
|
||||
}
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
|
||||
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu:latest", extra_volumes=["/vol/1/", "/vol"])
|
||||
with pytest.raises(DockerError):
|
||||
loop.run_until_complete(asyncio.ensure_future(vm.create()))
|
||||
|
||||
def test_create_with_extra_volumes_duplicate_4_backslash(loop, project, manager):
|
||||
|
||||
response = {
|
||||
"Id": "e90e34656806",
|
||||
"Warnings": [],
|
||||
}
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
|
||||
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu:latest", extra_volumes=["/vol//", "/vol"])
|
||||
with pytest.raises(DockerError):
|
||||
loop.run_until_complete(asyncio.ensure_future(vm.create()))
|
||||
|
||||
def test_create_with_extra_volumes(loop, project, manager):
|
||||
|
||||
response = {
|
||||
|
||||
Reference in new issue
Block a user