forked from haf/DotNetZip.Semverd
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,52 @@ | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Ionic.Zip.Tests | ||
namespace Ionic.Zip.Tests; | ||
|
||
public class BasicTest | ||
{ | ||
public class BasicTest | ||
private readonly ITestOutputHelper _output; | ||
|
||
public BasicTest(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
[Fact] | ||
public void TestCreate() | ||
{ | ||
var result = new ZipFile(); | ||
Assert.NotNull(result); | ||
} | ||
|
||
[Fact] | ||
public void Extract_ZipWithAbsolutePathsOutside() | ||
{ | ||
[Fact] | ||
public void TestCreate() | ||
Assert.Throws<IOException>(() => Extract_ZipFile("absolute-path-traversal.zip")); | ||
Assert.False(File.Exists(@"C:\Windows\Temp\foo")); | ||
} | ||
|
||
private void Extract_ZipFile(string fileName) | ||
{ | ||
var sourceDir = Directory.GetCurrentDirectory(); | ||
_output.WriteLine("Current Dir: {0}", sourceDir); | ||
|
||
var fqFileName = Path.Combine(sourceDir, "zips", fileName); | ||
|
||
_output.WriteLine("Reading zip file: '{0}'", fqFileName); | ||
using var zip = ZipFile.Read(fqFileName); | ||
const string extractDir = "extract"; | ||
foreach (ZipEntry e in zip) | ||
{ | ||
var result = new ZipFile(); | ||
Assert.NotNull(result); | ||
_output.WriteLine("{1,-22} {2,9} {3,5:F0}% {4,9} {5,3} {6:X8} {0}", | ||
e.FileName, | ||
e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"), | ||
e.UncompressedSize, | ||
e.CompressionRatio, | ||
e.CompressedSize, | ||
(e.UsesEncryption) ? "Y" : "N", | ||
e.Crc); | ||
e.Extract(extractDir); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.