コード例 #1
0
            public void ThrowsExceptionWhenKeyInfoConfirmationDataHasNoElements()
            {
                // Arrange
                var subjectConfirmationData = new KeyInfoConfirmationData { Recipient = "urn:wellformed.uri:ok" };
                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #2
0
            public void ThrowsExceptionWhenKeyInfoConfirmationDataHasNoElementsWithCorrectNamespace()
            {
                // Arrange
                var subjectConfirmationData = new KeyInfoConfirmationData();
                subjectConfirmationData.Recipient = "urn:wellformed.uri:ok";
                var doc = new XmlDocument();
                subjectConfirmationData.AnyElements = new[] { doc.CreateElement("ds", "KeyInfo", "http://wrongNameSpace.uri") };

                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #3
0
            public void ThrowsExceptionWhenKeyInfoConfirmationDataHasNoElementsWithValidKeyName()
            {
                // Arrange
                var subjectConfirmationData = new KeyInfoConfirmationData { Recipient = "urn:wellformed.uri:ok" };
                var doc = new XmlDocument();
                var elem = doc.CreateElement("ds", "KeyInfo", "http://wrongNameSpace.uri");
                elem.AppendChild(doc.CreateElement("ds", "KeyName", Saml20Constants.Xmldsig));

                subjectConfirmationData.AnyElements = new[] { elem };

                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #4
0
            public void ThrowsExceptionWhenKeyInfoConfirmationDataSubElementHasNoChildren()
            {
                // Arrange
                var subjectConfirmationData = new KeyInfoConfirmationData { Recipient = "urn:wellformed.uri:ok" };
                var doc = new XmlDocument();
                subjectConfirmationData.AnyElements = new[] { doc.CreateElement("ds", "KeyInfo", Saml20Constants.Xmldsig) };

                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #5
0
            public void ValidatesSubjectConfirmationDataTimeIntervalSettings()
            {
                // TODO: Split this up
                // Arrange
                var validator = new Saml20SubjectConfirmationDataValidator();

                var subjectConfirmationData = new SubjectConfirmationData();
                subjectConfirmationData.NotBefore = new DateTime(2008, 01, 30, 17, 13, 0, 500, DateTimeKind.Utc);
                subjectConfirmationData.NotOnOrAfter = subjectConfirmationData.NotBefore.Value.AddHours(1);

                validator.ValidateSubjectConfirmationData(subjectConfirmationData);

                subjectConfirmationData.NotBefore = null;
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);

                // DateTime validation wrt DateTime.UtcNow is NOT done by the validators
                // so a future-NotBefore must be valid
                subjectConfirmationData.NotBefore = subjectConfirmationData.NotOnOrAfter;
                subjectConfirmationData.NotOnOrAfter = null;
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);

                subjectConfirmationData.NotBefore = null;

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #6
0
            public void ValidatesSubjectConfirmationDataRecipient()
            {
                // Arrange
                var subjectConfirmationData = new SubjectConfirmationData { Recipient = "urn:wellformed.uri:ok" };
                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #7
0
            public void ValidatesKeyInfoConfirmationData()
            {
                // Arrange
                var subjectConfirmationData = new KeyInfoConfirmationData { Recipient = "urn:wellformed.uri:ok" };
                var doc = new XmlDocument();
                var elem = doc.CreateElement("ds", "KeyInfo", Saml20Constants.Xmldsig);
                elem.AppendChild(doc.CreateElement("lalala"));

                subjectConfirmationData.AnyElements = new[] { elem };

                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #8
0
            public void ThrowsExceptionWhenSubjectConfirmationDataTimeIntervalIsInvalid()
            {
                // Arrange
                var subjectConfirmationData = new SubjectConfirmationData();
                subjectConfirmationData.NotBefore = new DateTime(2008, 01, 30, 17, 13, 0, 500, DateTimeKind.Utc);
                subjectConfirmationData.NotOnOrAfter = subjectConfirmationData.NotBefore.Value.AddHours(-1);

                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }
コード例 #9
0
            public void ThrowsExceptionWhenSubjectConfirmationDataRecipientIsInvalid()
            {
                // Arrange
                var subjectConfirmationData = new SubjectConfirmationData { Recipient = "malformed uri" };
                var validator = new Saml20SubjectConfirmationDataValidator();

                // Act
                validator.ValidateSubjectConfirmationData(subjectConfirmationData);
            }