示例#1
0
 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_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)

        try:
            web_config_assist = RouterWebConfiguration(router, config, wizard=True)
            web_config_assist.start()
            web_config_assist.join()
        except Exception as e:
            Logger().error(str(e))
        finally:
            assert router.mode == Mode.normal
            network_ctrl.exit()
示例#3
0
    def test_create_Router(self):
        router = Router(0, "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
示例#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_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()
示例#6
0
    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)

        try:
            web_config_assist = RouterWebConfiguration(router,
                                                       config,
                                                       wizard=True)
            web_config_assist.start()
            web_config_assist.join()
        except Exception as e:
            Logger().error(str(e))
        finally:
            assert router.mode == Mode.normal
            network_ctrl.exit()
示例#7
0
 def _create_router(self):
     # Create router
     router = Router(0, "vlan21", 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)
     return router
示例#8
0
 def _create_router(self):
     # Create router
     router = Router(0, "vlan21", 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.normal
     assert isinstance(router, Router)
     return router
示例#9
0
    def test_router_info(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

        router_info = RouterInfo(router)
        router_info.start()
        router_info.join()
 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
示例#11
0
    def test_optional_getter_setter(self):
        router = Router(0, "vlan21", 21, "10.223.254.254", 16, "192.168.1.1",
                        24, "root", "root", 1)

        assert isinstance(router, Router)

        router.mode = Mode.configuration
        router.model = "TP-LINK TL-WR841N/ND v9"
        router.mac = "e8:de:27:b7:7c:e2"
        router.node_name = "64293-testframework1"
        router.public_key = "1234567890abcdef16171819"

        network_interface = NetworkInterface(0, "eth0")
        assert isinstance(network_interface, NetworkInterface)
        router.network_interfaces[network_interface.name] = network_interface

        cpu_process = CPUProcess(11, "root", 1.1, 11.2, "echo")
        assert isinstance(cpu_process, CPUProcess)
        router.cpu_processes.append(cpu_process)

        socket = InternetSocket()
        assert isinstance(socket, InternetSocket)
        router.sockets.append(socket)

        ram = RAM(8000, 4000, 4000, 0, 0)
        assert isinstance(ram, RAM)
        router.ram = ram

        flash_driver = Flashdriver(8000, 2000, 6000)
        assert isinstance(flash_driver, Flashdriver)
        router.flashdriver = flash_driver

        router.uci["autoupdater.settings.enabled"] = "1"

        bat_originator = BatOriginator(
            "00:00:00:00:00:00", 12.2, "01:00:01:00:01:00", "mesh0",
            ["01:00:01:00:01:00", "21:00:21:00:21:00", "03:00:03:00:03:00"])
        assert isinstance(bat_originator, BatOriginator)
        router.bat_originators.append(bat_originator)

        self.assertEqual(Mode.configuration, router.mode)
        self.assertEqual("TP-LINK TL-WR841N/ND v9", router.model)
        self.assertEqual("e8:de:27:b7:7c:e2", router.mac)
        self.assertEqual("64293-testframework1", router.node_name)
        self.assertEqual("1234567890abcdef16171819", router.public_key)
        self.assertEqual(network_interface,
                         router.network_interfaces[network_interface.name])
        self.assertEqual(cpu_process, router.cpu_processes.pop())
        self.assertEqual(socket, router.sockets.pop())
        self.assertEqual(ram, router.ram)
        self.assertEqual(flash_driver, router.flashdriver)
        self.assertEqual('Firmware not known', router.firmware.name)
        self.assertEqual("1", router.uci["autoupdater.settings.enabled"])
        self.assertEqual(bat_originator, router.bat_originators.pop())
示例#12
0
 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_optional_getter_setter(self):
        router = Router(0, "vlan21", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1)

        assert isinstance(router, Router)

        router.mode = Mode.configuration
        router.model = "TP-LINK TL-WR841N/ND v9"
        router.mac = "e8:de:27:b7:7c:e2"
        router.node_name = "64293-testframework1"
        router.public_key = "1234567890abcdef16171819"

        network_interface = NetworkInterface(0, "eth0")
        assert isinstance(network_interface, NetworkInterface)
        router.network_interfaces[network_interface.name] = network_interface

        cpu_process = CPUProcess(11, "root", 1.1, 11.2, "echo")
        assert isinstance(cpu_process, CPUProcess)
        router.cpu_processes.append(cpu_process)

        socket = InternetSocket()
        assert isinstance(socket, InternetSocket)
        router.sockets.append(socket)

        ram = RAM(8000, 4000, 4000, 0, 0)
        assert isinstance(ram, RAM)
        router.ram = ram

        flash_driver = Flashdriver(8000, 2000, 6000)
        assert isinstance(flash_driver, Flashdriver)
        router.flashdriver = flash_driver

        router.uci["autoupdater.settings.enabled"] = "1"

        bat_originator = BatOriginator("00:00:00:00:00:00", 12.2, "01:00:01:00:01:00", "mesh0",
                                       ["01:00:01:00:01:00", "21:00:21:00:21:00", "03:00:03:00:03:00"])
        assert isinstance(bat_originator, BatOriginator)
        router.bat_originators.append(bat_originator)

        self.assertEqual(Mode.configuration, router.mode)
        self.assertEqual("TP-LINK TL-WR841N/ND v9", router.model)
        self.assertEqual("e8:de:27:b7:7c:e2", router.mac)
        self.assertEqual("64293-testframework1", router.node_name)
        self.assertEqual("1234567890abcdef16171819", router.public_key)
        self.assertEqual(network_interface, router.network_interfaces[network_interface.name])
        self.assertEqual(cpu_process, router.cpu_processes.pop())
        self.assertEqual(socket, router.sockets.pop())
        self.assertEqual(ram, router.ram)
        self.assertEqual(flash_driver, router.flashdriver)
        self.assertEqual('Firmware not known', router.firmware.name)
        self.assertEqual("1", router.uci["autoupdater.settings.enabled"])
        self.assertEqual(bat_originator, router.bat_originators.pop())
示例#14
0
 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()
示例#15
0
 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()
示例#16
0
 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()
from util.router_flash_firmware import RouterFlashFirmware
from router.router import Router, Mode
from config.configmanager import ConfigManager

# 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 router.router import Router, Mode
from config.configmanager import ConfigManager

# 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)