use of uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto 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.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class AuthnResponseFromIdpServiceTest method shouldOnlyUpdateSessionStateWhenANonFraudRequesterPendingResponseIsReceived.
@Test
public void shouldOnlyUpdateSessionStateWhenANonFraudRequesterPendingResponseIsReceived() {
// Given
String entityId = UUID.randomUUID().toString();
InboundResponseFromIdpDto authnPendingResponse = InboundResponseFromIdpDtoBuilder.authnPendingResponse(entityId);
stub(samlEngineProxy.translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class))).toReturn(authnPendingResponse);
// When
ResponseAction responseAction = service.receiveAuthnResponseFromIdp(sessionId, samlAuthnResponseContainerDto);
// Then
verify(idpSelectedStateController).handlePausedRegistrationResponseFromIdp(entityId, PRINCIPAL_IP_ADDRESS, authnPendingResponse.getLevelOfAssurance().toJavaUtil());
ResponseAction expectedResponseAction = ResponseAction.pending(sessionId);
assertThat(responseAction).isEqualToComparingFieldByField(expectedResponseAction);
}
use of uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class AuthnResponseFromIdpServiceTest method mapAuthnCancelResponseFromIDP.
@Test
public void mapAuthnCancelResponseFromIDP() {
// Given
final boolean isRegistration = true;
stub(idpSelectedStateController.isRegistrationContext()).toReturn(isRegistration);
InboundResponseFromIdpDto noAuthenticationContextResponse = InboundResponseFromIdpDtoBuilder.errorResponse(UUID.randomUUID().toString(), IdpIdaStatus.Status.AuthenticationCancelled);
stub(samlEngineProxy.translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class))).toReturn(noAuthenticationContextResponse);
// When
ResponseAction responseAction = service.receiveAuthnResponseFromIdp(sessionId, samlAuthnResponseContainerDto);
// Then
verify(samlEngineProxy).translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class));
verifyNoMoreInteractions(samlEngineProxy);
verify(idpSelectedStateController).handleNoAuthenticationContextResponseFromIdp(any(AuthenticationErrorResponse.class));
ResponseAction expectedResponseAction = ResponseAction.cancel(sessionId, isRegistration);
assertThat(responseAction).isEqualToComparingFieldByField(expectedResponseAction);
verifyIdpStateControllerIsCalledWithRightDataOnNonFraudNoAuthenticationContext(noAuthenticationContextResponse);
}
use of uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class AuthnResponseFromIdpServiceTest method shouldOnlyUpdateSessionStateWhenAFraudSuccessfulResponseIsReceived.
@Test
public void shouldOnlyUpdateSessionStateWhenAFraudSuccessfulResponseIsReceived() {
// Given
stub(idpSelectedStateController.isRegistrationContext()).toReturn(REGISTERING);
InboundResponseFromIdpDto fraudResponseFromIdp = InboundResponseFromIdpDtoBuilder.fraudResponse(UUID.randomUUID().toString());
stub(samlEngineProxy.translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class))).toReturn(fraudResponseFromIdp);
// When
ResponseAction responseAction = service.receiveAuthnResponseFromIdp(sessionId, samlAuthnResponseContainerDto);
// Then
verify(samlEngineProxy).translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class));
ResponseAction expectedResponseAction = ResponseAction.other(sessionId, REGISTERING);
assertThat(responseAction).isEqualToComparingFieldByField(expectedResponseAction);
verifyIdpStateControllerIsCalledWithRightDataOnFraud(fraudResponseFromIdp);
}
use of uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto in project verify-hub by alphagov.
the class AuthnResponseFromIdpServiceTest method mapAuthnContextResponseFromIdpAsOther.
@Test
public void mapAuthnContextResponseFromIdpAsOther() {
// Given
final boolean isRegistration = true;
stub(idpSelectedStateController.isRegistrationContext()).toReturn(isRegistration);
InboundResponseFromIdpDto noAuthenticationContextResponse = InboundResponseFromIdpDtoBuilder.errorResponse(UUID.randomUUID().toString(), IdpIdaStatus.Status.NoAuthenticationContext);
stub(samlEngineProxy.translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class))).toReturn(noAuthenticationContextResponse);
// When
ResponseAction responseAction = service.receiveAuthnResponseFromIdp(sessionId, samlAuthnResponseContainerDto);
// Then
verify(samlEngineProxy).translateAuthnResponseFromIdp(any(SamlAuthnResponseTranslatorDto.class));
verifyNoMoreInteractions(samlEngineProxy);
verify(idpSelectedStateController).handleNoAuthenticationContextResponseFromIdp(any(AuthenticationErrorResponse.class));
ResponseAction expectedResponseAction = ResponseAction.other(sessionId, isRegistration);
assertThat(responseAction).isEqualToComparingFieldByField(expectedResponseAction);
verifyIdpStateControllerIsCalledWithRightDataOnNonFraudNoAuthenticationContext(noAuthenticationContextResponse);
}
Aggregations