2005-05-04 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Wed, 4 May 2005 16:24:37 +0000 (16:24 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Wed, 4 May 2005 16:24:37 +0000 (16:24 -0000)
* 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

svn path=/trunk/mcs/; revision=44035

mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs

index 30536d5c38ba361e74451c506eeb678dd308ccc6..52086318e7d9cfdd9bf46ec7cb5f0a5b8296fd3a 100644 (file)
@@ -2,9 +2,10 @@
 // MonoTests.System.Security.Cryptography.Xml.AssertCrypto.cs
 //
 // Author:
-//     Sebastien Pouliot (spouliot@motus.com)
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //
 // (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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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);
+               }
        }
 }
index 16d4a2acc06a73ed9be2bbf87acd811768fe057c..af6aaa0f8edd73d8010fe87773a95a394f3adc43 100644 (file)
@@ -1,3 +1,12 @@
+2005-05-04  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * 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  <sebastien@ximian.com>
 
        * SignedXmlTest.cs: AddObject and AddReference now throws 
index 3e970d1989201ba22e29a8b414543d8deba34454..cdef016e07bb521d6c77710a008032de753a2ccd 100644 (file)
@@ -2,9 +2,10 @@
 // KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
 //
 // Author:
-//     Sebastien Pouliot (spouliot@motus.com)
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //
 // (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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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", "<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));
+#else
+                       // Fx 1.0 misnamed the tag name
+                       AssertEquals("invalid", "<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
 #endif
                }
        }
index 77cf0efcdd90ba6e611b27bb522979bebf66933a..96a3e31f118e0e60173cb2289ba3707452a2ae7e 100644 (file)
@@ -5,7 +5,7 @@
 //     Sebastien Pouliot <sebastien@ximian.com>
 //
 // (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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
 #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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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);
                }
 
index 937c7cd511316e8533043d551ef3f46750c681d3..495980f8478726cdee290396654bc5239bc45ec0 100644 (file)
@@ -158,13 +158,17 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if NET_2_0
+               [Ignore ("MS throws a NullReferenceException - reported as FDBK25886")]\r
+               // 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 ());
index 4d92d62c0dcec11b11f5182bea7b4902e5f77de7..6a75e69bb87440e754a650348cc3b897e8f4d3aa 100644 (file)
@@ -5,7 +5,7 @@
 //     Sebastien Pouliot <sebastien@ximian.com>
 //
 // (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)\r
 //
 
 using System;
@@ -51,14 +51,12 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                [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=\"MyObjectId\"><MyElement xmlns=\"samples\">This is some text</MyElement></Object></Signature>";
+                       XmlDocument doc = new XmlDocument ();\r
+                       doc.LoadXml (expected);
                        signature.LoadXml (doc.DocumentElement);
-                       string result = signature.GetXml ().OuterXml;
-                       Assert ("Load", ((test1 == result) || (test2 == result)));
+                       string result = signature.GetXml ().OuterXml;\r
+                       AssertCrypto.AssertXmlEquals ("Load", expected, result);
                }
 
                [Test]
index bc9123ac394ca7e55b924703da66e05b07993ca5..55bf56b82af46ceebfb969c4bce788228b1345e6 100644 (file)
@@ -1,10 +1,11 @@
 //
 // SignedInfoTest.cs - NUnit Test Cases for SignedInfo
 //
-// Author:
-//     Sebastien Pouliot (spouliot@motus.com)
+// Author:\r
+//     Sebastien Pouliot <sebastien@ximian.com>\r
 //
-// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)\r
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)\r
 //
 
 using System;
@@ -146,6 +147,11 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if NET_2_0\r
+               // urn:foo is'nt accepted when calling GetXml\r
+               [ExpectedException (typeof (CryptographicException))]\r
+               [Category ("NotWorking")]\r
+#endif
                public void GetXmlWithSetProperty ()
                {
                        XmlDocument doc = new XmlDocument ();
index b216bcf4cea1ce567309d71dea1de66a1a5b7747..0b593631a6bd08d4ddf6315ee1ce4c8b8b575cb0 100644 (file)
@@ -4,8 +4,8 @@
 // Author:
 //     Sebastien Pouliot  <sebastien@ximian.com>
 //
-// (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)\r
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)\r
 //
 
 using System;
@@ -72,6 +72,10 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if NET_2_0
+               [Ignore ("2.0 throws a NullReferenceException - reported as FDBK25892")]\r
+               // 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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if !NET_2_0
                [ExpectedException (typeof (CryptographicException))]
+#endif
                public void Constructor_XmlElement_WithoutLoadXml () 
                {
                        XmlDocument doc = new XmlDocument ();
@@ -102,7 +108,7 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        // Compute the signature.
                        byte[] secretkey = Encoding.Default.GetBytes ("password");
                        HMACSHA1 hmac = new HMACSHA1 (secretkey);
-
+#if NET_2_0\r
+                       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);\r
+\r
+#if NET_2_0\r
+                       AssertEquals ("KeyInfo", 0, signedXml.KeyInfo.Count);\r
+#else
                        AssertNull ("KeyInfo", signedXml.KeyInfo);
+#endif\r
                        AssertNull ("SignatureLength", signedXml.SignatureLength);
                        AssertEquals ("SignatureMethod", SignedXml.XmlDsigHMACSHA1Url, signedXml.SignatureMethod);
                        AssertEquals ("SignatureValue", 20, signedXml.SignatureValue.Length);
@@ -365,10 +378,11 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 #if NET_2_0
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
+               // [ExpectedException (typeof (ArgumentNullException))]
                public void AddObject_Null () 
                {
-                       SignedXml sx = new SignedXml ();
+                       SignedXml sx = new SignedXml ();\r
+                       // still no ArgumentNullExceptions for this one\r
                        sx.AddObject (null);
                }
 
@@ -435,11 +449,13 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if !NET_2_0
                [ExpectedException (typeof (CryptographicException))]
+#endif
                public void CheckSignatureEmpty ()
                {
                        SignedXml sx = new SignedXml ();
-                       sx.CheckSignature ();
+                       Assert (!sx.CheckSignature ());
                }
        }
 }
index e1cf3cb7596960623731344a13369dcb269e81e9..5a59b45bd5faa62ac985336fecc542da7d8e97f1 100644 (file)
@@ -138,6 +138,10 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if NET_2_0
+               [Category ("NotDotNet")]\r
+               // see LoadInputAsXmlNodeList2 description
+#endif
                public void LoadInputAsXmlNodeList () 
                {
                        XmlDocument doc = GetDoc ();
index c7f5b802265a7f01ae24f10946cefbe90d904930..726fb7f914234797213f225cb3882ca2dd4728b1 100644 (file)
@@ -5,12 +5,13 @@
 // Author:
 //     Sebastien Pouliot <sebastien@ximian.com>
 //
-// (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)\r
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)\r
 //
 
 using System;
-using System.IO;
+using System.IO;\r
+using System.Security;\r
 using System.Security.Cryptography.Xml;
 using System.Text;
 using System.Xml;
@@ -119,15 +120,34 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                                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);
-               }
+               }\r
+\r
+               [Test]\r
+#if NET_2_0\r
+               [ExpectedException (typeof (SecurityException))]\r
+#endif\r
+               public void C14NSpecExample1_WithoutResolver ()\r
+               {\r
+                       using (StreamWriter sw = new StreamWriter ("doc.dtd", false, Encoding.ASCII)) {\r
+                               sw.Write ("<!-- presence, not content, required -->");\r
+                               sw.Close ();\r
+                       }\r
+#if NET_2_0\r
+                       if (!SecurityManager.SecurityEnabled)\r
+                               NUnit.Framework.Assert.Ignore ("SecurityManager isn't enabled.");\r
+#endif\r
+                       string res = ExecuteXmlDSigC14NTransform (C14NSpecExample1Input, false);\r
+                       AssertEquals ("Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (with comments)",\r
+                                       C14NSpecExample1Output, res);\r
+               }
 
                [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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                [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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                [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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                                        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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                [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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        vreader.ValidationType = ValidationType.None;
                        vreader.EntityHandling = EntityHandling.ExpandCharEntities;
                        doc.Load (vreader);
-
+#if NET_2_0\r
+                       if (resolver)\r
+                               transform.Resolver = new XmlUrlResolver ();
+#endif
                        transform.LoadInput (doc);
                        return Stream2String ((Stream)transform.GetOutput ());
                }
index a2a6ee4bc1333d6a438c883f5bd4b964e6d02a91..872aa161ab0517380850036b27b2f7b56a95096e 100755 (executable)
@@ -4,8 +4,8 @@
 // Author:
 //     Sebastien Pouliot <sebastien@ximian.com>
 //
-// (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)\r
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)\r
 //
 
 using System;
@@ -14,7 +14,8 @@ using System.Security.Cryptography;
 using System.Security.Cryptography.Xml;
 using System.Text;
 using System.Xml;
-using System.Xml.Xsl;
+using System.Xml.Xsl;\r
+using System.Xml.XPath;
 
 using NUnit.Framework;
 
@@ -85,6 +86,9 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if NET_2_0
+               [Category ("NotWorking")]
+#endif
                public void LoadInputAsXmlDocument () 
                {
                        XmlDocument doc = GetDoc ();
@@ -130,10 +137,17 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        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]\r
+#if NET_2_0\r
+               [ExpectedException (typeof (XPathException))]\r
+#endif\r
                public void LoadInputAsXmlDocument_EmptyXPath () 
                {
                        XmlDocument doc = GetDoc ();
@@ -155,7 +169,10 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        AssertEquals (1, xnl.Count);
                }
 
-               [Test]
+               [Test]\r
+#if NET_2_0\r
+               [ExpectedException (typeof (XPathException))]\r
+#endif\r
                public void LoadInputAsXmlNodeList_EmptyXPath () 
                {
                        XmlDocument doc = GetDoc ();
@@ -166,6 +183,9 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                }
 
                [Test]
+#if NET_2_0
+               [Category ("NotWorking")]
+#endif
                public void LoadInputAsStream () 
                {
                        XmlDocument doc = GetDoc ();
@@ -177,10 +197,17 @@ namespace MonoTests.System.Security.Cryptography.Xml {
                        XmlNodeList inner = InnerXml ("//*/title");
                        transform.LoadInnerXml (inner);
                        XmlNodeList xnl = (XmlNodeList) transform.GetOutput ();
+#if NET_2_0\r
+                       AssertEquals (73, xnl.Count);\r
+#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 @@ namespace MonoTests.System.Security.Cryptography.Xml {
 
                [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()\r
+#if NET_2_0\r
+               [ExpectedException (typeof (XPathException))]\r
+#endif\r
                public void FunctionHereObsolete ()
                {
                        XmlDsigXPathTransform t = new XmlDsigXPathTransform ();
@@ -261,6 +291,7 @@ namespace MonoTests.System.Security.Cryptography.Xml {
 
                        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);