Skip to content

Commit

Permalink
Add a few more checks on rollback of Util User.
Browse files Browse the repository at this point in the history
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
  • Loading branch information
bevanweiss committed Jul 14, 2024
1 parent 40df304 commit df67ec4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/test/burn/WixTestTools/UserVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public static class SIDStrings
/// <param name="userName"></param>
/// <param name="password"></param>
/// <remarks>Has to be run as an Admin</remarks>
public static void CreateLocalUser(string userName, string password)
public static void CreateLocalUser(string userName, string password, string comment = "")
{
DeleteLocalUser(userName);
UserPrincipal newUser = new UserPrincipal(new PrincipalContext(ContextType.Machine));
newUser.SetPassword(password);
newUser.Name = userName;
newUser.Description = String.Empty;
newUser.Description = comment;
newUser.UserCannotChangePassword = true;
newUser.PasswordNeverExpires = false;
newUser.Save();
Expand Down
9 changes: 7 additions & 2 deletions src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public void CanInstallAndUninstallUsers()
[RuntimeFact]
public void CanRollbackUsers()
{
UserVerifier.CreateLocalUser("testName3", "test123!@#");
UserVerifier.CreateLocalUser("testName3", "test123!@#", "User3 comment");
UserVerifier.AddUserToGroup("testName3", "Backup Operators");
var productFail = this.CreatePackageInstaller("ProductFail");

// make sure the user accounts are deleted before we start
Expand All @@ -63,6 +64,10 @@ public void CanRollbackUsers()

// Verify that user added to power users group is removed from power users group on rollback.
UserVerifier.VerifyUserIsNotMemberOf("", "testName3", "Power Users");
// but is not removed from Backup Operators
UserVerifier.VerifyUserIsMemberOf(string.Empty, "testName3", "Backup Operators");
// and has their original comment set back
UserVerifier.VerifyUserComment(string.Empty, "testName3", "User3 comment");

// clean up
UserVerifier.DeleteLocalUser("testName1");
Expand All @@ -71,7 +76,7 @@ public void CanRollbackUsers()
}


// Verify that command-line parameters aer not blocked by repair switches.
// Verify that command-line parameters are not blocked by repair switches.
// Original code signalled repair mode by using "-f ", which silently
// terminated the command-line parsing, ignoring any parameters that followed.
[RuntimeFact()]
Expand Down

0 comments on commit df67ec4

Please sign in to comment.