aboutsummaryrefslogtreecommitdiff
path: root/src/test/msi
diff options
context:
space:
mode:
authorchris_bednarski <Chris.Bednarski@minfos.com.au>2023-08-20 19:49:21 +1000
committerBob Arnson <github@bobs.org>2023-08-23 23:11:39 -0400
commit537e79d3c8b99e1576db48b19c8071c0922342f2 (patch)
treea3a21f66c55edf08def75bfa2c05c297886ad18b /src/test/msi
parentfebb9c943d6c6c0db3a660de6f96b7d9f5941b1a (diff)
downloadwix-537e79d3c8b99e1576db48b19c8071c0922342f2.tar.gz
wix-537e79d3c8b99e1576db48b19c8071c0922342f2.tar.bz2
wix-537e79d3c8b99e1576db48b19c8071c0922342f2.zip
use WcaGetRecordFormattedString to get firewall rule description
Diffstat (limited to 'src/test/msi')
-rw-r--r--src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/DynamicFirewallRules.wixproj13
-rw-r--r--src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/product.wxs50
-rw-r--r--src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs77
3 files changed, 140 insertions, 0 deletions
diff --git a/src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/DynamicFirewallRules.wixproj b/src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/DynamicFirewallRules.wixproj
new file mode 100644
index 00000000..b39f7387
--- /dev/null
+++ b/src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/DynamicFirewallRules.wixproj
@@ -0,0 +1,13 @@
1<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup>
4 <UpgradeCode>{C587F355-26FF-4D17-801F-50505C348D99}</UpgradeCode>
5 <ProductComponentsRef>true</ProductComponentsRef>
6 </PropertyGroup>
7 <ItemGroup>
8 <Compile Include="..\..\Templates\Product.wxs" Link="Product.wxs" />
9 </ItemGroup>
10 <ItemGroup>
11 <PackageReference Include="WixToolset.Firewall.wixext" />
12 </ItemGroup>
13</Project> \ No newline at end of file
diff --git a/src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/product.wxs b/src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/product.wxs
new file mode 100644
index 00000000..6bc45c10
--- /dev/null
+++ b/src/test/msi/TestData/FirewallExtensionTests/DynamicFirewallRules/product.wxs
@@ -0,0 +1,50 @@
1<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
2
3<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall">
4 <Fragment>
5 <ComponentGroup Id="ProductComponents">
6 <ComponentRef Id="FirewallComponent2"/>
7 </ComponentGroup>
8
9 <Property Id="PORTNUMBER" Secure="yes">
10 <RegistrySearch Id="FindPortNumber" Root="HKLM" Key="SOFTWARE\WiX\Tests\$(var.TestGroupName)" Name="PortNumber" Type="raw" />
11 </Property>
12
13 <CustomAction Id="SavePortNumberCmdLineValue" Property="CMDLINE_PORTNUMBER" Value="[PORTNUMBER]" Execute="firstSequence" />
14 <CustomAction Id="SetPortNumberFromCmdLineValue" Property="PORTNUMBER" Value="[CMDLINE_PORTNUMBER]" Execute="firstSequence" />
15 <CustomAction Id="SetPortNumberDefaultValue" Property="PORTNUMBER" Value="9999" Execute="firstSequence" />
16
17 <InstallExecuteSequence>
18 <Custom Action="SavePortNumberCmdLineValue" Before="AppSearch" />
19 <Custom Action="SetPortNumberFromCmdLineValue" After="AppSearch" Condition="CMDLINE_PORTNUMBER" />
20 <Custom Action="SetPortNumberDefaultValue" After="SetPortNumberFromCmdLineValue" Condition="NOT PORTNUMBER" />
21 </InstallExecuteSequence>
22 </Fragment>
23
24 <Fragment>
25 <Component Id="FirewallComponent2" Guid="528C212C-09C6-47FC-A466-A3799DD04D25" Directory="INSTALLFOLDER" >
26 <RegistryValue Root="HKLM" Key="SOFTWARE\WiX\Tests\$(var.TestGroupName)" Name="PortNumber" Value="[PORTNUMBER]" Type="string" />
27
28 <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" >
29 <fw:FirewallException Id="FirewallException1"
30 Port="[PORTNUMBER]"
31 Description="WiX Toolset firewall exception rule integration test - dynamic app description [PORTNUMBER]"
32 Name="WiXToolset401 Test - 0003" Scope="localSubnet" />
33 </File>
34
35 <fw:FirewallException Id="FirewallException2"
36 Description="WiX Toolset firewall exception rule integration test - dynamic port description [PORTNUMBER]"
37 Name="WiXToolset401 Test - 0004" Scope="any" Port="[PORTNUMBER]" />
38
39 <fw:FirewallException Id="FirewallException3"
40 Description="WiX Toolset firewall exception rule integration test - dynamic Name [PORTNUMBER]"
41 Program="%windir%\system32\[PORTNUMBER].exe"
42 Port="[PORTNUMBER]"
43 Protocol="udp" Profile="private"
44 Name="WiXToolset401 Test - 0005 - [PORTNUMBER]" >
45 <fw:RemoteAddress Value="127.0.0.1" />
46 <fw:RemoteAddress Value="192.168.1.1" />
47 </fw:FirewallException>
48 </Component>
49 </Fragment>
50</Wix>
diff --git a/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs
index fce95845..3e605d7a 100644
--- a/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs
+++ b/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs
@@ -200,5 +200,82 @@ namespace WixToolsetTest.MsiE2E
200 200
201 Verifier.VerifyFirewallRule("WiXToolset401 Test - 0001", expected); 201 Verifier.VerifyFirewallRule("WiXToolset401 Test - 0001", expected);
202 } 202 }
203
204 [RuntimeFact]
205 public void FirewallRulesUseFormattedStringProperties()
206 {
207 var product = this.CreatePackageInstaller("DynamicFirewallRules");
208 product.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS);
209
210 var expected1 = new RuleDetails("WiXToolset401 Test - 0003")
211 {
212 Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW,
213 ApplicationName = this.TestContext.GetTestInstallFolder(false, Path.Combine("DynamicFirewallRules", "product.wxs")),
214 Description = "WiX Toolset firewall exception rule integration test - dynamic app description 9999",
215 Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN,
216 EdgeTraversal = true,
217 EdgeTraversalOptions = 1,
218 Enabled = true,
219 InterfaceTypes = "All",
220 LocalAddresses = "*",
221 Profiles = Int32.MaxValue,
222 Protocol = 6,
223 RemoteAddresses = "LocalSubnet",
224 SecureFlags = 0,
225 LocalPorts = "9999",
226 RemotePorts = "*",
227 };
228
229 Verifier.VerifyFirewallRule("WiXToolset401 Test - 0003", expected1);
230
231 var expected2 = new RuleDetails("WiXToolset401 Test - 0004")
232 {
233 Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW,
234 Description = "WiX Toolset firewall exception rule integration test - dynamic port description 9999",
235 Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN,
236 EdgeTraversal = false,
237 EdgeTraversalOptions = 0,
238 Enabled = true,
239 InterfaceTypes = "All",
240 LocalAddresses = "*",
241 Profiles = Int32.MaxValue,
242 Protocol = 6,
243 RemoteAddresses = "*",
244 SecureFlags = 0,
245 LocalPorts = "9999",
246 RemotePorts = "*",
247 };
248
249 Verifier.VerifyFirewallRule("WiXToolset401 Test - 0004", expected2);
250
251
252 var expected3 = new RuleDetails("WiXToolset401 Test - 0005 - 9999")
253 {
254 Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW,
255 ApplicationName = Path.Combine(Environment.GetEnvironmentVariable("windir"), "system32", "9999.exe"),
256 Description = "WiX Toolset firewall exception rule integration test - dynamic Name 9999",
257 Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN,
258 EdgeTraversal = true,
259 EdgeTraversalOptions = 1,
260 Enabled = true,
261 InterfaceTypes = "All",
262 LocalAddresses = "*",
263 Profiles = 2,
264 Protocol = 17,
265 RemoteAddresses = "127.0.0.1/255.255.255.255,192.168.1.1/255.255.255.255",
266 SecureFlags = 0,
267 LocalPorts = "9999",
268 RemotePorts = "*",
269 };
270
271 Verifier.VerifyFirewallRule("WiXToolset401 Test - 0005 - 9999", expected3);
272
273 product.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS);
274
275 // verify the firewall exceptions have been removed.
276 Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0003"));
277 Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0004"));
278 Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0005 - 9999"));
279 }
203 } 280 }
204} 281}