mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
32 files changed
+652
-334
No files matched your search
@@ -465,3 +465,17 @@ def test_get_free_project_name(controller, async_run):
|
||||
async_run(controller.add_project(project_id=str(uuid.uuid4()), name="Test-1"))
|
||||
assert controller.get_free_project_name("Test") == "Test-2"
|
||||
assert controller.get_free_project_name("Hello") == "Hello"
|
||||
|
||||
|
||||
def test_load_base_files(controller, config, tmpdir):
|
||||
config.set_section_config("Server", {"configs_path": str(tmpdir)})
|
||||
|
||||
with open(str(tmpdir / 'iou_l2_base_startup-config.txt'), 'w+') as f:
|
||||
f.write('test')
|
||||
|
||||
controller.load_base_files()
|
||||
assert os.path.exists(str(tmpdir / 'iou_l3_base_startup-config.txt'))
|
||||
|
||||
# Check is the file has not been overwrite
|
||||
with open(str(tmpdir / 'iou_l2_base_startup-config.txt')) as f:
|
||||
assert f.read() == 'test'
|
||||
@@ -88,19 +88,6 @@ def test_eq(compute, project, node, controller):
|
||||
assert node != Node(Project(str(uuid.uuid4()), controller=controller), compute, "demo3", node_id=node.id, node_type="qemu")
|
||||
|
||||
|
||||
def test_properties_filter(project, compute):
|
||||
"""
|
||||
Some properties are private and should not be exposed
|
||||
"""
|
||||
node = Node(project, compute, "demo",
|
||||
node_id=str(uuid.uuid4()),
|
||||
node_type="vpcs",
|
||||
console_type="vnc",
|
||||
properties={"startup_script": "echo test", "iourc_content": "test"})
|
||||
assert node._properties == {"startup_script": "echo test", "iourc_content": "test"}
|
||||
assert node._filter_properties() == {"startup_script": "echo test"}
|
||||
|
||||
|
||||
def test_json(node, compute):
|
||||
assert node.__json__() == {
|
||||
"compute_id": str(compute.id),
|
||||
@@ -207,6 +194,30 @@ def test_create_image_missing(node, compute, project, async_run):
|
||||
node._upload_missing_image.called is True
|
||||
|
||||
|
||||
def test_create_base_script(node, config, compute, tmpdir, async_run):
|
||||
config.set_section_config("Server", {"configs_path": str(tmpdir)})
|
||||
|
||||
with open(str(tmpdir / 'test.txt'), 'w+') as f:
|
||||
f.write('hostname test')
|
||||
|
||||
node._properties = {"base_script_file": "test.txt"}
|
||||
node._console = 2048
|
||||
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
assert async_run(node.create()) is True
|
||||
data = {
|
||||
"console": 2048,
|
||||
"console_type": "vnc",
|
||||
"node_id": node.id,
|
||||
"startup_script": "hostname test",
|
||||
"name": "demo"
|
||||
}
|
||||
compute.post.assert_called_with("/projects/{}/vpcs/nodes".format(node.project.id), data=data, timeout=120)
|
||||
|
||||
|
||||
def test_symbol(node, symbols_dir):
|
||||
"""
|
||||
Change symbol should change the node size
|
||||
|
||||
@@ -137,7 +137,7 @@ def test_add_node_local(async_run, controller):
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
node = async_run(project.add_node(compute, "test", None, node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
node = async_run(project.add_node(compute, "test", None, node_type="vpcs", properties={"startup_script": "test.cfg"}))
|
||||
assert node.id in project._nodes
|
||||
|
||||
compute.post.assert_any_call('/projects', data={
|
||||
@@ -147,7 +147,7 @@ def test_add_node_local(async_run, controller):
|
||||
})
|
||||
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
||||
data={'node_id': node.id,
|
||||
'startup_config': 'test.cfg',
|
||||
'startup_script': 'test.cfg',
|
||||
'name': 'test'},
|
||||
timeout=120)
|
||||
assert compute in project._project_created_on_compute
|
||||
@@ -167,7 +167,7 @@ def test_add_node_non_local(async_run, controller):
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
node = async_run(project.add_node(compute, "test", None, node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
node = async_run(project.add_node(compute, "test", None, node_type="vpcs", properties={"startup_script": "test.cfg"}))
|
||||
|
||||
compute.post.assert_any_call('/projects', data={
|
||||
"name": project._name,
|
||||
@@ -175,7 +175,7 @@ def test_add_node_non_local(async_run, controller):
|
||||
})
|
||||
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
||||
data={'node_id': node.id,
|
||||
'startup_config': 'test.cfg',
|
||||
'startup_script': 'test.cfg',
|
||||
'name': 'test'},
|
||||
timeout=120)
|
||||
assert compute in project._project_created_on_compute
|
||||
|
||||
@@ -106,7 +106,6 @@ def demo_topology():
|
||||
"node_type": "vpcs",
|
||||
"properties": {
|
||||
"startup_script": "",
|
||||
"startup_script_path": "startup.vpc"
|
||||
},
|
||||
"symbol": ":/symbols/computer.svg",
|
||||
"width": 65,
|
||||
@@ -131,7 +130,6 @@ def demo_topology():
|
||||
"node_type": "vpcs",
|
||||
"properties": {
|
||||
"startup_script": "",
|
||||
"startup_script_path": "startup.vpc"
|
||||
},
|
||||
"symbol": ":/symbols/computer.svg",
|
||||
"width": 65,
|
||||
|
||||
@@ -80,7 +80,6 @@ def test_iou_create_with_params(http_compute, project, base_params):
|
||||
params["l1_keepalives"] = True
|
||||
params["startup_config_content"] = "hostname test"
|
||||
params["use_default_iou_values"] = True
|
||||
params["iourc_content"] = "test"
|
||||
|
||||
response = http_compute.post("/projects/{project_id}/iou/nodes".format(project_id=project.id), params, example=True)
|
||||
assert response.status == 201
|
||||
@@ -94,7 +93,6 @@ def test_iou_create_with_params(http_compute, project, base_params):
|
||||
assert response.json["l1_keepalives"] is True
|
||||
assert response.json["use_default_iou_values"] is True
|
||||
|
||||
assert "startup-config.cfg" in response.json["startup_config"]
|
||||
with open(startup_config_file(project, response.json)) as f:
|
||||
assert f.read() == "hostname test"
|
||||
|
||||
@@ -115,7 +113,6 @@ def test_iou_create_startup_config_already_exist(http_compute, project, base_par
|
||||
assert response.status == 201
|
||||
assert response.route == "/projects/{project_id}/iou/nodes"
|
||||
|
||||
assert "startup-config.cfg" in response.json["startup_config"]
|
||||
with open(startup_config_file(project, response.json)) as f:
|
||||
assert f.read() == "echo hello"
|
||||
|
||||
@@ -183,9 +180,7 @@ def test_iou_update(http_compute, vm, tmpdir, free_console_port, project):
|
||||
"ethernet_adapters": 4,
|
||||
"serial_adapters": 0,
|
||||
"l1_keepalives": True,
|
||||
"startup_config_content": "hostname test",
|
||||
"use_default_iou_values": True,
|
||||
"iourc_content": "test"
|
||||
}
|
||||
response = http_compute.put("/projects/{project_id}/iou/nodes/{node_id}".format(project_id=vm["project_id"], node_id=vm["node_id"]), params, example=True)
|
||||
assert response.status == 200
|
||||
@@ -197,9 +192,6 @@ def test_iou_update(http_compute, vm, tmpdir, free_console_port, project):
|
||||
assert response.json["nvram"] == 2048
|
||||
assert response.json["l1_keepalives"] is True
|
||||
assert response.json["use_default_iou_values"] is True
|
||||
assert "startup-config.cfg" in response.json["startup_config"]
|
||||
with open(startup_config_file(project, response.json)) as f:
|
||||
assert f.read() == "hostname test"
|
||||
|
||||
|
||||
def test_iou_nio_create_udp(http_compute, vm):
|
||||
|
||||
@@ -43,7 +43,6 @@ def test_vpcs_get(http_compute, project, vm):
|
||||
assert response.route == "/projects/{project_id}/vpcs/nodes/{node_id}"
|
||||
assert response.json["name"] == "PC TEST 1"
|
||||
assert response.json["project_id"] == project.id
|
||||
assert response.json["startup_script_path"] is None
|
||||
assert response.json["status"] == "stopped"
|
||||
|
||||
|
||||
@@ -53,8 +52,6 @@ def test_vpcs_create_startup_script(http_compute, project):
|
||||
assert response.route == "/projects/{project_id}/vpcs/nodes"
|
||||
assert response.json["name"] == "PC TEST 1"
|
||||
assert response.json["project_id"] == project.id
|
||||
assert response.json["startup_script"] == os.linesep.join(["ip 192.168.1.2", "echo TEST"])
|
||||
assert response.json["startup_script_path"] == "startup.vpc"
|
||||
|
||||
|
||||
def test_vpcs_create_port(http_compute, project, free_console_port):
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
],
|
||||
"slot0": "C7200-IO-FE",
|
||||
"sparsemem": true,
|
||||
"startup_config": "configs/i1_startup-config.cfg",
|
||||
"system_id": "FTX0945W0MY"
|
||||
},
|
||||
"x": -112,
|
||||
|
||||
-1
@@ -27,7 +27,6 @@
|
||||
"slot0": "Leopard-2FE",
|
||||
"idlepc": "0x6057efc8",
|
||||
"chassis": "3660",
|
||||
"startup_config": "configs/i1_startup-config.cfg",
|
||||
"image": "c3660-a3jk9s-mz.124-25c.bin",
|
||||
"mac_addr": "cc01.20b8.0000",
|
||||
"aux": 2103,
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
"ram": 256,
|
||||
"slot0": "GT96100-FE",
|
||||
"sparsemem": true,
|
||||
"startup_config": "configs/i1_startup-config.cfg",
|
||||
"system_id": "FTX0945W0MY"
|
||||
},
|
||||
"symbol": ":/symbols/router.svg",
|
||||
@@ -100,7 +99,6 @@
|
||||
"slot0": "Leopard-2FE",
|
||||
"slot1": "NM-16ESW",
|
||||
"sparsemem": true,
|
||||
"startup_config": "configs/i2_startup-config.cfg",
|
||||
"system_id": "FTX0945W0MY"
|
||||
},
|
||||
"symbol": ":/symbols/multilayer_switch.svg",
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
"port_segment_size": 0,
|
||||
"first_port_name": null,
|
||||
"properties": {
|
||||
"startup_script_path": "startup.vpc"
|
||||
},
|
||||
"symbol": ":/symbols/vpcs_guest.svg",
|
||||
"x": -29,
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
"path": "i86bi-linux-l3-adventerprisek9-15.4.1T.bin",
|
||||
"ram": 256,
|
||||
"serial_adapters": 2,
|
||||
"startup_config": "startup-config.cfg",
|
||||
"use_default_iou_values": true
|
||||
},
|
||||
"symbol": ":/symbols/router.svg",
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
"port_segment_size": 0,
|
||||
"first_port_name": null,
|
||||
"properties" : {
|
||||
"startup_script_path" : "startup.vpc"
|
||||
},
|
||||
"label" : {
|
||||
"y" : -25,
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"port_segment_size": 0,
|
||||
"first_port_name": null,
|
||||
"properties": {
|
||||
"startup_script_path": "startup.vpc"
|
||||
},
|
||||
"symbol": ":/symbols/vpcs_guest.svg",
|
||||
"x": -87,
|
||||
@@ -75,7 +74,6 @@
|
||||
"port_segment_size": 0,
|
||||
"first_port_name": null,
|
||||
"properties": {
|
||||
"startup_script_path": "startup.vpc"
|
||||
},
|
||||
"symbol": ":/symbols/vpcs_guest.svg",
|
||||
"x": 123,
|
||||
|
||||
@@ -61,8 +61,6 @@
|
||||
1,
|
||||
1
|
||||
],
|
||||
"private_config": "",
|
||||
"private_config_content": "",
|
||||
"ram": 512,
|
||||
"sensors": [
|
||||
22,
|
||||
@@ -78,8 +76,6 @@
|
||||
"slot5": null,
|
||||
"slot6": null,
|
||||
"sparsemem": true,
|
||||
"startup_config": "configs/i1_startup-config.cfg",
|
||||
"startup_config_content": "!\n!\nservice timestamps debug datetime msec\nservice timestamps log datetime msec\nno service password-encryption\n!\nhostname R1\n!\nip cef\nno ip domain-lookup\nno ip icmp rate-limit unreachable\nip tcp synwait 5\nno cdp log mismatch duplex\n!\nline con 0\n exec-timeout 0 0\n logging synchronous\n privilege level 15\n no login\nline aux 0\n exec-timeout 0 0\n logging synchronous\n privilege level 15\n no login\n!\n!\nend\n",
|
||||
"system_id": "FTX0945W0MY"
|
||||
},
|
||||
"symbol": ":/symbols/router.svg",
|
||||
@@ -129,8 +125,6 @@
|
||||
1,
|
||||
1
|
||||
],
|
||||
"private_config": "",
|
||||
"private_config_content": "",
|
||||
"ram": 512,
|
||||
"sensors": [
|
||||
22,
|
||||
@@ -146,8 +140,6 @@
|
||||
"slot5": null,
|
||||
"slot6": null,
|
||||
"sparsemem": true,
|
||||
"startup_config": "configs/i2_startup-config.cfg",
|
||||
"startup_config_content": "!\n!\nservice timestamps debug datetime msec\nservice timestamps log datetime msec\nno service password-encryption\n!\nhostname R2\n!\nip cef\nno ip domain-lookup\nno ip icmp rate-limit unreachable\nip tcp synwait 5\nno cdp log mismatch duplex\n!\nline con 0\n exec-timeout 0 0\n logging synchronous\n privilege level 15\n no login\nline aux 0\n exec-timeout 0 0\n logging synchronous\n privilege level 15\n no login\n!\n!\nend\n",
|
||||
"system_id": "FTX0945W0MY"
|
||||
},
|
||||
"symbol": ":/symbols/router.svg",
|
||||
@@ -160,4 +152,4 @@
|
||||
},
|
||||
"type": "topology",
|
||||
"version": "2.0.0dev7"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user