mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-05 06:41:13 +02:00
Fix interface information API endpoint for Cloud/NAT devices
This commit is contained in:
4 files changed
+40
-44
No files matched your search
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import uuid
|
||||
import pytest_asyncio
|
||||
|
||||
from typing import Tuple
|
||||
@@ -424,16 +425,18 @@ class TestLinkRoutes:
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() == FILTERS
|
||||
|
||||
|
||||
async def test_get_udp_interface(self, app: FastAPI, client: AsyncClient, project: Project) -> None:
|
||||
"""
|
||||
Test getting UDP tunnel interface information from a link.
|
||||
"""
|
||||
|
||||
link = Link(project)
|
||||
project._links = {link.id: link}
|
||||
|
||||
cloud_node = MagicMock()
|
||||
cloud_node.node_type = "cloud"
|
||||
cloud_node.id = "cloud-node-id"
|
||||
cloud_node.id = str(uuid.uuid4())
|
||||
cloud_node.name = "Cloud1"
|
||||
|
||||
compute = MagicMock()
|
||||
@@ -456,29 +459,28 @@ class TestLinkRoutes:
|
||||
link._nodes = [{"node": cloud_node, "port_number": 1}]
|
||||
|
||||
response = await client.get(app.url_path_for("get_iface", project_id=project.id, link_id=link.id))
|
||||
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
result = response.json()
|
||||
|
||||
assert "cloud-node-id" in result
|
||||
|
||||
udp_info = result["cloud-node-id"]
|
||||
assert udp_info["lport"] == 20000
|
||||
assert udp_info["rhost"] == "127.0.0.1"
|
||||
assert udp_info["rport"] == 30000
|
||||
assert udp_info["type"] == "udp"
|
||||
assert result["node_id"] == cloud_node.id
|
||||
assert result["lport"] == 20000
|
||||
assert result["rhost"] == "127.0.0.1"
|
||||
assert result["rport"] == 30000
|
||||
assert result["type"] == "udp"
|
||||
|
||||
|
||||
async def test_get_ethernet_interface(self, app: FastAPI, client: AsyncClient, project: Project) -> None:
|
||||
"""
|
||||
Test getting ethernet interface information from a link.
|
||||
"""
|
||||
link = Link(project)
|
||||
project._links = {link.id: link}
|
||||
|
||||
|
||||
cloud_node = MagicMock()
|
||||
cloud_node.node_type = "cloud"
|
||||
cloud_node.id = "cloud-node-id"
|
||||
cloud_node.id = str(uuid.uuid4())
|
||||
cloud_node.name = "Cloud1"
|
||||
|
||||
|
||||
compute = MagicMock()
|
||||
response = MagicMock()
|
||||
response.json = {
|
||||
@@ -493,16 +495,13 @@ class TestLinkRoutes:
|
||||
}
|
||||
compute.get = AsyncioMagicMock(return_value=response)
|
||||
cloud_node.compute = compute
|
||||
|
||||
|
||||
link._nodes = [{"node": cloud_node, "port_number": 1}]
|
||||
|
||||
|
||||
response = await client.get(app.url_path_for("get_iface", project_id=project.id, link_id=link.id))
|
||||
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
result = response.json()
|
||||
|
||||
assert "cloud-node-id" in result
|
||||
|
||||
interface_info = result["cloud-node-id"]
|
||||
assert interface_info["interface"] == "eth0"
|
||||
assert interface_info["type"] == "ethernet"
|
||||
assert result["node_id"] == cloud_node.id
|
||||
assert result["interface"] == "eth0"
|
||||
assert result["type"] == "ethernet"
|
||||
Reference in new issue
Block a user