Merge pull request #4621 from alexanderkyte/strdup_env
[mono.git] / mcs / class / corlib / Test / System.Security.Cryptography.X509Certificates / X509CapiTest.cs
index 304ddb6bcafd218f57d8b51b838074e69235dcf1..f49cf1ac3cf7686ca80449cf64ba50532100ce92 100644 (file)
@@ -8,7 +8,6 @@
 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 // Copyright 2011 Xamarin Inc (http://www.xamarin.com).
 //
-#if !TARGET_JVM
 using NUnit.Framework;
 
 using System;
@@ -73,6 +72,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
                        File.Delete("temp.b64");
                }
 
+#if !MOBILE && !MONOMAC
                public IntPtr GetHandleEx (byte[] certificate) 
                {
                        CertificateContext cc = new CertificateContext ();
@@ -104,11 +104,15 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
                }
 
                [Test]
-#if NET_2_1
-               [Ignore ("This constructor always throw a NotSupportedException under NET_2_1 and is useless without CryptoAPI (i.e. outside Windows)")]
+#if MOBILE || MONOMAC
+               [Ignore ("This constructor always throw a NotSupportedException under MOBILE and is useless without CryptoAPI (i.e. outside Windows)")]
 #endif
                public void ConstructorIntPtr ()
                {
+                       // This test uses a certificate format that only works
+                       if (PlatformID.Win32NT != Environment.OSVersion.Platform)
+                               return;
+
                        byte[] cert = { 0x30,0x82,0x01,0xFF,0x30,0x82,0x01,0x6C,0x02,0x05,0x02,0x72,0x00,0x06,0xE8,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,
                                0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x37,0x5A,0x17,0x0D,0x39,0x37,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x36,0x5A,0x30,0x61,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,
                                0x55,0x04,0x0A,0x13,0x0B,0x43,0x6F,0x6D,0x6D,0x65,0x72,0x63,0x65,0x4E,0x65,0x74,0x31,0x27,0x30,0x25,0x06,0x03,0x55,0x04,0x0B,0x13,0x1E,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x70,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x5F,0x00,0x30,0x5C,0x02,0x55,0x2D,0x58,0xE9,0xBF,0xF0,0x31,0xCD,0x79,0x06,0x50,0x5A,0xD5,0x9E,0x0E,0x2C,0xE6,0xC2,0xF7,0xF9,
@@ -131,17 +135,10 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
                        byte[] hash = { 0xD6,0x2F,0x48,0xD0,0x13,0xEE,0x7F,0xB5,0x8B,0x79,0x07,0x45,0x12,0x67,0x0D,0x9C,0x5B,0x3A,0x5D,0xA9 };
                        Assert.AreEqual (hash, x509.GetCertHash (), "GetCertHash");
                        Assert.AreEqual ("D62F48D013EE7FB58B79074512670D9C5B3A5DA9", x509.GetCertHashString (), "GetCertHashString");
-#if NET_2_0
                        DateTime from = DateTime.ParseExact (x509.GetEffectiveDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
                        Assert.AreEqual ("03/12/1996 18:38:47", from.ToString (), "GetEffectiveDateString");
                        DateTime until = DateTime.ParseExact (x509.GetExpirationDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
                        Assert.AreEqual ("03/12/1997 18:38:46", until.ToString (), "GetExpirationDateString");
-#else
-                       // fx 1.x has a bug where the returned dates were always in the Seattle time zone
-                       Assert.AreEqual ("03/12/1996 10:38:47", x509.GetEffectiveDateString (), "GetEffectiveDateString");
-                       Assert.AreEqual ("03/12/1997 10:38:46", x509.GetExpirationDateString (), "GetExpirationDateString");
-                       // which was making it easier to test the dates ;-)
-#endif
                        Assert.AreEqual ("X509", x509.GetFormat (), "GetFormat");
                        Assert.AreEqual (-701544240, x509.GetHashCode (), "GetHashCode");
                        Assert.AreEqual ("C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.GetIssuerName (), "GetIssuerName");
@@ -157,17 +154,12 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
                        Assert.AreEqual (ToString (cert), x509.GetRawCertDataString (), "GetRawCertDataString");
                        byte[] serial = { 0xE8,0x06,0x00,0x72,0x02 };
                        Assert.AreEqual (serial, x509.GetSerialNumber (), "GetSerialNumber");
-#if NET_2_0
                        Assert.AreEqual ("02720006E8", x509.GetSerialNumberString (), "GetSerialNumberString");
-#else
-                       Assert.AreEqual ("E806007202", x509.GetSerialNumberString (), "GetSerialNumberString");
-#endif
                }
+#endif
 
                [Test]
-#if NET_2_0
                [ExpectedException (typeof (ArgumentException))]
-#endif
                public void ConstructorIntPtrZero ()
                {
                        X509Certificate spc = new X509Certificate (IntPtr.Zero);
@@ -175,4 +167,3 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
                }
        }
 }
-#endif