Disable EncryptDecrypt_Read() test on the Home editions of Windows (dotnet/corefx...
authorJulius Hardt <julius.moritz@live.de>
Sun, 23 Sep 2018 20:32:59 +0000 (22:32 +0200)
committerViktor Hofer <viktor.hofer@microsoft.com>
Sun, 23 Sep 2018 20:32:59 +0000 (22:32 +0200)
* Disable System.IO.Tests.EncryptDecrypt.EncryptDecrypt_Read() on the Home editions of Windows

* Add a comment explaining why we skip the test on home editions

Commit migrated from https://github.com/dotnet/corefx/commit/4f7690ad97ea1772433fcfeafc4b0c26f0fb80a2

src/libraries/CoreFx.Private.TestUtilities/ref/CoreFx.Private.TestUtilities.cs
src/libraries/CoreFx.Private.TestUtilities/src/System/PlatformDetection.Unix.cs
src/libraries/CoreFx.Private.TestUtilities/src/System/PlatformDetection.Windows.cs
src/libraries/CoreFx.Private.TestUtilities/src/System/PlatformDetection.cs
src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs

index ab4b742..28114ba 100644 (file)
@@ -72,6 +72,7 @@ namespace System
         public static bool IsNotNetNativeRunningAsConsoleApp { get { throw null; } }
         public static bool IsNotOneCoreUAP { get { throw null; } }
         public static bool IsNotWindows8x { get { throw null; } }
+        public static bool IsNotWindowsHomeEdition { get { throw null; } }
         public static bool IsNotWindowsIoTCore { get { throw null; } }
         public static bool IsNotWindowsNanoServer { get { throw null; } }
         public static bool IsNotWindowsServerCore { get { throw null; } }
@@ -105,6 +106,7 @@ namespace System
         public static bool IsWindows7 { get { throw null; } }
         public static bool IsWindows8x { get { throw null; } }
         public static bool IsWindowsAndElevated { get { throw null; } }
+        public static bool IsWindowsHomeEdition { get { throw null; } }
         public static bool IsWindowsIoTCore { get { throw null; } }
         public static bool IsWindowsNanoServer { get { throw null; } }
         public static bool IsWindowsServerCore { get { throw null; } }
index a7f8b2a..db8abe1 100644 (file)
@@ -14,6 +14,7 @@ namespace System
     public static partial class PlatformDetection
     {
         public static bool IsWindowsIoTCore => false;
+        public static bool IsWindowsHomeEdition => false;
         public static bool IsWindows => false;
         public static bool IsWindows7 => false;
         public static bool IsWindows8x => false;
index 1c0f8b6..7d9bcbc 100644 (file)
@@ -70,6 +70,28 @@ namespace System
             }
         }
 
+        public static bool IsWindowsHomeEdition
+        {
+            get
+            {
+                int productType = GetWindowsProductType();
+                switch (productType)
+                {
+                    case PRODUCT_CORE:
+                    case PRODUCT_CORE_COUNTRYSPECIFIC:
+                    case PRODUCT_CORE_N:
+                    case PRODUCT_CORE_SINGLELANGUAGE:
+                    case PRODUCT_HOME_BASIC:
+                    case PRODUCT_HOME_BASIC_N:
+                    case PRODUCT_HOME_PREMIUM:
+                    case PRODUCT_HOME_PREMIUM_N:
+                        return true;
+                    default:
+                        return false;
+                }
+            }
+        }
+
         public static bool IsWindows => true;
         public static bool IsWindows7 => GetWindowsVersion() == 6 && GetWindowsMinorVersion() == 1;
         public static bool IsWindows8x => GetWindowsVersion() == 6 && (GetWindowsMinorVersion() == 2 || GetWindowsMinorVersion() == 3);
@@ -228,6 +250,14 @@ namespace System
 
         private const int PRODUCT_IOTUAP = 0x0000007B;
         private const int PRODUCT_IOTUAPCOMMERCIAL = 0x00000083;
+        private const int PRODUCT_CORE = 0x00000065;
+        private const int PRODUCT_CORE_COUNTRYSPECIFIC = 0x00000063;
+        private const int PRODUCT_CORE_N = 0x00000062;
+        private const int PRODUCT_CORE_SINGLELANGUAGE = 0x00000064;
+        private const int PRODUCT_HOME_BASIC = 0x00000002;
+        private const int PRODUCT_HOME_BASIC_N = 0x00000005;
+        private const int PRODUCT_HOME_PREMIUM = 0x00000003;
+        private const int PRODUCT_HOME_PREMIUM_N = 0x0000001A;
 
         [DllImport("kernel32.dll", SetLastError = false)]
         private static extern bool GetProductInfo(
index 563f1d7..ca04c1c 100644 (file)
@@ -31,6 +31,7 @@ namespace System
         public static bool IsNotWindowsNanoServer => !IsWindowsNanoServer;
         public static bool IsNotWindowsServerCore => !IsWindowsServerCore;
         public static bool IsNotWindowsIoTCore => !IsWindowsIoTCore;
+        public static bool IsNotWindowsHomeEdition => !IsWindowsHomeEdition;
         public static bool IsDrawingSupported => (IsNotWindowsNanoServer && IsNotWindowsIoTCore);
         public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm;
         public static bool IsNotArmProcess => !IsArmProcess;
index 4e5a5c1..4ce660f 100644 (file)
@@ -32,7 +32,9 @@ namespace System.IO.Tests
             Assert.Throws<PlatformNotSupportedException>(() => File.Decrypt(null));
         }
 
-        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
+        // On Windows Nano Server and Home Edition, file encryption with File.Encrypt(string path) throws an IOException
+        // because EFS (Encrypted File System), its underlying technology, is not available on these operating systems.
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotWindowsHomeEdition))]
         [SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "File encryption is not supported on this platform.")]
         [PlatformSpecific(TestPlatforms.Windows)]
         public static void EncryptDecrypt_Read()