Author: spouliot
Date: 2006-11-17 15:33:16 -0500 (Fri, 17 Nov 2006)
New Revision: 68094

Modified:
   
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog
   
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509Cert20Test.cs
Log:
2006-11-17  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * X509Cert20Test.cs: Add test cases for Equals and Export.



Modified: 
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog
 2006-11-17 20:33:02 UTC (rev 68093)
+++ 
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/ChangeLog
 2006-11-17 20:33:16 UTC (rev 68094)
@@ -1,3 +1,7 @@
+2006-11-17  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * X509Cert20Test.cs: Add test cases for Equals and Export.
+
 2006-11-13  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * X509Cert20Test.cs: Added test cases for importing PEM encoded

Modified: 
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509Cert20Test.cs
===================================================================
--- 
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509Cert20Test.cs
 2006-11-17 20:33:02 UTC (rev 68093)
+++ 
trunk/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509Cert20Test.cs
 2006-11-17 20:33:16 UTC (rev 68094)
@@ -33,6 +33,7 @@
 using System.IO;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
+using System.Security;
 using System.Security.Cryptography;
 using System.Security.Cryptography.X509Certificates;
 using System.Text;
@@ -203,6 +204,106 @@
                }
 
                [Test]
+               public void Equals_Empty_Source ()
+               {
+                       X509Certificate empty = new X509Certificate ();
+                       Assert.IsFalse (empty.Equals (null), "null");
+                       X509Certificate x = new X509Certificate (cert1);
+                       Assert.IsFalse (empty.Equals (x), "X509Certificate");
+                       Assert.IsFalse (empty.Equals ((object) x), "object");
+                       Assert.IsTrue (empty.Equals (empty), "empty");
+               }
+
+               [Test]
+               [ExpectedException (typeof (CryptographicException))]
+               public void Equals_Empty_Destination ()
+               {
+                       new X509Certificate (cert1).Equals (new X509Certificate 
());
+               }
+
+               [Test]
+               [ExpectedException (typeof (CryptographicException))]
+               public void Export_Authenticode ()
+               {
+                       new X509Certificate (cert1).Export 
(X509ContentType.Authenticode);
+               }
+
+               [Test]
+               public void Export_Cert ()
+               {
+                       X509Certificate cert = new X509Certificate (cert1);
+                       byte[] data = cert.Export (X509ContentType.Cert);
+                       Assert.AreEqual (data, cert1, "original");
+
+                       data = cert.Export (X509ContentType.Cert, (string)null);
+                       Assert.AreEqual (data, cert1, "original/string/null");
+
+                       data = cert.Export (X509ContentType.Cert, 
(SecureString) null);
+                       Assert.AreEqual (data, cert1, 
"original/SecureString/null");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Export_Pfx ()
+               {
+                       X509Certificate cert = new X509Certificate (cert1);
+                       byte[] data = cert.Export (X509ContentType.Pfx);
+                       // usable
+                       X509Certificate2 c = new X509Certificate2 (data);
+                       Assert.AreEqual (cert1, c.GetRawCertData (), "Equals");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Export_Pkcs12 ()
+               {
+                       X509Certificate cert = new X509Certificate (cert1);
+                       byte[] data = cert.Export (X509ContentType.Pkcs12);
+                       // usable
+                       X509Certificate2 c = new X509Certificate2 (data);
+                       Assert.AreEqual (cert1, c.GetRawCertData (), "Equals");
+               }
+
+               [Test]
+               [ExpectedException (typeof (CryptographicException))]
+               public void Export_Pkcs7 ()
+               {
+                       new X509Certificate (cert1).Export 
(X509ContentType.Pkcs7);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Export_SerializedCert ()
+               {
+                       X509Certificate cert = new X509Certificate (cert1);
+                       byte[] data = cert.Export 
(X509ContentType.SerializedCert);
+                       // usable
+                       X509Certificate2 c = new X509Certificate2 (data);
+                       Assert.AreEqual (cert1, c.GetRawCertData (), "Equals");
+               }
+
+               [Test]
+               [ExpectedException (typeof (CryptographicException))]
+               public void Export_SerializedStore ()
+               {
+                       new X509Certificate (cert1).Export 
(X509ContentType.SerializedStore);
+               }
+
+               [Test]
+               [ExpectedException (typeof (CryptographicException))]
+               public void Export_Unknown ()
+               {
+                       new X509Certificate (cert1).Export 
(X509ContentType.Unknown);
+               }
+
+               [Test]
+               [ExpectedException (typeof (CryptographicException))]
+               public void Export_Bad ()
+               {
+                       new X509Certificate (cert1).Export ((X509ContentType) 
Int32.MinValue);
+               }
+
+               [Test]
                public void UnrequiredPassword ()
                {
                        // MS permits to supply an unrequired password for an 
(unencrypted) DER certificate
@@ -641,9 +742,6 @@
                {
                        X509Certificate x = new X509Certificate ();
                        x.Import (farscape_pkcs7);
-                       // note: the certificate inside the PKCS7 structure is 
the same
-                       // as used in the base64 tests
-                       CheckBase64 (x);
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to