mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-20 21:25:14 +02:00
fix: attribute duplicated project to the user who duplicated it
duplicate() kept the original author in created_by. The project list filters on created_by, so a non-admin user could not see the copy they just made. Pass the caller through both duplication paths, the same way import already does since #3017.
This commit is contained in:
4 files changed
+39
-5
No files matched your search
@@ -936,9 +936,10 @@ async def test_duplicate(project, controller):
|
||||
compute, "test", None, node_type="vmware", properties={"startup_config": "test.cfg"}
|
||||
)
|
||||
|
||||
new_project = await project.duplicate(name="Hello")
|
||||
new_project = await project.duplicate(name="Hello", user="user1")
|
||||
assert new_project.id != project.id
|
||||
assert new_project.name == "Hello"
|
||||
assert new_project.created_by == "user1"
|
||||
|
||||
await new_project.open()
|
||||
|
||||
@@ -946,6 +947,25 @@ async def test_duplicate(project, controller):
|
||||
assert list(new_project.nodes.values())[1].compute.id == "remote"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_duplicate_created_by(project, controller):
|
||||
"""
|
||||
The duplicated project is owned by the user who duplicated it (fast path)
|
||||
"""
|
||||
|
||||
project.created_by = "alice"
|
||||
project.dump()
|
||||
|
||||
new_project = await project.duplicate(name="Hello", user="bob")
|
||||
assert new_project.created_by == "bob"
|
||||
# the original project keeps its owner
|
||||
assert project.created_by == "alice"
|
||||
|
||||
# without a user the original owner is kept (backward compatible)
|
||||
new_project = await project.duplicate(name="Hello2")
|
||||
assert new_project.created_by == "alice"
|
||||
|
||||
|
||||
def test_snapshots(project):
|
||||
"""
|
||||
List the snapshots
|
||||
|
||||
Reference in new issue
Block a user