public void ThrowsExceptionWhenNullAttributeList()
            {
                // Arrange
                var statement = new AttributeStatement();
                var validator = new Saml20StatementValidator();

                statement.Items = null;

                // Act
                validator.ValidateStatement(statement);
            }
            public void ThrowsExceptionWhenAttributeElementEmptyName()
            {
                // Arrange
                var statement = new AttributeStatement();
                var validator = new Saml20StatementValidator();

                statement.Items = new object[] { new SamlAttribute() };

                // Act
                validator.ValidateStatement(statement);
            }
            public void ThrowsExceptionWhenAuthnContextAuthenticatingAuthorityUriInvalid()
            {
                // Arrange
                var statement = new AuthnStatement
                                    {
                                        AuthnInstant = DateTime.UtcNow,
                                        SessionNotOnOrAfter = DateTime.UtcNow.AddHours(1)
                                    };
                statement.AuthnContext = new AuthnContext
                                             {
                                                 AuthenticatingAuthority = new[]
                                                                               {
                                                                                   "urn:aksdlfj",
                                                                                   "urn/invalid"
                                                                               },
                                                 Items = new object[]
                                                             {
                                                                 "urn:a:valid.uri:string",
                                                                 "http://another/valid/uri.string"
                                                             },
                                                 ItemsElementName = new[]
                                                                        {
                                                                            AuthnContextType.AuthnContextClassRef,
                                                                            AuthnContextType.AuthnContextDeclRef
                                                                        }
                                             };
                var validator = new Saml20StatementValidator();

                // Act
                validator.ValidateStatement(statement);
            }
            public void ValidatesResources()
            {
                // Arrange
                var statement = new AuthzDecisionStatement();
                var validator = new Saml20StatementValidator();

                statement.Resource = string.Empty;
                var action = new Schema.Core.Action { Namespace = "http://valid/namespace" };
                statement.Action = new[] { action };
                validator.ValidateStatement(statement);

                statement.Resource = "urn:valid.ok:askjld";

                // Act
                validator.ValidateStatement(statement);
            }
            public void ThrowsExceptionWhenMissingResourceEmpty()
            {
                // Arrange
                var statement = new AuthzDecisionStatement();
                var validator = new Saml20StatementValidator();

                statement.Resource = null;

                // Act
                validator.ValidateStatement(statement);
            }
            public void ThrowsExceptionWhenMalformedResource()
            {
                // Arrange
                var statement = new AuthzDecisionStatement();
                var validator = new Saml20StatementValidator();

                statement.Resource = "a malformed uri";

                // Act
                validator.ValidateStatement(statement);
            }
            public void ThrowsExceptionWhenAuthnInstantNull()
            {
                // Arrange
                var statement = new AuthnStatement();
                var validator = new Saml20StatementValidator();

                statement.AuthnInstant = null;

                // Act
                validator.ValidateStatement(statement);
            }
            public void ThrowsExceptionWhenAuthnContextNull()
            {
                // Arrange
                var statement = new AuthnStatement
                                    {
                                        AuthnInstant = DateTime.UtcNow,
                                        SessionNotOnOrAfter = DateTime.UtcNow.AddHours(1)
                                    };
                var validator = new Saml20StatementValidator();

                // Act
                validator.ValidateStatement(statement);
            }
            public void ThrowsExceptionWhenAuthnContextItemsEmpty()
            {
                // Arrange
                var statement = new AuthnStatement
                                    {
                                        AuthnInstant = DateTime.UtcNow,
                                        SessionNotOnOrAfter = DateTime.UtcNow.AddHours(1)
                                    };
                statement.AuthnContext = new AuthnContext
                                             {
                                                 Items = new List<object>().ToArray(),
                                                 ItemsElementName = new List<AuthnContextType>().ToArray()
                                             };
                var validator = new Saml20StatementValidator();

                // Act
                validator.ValidateStatement(statement);
            }
Ejemplo n.º 10
0
            public void ThrowsExceptionWhenAuthnContextHasMoreThanTwoItems()
            {
                // Arrange
                var statement = new AuthnStatement
                                    {
                                        AuthnInstant = DateTime.UtcNow,
                                        SessionNotOnOrAfter = DateTime.UtcNow.AddHours(1)
                                    };
                statement.AuthnContext = new AuthnContext
                                             {
                                                 Items = new object[]
                                                             {
                                                                 "urn:a.valid.uri:string",
                                                                 "urn:a.valid.uri:string",
                                                                 "urn:a.valid.uri:string"
                                                             },
                                                 ItemsElementName = new[]
                                                                        {
                                                                            AuthnContextType.AuthnContextDeclRef,
                                                                            AuthnContextType.AuthnContextDeclRef,
                                                                            AuthnContextType.AuthnContextDeclRef
                                                                        }
                                             };
                var validator = new Saml20StatementValidator();

                // Act
                validator.ValidateStatement(statement);
            }
Ejemplo n.º 11
0
            public void ThrowsExceptionWhenAuthnContextAuthnContextDeclInvalid()
            {
                // Arrange
                var statement = new AuthnStatement
                                    {
                                        AuthnInstant = DateTime.UtcNow,
                                        SessionNotOnOrAfter = DateTime.UtcNow.AddHours(1)
                                    };
                statement.AuthnContext = new AuthnContext
                                             {
                                                 Items = new object[]
                                                             {
                                                                 new AuthnStatement()
                                                             },
                                                 ItemsElementName = new[]
                                                                        {
                                                                            AuthnContextType.AuthnContextDecl
                                                                        }
                                             };
                var validator = new Saml20StatementValidator();

                // Act
                validator.ValidateStatement(statement);
            }