use of uk.gov.ida.hub.policy.domain.RequesterErrorResponse in project verify-hub by alphagov.
the class AuthnResponseFromIdpServiceTest method shouldOnlyUpdateSessionStateWhenANonFraudRequesterErrorResponseIsReceived.
@Test
public void shouldOnlyUpdateSessionStateWhenANonFraudRequesterErrorResponseIsReceived() {
// Given
stub(idpSelectedStateController.isRegistrationContext()).toReturn(REGISTERING);
InboundResponseFromIdpDto requesterErrorResponse = InboundResponseFromIdpDtoBuilder.errorResponse(UUID.randomUUID().toString(), IdpIdaStatus.Status.RequesterError);
stub(samlEngineProxy.translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class))).toReturn(requesterErrorResponse);
// When
ResponseAction responseAction = service.receiveAuthnResponseFromIdp(sessionId, samlAuthnResponseContainerDto);
// Then
verify(samlEngineProxy).translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class));
verify(idpSelectedStateController).handleRequesterErrorResponseFromIdp(any(RequesterErrorResponse.class));
ResponseAction expectedResponseAction = ResponseAction.other(sessionId, REGISTERING);
assertThat(responseAction).isEqualToComparingFieldByField(expectedResponseAction);
verifyIdpStateControllerIsCalledWithRightDataOnNonFraudRequesterError(requesterErrorResponse);
}
use of uk.gov.ida.hub.policy.domain.RequesterErrorResponse in project verify-hub by alphagov.
the class IdpSelectedStateControllerTest method handleRequesterErrorResponseFromIdp_shouldThrowExceptionWhenIdpIsDisabled.
@Test(expected = IdpDisabledException.class)
public void handleRequesterErrorResponseFromIdp_shouldThrowExceptionWhenIdpIsDisabled() {
RequesterErrorResponse requesterErrorResponse = aRequesterErrorResponse().build();
when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(emptyList());
controller.handleRequesterErrorResponseFromIdp(requesterErrorResponse);
}
use of uk.gov.ida.hub.policy.domain.RequesterErrorResponse in project verify-hub by alphagov.
the class IdpSelectedStateControllerTest method handleRequesterErrorResponseFromIdp_shouldLogEvent.
@Test
public void handleRequesterErrorResponseFromIdp_shouldLogEvent() {
final String errorMessage = "an-error-message";
RequesterErrorResponse requesterErrorResponse = aRequesterErrorResponse().withIssuerId(IDP_ENTITY_ID).withErrorMessage(errorMessage).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).build();
when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
controller.handleRequesterErrorResponseFromIdp(requesterErrorResponse);
verify(hubEventLogger).logIdpRequesterErrorEvent(NEW_SESSION_ID, TRANSACTION_ENTITY_ID, SESSION_EXPIRY_TIMESTAMP, REQUEST_ID, Optional.fromNullable(errorMessage), PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB);
}
use of uk.gov.ida.hub.policy.domain.RequesterErrorResponse in project verify-hub by alphagov.
the class AuthnResponseFromIdpServiceTest method verifyIdpStateControllerIsCalledWithRightDataOnNonFraudRequesterError.
private void verifyIdpStateControllerIsCalledWithRightDataOnNonFraudRequesterError(InboundResponseFromIdpDto requesterErrorResponse) {
ArgumentCaptor<RequesterErrorResponse> captor = ArgumentCaptor.forClass(RequesterErrorResponse.class);
RequesterErrorResponse expectedRequesterErrorResponse = aRequesterErrorResponse().withIssuerId(requesterErrorResponse.getIssuer()).withErrorMessage(requesterErrorResponse.getStatusMessage().get()).withPrincipalIpAddressAsSeenByHub(samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub()).build();
verify(idpSelectedStateController).handleRequesterErrorResponseFromIdp(captor.capture());
RequesterErrorResponse actualRequesterErrorResponse = captor.getValue();
assertThat(actualRequesterErrorResponse).isEqualToIgnoringGivenFields(expectedRequesterErrorResponse);
}
use of uk.gov.ida.hub.policy.domain.RequesterErrorResponse in project verify-hub by alphagov.
the class AuthnResponseFromIdpService method handleRequesterError.
private ResponseAction handleRequesterError(InboundResponseFromIdpDto idaResponseFromIdp, SessionId sessionId, String principalIPAddressAsSeenByHub, IdpSelectedStateController idpSelectedStateController) {
RequesterErrorResponse requesterErrorResponse = new RequesterErrorResponse(idaResponseFromIdp.getIssuer(), idaResponseFromIdp.getStatusMessage(), principalIPAddressAsSeenByHub);
idpSelectedStateController.handleRequesterErrorResponseFromIdp(requesterErrorResponse);
return other(sessionId, idpSelectedStateController.isRegistrationContext());
}
Aggregations