use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class MatchingDatasetAssertionValidatorTest method validate_shouldNotThrowExceptionWhenAttributeValueToDateIsAbsent.
@Test
public void validate_shouldNotThrowExceptionWhenAttributeValueToDateIsAbsent() {
Attribute attribute = aPersonName_1_1().addValue(aPersonNameValue().withTo(null).build()).buildAsFirstname();
AttributeStatement attributeStatement = aMatchingDatasetAttributeStatement_1_1().withFirstname(attribute).build();
Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID);
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class MatchingDatasetAssertionValidatorTest method validate_shouldNotThrowAnExceptionWhenDateOfBirthIsPresent_ProfileV1_1.
@Test
public void validate_shouldNotThrowAnExceptionWhenDateOfBirthIsPresent_ProfileV1_1() {
AttributeStatement attributeStatement = anEmptyMatchingDatasetAttributeStatement_1_1().withDateOfBirth().build();
Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID);
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class IdaResponseFromIdpUnmarshallerTest method transform_shouldTransformTheSamlResponseToIdaResponseByIdp.
@Test
public void transform_shouldTransformTheSamlResponseToIdaResponseByIdp() {
Assertion mdsAssertion = anAssertion().addAttributeStatement(anAttributeStatement().build()).buildUnencrypted();
Assertion authnStatementAssertion = anAssertion().addAuthnStatement(anAuthnStatement().build()).buildUnencrypted();
when(response.getAssertions()).thenReturn(List.of(mdsAssertion, authnStatementAssertion));
PassthroughAssertion passthroughMdsAssertion = aPassthroughAssertion().buildMatchingDatasetAssertion();
when(passthroughAssertionUnmarshaller.fromAssertion(mdsAssertion)).thenReturn(passthroughMdsAssertion);
PassthroughAssertion passthroughAuthnAssertion = aPassthroughAssertion().buildAuthnStatementAssertion();
when(passthroughAssertionUnmarshaller.fromAssertion(authnStatementAssertion)).thenReturn(passthroughAuthnAssertion);
InboundResponseFromIdp inboundResponseFromIdp = unmarshaller.fromSaml(new ValidatedResponse(response), new ValidatedAssertions(response.getAssertions()));
assertThat(inboundResponseFromIdp.getSignature().isPresent()).isEqualTo(true);
assertThat(inboundResponseFromIdp.getMatchingDatasetAssertion().isPresent()).isEqualTo(true);
assertThat(inboundResponseFromIdp.getAuthnStatementAssertion().isPresent()).isEqualTo(true);
assertThat(inboundResponseFromIdp.getSignature().get()).isEqualTo(signature);
assertThat(inboundResponseFromIdp.getAuthnStatementAssertion().get()).isEqualTo(passthroughAuthnAssertion);
assertThat(inboundResponseFromIdp.getMatchingDatasetAssertion().get()).isEqualTo(passthroughMdsAssertion);
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class ResponseAssertionsFromIdpValidatorTest method validate_shouldDelegateToIpAddressValidator.
@Test
public void validate_shouldDelegateToIpAddressValidator() throws Exception {
Assertion authnStatementAssertion = anAssertion().addAuthnStatement(anAuthnStatement().build()).buildUnencrypted();
Response response = aResponse().addEncryptedAssertion(anAssertion().addAttributeStatement(aMatchingDatasetAttributeStatement_1_1().build()).build()).addEncryptedAssertion(anAssertion().addAuthnStatement(anAuthnStatement().build()).build()).build();
List<Assertion> assertions = asList(anAssertion().addAttributeStatement(aMatchingDatasetAttributeStatement_1_1().build()).buildUnencrypted(), authnStatementAssertion);
validator.validate(new ValidatedResponse(response), new ValidatedAssertions(assertions));
verify(ipAddressValidator).validate(authnStatementAssertion);
}
use of org.opensaml.saml2.core.Assertion in project verify-hub by alphagov.
the class ResponseAssertionsFromIdpValidatorTest method validate_shouldThrowExceptionIfAuthnStatementAssertionIsMissing.
@Test
public void validate_shouldThrowExceptionIfAuthnStatementAssertionIsMissing() throws Exception {
Response response = aResponse().addEncryptedAssertion(anAssertion().addAttributeStatement(aMatchingDatasetAttributeStatement_1_1().build()).build()).addEncryptedAssertion(anAssertion().addAttributeStatement(aMatchingDatasetAttributeStatement_1_1().build()).build()).build();
List<Assertion> assertions = asList(anAssertion().addAttributeStatement(aMatchingDatasetAttributeStatement_1_1().build()).buildUnencrypted(), anAssertion().addAttributeStatement(aMatchingDatasetAttributeStatement_1_1().build()).buildUnencrypted());
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(new ValidatedResponse(response), new ValidatedAssertions(assertions))), SamlTransformationErrorFactory.missingAuthnStatement());
}
Aggregations