Search in sources :

Example 56 with Assertion

use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.

the class MatchingDatasetAssertionValidatorTest method validate_shouldNotThrowAnExceptionWhenMiddleNameIsPresent_ProfileV1_1.

@Test
public void validate_shouldNotThrowAnExceptionWhenMiddleNameIsPresent_ProfileV1_1() {
    AttributeStatement attributeStatement = anEmptyMatchingDatasetAttributeStatement_1_1().withMiddleNames(aPersonName_1_1().buildAsMiddlename()).build();
    Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
    validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID);
}
Also used : AttributeStatement(org.opensaml.saml.saml2.core.AttributeStatement) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Test(org.junit.jupiter.api.Test)

Example 57 with Assertion

use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.

the class MatchingDatasetAssertionValidatorTest method validate_shouldValidateForDuplicateIds.

@Test
public void validate_shouldValidateForDuplicateIds() {
    AttributeStatement attributeStatement = anEmptyMatchingDatasetAttributeStatement_1_1().withFirstname(aPersonName_1_1().buildAsFirstname()).build();
    Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
    validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID);
    verify(duplicateAssertionValidator, times(1)).validateMatchingDataSetAssertion(matchingDatasetAssertion, RESPONSE_ISSUER_ID);
}
Also used : AttributeStatement(org.opensaml.saml.saml2.core.AttributeStatement) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Test(org.junit.jupiter.api.Test)

Example 58 with Assertion

use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.

the class MatchingDatasetAssertionValidatorTest method validate_shouldThrowExceptionWhenNameIsNotRecognised.

@Test
public void validate_shouldThrowExceptionWhenNameIsNotRecognised() {
    Attribute attribute = aSimpleStringAttribute().withName("dummy attribute").build();
    AttributeStatement attributeStatement = anEmptyMatchingDatasetAttributeStatement_1_1().addCustomAttribute(attribute).build();
    Assertion assertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
    validateFail(() -> validator.validate(assertion, RESPONSE_ISSUER_ID), mdsAttributeNotRecognised("dummy attribute"));
}
Also used : SimpleStringAttributeBuilder.aSimpleStringAttribute(uk.gov.ida.saml.core.test.builders.SimpleStringAttributeBuilder.aSimpleStringAttribute) Attribute(org.opensaml.saml.saml2.core.Attribute) SamlTransformationErrorFactory.emptyAttribute(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.emptyAttribute) AttributeStatement(org.opensaml.saml.saml2.core.AttributeStatement) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Test(org.junit.jupiter.api.Test)

Example 59 with Assertion

use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.

the class MatchingDatasetAssertionValidatorTest method validate_shouldThrowExceptionWhenAttributeValueIsIncorrectType.

@Test
public void validate_shouldThrowExceptionWhenAttributeValueIsIncorrectType() {
    Attribute attribute = aSimpleStringAttribute().withName(IdaConstants.Attributes_1_1.Firstname.NAME).withSimpleStringValue("Joe").build();
    AttributeStatement attributeStatement = aMatchingDatasetAttributeStatement_1_1().withFirstname(attribute).build();
    Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
    validateFail(() -> validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID), attributeWithIncorrectType(IdaConstants.Attributes_1_1.Firstname.NAME, PersonName.TYPE_NAME, StringBasedMdsAttributeValue.TYPE_NAME));
}
Also used : SimpleStringAttributeBuilder.aSimpleStringAttribute(uk.gov.ida.saml.core.test.builders.SimpleStringAttributeBuilder.aSimpleStringAttribute) Attribute(org.opensaml.saml.saml2.core.Attribute) SamlTransformationErrorFactory.emptyAttribute(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.emptyAttribute) AttributeStatement(org.opensaml.saml.saml2.core.AttributeStatement) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Test(org.junit.jupiter.api.Test)

Example 60 with Assertion

use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.

the class MatchingDatasetAssertionValidatorTest method validate_shouldNotThrowExceptionWhenAttributeValueVerifiedIsAbsent.

@Test
public void validate_shouldNotThrowExceptionWhenAttributeValueVerifiedIsAbsent() {
    Attribute attribute = aPersonName_1_1().addValue(aPersonNameValue().withVerified(null).build()).buildAsFirstname();
    AttributeStatement attributeStatement = aMatchingDatasetAttributeStatement_1_1().withFirstname(attribute).build();
    Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
    validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID);
}
Also used : SimpleStringAttributeBuilder.aSimpleStringAttribute(uk.gov.ida.saml.core.test.builders.SimpleStringAttributeBuilder.aSimpleStringAttribute) Attribute(org.opensaml.saml.saml2.core.Attribute) SamlTransformationErrorFactory.emptyAttribute(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.emptyAttribute) AttributeStatement(org.opensaml.saml.saml2.core.AttributeStatement) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Test(org.junit.jupiter.api.Test)

Aggregations

Assertion (org.opensaml.saml.saml2.core.Assertion)175 Test (org.junit.jupiter.api.Test)118 Response (org.opensaml.saml.saml2.core.Response)62 AssertionBuilder.anAssertion (uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion)61 EncryptedAssertion (org.opensaml.saml.saml2.core.EncryptedAssertion)58 AttributeStatement (org.opensaml.saml.saml2.core.AttributeStatement)43 Attribute (org.opensaml.saml.saml2.core.Attribute)25 DateTime (org.joda.time.DateTime)22 Element (org.w3c.dom.Element)22 NameID (org.opensaml.saml.saml2.core.NameID)20 XMLObject (org.opensaml.core.xml.XMLObject)19 PassthroughAssertion (uk.gov.ida.saml.core.domain.PassthroughAssertion)17 ValidatedResponse (uk.gov.ida.saml.security.validators.ValidatedResponse)15 Authentication (org.springframework.security.core.Authentication)14 SubjectConfirmation (org.opensaml.saml.saml2.core.SubjectConfirmation)13 Test (org.junit.Test)12 AuthnStatement (org.opensaml.saml.saml2.core.AuthnStatement)12 Conditions (org.opensaml.saml.saml2.core.Conditions)12 HashMap (java.util.HashMap)11 NameIDBuilder (org.opensaml.saml.saml2.core.impl.NameIDBuilder)11