Exemplo n.º 1
0
 def setUp(self):
     super(DriverRegistrationTestCase, self).setUp()
     self.options = {
         "version":
         "1.1.5",
         "compiler":
         "WDDK",  # MSVC | MINGW
         "url":
         "https://github.com/basil00/Divert/releases/download/v%(version)s/WinDivert-%(version)s-%(compiler)s.zip"
     }
     self.installer = WinDivertInstaller(options=self.options,
                                         inst_dir=self.driver_dir)
     self.dll_path = os.path.join(self.driver_dir, "WinDivert.dll")
Exemplo n.º 2
0
 def test_download(self):
     """
     Tests the download of a package through WinDivertInstaller class
     :return:
     """
     with cd(self.work_dir):
         local_filename = WinDivertInstaller.download(url="http://somehost/somedir/%s" % self.tarball)
         self.assertEquals(local_filename, self.tarball)
         self.assertTrue(os.path.exists(os.path.join(self.work_dir, self.tarball)))
Exemplo n.º 3
0
 def setUp(self):
     super(DriverRegistrationTestCase, self).setUp()
     self.options = {
         "version": "1.1.5",
         "compiler": "WDDK",  # MSVC | MINGW
         "url": "https://github.com/basil00/Divert/releases/download/v%(version)s/WinDivert-%(version)s-%(compiler)s.zip"
     }
     self.installer = WinDivertInstaller(options=self.options, inst_dir=self.driver_dir)
     self.dll_path = os.path.join(self.driver_dir, "WinDivert.dll")
Exemplo n.º 4
0
 def test_download(self):
     """
     Tests the download of a package through WinDivertInstaller class
     :return:
     """
     with cd(self.work_dir):
         local_filename = WinDivertInstaller.download(
             url="http://somehost/somedir/%s" % self.tarball)
         self.assertEquals(local_filename, self.tarball)
         self.assertTrue(
             os.path.exists(os.path.join(self.work_dir, self.tarball)))
Exemplo n.º 5
0
 def test_unzip(self):
     """
     Tests the uncompressing method of WinDivertInstaller class
     :return:
     """
     self.test_download()
     with cd(self.work_dir):
         expected_dir = os.path.join(self.work_dir, os.path.splitext(self.tarball)[0])
         extracted_dir = WinDivertInstaller.unzip(os.path.join(self.work_dir, self.tarball))
         self.assertEquals(extracted_dir, expected_dir)
         self.assertTrue(os.path.exists(expected_dir))
Exemplo n.º 6
0
 def test_unzip(self):
     """
     Tests the uncompressing method of WinDivertInstaller class
     :return:
     """
     self.test_download()
     with cd(self.work_dir):
         expected_dir = os.path.join(self.work_dir,
                                     os.path.splitext(self.tarball)[0])
         extracted_dir = WinDivertInstaller.unzip(
             os.path.join(self.work_dir, self.tarball))
         self.assertEquals(extracted_dir, expected_dir)
         self.assertTrue(os.path.exists(expected_dir))
Exemplo n.º 7
0
class DriverRegistrationTestCase(BaseTestCase):
    def setUp(self):
        super(DriverRegistrationTestCase, self).setUp()
        self.options = {
            "version": "1.1.5",
            "compiler": "WDDK",  # MSVC | MINGW
            "url": "https://github.com/basil00/Divert/releases/download/v%(version)s/WinDivert-%(version)s-%(compiler)s.zip"
        }
        self.installer = WinDivertInstaller(options=self.options, inst_dir=self.driver_dir)
        self.dll_path = os.path.join(self.driver_dir, "WinDivert.dll")


    def test_driver_registration_with_installer(self):
        """
        Tests WinDivert driver installer register check
        :return:
        """
        self.assertIsNotNone(self.installer.check_driver_path(self.dll_path))
Exemplo n.º 8
0
class DriverRegistrationTestCase(BaseTestCase):
    def setUp(self):
        super(DriverRegistrationTestCase, self).setUp()
        self.options = {
            "version":
            "1.1.5",
            "compiler":
            "WDDK",  # MSVC | MINGW
            "url":
            "https://github.com/basil00/Divert/releases/download/v%(version)s/WinDivert-%(version)s-%(compiler)s.zip"
        }
        self.installer = WinDivertInstaller(options=self.options,
                                            inst_dir=self.driver_dir)
        self.dll_path = os.path.join(self.driver_dir, "WinDivert.dll")

    def test_driver_registration_with_installer(self):
        """
        Tests WinDivert driver installer register check
        :return:
        """
        self.assertIsNotNone(self.installer.check_driver_path(self.dll_path))
Exemplo n.º 9
0
class InstallerInstanceTestCase(InstallerBaseTestCase):
    def setUp(self):
        super(InstallerInstanceTestCase, self).setUp()
        self.installer = WinDivertInstaller(options=self.options, inst_dir=self.work_dir)

    def tearDown(self):
        self.installer.uninstall()
        super(InstallerInstanceTestCase, self).tearDown()

    def test_uninstall(self):
        """
        Tests the uninstallation of WinDivert driver
        :return:
        """

        def fake_uninstall(*args, **kwargs):
            for item in os.listdir(self.work_dir):
                name, ext = os.path.splitext(item)
                if name.lower() in ("windivert",
                                    "windivert32",
                                    "windivert64") and ext.lower() in (".sys",
                                                                       ".dll"):
                    item = os.path.join(self.work_dir, item)
                    os.remove(item)

        with patch("subprocess.call", fake_uninstall):
            self.installer.uninstall()
            for item in os.listdir(self.work_dir):
                name, ext = os.path.splitext(item)
                self.assertNotIn(name.lower(), ("windivert",
                                                "windivert32",
                                                "windivert64"))
                self.assertNotIn(ext.lower(), (".sys", ".dll"))

    @mock_urllib_download()
    def test_install(self):
        """
        Tests the installation of the driver. Downloader is mocked to avoid a real http get
        :return:
        """
        with patch.object(self.installer, "check_driver_path", lambda *args, **kwargs: None):
            self.installer.run(workdir=self.work_dir)
            for item in os.listdir(self.work_dir):
                name, ext = os.path.splitext(item)
                self.assertIn(name.lower(), ("windivert",
                                             "windivert32",
                                             "windivert64"))
                self.assertIn(ext.lower(), (".sys", ".dll"))
Exemplo n.º 10
0
class InstallerInstanceTestCase(InstallerBaseTestCase):
    def setUp(self):
        super(InstallerInstanceTestCase, self).setUp()
        self.installer = WinDivertInstaller(options=self.options,
                                            inst_dir=self.work_dir)

    def tearDown(self):
        self.installer.uninstall()
        super(InstallerInstanceTestCase, self).tearDown()

    def test_uninstall(self):
        """
        Tests the uninstallation of WinDivert driver
        :return:
        """
        def fake_uninstall(*args, **kwargs):
            for item in os.listdir(self.work_dir):
                name, ext = os.path.splitext(item)
                if name.lower() in ("windivert", "windivert32",
                                    "windivert64") and ext.lower() in (".sys",
                                                                       ".dll"):
                    item = os.path.join(self.work_dir, item)
                    os.remove(item)

        with patch("subprocess.call", fake_uninstall):
            self.installer.uninstall()
            for item in os.listdir(self.work_dir):
                name, ext = os.path.splitext(item)
                self.assertNotIn(name.lower(),
                                 ("windivert", "windivert32", "windivert64"))
                self.assertNotIn(ext.lower(), (".sys", ".dll"))

    @mock_urllib_download()
    def test_install(self):
        """
        Tests the installation of the driver. Downloader is mocked to avoid a real http get
        :return:
        """
        with patch.object(self.installer, "check_driver_path",
                          lambda *args, **kwargs: None):
            self.installer.run(workdir=self.work_dir)
            for item in os.listdir(self.work_dir):
                name, ext = os.path.splitext(item)
                self.assertIn(name.lower(),
                              ("windivert", "windivert32", "windivert64"))
                self.assertIn(ext.lower(), (".sys", ".dll"))
Exemplo n.º 11
0
 def setUp(self):
     super(InstallerInstanceTestCase, self).setUp()
     self.installer = WinDivertInstaller(options=self.options,
                                         inst_dir=self.work_dir)
Exemplo n.º 12
0
 def setUp(self):
     super(InstallerInstanceTestCase, self).setUp()
     self.installer = WinDivertInstaller(options=self.options, inst_dir=self.work_dir)
Exemplo n.º 13
0
 def run(self):
     windivert_installer = WinDivertInstaller(windivert)
     self.execute(windivert_installer.uninstall, [],
                  msg="Running WinDivert uninstall task")
Exemplo n.º 14
0
 def run(self):
     windivert_installer = WinDivertInstaller(windivert)
     self.execute(windivert_installer.run, (site.getsitepackages()[0], ),
                  msg="Running WinDivert uninstall task")
Exemplo n.º 15
0
 def run(self):
     windivert_installer = WinDivertInstaller(windivert)
     _install.run(self)
     self.execute(windivert_installer.run, (self.install_lib, ),
                  msg="Running WinDivert install task")