diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-07-01 00:07:05 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-07-01 11:26:56 -0700 |
| commit | ea4fe9e10a1236262011f845585ae94154964a86 (patch) | |
| tree | 6bc197de15d47fd75b41b768ed1ef34074c95b00 /src | |
| parent | 48aea40184697a5394875e07aac2293da10875bb (diff) | |
| download | wix-ea4fe9e10a1236262011f845585ae94154964a86.tar.gz wix-ea4fe9e10a1236262011f845585ae94154964a86.tar.bz2 wix-ea4fe9e10a1236262011f845585ae94154964a86.zip | |
Convert Firewall/RemoteAddress inner text to Value attribute
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Converters/WixConverter.cs | 7 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs | 79 |
2 files changed, 85 insertions, 1 deletions
diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index 86a1bfba..73538d56 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs | |||
| @@ -26,6 +26,7 @@ namespace WixToolset.Converters | |||
| 26 | private static readonly XNamespace WixNamespace = "http://wixtoolset.org/schemas/v4/wxs"; | 26 | private static readonly XNamespace WixNamespace = "http://wixtoolset.org/schemas/v4/wxs"; |
| 27 | private static readonly XNamespace Wix3Namespace = "http://schemas.microsoft.com/wix/2006/wi"; | 27 | private static readonly XNamespace Wix3Namespace = "http://schemas.microsoft.com/wix/2006/wi"; |
| 28 | private static readonly XNamespace WixUtilNamespace = "http://wixtoolset.org/schemas/v4/wxs/util"; | 28 | private static readonly XNamespace WixUtilNamespace = "http://wixtoolset.org/schemas/v4/wxs/util"; |
| 29 | private static readonly XNamespace WixFirewallNamespace = "http://wixtoolset.org/schemas/v4/wxs/firewall"; | ||
| 29 | 30 | ||
| 30 | private static readonly XName AdminExecuteSequenceElementName = WixNamespace + "AdminExecuteSequence"; | 31 | private static readonly XName AdminExecuteSequenceElementName = WixNamespace + "AdminExecuteSequence"; |
| 31 | private static readonly XName AdminUISequenceSequenceElementName = WixNamespace + "AdminUISequence"; | 32 | private static readonly XName AdminUISequenceSequenceElementName = WixNamespace + "AdminUISequence"; |
| @@ -40,10 +41,11 @@ namespace WixToolset.Converters | |||
| 40 | private static readonly XName CreateFolderElementName = WixNamespace + "CreateFolder"; | 41 | private static readonly XName CreateFolderElementName = WixNamespace + "CreateFolder"; |
| 41 | private static readonly XName CustomTableElementName = WixNamespace + "CustomTable"; | 42 | private static readonly XName CustomTableElementName = WixNamespace + "CustomTable"; |
| 42 | private static readonly XName DirectoryElementName = WixNamespace + "Directory"; | 43 | private static readonly XName DirectoryElementName = WixNamespace + "Directory"; |
| 44 | private static readonly XName ErrorElementName = WixNamespace + "Error"; | ||
| 43 | private static readonly XName FeatureElementName = WixNamespace + "Feature"; | 45 | private static readonly XName FeatureElementName = WixNamespace + "Feature"; |
| 44 | private static readonly XName FileElementName = WixNamespace + "File"; | 46 | private static readonly XName FileElementName = WixNamespace + "File"; |
| 45 | private static readonly XName FragmentElementName = WixNamespace + "Fragment"; | 47 | private static readonly XName FragmentElementName = WixNamespace + "Fragment"; |
| 46 | private static readonly XName ErrorElementName = WixNamespace + "Error"; | 48 | private static readonly XName FirewallRemoteAddressElementName = WixFirewallNamespace + "RemoteAddress"; |
| 47 | private static readonly XName LaunchElementName = WixNamespace + "Launch"; | 49 | private static readonly XName LaunchElementName = WixNamespace + "Launch"; |
| 48 | private static readonly XName LevelElementName = WixNamespace + "Level"; | 50 | private static readonly XName LevelElementName = WixNamespace + "Level"; |
| 49 | private static readonly XName ExePackageElementName = WixNamespace + "ExePackage"; | 51 | private static readonly XName ExePackageElementName = WixNamespace + "ExePackage"; |
| @@ -142,6 +144,7 @@ namespace WixToolset.Converters | |||
| 142 | { WixConverter.FeatureElementName, this.ConvertFeatureElement }, | 144 | { WixConverter.FeatureElementName, this.ConvertFeatureElement }, |
| 143 | { WixConverter.FileElementName, this.ConvertFileElement }, | 145 | { WixConverter.FileElementName, this.ConvertFileElement }, |
| 144 | { WixConverter.FragmentElementName, this.ConvertFragmentElement }, | 146 | { WixConverter.FragmentElementName, this.ConvertFragmentElement }, |
| 147 | { WixConverter.FirewallRemoteAddressElementName, this.ConvertFirewallRemoteAddressElement }, | ||
| 145 | { WixConverter.EmbeddedChainerElementName, this.ConvertEmbeddedChainerElement }, | 148 | { WixConverter.EmbeddedChainerElementName, this.ConvertEmbeddedChainerElement }, |
| 146 | { WixConverter.ErrorElementName, this.ConvertErrorElement }, | 149 | { WixConverter.ErrorElementName, this.ConvertErrorElement }, |
| 147 | { WixConverter.ExePackageElementName, this.ConvertSuppressSignatureValidation }, | 150 | { WixConverter.ExePackageElementName, this.ConvertSuppressSignatureValidation }, |
| @@ -547,6 +550,8 @@ namespace WixToolset.Converters | |||
| 547 | } | 550 | } |
| 548 | } | 551 | } |
| 549 | 552 | ||
| 553 | private void ConvertFirewallRemoteAddressElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value"); | ||
| 554 | |||
| 550 | private void ConvertEmbeddedChainerElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Condition"); | 555 | private void ConvertEmbeddedChainerElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Condition"); |
| 551 | 556 | ||
| 552 | private void ConvertErrorElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Message"); | 557 | private void ConvertErrorElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Message"); |
diff --git a/src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs new file mode 100644 index 00000000..72571cd8 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/FirewallExtensionFixture.cs | |||
| @@ -0,0 +1,79 @@ | |||
| 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 | namespace WixToolsetTest.Converters | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Xml.Linq; | ||
| 7 | using WixToolset.Converters; | ||
| 8 | using WixToolsetTest.Converters.Mocks; | ||
| 9 | using Xunit; | ||
| 10 | |||
| 11 | public class FirewallExtensionFixture : BaseConverterFixture | ||
| 12 | { | ||
| 13 | [Fact] | ||
| 14 | public void FixRemoteAddressValue() | ||
| 15 | { | ||
| 16 | var parse = String.Join(Environment.NewLine, | ||
| 17 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:fw='http://schemas.microsoft.com/wix/FirewallExtension'>", | ||
| 18 | " <Fragment>", | ||
| 19 | " <fw:RemoteAddress>", | ||
| 20 | " 127.0.0.1", | ||
| 21 | " </fw:RemoteAddress>", | ||
| 22 | " </Fragment>", | ||
| 23 | "</Wix>"); | ||
| 24 | |||
| 25 | var expected = new[] | ||
| 26 | { | ||
| 27 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:fw=\"http://wixtoolset.org/schemas/v4/wxs/firewall\">", | ||
| 28 | " <Fragment>", | ||
| 29 | " <fw:RemoteAddress Value=\"127.0.0.1\" />", | ||
| 30 | " </Fragment>", | ||
| 31 | "</Wix>" | ||
| 32 | }; | ||
| 33 | |||
| 34 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 35 | |||
| 36 | var messaging = new MockMessaging(); | ||
| 37 | var converter = new WixConverter(messaging, 2, null, null); | ||
| 38 | |||
| 39 | var errors = converter.ConvertDocument(document); | ||
| 40 | Assert.Equal(3, errors); | ||
| 41 | |||
| 42 | var actualLines = UnformattedDocumentLines(document); | ||
| 43 | CompareLineByLine(expected, actualLines); | ||
| 44 | } | ||
| 45 | |||
| 46 | [Fact] | ||
| 47 | public void FixXmlConfigValue() | ||
| 48 | { | ||
| 49 | var parse = String.Join(Environment.NewLine, | ||
| 50 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", | ||
| 51 | " <Fragment>", | ||
| 52 | " <util:XmlConfig Id='Change' ElementPath='book'>", | ||
| 53 | " a<>b", | ||
| 54 | " </util:XmlConfig>", | ||
| 55 | " </Fragment>", | ||
| 56 | "</Wix>"); | ||
| 57 | |||
| 58 | var expected = new[] | ||
| 59 | { | ||
| 60 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | ||
| 61 | " <Fragment>", | ||
| 62 | " <util:XmlConfig Id=\"Change\" ElementPath=\"book\" Value=\"a<>b\" />", | ||
| 63 | " </Fragment>", | ||
| 64 | "</Wix>" | ||
| 65 | }; | ||
| 66 | |||
| 67 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 68 | |||
| 69 | var messaging = new MockMessaging(); | ||
| 70 | var converter = new WixConverter(messaging, 2, null, null); | ||
| 71 | |||
| 72 | var errors = converter.ConvertDocument(document); | ||
| 73 | Assert.Equal(3, errors); | ||
| 74 | |||
| 75 | var actualLines = UnformattedDocumentLines(document); | ||
| 76 | CompareLineByLine(expected, actualLines); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
