mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Merge branch 'master' into 2.2
# Conflicts: # tests/handlers/api/compute/test_dynamips.py # tests/handlers/api/compute/test_qemu.py
This commit is contained in:
commit
850c30f958
@ -7,6 +7,9 @@ GNS3-server
|
|||||||
.. image:: https://img.shields.io/pypi/v/gns3-server.svg
|
.. image:: https://img.shields.io/pypi/v/gns3-server.svg
|
||||||
:target: https://pypi.python.org/pypi/gns3-server
|
:target: https://pypi.python.org/pypi/gns3-server
|
||||||
|
|
||||||
|
.. image:: https://snyk.io/test/github/GNS3/gns3-server/badge.svg
|
||||||
|
:target: https://snyk.io/test/github/GNS3/gns3-server
|
||||||
|
|
||||||
This is the GNS3 server repository.
|
This is the GNS3 server repository.
|
||||||
|
|
||||||
The GNS3 server manages emulators such as Dynamips, VirtualBox or Qemu/KVM.
|
The GNS3 server manages emulators such as Dynamips, VirtualBox or Qemu/KVM.
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
import asyncio
|
import asyncio
|
||||||
import pytest
|
import pytest
|
||||||
@ -149,6 +150,7 @@ async def test_project_delete():
|
|||||||
assert os.path.exists(directory) is False
|
assert os.path.exists(directory) is False
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(not sys.platform.startswith("win") and os.getuid() == 0, reason="Root can delete any project")
|
||||||
async def test_project_delete_permission_issue():
|
async def test_project_delete_permission_issue():
|
||||||
|
|
||||||
project = Project(project_id=str(uuid4()))
|
project = Project(project_id=str(uuid4()))
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
@ -184,13 +185,13 @@ async def test_upload_image(compute_api, images_dir):
|
|||||||
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
|
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
|
||||||
|
|
||||||
|
|
||||||
async def test_upload_image_permission_denied(compute_api, tmpdir, images_dir):
|
@pytest.mark.skipif(not sys.platform.startswith("win") and os.getuid() == 0, reason="Root can delete any image")
|
||||||
|
async def test_upload_image_permission_denied(compute_api, images_dir):
|
||||||
|
|
||||||
os.makedirs(os.path.join(images_dir, "IOS"), exist_ok=True)
|
os.makedirs(os.path.join(images_dir, "IOS"), exist_ok=True)
|
||||||
with open(os.path.join(images_dir, "IOS", "test3.tmp"), "w+") as f:
|
with open(os.path.join(images_dir, "IOS", "test2.tmp"), "w+") as f:
|
||||||
f.write("")
|
f.write("")
|
||||||
os.chmod(os.path.join(images_dir, "IOS", "test3.tmp"), 0)
|
os.chmod(os.path.join(images_dir, "IOS", "test2.tmp"), 0)
|
||||||
|
|
||||||
with patch("gns3server.utils.images.default_images_directory", return_value=str(tmpdir)):
|
response = await compute_api.post("/dynamips/images/test2", body="TEST", raw=True)
|
||||||
response = await compute_api.post("/dynamips/images/test3", "TEST", raw=True)
|
|
||||||
assert response.status == 409
|
assert response.status == 409
|
||||||
|
@ -315,14 +315,14 @@ async def test_upload_image_forbiden_location(compute_api, tmpdir):
|
|||||||
assert response.status == 404
|
assert response.status == 404
|
||||||
|
|
||||||
|
|
||||||
async def test_upload_image_permission_denied(compute_api, tmpdir):
|
@pytest.mark.skipif(not sys.platform.startswith("win") and os.getuid() == 0, reason="Root can delete any image")
|
||||||
|
async def test_upload_image_permission_denied(compute_api, images_dir):
|
||||||
|
|
||||||
with open(str(tmpdir / "test3.tmp"), "w+") as f:
|
with open(os.path.join(images_dir, "QEMU", "test2.tmp"), "w+") as f:
|
||||||
f.write("")
|
f.write("")
|
||||||
os.chmod(str(tmpdir / "test3.tmp"), 0)
|
os.chmod(os.path.join(images_dir, "QEMU", "test2.tmp"), 0)
|
||||||
|
|
||||||
with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir)):
|
response = await compute_api.post("/qemu/images/test2", body="TEST", raw=True)
|
||||||
response = await compute_api.post("/qemu/images/test3", "TEST", raw=True)
|
|
||||||
assert response.status == 409
|
assert response.status == 409
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user