mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
VCPS create NIO work and tested
This commit is contained in:
1 parent
aff834f565
commit
0cdc1c3042
7 files changed
+90
-187
No files matched your search
@@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from tests.api.base import server, loop
|
||||
from tests.api.base import server, loop, port_manager
|
||||
from tests.utils import asyncio_patch
|
||||
from gns3server import modules
|
||||
|
||||
@@ -30,16 +30,12 @@ def test_vpcs_create(server):
|
||||
|
||||
|
||||
def test_vpcs_nio_create(server):
|
||||
response = server.post('/vpcs/42/nio', {
|
||||
'id': 42,
|
||||
'nio': {
|
||||
response = server.post('/vpcs/42/ports/0/nio', {
|
||||
'type': 'nio_unix',
|
||||
'local_file': '/tmp/test',
|
||||
'remote_file': '/tmp/remote'
|
||||
},
|
||||
'port': 0,
|
||||
'port_id': 0},
|
||||
example=True)
|
||||
assert response.status == 200
|
||||
assert response.route == '/vpcs/{vpcs_id}/nio'
|
||||
assert response.route == '/vpcs/{vpcs_id}/ports/{port_id}/nio'
|
||||
assert response.json['name'] == 'PC 2'
|
||||
@@ -61,3 +61,19 @@ def test_stop(tmpdir, loop, port_manager):
|
||||
assert vm.is_running() == False
|
||||
process.terminate.assert_called_with()
|
||||
|
||||
def test_add_nio_binding_udp(port_manager, tmpdir):
|
||||
vm = VPCSDevice("test", 42, port_manager, working_dir=str(tmpdir), path="/bin/test")
|
||||
nio = vm.port_add_nio_binding(0, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
|
||||
assert nio.lport == 4242
|
||||
|
||||
def test_add_nio_binding_tap(port_manager, tmpdir):
|
||||
vm = VPCSDevice("test", 42, port_manager, working_dir=str(tmpdir), path="/bin/test")
|
||||
with patch("gns3server.modules.vpcs.vpcs_device.has_privileged_access", return_value=True):
|
||||
nio = vm.port_add_nio_binding(0, {"type": "nio_tap", "tap_device": "test"})
|
||||
assert nio.tap_device == "test"
|
||||
|
||||
def test_add_nio_binding_tap_no_privileged_access(port_manager, tmpdir):
|
||||
vm = VPCSDevice("test", 42, port_manager, working_dir=str(tmpdir), path="/bin/test")
|
||||
with patch("gns3server.modules.vpcs.vpcs_device.has_privileged_access", return_value=False):
|
||||
with pytest.raises(VPCSError):
|
||||
vm.port_add_nio_binding(0, {"type": "nio_tap", "tap_device": "test"})
|
||||
Reference in new issue
Block a user