Add a few more checks on rollback of Util User.
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Bevan Weiss committed
Jun 30, 2024 at 11:52 UTC
85745284cd76858f8699190c53719607e0058712
2 files changed
+9
-4
src/test/burn/WixTestTools/UserVerifier.cs
+2
-2
@@ -43,13 +43,13 @@ namespace WixTestTools
43
/// <param name="userName"></param>
44
/// <param name="password"></param>
45
/// <remarks>Has to be run as an Admin</remarks>
46
- public static void CreateLocalUser(string userName, string password)
46
+ public static void CreateLocalUser(string userName, string password, string comment = "")
47
{
48
DeleteLocalUser(userName);
49
UserPrincipal newUser = new UserPrincipal(new PrincipalContext(ContextType.Machine));
50
newUser.SetPassword(password);
51
newUser.Name = userName;
52
- newUser.Description = String.Empty;
52
+ newUser.Description = comment;
53
newUser.UserCannotChangePassword = true;
54
newUser.PasswordNeverExpires = false;
55
newUser.Save();
src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs
+7
-2
@@ -48,7 +48,8 @@ namespace WixToolsetTest.MsiE2E
48
[RuntimeFact]
49
public void CanRollbackUsers()
50
{
51
- UserVerifier.CreateLocalUser("testName3", "test123!@#");
51
+ UserVerifier.CreateLocalUser("testName3", "test123!@#", "User3 comment");
52
+ UserVerifier.AddUserToGroup("testName3", "Backup Operators");
53
var productFail = this.CreatePackageInstaller("ProductFail");
54
55
// make sure the user accounts are deleted before we start
@@ -63,6 +64,10 @@ namespace WixToolsetTest.MsiE2E
64
65
// Verify that user added to power users group is removed from power users group on rollback.
66
UserVerifier.VerifyUserIsNotMemberOf("", "testName3", "Power Users");
67
+ // but is not removed from Backup Operators
68
+ UserVerifier.VerifyUserIsMemberOf(string.Empty, "testName3", "Backup Operators");
69
+ // and has their original comment set back
70
+ UserVerifier.VerifyUserComment(string.Empty, "testName3", "User3 comment");
71
72
// clean up
73
UserVerifier.DeleteLocalUser("testName1");
@@ -71,7 +76,7 @@ namespace WixToolsetTest.MsiE2E
76
}
77
78
74
- // Verify that command-line parameters aer not blocked by repair switches.
79
+ // Verify that command-line parameters are not blocked by repair switches.
80
// Original code signalled repair mode by using "-f ", which silently
81
// terminated the command-line parsing, ignoring any parameters that followed.
82
[RuntimeFact()]