Search in sources :

Example 1 with MatchingProcess

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

the class Cycle0And1MatchRequestSentStateControllerTest method cycle0And1SuccessfulMatchResponseFromMatchingService_shouldLogRelevantEvents.

@Test
public void cycle0And1SuccessfulMatchResponseFromMatchingService_shouldLogRelevantEvents() {
    List<UserAccountCreationAttribute> userAccountCreationAttributes = singletonList(UserAccountCreationAttribute.DATE_OF_BIRTH);
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(userAccountCreationAttributes);
    MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(MATCHING_SERVICE_ENTITY_ID, REQUEST_ID, "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
    controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
    verify(hubEventLogger, times(1)).logCycle01SuccessfulMatchEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
    verify(hubEventLogger, times(0)).logCycle01NoMatchEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
}
Also used : UserAccountCreationAttribute(uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute) NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchFromMatchingServiceBuilder.aMatchFromMatchingService(uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService) MatchFromMatchingService(uk.gov.ida.hub.policy.domain.MatchFromMatchingService) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Test(org.junit.Test)

Example 2 with MatchingProcess

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

the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldReturnNoMatchStateWhenTransactionDoesNotSupportCycle3AndMatchingServiceReturnsNoMatchAndUserAccountCreationIsDisabled.

@Test
public void getNextState_shouldReturnNoMatchStateWhenTransactionDoesNotSupportCycle3AndMatchingServiceReturnsNoMatchAndUserAccountCreationIsDisabled() throws Exception {
    // Given
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(Collections.emptyList());
    // When
    final State nextState = controller.getNextStateForNoMatch();
    // Then
    assertThat(nextState).isInstanceOf(NoMatchState.class);
}
Also used : NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) SuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState) Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) State(uk.gov.ida.hub.policy.domain.State) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) UserAccountCreationRequestSentState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Test(org.junit.Test)

Example 3 with MatchingProcess

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

the class Cycle0And1MatchRequestSentStateControllerTest method cycle0And1NoMatchResponseFromMatchingServiceWhenC3NotEnabled_shouldNotLogWaitingForCycle3AttributesEventToEventSink.

@Test
public void cycle0And1NoMatchResponseFromMatchingServiceWhenC3NotEnabled_shouldNotLogWaitingForCycle3AttributesEventToEventSink() {
    when(transactionsConfigProxy.getMatchingProcess(TRANSACTION_ENTITY_ID)).thenReturn(new MatchingProcess(Optional.absent()));
    when(transactionsConfigProxy.getUserAccountCreationAttributes(TRANSACTION_ENTITY_ID)).thenReturn(emptyList());
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(MATCHING_SERVICE_ENTITY_ID, REQUEST_ID);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(hubEventLogger, times(0)).logWaitingForCycle3AttributesEvent(state.getSessionId(), TRANSACTION_ENTITY_ID, REQUEST_ID, state.getSessionExpiryTimestamp());
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Test(org.junit.Test)

Example 4 with MatchingProcess

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

the class EidasAwaitingCycle3DataStateControllerTest method getCycle3AttributeRequestData.

@Test
public void getCycle3AttributeRequestData() {
    final MatchingProcess matchingProcess = new MatchingProcess(Optional.of(CYCLE_3_ATTRIBUTE_NAME));
    when(transactionsConfigProxy.getMatchingProcess(state.getRequestIssuerEntityId())).thenReturn(matchingProcess);
    final Cycle3AttributeRequestData expectedData = new Cycle3AttributeRequestData(CYCLE_3_ATTRIBUTE_NAME, state.getRequestIssuerEntityId());
    final Cycle3AttributeRequestData actualData = controller.getCycle3AttributeRequestData();
    assertThat(actualData).isEqualTo(expectedData);
}
Also used : MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) Test(org.junit.Test)

Example 5 with MatchingProcess

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

the class EidasCycle0And1MatchRequestSentStateControllerTest method shouldReturnEidasAwaitingCycle3DataState.

@Test
public void shouldReturnEidasAwaitingCycle3DataState() {
    when(transactionsConfigProxy.getMatchingProcess(state.getRequestIssuerEntityId())).thenReturn(new MatchingProcess(Optional.of("cycle3AttributeName")));
    doNothing().when(hubEventLogger).logWaitingForCycle3AttributesEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getRequestId(), state.getSessionExpiryTimestamp());
    EidasAwaitingCycle3DataState expectedState = new EidasAwaitingCycle3DataState(state.getRequestId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getAssertionConsumerServiceUri(), state.getSessionId(), state.getTransactionSupportsEidas(), state.getIdentityProviderEntityId(), state.getMatchingServiceAdapterEntityId(), state.getRelayState(), state.getPersistentId(), state.getIdpLevelOfAssurance(), state.getEncryptedIdentityAssertion());
    State actualState = eidasCycle0And1MatchRequestSentStateController.getNextStateForNoMatch();
    assertThat(actualState).isEqualTo(expectedState);
}
Also used : EidasAwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState) NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) EidasSuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.EidasSuccessfulMatchState) EidasCycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState) EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState) State(uk.gov.ida.hub.policy.domain.State) EidasAwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState) MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Test(org.junit.Test)

Aggregations

MatchingProcess (uk.gov.ida.hub.policy.domain.MatchingProcess)17 Test (org.junit.Test)10 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)9 NoMatchState (uk.gov.ida.hub.policy.domain.state.NoMatchState)7 Test (org.junit.jupiter.api.Test)6 State (uk.gov.ida.hub.policy.domain.State)4 UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)3 UserAccountCreationRequestSentState (uk.gov.ida.hub.policy.domain.state.UserAccountCreationRequestSentState)3 URI (java.net.URI)2 Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState)2 EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState)2 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)2 Cycle3AttributeRequestData (uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)2 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)2 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)2 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)2 EidasAwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState)2 EidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState)2 EidasSuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.EidasSuccessfulMatchState)2 SuccessfulMatchState (uk.gov.ida.hub.policy.domain.state.SuccessfulMatchState)2