aboutsummaryrefslogtreecommitdiff
path: root/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs')
-rw-r--r--src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs271
1 files changed, 271 insertions, 0 deletions
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
3namespace 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}