File tree Expand file tree Collapse file tree 5 files changed +60
-10
lines changed Expand file tree Collapse file tree 5 files changed +60
-10
lines changed Original file line number Diff line number Diff line change 2
2
#tool nuget: ? package = OpenCover
3
3
#tool nuget: ? package= xunit. runner. console
4
4
#tool nuget: ? package= Codecov
5
- #tool nuget: ? package= ReportGenerator
5
+ #tool nuget: ? package= ReportGenerator& version = 4.2 .20
6
6
#addin nuget: ? package = Cake . Codecov & version = 0.5 .0
7
7
8
8
var target = Argument( "target" , "Default" ) ;
Original file line number Diff line number Diff line change @@ -25,19 +25,24 @@ public HasPassword(IInput zip, string virtualPath)
25
25
26
26
public bool Value ( )
27
27
{
28
- var stream = zip . Stream ( ) ;
29
- stream . Seek ( 0 , SeekOrigin . Begin ) ;
30
28
new FailWhen (
31
29
( ) => ! new IsZipArchive ( this . zip ) . Value ( ) ,
32
- new ArgumentException (
33
- "Can not extract zip because no zip was provided."
34
- )
30
+ new ArgumentException ( "Cannot check for password because no zip was provided." )
35
31
) . Go ( ) ;
36
- stream . Seek ( 0 , SeekOrigin . Begin ) ;
32
+
33
+ // ZipFile.ContainsEntry() by Ionic does not work with backslashes,
34
+ // even if the path is normalized. Misterious
35
+ new FailWhen (
36
+ ( ) => ! new ZipContains ( this . zip , this . virtualPath ) . Value ( ) ,
37
+ new ArgumentException ( $ "Cannot check for password because file '{ this . virtualPath } doesn't exists in zip.")
38
+ ) . Go ( ) ;
39
+
37
40
bool result ;
38
- using ( var zip = ZipFile . Read ( this . zip . Stream ( ) ) )
41
+ var stream = this . zip . Stream ( ) ;
42
+ stream . Seek ( 0 , SeekOrigin . Begin ) ;
43
+ using ( var zip = ZipFile . Read ( stream ) )
39
44
{
40
- result = zip [ virtualPath ] . UsesEncryption ;
45
+ result = zip [ this . virtualPath ] . UsesEncryption ;
41
46
}
42
47
return result ;
43
48
}
Original file line number Diff line number Diff line change @@ -71,5 +71,19 @@ public void ThrowsOnNoZip()
71
71
new HasPassword ( new InputOf ( "test" ) , "a path" ) . Value ( )
72
72
) ;
73
73
}
74
+
75
+ [ Fact ]
76
+ public void ThrowsOnMissingEntry ( )
77
+ {
78
+ Assert . Throws < ArgumentException > ( ( ) =>
79
+ new HasPassword (
80
+ new Zipped (
81
+ "filename.txt" ,
82
+ new InputOf ( "a input" )
83
+ ) ,
84
+ "otherfile.txt"
85
+ ) . Value ( )
86
+ ) ;
87
+ }
74
88
}
75
89
}
Original file line number Diff line number Diff line change 1
- using Xunit ;
1
+ using System ;
2
+ using Xunit ;
2
3
using Yaapii . Atoms . IO ;
3
4
using Yaapii . Atoms . Text ;
4
5
@@ -39,6 +40,20 @@ public void WorksWithSlashAndBacklashSeparation(string path)
39
40
) ;
40
41
}
41
42
43
+ [ Fact ]
44
+ public void FailsOnMissingEntry ( )
45
+ {
46
+ Assert . Throws < ArgumentException > ( ( ) =>
47
+ new ZipExtracted (
48
+ new Zipped (
49
+ "filename.txt" ,
50
+ new InputOf ( "a input" )
51
+ ) ,
52
+ "otherfile.txt"
53
+ ) . Stream ( )
54
+ ) ;
55
+ }
56
+
42
57
[ Theory ]
43
58
[ InlineData ( "Datum/windows.zip" ) ]
44
59
[ InlineData ( "Datum/7zip.zip" ) ]
Original file line number Diff line number Diff line change @@ -77,5 +77,21 @@ public void FailsOnNoPassword()
77
77
) . AsString ( )
78
78
) ;
79
79
}
80
+
81
+ [ Fact ]
82
+ public void FailsOnMissingEntry ( )
83
+ {
84
+ Assert . Throws < ArgumentException > ( ( ) =>
85
+ new ZipPasswordExtracted (
86
+ new ZipWithPassword (
87
+ "filename.txt" ,
88
+ "pwd" ,
89
+ new InputOf ( "a input" )
90
+ ) ,
91
+ "otherfile.txt" ,
92
+ "pwd"
93
+ ) . Stream ( )
94
+ ) ;
95
+ }
80
96
}
81
97
}
You can’t perform that action at this time.
0 commit comments