Search in sources :

Example 26 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class SessionTimeoutExceptionMapperTest method toResponse_shouldLogToEventSink.

@Test
public void toResponse_shouldLogToEventSink() throws Exception {
    when(servletRequest.getParameter(Urls.SharedUrls.SESSION_ID_PARAM)).thenReturn("42");
    SessionTimeoutExceptionMapper mapper = new SessionTimeoutExceptionMapper(hubEventLogger);
    mapper.setHttpServletRequest(servletRequest);
    SessionId sessionId = aSessionId().build();
    DateTime sessionExpiryTimestamp = DateTime.now().minusMinutes(10);
    String transactionEntityId = "some entity id";
    String requestId = "some request id";
    SessionTimeoutException exception = new SessionTimeoutException("Timeout exception", sessionId, transactionEntityId, sessionExpiryTimestamp, requestId);
    mapper.toResponse(exception);
    verify(hubEventLogger).logSessionTimeoutEvent(sessionId, sessionExpiryTimestamp, transactionEntityId, requestId);
}
Also used : SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionIdBuilder.aSessionId(uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 27 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class Cycle3ServiceTest method shouldProcessCancellationAfterReceivingCancelCycle3DataInputForEidasFlow.

@Test
public void shouldProcessCancellationAfterReceivingCancelCycle3DataInputForEidasFlow() {
    SessionId eidasSessionId = SessionIdBuilder.aSessionId().build();
    when(sessionRepository.getStateController(eidasSessionId, AbstractAwaitingCycle3DataState.class)).thenReturn(eidasAwaitingCycle3DataStateController);
    doNothing().when(eidasAwaitingCycle3DataStateController).handleCancellation();
    service.cancelCycle3DataInput(eidasSessionId);
    verify(eidasAwaitingCycle3DataStateController).handleCancellation();
}
Also used : SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 28 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class Cycle3ServiceTest method shouldReturnCycle3AttributeRequestDataAfterReceivingCycle3AttributeRequestDataForEidasFlow.

@Test
public void shouldReturnCycle3AttributeRequestDataAfterReceivingCycle3AttributeRequestDataForEidasFlow() {
    SessionId eidasSessionId = SessionIdBuilder.aSessionId().build();
    when(sessionRepository.getStateController(eidasSessionId, AbstractAwaitingCycle3DataState.class)).thenReturn(eidasAwaitingCycle3DataStateController);
    when(eidasAwaitingCycle3DataStateController.getCycle3AttributeRequestData()).thenReturn(ATTRIBUTE_REQUEST_DATA);
    Cycle3AttributeRequestData result = service.getCycle3AttributeRequestData(eidasSessionId);
    assertThat(result).isEqualTo(ATTRIBUTE_REQUEST_DATA);
}
Also used : Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 29 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class SessionServiceTest method getSession_ReturnSessionIdWhenSessionExists.

@Test
public void getSession_ReturnSessionIdWhenSessionExists() throws Exception {
    SessionId sessionId = createNewSessionId();
    when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
    assertThat(service.getSessionIfItExists(sessionId)).isEqualTo(sessionId);
}
Also used : SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionId.createNewSessionId(uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId) Test(org.junit.Test)

Example 30 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class SessionServiceTest method sendErrorResponseFromHub_shouldReturnDtoWithSamlRequestPostLocationAndRelayState.

@Test
public void sendErrorResponseFromHub_shouldReturnDtoWithSamlRequestPostLocationAndRelayState() throws Exception {
    SessionId sessionId = createNewSessionId();
    when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
    ResponseFromHub responseFromHub = aResponseFromHubDto().withRelayState("relayState").build();
    when(authnRequestHandler.getErrorResponseFromHub(sessionId)).thenReturn(responseFromHub);
    final SamlMessageDto samlMessageDto = new SamlMessageDto("saml");
    when(samlEngineProxy.generateErrorResponseFromHub(any())).thenReturn(samlMessageDto);
    AuthnResponseFromHubContainerDto dto = service.getRpErrorResponse(sessionId);
    assertThat(dto.getSamlResponse()).isEqualTo(samlMessageDto.getSamlMessage());
    assertThat(dto.getPostEndpoint()).isEqualTo(responseFromHub.getAssertionConsumerServiceUri());
    assertThat(dto.getRelayState()).isEqualTo(responseFromHub.getRelayState());
    assertThat(dto.getResponseId()).isEqualTo(responseFromHub.getResponseId());
}
Also used : AuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto) AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.builder.AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto) SamlMessageDto(uk.gov.ida.hub.policy.contracts.SamlMessageDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionId.createNewSessionId(uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Aggregations

SessionId (uk.gov.ida.hub.policy.domain.SessionId)92 Test (org.junit.Test)83 Response (javax.ws.rs.core.Response)41 URI (java.net.URI)33 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)14 SessionId.createNewSessionId (uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId)13 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)12 Matchers.anyString (org.mockito.Matchers.anyString)9 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)9 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)6 MatchingServiceRequestErrorState (uk.gov.ida.hub.policy.domain.state.MatchingServiceRequestErrorState)6 SessionIdBuilder.aSessionId (uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId)5 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto)5 Cycle3AttributeRequestData (uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)5 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)5 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)5 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)5 SamlRequestDto (uk.gov.ida.hub.policy.contracts.SamlRequestDto)4 SamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto)4 AuthnRequestFromHubContainerDto (uk.gov.ida.hub.policy.domain.AuthnRequestFromHubContainerDto)4