Search in sources :

Example 6 with MatchFromMatchingService

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

the class EidasCycle0And1MatchRequestSentStateControllerTest method shouldReturnSuccessfulMatchState.

@Test
public void shouldReturnSuccessfulMatchState() {
    MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService("issuer", "inResponseTo", "matchingServiceAssertion", Optional.of(LevelOfAssurance.LEVEL_2));
    doNothing().when(hubEventLogger).logCycle01SuccessfulMatchEvent(state.getSessionId(), state.getRequestIssuerEntityId(), state.getRequestId(), state.getSessionExpiryTimestamp());
    EidasSuccessfulMatchState expectedState = new EidasSuccessfulMatchState(state.getRequestId(), state.getSessionExpiryTimestamp(), state.getIdentityProviderEntityId(), matchFromMatchingService.getMatchingServiceAssertion(), state.getRelayState().orNull(), state.getRequestIssuerEntityId(), state.getAssertionConsumerServiceUri(), state.getSessionId(), state.getIdpLevelOfAssurance(), state.getTransactionSupportsEidas());
    State actualState = eidasCycle0And1MatchRequestSentStateController.getNextStateForMatch(matchFromMatchingService);
    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) MatchFromMatchingService(uk.gov.ida.hub.policy.domain.MatchFromMatchingService) EidasSuccessfulMatchState(uk.gov.ida.hub.policy.domain.state.EidasSuccessfulMatchState) Test(org.junit.Test)

Example 7 with MatchFromMatchingService

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

the class Cycle0And1MatchRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.

@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
    final String responseIssuerId = "wrong issuer";
    MatchFromMatchingService matchFromMatchingService = aMatchFromMatchingService().withIssuerId(responseIssuerId).build();
    try {
        controller.validateResponse(matchFromMatchingService);
        fail("fail");
    } catch (StateProcessingValidationException e) {
        assertThat(e.getMessage()).isEqualTo(format("Response to request ID [requestId] came from [{0}] and was expected to come from [{1}]", responseIssuerId, MATCHING_SERVICE_ENTITY_ID));
    }
}
Also used : 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) Matchers.anyString(org.mockito.Matchers.anyString) StateProcessingValidationException(uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException) Test(org.junit.Test)

Example 8 with MatchFromMatchingService

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

the class Cycle3MatchRequestSentStateControllerTest method cycle3SuccessfulMatchResponseFromMatchingService_shouldLogCycle3MatchEventToEventSink.

@Test
public void cycle3SuccessfulMatchResponseFromMatchingService_shouldLogCycle3MatchEventToEventSink() {
    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, mock(LevelOfAssuranceValidator.class), null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(matchingServiceEntityId, requestId, "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
    controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
    verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getEventType()).isEqualTo(EventSinkHubEventConstants.EventTypes.SESSION_EVENT);
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_MATCH);
    assertThat(argumentCaptor.getValue().getSessionId()).isEqualTo(sessionId.getSessionId());
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.request_id)).isEqualTo(requestId);
    assertThat(argumentCaptor.getValue().getOriginatingService()).isEqualTo(serviceInfo.getName());
}
Also used : StateTransitionAction(uk.gov.ida.hub.policy.domain.StateTransitionAction) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) 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) Matchers.anyString(org.mockito.Matchers.anyString) LevelOfAssuranceValidator(uk.gov.ida.hub.policy.validators.LevelOfAssuranceValidator) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Aggregations

MatchFromMatchingService (uk.gov.ida.hub.policy.domain.MatchFromMatchingService)8 Test (org.junit.Test)7 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)7 MatchFromMatchingServiceBuilder.aMatchFromMatchingService (uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService)6 Matchers.anyString (org.mockito.Matchers.anyString)3 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)3 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)3 SessionId (uk.gov.ida.hub.policy.domain.SessionId)2 StateProcessingValidationException (uk.gov.ida.hub.policy.domain.exception.StateProcessingValidationException)2 LevelOfAssuranceValidator (uk.gov.ida.hub.policy.validators.LevelOfAssuranceValidator)2 EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.EidasCycle0And1MatchRequestSentStateBuilder.anEidasCycle0And1MatchRequestSentState)1 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)1 MatchingProcess (uk.gov.ida.hub.policy.domain.MatchingProcess)1 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)1 State (uk.gov.ida.hub.policy.domain.State)1 StateTransitionAction (uk.gov.ida.hub.policy.domain.StateTransitionAction)1 UserAccountCreationAttribute (uk.gov.ida.hub.policy.domain.UserAccountCreationAttribute)1 WaitingForMatchingServiceResponseStateController (uk.gov.ida.hub.policy.domain.controller.WaitingForMatchingServiceResponseStateController)1 EidasAwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.EidasAwaitingCycle3DataState)1 EidasCycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle0And1MatchRequestSentState)1