Search in sources :

Example 1 with ResponseAction

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);
}
Also used : ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction)

Example 2 with ResponseAction

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);
}
Also used : Response(javax.ws.rs.core.Response) SessionId(uk.gov.ida.hub.policy.domain.SessionId) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Example 3 with ResponseAction

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);
}
Also used : InboundResponseFromIdpDto(uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto) RequesterErrorResponseBuilder.aRequesterErrorResponse(uk.gov.ida.hub.policy.builder.domain.RequesterErrorResponseBuilder.aRequesterErrorResponse) RequesterErrorResponse(uk.gov.ida.hub.policy.domain.RequesterErrorResponse) SamlAuthnResponseTranslatorDto(uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Example 4 with ResponseAction

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);
}
Also used : InboundResponseFromIdpDto(uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto) SamlAuthnResponseTranslatorDto(uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Example 5 with ResponseAction

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);
}
Also used : InboundResponseFromIdpDto(uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto) AuthenticationErrorResponse(uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse) AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse(uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse) SamlAuthnResponseTranslatorDto(uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Aggregations

ResponseAction (uk.gov.ida.hub.policy.domain.ResponseAction)18 Test (org.junit.Test)16 SamlAuthnResponseTranslatorDto (uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto)10 InboundResponseFromIdpDto (uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto)9 Response (javax.ws.rs.core.Response)8 AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse (uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse)3 AuthenticationErrorResponse (uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse)3 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)3 SessionId (uk.gov.ida.hub.policy.domain.SessionId)3 URI (java.net.URI)1 RequesterErrorResponseBuilder.aRequesterErrorResponse (uk.gov.ida.hub.policy.builder.domain.RequesterErrorResponseBuilder.aRequesterErrorResponse)1 AttributeQueryContainerDto (uk.gov.ida.hub.policy.contracts.AttributeQueryContainerDto)1 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 RequesterErrorResponse (uk.gov.ida.hub.policy.domain.RequesterErrorResponse)1 SuccessFromIdp (uk.gov.ida.hub.policy.domain.SuccessFromIdp)1 IdpSelectedStateController (uk.gov.ida.hub.policy.domain.controller.IdpSelectedStateController)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1