[Ignore] // TODO: test data needs fixing public void AddAttribute() { // Arrange var assertion = new Saml20Assertion(AssertionUtil.LoadXmlDocument(@"Assertions\Saml2Assertion_01").DocumentElement, null, false, TestConfiguration.Configuration); var attributes = assertion.Attributes; // This needs to be addressed and is why the test is ignored. See the original Hg project attributes.Add(new SamlAttribute()); var cert = AssertionUtil.GetCertificate(); assertion.Sign(cert, null); assertion.CheckValid(new[] { cert.PublicKey.Key }); // Verify that the modified assertion can survive complete serialization and deserialization. var assertionString = assertion.GetXml().OuterXml; var deserializedAssertionDoc = new XmlDocument { PreserveWhitespace = true }; deserializedAssertionDoc.Load(new StringReader(assertionString)); var deserializedAssertion = new Saml20Assertion(deserializedAssertionDoc.DocumentElement, null, false, TestConfiguration.Configuration); Assert.IsNotNull(deserializedAssertion.GetSignatureKeys(), "Signing keys must be present"); deserializedAssertion.CheckValid(new[] { cert.PublicKey.Key }); }
public void AddAttribute() { // Arrange var assertion = new Saml20Assertion(AssertionUtil.LoadXmlDocument(TestContext.CurrentContext.TestDirectory + @"\Assertions\Saml2Assertion_01").DocumentElement, null, false); var attributes = assertion.Attributes; attributes.Add(new SamlAttribute()); var cert = AssertionUtil.GetCertificate(); assertion.Sign(cert); assertion.CheckValid(new[] { cert.PublicKey.Key }); // Verify that the modified assertion can survive complete serialization and deserialization. var assertionString = assertion.GetXml().OuterXml; var deserializedAssertionDoc = new XmlDocument { PreserveWhitespace = true }; deserializedAssertionDoc.Load(new StringReader(assertionString)); var deserializedAssertion = new Saml20Assertion(deserializedAssertionDoc.DocumentElement, null, false); Assert.IsNotNull(deserializedAssertion.GetSignatureKeys(), "Signing keys must be present"); deserializedAssertion.CheckValid(new[] { cert.PublicKey.Key }); }
public void HasNoAssertionBeforeDecrypt() { // Arrange var doc = AssertionUtil.LoadXmlDocument(TestContext.CurrentContext.TestDirectory + @"\Assertions\EncryptedAssertion_01"); var cert = new X509Certificate2(TestContext.CurrentContext.TestDirectory + @"\Certificates\sts_dev_certificate.pfx", "test1234"); // Act var encryptedAssertion = new Saml20EncryptedAssertion((RSA)cert.PrivateKey, doc); // Assert Assert.IsNull(encryptedAssertion.Assertion); }
public void CanDecryptAssertionWithPeerIncludedKeysWithoutSpecifiedEncryptionMethod() { // Arrange var doc = AssertionUtil.LoadXmlDocument(TestContext.CurrentContext.TestDirectory + @"\Assertions\EncryptedAssertion_03"); var cert = new X509Certificate2(TestContext.CurrentContext.TestDirectory + @"\Certificates\sts_dev_certificate.pfx", "test1234"); var encryptedAssertion = new Saml20EncryptedAssertion((RSA)cert.PrivateKey, doc); // Act encryptedAssertion.Decrypt(); // Assert Assert.IsNotNull(encryptedAssertion.Assertion); }
public void CanDecryptAssertionWithPeerIncludedKeys() { // Arrange var doc = AssertionUtil.LoadXmlDocument(@"Assertions\EncryptedAssertion_02"); var cert = new X509Certificate2(@"Certificates\sts_dev_certificate.pfx", "test1234"); var encryptedAssertion = new Saml20EncryptedAssertion((RSA)cert.PrivateKey, doc); // Act encryptedAssertion.Decrypt(); // Assert Assert.IsNotNull(encryptedAssertion.Assertion); }
public void CanReadAttributes() { // Act var assertion = new Saml20Assertion(AssertionUtil.LoadXmlDocument(@"Assertions\Saml2Assertion_01").DocumentElement, null, false, TestConfiguration.Configuration); // Assert CollectionAssert.IsNotEmpty(assertion.Attributes); Assert.AreEqual(4, assertion.Attributes.Count); foreach (var sa in assertion.Attributes) { Assert.That(sa.AttributeValue.Length != 0, "Attribute should have a value"); } }
public void CanDecryptAssertionWithPeerIncludedAesKeys() { // Arrange var doc = AssertionUtil.LoadXmlDocument(TestContext.CurrentContext.TestDirectory + @"\Assertions\EncryptedAssertion_05"); var cert = new X509Certificate2(TestContext.CurrentContext.TestDirectory + @"\Certificates\sts_dev_certificate.pfx", "test1234"); var encryptedAssertion = new Saml20EncryptedAssertion((RSA)cert.PrivateKey, doc); // Act encryptedAssertion.Decrypt(); // Assert Assert.IsNotNull(encryptedAssertion.Assertion); Assert.AreEqual(1, encryptedAssertion.Assertion.GetElementsByTagName(Assertion.ElementName, Saml20Constants.Assertion).Count); }
public void CanDecryptAssertion() { // Arrange var doc = AssertionUtil.LoadXmlDocument(@"Assertions\EncryptedAssertion_01"); var cert = new X509Certificate2(@"Certificates\sts_dev_certificate.pfx", "test1234"); var encryptedAssertion = new Saml20EncryptedAssertion((RSA)cert.PrivateKey, doc); // Act encryptedAssertion.Decrypt(); var assertion = new Saml20Assertion(encryptedAssertion.Assertion.DocumentElement, null, false, TestConfiguration.Configuration); // Assert Assert.IsNotNull(encryptedAssertion.Assertion); }