use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink.
@Test
public void cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
final EventSinkHubEvent eventSinkHubEvent = argumentCaptor.getValue();
assertThat(eventSinkHubEvent.getEventType()).isEqualTo(EventSinkHubEventConstants.EventTypes.SESSION_EVENT);
assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
assertThat(eventSinkHubEvent.getSessionId()).isEqualTo(sessionId.getSessionId());
assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.request_id)).isEqualTo(requestId);
assertThat(eventSinkHubEvent.getOriginatingService()).isEqualTo(serviceInfo.getName());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink.
@Test
public void cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, mock(StateTransitionAction.class), policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isNotEqualTo(CYCLE3_MATCH);
assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState.
@Test
public void shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, responseFromHubFactory, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
final ResponseFromHub responseFromHub = controller.getErrorResponse();
assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived.
@Test
public void shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
ResponseProcessingDetails responseProcessingDetails = controller.getResponseProcessingDetails();
assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.WAIT);
assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest.
@Test(expected = StateProcessingValidationException.class)
public void responseFromMatchingService_shouldThrowExceptionWhenInResponseToDoesNotMatchFromCycle3MatchRequest() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, policyConfiguration, mock(LevelOfAssuranceValidator.class), null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(matchingServiceEntityId, "definitelyNotTheSameRequestId", "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
}
Aggregations