Author: spouliot
Date: 2005-05-04 12:24:37 -0400 (Wed, 04 May 2005)
New Revision: 44035
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs
Log:
2005-05-04 Sebastien Pouliot <[EMAIL PROTECTED]>
* AssertCrypto.cs: Added method to compare somewhat different but ok
XML fragments (when the xmlns for xmldsig is on a different element).
* KeyInfoTest.cs, KeyInfoRetrievalMethodTest.cs, ReferenceTest.cs,
SignedInfoTest.cs, SignatureTest.cs, SignedXmlTest.cs,
XmlDsigC14NTransformTest.cs, XmlDsigC14NWithCommentsTransformTest.cs,
XmlDsigXPathTransformTest.cs: Make all tests works under Fx 2.0 beta 2
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -2,9 +2,10 @@
// MonoTests.System.Security.Cryptography.Xml.AssertCrypto.cs
//
// Author:
-// Sebastien Pouliot ([EMAIL PROTECTED])
+// Sebastien Pouliot <[EMAIL PROTECTED]>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
using System;
@@ -39,5 +40,15 @@
msg += " is different than " + BitConverter.ToString
(array2, 0);
Assert (msg, a);
}
+
+ private const string xmldsig = "
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"";
+
+ // not to be used to test C14N output
+ static public void AssertXmlEquals (string msg, string
expected, string actual)
+ {
+ expected = expected.Replace (xmldsig, String.Empty);
+ actual = actual.Replace (xmldsig, String.Empty);
+ AssertEquals (msg, expected, actual);
+ }
}
}
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
2005-05-04 16:24:37 UTC (rev 44035)
@@ -1,3 +1,12 @@
+2005-05-04 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * AssertCrypto.cs: Added method to compare somewhat different but ok
+ XML fragments (when the xmlns for xmldsig is on a different element).
+ * KeyInfoTest.cs, KeyInfoRetrievalMethodTest.cs, ReferenceTest.cs,
+ SignedInfoTest.cs, SignatureTest.cs, SignedXmlTest.cs,
+ XmlDsigC14NTransformTest.cs, XmlDsigC14NWithCommentsTransformTest.cs,
+ XmlDsigXPathTransformTest.cs: Make all tests works under Fx 2.0 beta 2
+
2005-05-02 Sebastien Pouliot <[EMAIL PROTECTED]>
* SignedXmlTest.cs: AddObject and AddReference now throws
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -2,9 +2,10 @@
// KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
//
// Author:
-// Sebastien Pouliot ([EMAIL PROTECTED])
+// Sebastien Pouliot <[EMAIL PROTECTED]>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
using System;
@@ -85,11 +86,14 @@
KeyInfoRetrievalMethod uri1 = new
KeyInfoRetrievalMethod ();
// no exception is thrown
uri1.LoadXml (doc.DocumentElement);
+#if NET_2_0
+ AssertCrypto.AssertXmlEquals ("invalid",
"<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />",
(uri1.GetXml ().OuterXml));
+#elif NET_1_1
// note that URI="" is present (unlike a empty Uri)
-#if NET_1_0
+ AssertEquals("invalid", "<RetrievalMethod URI=\"\"
xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
+#else
+ // Fx 1.0 misnamed the tag name
AssertEquals("invalid", "<RetrievalElement URI=\"\"
xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
-#else
- AssertEquals("invalid", "<RetrievalMethod URI=\"\"
xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
#endif
}
}
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -5,7 +5,7 @@
// Sebastien Pouliot <[EMAIL PROTECTED]>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
using System;
@@ -68,7 +68,7 @@
key.FromXmlString (xmlDSA);
DSAKeyValue dsa = new DSAKeyValue (key);
info.AddClause (dsa);
- AssertEquals ("dsa", "<KeyInfo
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue
xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlDSA +
"</KeyValue></KeyInfo>", (info.GetXml ().OuterXml));
+ AssertCrypto.AssertXmlEquals ("dsa", "<KeyInfo
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue
xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlDSA +
"</KeyValue></KeyInfo>", (info.GetXml ().OuterXml));
AssertEquals ("dsa count", 1, info.Count);
}
@@ -81,7 +81,7 @@
key.FromXmlString (xmlRSA);
RSAKeyValue rsa = new RSAKeyValue (key);
info.AddClause (rsa);
- AssertEquals ("rsa", "<KeyInfo
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue
xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlRSA +
"</KeyValue></KeyInfo>", (info.GetXml ().OuterXml));
+ AssertCrypto.AssertXmlEquals ("rsa", "<KeyInfo
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue
xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlRSA +
"</KeyValue></KeyInfo>", (info.GetXml ().OuterXml));
AssertEquals ("rsa count", 1, info.Count);
}
@@ -112,7 +112,7 @@
X509Certificate x509 = new X509Certificate (cert);
KeyInfoX509Data x509data = new KeyInfoX509Data (x509);
info.AddClause (x509data);
- AssertEquals ("X509Data", "<KeyInfo
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Data
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>",
(info.GetXml ().OuterXml));
+ AssertCrypto.AssertXmlEquals ("X509Data", "<KeyInfo
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Data
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>",
(info.GetXml ().OuterXml));
AssertEquals ("X509Data count", 1, info.Count);
}
@@ -150,7 +150,7 @@
#endif
s += "<X509Data
xmlns=\"http://www.w3.org/2000/09/xmldsig#\">";
s +=
"<X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>";
- AssertEquals ("Complex", s, (info.GetXml ().OuterXml));
+ AssertCrypto.AssertXmlEquals ("Complex", s,
(info.GetXml ().OuterXml));
AssertEquals ("RetrievalMethod count", 5, info.Count);
}
@@ -164,7 +164,7 @@
doc.LoadXml (value);
info.LoadXml (doc.DocumentElement);
- AssertEquals ("Import", value, (info.GetXml
().OuterXml));
+ AssertCrypto.AssertXmlEquals ("Import", value,
(info.GetXml ().OuterXml));
AssertEquals ("Import count", 5, info.Count);
}
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -158,13 +158,17 @@
}
[Test]
+#if NET_2_0
+ [Ignore ("MS throws a NullReferenceException - reported as
FDBK25886")]
+ //
http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=3596d1e3-362b-40bd-bca9-2e8be75261ff
+#endif
public void AddAllTransforms ()
{
// adding an empty hash value
byte[] hash = new byte [20];
reference.DigestValue = hash;
XmlElement xel = reference.GetXml ();
- // this is the minimal Reference (DisestValue)!
+ // this is the minimal Reference (DigestValue)!
AssertNotNull ("GetXml", xel);
reference.AddTransform (new XmlDsigBase64Transform ());
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -5,7 +5,7 @@
// Sebastien Pouliot <[EMAIL PROTECTED]>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
using System;
@@ -51,14 +51,12 @@
[Test]
public void Load ()
{
- string test1 = "<Signature
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod
Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"
/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"
/><Reference URI=\"#MyObjectId\"><DigestMethod
Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"
/><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference></SignedInfo><SignatureValue>A6XuE8Cy9iOffRXaW9b0+dUcMUJQnlmwLsiqtQnADbCtZXnXAaeJ6nGnQ4Mm0IGi0AJc7/2CoJReXl7iW4hltmFguG1e3nl0VxCyCTHKGOCo1u8R3K+B1rTaenFbSxs42EM7/D9KETsPlzfYfis36yM3PqatiCUOsoMsAiMGzlc=</SignatureValue><KeyInfo><KeyValue
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>tI8QYIpbG/m6JLyvP+S3X8mzcaAIayxomyTimSh9UCpEucRnGvLw0P73uStNpiF7wltTZA1HEsv+Ha39dY/0j/Wiy3RAodGDRNuKQao1wu34aNybZ673brbsbHFUfw/o7nlKD2xO84fbajBZmKtBBDy63NHt+QL+grSrREPfCTM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo><Object
Id=\"MyObjectId\"
><MyElement xmlns=\"samples\">This is some
>text</MyElement></Object></Signature>";
- // Mono's result is XML equivalent but a little
different from the original
- string test2 = test1.Replace ("<Object
Id=\"MyObjectId\">", "<Object Id=\"MyObjectId\"
xmlns=\"http://www.w3.org/2000/09/xmldsig#\">");
- XmlDocument doc = new XmlDocument ();
- doc.LoadXml (test1);
+ string expected = "<Signature
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod
Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"
/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"
/><Reference URI=\"#MyObjectId\"><DigestMethod
Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"
/><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference></SignedInfo><SignatureValue>A6XuE8Cy9iOffRXaW9b0+dUcMUJQnlmwLsiqtQnADbCtZXnXAaeJ6nGnQ4Mm0IGi0AJc7/2CoJReXl7iW4hltmFguG1e3nl0VxCyCTHKGOCo1u8R3K+B1rTaenFbSxs42EM7/D9KETsPlzfYfis36yM3PqatiCUOsoMsAiMGzlc=</SignatureValue><KeyInfo><KeyValue
xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>tI8QYIpbG/m6JLyvP+S3X8mzcaAIayxomyTimSh9UCpEucRnGvLw0P73uStNpiF7wltTZA1HEsv+Ha39dY/0j/Wiy3RAodGDRNuKQao1wu34aNybZ673brbsbHFUfw/o7nlKD2xO84fbajBZmKtBBDy63NHt+QL+grSrREPfCTM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo><Object
Id=\"MyObjectI
d\"><MyElement xmlns=\"samples\">This is some
text</MyElement></Object></Signature>";
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml (expected);
signature.LoadXml (doc.DocumentElement);
- string result = signature.GetXml ().OuterXml;
- Assert ("Load", ((test1 == result) || (test2 ==
result)));
+ string result = signature.GetXml ().OuterXml;
+ AssertCrypto.AssertXmlEquals ("Load", expected, result);
}
[Test]
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -1,10 +1,11 @@
//
// SignedInfoTest.cs - NUnit Test Cases for SignedInfo
//
-// Author:
-// Sebastien Pouliot ([EMAIL PROTECTED])
+// Author:
+// Sebastien Pouliot <[EMAIL PROTECTED]>
//
-// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
using System;
@@ -146,6 +147,11 @@
}
[Test]
+#if NET_2_0
+ // urn:foo is'nt accepted when calling GetXml
+ [ExpectedException (typeof (CryptographicException))]
+ [Category ("NotWorking")]
+#endif
public void GetXmlWithSetProperty ()
{
XmlDocument doc = new XmlDocument ();
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -4,8 +4,8 @@
// Author:
// Sebastien Pouliot <[EMAIL PROTECTED]>
//
-// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
using System;
@@ -72,6 +72,10 @@
}
[Test]
+#if NET_2_0
+ [Ignore ("2.0 throws a NullReferenceException - reported as
FDBK25892")]
+ //
http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=02dd9730-d1ad-4170-8c82-36858c55fbe2
+#endif
[ExpectedException (typeof (ArgumentNullException))]
public void Constructor_XmlDocument_Null ()
{
@@ -93,7 +97,9 @@
}
[Test]
+#if !NET_2_0
[ExpectedException (typeof (CryptographicException))]
+#endif
public void Constructor_XmlElement_WithoutLoadXml ()
{
XmlDocument doc = new XmlDocument ();
@@ -102,7 +108,7 @@
XmlElement xel = (XmlElement) xnl [0];
SignedXml sx = new SignedXml (doc.DocumentElement);
- Assert ("!CheckSignature", sx.CheckSignature ());
+ Assert ("!CheckSignature", !sx.CheckSignature ());
// SignedXml (XmlElement) != SignedXml () + LoadXml
(XmlElement)
}
@@ -231,16 +237,23 @@
// Compute the signature.
byte[] secretkey = Encoding.Default.GetBytes
("password");
HMACSHA1 hmac = new HMACSHA1 (secretkey);
-
+#if NET_2_0
+ AssertEquals ("KeyInfo", 0, signedXml.KeyInfo.Count);
+#else
AssertNull ("KeyInfo", signedXml.KeyInfo);
+#endif
AssertNull ("SignatureLength",
signedXml.SignatureLength);
AssertNull ("SignatureMethod",
signedXml.SignatureMethod);
AssertNull ("SignatureValue", signedXml.SignatureValue);
AssertNull ("SigningKeyName", signedXml.SigningKeyName);
- signedXml.ComputeSignature (hmac);
-
+ signedXml.ComputeSignature (hmac);
+
+#if NET_2_0
+ AssertEquals ("KeyInfo", 0, signedXml.KeyInfo.Count);
+#else
AssertNull ("KeyInfo", signedXml.KeyInfo);
+#endif
AssertNull ("SignatureLength",
signedXml.SignatureLength);
AssertEquals ("SignatureMethod",
SignedXml.XmlDsigHMACSHA1Url, signedXml.SignatureMethod);
AssertEquals ("SignatureValue", 20,
signedXml.SignatureValue.Length);
@@ -365,10 +378,11 @@
}
#if NET_2_0
[Test]
- [ExpectedException (typeof (ArgumentNullException))]
+ // [ExpectedException (typeof (ArgumentNullException))]
public void AddObject_Null ()
{
- SignedXml sx = new SignedXml ();
+ SignedXml sx = new SignedXml ();
+ // still no ArgumentNullExceptions for this one
sx.AddObject (null);
}
@@ -435,11 +449,13 @@
}
[Test]
+#if !NET_2_0
[ExpectedException (typeof (CryptographicException))]
+#endif
public void CheckSignatureEmpty ()
{
SignedXml sx = new SignedXml ();
- sx.CheckSignature ();
+ Assert (!sx.CheckSignature ());
}
}
}
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -138,6 +138,10 @@
}
[Test]
+#if NET_2_0
+ [Category ("NotDotNet")]
+ // see LoadInputAsXmlNodeList2 description
+#endif
public void LoadInputAsXmlNodeList ()
{
XmlDocument doc = GetDoc ();
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -5,12 +5,13 @@
// Author:
// Sebastien Pouliot <[EMAIL PROTECTED]>
//
-// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
using System;
-using System.IO;
+using System.IO;
+using System.Security;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Xml;
@@ -119,15 +120,34 @@
sw.Write ("<!-- presence, not content, required
-->");
sw.Close ();
}
- string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample1Input);
+ string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample1Input, true);
AssertEquals ("Example 1 from c14n spec - PIs,
Comments, and Outside of Document Element (with comments)",
C14NSpecExample1Output, res);
- }
+ }
+
+ [Test]
+#if NET_2_0
+ [ExpectedException (typeof (SecurityException))]
+#endif
+ public void C14NSpecExample1_WithoutResolver ()
+ {
+ using (StreamWriter sw = new StreamWriter ("doc.dtd",
false, Encoding.ASCII)) {
+ sw.Write ("<!-- presence, not content, required
-->");
+ sw.Close ();
+ }
+#if NET_2_0
+ if (!SecurityManager.SecurityEnabled)
+ NUnit.Framework.Assert.Ignore ("SecurityManager
isn't enabled.");
+#endif
+ string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample1Input, false);
+ AssertEquals ("Example 1 from c14n spec - PIs,
Comments, and Outside of Document Element (with comments)",
+ C14NSpecExample1Output, res);
+ }
[Test]
public void C14NSpecExample2 ()
{
- string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample2Input);
+ string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample2Input, false);
AssertEquals ("Example 2 from c14n spec - Whitespace in
Document Content (with comments)",
C14NSpecExample2Output, res);
}
@@ -135,7 +155,7 @@
[Test]
public void C14NSpecExample3 ()
{
- string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample3Input);
+ string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample3Input, false);
AssertEquals ("Example 3 from c14n spec - Start and End
Tags (with comments)",
C14NSpecExample3Output, res);
}
@@ -143,7 +163,7 @@
[Test]
public void C14NSpecExample4 ()
{
- string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample4Input);
+ string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample4Input, false);
AssertEquals ("Example 4 from c14n spec - Character
Modifications and Character References (with comments)",
C14NSpecExample4Output, res);
}
@@ -157,7 +177,7 @@
sw.Close ();
}
}
- string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample5Input);
+ string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample5Input, false);
AssertEquals ("Example 5 from c14n spec - Entity
References (with comments)",
C14NSpecExample5Output, res);
}
@@ -165,12 +185,12 @@
[Test]
public void C14NSpecExample6 ()
{
- string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample6Input);
+ string res = ExecuteXmlDSigC14NTransform
(C14NSpecExample6Input, false);
AssertEquals ("Example 6 from c14n spec - UTF-8
Encoding (with comments)",
C14NSpecExample6Output, res);
}
- private string ExecuteXmlDSigC14NTransform (string InputXml)
+ private string ExecuteXmlDSigC14NTransform (string InputXml,
bool resolver)
{
XmlDocument doc = new XmlDocument ();
doc.PreserveWhitespace = true;
@@ -186,7 +206,10 @@
vreader.ValidationType = ValidationType.None;
vreader.EntityHandling =
EntityHandling.ExpandCharEntities;
doc.Load (vreader);
-
+#if NET_2_0
+ if (resolver)
+ transform.Resolver = new XmlUrlResolver ();
+#endif
transform.LoadInput (doc);
return Stream2String ((Stream)transform.GetOutput ());
}
Modified:
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs
===================================================================
---
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs
2005-05-04 16:21:08 UTC (rev 44034)
+++
trunk/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs
2005-05-04 16:24:37 UTC (rev 44035)
@@ -4,8 +4,8 @@
// Author:
// Sebastien Pouliot <[EMAIL PROTECTED]>
//
-// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
using System;
@@ -14,7 +14,8 @@
using System.Security.Cryptography.Xml;
using System.Text;
using System.Xml;
-using System.Xml.Xsl;
+using System.Xml.Xsl;
+using System.Xml.XPath;
using NUnit.Framework;
@@ -85,6 +86,9 @@
}
[Test]
+#if NET_2_0
+ [Ignore ("throws a NullReferenceException - but it's (kind of
internal)")]
+#endif
public void GetInnerXml ()
{
XmlNodeList xnl = transform.UnprotectedGetInnerXml ();
@@ -123,6 +127,9 @@
}
[Test]
+#if NET_2_0
+ [Category ("NotWorking")]
+#endif
public void LoadInputAsXmlDocument ()
{
XmlDocument doc = GetDoc ();
@@ -130,10 +137,17 @@
XmlNodeList inner = InnerXml ("//*/title");
transform.LoadInnerXml (inner);
XmlNodeList xnl = (XmlNodeList) transform.GetOutput ();
+#if NET_2_0
+ AssertEquals (73, xnl.Count);
+#else
AssertEquals (47, xnl.Count);
+#endif
}
- [Test]
+ [Test]
+#if NET_2_0
+ [ExpectedException (typeof (XPathException))]
+#endif
public void LoadInputAsXmlDocument_EmptyXPath ()
{
XmlDocument doc = GetDoc ();
@@ -155,7 +169,10 @@
AssertEquals (1, xnl.Count);
}
- [Test]
+ [Test]
+#if NET_2_0
+ [ExpectedException (typeof (XPathException))]
+#endif
public void LoadInputAsXmlNodeList_EmptyXPath ()
{
XmlDocument doc = GetDoc ();
@@ -166,6 +183,9 @@
}
[Test]
+#if NET_2_0
+ [Category ("NotWorking")]
+#endif
public void LoadInputAsStream ()
{
XmlDocument doc = GetDoc ();
@@ -177,10 +197,17 @@
XmlNodeList inner = InnerXml ("//*/title");
transform.LoadInnerXml (inner);
XmlNodeList xnl = (XmlNodeList) transform.GetOutput ();
+#if NET_2_0
+ AssertEquals (73, xnl.Count);
+#else
AssertEquals (47, xnl.Count);
+#endif
}
[Test]
+#if NET_2_0
+ [ExpectedException (typeof (XPathException))]
+#endif
public void LoadInputAsStream_EmptyXPath ()
{
XmlDocument doc = GetDoc ();
@@ -247,7 +274,10 @@
[Test]
[Category ("NotWorking")]
- // MS.NET looks incorrect, or something incorrect in this test
code; It turned out nothing to do with function here()
+ // MS.NET looks incorrect, or something incorrect in this test
code; It turned out nothing to do with function here()
+#if NET_2_0
+ [ExpectedException (typeof (XPathException))]
+#endif
public void FunctionHereObsolete ()
{
XmlDsigXPathTransform t = new XmlDsigXPathTransform ();
@@ -261,6 +291,7 @@
doc.LoadXml ("<element
a='b'><foo><bar>test</bar></foo></element>");
t.LoadInput (doc);
+ // FX 2.0 throws at next line!
XmlNodeList nl = (XmlNodeList) t.GetOutput ();
AssertEquals (0, nl.Count);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches