use of uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState in project verify-hub by alphagov.
the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldGetAwaitingCycle3DataStateWhenTransactionSupportsCycle3.
@Test
public void getNextState_shouldGetAwaitingCycle3DataStateWhenTransactionSupportsCycle3() {
// Given
when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(matchingProcess);
when(matchingProcess.getAttributeName()).thenReturn(Optional.of("somestring"));
// When
final State nextState = controller.getNextStateForNoMatch();
// Then
assertThat(nextState).isInstanceOf(AwaitingCycle3DataState.class);
assertThat(((AwaitingCycle3DataState) nextState).getEncryptedMatchingDatasetAssertion()).isEqualTo(state.getEncryptedMatchingDatasetAssertion());
verify(transactionsConfigProxy, times(0)).getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID);
}
use of uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState in project verify-hub by alphagov.
the class AwaitingCycle3DataStateControllerTest method setUpAwaitingCycle3DataStateController.
private AwaitingCycle3DataStateController setUpAwaitingCycle3DataStateController(String requestId, SessionId sessionId) {
final String transactionEntityId = "some-transaction-entity-id";
final DateTime sessionExpiryTime = DateTime.now().plusMinutes(1);
AwaitingCycle3DataState state = anAwaitingCycle3DataState().withSessionId(sessionId).withTransactionEntityId(transactionEntityId).withSessionExpiryTime(sessionExpiryTime).withRequestId(requestId).build();
when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(new Duration(600L));
final AwaitingCycle3DataStateController awaitingCycle3DataStateController = new AwaitingCycle3DataStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionsFactory, matchingServiceConfigProxy);
when(matchingServiceConfigProxy.getMatchingService(state.getMatchingServiceEntityId())).thenReturn(aMatchingServiceConfigEntityDataDto().build());
return awaitingCycle3DataStateController;
}
use of uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState in project verify-hub by alphagov.
the class AwaitingCycle3DataStateControllerTest method shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived.
@Test
public void shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived() throws Exception {
final SessionId sessionId = SessionId.createNewSessionId();
AwaitingCycle3DataState state = anAwaitingCycle3DataState().withSessionId(sessionId).build();
AwaitingCycle3DataStateController controller = new AwaitingCycle3DataStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionsFactory, matchingServiceConfigProxy);
when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
ArgumentCaptor<Cycle3MatchRequestSentState> argumentCaptor = ArgumentCaptor.forClass(Cycle3MatchRequestSentState.class);
when(matchingServiceConfigProxy.getMatchingService(state.getMatchingServiceEntityId())).thenReturn(aMatchingServiceConfigEntityDataDto().build());
controller.handleCycle3DataSubmitted("principalIpAsSeenByHub");
verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
final Cycle3MatchRequestSentState cycle3MatchRequestSentState = argumentCaptor.getValue();
assertThat(cycle3MatchRequestSentState.getEncryptedMatchingDatasetAssertion()).isEqualTo(state.getEncryptedMatchingDatasetAssertion());
}
use of uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState in project verify-hub by alphagov.
the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInAwaitingCycle3DataState.
@Test
public void shouldReturnErrorResponseWhenAskedAndInAwaitingCycle3DataState() {
AwaitingCycle3DataState state = AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState().build();
StateController stateController = new AwaitingCycle3DataStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionFactory, matchingServiceConfigProxy);
when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Aggregations