Exemple #1
0
        public void ReadToken(SamlTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.ReadToken", theoryData);

            try
            {
                theoryData.Handler.ReadToken(theoryData.Token);
                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
Exemple #2
0
        public void RoundTripToken(SamlTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.RoundTripToken", theoryData);

            try
            {
                var samlToken = theoryData.Handler.CreateToken(theoryData.TokenDescriptor);
                var token     = theoryData.Handler.WriteToken(samlToken);
                var principal = theoryData.Handler.ValidateToken(token, theoryData.ValidationParameters, out SecurityToken validatedToken);
                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
        public void SamlSecurityTokenReadFrom(SamlTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.SamlSecurityTokenReadFrom", theoryData);

            try
            {
                var sr        = new StringReader(theoryData.SamlTokenTestSet.Xml);
                var reader    = XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(sr));
                var assertion = theoryData.SamlSerializer.ReadAssertion(reader);
                theoryData.ExpectedException.ProcessNoException(context);

                IdentityComparer.AreEqual(assertion, (theoryData.SamlTokenTestSet.SecurityToken as SamlSecurityToken).Assertion, context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
Exemple #4
0
        public void CanReadToken(SamlTheoryData theoryData)
        {
            var context = TestUtilities.WriteHeader($"{this}.CanReadToken", theoryData);

            try
            {
                if (theoryData.CanRead != theoryData.Handler.CanReadToken(theoryData.Token))
                {
                    Assert.False(true, $"Expected CanRead != CanRead, token: {theoryData.Token}");
                }

                theoryData.ExpectedException.ProcessNoException(context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }
Exemple #5
0
        public void CreateClaimsIdentities(SamlTheoryData theoryData)
        {
            TestUtilities.WriteHeader($"{this}.CreateClaimsIdentities", theoryData);
            var context = new CompareContext($"{this}.CreateClaimsIdentities, {theoryData.TestId}")
            {
                IgnoreType = true
            };

            try
            {
                var identities = ((theoryData.Handler) as SamlSecurityTokenHandlerPublic).CreateClaimsIdentitiesPublic(theoryData.TokenTestSet.SecurityToken as SamlSecurityToken, theoryData.Issuer, theoryData.ValidationParameters);
                theoryData.ExpectedException.ProcessNoException(context);

                IdentityComparer.AreEqual(identities, theoryData.TokenTestSet.Identities, context);
            }
            catch (Exception ex)
            {
                theoryData.ExpectedException.ProcessException(ex, context);
            }

            TestUtilities.AssertFailIfErrors(context);
        }