From 9cb321d8122d1bc9dc0c3bcbba4f4b9b8cf67138 Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Sun, 30 Jun 2024 11:52:25 +1000 Subject: [PATCH] Add a few more checks on rollback of Util User. Signed-off-by: Bevan Weiss --- src/test/burn/WixTestTools/UserVerifier.cs | 4 ++-- .../msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/burn/WixTestTools/UserVerifier.cs b/src/test/burn/WixTestTools/UserVerifier.cs index 51c6c31e5..d192a8b8f 100644 --- a/src/test/burn/WixTestTools/UserVerifier.cs +++ b/src/test/burn/WixTestTools/UserVerifier.cs @@ -43,13 +43,13 @@ public static class SIDStrings /// /// /// Has to be run as an Admin - 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(); diff --git a/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs index 30bc53e8f..08b7cee18 100644 --- a/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs +++ b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs @@ -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 @@ -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"); @@ -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()]