use of uk.gov.ida.hub.policy.domain.ResponseAction in project verify-hub by alphagov.
the class EidasSessionResourceContractTest method assertThatResponseIsSuccess.
private void assertThatResponseIsSuccess(Response response) {
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
ResponseAction expectedResult = ResponseAction.success(sessionId, false, LevelOfAssurance.LEVEL_2);
assertThat(response.readEntity(ResponseAction.class)).isEqualToComparingFieldByField(expectedResult);
}
use of uk.gov.ida.hub.policy.domain.ResponseAction in project verify-hub by alphagov.
the class EidasSessionResourceIntegrationTest method shouldReturnOkWhenSuccessAuthnResponseIsReceived.
@Test
public void shouldReturnOkWhenSuccessAuthnResponseIsReceived() throws Exception {
SessionId sessionId = selectACountry(NETHERLANDS);
samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
Response response = postAuthnResponseToPolicy(sessionId);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
ResponseAction expectedResult = ResponseAction.success(sessionId, false, LevelOfAssurance.LEVEL_2);
assertThat(response.readEntity(ResponseAction.class)).isEqualToComparingFieldByField(expectedResult);
assertThatCurrentStateForSesssionIs(sessionId, EidasCycle0And1MatchRequestSentState.class);
}
use of uk.gov.ida.hub.policy.domain.ResponseAction 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.ResponseAction 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.ResponseAction 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);
}
Aggregations