use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorServiceTest method populateReturnDtoCorrectly_handleRequesterError.
@Test
public void populateReturnDtoCorrectly_handleRequesterError() {
final String inResponseTo = "inResponseTo";
final String issuer = "issuer";
final Optional<AuthnContext> authnContext = Optional.empty();
final Optional<FraudDetectedDetails> fraudDetectedDetails = Optional.empty();
final String underlyingAssertionBlob = null;
final MatchingServiceIdaStatus status = MatchingServiceIdaStatus.RequesterError;
final SamlResponseContainerDto samlResponse = new SamlResponseContainerDto("saml", TEST_RP);
setUpForTranslate(authnContext, fraudDetectedDetails, underlyingAssertionBlob, inResponseTo, issuer, samlResponse.getSamlResponse(), status);
final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = matchingServiceResponseTranslatorService.translate(samlResponse);
assertThat(inboundResponseFromMatchingServiceDto.getInResponseTo()).isEqualTo(inResponseTo);
assertThat(inboundResponseFromMatchingServiceDto.getEncryptedMatchingServiceAssertion()).isNotPresent();
assertThat(inboundResponseFromMatchingServiceDto.getIssuer()).isEqualTo(issuer);
assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance()).isNotPresent();
assertThat(inboundResponseFromMatchingServiceDto.getStatus()).isEqualTo(status);
}
use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorServiceTest method populateReturnDtoCorrectly_handleMatchResponse.
@Test
public void populateReturnDtoCorrectly_handleMatchResponse() {
final String inResponseTo = "inResponseTo";
final String issuer = "issuer";
final Optional<AuthnContext> authnContext = Optional.of(AuthnContext.LEVEL_2);
final Optional<FraudDetectedDetails> fraudDetectedDetails = Optional.empty();
final String encryptedAssertion = "encryptedAssertion";
final MatchingServiceIdaStatus status = MatchingServiceIdaStatus.MatchingServiceMatch;
final SamlResponseContainerDto samlResponse = new SamlResponseContainerDto("saml", TEST_RP);
setUpForTranslate(authnContext, fraudDetectedDetails, encryptedAssertion, inResponseTo, issuer, samlResponse.getSamlResponse(), status);
final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = matchingServiceResponseTranslatorService.translate(samlResponse);
assertThat(inboundResponseFromMatchingServiceDto.getInResponseTo()).isEqualTo(inResponseTo);
assertThat(inboundResponseFromMatchingServiceDto.getEncryptedMatchingServiceAssertion().isPresent()).isTrue();
assertThat(inboundResponseFromMatchingServiceDto.getEncryptedMatchingServiceAssertion().get()).isEqualTo(encryptedAssertion);
assertThat(inboundResponseFromMatchingServiceDto.getIssuer()).isEqualTo(issuer);
assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().isPresent()).isTrue();
assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().get().name()).isEqualTo(authnContext.get().name());
assertThat(inboundResponseFromMatchingServiceDto.getStatus()).isEqualTo(status);
}
use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshallerTest method transform_shouldTransformTheGpg45StatusIt01ForAFraudAssertion.
@Test
public void transform_shouldTransformTheGpg45StatusIt01ForAFraudAssertion() {
String gpg45Status = "IT01";
Assertion theAssertion = givenAFraudEventAssertion(gpg45Status);
PassthroughAssertion passthroughAssertion = unmarshaller.fromAssertion(theAssertion);
FraudDetectedDetails fraudDetectedDetails = passthroughAssertion.getFraudDetectedDetails().get();
assertThat(fraudDetectedDetails.getFraudIndicator()).isEqualTo(gpg45Status);
}
use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshaller method fromAssertion.
public PassthroughAssertion fromAssertion(Assertion assertion) {
PersistentId persistentId = new PersistentId(assertion.getSubject().getNameID().getValue());
Optional<AuthnContext> levelOfAssurance = Optional.empty();
Optional<String> principalIpAddress = getPrincipalIpAddress(assertion.getAttributeStatements());
if (!assertion.getAuthnStatements().isEmpty()) {
String levelOfAssuranceAsString = assertion.getAuthnStatements().get(0).getAuthnContext().getAuthnContextClassRef().getAuthnContextClassRef();
levelOfAssurance = Optional.ofNullable(authnContextFactory.authnContextForLevelOfAssurance(levelOfAssuranceAsString));
}
String underlyingAssertion = assertionStringTransformer.apply(assertion);
Optional<FraudDetectedDetails> fraudDetectedDetails = Optional.empty();
if (levelOfAssurance.isPresent() && levelOfAssurance.get().equals(AuthnContext.LEVEL_X)) {
String idpFraudEventId = getIdpFraudEventId(assertion.getAttributeStatements());
fraudDetectedDetails = Optional.of(new FraudDetectedDetails(idpFraudEventId, gpg45Status(assertion.getAttributeStatements())));
}
return new PassthroughAssertion(persistentId, levelOfAssurance, underlyingAssertion, fraudDetectedDetails, principalIpAddress);
}
use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.
the class IdpAuthnResponseTranslatorServiceTest method shouldExtractFraudDetails.
@Test
public void shouldExtractFraudDetails() {
String fraudIndicator = "fraud indicator";
String fraudEventId = "fraud event id";
FraudDetectedDetails fraudDetectedDetails = Mockito.mock(FraudDetectedDetails.class);
when(fraudDetectedDetails.getFraudIndicator()).thenReturn(fraudIndicator);
when(fraudDetectedDetails.getIdpFraudEventId()).thenReturn(fraudEventId);
when(authStatementAssertion.getFraudDetectedDetails()).thenReturn(Optional.of(fraudDetectedDetails));
when(responseFromIdp.getAuthnStatementAssertion()).thenReturn(of(authStatementAssertion));
InboundResponseFromIdpDto result = translateAndCheckCommonFields();
checkAuthnStatementValues(result);
assert (result.getFraudIndicator().get()).equals(fraudIndicator);
assert (result.getIdpFraudEventId().get()).equals(fraudEventId);
}
Aggregations