Search in sources :

Example 6 with FraudDetectedDetails

use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.

the class MatchingServiceResponseTranslatorServiceTest method populateReturnDtoCorrectly_handleNoMatchResponse.

@Test
public void populateReturnDtoCorrectly_handleNoMatchResponse() {
    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 underlyingAssertionBlob = "underlyingAssertionBlob";
    final MatchingServiceIdaStatus status = MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService;
    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().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getEncryptedMatchingServiceAssertion().get()).isEqualTo(underlyingAssertionBlob);
    assertThat(inboundResponseFromMatchingServiceDto.getIssuer()).isEqualTo(issuer);
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().get().name()).isEqualTo(authnContext.get().name());
    assertThat(inboundResponseFromMatchingServiceDto.getStatus()).isEqualTo(status);
}
Also used : SamlResponseContainerDto(uk.gov.ida.hub.samlengine.domain.SamlResponseContainerDto) FraudDetectedDetails(uk.gov.ida.saml.core.domain.FraudDetectedDetails) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext) MatchingServiceIdaStatus(uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus) Test(org.junit.jupiter.api.Test)

Example 7 with FraudDetectedDetails

use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.

the class MatchingServiceResponseTranslatorServiceTest method populateReturnDtoCorrectly_handleUserAccountCreatedResponse.

@Test
public void populateReturnDtoCorrectly_handleUserAccountCreatedResponse() {
    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 underlyingAssertionBlob = "underlyingAssertionBlob";
    final MatchingServiceIdaStatus status = MatchingServiceIdaStatus.UserAccountCreated;
    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().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getEncryptedMatchingServiceAssertion().get()).isEqualTo(underlyingAssertionBlob);
    assertThat(inboundResponseFromMatchingServiceDto.getIssuer()).isEqualTo(issuer);
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().get().name()).isEqualTo(authnContext.get().name());
    assertThat(inboundResponseFromMatchingServiceDto.getStatus()).isEqualTo(status);
}
Also used : SamlResponseContainerDto(uk.gov.ida.hub.samlengine.domain.SamlResponseContainerDto) FraudDetectedDetails(uk.gov.ida.saml.core.domain.FraudDetectedDetails) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext) MatchingServiceIdaStatus(uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus) Test(org.junit.jupiter.api.Test)

Example 8 with FraudDetectedDetails

use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.

the class PassthroughAssertionUnmarshallerTest method transform_shouldTransformTheIdpFraudEventIdForAFraudAssertion.

@Test
public void transform_shouldTransformTheIdpFraudEventIdForAFraudAssertion() {
    String fraudEventId = "Fraud Id";
    Assertion theAssertion = anAssertion().addAuthnStatement(anAuthnStatement().withAuthnContext(anAuthnContext().withAuthnContextClassRef(anAuthnContextClassRef().withAuthnContextClasRefValue(IdaAuthnContext.LEVEL_X_AUTHN_CTX).build()).build()).build()).addAttributeStatement(anAttributeStatement().addAttribute(anIdpFraudEventIdAttribute().withValue(fraudEventId).build()).addAttribute(aGpg45StatusAttribute().build()).build()).buildUnencrypted();
    when(authnContextFactory.authnContextForLevelOfAssurance(IdaAuthnContext.LEVEL_X_AUTHN_CTX)).thenReturn(AuthnContext.LEVEL_X);
    PassthroughAssertion passthroughAssertion = unmarshaller.fromAssertion(theAssertion);
    FraudDetectedDetails fraudDetectedDetails = passthroughAssertion.getFraudDetectedDetails().get();
    assertThat(fraudDetectedDetails.getIdpFraudEventId()).isEqualTo(fraudEventId);
}
Also used : PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) FraudDetectedDetails(uk.gov.ida.saml.core.domain.FraudDetectedDetails) Test(org.junit.jupiter.api.Test)

Example 9 with FraudDetectedDetails

use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.

the class PassthroughAssertionUnmarshallerTest method transform_shouldTransformTheGpg45StatusFi01ForAFraudAssertion.

@Test
public void transform_shouldTransformTheGpg45StatusFi01ForAFraudAssertion() {
    String gpg45Status = "FI01";
    Assertion theAssertion = givenAFraudEventAssertion(gpg45Status);
    PassthroughAssertion passthroughAssertion = unmarshaller.fromAssertion(theAssertion);
    FraudDetectedDetails fraudDetectedDetails = passthroughAssertion.getFraudDetectedDetails().get();
    assertThat(fraudDetectedDetails.getFraudIndicator()).isEqualTo(gpg45Status);
}
Also used : PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) FraudDetectedDetails(uk.gov.ida.saml.core.domain.FraudDetectedDetails) Test(org.junit.jupiter.api.Test)

Example 10 with FraudDetectedDetails

use of uk.gov.ida.saml.core.domain.FraudDetectedDetails in project verify-hub by alphagov.

the class PassthroughAssertionUnmarshallerTest method transform_shouldTransformTheGpg45StatusDF01ForAFraudAssertion.

@Test
public void transform_shouldTransformTheGpg45StatusDF01ForAFraudAssertion() {
    String gpg45Status = "DF01";
    Assertion theAssertion = givenAFraudEventAssertion(gpg45Status);
    PassthroughAssertion passthroughAssertion = unmarshaller.fromAssertion(theAssertion);
    FraudDetectedDetails fraudDetectedDetails = passthroughAssertion.getFraudDetectedDetails().get();
    assertThat(fraudDetectedDetails.getFraudIndicator()).isEqualTo(gpg45Status);
}
Also used : PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) FraudDetectedDetails(uk.gov.ida.saml.core.domain.FraudDetectedDetails) Test(org.junit.jupiter.api.Test)

Aggregations

FraudDetectedDetails (uk.gov.ida.saml.core.domain.FraudDetectedDetails)10 Test (org.junit.jupiter.api.Test)9 AuthnContext (uk.gov.ida.saml.core.domain.AuthnContext)5 PassthroughAssertion (uk.gov.ida.saml.core.domain.PassthroughAssertion)5 Assertion (org.opensaml.saml.saml2.core.Assertion)4 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto)4 SamlResponseContainerDto (uk.gov.ida.hub.samlengine.domain.SamlResponseContainerDto)4 AssertionBuilder.anAssertion (uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion)4 MatchingServiceIdaStatus (uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus)4 InboundResponseFromIdpDto (uk.gov.ida.hub.samlengine.domain.InboundResponseFromIdpDto)1 PersistentId (uk.gov.ida.saml.core.domain.PersistentId)1