Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few more checks on rollback of Util User. #535

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading