Browse Source

2005-04-23 Sebastien Pouliot <[email protected]>

	* CmsRecipientTest.cs, CmsSignerTest.cs, EnvelopedCmsTest.cs,
	Pkcs9AttributeTest.cs, Pkcs9DocumentDescriptionTest.cs, 
	Pkcs9DocumentNameTest.cs, Pkcs9SigningTimeTest.cs, SignedCmsTest.cs:
	Adapted for class name changes in beta2 and re-activated some tests on
	Windows that were fixed in beta2.


svn path=/trunk/mcs/; revision=43483
Sebastien Pouliot 20 years ago
parent
commit
44c8858ab2

+ 8 - 0
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/ChangeLog

@@ -1,3 +1,11 @@
+2005-04-23  Sebastien Pouliot  <[email protected]>
+
+	* CmsRecipientTest.cs, CmsSignerTest.cs, EnvelopedCmsTest.cs,
+	Pkcs9AttributeTest.cs, Pkcs9DocumentDescriptionTest.cs, 
+	Pkcs9DocumentNameTest.cs, Pkcs9SigningTimeTest.cs, SignedCmsTest.cs:
+	Adapted for class name changes in beta2 and re-activated some tests on
+	Windows that were fixed in beta2.
+
 2005-01-17  Sebastien Pouliot  <[email protected]>
 
 	* Pkcs9ContentTypeTest.cs: New. Unit tests for ContentType attribute.

+ 5 - 5
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/CmsRecipientTest.cs

@@ -64,15 +64,15 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			0x0F, 0xCE, 0x10, 0x28, 0x3D, 0x2A, 0x45, 0x64, 0x60, 0xE3, 0xB7, 0xE1, 0x76, 0x90, 0xEC, 0x5B, 0xC6, 0xA1, 0xF0, 0xC4, 0xE8, 0x12, 0xD9, 0xC6, 0x22, 0x80, 0xB5, 0x30, 0xE5, 0x17, 0xAE, 0x05, 0x96, 0xBB, 0x4E, 0xBB, 0x33, 0xBB, 0xB0, 0x63, 0x29, 0x74, 0x11, 0x06, 0x23, 0x36, 0xB4, 0xA1, 0x25, 0xD5, 0x2A, 0xF3, 0x90, 0x38, 0x18, 0x02, 0x62, 0x30, 0x3B, 0x30, 0x1F, 0x30, 0x07, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x04, 0x14, 0xDC, 0x3A, 0xAB, 0x36, 0xD7, 0x3E, 0xF4, 0x6C, 0x52, 0xC9, 0x89, 0x37, 0xFE, 0x71, 0x71, 0x83, 0xC6, 0x09, 0x88, 0xDD, 0x04, 0x14, 0xF5, 0x76, 0xC2, 0xCC, 0xB9, 0xE5, 
 			0xF5, 0x28, 0xA3, 0x2D, 0x55, 0xDC, 0xDE, 0x3B, 0xCF, 0x53, 0xEE, 0x4B, 0x8F, 0x6F, 0x02, 0x02, 0x07, 0xD0 };
 
-		private X509CertificateEx GetCertificate (bool includePrivateKey) 
+		private X509Certificate2 GetCertificate (bool includePrivateKey) 
 		{
-			return new X509CertificateEx (farscape_p12_pfx, "farscape");
+			return new X509Certificate2 (farscape_p12_pfx, "farscape");
 		}
 
 		[Test]
 		public void IssuerAndSerialNumber () 
 		{
-			X509CertificateEx x509 = GetCertificate (true);
+			X509Certificate2 x509 = GetCertificate (true);
 			CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.IssuerAndSerialNumber, x509);
 			AssertEquals ("RecipientIdentifierType", SubjectIdentifierType.IssuerAndSerialNumber, p7r.RecipientIdentifierType);
 			AssertEquals ("Certificate", x509.Thumbprint, p7r.Certificate.Thumbprint);
@@ -81,7 +81,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[Test]
 		public void SubjectKeyIdentifier () 
 		{
-			X509CertificateEx x509 = GetCertificate (true);
+			X509Certificate2 x509 = GetCertificate (true);
 			CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.SubjectKeyIdentifier, x509);
 			AssertEquals ("RecipientIdentifierType", SubjectIdentifierType.SubjectKeyIdentifier, p7r.RecipientIdentifierType);
 			AssertEquals ("Certificate", x509.Thumbprint, p7r.Certificate.Thumbprint);
@@ -90,7 +90,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[Test]
 		public void Unknown () 
 		{
-			X509CertificateEx x509 = GetCertificate (true);
+			X509Certificate2 x509 = GetCertificate (true);
 			CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.Unknown, x509);
 			AssertEquals ("RecipientIdentifierType", SubjectIdentifierType.IssuerAndSerialNumber, p7r.RecipientIdentifierType);
 			AssertEquals ("Certificate", x509.Thumbprint, p7r.Certificate.Thumbprint);

+ 8 - 8
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/CmsSignerTest.cs

@@ -106,16 +106,16 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		}
 
 		// TODO: return valid x509 certifiate with private key
-		private X509CertificateEx GetValidCertificateWithPrivateKey () 
+		private X509Certificate2 GetValidCertificateWithPrivateKey () 
 		{
-			X509CertificateEx x509 = new X509CertificateEx ();
+			X509Certificate2 x509 = new X509Certificate2 ();
 			return x509;
 		}
 
 		[Test]
 		public void ConstructorX509CertificateEx () 
 		{
-			X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+			X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
 			CmsSigner ps = new CmsSigner (x509);
 			// default properties
 			AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
@@ -130,7 +130,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[Test]
 		public void ConstructorX509CertificateExEmpty () 
 		{
-			X509CertificateEx x509 = new X509CertificateEx (); // empty
+			X509Certificate2 x509 = new X509Certificate2 (); // empty
 			CmsSigner ps = new CmsSigner (x509);
 			// default properties
 			AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
@@ -146,7 +146,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		//BUG [ExpectedException (typeof (ArgumentNullException))]
 		public void ConstructorX509CertificateExNull () 
 		{
-			X509CertificateEx x509 = null;
+			X509Certificate2 x509 = null;
 			CmsSigner ps = new CmsSigner (x509);
 			// default properties
 			AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
@@ -161,7 +161,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[Test]
 		public void ConstructorIssuerAndSerialNumberX509CertificateEx () 
 		{
-			X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+			X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
 			CmsSigner ps = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber, x509);
 			// default properties
 			AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
@@ -176,7 +176,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[Test]
 		public void ConstructorSubjectKeyIdentifierX509CertificateEx () 
 		{
-			X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+			X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
 			CmsSigner ps = new CmsSigner (SubjectIdentifierType.SubjectKeyIdentifier, x509);
 			// default properties
 			AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
@@ -191,7 +191,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[Test]
 		public void ConstructorUnknownX509CertificateEx () 
 		{
-			X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+			X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
 			CmsSigner ps = new CmsSigner (SubjectIdentifierType.Unknown, x509);
 			// default properties
 			AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);

+ 10 - 10
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/EnvelopedCmsTest.cs

@@ -85,9 +85,9 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			AssertEquals ("Version", version, ep.Version);
 		}
 
-		private X509CertificateEx GetCertificate (bool includePrivateKey) 
+		private X509Certificate2 GetCertificate (bool includePrivateKey) 
 		{
-			return new X509CertificateEx (farscape_p12_pfx, "farscape");
+			return new X509Certificate2 (farscape_p12_pfx, "farscape");
 		}
 
 		[Test]
@@ -233,8 +233,8 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			EnvelopedCms ep = new EnvelopedCms ();
 			ep.Decode (encoded);
 
-			X509CertificateEx x509 = GetCertificate (true);
-			X509CertificateExCollection xc = new X509CertificateExCollection ();
+			X509Certificate2 x509 = GetCertificate (true);
+			X509Certificate2Collection xc = new X509Certificate2Collection ();
 			xc.Add (x509);
 			ep.Decrypt (xc);
 			// properties
@@ -273,7 +273,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		public void DecryptX509CertificateExCollectionNull () 
 		{
 			EnvelopedCms ep = new EnvelopedCms ();
-			X509CertificateExCollection xec = null; // do not confuse compiler
+			X509Certificate2Collection xec = null; // do not confuse compiler
 			ep.Decrypt (xec);
 		}
 
@@ -282,7 +282,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		public void DecryptRecipientInfoX509CertificateExCollectionNull () 
 		{
 			EnvelopedCms ep = new EnvelopedCms ();
-			X509CertificateExCollection xec = new X509CertificateExCollection ();
+			X509Certificate2Collection xec = new X509Certificate2Collection ();
 			ep.Decrypt (null, xec);
 		}
 
@@ -297,7 +297,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 
 		private void RoundTrip (byte[] encoded) 
 		{
-			X509CertificateExCollection xc = new X509CertificateExCollection ();
+			X509Certificate2Collection xc = new X509Certificate2Collection ();
 			xc.Add (GetCertificate (true));
 			EnvelopedCms ep = new EnvelopedCms ();
 			ep.Decode (encoded);
@@ -311,7 +311,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			ContentInfo ci = new ContentInfo (asnNull);
 			EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
 
-			X509CertificateEx x509 = GetCertificate (false);
+			X509Certificate2 x509 = GetCertificate (false);
 			CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.IssuerAndSerialNumber, x509);
 			ep.Encrypt (p7r);
 			byte[] encoded = ep.Encode ();
@@ -329,7 +329,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			ContentInfo ci = new ContentInfo (asnNull);
 			EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
 
-			X509CertificateEx x509 = GetCertificate (false);
+			X509Certificate2 x509 = GetCertificate (false);
 			CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.SubjectKeyIdentifier, x509);
 			ep.Encrypt (p7r);
 			byte[] encoded = ep.Encode ();
@@ -347,7 +347,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			ContentInfo ci = new ContentInfo (asnNull);
 			EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
 
-			X509CertificateEx x509 = GetCertificate (false);
+			X509Certificate2 x509 = GetCertificate (false);
 			CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.Unknown, x509);
 			ep.Encrypt (p7r);
 			byte[] encoded = ep.Encode ();

+ 9 - 9
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkcs9AttributeTest.cs

@@ -39,7 +39,7 @@ using System.Security.Cryptography.Pkcs;
 namespace MonoTests.System.Security.Cryptography.Pkcs {
 
 	[TestFixture]
-	public class Pkcs9AttributeTest {
+	public class Pkcs9AttributeObjectTest {
 
 		static string defaultOid = "1.2.840.113549.1.7.1";
 		static string defaultName = "PKCS 7 Data";
@@ -47,7 +47,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[Test]
 		public void ConstructorEmpty () 
 		{
-			Pkcs9Attribute a = new Pkcs9Attribute ();
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject ();
 			Assert.IsNull (a.Oid, "Oid");
 			Assert.IsNull (a.RawData, "RawData");
 		}
@@ -56,14 +56,14 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		[ExpectedException (typeof (ArgumentNullException))]
 		public void ConstructorAsnEncodedDataNull () 
 		{
-			Pkcs9Attribute a = new Pkcs9Attribute (null);
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject (null);
 		}
 
 		[Test]
 		public void ConstructorOidArray () 
 		{
 			Oid o = new Oid (defaultOid);
-			Pkcs9Attribute a = new Pkcs9Attribute (o, new byte [0]);
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, new byte[0]);
 			Assert.AreEqual (defaultName, a.Oid.FriendlyName, "Oid.FriendlyName");
 			Assert.AreEqual (defaultOid, a.Oid.Value, "Oid.Value");
 			Assert.AreEqual (0, a.RawData.Length, "RawData");
@@ -74,7 +74,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		public void ConstructorOidNullArray ()
 		{
 			Oid o = null;
-			Pkcs9Attribute a = new Pkcs9Attribute (o, new byte [0]);
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, new byte[0]);
 		}
 
 		[Test]
@@ -82,13 +82,13 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		public void ConstructorOidArrayNull ()
 		{
 			Oid o = new Oid (defaultOid);
-			Pkcs9Attribute a = new Pkcs9Attribute (o, null);
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, null);
 		}
 
 		[Test]
 		public void ConstructorStringArray ()
 		{
-			Pkcs9Attribute a = new Pkcs9Attribute (defaultOid, new byte [0]);
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject (defaultOid, new byte[0]);
 			Assert.AreEqual (defaultName, a.Oid.FriendlyName, "Oid.FriendlyName");
 			Assert.AreEqual (defaultOid, a.Oid.Value, "Oid.Value");
 			Assert.AreEqual (0, a.RawData.Length, "RawData");
@@ -99,14 +99,14 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		public void ConstructorStringNullArray ()
 		{
 			string s = null;
-			Pkcs9Attribute a = new Pkcs9Attribute (s, new byte [0]);
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject (s, new byte[0]);
 		}
 
 		[Test]
 		[ExpectedException (typeof (ArgumentNullException))]
 		public void ConstructorStringArrayNull ()
 		{
-			Pkcs9Attribute a = new Pkcs9Attribute (defaultOid, null);
+			Pkcs9AttributeObject a = new Pkcs9AttributeObject (defaultOid, null);
 		}
 	}
 }

+ 2 - 4
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkcs9DocumentDescriptionTest.cs

@@ -5,7 +5,7 @@
 //	Sebastien Pouliot  <[email protected]>
 //
 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -75,9 +75,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		}
 
 		[Test]
-		[ExpectedException (typeof (NullReferenceException))]
-		// MSBUG [ExpectedException (typeof (ArgumentNullException))]
-		// reported as 
+		[ExpectedException (typeof (ArgumentNullException))]
 		public void Constructor_StringNull () 
 		{
 			string desc = null;

+ 2 - 4
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkcs9DocumentNameTest.cs

@@ -5,7 +5,7 @@
 //	Sebastien Pouliot  <[email protected]>
 //
 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -75,9 +75,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		}
 
 		[Test]
-		[ExpectedException (typeof (NullReferenceException))]
-		// MSBUG [ExpectedException (typeof (ArgumentNullException))]
-		// reported as 
+		[ExpectedException (typeof (ArgumentNullException))]
 		public void Constructor_StringNull ()
 		{
 			string name = null;

+ 2 - 2
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/Pkcs9SigningTimeTest.cs

@@ -188,7 +188,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		}
 
 		[Test]
-		[Ignore ("MS returns bad results (original time) - Mono needs to override CopyFrom to fix")]
+//		[Ignore ("MS returns bad results (original time) - Mono needs to override CopyFrom to fix")]
 		// http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=66943396-ad73-497f-82ae-090b87ffcb4e
 		public void CopyFrom () 
 		{
@@ -210,7 +210,7 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 		}
 
 		[Test]
-		[Ignore ("MS doesn't throw but returns bad results - Mono needs to override CopyFrom to fix")]
+//		[Ignore ("MS doesn't throw but returns bad results - Mono needs to override CopyFrom to fix")]
 		// http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=66943396-ad73-497f-82ae-090b87ffcb4e
 		[ExpectedException (typeof (CryptographicException))]
 		public void CopyFrom_Bad ()

+ 11 - 11
mcs/class/System.Security/Test/System.Security.Cryptography.Pkcs/SignedCmsTest.cs

@@ -92,15 +92,15 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			AssertEquals ("Version", version, sp.Version);
 		}
 
-		private X509CertificateEx GetCertificate (bool includePrivateKey) 
+		private X509Certificate2 GetCertificate (bool includePrivateKey) 
 		{
-			return new X509CertificateEx (farscape_p12_pfx, "farscape");
+			return new X509Certificate2 (farscape_p12_pfx, "farscape");
 		}
 
-		private void AddChain (X509CertificateExCollection coll)
+		private void AddChain (X509Certificate2Collection coll)
 		{
-			coll.Add (new X509CertificateEx (intca_cer));
-			coll.Add (new X509CertificateEx (root_cer));
+			coll.Add (new X509Certificate2 (intca_cer));
+			coll.Add (new X509Certificate2 (root_cer));
 		}
 
 		[Test]
@@ -305,8 +305,8 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			SignedCms sp = new SignedCms (ci);
 
 			CmsSigner signer = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber, GetCertificate (true));
-			signer.Certificates.Add (new X509CertificateEx (intca_cer));
-			signer.Certificates.Add (new X509CertificateEx (root_cer));
+			signer.Certificates.Add (new X509Certificate2 (intca_cer));
+			signer.Certificates.Add (new X509Certificate2 (root_cer));
 			sp.ComputeSignature (signer);
 
 			byte[] encoded = sp.Encode ();
@@ -326,8 +326,8 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			SignedCms sp = new SignedCms (ci);
 
 			CmsSigner signer = new CmsSigner (SubjectIdentifierType.SubjectKeyIdentifier, GetCertificate (true));
-			signer.Certificates.Add (new X509CertificateEx (intca_cer));
-			signer.Certificates.Add (new X509CertificateEx (root_cer));
+			signer.Certificates.Add (new X509Certificate2 (intca_cer));
+			signer.Certificates.Add (new X509Certificate2 (root_cer));
 			sp.ComputeSignature (signer);
 
 			byte[] encoded = sp.Encode ();
@@ -347,8 +347,8 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
 			SignedCms sp = new SignedCms (ci);
 
 			CmsSigner signer = new CmsSigner (SubjectIdentifierType.Unknown, GetCertificate (true));
-			signer.Certificates.Add (new X509CertificateEx (intca_cer));
-			signer.Certificates.Add (new X509CertificateEx (root_cer));
+			signer.Certificates.Add (new X509Certificate2 (intca_cer));
+			signer.Certificates.Add (new X509Certificate2 (root_cer));
 			sp.ComputeSignature (signer);
 
 			byte[] encoded = sp.Encode ();