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);
}
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();
}
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);
}
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);
}
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());
}
Aggregations