From 726889978e57e13e8f0b13526c5fc53f43809848 Mon Sep 17 00:00:00 2001 From: chris_bednarski Date: Sat, 2 Sep 2023 17:31:05 +1000 Subject: [PATCH] add cross version test --- nuget.config | 1 + .../SetBuildNumber/SetBuildNumber.proj | 19 ++ .../SetBuildNumber/transform.wix.app.config | 18 ++ .../CrossVersionMerge.wixproj | 13 + .../CrossVersionMerge/package.en-us.wxl | 11 + .../CrossVersionMerge/package.wxs | 34 +++ .../Module401/Module.en-us.wxl | 10 + .../Module401/Module401.wixproj | 10 + .../Module401/data/test.txt | 1 + .../Module401/module.wxs | 36 +++ .../ModuleCurrent/ModuleCurrent.wixproj | 10 + .../ModuleCurrent/data/test.txt | 1 + .../ModuleCurrent/module.en-us.wxl | 10 + .../ModuleCurrent/module.wxs | 36 +++ .../FirewallExtensionTests.cs | 227 ++++++++++++++++++ src/wix/wix/app.config | 10 + 16 files changed, 447 insertions(+) create mode 100644 src/internal/SetBuildNumber/transform.wix.app.config create mode 100644 src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/CrossVersionMerge.wixproj create mode 100644 src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.en-us.wxl create mode 100644 src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.wxs create mode 100644 src/test/msi/TestData/FirewallExtensionTests/Module401/Module.en-us.wxl create mode 100644 src/test/msi/TestData/FirewallExtensionTests/Module401/Module401.wixproj create mode 100644 src/test/msi/TestData/FirewallExtensionTests/Module401/data/test.txt create mode 100644 src/test/msi/TestData/FirewallExtensionTests/Module401/module.wxs create mode 100644 src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/ModuleCurrent.wixproj create mode 100644 src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/data/test.txt create mode 100644 src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.en-us.wxl create mode 100644 src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.wxs diff --git a/nuget.config b/nuget.config index b7e5add1c..cea62835b 100644 --- a/nuget.config +++ b/nuget.config @@ -12,6 +12,7 @@ + diff --git a/src/internal/SetBuildNumber/SetBuildNumber.proj b/src/internal/SetBuildNumber/SetBuildNumber.proj index cf98234ef..87a81d5bc 100644 --- a/src/internal/SetBuildNumber/SetBuildNumber.proj +++ b/src/internal/SetBuildNumber/SetBuildNumber.proj @@ -23,6 +23,7 @@ SetGlobalJson; SetDirectoryPackagesProps; SetOverallWixVersions; + TransformWixAppConfig; InstallSigningClient @@ -30,8 +31,26 @@ $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\..\..\Directory.Packages.props)) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\..\..\build\wixver.props)) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\..\..\build\ThisAssembly.WixVer.cs)) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\..\wix\wix\app.config)) + + + + $([System.IO.File]::ReadAllText(transform.wix.app.config)) + $(OverallWixAppConfigText.Replace('{GitBaseVersionMajor}', $(GitBaseVersionMajor))) + + + + + + + diff --git a/src/internal/SetBuildNumber/transform.wix.app.config b/src/internal/SetBuildNumber/transform.wix.app.config new file mode 100644 index 000000000..188427ea4 --- /dev/null +++ b/src/internal/SetBuildNumber/transform.wix.app.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/CrossVersionMerge.wixproj b/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/CrossVersionMerge.wixproj new file mode 100644 index 000000000..27b6940e5 --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/CrossVersionMerge.wixproj @@ -0,0 +1,13 @@ + + + + 1055;1056 + + + + + + + + + diff --git a/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.en-us.wxl b/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.en-us.wxl new file mode 100644 index 000000000..2bcb83ee5 --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.wxs b/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.wxs new file mode 100644 index 000000000..a1d1c3b5e --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/CrossVersionMerge/package.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/msi/TestData/FirewallExtensionTests/Module401/Module.en-us.wxl b/src/test/msi/TestData/FirewallExtensionTests/Module401/Module.en-us.wxl new file mode 100644 index 000000000..aa357833d --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/Module401/Module.en-us.wxl @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/src/test/msi/TestData/FirewallExtensionTests/Module401/Module401.wixproj b/src/test/msi/TestData/FirewallExtensionTests/Module401/Module401.wixproj new file mode 100644 index 000000000..239a80c48 --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/Module401/Module401.wixproj @@ -0,0 +1,10 @@ + + + + Module + 1072 + + + + + \ No newline at end of file diff --git a/src/test/msi/TestData/FirewallExtensionTests/Module401/data/test.txt b/src/test/msi/TestData/FirewallExtensionTests/Module401/data/test.txt new file mode 100644 index 000000000..cd0db0e19 --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/Module401/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/msi/TestData/FirewallExtensionTests/Module401/module.wxs b/src/test/msi/TestData/FirewallExtensionTests/Module401/module.wxs new file mode 100644 index 000000000..1817551dd --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/Module401/module.wxs @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/ModuleCurrent.wixproj b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/ModuleCurrent.wixproj new file mode 100644 index 000000000..8a84280c7 --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/ModuleCurrent.wixproj @@ -0,0 +1,10 @@ + + + + Module + 1072 + + + + + \ No newline at end of file diff --git a/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/data/test.txt b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/data/test.txt new file mode 100644 index 000000000..cd0db0e19 --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.en-us.wxl b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.en-us.wxl new file mode 100644 index 000000000..3afcdf157 --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.en-us.wxl @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.wxs b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.wxs new file mode 100644 index 000000000..3cd3e243c --- /dev/null +++ b/src/test/msi/TestData/FirewallExtensionTests/ModuleCurrent/module.wxs @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs index ce55aa142..1cd1a22ab 100644 --- a/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs +++ b/src/test/msi/WixToolsetTest.MsiE2E/FirewallExtensionTests.cs @@ -532,5 +532,232 @@ public void FullSetOfScopeValuesCanBeUsed() Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0016")); Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0017")); } + + [RuntimeFact] + public void CanInstallAndUninstallFirewallRulesPackagedByDifferentModules() + { + var product = this.CreatePackageInstaller("en-US\\CrossVersionMerge"); + product.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); + + // Validate new firewall exception details. + var expected1 = new RuleDetails("WiXToolset401 Test - 0018") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + ApplicationName = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "MsiPackage", "file1.txt"), + Description = "WiX Toolset firewall exception rule integration test - module 401 MergeRedirectFolder - app", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = true, + EdgeTraversalOptions = 1, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "40101", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset401 Test - 0018", expected1); + + var expected2 = new RuleDetails("WiXToolset401 Test - 0019") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + Description = "WiX Toolset firewall exception rule integration test - module 401 MergeRedirectFolder - port", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = false, + EdgeTraversalOptions = 0, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "40102", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset401 Test - 0019", expected2); + + var expected3 = new RuleDetails("WiXToolset401 Test - 0020") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + ApplicationName = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "MsiPackage", "file2.txt"), + Description = "WiX Toolset firewall exception rule integration test - module 401 NotTheMergeRedirectFolder - app", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = true, + EdgeTraversalOptions = 1, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "40103", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset401 Test - 0020", expected3); + + var expected4 = new RuleDetails("WiXToolset401 Test - 0021") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + Description = "WiX Toolset firewall exception rule integration test - module 401 NotTheMergeRedirectFolder - port", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = false, + EdgeTraversalOptions = 0, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "40104", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset401 Test - 0021", expected4); + + var expected5 = new RuleDetails("WiXToolset Test - 0022") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + ApplicationName = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "MsiPackage", "file1.txt"), + Description = "WiX Toolset firewall exception rule integration test - module MergeRedirectFolder - app", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = true, + EdgeTraversalOptions = 1, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "50001", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset Test - 0022", expected5); + + var expected6 = new RuleDetails("WiXToolset Test - 0023") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + Description = "WiX Toolset firewall exception rule integration test - module MergeRedirectFolder - port", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = false, + EdgeTraversalOptions = 0, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "50002", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset Test - 0023", expected6); + + var expected7 = new RuleDetails("WiXToolset Test - 0024") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + ApplicationName = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "MsiPackage", "file2.txt"), + Description = "WiX Toolset firewall exception rule integration test - module NotTheMergeRedirectFolder - app", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = true, + EdgeTraversalOptions = 1, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "50003", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset Test - 0024", expected7); + + var expected8 = new RuleDetails("WiXToolset Test - 0025") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + Description = "WiX Toolset firewall exception rule integration test - module NotTheMergeRedirectFolder - port", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = false, + EdgeTraversalOptions = 0, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "50004", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset Test - 0025", expected8); + + var expected9 = new RuleDetails("WiXToolset Test - 0026") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + ApplicationName = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "MsiPackage", "package.wxs"), + Description = "WiX Toolset firewall exception rule integration test - package app", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = true, + EdgeTraversalOptions = 1, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "20001", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset Test - 0026", expected9); + + var expected10 = new RuleDetails("WiXToolset Test - 0027") + { + Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW, + Description = "WiX Toolset firewall exception rule integration test - package port", + Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN, + EdgeTraversal = false, + EdgeTraversalOptions = 0, + Enabled = true, + InterfaceTypes = "All", + LocalAddresses = "*", + LocalPorts = "20002", + Profiles = Int32.MaxValue, + Protocol = 6, + RemoteAddresses = "*", + RemotePorts = "*", + SecureFlags = 0, + }; + + Verifier.VerifyFirewallRule("WiXToolset Test - 0027", expected10); + + product.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); + + // verify the firewall exceptions have been removed. + Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0018")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0019")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0020")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset401 Test - 0021")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset Test - 0022")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset Test - 0023")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset Test - 0024")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset Test - 0025")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset Test - 0026")); + Assert.False(Verifier.FirewallRuleExists("WiXToolset Test - 0027")); + } } } diff --git a/src/wix/wix/app.config b/src/wix/wix/app.config index 081fea2c4..75b447520 100644 --- a/src/wix/wix/app.config +++ b/src/wix/wix/app.config @@ -4,5 +4,15 @@ + + + + + + + + + +