diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-05-23 22:02:15 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-05-23 22:06:11 +1000 |
| commit | 2480d0ad4bf4f0dd841697d6d607bb35a0fd8161 (patch) | |
| tree | eeae44c10d400a509db879e8b88e8b93cf264011 | |
| parent | 049a5c80b1af9612c8484db177323be4444e7c8a (diff) | |
| download | wix-2480d0ad4bf4f0dd841697d6d607bb35a0fd8161.tar.gz wix-2480d0ad4bf4f0dd841697d6d607bb35a0fd8161.tar.bz2 wix-2480d0ad4bf4f0dd841697d6d607bb35a0fd8161.zip | |
Add test for wixcop handling util:PermissionEx/@Inheritable.
4 files changed, 103 insertions, 2 deletions
diff --git a/src/test/WixToolsetTest.WixCop/TestData/PermissionEx/v3.wxs b/src/test/WixToolsetTest.WixCop/TestData/PermissionEx/v3.wxs new file mode 100644 index 00000000..0e241544 --- /dev/null +++ b/src/test/WixToolsetTest.WixCop/TestData/PermissionEx/v3.wxs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> | ||
| 3 | <Fragment> | ||
| 4 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
| 5 | <Component> | ||
| 6 | <File Source="example.txt"> | ||
| 7 | <util:PermissionEx User="Everyone" GenericAll="yes" /> | ||
| 8 | </File> | ||
| 9 | <CreateFolder> | ||
| 10 | <util:PermissionEx User="Everyone" GenericAll="yes" /> | ||
| 11 | </CreateFolder> | ||
| 12 | <ServiceInstall Name="testsvc" Type="ownProcess" Start="disabled" ErrorControl="normal"> | ||
| 13 | <util:PermissionEx User="Everyone" GenericAll="yes" /> | ||
| 14 | </ServiceInstall> | ||
| 15 | <Registry Action="createKey" Root="HKLM" Key="TestKey"> | ||
| 16 | <util:PermissionEx User="Everyone" GenericAll="yes" /> | ||
| 17 | </Registry> | ||
| 18 | <RegistryKey Id="ExampleRegistryKey" ForceCreateOnInstall="yes" Root="HKLM" Key="TestRegistryKey"> | ||
| 19 | <util:PermissionEx User="Everyone" GenericAll="yes" /> | ||
| 20 | </RegistryKey> | ||
| 21 | <RegistryValue Root="HKLM" Key="TestRegistryValueKey" Value="abc"> | ||
| 22 | <util:PermissionEx User="Everyone" GenericAll="yes" /> | ||
| 23 | </RegistryValue> | ||
| 24 | </Component> | ||
| 25 | </ComponentGroup> | ||
| 26 | </Fragment> | ||
| 27 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.WixCop/TestData/PermissionEx/v4_expected.wxs b/src/test/WixToolsetTest.WixCop/TestData/PermissionEx/v4_expected.wxs new file mode 100644 index 00000000..375b70d3 --- /dev/null +++ b/src/test/WixToolsetTest.WixCop/TestData/PermissionEx/v4_expected.wxs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 3 | <Fragment> | ||
| 4 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
| 5 | <Component> | ||
| 6 | <File Id="example.txt" Source="example.txt"> | ||
| 7 | <util:PermissionEx User="Everyone" GenericAll="yes" Inheritable="no" /> | ||
| 8 | </File> | ||
| 9 | <CreateFolder> | ||
| 10 | <util:PermissionEx User="Everyone" GenericAll="yes" /> | ||
| 11 | </CreateFolder> | ||
| 12 | <ServiceInstall Name="testsvc" Type="ownProcess" Start="disabled" ErrorControl="normal"> | ||
| 13 | <util:PermissionEx User="Everyone" GenericAll="yes" Inheritable="no" /> | ||
| 14 | </ServiceInstall> | ||
| 15 | <Registry Action="createKey" Root="HKLM" Key="TestKey"> | ||
| 16 | <util:PermissionEx User="Everyone" GenericAll="yes" Inheritable="no" /> | ||
| 17 | </Registry> | ||
| 18 | <RegistryKey Id="ExampleRegistryKey" ForceCreateOnInstall="yes" Root="HKLM" Key="TestRegistryKey"> | ||
| 19 | <util:PermissionEx User="Everyone" GenericAll="yes" Inheritable="no" /> | ||
| 20 | </RegistryKey> | ||
| 21 | <RegistryValue Root="HKLM" Key="TestRegistryValueKey" Value="abc"> | ||
| 22 | <util:PermissionEx User="Everyone" GenericAll="yes" Inheritable="no" /> | ||
| 23 | </RegistryValue> | ||
| 24 | </Component> | ||
| 25 | </ComponentGroup> | ||
| 26 | </Fragment> | ||
| 27 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.WixCop/WixCopFixture.cs b/src/test/WixToolsetTest.WixCop/WixCopFixture.cs index 207782b7..72a36dd6 100644 --- a/src/test/WixToolsetTest.WixCop/WixCopFixture.cs +++ b/src/test/WixToolsetTest.WixCop/WixCopFixture.cs | |||
| @@ -10,6 +10,51 @@ namespace WixToolsetTest.WixCop | |||
| 10 | public class WixCopFixture | 10 | public class WixCopFixture |
| 11 | { | 11 | { |
| 12 | [Fact] | 12 | [Fact] |
| 13 | public void CanConvertPermissionExFile() | ||
| 14 | { | ||
| 15 | const string beforeFileName = "v3.wxs"; | ||
| 16 | const string afterFileName = "v4_expected.wxs"; | ||
| 17 | var folder = TestData.Get(@"TestData\PermissionEx"); | ||
| 18 | |||
| 19 | using (var fs = new DisposableFileSystem()) | ||
| 20 | { | ||
| 21 | var baseFolder = fs.GetFolder(true); | ||
| 22 | var targetFile = Path.Combine(baseFolder, beforeFileName); | ||
| 23 | File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName)); | ||
| 24 | |||
| 25 | var runner = new WixCopRunner | ||
| 26 | { | ||
| 27 | FixErrors = true, | ||
| 28 | SearchPatterns = | ||
| 29 | { | ||
| 30 | targetFile, | ||
| 31 | }, | ||
| 32 | }; | ||
| 33 | |||
| 34 | var result = runner.Execute(); | ||
| 35 | |||
| 36 | Assert.Equal(2, result.ExitCode); | ||
| 37 | |||
| 38 | var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n"); | ||
| 39 | var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n"); | ||
| 40 | Assert.Equal(expected, actual); | ||
| 41 | |||
| 42 | var runner2 = new WixCopRunner | ||
| 43 | { | ||
| 44 | FixErrors = true, | ||
| 45 | SearchPatterns = | ||
| 46 | { | ||
| 47 | targetFile, | ||
| 48 | }, | ||
| 49 | }; | ||
| 50 | |||
| 51 | var result2 = runner2.Execute(); | ||
| 52 | |||
| 53 | Assert.Equal(0, result2.ExitCode); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | [Fact] | ||
| 13 | public void CanConvertSingleFile() | 58 | public void CanConvertSingleFile() |
| 14 | { | 59 | { |
| 15 | const string beforeFileName = "SingleFile.wxs"; | 60 | const string beforeFileName = "SingleFile.wxs"; |
diff --git a/src/test/WixToolsetTest.WixCop/WixToolsetTest.WixCop.csproj b/src/test/WixToolsetTest.WixCop/WixToolsetTest.WixCop.csproj index 787b8ca1..3ea4dae5 100644 --- a/src/test/WixToolsetTest.WixCop/WixToolsetTest.WixCop.csproj +++ b/src/test/WixToolsetTest.WixCop/WixToolsetTest.WixCop.csproj | |||
| @@ -18,8 +18,8 @@ | |||
| 18 | <None Remove="TestData\SingleFile\SingleFile.wxs" /> | 18 | <None Remove="TestData\SingleFile\SingleFile.wxs" /> |
| 19 | </ItemGroup> | 19 | </ItemGroup> |
| 20 | <ItemGroup> | 20 | <ItemGroup> |
| 21 | <Content Include="TestData\SingleFile\ConvertedSingleFile.wxs" CopyToOutputDirectory="PreserveNewest" /> | 21 | <Content Include="TestData\PermissionEx\v3.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 22 | <Content Include="TestData\SingleFile\SingleFile.wxs" CopyToOutputDirectory="PreserveNewest" /> | 22 | <Content Include="TestData\PermissionEx\v4_expected.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 23 | <Content Include="TestData\Preprocessor\ConvertedPreprocessor.wxs" CopyToOutputDirectory="PreserveNewest" /> | 23 | <Content Include="TestData\Preprocessor\ConvertedPreprocessor.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 24 | <Content Include="TestData\Preprocessor\Preprocessor.wxs" CopyToOutputDirectory="PreserveNewest" /> | 24 | <Content Include="TestData\Preprocessor\Preprocessor.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 25 | <Content Include="TestData\Preprocessor\wixcop.settings.xml" CopyToOutputDirectory="PreserveNewest" /> | 25 | <Content Include="TestData\Preprocessor\wixcop.settings.xml" CopyToOutputDirectory="PreserveNewest" /> |
| @@ -27,6 +27,8 @@ | |||
| 27 | <Content Include="TestData\QtExec\v4_expected.wxs" CopyToOutputDirectory="PreserveNewest" /> | 27 | <Content Include="TestData\QtExec\v4_expected.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 28 | <Content Include="TestData\QtExec.bad\v3.wxs" CopyToOutputDirectory="PreserveNewest" /> | 28 | <Content Include="TestData\QtExec.bad\v3.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 29 | <Content Include="TestData\QtExec.bad\v4_expected.wxs" CopyToOutputDirectory="PreserveNewest" /> | 29 | <Content Include="TestData\QtExec.bad\v4_expected.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 30 | <Content Include="TestData\SingleFile\ConvertedSingleFile.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
| 31 | <Content Include="TestData\SingleFile\SingleFile.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
| 30 | </ItemGroup> | 32 | </ItemGroup> |
| 31 | 33 | ||
| 32 | <ItemGroup> | 34 | <ItemGroup> |
