aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-01-10 14:23:21 -0800
committerRob Mensching <rob@firegiant.com>2022-01-10 17:08:43 -0800
commitc0e933d1cec2515e1c43aa1f3b3c4bde9a17e449 (patch)
tree0b6a1a5719d64c8622173320d16b1a7729f75d89
parent9e8ae377ad8ee2e5d00cce6e337a2dbb3ad99736 (diff)
downloadwix-c0e933d1cec2515e1c43aa1f3b3c4bde9a17e449.tar.gz
wix-c0e933d1cec2515e1c43aa1f3b3c4bde9a17e449.tar.bz2
wix-c0e933d1cec2515e1c43aa1f3b3c4bde9a17e449.zip
MSBuild tests enhanced to test signing
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/.Data/signed_cab1.cabbin0 -> 1585 bytes
-rw-r--r--src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs57
-rw-r--r--src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj21
-rw-r--r--src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/SimpleBundle/SimpleBundle.wixproj10
-rw-r--r--src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/UncompressedBundle/UncompressedBundle.wixproj10
5 files changed, 89 insertions, 9 deletions
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/.Data/signed_cab1.cab b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/.Data/signed_cab1.cab
new file mode 100644
index 00000000..4dbd3cff
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/.Data/signed_cab1.cab
Binary files differ
diff --git a/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs b/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs
index b1a97644..3a9ce776 100644
--- a/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs
+++ b/src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs
@@ -26,12 +26,19 @@ namespace WixToolsetTest.Sdk
26 var binFolder = Path.Combine(baseFolder, @"bin\"); 26 var binFolder = Path.Combine(baseFolder, @"bin\");
27 var projectPath = Path.Combine(baseFolder, "SimpleBundle.wixproj"); 27 var projectPath = Path.Combine(baseFolder, "SimpleBundle.wixproj");
28 28
29 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath); 29 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] { "-p:SignOutput=true" });
30 result.AssertSuccess(); 30 result.AssertSuccess();
31 31
32 var warnings = result.Output.Where(line => line.Contains(": warning")).ToArray(); 32 var warnings = result.Output.Where(line => line.Contains(": warning")).ToArray();
33 WixAssert.StringCollectionEmpty(warnings); 33 WixAssert.StringCollectionEmpty(warnings);
34 34
35 var testMessages = result.Output.Where(line => line.Contains("TEST:")).Select(line => line.Trim()).ToArray();
36 WixAssert.CompareLineByLine(new[]
37 {
38 @"TEST: SignBundleEngine: obj\x86\Release\SimpleBundle.exe",
39 @"TEST: SignBundle: obj\x86\Release\SimpleBundle.exe",
40 }, testMessages);
41
35 var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) 42 var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
36 .Select(s => s.Substring(baseFolder.Length + 1)) 43 .Select(s => s.Substring(baseFolder.Length + 1))
37 .OrderBy(s => s) 44 .OrderBy(s => s)
@@ -59,12 +66,18 @@ namespace WixToolsetTest.Sdk
59 var binFolder = Path.Combine(baseFolder, @"bin\"); 66 var binFolder = Path.Combine(baseFolder, @"bin\");
60 var projectPath = Path.Combine(baseFolder, "UncompressedBundle.wixproj"); 67 var projectPath = Path.Combine(baseFolder, "UncompressedBundle.wixproj");
61 68
62 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath); 69 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] { "-p:SignOutput=true" });
63 result.AssertSuccess(); 70 result.AssertSuccess();
64 71
65 var warnings = result.Output.Where(line => line.Contains(": warning")).ToArray(); 72 var warnings = result.Output.Where(line => line.Contains(": warning")).ToArray();
66 WixAssert.StringCollectionEmpty(warnings); 73 WixAssert.StringCollectionEmpty(warnings);
67 74
75 var testMessages = result.Output.Where(line => line.Contains("TEST:")).Select(line => line.Trim()).ToArray();
76 WixAssert.CompareLineByLine(new[]
77 {
78 @"TEST: SignBundleEngine: obj\x86\Release\UncompressedBundle.exe",
79 }, testMessages);
80
68 var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) 81 var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
69 .Select(s => s.Substring(baseFolder.Length + 1)) 82 .Select(s => s.Substring(baseFolder.Length + 1))
70 .OrderBy(s => s) 83 .OrderBy(s => s)
@@ -119,21 +132,39 @@ namespace WixToolsetTest.Sdk
119 { 132 {
120 var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); 133 var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
121 134
135 var baseFolder = String.Empty;
136
122 using (var fs = new TestDataFolderFileSystem()) 137 using (var fs = new TestDataFolderFileSystem())
123 { 138 {
124 fs.Initialize(sourceFolder); 139 fs.Initialize(sourceFolder);
125 var baseFolder = fs.BaseFolder; 140 baseFolder = fs.BaseFolder;
141
126 var binFolder = Path.Combine(baseFolder, @"bin\"); 142 var binFolder = Path.Combine(baseFolder, @"bin\");
127 var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); 143 var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
128 144
129 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath); 145 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] { "-p:SignOutput=true" });
130 result.AssertSuccess(); 146 result.AssertSuccess();
131 147
132 var platformSwitches = result.Output.Where(line => line.Contains("-platform x86")); 148 var platformSwitches = result.Output.Where(line => line.Contains("-platform x86"));
133 Assert.Single(platformSwitches); 149 Assert.Single(platformSwitches);
134 150
135 var warnings = result.Output.Where(line => line.Contains(": warning")); 151 var warnings = result.Output.Where(line => line.Contains(": warning")).Select(ExtractWarningFromMessage).ToArray();
136 Assert.Equal(4, warnings.Count()); 152 WixAssert.CompareLineByLine(new[]
153 {
154 @"WIX1118: The variable 'Variable' with value 'DifferentValue' was previously declared with value 'Value'.",
155 @"WIX1102: The DefaultLanguage '1033' was used for file 'filcV1yrx0x8wJWj4qMzcH21jwkPko' which has no language or version. For unversioned files, specifying a value for DefaultLanguage is not neccessary and it will not be used when determining file versions. Remove the DefaultLanguage attribute to eliminate this warning.",
156 @"WIX1122: The installer database '<basefolder>\obj\x86\Release\en-US\MsiPackage.msi' has external cabs, but at least one of them is not signed. Please ensure that all external cabs are signed, if you mean to sign them. If you don't mean to sign them, there is no need to inscribe the MSI as part of your build.",
157 @"WIX1118: The variable 'Variable' with value 'DifferentValue' was previously declared with value 'Value'.",
158 @"WIX1102: The DefaultLanguage '1033' was used for file 'filcV1yrx0x8wJWj4qMzcH21jwkPko' which has no language or version. For unversioned files, specifying a value for DefaultLanguage is not neccessary and it will not be used when determining file versions. Remove the DefaultLanguage attribute to eliminate this warning.",
159 @"WIX1122: The installer database '<basefolder>\obj\x86\Release\en-US\MsiPackage.msi' has external cabs, but at least one of them is not signed. Please ensure that all external cabs are signed, if you mean to sign them. If you don't mean to sign them, there is no need to inscribe the MSI as part of your build."
160 }, warnings);
161
162 var testMessages = result.Output.Where(line => line.Contains("TEST:")).Select(ReplacePathsInMessage).ToArray();
163 WixAssert.CompareLineByLine(new[]
164 {
165 @"TEST: SignCabs: <basefolder>\obj\x86\Release\en-US\cab1.cab",
166 @"TEST: SignMsi: obj\x86\Release\en-US\MsiPackage.msi",
167 }, testMessages);
137 168
138 var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) 169 var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
139 .Select(s => s.Substring(baseFolder.Length + 1)) 170 .Select(s => s.Substring(baseFolder.Length + 1))
@@ -146,6 +177,20 @@ namespace WixToolsetTest.Sdk
146 @"bin\x86\Release\en-US\MsiPackage.wixpdb", 177 @"bin\x86\Release\en-US\MsiPackage.wixpdb",
147 }, paths); 178 }, paths);
148 } 179 }
180
181 string ExtractWarningFromMessage(string message)
182 {
183 const string prefix = ": warning ";
184
185 var start = message.IndexOf(prefix) + prefix.Length;
186 var end = message.LastIndexOf("[");
187 return ReplacePathsInMessage(message.Substring(start, end - start));
188 }
189
190 string ReplacePathsInMessage(string message)
191 {
192 return message.Replace(baseFolder, "<basefolder>").Trim();
193 }
149 } 194 }
150 195
151 [Theory] 196 [Theory]
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj b/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj
index 18ae08b2..acbcd85d 100644
--- a/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj
+++ b/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/MsiPackage/MsiPackage.wixproj
@@ -43,4 +43,23 @@
43 </ItemGroup> 43 </ItemGroup>
44 44
45 <Import Project="$(WixTargetsPath)" /> 45 <Import Project="$(WixTargetsPath)" />
46</Project> \ No newline at end of file 46
47 <Target Name="SignCabs">
48 <!-- It would be cool to actually sign, but signtool.exe is not always easy to find, so we'll
49 mock it up instead.
50 <Error Text="Could not find pfx at: $(TestCertificate)" Condition=" !Exists('$(TestCertificate)') " />
51 <Exec Command='signtool.exe sign /v /f $(TestCertificate) /p password %(SignCabs.FullPath)' />
52 -->
53 <Message Importance="high" Text="TEST: SignCabs: @(SignCabs)" />
54 </Target>
55
56 <Target Name="SignMsi">
57 <!-- It would be cool to actually sign, but signtool.exe is not always easy to find, so we'll
58 mock it up instead.
59 <Error Text="Could not find pfx at: $(TestCertificate)" Condition=" !Exists('$(TestCertificate)') " />
60 <Exec Command='signtool.exe sign /v /f $(TestCertificate) /p password "%(SignMsi.FullPath)" ' />
61 -->
62 <Message Importance="high" Text="TEST: SignMsi: @(SignMsi)" />
63 </Target>
64
65</Project>
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/SimpleBundle/SimpleBundle.wixproj b/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/SimpleBundle/SimpleBundle.wixproj
index 199eb6d9..8f06f328 100644
--- a/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/SimpleBundle/SimpleBundle.wixproj
+++ b/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/SimpleBundle/SimpleBundle.wixproj
@@ -39,4 +39,12 @@
39 </ItemGroup> 39 </ItemGroup>
40 40
41 <Import Project="$(WixTargetsPath)" /> 41 <Import Project="$(WixTargetsPath)" />
42</Project> \ No newline at end of file 42
43 <Target Name="SignBundleEngine">
44 <Message Importance="high" Text="TEST: SignBundleEngine: @(SignBundleEngine)" />
45 </Target>
46
47 <Target Name="SignBundle">
48 <Message Importance="high" Text="TEST: SignBundle: @(SignBundle)" />
49 </Target>
50</Project>
diff --git a/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/UncompressedBundle/UncompressedBundle.wixproj b/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/UncompressedBundle/UncompressedBundle.wixproj
index 199eb6d9..8f06f328 100644
--- a/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/UncompressedBundle/UncompressedBundle.wixproj
+++ b/src/wix/test/WixToolsetTest.Sdk/TestData/SimpleMsiPackage/UncompressedBundle/UncompressedBundle.wixproj
@@ -39,4 +39,12 @@
39 </ItemGroup> 39 </ItemGroup>
40 40
41 <Import Project="$(WixTargetsPath)" /> 41 <Import Project="$(WixTargetsPath)" />
42</Project> \ No newline at end of file 42
43 <Target Name="SignBundleEngine">
44 <Message Importance="high" Text="TEST: SignBundleEngine: @(SignBundleEngine)" />
45 </Target>
46
47 <Target Name="SignBundle">
48 <Message Importance="high" Text="TEST: SignBundle: @(SignBundle)" />
49 </Target>
50</Project>