use of uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState 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.state.Cycle3MatchRequestSentState 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.state.Cycle3MatchRequestSentState in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method getNextStateForNoMatch_shouldReturnNoMatchWhenNoAttributesArePresent.
@Test
public void getNextStateForNoMatch_shouldReturnNoMatchWhenNoAttributesArePresent() {
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
ImmutableList<UserAccountCreationAttribute> userAccountCreationAttributes = ImmutableList.of();
when(transactionsConfigProxy.getUserAccountCreationAttributes("request issuer id")).thenReturn(userAccountCreationAttributes);
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, null, null, null, transactionsConfigProxy, null, null, null);
State nextState = controller.getNextStateForNoMatch();
assertThat(nextState).isInstanceOf(NoMatchState.class);
}
use of uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState 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.state.Cycle3MatchRequestSentState 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);
}
Aggregations