diff --git a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs
index f73c87a29..02cec9e44 100644
--- a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs
+++ b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs
@@ -3,16 +3,21 @@
namespace WixTestTools
{
using System;
+ using System.DirectoryServices.ActiveDirectory;
using System.Security.Principal;
using WixInternal.TestSupport.XunitExtensions;
public class RuntimeFactAttribute : SkippableFactAttribute
{
const string RequiredEnvironmentVariableName = "RuntimeTestsEnabled";
+ const string RequiredDomainEnvironmentVariableName = "RuntimeDomainTestsEnabled";
public static bool RuntimeTestsEnabled { get; }
public static bool RunningAsAdministrator { get; }
+ public static bool RuntimeDomainTestsEnabled { get; }
+ public static bool RunningInDomain { get; }
+
static RuntimeFactAttribute()
{
using var identity = WindowsIdentity.GetCurrent();
@@ -21,6 +26,33 @@ static RuntimeFactAttribute()
var testsEnabledString = Environment.GetEnvironmentVariable(RequiredEnvironmentVariableName);
RuntimeTestsEnabled = Boolean.TryParse(testsEnabledString, out var testsEnabled) && testsEnabled;
+
+ RunningInDomain = false;
+ try
+ {
+ RunningInDomain = !String.IsNullOrEmpty(System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().Name);
+ }
+ catch (ActiveDirectoryObjectNotFoundException) { }
+
+ var domainTestsEnabledString = Environment.GetEnvironmentVariable(RequiredDomainEnvironmentVariableName);
+ RuntimeDomainTestsEnabled = Boolean.TryParse(domainTestsEnabledString, out var domainTestsEnabled) && domainTestsEnabled;
+ }
+
+ private bool _domainRequired;
+ public bool DomainRequired
+ {
+ get
+ {
+ return _domainRequired;
+ }
+ set
+ {
+ _domainRequired = value;
+ if (_domainRequired && String.IsNullOrEmpty(this.Skip) && (!RunningInDomain || !RuntimeDomainTestsEnabled))
+ {
+ this.Skip = $"These tests require the test host to be running as a domain member ({(RunningInDomain ? "passed" : "failed")}). These tests affect both MACHINE AND DOMAIN state. To accept the consequences, set the {RequiredDomainEnvironmentVariableName} environment variable to true ({(RuntimeDomainTestsEnabled ? "passed" : "failed")}).";
+ }
+ }
}
public RuntimeFactAttribute()
diff --git a/src/test/burn/WixTestTools/UserVerifier.cs b/src/test/burn/WixTestTools/UserVerifier.cs
index 871d3f7c7..c3dd72153 100644
--- a/src/test/burn/WixTestTools/UserVerifier.cs
+++ b/src/test/burn/WixTestTools/UserVerifier.cs
@@ -172,7 +172,7 @@ public static void VerifyUserInformation(string domainName, string userName, boo
Assert.False(null == user, String.Format("User '{0}' was not found under domain '{1}'.", userName, domainName));
Assert.True(passwordNeverExpires == user.PasswordNeverExpires, String.Format("Password Never Expires for user '{0}\\{1}' is: '{2}', expected: '{3}'.", domainName, userName, user.PasswordNeverExpires, passwordNeverExpires));
- Assert.True(disabled != user.Enabled, String.Format("Accound disabled for user '{0}\\{1}' is: '{2}', expected: '{3}'.", domainName, userName, !user.Enabled, disabled));
+ Assert.True(disabled != user.Enabled, String.Format("Account disabled for user '{0}\\{1}' is: '{2}', expected: '{3}'.", domainName, userName, !user.Enabled, disabled));
DateTime expirationDate = user.AccountExpirationDate.GetValueOrDefault();
bool accountExpired = expirationDate.ToLocalTime().CompareTo(DateTime.Now) <= 0;
diff --git a/src/test/msi/TestData/UtilExtensionUserTests/ProductDomain/ProductDomain.wixproj b/src/test/msi/TestData/UtilExtensionUserTests/ProductDomain/ProductDomain.wixproj
new file mode 100644
index 000000000..1477407a6
--- /dev/null
+++ b/src/test/msi/TestData/UtilExtensionUserTests/ProductDomain/ProductDomain.wixproj
@@ -0,0 +1,13 @@
+
+
+
+ {08806ED8-3CE7-4BC3-A319-3ACCE3AAE7DC}
+ true
+
+
+
+
+
+
+
+
diff --git a/src/test/msi/TestData/UtilExtensionUserTests/ProductDomain/product.wxs b/src/test/msi/TestData/UtilExtensionUserTests/ProductDomain/product.wxs
new file mode 100644
index 000000000..93df23518
--- /dev/null
+++ b/src/test/msi/TestData/UtilExtensionUserTests/ProductDomain/product.wxs
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs
index 30bc53e8f..8b4a0731f 100644
--- a/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs
+++ b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionUserTests.cs
@@ -74,7 +74,7 @@ public void CanRollbackUsers()
// Verify that command-line parameters aer 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()]
+ [RuntimeFact]
public void CanRepairUsersWithCommandLineParameters()
{
var arguments = new string[]
@@ -98,7 +98,7 @@ public void CanRepairUsersWithCommandLineParameters()
// Verify that the users specified in the authoring are created as expected on repair.
- [RuntimeFact()]
+ [RuntimeFact]
public void CanRepairUsers()
{
UserVerifier.CreateLocalUser("testName3", "test123!@#");
@@ -274,5 +274,25 @@ public void CanDeleteCommentOfExistingUser()
// clean up
UserVerifier.DeleteLocalUser("testName1");
}
+
+ // Verify that the users specified in the authoring are created as expected.
+ [RuntimeFact(DomainRequired = true)]
+ public void CanInstallAndUninstallDomainUsers()
+ {
+
+ var productDomain = this.CreatePackageInstaller("ProductDomain");
+
+ productDomain.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS);
+
+ // Validate New User Information.
+ UserVerifier.VerifyUserInformation("TESTDOMAIN", "testName1", true, false, true);
+ UserVerifier.VerifyUserIsMemberOf("TESTDOMAIN", "testName1", "Administrators", "TESTDOMAIN\\Domain Guests");
+ UserVerifier.VerifyUserComment("TESTDOMAIN", "testName1", "testComment1");
+
+ productDomain.UninstallProduct(MSIExec.MSIExecReturnCode.SUCCESS);
+
+ // Verify Users marked as RemoveOnUninstall were removed.
+ Assert.False(UserVerifier.UserExists("TESTDOMAIN", "testName1"), String.Format("User '{0}\\{1}' was not removed on Uninstall", "TESTDOMAIN", "testName1"));
+ }
}
}
diff --git a/src/test/msi/WixToolsetTest.MsiE2E/runtests.cmd b/src/test/msi/WixToolsetTest.MsiE2E/runtests.cmd
index a2e67c891..ed1d50b68 100644
--- a/src/test/msi/WixToolsetTest.MsiE2E/runtests.cmd
+++ b/src/test/msi/WixToolsetTest.MsiE2E/runtests.cmd
@@ -1,2 +1,3 @@
SET RuntimeTestsEnabled=true
+SET RuntimeDomainTestsEnabled=true
dotnet test WixToolsetTest.MsiE2E.dll -v normal --logger trx