public void RetrievalMethod() { KeyInfoRetrievalMethod retrieval = new KeyInfoRetrievalMethod(); retrieval.Uri = "http://www.go-mono.org/"; info.AddClause(retrieval); Assert.Equal("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalMethod URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml().OuterXml)); Assert.Equal(1, info.Count); }
public void TestNewEmptyKeyNode() { KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); #if NET_1_0 Assert.AreEqual("<RetrievalElement xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml), "Empty"); #else Assert.AreEqual("<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml), "Empty"); #endif }
public void InvalidKeyNode2() { string bad = "<Test></Test>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(bad); KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); uri1.LoadXml(doc.DocumentElement); AssertCrypto.AssertXmlEquals("invalid", "<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml)); }
public void RetrievalMethod() { KeyInfoRetrievalMethod retrieval = new KeyInfoRetrievalMethod(); retrieval.Uri = "http://www.go-mono.org/"; info.AddClause(retrieval); #if NET_1_0 Assert.AreEqual("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalElement URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml().OuterXml), "RetrievalMethod"); #else Assert.AreEqual("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalMethod URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml().OuterXml), "RetrievalMethod"); #endif Assert.AreEqual(1, info.Count, "RetrievalMethod count"); }
public void Complex() { KeyInfoName name = new KeyInfoName(); name.Value = "CoreFx::"; info.AddClause(name); using (DSA keyDSA = DSA.Create()) { keyDSA.ImportParameters(new DSAParameters { P = Convert.FromBase64String(dsaP), Q = Convert.FromBase64String(dsaQ), G = Convert.FromBase64String(dsaG), Y = Convert.FromBase64String(dsaY), }); DSAKeyValue dsa = new DSAKeyValue(keyDSA); info.AddClause(dsa); using (RSA keyRSA = RSA.Create()) { keyRSA.ImportParameters(new RSAParameters() { Modulus = Convert.FromBase64String(rsaModulus), Exponent = Convert.FromBase64String(rsaExponent) }); RSAKeyValue rsa = new RSAKeyValue(keyRSA); info.AddClause(rsa); KeyInfoRetrievalMethod retrieval = new KeyInfoRetrievalMethod(); retrieval.Uri = "https://github.com/dotnet/corefx"; info.AddClause(retrieval); using (X509Certificate x509 = new X509Certificate(cert)) { KeyInfoX509Data x509data = new KeyInfoX509Data(x509); info.AddClause(x509data); string s = "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyName>CoreFx::</KeyName><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue><P>rjxsMU368YOCTQejWkiuO9e/vUVwkLtq1jKiU3TtJ53hBJqjFRuTa228vZe+BH2su9RPn/vYFWfQDv6zgBYe3eNdu4Afw+Ny0FatX6dl3E77Ra6Tsd3MmLXBiGSQ1mMNd5G2XQGpbt9zsGlUaexXekeMLxIufgfZLwYp67M+2WM=</P><Q>tf0K9rMyvUrU4cIkwbCrDRhQAJk=</Q><G>S8Z+1pGCed00w6DtVcqZLKjfqlCJ7JsugEFIgSy/Vxtu9YGCMclV4ijGEbPo/jU8YOSMuD7E9M7UaopMRcmKQjoKZzoJjkgVFP48Ohxl1f08lERnButsxanx3+OstFwUGQ8XNaGg3KrIoZt1FUnfxN3RHHTvVhjzNSHxMGULGaU=</G><Y>LnrxxRGLYeV2XLtK3SYz8RQHlHFZYrtznDZyMotuRfO5uC5YODhSFyLXvb1qB3WeGtF4h3Eo4KzHgMgfN2ZMlffxFRhJgTtH3ctbL8lfQoDkjeiPPnYGhspdJxr0tyZmiy0gkjJG3vwHYrLnvZWx9Wm/unqiOlGBPNuxJ+hOeP8=</Y></DSAKeyValue></KeyValue>"; s += "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>9DC4XNdQJwMRnz5pP2a6U51MHCODRilaIoVXqUPhCUb0lJdGroeqVYT84ZyIVrcarzD7Tqs3aEOIa3rKox0N1bxQpZPqayVQeLAkjLLtzJW/ScRJx3uEDJdgT1JnM1FH0GZTinmEdCUXdLc7+Y/c/qqIkTfbwHbRZjW0bBJyExM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue>"; s += "<RetrievalMethod URI=\"https://github.com/dotnet/corefx\" />"; 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>"; AssertCrypto.AssertXmlEquals("Complex", s, (info.GetXml().OuterXml)); Assert.Equal(5, info.Count); } } } }
public void TestNewKeyNode() { string uri = "http://www.go-mono.com/"; KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); uri1.Uri = uri; XmlElement xel = uri1.GetXml(); KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod(uri1.Uri); uri2.LoadXml(xel); Assert.Equal((uri1.GetXml().OuterXml), (uri2.GetXml().OuterXml)); Assert.Equal(uri, uri1.Uri); }
public void TestNewKeyNode() { string uri = "http://www.example.com/"; KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); uri1.Uri = uri; XmlElement xel = uri1.GetXml(); KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod(uri1.Uri); uri2.LoadXml(xel); Assert.AreEqual((uri1.GetXml().OuterXml), (uri2.GetXml().OuterXml), "uri1==uri2"); Assert.AreEqual(uri, uri1.Uri, "uri==Uri"); }
public void TestImportKeyNode() { string value = "<RetrievalMethod URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />"; XmlDocument doc = new XmlDocument(); doc.LoadXml(value); KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); uri1.LoadXml(doc.DocumentElement); // verify that proper XML is generated (equals to original) string s = (uri1.GetXml().OuterXml); Assert.Equal(value, s); // verify that property is parsed correctly Assert.Equal("http://www.go-mono.com/", uri1.Uri); }
public void TestImportKeyNode() { string value = "<RetrievalMethod URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />"; XmlDocument doc = new XmlDocument(); doc.LoadXml(value); KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); uri1.LoadXml(doc.DocumentElement); string s = (uri1.GetXml().OuterXml); Assert.Equal(value, s); Assert.Equal("http://www.go-mono.com/", uri1.GetUri()); }
public void InvalidKeyNode2() { string bad = "<Test></Test>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(bad); 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) Assert.AreEqual("<RetrievalMethod URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml), "invalid"); #else // Fx 1.0 misnamed the tag name Assert.AreEqual("<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml), "invalid"); #endif }
public void InvalidKeyNode1() { KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); Assert.Throws <ArgumentNullException>(() => uri1.LoadXml(null)); }
public void TestNewEmptyKeyNode() { KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); Assert.Equal("<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml)); }
public void InvalidKeyNode1() { KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod(); uri1.LoadXml(null); }