Search in sources :

Example 6 with PersistentId

use of uk.gov.ida.hub.policy.domain.PersistentId in project verify-hub by alphagov.

the class AuthnResponseFromIdpServiceTest method verifyIdpStateControllerIsCalledWithRightDataOnFraud.

private void verifyIdpStateControllerIsCalledWithRightDataOnFraud(InboundResponseFromIdpDto fraudResponseFromIdp) {
    ArgumentCaptor<FraudFromIdp> captor = ArgumentCaptor.forClass(FraudFromIdp.class);
    String persistentIdName = fraudResponseFromIdp.getPersistentId().get();
    FraudDetectedDetails expectedFraudDetectedDetails = new FraudDetectedDetails(fraudResponseFromIdp.getIdpFraudEventId().get(), fraudResponseFromIdp.getFraudIndicator().get());
    FraudFromIdp fraudFromIdp = new FraudFromIdp(fraudResponseFromIdp.getIssuer(), samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub(), new PersistentId(persistentIdName), expectedFraudDetectedDetails, fraudResponseFromIdp.getPrincipalIpAddressAsSeenByIdp());
    verify(idpSelectedStateController).handleFraudResponseFromIdp(captor.capture());
    FraudFromIdp actualFraudFromIdp = captor.getValue();
    assertThat(actualFraudFromIdp).isEqualToIgnoringGivenFields(fraudFromIdp, "persistentId", "fraudDetectedDetails");
    assertThat(actualFraudFromIdp.getPersistentId().getNameId()).isEqualTo(persistentIdName);
    assertThat(actualFraudFromIdp.getFraudDetectedDetails()).isEqualToComparingFieldByField(expectedFraudDetectedDetails);
}
Also used : FraudFromIdp(uk.gov.ida.hub.policy.domain.FraudFromIdp) FraudDetectedDetails(uk.gov.ida.hub.policy.domain.FraudDetectedDetails) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId)

Example 7 with PersistentId

use of uk.gov.ida.hub.policy.domain.PersistentId in project verify-hub by alphagov.

the class IdpSelectedStateControllerTest method handleSuccessResponseFromIdp_shouldLogEventContainingLvlOfAssuranceForBillingAndPrincipalIpAddressSeenByIdpAndHub.

@Test
public void handleSuccessResponseFromIdp_shouldLogEventContainingLvlOfAssuranceForBillingAndPrincipalIpAddressSeenByIdpAndHub() {
    PersistentId persistentId = aPersistentId().withNameId("idname").build();
    SuccessFromIdp successFromIdp = aSuccessFromIdp().withIssuerId(IDP_ENTITY_ID).withPersistentId(persistentId).withPrincipalIpAddressSeenByIdp(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_IDP).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).withLevelOfAssurance(PROVIDED_LOA).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(new org.joda.time.Duration(600L));
    when(identityProvidersConfigProxy.getIdpConfig(IDP_ENTITY_ID)).thenReturn(anIdpConfigDto().withLevelsOfAssurance(LEVELS_OF_ASSURANCE).build());
    controller.handleSuccessResponseFromIdp(successFromIdp);
    verify(hubEventLogger).logIdpAuthnSucceededEvent(NEW_SESSION_ID, SESSION_EXPIRY_TIMESTAMP, IDP_ENTITY_ID, TRANSACTION_ENTITY_ID, persistentId, REQUEST_ID, LEVELS_OF_ASSURANCE.get(0), LEVELS_OF_ASSURANCE.get(1), PROVIDED_LOA, Optional.fromNullable(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_IDP), PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB);
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) SuccessFromIdpBuilder.aSuccessFromIdp(uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) PersistentIdBuilder.aPersistentId(uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId) Test(org.junit.Test)

Example 8 with PersistentId

use of uk.gov.ida.hub.policy.domain.PersistentId in project verify-hub by alphagov.

the class IdpSelectedStateControllerTest method handleSuccessResponseFromIdp_shouldThrowExceptionWhenReturnedLOAIsUnsupportedByIdpConfig.

@Test(expected = StateProcessingValidationException.class)
public void handleSuccessResponseFromIdp_shouldThrowExceptionWhenReturnedLOAIsUnsupportedByIdpConfig() {
    PersistentId persistentId = aPersistentId().withNameId("idname").build();
    SuccessFromIdp successFromIdp = aSuccessFromIdp().withIssuerId(IDP_ENTITY_ID).withPersistentId(persistentId).withPrincipalIpAddressSeenByIdp(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_IDP).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).withLevelOfAssurance(LevelOfAssurance.LEVEL_3).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(new org.joda.time.Duration(600L));
    when(identityProvidersConfigProxy.getIdpConfig(IDP_ENTITY_ID)).thenReturn(anIdpConfigDto().withLevelsOfAssurance(LEVELS_OF_ASSURANCE).build());
    controller.handleSuccessResponseFromIdp(successFromIdp);
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) SuccessFromIdpBuilder.aSuccessFromIdp(uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) PersistentIdBuilder.aPersistentId(uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId) Test(org.junit.Test)

Example 9 with PersistentId

use of uk.gov.ida.hub.policy.domain.PersistentId in project verify-hub by alphagov.

the class AuthnResponseFromIdpServiceTest method verifyIdpStateControllerIsCalledWithRightDataOnSuccess.

private void verifyIdpStateControllerIsCalledWithRightDataOnSuccess(InboundResponseFromIdpDto successResponseFromIdp) {
    ArgumentCaptor<SuccessFromIdp> captor = ArgumentCaptor.forClass(SuccessFromIdp.class);
    PersistentId persistentId = PersistentIdBuilder.aPersistentId().withNameId(successResponseFromIdp.getPersistentId().get()).build();
    SuccessFromIdp expectedSuccessFromIdp = SuccessFromIdpBuilder.aSuccessFromIdp().withIssuerId(successResponseFromIdp.getIssuer()).withEncryptedMatchingDatasetAssertion(successResponseFromIdp.getEncryptedMatchingDatasetAssertion().get()).withAuthnStatementAssertion(successResponseFromIdp.getAuthnStatementAssertionBlob().get()).withPersistentId(persistentId).withLevelOfAssurance(successResponseFromIdp.getLevelOfAssurance().get()).withPrincipalIpAddressAsSeenByHub(samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub()).withPrincipalIpAddressSeenByIdp(successResponseFromIdp.getPrincipalIpAddressAsSeenByIdp().get()).build();
    verify(idpSelectedStateController).handleSuccessResponseFromIdp(captor.capture());
    SuccessFromIdp actualSuccessFromIdp = captor.getValue();
    assertThat(actualSuccessFromIdp).isEqualToIgnoringGivenFields(expectedSuccessFromIdp, "persistentId");
    assertThat(actualSuccessFromIdp.getPersistentId().getNameId()).isEqualTo(persistentId.getNameId());
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId)

Example 10 with PersistentId

use of uk.gov.ida.hub.policy.domain.PersistentId in project verify-hub by alphagov.

the class AuthnResponseFromCountryService method getEidasAttributeQueryRequestDto.

private EidasAttributeQueryRequestDto getEidasAttributeQueryRequestDto(CountrySelectedStateController stateController, InboundResponseFromCountry response) {
    final String matchingServiceEntityId = stateController.getMatchingServiceEntityId();
    MatchingServiceConfigEntityDataDto matchingServiceConfig = matchingServiceConfigProxy.getMatchingService(matchingServiceEntityId);
    return new EidasAttributeQueryRequestDto(stateController.getRequestId(), stateController.getRequestIssuerEntityId(), stateController.getAssertionConsumerServiceUri(), assertionRestrictionFactory.getAssertionExpiry(), matchingServiceEntityId, matchingServiceConfig.getUri(), DateTime.now().plus(policyConfiguration.getMatchingServiceResponseWaitPeriod()), matchingServiceConfig.isOnboarding(), response.getLevelOfAssurance().get(), new PersistentId(response.getPersistentId().get()), Optional.absent(), Optional.absent(), response.getEncryptedIdentityAssertionBlob().get());
}
Also used : MatchingServiceConfigEntityDataDto(uk.gov.ida.hub.policy.contracts.MatchingServiceConfigEntityDataDto) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId)

Aggregations

PersistentId (uk.gov.ida.hub.policy.domain.PersistentId)13 Test (org.junit.Test)8 SuccessFromIdp (uk.gov.ida.hub.policy.domain.SuccessFromIdp)6 PersistentIdBuilder.aPersistentId (uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId)4 SuccessFromIdpBuilder.aSuccessFromIdp (uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp)4 SessionId (uk.gov.ida.hub.policy.domain.SessionId)3 EidasAttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto)2 FraudDetectedDetails (uk.gov.ida.hub.policy.domain.FraudDetectedDetails)2 FraudFromIdp (uk.gov.ida.hub.policy.domain.FraudFromIdp)2 HashMap (java.util.HashMap)1 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 MatchingServiceConfigEntityDataDto (uk.gov.ida.hub.policy.contracts.MatchingServiceConfigEntityDataDto)1 Cycle3Dataset (uk.gov.ida.hub.policy.domain.Cycle3Dataset)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 EidasAwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState)1 EidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState)1 EidasCycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle3MatchRequestSentState)1