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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations