diff options
| author | Bevan Weiss <bevan.weiss@gmail.com> | 2024-06-18 19:03:40 +1000 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2025-02-11 23:14:49 -0800 |
| commit | 7b1bb025dea1d1e9e144cce0dcbba2d86f053b8f (patch) | |
| tree | c2fc969615d858ee40f54cfba406648e9c2743c3 /src/test | |
| parent | 040e50ec2859c1de70cd8e9f957474321774f293 (diff) | |
| download | wix-7b1bb025dea1d1e9e144cce0dcbba2d86f053b8f.tar.gz wix-7b1bb025dea1d1e9e144cce0dcbba2d86f053b8f.tar.bz2 wix-7b1bb025dea1d1e9e144cce0dcbba2d86f053b8f.zip | |
CreateGroups additions
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Diffstat (limited to 'src/test')
24 files changed, 861 insertions, 0 deletions
diff --git a/src/test/burn/WixTestTools/UserGroupVerifier.cs b/src/test/burn/WixTestTools/UserGroupVerifier.cs new file mode 100644 index 00000000..2f874057 --- /dev/null +++ b/src/test/burn/WixTestTools/UserGroupVerifier.cs | |||
| @@ -0,0 +1,198 @@ | |||
| 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 WixTestTools | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Text; | ||
| 7 | using System.DirectoryServices; | ||
| 8 | using System.DirectoryServices.AccountManagement; | ||
| 9 | using System.Security.Principal; | ||
| 10 | using Xunit; | ||
| 11 | |||
| 12 | /// <summary> | ||
| 13 | /// Contains methods for User Group verification | ||
| 14 | /// </summary> | ||
| 15 | public static class UserGroupVerifier | ||
| 16 | { | ||
| 17 | /// <summary> | ||
| 18 | /// Create a local group on the machine | ||
| 19 | /// </summary> | ||
| 20 | /// <param name="groupName"></param> | ||
| 21 | /// <remarks>Has to be run as an Admin</remarks> | ||
| 22 | public static void CreateLocalGroup(string groupName) | ||
| 23 | { | ||
| 24 | DeleteLocalGroup(groupName); | ||
| 25 | GroupPrincipal newGroup = new GroupPrincipal(new PrincipalContext(ContextType.Machine)); | ||
| 26 | newGroup.Name = groupName; | ||
| 27 | newGroup.Description = String.Empty; | ||
| 28 | newGroup.Save(); | ||
| 29 | } | ||
| 30 | |||
| 31 | /// <summary> | ||
| 32 | /// Deletes a local gorup from the machine | ||
| 33 | /// </summary> | ||
| 34 | /// <param name="groupName">group name to delete</param> | ||
| 35 | /// <remarks>Has to be run as an Admin</remarks> | ||
| 36 | public static void DeleteLocalGroup(string groupName) | ||
| 37 | { | ||
| 38 | GroupPrincipal newGroup = GetGroup(String.Empty, groupName); | ||
| 39 | if (null != newGroup) | ||
| 40 | { | ||
| 41 | newGroup.Delete(); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | /// <summary> | ||
| 46 | /// Verifies that a group exists or not | ||
| 47 | /// </summary> | ||
| 48 | /// <param name="domainName">domain name for the group, empty for local groups</param> | ||
| 49 | /// <param name="groupName">the group name</param> | ||
| 50 | public static bool GroupExists(string domainName, string groupName) | ||
| 51 | { | ||
| 52 | GroupPrincipal group = GetGroup(domainName, groupName); | ||
| 53 | |||
| 54 | return null != group; | ||
| 55 | } | ||
| 56 | |||
| 57 | /// <summary> | ||
| 58 | /// Sets the group comment for a given group | ||
| 59 | /// </summary> | ||
| 60 | /// <param name="domainName">domain name for the group, empty for local users</param> | ||
| 61 | /// <param name="groupName">the group name</param> | ||
| 62 | /// <param name="comment">comment to be set for the group</param> | ||
| 63 | public static void SetGroupComment(string domainName, string groupName, string comment) | ||
| 64 | { | ||
| 65 | GroupPrincipal group = GetGroup(domainName, groupName); | ||
| 66 | |||
| 67 | Assert.False(null == group, String.Format("Group '{0}' was not found under domain '{1}'.", groupName, domainName)); | ||
| 68 | |||
| 69 | var directoryEntry = group.GetUnderlyingObject() as DirectoryEntry; | ||
| 70 | Assert.False(null == directoryEntry); | ||
| 71 | directoryEntry.Properties["Description"].Value = comment; | ||
| 72 | group.Save(); | ||
| 73 | } | ||
| 74 | |||
| 75 | /// <summary> | ||
| 76 | /// Adds the specified group to the specified local group | ||
| 77 | /// </summary> | ||
| 78 | /// <param name="memberName">Member to add</param> | ||
| 79 | /// <param name="groupName">Group to add too</param> | ||
| 80 | public static void AddGroupToGroup(string memberName, string groupName) | ||
| 81 | { | ||
| 82 | DirectoryEntry localMachine; | ||
| 83 | DirectoryEntry localGroup; | ||
| 84 | |||
| 85 | localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName.ToString()); | ||
| 86 | localGroup = localMachine.Children.Find(groupName, "group"); | ||
| 87 | Assert.False(null == localGroup, String.Format("Group '{0}' was not found.", groupName)); | ||
| 88 | DirectoryEntry group = FindActiveDirectoryGroup(memberName); | ||
| 89 | localGroup.Invoke("Add", new object[] { group.Path.ToString() }); | ||
| 90 | } | ||
| 91 | |||
| 92 | /// <summary> | ||
| 93 | /// Find the specified group in AD | ||
| 94 | /// </summary> | ||
| 95 | /// <param name="groupName">group name to lookup</param> | ||
| 96 | /// <returns>DirectoryEntry of the group</returns> | ||
| 97 | private static DirectoryEntry FindActiveDirectoryGroup(string groupName) | ||
| 98 | { | ||
| 99 | var mLocalMachine = new DirectoryEntry("WinNT://" + Environment.MachineName.ToString()); | ||
| 100 | var mLocalEntries = mLocalMachine.Children; | ||
| 101 | |||
| 102 | var theGroup = mLocalEntries.Find(groupName); | ||
| 103 | return theGroup; | ||
| 104 | } | ||
| 105 | |||
| 106 | /// <summary> | ||
| 107 | /// Verifies the group comment for a given group | ||
| 108 | /// </summary> | ||
| 109 | /// <param name="domainName">domain name for the group, empty for local users</param> | ||
| 110 | /// <param name="groupName">the group name</param> | ||
| 111 | /// <param name="comment">the comment to be verified</param> | ||
| 112 | public static void VerifyGroupComment(string domainName, string groupName, string comment) | ||
| 113 | { | ||
| 114 | GroupPrincipal group = GetGroup(domainName, groupName); | ||
| 115 | |||
| 116 | Assert.False(null == group, String.Format("Group '{0}' was not found under domain '{1}'.", groupName, domainName)); | ||
| 117 | |||
| 118 | var directoryEntry = group.GetUnderlyingObject() as DirectoryEntry; | ||
| 119 | Assert.False(null == directoryEntry); | ||
| 120 | Assert.True(comment == (string)(directoryEntry.Properties["Description"].Value)); | ||
| 121 | } | ||
| 122 | |||
| 123 | /// <summary> | ||
| 124 | /// Verify that a given group is member of a local group | ||
| 125 | /// </summary> | ||
| 126 | /// <param name="domainName">domain name for the group, empty for local groups</param> | ||
| 127 | /// <param name="memberName">the member name</param> | ||
| 128 | /// <param name="groupNames">list of groups to check for membership</param> | ||
| 129 | public static void VerifyIsMemberOf(string domainName, string memberName, params string[] groupNames) | ||
| 130 | { | ||
| 131 | IsMemberOf(domainName, memberName, true, groupNames); | ||
| 132 | } | ||
| 133 | |||
| 134 | /// <summary> | ||
| 135 | /// Verify that a given group is NOT member of a local group | ||
| 136 | /// </summary> | ||
| 137 | /// <param name="domainName">domain name for the group, empty for local groups</param> | ||
| 138 | /// <param name="memberName">the member name</param> | ||
| 139 | /// <param name="groupNames">list of groups to check for membership</param> | ||
| 140 | public static void VerifyIsNotMemberOf(string domainName, string memberName, params string[] groupNames) | ||
| 141 | { | ||
| 142 | IsMemberOf(domainName, memberName, false, groupNames); | ||
| 143 | } | ||
| 144 | |||
| 145 | /// <summary> | ||
| 146 | /// Verify that a given user is member of a local group | ||
| 147 | /// </summary> | ||
| 148 | /// <param name="domainName">domain name for the group, empty for local groups</param> | ||
| 149 | /// <param name="memberName">the member name</param> | ||
| 150 | /// <param name="shouldBeMember">whether the group is expected to be a member of the groups or not</param> | ||
| 151 | /// <param name="groupNames">list of groups to check for membership</param> | ||
| 152 | private static void IsMemberOf(string domainName, string memberName, bool shouldBeMember, params string[] groupNames) | ||
| 153 | { | ||
| 154 | GroupPrincipal group = GetGroup(domainName, memberName); | ||
| 155 | Assert.False(null == group, String.Format("Group '{0}' was not found under domain '{1}'.", memberName, domainName)); | ||
| 156 | |||
| 157 | bool missedAGroup = false; | ||
| 158 | string message = String.Empty; | ||
| 159 | foreach (string groupName in groupNames) | ||
| 160 | { | ||
| 161 | try | ||
| 162 | { | ||
| 163 | bool found = group.IsMemberOf(new PrincipalContext(ContextType.Machine), IdentityType.Name, groupName); | ||
| 164 | if (found != shouldBeMember) | ||
| 165 | { | ||
| 166 | missedAGroup = true; | ||
| 167 | message += String.Format("Group '{0}/{1}' is {2} a member of local group '{3}'. \r\n", domainName, memberName, found ? String.Empty : "NOT", groupName); | ||
| 168 | } | ||
| 169 | } | ||
| 170 | catch (System.DirectoryServices.AccountManagement.PrincipalOperationException) | ||
| 171 | { | ||
| 172 | missedAGroup = true; | ||
| 173 | message += String.Format("Local group '{0}' was not found. \r\n", groupName); | ||
| 174 | } | ||
| 175 | } | ||
| 176 | Assert.False(missedAGroup, message); | ||
| 177 | } | ||
| 178 | |||
| 179 | /// <summary> | ||
| 180 | /// Returns the GroupPrincipal object for a given group | ||
| 181 | /// </summary> | ||
| 182 | /// <param name="domainName">Domain name to look under, if Empty the LocalMachine is assumed as the domain</param> | ||
| 183 | /// <param name="groupName"></param> | ||
| 184 | /// <returns>UserPrincipal Object for the group if found, or null other wise</returns> | ||
| 185 | private static GroupPrincipal GetGroup(string domainName, string groupName) | ||
| 186 | { | ||
| 187 | if (String.IsNullOrEmpty(domainName)) | ||
| 188 | { | ||
| 189 | return GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Machine), IdentityType.Name, groupName); | ||
| 190 | } | ||
| 191 | else | ||
| 192 | { | ||
| 193 | return GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Domain,domainName), IdentityType.Name, groupName); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | } | ||
| 197 | } | ||
| 198 | |||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductA/ProductA.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductA/ProductA.wixproj new file mode 100644 index 00000000..3895b853 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductA/ProductA.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>{A3E0B539-63F9-4B43-9E34-F33AE1C6E06D}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> \ No newline at end of file | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductA/product.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductA/product.wxs new file mode 100644 index 00000000..e3c143e6 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductA/product.wxs | |||
| @@ -0,0 +1,25 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | |||
| 10 | <Property Id="TEMPDOMAIN" Secure="yes" /> | ||
| 11 | <Property Id="TEMPGROUPNAME" Secure="yes" /> | ||
| 12 | </Fragment> | ||
| 13 | |||
| 14 | <Fragment> | ||
| 15 | <Component Id="Component1" Guid="09624A9A-4BBC-4126-BBF9-0713C5217DB1" Directory="INSTALLFOLDER"> | ||
| 16 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 17 | |||
| 18 | <util:Group Id="TEST_GROUP1" Name="testName1" Comment="Group1" CreateGroup="yes" RemoveOnUninstall="yes" /> | ||
| 19 | |||
| 20 | <util:Group Id="TEST_GROUP2" Name="testName2" Comment="Group2" RemoveOnUninstall="no" UpdateIfExists="yes" /> | ||
| 21 | |||
| 22 | <util:Group Id="TEST_GROUP3" Name="testName3" Comment="Group3" CreateGroup="no" /> | ||
| 23 | </Component> | ||
| 24 | </Fragment> | ||
| 25 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductAddCommentToExistingGroup/ProductAddCommentToExistingGroup.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductAddCommentToExistingGroup/ProductAddCommentToExistingGroup.wixproj new file mode 100644 index 00000000..5938e525 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductAddCommentToExistingGroup/ProductAddCommentToExistingGroup.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>{B33D3140-4AA5-469D-9DEE-AAF8F0C626DA}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductAddCommentToExistingGroup/product.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductAddCommentToExistingGroup/product.wxs new file mode 100644 index 00000000..e0170746 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductAddCommentToExistingGroup/product.wxs | |||
| @@ -0,0 +1,23 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | |||
| 11 | <Fragment> | ||
| 12 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 13 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 14 | |||
| 15 | <util:Group Id="TEST_GROUP1" | ||
| 16 | Name="testName1" | ||
| 17 | CreateGroup="yes" | ||
| 18 | UpdateIfExists="yes" | ||
| 19 | RemoveOnUninstall="yes" | ||
| 20 | Comment="testComment1"/> | ||
| 21 | </Component> | ||
| 22 | </Fragment> | ||
| 23 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentDelete/ProductCommentDelete.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentDelete/ProductCommentDelete.wixproj new file mode 100644 index 00000000..63bb2370 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentDelete/ProductCommentDelete.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>{9E4C301E-5F36-4A86-85BE-776E067D929D}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentDelete/product.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentDelete/product.wxs new file mode 100644 index 00000000..d1824890 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentDelete/product.wxs | |||
| @@ -0,0 +1,18 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | |||
| 11 | <Fragment> | ||
| 12 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 13 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 14 | |||
| 15 | <util:Group Id="TEST_GROUP1" Name="testName1" UpdateIfExists="yes" RemoveOnUninstall="yes" RemoveComment="yes"/> | ||
| 16 | </Component> | ||
| 17 | </Fragment> | ||
| 18 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/ProductCommentFail.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/ProductCommentFail.wixproj new file mode 100644 index 00000000..66f308ae --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/ProductCommentFail.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>{85F698E0-F542-4CB4-80A1-6630D2DEB647}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/product_fail.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/product_fail.wxs new file mode 100644 index 00000000..29b908da --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/product_fail.wxs | |||
| @@ -0,0 +1,22 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | |||
| 10 | <InstallExecuteSequence> | ||
| 11 | <Custom Action="CaFail" After="Wix4ConfigureGroups_X86" /> | ||
| 12 | </InstallExecuteSequence> | ||
| 13 | </Fragment> | ||
| 14 | |||
| 15 | <Fragment> | ||
| 16 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 17 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 18 | |||
| 19 | <util:Group Id="TEST_GROUP1" Name="testName1" CreateGroup="yes" RemoveOnUninstall="yes" Comment="testComment1"/> | ||
| 20 | </Component> | ||
| 21 | </Fragment> | ||
| 22 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/ProductFail.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/ProductFail.wixproj new file mode 100644 index 00000000..e2fe3aa8 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/ProductFail.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>{91D27DAC-04C1-4160-914E-343676D36CAA}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> \ No newline at end of file | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/product_fail.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/product_fail.wxs new file mode 100644 index 00000000..fb35bc1e --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/product_fail.wxs | |||
| @@ -0,0 +1,29 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | |||
| 10 | <Property Id="TEMPDOMAIN" Secure="yes" /> | ||
| 11 | <Property Id="TEMPUSERNAME" Secure="yes" /> | ||
| 12 | |||
| 13 | <InstallExecuteSequence> | ||
| 14 | <Custom Action="CaFail" After="Wix4ConfigureGroups_X86" /> | ||
| 15 | </InstallExecuteSequence> | ||
| 16 | </Fragment> | ||
| 17 | |||
| 18 | <Fragment> | ||
| 19 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 20 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 21 | |||
| 22 | <util:Group Id="TEST_GROUP1" Name="testName1" /> | ||
| 23 | |||
| 24 | <util:Group Id="TEST_GROUP2" Name="testName2" RemoveOnUninstall="no" UpdateIfExists="yes" /> | ||
| 25 | |||
| 26 | <util:Group Id="TEST_GROUP3" Name="testName3" CreateGroup="no" /> | ||
| 27 | </Component> | ||
| 28 | </Fragment> | ||
| 29 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductFailIfExists/FailIfExists.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFailIfExists/FailIfExists.wxs new file mode 100644 index 00000000..00f8e12d --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFailIfExists/FailIfExists.wxs | |||
| @@ -0,0 +1,18 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | |||
| 11 | <Fragment> | ||
| 12 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 13 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 14 | |||
| 15 | <util:Group Id="TEST_USER4" Name="existinggroup" FailIfExists="yes" RemoveOnUninstall="yes" /> | ||
| 16 | </Component> | ||
| 17 | </Fragment> | ||
| 18 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductFailIfExists/ProductFailIfExists.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFailIfExists/ProductFailIfExists.wixproj new file mode 100644 index 00000000..9e1a836f --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFailIfExists/ProductFailIfExists.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>{BC803822-929E-47DA-AB3A-3A62EEEA2BFB}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> \ No newline at end of file | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/ProductNestedGroups.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/ProductNestedGroups.wixproj new file mode 100644 index 00000000..3b2e3942 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/ProductNestedGroups.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>{8B6C2900-44C4-42C9-879F-82F551B10C15}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/product.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/product.wxs new file mode 100644 index 00000000..191d605c --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/product.wxs | |||
| @@ -0,0 +1,33 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | |||
| 10 | <Property Id="TEMPDOMAIN" Secure="yes" /> | ||
| 11 | <Property Id="TEMPGROUPNAME" Secure="yes" /> | ||
| 12 | </Fragment> | ||
| 13 | |||
| 14 | <Fragment> | ||
| 15 | <util:Group Id="ADMIN" Name="Administrators" > | ||
| 16 | <util:GroupRef Id="TEST_GROUP1" /> | ||
| 17 | <util:GroupRef Id="TEST_GROUP2" /> | ||
| 18 | </util:Group> | ||
| 19 | <util:Group Id="POWER_USERS" Name="Power Users" > | ||
| 20 | <util:GroupRef Id="TEST_GROUP1" /> | ||
| 21 | </util:Group> | ||
| 22 | |||
| 23 | <Component Id="Component1" Guid="09624A9A-4BBC-4126-BBF9-0713C5217DB1" Directory="INSTALLFOLDER"> | ||
| 24 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 25 | |||
| 26 | <util:Group Id="TEST_GROUP1" Name="testName1" Comment="Group1" CreateGroup="yes" RemoveOnUninstall="yes" /> | ||
| 27 | |||
| 28 | <util:Group Id="TEST_GROUP2" Name="testName2" Comment="Group2" RemoveOnUninstall="no" UpdateIfExists="yes" /> | ||
| 29 | |||
| 30 | <util:Group Id="TEST_GROUP3" Name="testName3" Comment="Group3" /> | ||
| 31 | </Component> | ||
| 32 | </Fragment> | ||
| 33 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNewGroupWithComment/ProductNewGroupWithComment.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNewGroupWithComment/ProductNewGroupWithComment.wixproj new file mode 100644 index 00000000..aeac903a --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNewGroupWithComment/ProductNewGroupWithComment.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>{549E1829-BBDE-42E1-968A-BEB8FC12BFC7}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNewGroupWithComment/product.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNewGroupWithComment/product.wxs new file mode 100644 index 00000000..2d012b23 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNewGroupWithComment/product.wxs | |||
| @@ -0,0 +1,23 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | |||
| 11 | <Fragment> | ||
| 12 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 13 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 14 | <util:Group | ||
| 15 | Id="TEST_GROUP1" | ||
| 16 | Name="testName1" | ||
| 17 | CreateGroup="yes" | ||
| 18 | UpdateIfExists="yes" | ||
| 19 | RemoveOnUninstall="yes" | ||
| 20 | Comment="testComment1" /> | ||
| 21 | </Component> | ||
| 22 | </Fragment> | ||
| 23 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNonVitalGroup/NonVitalUserGroup.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNonVitalGroup/NonVitalUserGroup.wxs new file mode 100644 index 00000000..a834c76b --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNonVitalGroup/NonVitalUserGroup.wxs | |||
| @@ -0,0 +1,19 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | |||
| 11 | <Fragment> | ||
| 12 | |||
| 13 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 14 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 15 | |||
| 16 | <util:Group Id="CurrentGroup" Name="[LogonUser]" Domain="[%USERDOMAIN]" RemoveOnUninstall="no" Vital="no" /> | ||
| 17 | </Component> | ||
| 18 | </Fragment> | ||
| 19 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNonVitalGroup/ProductNonVitalUserGroup.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNonVitalGroup/ProductNonVitalUserGroup.wixproj new file mode 100644 index 00000000..8734224d --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNonVitalGroup/ProductNonVitalUserGroup.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>{455C8D4F-6D59-405C-AD51-0ACC7FB91A26}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> \ No newline at end of file | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductRestrictedDomain/ProductRestrictedDomain.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductRestrictedDomain/ProductRestrictedDomain.wixproj new file mode 100644 index 00000000..e4a01a3a --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductRestrictedDomain/ProductRestrictedDomain.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>{50CF526C-A862-4327-9EA3-C96AAB6FABCE}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> \ No newline at end of file | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductRestrictedDomain/RestrictedDomain.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductRestrictedDomain/RestrictedDomain.wxs new file mode 100644 index 00000000..edb3387c --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductRestrictedDomain/RestrictedDomain.wxs | |||
| @@ -0,0 +1,20 @@ | |||
| 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 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 5 | <Fragment> | ||
| 6 | <ComponentGroup Id="ProductComponents"> | ||
| 7 | <ComponentRef Id="Component1" /> | ||
| 8 | </ComponentGroup> | ||
| 9 | |||
| 10 | <Property Id="TEMPDOMAIN" Secure="yes" /> | ||
| 11 | </Fragment> | ||
| 12 | |||
| 13 | <Fragment> | ||
| 14 | <Component Id="Component1" Guid="00030829-0000-0000-C000-000000000046" Directory="INSTALLFOLDER"> | ||
| 15 | <File Source="$(sys.SOURCEFILEPATH)" KeyPath="yes" /> | ||
| 16 | |||
| 17 | <util:Group Id="TEST_GROUP_test" Name="testName1" Domain="[TEMPDOMAIN]" /> | ||
| 18 | </Component> | ||
| 19 | </Fragment> | ||
| 20 | </Wix> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductWithCommandLineParameters/ProductWithCommandLineParameters.wixproj b/src/test/msi/TestData/UtilExtensionGroupTests/ProductWithCommandLineParameters/ProductWithCommandLineParameters.wixproj new file mode 100644 index 00000000..93a56216 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductWithCommandLineParameters/ProductWithCommandLineParameters.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>{79F2CB65-1E71-42EB-AA30-51BD70C29B23}</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.Util.wixext" /> | ||
| 12 | </ItemGroup> | ||
| 13 | </Project> | ||
diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductWithCommandLineParameters/ProductWithCommandLineParameters.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductWithCommandLineParameters/ProductWithCommandLineParameters.wxs new file mode 100644 index 00000000..059ecee8 --- /dev/null +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductWithCommandLineParameters/ProductWithCommandLineParameters.wxs | |||
| @@ -0,0 +1,19 @@ | |||
| 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 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"> | ||
| 3 | <Fragment> | ||
| 4 | <ComponentGroup Id="ProductComponents"> | ||
| 5 | <ComponentRef Id="Component1" /> | ||
| 6 | </ComponentGroup> | ||
| 7 | </Fragment> | ||
| 8 | |||
| 9 | <Fragment> | ||
| 10 | <Component Id="Component1" | ||
| 11 | Guid="1FDC6C4D-7741-4BF1-A4F0-4231879CEC45" | ||
| 12 | Directory="INSTALLFOLDER"> | ||
| 13 | <util:Group Id="TEST_GROUP1" | ||
| 14 | Name="[TESTPARAMETER1]" | ||
| 15 | CreateGroup="yes" | ||
| 16 | RemoveOnUninstall="yes" /> | ||
| 17 | </Component> | ||
| 18 | </Fragment> | ||
| 19 | </Wix> | ||
diff --git a/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs new file mode 100644 index 00000000..796c4ecd --- /dev/null +++ b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs | |||
| @@ -0,0 +1,271 @@ | |||
| 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.MsiE2E | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using WixTestTools; | ||
| 7 | using Xunit; | ||
| 8 | using Xunit.Abstractions; | ||
| 9 | |||
| 10 | public class UtilExtensionGroupTests : MsiE2ETests | ||
| 11 | { | ||
| 12 | public UtilExtensionGroupTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } | ||
| 13 | |||
| 14 | // Verify that the users specified in the authoring are created as expected. | ||
| 15 | [RuntimeFact] | ||
| 16 | public void CanInstallAndUninstallGroups() | ||
| 17 | { | ||
| 18 | UserGroupVerifier.CreateLocalGroup("testName3"); | ||
| 19 | var productA = this.CreatePackageInstaller("ProductA"); | ||
| 20 | |||
| 21 | productA.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 22 | |||
| 23 | // Validate New User Information. | ||
| 24 | Assert.True(UserGroupVerifier.GroupExists(String.Empty, "testName1"), String.Format("Group '{0}' was not created on Install", "testName1")); | ||
| 25 | Assert.True(UserGroupVerifier.GroupExists(String.Empty, "testName2"), String.Format("Group '{0}' was not created on Install", "testName2")); | ||
| 26 | Assert.True(UserGroupVerifier.GroupExists(String.Empty, "testName3"), String.Format("Group '{0}' was not created on Install", "testName3")); | ||
| 27 | |||
| 28 | productA.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 29 | |||
| 30 | // Verify Users marked as RemoveOnUninstall were removed. | ||
| 31 | Assert.False(UserGroupVerifier.GroupExists(String.Empty, "testName1"), String.Format("Group '{0}' was not removed on Uninstall", "testName1")); | ||
| 32 | Assert.True(UserGroupVerifier.GroupExists(String.Empty, "testName2"), String.Format("Group '{0}' was removed on Uninstall", "testName2")); | ||
| 33 | |||
| 34 | // clean up | ||
| 35 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 36 | UserGroupVerifier.DeleteLocalGroup("testName2"); | ||
| 37 | UserGroupVerifier.DeleteLocalGroup("testName3"); | ||
| 38 | } | ||
| 39 | |||
| 40 | // Verify the rollback action reverts all Users changes. | ||
| 41 | [RuntimeFact] | ||
| 42 | public void CanRollbackGroups() | ||
| 43 | { | ||
| 44 | UserGroupVerifier.CreateLocalGroup("testName3"); | ||
| 45 | var productFail = this.CreatePackageInstaller("ProductFail"); | ||
| 46 | |||
| 47 | // make sure the user accounts are deleted before we start | ||
| 48 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 49 | UserGroupVerifier.DeleteLocalGroup("testName2"); | ||
| 50 | |||
| 51 | productFail.InstallProduct(MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE); | ||
| 52 | |||
| 53 | // Verify added Users were removed on rollback. | ||
| 54 | Assert.False(UserGroupVerifier.GroupExists(String.Empty, "testName1"), String.Format("Group '{0}' was not removed on Rollback", "testName1")); | ||
| 55 | Assert.False(UserGroupVerifier.GroupExists(String.Empty, "testName2"), String.Format("Group '{0}' was not removed on Rollback", "testName2")); | ||
| 56 | |||
| 57 | // clean up | ||
| 58 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 59 | UserGroupVerifier.DeleteLocalGroup("testName2"); | ||
| 60 | UserGroupVerifier.DeleteLocalGroup("testName3"); | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | // Verify that command-line parameters aer not blocked by repair switches. | ||
| 65 | // Original code signalled repair mode by using "-f ", which silently | ||
| 66 | // terminated the command-line parsing, ignoring any parameters that followed. | ||
| 67 | [RuntimeFact()] | ||
| 68 | public void CanRepairGroupsWithCommandLineParameters() | ||
| 69 | { | ||
| 70 | var arguments = new string[] | ||
| 71 | { | ||
| 72 | "TESTPARAMETER1=testName1", | ||
| 73 | }; | ||
| 74 | var productWithCommandLineParameters = this.CreatePackageInstaller("ProductWithCommandLineParameters"); | ||
| 75 | |||
| 76 | // Make sure that the user doesn't exist when we start the test. | ||
| 77 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 78 | |||
| 79 | // Install | ||
| 80 | productWithCommandLineParameters.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS, arguments); | ||
| 81 | |||
| 82 | // Repair | ||
| 83 | productWithCommandLineParameters.RepairProduct(MSIExec.MSIExecReturnCode.SUCCESS, arguments); | ||
| 84 | |||
| 85 | // Clean up | ||
| 86 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
| 90 | // Verify that the groups specified in the authoring are created as expected on repair. | ||
| 91 | [RuntimeFact()] | ||
| 92 | public void CanRepairGroups() | ||
| 93 | { | ||
| 94 | UserGroupVerifier.CreateLocalGroup("testName3"); | ||
| 95 | var productA = this.CreatePackageInstaller("ProductA"); | ||
| 96 | |||
| 97 | productA.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 98 | |||
| 99 | // Validate New User Information. | ||
| 100 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 101 | |||
| 102 | productA.RepairProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 103 | |||
| 104 | // Validate New User Information. | ||
| 105 | Assert.True(UserGroupVerifier.GroupExists(String.Empty, "testName1"), String.Format("User '{0}' was not installed on Repair", "testName1")); | ||
| 106 | Assert.True(UserGroupVerifier.GroupExists(String.Empty, "testName2"), String.Format("User '{0}' was not installed after Repair", "testName2")); | ||
| 107 | |||
| 108 | productA.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 109 | |||
| 110 | // Verify Users marked as RemoveOnUninstall were removed. | ||
| 111 | Assert.False(UserGroupVerifier.GroupExists(String.Empty, "testName1"), String.Format("User '{0}' was not removed on Uninstall", "testName1")); | ||
| 112 | Assert.True(UserGroupVerifier.GroupExists(String.Empty, "testName2"), String.Format("User '{0}' was removed on Uninstall", "testName2")); | ||
| 113 | |||
| 114 | // clean up | ||
| 115 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 116 | UserGroupVerifier.DeleteLocalGroup("testName2"); | ||
| 117 | UserGroupVerifier.DeleteLocalGroup("testName3"); | ||
| 118 | } | ||
| 119 | |||
| 120 | // Verify that Installation fails if FailIfExists is set. | ||
| 121 | [RuntimeFact] | ||
| 122 | public void FailsIfGroupExists() | ||
| 123 | { | ||
| 124 | var productFailIfExists = this.CreatePackageInstaller("ProductFailIfExists"); | ||
| 125 | |||
| 126 | // Create 'existinggroup' | ||
| 127 | UserGroupVerifier.CreateLocalGroup("existinggroup"); | ||
| 128 | |||
| 129 | try | ||
| 130 | { | ||
| 131 | productFailIfExists.InstallProduct(MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE); | ||
| 132 | |||
| 133 | // Verify User still exists. | ||
| 134 | bool userExists = UserGroupVerifier.GroupExists(String.Empty, "existinggroup"); | ||
| 135 | |||
| 136 | Assert.True(userExists, String.Format("Group '{0}' was removed on Rollback", "existinggroup")); | ||
| 137 | } | ||
| 138 | finally | ||
| 139 | { | ||
| 140 | // clean up | ||
| 141 | UserGroupVerifier.DeleteLocalGroup("existinggroup"); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | // Verify that a group cannot be created on a domain on which you don't have create user permission. | ||
| 146 | [RuntimeFact] | ||
| 147 | public void FailsIfRestrictedDomain() | ||
| 148 | { | ||
| 149 | var productRestrictedDomain = this.CreatePackageInstaller("ProductRestrictedDomain"); | ||
| 150 | |||
| 151 | string logFile = productRestrictedDomain.InstallProduct(MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "TEMPDOMAIN=DOESNOTEXIST"); | ||
| 152 | |||
| 153 | // Verify expected error message in the log file | ||
| 154 | Assert.True(LogVerifier.MessageInLogFile(logFile, "CreateGroup: Error 0x8007054b: failed to find Domain DOESNOTEXIST.")); | ||
| 155 | } | ||
| 156 | |||
| 157 | // Verify that a group can be created with a group comment | ||
| 158 | [RuntimeFact] | ||
| 159 | public void CanCreateNewGroupWithComment() | ||
| 160 | { | ||
| 161 | var productNewUserWithComment = this.CreatePackageInstaller("ProductNewGroupWithComment"); | ||
| 162 | |||
| 163 | productNewUserWithComment.InstallProduct(); | ||
| 164 | UserGroupVerifier.VerifyGroupComment(String.Empty, "testName1", "testComment1"); | ||
| 165 | |||
| 166 | // clean up | ||
| 167 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 168 | } | ||
| 169 | |||
| 170 | // Verify that a comment can be added to an existing group | ||
| 171 | [RuntimeFact] | ||
| 172 | public void CanAddCommentToExistingGroup() | ||
| 173 | { | ||
| 174 | UserGroupVerifier.CreateLocalGroup("testName1"); | ||
| 175 | var productAddCommentToExistingUser = this.CreatePackageInstaller("ProductAddCommentToExistingGroup"); | ||
| 176 | |||
| 177 | productAddCommentToExistingUser.InstallProduct(); | ||
| 178 | |||
| 179 | UserGroupVerifier.VerifyGroupComment(String.Empty, "testName1", "testComment1"); | ||
| 180 | |||
| 181 | // clean up | ||
| 182 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 183 | } | ||
| 184 | |||
| 185 | // Verify that a comment can be repaired for a new group | ||
| 186 | [RuntimeFact] | ||
| 187 | public void CanRepairCommentOfNewGroup() | ||
| 188 | { | ||
| 189 | var productNewUserWithComment = this.CreatePackageInstaller("ProductNewGroupWithComment"); | ||
| 190 | |||
| 191 | productNewUserWithComment.InstallProduct(); | ||
| 192 | UserGroupVerifier.SetGroupComment(String.Empty, "testName1", ""); | ||
| 193 | |||
| 194 | productNewUserWithComment.RepairProduct(); | ||
| 195 | UserGroupVerifier.VerifyGroupComment(String.Empty, "testName1", "testComment1"); | ||
| 196 | |||
| 197 | // clean up | ||
| 198 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 199 | } | ||
| 200 | |||
| 201 | // Verify that a comment can be changed for an existing group | ||
| 202 | [RuntimeFact] | ||
| 203 | public void CanChangeCommentOfExistingGroup() | ||
| 204 | { | ||
| 205 | UserGroupVerifier.CreateLocalGroup("testName1"); | ||
| 206 | UserGroupVerifier.SetGroupComment(String.Empty, "testName1", "initialTestComment1"); | ||
| 207 | var productNewUserWithComment = this.CreatePackageInstaller("ProductNewGroupWithComment"); | ||
| 208 | |||
| 209 | productNewUserWithComment.InstallProduct(); | ||
| 210 | UserGroupVerifier.VerifyGroupComment(String.Empty, "testName1", "testComment1"); | ||
| 211 | |||
| 212 | // clean up | ||
| 213 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 214 | } | ||
| 215 | |||
| 216 | // Verify that a comment can be rolled back for an existing group | ||
| 217 | [RuntimeFact] | ||
| 218 | public void CanRollbackCommentOfExistingGroup() | ||
| 219 | { | ||
| 220 | UserGroupVerifier.CreateLocalGroup("testName1"); | ||
| 221 | UserGroupVerifier.SetGroupComment(String.Empty, "testName1", "initialTestComment1"); | ||
| 222 | var productCommentFail = this.CreatePackageInstaller("ProductCommentFail"); | ||
| 223 | |||
| 224 | productCommentFail.InstallProduct(MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE); | ||
| 225 | |||
| 226 | // Verify that comment change was rolled back. | ||
| 227 | UserGroupVerifier.VerifyGroupComment(String.Empty, "testName1", "initialTestComment1"); | ||
| 228 | |||
| 229 | // clean up | ||
| 230 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 231 | } | ||
| 232 | |||
| 233 | // Verify that a comment can be deleted for an existing group | ||
| 234 | [RuntimeFact] | ||
| 235 | public void CanDeleteCommentOfExistingGroup() | ||
| 236 | { | ||
| 237 | UserGroupVerifier.CreateLocalGroup("testName1"); | ||
| 238 | UserGroupVerifier.SetGroupComment(String.Empty, "testName1", "testComment1"); | ||
| 239 | var productCommentDelete = this.CreatePackageInstaller("ProductCommentDelete"); | ||
| 240 | |||
| 241 | productCommentDelete.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 242 | |||
| 243 | // Verify that comment was removed. | ||
| 244 | UserGroupVerifier.VerifyGroupComment(String.Empty, "testName1", ""); | ||
| 245 | |||
| 246 | // clean up | ||
| 247 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 248 | } | ||
| 249 | |||
| 250 | // Verify that a comment can be deleted for an existing group | ||
| 251 | [RuntimeFact] | ||
| 252 | public void CanNestGroups() | ||
| 253 | { | ||
| 254 | var productNestedGroups = this.CreatePackageInstaller("ProductNestedGroups"); | ||
| 255 | |||
| 256 | productNestedGroups.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); | ||
| 257 | |||
| 258 | // Verify group nested membership | ||
| 259 | UserGroupVerifier.VerifyIsMemberOf(String.Empty, "Administrators", new string[] { "testName1", "testName2" }); | ||
| 260 | UserGroupVerifier.VerifyIsMemberOf(String.Empty, "Power Users", new string[] { "testName1" }); | ||
| 261 | |||
| 262 | UserGroupVerifier.VerifyIsNotMemberOf(String.Empty, "Administrators", new string[] { "testName3" }); | ||
| 263 | UserGroupVerifier.VerifyIsNotMemberOf(String.Empty, "Power Users", new string[] { "testName2", "testName3" }); | ||
| 264 | |||
| 265 | // clean up | ||
| 266 | UserGroupVerifier.DeleteLocalGroup("testName1"); | ||
| 267 | UserGroupVerifier.DeleteLocalGroup("testName2"); | ||
| 268 | UserGroupVerifier.DeleteLocalGroup("testName3"); | ||
| 269 | } | ||
| 270 | } | ||
| 271 | } | ||
