def test_create_Router(self):
        router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)
        router.mode = Mode.normal
        assert isinstance(router, Router)

        assert router.ip == "10.223.254.254"
        assert router.ip_mask == 16
 def test_router_wget(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1",
                     24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     # Has to be matched with the current mode (normal, configuration)
     router.mode = Mode.configuration
     assert isinstance(router, Router)
     # Create NetworkCrtl
     network_ctrl = NetworkCtrl(router, 'eth0')
     assert isinstance(network_ctrl, NetworkCtrl)
     self.assertRaises(Exception, network_ctrl.connect_with_remote_system())
     # Create test file 'test_wget.txt'
     path = os.path.dirname(__file__)
     file = open(path + '/test_wget.txt', 'w+')
     # The Router downloads this file via wget from the raspberryPi
     network_ctrl.remote_system_wget(path + '/test_wget.txt', '/tmp/')
     # Tests if the file has successful downloaded
     output = network_ctrl.send_command(
         "test -f '/tmp/test_wget.txt' && echo True")
     self.assertEqual(output, "['True\\n']")
     # Test
     output = network_ctrl.send_command(
         "rm '/tmp/test_wget.txt' && echo True")
     self.assertEqual(output, "['True\\n']")
     file.close()
     network_ctrl.exit()
 def test_router_wget(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     # Has to be matched with the current mode (normal, configuration)
     router.mode = Mode.configuration
     assert isinstance(router, Router)
     # Create NetworkCrtl
     network_ctrl = NetworkCtrl(router, 'eth0')
     assert isinstance(network_ctrl, NetworkCtrl)
     self.assertRaises(Exception, network_ctrl.connect_with_remote_system())
     # Create test file 'test_wget.txt'
     path = os.path.dirname(__file__)
     file = open(path + '/test_wget.txt', 'w+')
     # The Router downloads this file via wget from the raspberryPi
     network_ctrl.remote_system_wget(path + '/test_wget.txt', '/tmp/')
     # Tests if the file has successful downloaded
     output = network_ctrl.send_command("test -f '/tmp/test_wget.txt' && echo True")
     self.assertEqual(output, "['True\\n']")
     # Test
     output = network_ctrl.send_command("rm '/tmp/test_wget.txt' && echo True")
     self.assertEqual(output, "['True\\n']")
     file.close()
     network_ctrl.exit()
Пример #4
0
    def test_create_Router(self):
        router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1",
                        24, "root", "root", 1)
        router.mode = Mode.normal
        assert isinstance(router, Router)

        assert router.ip == "10.223.254.254"
        assert router.ip_mask == 16
 def test_reboot_into_config(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     router.mode = Mode.normal
     assert isinstance(router, Router)
     RouterReboot().configmode(router)
     assert router.mode == Mode.configuration
 def test_reboot_into_config(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1",
                     24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     router.mode = Mode.normal
     assert isinstance(router, Router)
     RouterReboot().configmode(router)
     assert router.mode == Mode.configuration
 def test_connection(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     # Has to be matched with the current mode (normal, configuration)
     router.mode = Mode.configuration
     assert isinstance(router, Router)
     # Create NetworkCrtl
     network_ctrl = NetworkCtrl(router, 'eth0')
     assert isinstance(network_ctrl, NetworkCtrl)
     # network_ctrl.connect_with_router()
     network_ctrl.exit()
 def test_connection(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1",
                     24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     # Has to be matched with the current mode (normal, configuration)
     router.mode = Mode.configuration
     assert isinstance(router, Router)
     # Create NetworkCrtl
     network_ctrl = NetworkCtrl(router, 'eth0')
     assert isinstance(network_ctrl, NetworkCtrl)
     # network_ctrl.connect_with_router()
     network_ctrl.exit()
 def test_send_command(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     # Has to be matched with the current mode (normal, configuration)
     router.mode = Mode.configuration
     assert isinstance(router, Router)
     # Create NetworkCrtl
     network_ctrl = NetworkCtrl(router, 'eth0')
     assert isinstance(network_ctrl, NetworkCtrl)
     # Test if the command 'uname' could be send via ssh
     self.assertRaises(Exception, network_ctrl.connect_with_remote_system())
     output = network_ctrl.send_command("uname")
     self.assertEqual(output, "['Linux\\n']")
     network_ctrl.exit()
 def test_send_command(self):
     # Create router
     router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1",
                     24, "root", "root", 1)
     router.model = "TP-LINK TL-WR841N/ND v9"
     router.mac = "e8:de:27:b7:7c:e2"
     # Has to be matched with the current mode (normal, configuration)
     router.mode = Mode.configuration
     assert isinstance(router, Router)
     # Create NetworkCrtl
     network_ctrl = NetworkCtrl(router, 'eth0')
     assert isinstance(network_ctrl, NetworkCtrl)
     # Test if the command 'uname' could be send via ssh
     self.assertRaises(Exception, network_ctrl.connect_with_remote_system())
     output = network_ctrl.send_command("uname")
     self.assertEqual(output, "['Linux\\n']")
     network_ctrl.exit()
    def test_setup_expert(self):
        """
        This UnitTest executes the wca_setup_expert-function with the given config-file.
        It sets the values of all the  from WebInterface of the Router.
        """
        # Create router
        router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)
        router.model = "TP-LINK TL-WR841N/ND v9"
        router.mac = "e8:de:27:b7:7c:e2"
        router.mode = Mode.configuration
        assert isinstance(router, Router)
        # Config
        config = ConfigManager().get_web_interface_dict()[0]
        self.assertEqual(len(config), 30, "Wrong size of the Config-Directory")
        # Create NetworkCrtl
        network_ctrl = NetworkCtrl(router, "eth0")
        assert isinstance(network_ctrl, NetworkCtrl)

        self.assertRaises(Exception, network_ctrl.wca_setup_expert(config))

        network_ctrl.exit()
    def test_setup_expert(self):
        """
        This UnitTest executes the wca_setup_expert-function with the given config-file.
        It sets the values of all the  from WebInterface of the Router.
        """
        # Create router
        router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1",
                        24, "root", "root", 1)
        router.model = "TP-LINK TL-WR841N/ND v9"
        router.mac = "e8:de:27:b7:7c:e2"
        router.mode = Mode.configuration
        assert isinstance(router, Router)
        # Config
        config = ConfigManager().get_web_interface_dict()[0]
        self.assertEqual(len(config), 30, "Wrong size of the Config-Directory")
        # Create NetworkCrtl
        network_ctrl = NetworkCtrl(router, 'eth0')
        assert isinstance(network_ctrl, NetworkCtrl)

        self.assertRaises(Exception, network_ctrl.wca_setup_expert(config))

        network_ctrl.exit()
Пример #13
0
from util.router_flash_firmware import RouterFlashFirmware
from server.router import Router
from config.configmanager import ConfigManager
from server.router import Mode

# Create router
router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24,
                "root", "root", 1)
router.model = "TP-LINK TL-WR841N/ND v9"
router.mac = "e8:de:27:b7:7c:e2"
router.mode = Mode.configuration
# Create firware configuration
firmware_config = ConfigManager.get_firmware_dict()[0]

RouterFlashFirmware.sysupdate(router, firmware_config)
RouterFlashFirmware.sysupgrade(router, n=True)
from util.router_flash_firmware import RouterFlashFirmware
from server.router import Router
from config.configmanager import ConfigManager
from server.router import Mode

# Create router
router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)
router.model = "TP-LINK TL-WR841N/ND v9"
router.mac = "e8:de:27:b7:7c:e2"
router.mode = Mode.configuration
# Create firware configuration
firmware_config = ConfigManager.get_firmware_dict()[0]

RouterFlashFirmware.sysupdate(router, firmware_config)
RouterFlashFirmware.sysupgrade(router, n=True)