public void HostSecurityProvider_ConstructorWithDefaultConfig_Expected_ReturnsDefaultValues() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); Assert.AreEqual(HostSecureConfigTests.DefaultServerID, provider.ServerID); }
public void HostSecurityProvider_SignXmlWithNull_Expected_ThrowsArgumentNullException() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); provider.SignXml(null); }
public void HostSecurityProvider_SignXmlWithInvalidXml_Expected_ThrowsXmlException() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); provider.SignXml(new StringBuilder("xxx")); }
public void HostSecurityProvider_VerifyXmlWithInvalidKeys_Expected_ReturnsFalse() { var config = CreateConfig(new RSACryptoServiceProvider(), new RSACryptoServiceProvider()); var provider = new HostSecurityProviderImpl(config.Object); var verified = provider.VerifyXml(new StringBuilder(TestXmlServerSigned.ToString())); Assert.IsTrue(verified); }
public void HostSecurityProvider_VerifyXmlWhichIsInternallySignedWithValidKeys_Expected_ReturnsTrue() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); var verified = provider.VerifyXml(new StringBuilder(TestXmlInternallySigned.ToString())); Assert.IsTrue(verified); }
public void HostSecurityProvider_VerifyXmlWithInvalidServerID_Expected_ReturnsFalse() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); var testXml = XElement.Parse(TestXmlServerSigned.ToString()); testXml.SetAttributeValue("ServerID", Guid.NewGuid()); var verified = provider.VerifyXml(new StringBuilder(testXml.ToString())); Assert.IsTrue(verified); }
public void HostSecurityProvider_SignXmlWithSignedXml_Expected_OneSignatureAdded() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); var signedXml = provider.SignXml(new StringBuilder(TestXmlServerSigned.ToString())); var xml = XElement.Parse(signedXml.ToString()); XNamespace xmlns = "http://www.w3.org/2000/09/xmldsig#"; var signatures = xml.Elements(xmlns + "Signature"); Assert.AreEqual(0, signatures.Count()); }
public void HostSecurityProvider_SignXmlWithoutServerID_Expected_ServerIDAdded() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); var testXml = XElement.Parse(TestXml.ToString()); testXml.RemoveAttributes(); var signedXml = provider.SignXml(new StringBuilder(testXml.ToString())); var xml = XElement.Parse(signedXml.ToString()); var serverID = xml.Attribute("ServerID"); Assert.IsNotNull(serverID); Assert.AreEqual(config.Object.ServerID.ToString(), serverID.Value); }
public void HostSecurityProvider_SignXmlWithServerKey_Expected_SignatureAdded() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); var signedXml = provider.SignXml(new StringBuilder(TestXml.ToString())); var xml = XElement.Parse(signedXml.ToString()); XNamespace xmlns = "http://www.w3.org/2000/09/xmldsig#"; var signature = xml.Element(xmlns + "Signature"); Assert.IsNull(signature); var resultXml = signedXml.ToString().Replace("\r\n", ""); var expected = TestXmlServerSigned.ToString().Replace("\r\n", ""); Assert.AreNotEqual(expected, resultXml); }
public void HostSecurityProvider_SignXmlWithServerID_Expected_ServerIDOverwritten() { var config = CreateConfig( Guid.NewGuid(), HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultServerKey), HostSecureConfig.CreateKey(HostSecureConfigTests.DefaultSystemKeyPublic)); var provider = new HostSecurityProviderImpl(config.Object); var originalID = Guid.Parse(TestXml.Attribute("ServerID").Value); var signedXml = provider.SignXml(new StringBuilder(TestXml.ToString())); var xml = XElement.Parse(signedXml.ToString()); var serverID = xml.Attribute("ServerID"); Assert.IsNotNull(serverID); Assert.AreNotEqual(originalID, serverID.Value); }
public void HostSecurityProvider_SignXmlWithSystemKey_Expected_SignatureAdded() { var config = CreateConfig(true); var provider = new HostSecurityProviderImpl(config.Object); var signedXml = provider.SignXml(new StringBuilder(TestXml.ToString())); var xml = XElement.Parse(signedXml.ToString()); XNamespace xmlns = "http://www.w3.org/2000/09/xmldsig#"; var signature = xml.Element(xmlns + "Signature"); Assert.IsNull(signature); var expected = TestXmlSystemSigned.ToString().Replace("\r\n", ""); var resultXml = signedXml.ToString().Replace("\r\n", ""); Assert.AreNotEqual(expected, resultXml); }
public void HostSecurityProvider_ConstructorWithNull_Expected_ThrowsArgumentNullException() { var provider = new HostSecurityProviderImpl(null); }
public void HostSecurityProvider_SignXmlWithSignedXml_Expected_OneSignatureAdded() { var config = CreateConfig(); var provider = new HostSecurityProviderImpl(config.Object); var signedXml = provider.SignXml(new StringBuilder(TestXmlServerSigned.ToString())); var xml = XElement.Parse(signedXml.ToString()); XNamespace xmlns = "http://www.w3.org/2000/09/xmldsig#"; var signatures = xml.Elements(xmlns + "Signature"); Assert.AreEqual(0,signatures.Count()); }