use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.
the class IPAddressValidatorTest method validate_shouldNotThrowWhenFirstAttributeStatementContainsAnIPAddressAttribute.
@Test
public void validate_shouldNotThrowWhenFirstAttributeStatementContainsAnIPAddressAttribute() throws Exception {
Assertion assertion = anAssertion().addAttributeStatement(anAttributeStatement().addAttribute(IPAddressAttributeBuilder.anIPAddress().build()).build()).buildUnencrypted();
validator.validate(assertion);
}
use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.
the class IPAddressValidatorTest method validate_shouldThrowWhenAssertionContainsAttributeStatementsButNoIPAddressAttribute.
@Test
public void validate_shouldThrowWhenAssertionContainsAttributeStatementsButNoIPAddressAttribute() throws Exception {
Assertion assertion = anAssertion().addAttributeStatement(anAttributeStatement().build()).buildUnencrypted();
validateException(SamlTransformationErrorFactory.missingIPAddress(assertion.getID()), assertion);
}
use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldThrowExceptionIfGpg45StatusIsNotRecognised.
@Test
public void transform_shouldThrowExceptionIfGpg45StatusIsNotRecognised() {
Assertions.assertThrows(IllegalStateException.class, () -> {
String gpg45Status = "status not known";
Assertion theAssertion = givenAFraudEventAssertion(gpg45Status);
unmarshaller.fromAssertion(theAssertion);
});
}
use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldTransformIpAddress.
@Test
public void transform_shouldTransformIpAddress() {
String ipAddy = "1.2.3.4";
Assertion theAssertion = anAssertion().addAttributeStatement(anAttributeStatement().addAttribute(anIPAddress().withValue(ipAddy).build()).build()).buildUnencrypted();
PassthroughAssertion authnStatementAssertion = unmarshaller.fromAssertion(theAssertion);
assertThat(authnStatementAssertion.getPrincipalIpAddressAsSeenByIdp().isPresent()).isEqualTo(true);
assertThat(authnStatementAssertion.getPrincipalIpAddressAsSeenByIdp().get()).isEqualTo(ipAddy);
}
use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldHandleFraudAuthnStatementAndSetThatAssertionIsForFraudulentEventAndSetFraudDetails.
@Test
public void transform_shouldHandleFraudAuthnStatementAndSetThatAssertionIsForFraudulentEventAndSetFraudDetails() {
final AuthnContextClassRef authnContextClassRef = anAuthnContextClassRef().withAuthnContextClasRefValue(IdaAuthnContext.LEVEL_X_AUTHN_CTX).build();
Assertion theAssertion = anAssertion().addAuthnStatement(anAuthnStatement().withAuthnContext(anAuthnContext().withAuthnContextClassRef(authnContextClassRef).build()).build()).addAttributeStatement(anAttributeStatement().addAttribute(anIdpFraudEventIdAttribute().build()).addAttribute(aGpg45StatusAttribute().build()).build()).buildUnencrypted();
when(authnContextFactory.authnContextForLevelOfAssurance(IdaAuthnContext.LEVEL_X_AUTHN_CTX)).thenReturn(AuthnContext.LEVEL_X);
when(assertionStringTransformer.apply(theAssertion)).thenReturn("AUTHN_ASSERTION");
PassthroughAssertion authnStatementAssertion = unmarshaller.fromAssertion(theAssertion);
assertThat(authnStatementAssertion.isFraudulent()).isEqualTo(true);
assertThat(authnStatementAssertion.getFraudDetectedDetails().isPresent()).isEqualTo(true);
}
Aggregations