// 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;
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);
+ }
}
}
+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
// 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;
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
}
}
// 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;
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);
}
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);
}
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);
}
#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);
}
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);
}
}
[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 ());
// 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;
[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]
//
// 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;
}
[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 ();
// 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;
}
[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 ()
{
}
[Test]
+#if !NET_2_0
[ExpectedException (typeof (CryptographicException))]
+#endif
public void Constructor_XmlElement_WithoutLoadXml ()
{
XmlDocument doc = new XmlDocument ();
XmlElement xel = (XmlElement) xnl [0];
SignedXml sx = new SignedXml (doc.DocumentElement);
- Assert ("!CheckSignature", sx.CheckSignature ());
+ Assert ("!CheckSignature", !sx.CheckSignature ());
// SignedXml (XmlElement) != SignedXml () + LoadXml (XmlElement)
}
// 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);
}
#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);
}
}
[Test]
+#if !NET_2_0
[ExpectedException (typeof (CryptographicException))]
+#endif
public void CheckSignatureEmpty ()
{
SignedXml sx = new SignedXml ();
- sx.CheckSignature ();
+ Assert (!sx.CheckSignature ());
}
}
}
}
[Test]
+#if NET_2_0
+ [Category ("NotDotNet")]\r
+ // see LoadInputAsXmlNodeList2 description
+#endif
public void LoadInputAsXmlNodeList ()
{
XmlDocument doc = GetDoc ();
// 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;
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);
}
[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);
}
[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);
}
sw.Close ();
}
}
- string res = ExecuteXmlDSigC14NTransform (C14NSpecExample5Input);
+ string res = ExecuteXmlDSigC14NTransform (C14NSpecExample5Input, false);
AssertEquals ("Example 5 from c14n spec - Entity References (with comments)",
C14NSpecExample5Output, res);
}
[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;
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 ());
}
// 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.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;
}
[Test]
+#if NET_2_0
+ [Ignore ("throws a NullReferenceException - but it's (kind of internal)")]
+#endif
public void GetInnerXml ()
{
XmlNodeList xnl = transform.UnprotectedGetInnerXml ();
}
[Test]
+#if NET_2_0
+ [Category ("NotWorking")]
+#endif
public void LoadInputAsXmlDocument ()
{
XmlDocument doc = GetDoc ();
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 ();
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 ();
}
[Test]
+#if NET_2_0
+ [Category ("NotWorking")]
+#endif
public void LoadInputAsStream ()
{
XmlDocument doc = GetDoc ();
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 ();
[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 ();
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);