diff options
| author | chris_bednarski <Chris.Bednarski@minfos.com.au> | 2023-08-26 18:51:38 +1000 |
|---|---|---|
| committer | Bob Arnson <github@bobs.org> | 2023-11-19 12:17:13 -0500 |
| commit | 80e604761b4f43b9b79a4878fcae360b071a7c35 (patch) | |
| tree | 9ca40a1d60a2ef1a5a1a426382356ae8b7cf9868 /src/ext/Firewall/test | |
| parent | 6e974490eeabc9a3728aa2fb9ad07e8a5adf4fb6 (diff) | |
| download | wix-80e604761b4f43b9b79a4878fcae360b071a7c35.tar.gz wix-80e604761b4f43b9b79a4878fcae360b071a7c35.tar.bz2 wix-80e604761b4f43b9b79a4878fcae360b071a7c35.zip | |
change firewall extension table name to Wix5FirewallException
Diffstat (limited to 'src/ext/Firewall/test')
| -rw-r--r-- | src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | 160 | ||||
| -rw-r--r-- | src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs | 4 |
2 files changed, 144 insertions, 20 deletions
diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index 06a877f6..7119e92d 100644 --- a/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | |||
| @@ -18,17 +18,21 @@ namespace WixToolsetTest.Firewall | |||
| 18 | var folder = TestData.Get(@"TestData\UsingFirewall"); | 18 | var folder = TestData.Get(@"TestData\UsingFirewall"); |
| 19 | var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); | 19 | var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); |
| 20 | 20 | ||
| 21 | var results = build.BuildAndQuery(Build, "Wix4FirewallException", "CustomAction"); | 21 | var results = build.BuildAndQuery(Build, "Wix5FirewallException", "CustomAction"); |
| 22 | WixAssert.CompareLineByLine(new[] | 22 | WixAssert.CompareLineByLine(new[] |
| 23 | { | 23 | { |
| 24 | "CustomAction:Wix4ExecFirewallExceptionsInstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", | 24 | "CustomAction:Wix5ExecFirewallExceptionsInstall_X86\t3073\tWix5FWCA_X86\tExecFirewallExceptions\t", |
| 25 | "CustomAction:Wix4ExecFirewallExceptionsUninstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", | 25 | "CustomAction:Wix5ExecFirewallExceptionsUninstall_X86\t3073\tWix5FWCA_X86\tExecFirewallExceptions\t", |
| 26 | "CustomAction:Wix4RollbackFirewallExceptionsInstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", | 26 | "CustomAction:Wix5RollbackFirewallExceptionsInstall_X86\t3329\tWix5FWCA_X86\tExecFirewallExceptions\t", |
| 27 | "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", | 27 | "CustomAction:Wix5RollbackFirewallExceptionsUninstall_X86\t3329\tWix5FWCA_X86\tExecFirewallExceptions\t", |
| 28 | "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", | 28 | "CustomAction:Wix5SchedFirewallExceptionsInstall_X86\t1\tWix5FWCA_X86\tSchedFirewallExceptionsInstall\t", |
| 29 | "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", | 29 | "CustomAction:Wix5SchedFirewallExceptionsUninstall_X86\t1\tWix5FWCA_X86\tSchedFirewallExceptionsUninstall\t", |
| 30 | "Wix4FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", | 30 | "Wix5FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", |
| 31 | "Wix4FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", | 31 | "Wix5FirewallException:fex_ZpDsnKyHlYiA24JHzvFxm3uLZ8\tExampleDefaultGatewayScope\tDefaultGateway\t4432\t6\t\t0\t2\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tdefaultGateway scope firewall exception\t1", |
| 32 | "Wix5FirewallException:fex6bkfWwpiRGI.wVFx0T7W4LXIHxU\tExampleDHCPScope\tdhcp\t\t211\ttest.exe\t0\t4\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tDHCP scope firewall exception\t1", | ||
| 33 | "Wix5FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", | ||
| 34 | "Wix5FirewallException:fexXxaXCXXFh.UxO_BjmZxi1B1du_Q\tExampleWINSScope\twins\t6573\t6\t\t0\t1\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tWINS scope firewall exception\t1", | ||
| 35 | "Wix5FirewallException:fexxY71H2ZBkPalv7uid1Yy4qaA_lA\tExampleDNSScope\tdns\t356\t17\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tDNS scope firewall exception\t1", | ||
| 32 | }, results); | 36 | }, results); |
| 33 | } | 37 | } |
| 34 | 38 | ||
| @@ -38,17 +42,21 @@ namespace WixToolsetTest.Firewall | |||
| 38 | var folder = TestData.Get(@"TestData\UsingFirewall"); | 42 | var folder = TestData.Get(@"TestData\UsingFirewall"); |
| 39 | var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); | 43 | var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); |
| 40 | 44 | ||
| 41 | var results = build.BuildAndQuery(BuildARM64, "Wix4FirewallException", "CustomAction"); | 45 | var results = build.BuildAndQuery(BuildARM64, "Wix5FirewallException", "CustomAction"); |
| 42 | WixAssert.CompareLineByLine(new[] | 46 | WixAssert.CompareLineByLine(new[] |
| 43 | { | 47 | { |
| 44 | "CustomAction:Wix4ExecFirewallExceptionsInstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", | 48 | "CustomAction:Wix5ExecFirewallExceptionsInstall_A64\t3073\tWix5FWCA_A64\tExecFirewallExceptions\t", |
| 45 | "CustomAction:Wix4ExecFirewallExceptionsUninstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", | 49 | "CustomAction:Wix5ExecFirewallExceptionsUninstall_A64\t3073\tWix5FWCA_A64\tExecFirewallExceptions\t", |
| 46 | "CustomAction:Wix4RollbackFirewallExceptionsInstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", | 50 | "CustomAction:Wix5RollbackFirewallExceptionsInstall_A64\t3329\tWix5FWCA_A64\tExecFirewallExceptions\t", |
| 47 | "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", | 51 | "CustomAction:Wix5RollbackFirewallExceptionsUninstall_A64\t3329\tWix5FWCA_A64\tExecFirewallExceptions\t", |
| 48 | "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", | 52 | "CustomAction:Wix5SchedFirewallExceptionsInstall_A64\t1\tWix5FWCA_A64\tSchedFirewallExceptionsInstall\t", |
| 49 | "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", | 53 | "CustomAction:Wix5SchedFirewallExceptionsUninstall_A64\t1\tWix5FWCA_A64\tSchedFirewallExceptionsUninstall\t", |
| 50 | "Wix4FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", | 54 | "Wix5FirewallException:ExampleFirewall\tExampleApp\t*\t42\t6\t[#filNdJBJmq3UCUIwmXS8x21aAsvqzk]\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tAn app-based firewall exception\t1", |
| 51 | "Wix4FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", | 55 | "Wix5FirewallException:fex_ZpDsnKyHlYiA24JHzvFxm3uLZ8\tExampleDefaultGatewayScope\tDefaultGateway\t4432\t6\t\t0\t2\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tdefaultGateway scope firewall exception\t1", |
| 56 | "Wix5FirewallException:fex6bkfWwpiRGI.wVFx0T7W4LXIHxU\tExampleDHCPScope\tdhcp\t\t211\ttest.exe\t0\t4\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tDHCP scope firewall exception\t1", | ||
| 57 | "Wix5FirewallException:fex70IVsYNnbwiHQrEepmdTPKH8XYs\tExamplePort\tLocalSubnet\t42\t6\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tA port-based firewall exception\t2", | ||
| 58 | "Wix5FirewallException:fexXxaXCXXFh.UxO_BjmZxi1B1du_Q\tExampleWINSScope\twins\t6573\t6\t\t0\t1\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tWINS scope firewall exception\t1", | ||
| 59 | "Wix5FirewallException:fexxY71H2ZBkPalv7uid1Yy4qaA_lA\tExampleDNSScope\tdns\t356\t17\t\t0\t2147483647\tfilNdJBJmq3UCUIwmXS8x21aAsvqzk\tDNS scope firewall exception\t1", | ||
| 52 | }, results); | 60 | }, results); |
| 53 | } | 61 | } |
| 54 | 62 | ||
| @@ -71,8 +79,17 @@ namespace WixToolsetTest.Firewall | |||
| 71 | { | 79 | { |
| 72 | "FirewallException", | 80 | "FirewallException", |
| 73 | "FirewallException", | 81 | "FirewallException", |
| 82 | "FirewallException", | ||
| 83 | "FirewallException", | ||
| 84 | "FirewallException", | ||
| 85 | "FirewallException", | ||
| 74 | }, actual.Select(a => a.Name).ToArray()); | 86 | }, actual.Select(a => a.Name).ToArray()); |
| 87 | } | ||
| 75 | 88 | ||
| 89 | [Fact] | ||
| 90 | public void RoundtripAttributesAreCorrectForApp() | ||
| 91 | { | ||
| 92 | var actual = BuildAndDecompileAndBuild("http://wixtoolset.org/schemas/v4/wxs/firewall", "ExampleApp"); | ||
| 76 | WixAssert.CompareLineByLine(new[] | 93 | WixAssert.CompareLineByLine(new[] |
| 77 | { | 94 | { |
| 78 | "Id=ExampleFirewall", | 95 | "Id=ExampleFirewall", |
| @@ -85,8 +102,13 @@ namespace WixToolsetTest.Firewall | |||
| 85 | "Description=An app-based firewall exception", | 102 | "Description=An app-based firewall exception", |
| 86 | "Outbound=no", | 103 | "Outbound=no", |
| 87 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall", | 104 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall", |
| 88 | }, actual[0].Attributes); | 105 | }, actual.Attributes); |
| 106 | } | ||
| 89 | 107 | ||
| 108 | [Fact] | ||
| 109 | public void RoundtripAttributesAreCorrectForPort() | ||
| 110 | { | ||
| 111 | var actual = BuildAndDecompileAndBuild("http://wixtoolset.org/schemas/v4/wxs/firewall", "ExamplePort"); | ||
| 90 | WixAssert.CompareLineByLine(new[] | 112 | WixAssert.CompareLineByLine(new[] |
| 91 | { | 113 | { |
| 92 | "Id=fex70IVsYNnbwiHQrEepmdTPKH8XYs", | 114 | "Id=fex70IVsYNnbwiHQrEepmdTPKH8XYs", |
| @@ -98,7 +120,79 @@ namespace WixToolsetTest.Firewall | |||
| 98 | "Description=A port-based firewall exception", | 120 | "Description=A port-based firewall exception", |
| 99 | "Outbound=yes", | 121 | "Outbound=yes", |
| 100 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall", | 122 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall", |
| 101 | }, actual[1].Attributes); | 123 | }, actual.Attributes); |
| 124 | } | ||
| 125 | |||
| 126 | [Fact] | ||
| 127 | public void RoundtripAttributesAreCorrectForDNSScope() | ||
| 128 | { | ||
| 129 | var actual = BuildAndDecompileAndBuild("http://wixtoolset.org/schemas/v4/wxs/firewall", "ExampleDNSScope"); | ||
| 130 | WixAssert.CompareLineByLine(new[] | ||
| 131 | { | ||
| 132 | "Id=fexxY71H2ZBkPalv7uid1Yy4qaA_lA", | ||
| 133 | "Name=ExampleDNSScope", | ||
| 134 | "Scope=DNS", | ||
| 135 | "Port=356", | ||
| 136 | "Protocol=udp", | ||
| 137 | "Profile=all", | ||
| 138 | "Description=DNS scope firewall exception", | ||
| 139 | "Outbound=no", | ||
| 140 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall", | ||
| 141 | }, actual.Attributes); | ||
| 142 | } | ||
| 143 | |||
| 144 | [Fact] | ||
| 145 | public void RoundtripAttributesAreCorrectForDHCPScope() | ||
| 146 | { | ||
| 147 | var actual = BuildAndDecompileAndBuild("http://wixtoolset.org/schemas/v4/wxs/firewall", "ExampleDHCPScope"); | ||
| 148 | WixAssert.CompareLineByLine(new[] | ||
| 149 | { | ||
| 150 | "Id=fex6bkfWwpiRGI.wVFx0T7W4LXIHxU", | ||
| 151 | "Name=ExampleDHCPScope", | ||
| 152 | "Scope=DHCP", | ||
| 153 | "Protocol=211", | ||
| 154 | "Program=test.exe", | ||
| 155 | "Profile=public", | ||
| 156 | "Description=DHCP scope firewall exception", | ||
| 157 | "Outbound=no", | ||
| 158 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall" | ||
| 159 | }, actual.Attributes); | ||
| 160 | } | ||
| 161 | |||
| 162 | [Fact] | ||
| 163 | public void RoundtripAttributesAreCorrectForWINSScope() | ||
| 164 | { | ||
| 165 | var actual = BuildAndDecompileAndBuild("http://wixtoolset.org/schemas/v4/wxs/firewall", "ExampleWINSScope"); | ||
| 166 | WixAssert.CompareLineByLine(new[] | ||
| 167 | { | ||
| 168 | "Id=fexXxaXCXXFh.UxO_BjmZxi1B1du_Q", | ||
| 169 | "Name=ExampleWINSScope", | ||
| 170 | "Scope=WINS", | ||
| 171 | "Port=6573", | ||
| 172 | "Protocol=tcp", | ||
| 173 | "Profile=domain", | ||
| 174 | "Description=WINS scope firewall exception", | ||
| 175 | "Outbound=no", | ||
| 176 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall", | ||
| 177 | }, actual.Attributes); | ||
| 178 | } | ||
| 179 | |||
| 180 | [Fact] | ||
| 181 | public void RoundtripAttributesAreCorrectForDefaultGatewayScope() | ||
| 182 | { | ||
| 183 | var actual = BuildAndDecompileAndBuild("http://wixtoolset.org/schemas/v4/wxs/firewall", "ExampleDefaultGatewayScope"); | ||
| 184 | WixAssert.CompareLineByLine(new[] | ||
| 185 | { | ||
| 186 | "Id=fex_ZpDsnKyHlYiA24JHzvFxm3uLZ8", | ||
| 187 | "Name=ExampleDefaultGatewayScope", | ||
| 188 | "Scope=defaultGateway", | ||
| 189 | "Port=4432", | ||
| 190 | "Protocol=tcp", | ||
| 191 | "Profile=private", | ||
| 192 | "Description=defaultGateway scope firewall exception", | ||
| 193 | "Outbound=no", | ||
| 194 | "xmlns=http://wixtoolset.org/schemas/v4/wxs/firewall", | ||
| 195 | }, actual.Attributes); | ||
| 102 | } | 196 | } |
| 103 | 197 | ||
| 104 | private static void Build(string[] args) | 198 | private static void Build(string[] args) |
| @@ -122,5 +216,31 @@ namespace WixToolsetTest.Firewall | |||
| 122 | var result = WixRunner.Execute(args); | 216 | var result = WixRunner.Execute(args); |
| 123 | result.AssertSuccess(); | 217 | result.AssertSuccess(); |
| 124 | } | 218 | } |
| 219 | class AttributeVerifier | ||
| 220 | { | ||
| 221 | public string Name { get; set; } | ||
| 222 | public string[] Attributes { get; set; } | ||
| 223 | } | ||
| 224 | |||
| 225 | private static AttributeVerifier BuildAndDecompileAndBuild(string nameSpace, string ruleName) | ||
| 226 | { | ||
| 227 | var folder = TestData.Get(@"TestData", "UsingFirewall"); | ||
| 228 | var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); | ||
| 229 | var output = Path.Combine(folder, $"Firewall{ruleName}.xml"); | ||
| 230 | |||
| 231 | build.BuildAndDecompileAndBuild(Build, Decompile, output); | ||
| 232 | |||
| 233 | var doc = XDocument.Load(output); | ||
| 234 | var actual = doc.Descendants() | ||
| 235 | .Where(e => e.Name.Namespace == nameSpace) | ||
| 236 | .Select(fe => new AttributeVerifier | ||
| 237 | { | ||
| 238 | Name = fe.Attributes().Single(a => a.Name.LocalName == "Name").Value, | ||
| 239 | Attributes = fe.Attributes().Select(a => $"{a.Name.LocalName}={a.Value}").ToArray() | ||
| 240 | }) | ||
| 241 | .Single(av => av.Name == ruleName); | ||
| 242 | |||
| 243 | return actual; | ||
| 244 | } | ||
| 125 | } | 245 | } |
| 126 | } | 246 | } |
diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs index c712d895..957aa642 100644 --- a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs | |||
| @@ -12,6 +12,10 @@ | |||
| 12 | </File> | 12 | </File> |
| 13 | 13 | ||
| 14 | <fw:FirewallException Description="A port-based firewall exception" Name="ExamplePort" Port="42" Outbound="yes" Scope="localSubnet" /> | 14 | <fw:FirewallException Description="A port-based firewall exception" Name="ExamplePort" Port="42" Outbound="yes" Scope="localSubnet" /> |
| 15 | <fw:FirewallException Description="DNS scope firewall exception" Name="ExampleDNSScope" Port="356" Protocol="udp" Scope="DNS" /> | ||
| 16 | <fw:FirewallException Description="DHCP scope firewall exception" Name="ExampleDHCPScope" Program="test.exe" Protocol="211" Scope="DHCP" Profile="public" /> | ||
| 17 | <fw:FirewallException Description="WINS scope firewall exception" Name="ExampleWINSScope" Port="6573" Scope="WINS" Profile="domain"/> | ||
| 18 | <fw:FirewallException Description="defaultGateway scope firewall exception" Name="ExampleDefaultGatewayScope" Port="4432" Scope="defaultGateway" Profile="private" /> | ||
| 15 | </Component> | 19 | </Component> |
| 16 | </ComponentGroup> | 20 | </ComponentGroup> |
| 17 | </Fragment> | 21 | </Fragment> |
