[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 });
            }
Ejemplo n.º 2
0
            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 });
            }