예제 #1
0
        public void AND_deve_retornar_instancia_do_tipo_and_assertion()
        {
            Assertion assert = new Assertion();
            IAssertion assertAnd = assert.AND(assert);

            Assert.IsTrue(assertAnd.GetType() == typeof(AndAssertion));
        }
예제 #2
0
        /// <summary>
        /// Returns the <c>Saml20Assertion</c> as an XmlDocument as used by the Assertion class.
        /// </summary>
        /// <param name="assertion">The assertion.</param>
        /// <returns>The XML document.</returns>
        public static XmlDocument ConvertAssertionToXml(Assertion assertion)
        {
            if (assertion == null)
            {
                throw new ArgumentNullException("assertion");
            }

            var res = new XmlDocument { PreserveWhitespace = true };
            res.Load(new StringReader(Serialization.SerializeToXmlString(assertion)));

            return res;
        }
예제 #3
0
        public void do_validation_com_sucesso()
        {
            List<string> lista = new List<string>();
            lista.Add("item");
            Assertion assert = new Assertion();

            var specification = typeof(Assertion).GetProperty("Specification", BindingFlags.Public | BindingFlags.Instance);
            specification.SetValue(assert, CompositeSpecification.Null(new object()), new object[] { });

            var mesagem = typeof(Assertion).GetProperty("Message", BindingFlags.Public | BindingFlags.Instance);
            mesagem.SetValue(assert, "item", new object[] { });

            assert.DoValidation(lista);
            Assert.IsTrue(lista.Count == 2);
        }
예제 #4
0
 public void assert_equals_e_falso()
 {
     Assertion assertion = new Assertion();
     Assert.IsFalse(assertion.Equals(new object()));
 }
예제 #5
0
        public void OR_assertion_com_sucesso()
        {
            Assertion assertion = new Assertion();

            var OR = assertion.OR(assertion);

            Assert.IsAssignableFrom<OrAssertion>(OR);
        }
예제 #6
0
        public void or_assertion_com_sucesso()
        {
            Assertion assertion = new Assertion();

            var or = assertion.or(assertion);

            Assert.IsAssignableFrom<orAssertion>(or);
        }
예제 #7
0
        public void not_assertion_com_sucesso()
        {
            Assertion assertion = new Assertion();

            var not = assertion.Not();

            Assert.IsAssignableFrom<NotAssertion>(not);
        }
예제 #8
0
        public void nao_existe_http_context()
        {
            Assertion assert = new Assertion();
            var httpContext = typeof(Assertion).GetProperty("HasHttpContext", BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.IsFalse((bool)httpContext.GetValue(assert, new object[] { }));
        }
예제 #9
0
        public void is_valid_e_verdadeiro()
        {
            Assertion assertion = new Assertion();

            var specification = typeof(Assertion).GetProperty("Specification", BindingFlags.Public | BindingFlags.Instance);
            specification.SetValue(assertion, CompositeSpecification.Null(null), new object[] { });

            Assert.IsTrue(assertion.IsValid());
        }
예제 #10
0
        public void iniciar_assertion_com_sucesso()
        {
            Assertion assertion = new Assertion();

            Assert.NotNull(assertion);
        }
예제 #11
0
        /// <summary>
        /// Assembles our basic test assertion
        /// </summary>
        /// <returns>The <see cref="Assertion"/>.</returns>
        public static Assertion GetBasicAssertion()
        {
            var assertion = new Assertion
                                {
                                    Issuer = new NameId(),
                                    Id = "_b8977dc86cda41493fba68b32ae9291d",
                                    IssueInstant = DateTime.UtcNow,
                                    Version = "2.0"
                                };

            assertion.Issuer.Value = GetBasicIssuer();
            assertion.Subject = new Subject();
            var subjectConfirmation = new SubjectConfirmation
            {
                Method = SubjectConfirmation.BearerMethod,
                SubjectConfirmationData =
                    new SubjectConfirmationData
                    {
                        NotOnOrAfter = new DateTime(2008, 12, 31, 12, 0, 0, 0),
                        Recipient = "http://borger.dk"
                    }
            };
            assertion.Subject.Items = new object[] { subjectConfirmation };
            assertion.Conditions = new Conditions { NotOnOrAfter = new DateTime(2008, 12, 31, 12, 0, 0, 0) };
            var audienceRestriction = new AudienceRestriction { Audience = GetAudiences().Select(u => u.ToString()).ToList() };
            assertion.Conditions.Items = new List<ConditionAbstract>(new ConditionAbstract[] { audienceRestriction });

            AuthnStatement authnStatement;
            {
                authnStatement = new AuthnStatement();
                assertion.Items = new StatementAbstract[] { authnStatement };
                authnStatement.AuthnInstant = new DateTime(2008, 1, 8);
                authnStatement.SessionIndex = "70225885";
                authnStatement.AuthnContext = new AuthnContext
                                                  {
                                                      Items = new object[]
                                                                  {
                                                                      "urn:oasis:names:tc:SAML:2.0:ac:classes:X509",
                                                                      "http://www.safewhere.net/authncontext/declref"
                                                                  },
                                                      ItemsElementName = new[]
                                                                             {
                                                                                 AuthnContextType.AuthnContextClassRef,
                                                                                 AuthnContextType.AuthnContextDeclRef
                                                                             }
                                                  };
            }

            AttributeStatement attributeStatement;
            {
                attributeStatement = new AttributeStatement();
                var surName = new SamlAttribute
                    {
                        FriendlyName = "SurName",
                        Name = "urn:oid:2.5.4.4",
                        NameFormat = SamlAttribute.NameformatUri,
                        AttributeValue = new[] { "Fry" }
                    };

                var commonName = new SamlAttribute
                    {
                        FriendlyName = "CommonName",
                        Name = "urn:oid:2.5.4.3",
                        NameFormat = SamlAttribute.NameformatUri,
                        AttributeValue = new[] { "Philip J. Fry" }
                    };

                var userName = new SamlAttribute
                    {
                        Name = "urn:oid:0.9.2342.19200300.100.1.1",
                        NameFormat = SamlAttribute.NameformatUri,
                        AttributeValue = new[] { "fry" }
                    };

                var email = new SamlAttribute
                    {
                        FriendlyName = "Email",
                        Name = "urn:oid:0.9.2342.19200300.100.1.3",
                        NameFormat = SamlAttribute.NameformatUri,
                        AttributeValue = new[] { "*****@*****.**" }
                    };

                attributeStatement.Items = new object[] { surName, commonName, userName, email };
            }

            assertion.Items = new StatementAbstract[] { authnStatement, attributeStatement };

            return assertion;
        }
예제 #12
0
 /// <summary>Asserts that two ints are equal. If they are not
 /// an <see cref="AssertionException"/> is thrown.</summary>
 static public void AssertEquals(int expected, int actual)
 {
     Assertion.AssertEquals(string.Empty, expected, actual);
 }
예제 #13
0
 /// <summary>
 /// /// Asserts that two singles are equal concerning a delta. If the
 /// expected value is infinity then the delta value is ignored.
 /// </summary>
 /// <param name="expected">The expected value</param>
 /// <param name="actual">The actual value</param>
 /// <param name="delta">The maximum acceptable difference between the
 /// the expected and the actual</param>
 static public void AssertEquals(float expected, float actual, float delta)
 {
     Assertion.AssertEquals(string.Empty, expected, actual, delta);
 }
예제 #14
0
 /// <summary>
 /// /// Asserts that two doubles are equal concerning a delta. If the
 /// expected value is infinity then the delta value is ignored.
 /// </summary>
 /// <param name="expected">The expected value</param>
 /// <param name="actual">The actual value</param>
 /// <param name="delta">The maximum acceptable difference between the
 /// the expected and the actual</param>
 static public void AssertEquals(double expected, double actual, double delta)
 {
     Assertion.AssertEquals(string.Empty, expected, actual, delta);
 }
예제 #15
0
 /// <summary>
 /// Asserts that a condition is true. If it isn't it throws
 /// an <see cref="AssertionException"/>.
 /// </summary>
 /// <param name="condition">The evaluated condition</param>
 static public void Assert(bool condition)
 {
     Assertion.Assert(string.Empty, condition);
 }