Exemplo n.º 1
0
 def test_unpack_zip(self, data: TestData) -> None:
     """
     Test unpacking a *.zip, and setting execute permissions
     """
     test_file = data.packages.joinpath("test_zip.zip")
     unzip_file(os.fspath(test_file), self.tempdir)
     self.confirm_files()
Exemplo n.º 2
0
 def test_unpack_zip_failure(self) -> None:
     """
     Test unpacking a *.zip with file containing .. path
     and expect exception
     """
     files = ["regular_file.txt", os.path.join("..", "outside_file.txt")]
     test_zip = self.make_zip_file("test_zip.zip", files)
     with pytest.raises(InstallationError) as e:
         unzip_file(test_zip, self.tempdir)
     assert "trying to install outside target directory" in str(e.value)
Exemplo n.º 3
0
 def test_unpack_zip_failure(self):
     """
     Test unpacking a *.zip with file containing .. path
     and expect exception
     """
     files = ['regular_file.txt', os.path.join('..', 'outside_file.txt')]
     test_zip = self.make_zip_file('test_zip.zip', files)
     with pytest.raises(InstallationError) as e:
         unzip_file(test_zip, self.tempdir)
     assert 'trying to install outside target directory' in str(e.value)
Exemplo n.º 4
0
 def test_unpack_zip_success(self) -> None:
     """
     Test unpacking a *.zip with regular files,
     no file will be installed outside target directory after unpack
     so no exception raised
     """
     files = [
         "regular_file1.txt",
         os.path.join("dir", "dir_file1.txt"),
         os.path.join("dir", "..", "dir_file2.txt"),
     ]
     test_zip = self.make_zip_file("test_zip.zip", files)
     unzip_file(test_zip, self.tempdir)
Exemplo n.º 5
0
 def test_unpack_zip_success(self):
     """
     Test unpacking a *.zip with regular files,
     no file will be installed outside target directory after unpack
     so no exception raised
     """
     files = [
         'regular_file1.txt',
         os.path.join('dir', 'dir_file1.txt'),
         os.path.join('dir', '..', 'dir_file2.txt'),
     ]
     test_zip = self.make_zip_file('test_zip.zip', files)
     unzip_file(test_zip, self.tempdir)