use of uk.gov.ida.hub.policy.domain.ResponseAction 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.ResponseAction 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);
}
use of uk.gov.ida.hub.policy.domain.ResponseAction in project verify-hub by alphagov.
the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldHandleAuthnFailedResponse.
@Test
public void responsePost_shouldHandleAuthnFailedResponse() throws Exception {
samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.failedResponse(idpEntityId));
Response response = postIdpResponse(sessionId, samlResponseDto);
ResponseAction expected = ResponseAction.other(sessionId, true);
ResponseAction actualResponseAction = response.readEntity(ResponseAction.class);
assertThat(actualResponseAction).isEqualToComparingFieldByField(expected);
}
use of uk.gov.ida.hub.policy.domain.ResponseAction in project verify-hub by alphagov.
the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldHandAuthnSuccessResponse.
@Test
public void responsePost_shouldHandAuthnSuccessResponse() throws Exception {
LevelOfAssurance loaAchieved = LevelOfAssurance.LEVEL_2;
samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.successResponse(idpEntityId, loaAchieved));
samlEngineStub.setupStubForAttributeQueryRequest(AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto().build());
samlSoapProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
Response response = postIdpResponse(sessionId, samlResponseDto);
ResponseAction expected = ResponseAction.success(sessionId, true, loaAchieved);
ResponseAction actualResponseAction = response.readEntity(ResponseAction.class);
assertThat(actualResponseAction).isEqualToComparingFieldByField(expected);
SamlAuthnResponseTranslatorDto samlAuthnResponseTranslatorDto = samlEngineStub.getSamlAuthnResponseTranslatorDto(policy.getObjectMapper());
assertThat(samlAuthnResponseTranslatorDto.getMatchingServiceEntityId()).isEqualTo(matchingServiceEntityId);
}
use of uk.gov.ida.hub.policy.domain.ResponseAction in project verify-hub by alphagov.
the class AuthnResponseFromIdpServiceTest method mapFailedUpliftResponseFromIDP.
@Test
public void mapFailedUpliftResponseFromIDP() {
// Given
stub(idpSelectedStateController.isRegistrationContext()).toReturn(REGISTERING);
InboundResponseFromIdpDto noAuthenticationContextResponse = InboundResponseFromIdpDtoBuilder.errorResponse(UUID.randomUUID().toString(), IdpIdaStatus.Status.UpliftFailed);
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.failedUplift(sessionId, REGISTERING);
assertThat(responseAction).isEqualToComparingFieldByField(expectedResponseAction);
verifyIdpStateControllerIsCalledWithRightDataOnNonFraudNoAuthenticationContext(noAuthenticationContextResponse);
}
Aggregations