diff options
| author | Bevan Weiss <bevan.weiss@gmail.com> | 2024-08-04 21:13:44 +1000 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2025-02-11 23:14:49 -0800 |
| commit | 5b4a6538ee06988c75b717bd905197fb670e6142 (patch) | |
| tree | eb078854f258ebdabaf206282d56cbdcf87759ef /src/test/burn | |
| parent | 2c5bb89424b12de812498d568bc1aae2d4098e60 (diff) | |
| download | wix-5b4a6538ee06988c75b717bd905197fb670e6142.tar.gz wix-5b4a6538ee06988c75b717bd905197fb670e6142.tar.bz2 wix-5b4a6538ee06988c75b717bd905197fb670e6142.zip | |
Add/Remove Group Membership rollback handled.
Fixups to a few test cases.
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Diffstat (limited to 'src/test/burn')
| -rw-r--r-- | src/test/burn/WixTestTools/RuntimeFactAttribute.cs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs index 573a9de2..76004f26 100644 --- a/src/test/burn/WixTestTools/RuntimeFactAttribute.cs +++ b/src/test/burn/WixTestTools/RuntimeFactAttribute.cs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | namespace WixTestTools | 3 | namespace WixTestTools |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.DirectoryServices.ActiveDirectory; | ||
| 6 | using System.Security.Principal; | 7 | using System.Security.Principal; |
| 7 | using WixInternal.TestSupport.XunitExtensions; | 8 | using WixInternal.TestSupport.XunitExtensions; |
| 8 | using System.Runtime.InteropServices; | 9 | using System.Runtime.InteropServices; |
| @@ -10,10 +11,13 @@ namespace WixTestTools | |||
| 10 | public class RuntimeFactAttribute : SkippableFactAttribute | 11 | public class RuntimeFactAttribute : SkippableFactAttribute |
| 11 | { | 12 | { |
| 12 | const string RequiredEnvironmentVariableName = "RuntimeTestsEnabled"; | 13 | const string RequiredEnvironmentVariableName = "RuntimeTestsEnabled"; |
| 14 | const string RequiredDomainEnvironmentVariableName = "RuntimeDomainTestsEnabled"; | ||
| 13 | 15 | ||
| 14 | public static bool RuntimeTestsEnabled { get; } | 16 | public static bool RuntimeTestsEnabled { get; } |
| 17 | public static bool RuntimeDomainTestsEnabled { get; } | ||
| 15 | public static bool RunningAsAdministrator { get; } | 18 | public static bool RunningAsAdministrator { get; } |
| 16 | public static bool RunningOnWindowsServer { get; } | 19 | public static bool RunningOnWindowsServer { get; } |
| 20 | public static bool RunningInDomain { get; } | ||
| 17 | 21 | ||
| 18 | [DllImport("shlwapi.dll", SetLastError = true, EntryPoint = "#437")] | 22 | [DllImport("shlwapi.dll", SetLastError = true, EntryPoint = "#437")] |
| 19 | private static extern bool IsOS(int os); | 23 | private static extern bool IsOS(int os); |
| @@ -23,7 +27,6 @@ namespace WixTestTools | |||
| 23 | return IsOS(OS_ANYSERVER); | 27 | return IsOS(OS_ANYSERVER); |
| 24 | } | 28 | } |
| 25 | 29 | ||
| 26 | |||
| 27 | static RuntimeFactAttribute() | 30 | static RuntimeFactAttribute() |
| 28 | { | 31 | { |
| 29 | using var identity = WindowsIdentity.GetCurrent(); | 32 | using var identity = WindowsIdentity.GetCurrent(); |
| @@ -33,6 +36,33 @@ namespace WixTestTools | |||
| 33 | var testsEnabledString = Environment.GetEnvironmentVariable(RequiredEnvironmentVariableName); | 36 | var testsEnabledString = Environment.GetEnvironmentVariable(RequiredEnvironmentVariableName); |
| 34 | RuntimeTestsEnabled = Boolean.TryParse(testsEnabledString, out var testsEnabled) && testsEnabled; | 37 | RuntimeTestsEnabled = Boolean.TryParse(testsEnabledString, out var testsEnabled) && testsEnabled; |
| 35 | 38 | ||
| 39 | RunningInDomain = false; | ||
| 40 | try | ||
| 41 | { | ||
| 42 | RunningInDomain = !String.IsNullOrEmpty(System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().Name); | ||
| 43 | } | ||
| 44 | catch (ActiveDirectoryObjectNotFoundException) { } | ||
| 45 | |||
| 46 | var domainTestsEnabledString = Environment.GetEnvironmentVariable(RequiredDomainEnvironmentVariableName); | ||
| 47 | RuntimeDomainTestsEnabled = Boolean.TryParse(domainTestsEnabledString, out var domainTestsEnabled) && domainTestsEnabled; | ||
| 48 | } | ||
| 49 | |||
| 50 | private bool _domainRequired; | ||
| 51 | public bool DomainRequired | ||
| 52 | { | ||
| 53 | get | ||
| 54 | { | ||
| 55 | return _domainRequired; | ||
| 56 | } | ||
| 57 | set | ||
| 58 | { | ||
| 59 | _domainRequired = value; | ||
| 60 | if (_domainRequired && String.IsNullOrEmpty(this.Skip) && (!RunningInDomain || !RuntimeDomainTestsEnabled)) | ||
| 61 | { | ||
| 62 | 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")})."; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 36 | RunningOnWindowsServer = IsWindowsServer(); | 66 | RunningOnWindowsServer = IsWindowsServer(); |
| 37 | } | 67 | } |
| 38 | 68 | ||
