use of uk.gov.ida.hub.policy.domain.MatchFromMatchingService in project verify-hub by alphagov.
the class MatchingServiceResponseService method handleMatchResponseFromMatchingService.
private void handleMatchResponseFromMatchingService(SessionId sessionId, InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto) {
MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(inboundResponseFromMatchingServiceDto.getIssuer(), inboundResponseFromMatchingServiceDto.getInResponseTo(), inboundResponseFromMatchingServiceDto.getUnderlyingMatchingServiceAssertionBlob().get(), inboundResponseFromMatchingServiceDto.getLevelOfAssurance());
WaitingForMatchingServiceResponseStateController stateController = (WaitingForMatchingServiceResponseStateController) sessionRepository.getStateController(sessionId, WaitingForMatchingServiceResponseState.class);
stateController.handleMatchResponseFromMatchingService(matchFromMatchingService);
}
use of uk.gov.ida.hub.policy.domain.MatchFromMatchingService 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());
}
use of uk.gov.ida.hub.policy.domain.MatchFromMatchingService in project verify-hub by alphagov.
the class Cycle0And1MatchRequestSentStateControllerTest method responseProcessingDetails_shouldReturnCompleteStatus_successResponseSentFromMatchingService.
@Test
public void responseProcessingDetails_shouldReturnCompleteStatus_successResponseSentFromMatchingService() {
ArgumentCaptor<SuccessfulMatchState> argumentCaptor = ArgumentCaptor.forClass(SuccessfulMatchState.class);
MatchFromMatchingService matchFromMatchingService = new MatchFromMatchingService(MATCHING_SERVICE_ENTITY_ID, REQUEST_ID, "assertionBlob", Optional.of(LevelOfAssurance.LEVEL_1));
controller.handleMatchResponseFromMatchingService(matchFromMatchingService);
IdentityProvidersConfigProxy identityProvidersConfigProxy = mock(IdentityProvidersConfigProxy.class);
verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
SuccessfulMatchStateController successfulMatchStateController = new SuccessfulMatchStateController(argumentCaptor.getValue(), responseFromHubFactory, identityProvidersConfigProxy);
final ResponseProcessingDetails responseProcessingDetails = successfulMatchStateController.getResponseProcessingDetails();
assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SEND_SUCCESSFUL_MATCH_RESPONSE_TO_TRANSACTION);
assertThat(responseProcessingDetails.getSessionId()).isEqualTo(state.getSessionId());
}
use of uk.gov.ida.hub.policy.domain.MatchFromMatchingService in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService.
@Test
public void getNextState_shouldThrowStateProcessingValidationExceptionIfResponseIsNotFromTheExpectedMatchingService() {
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, null, null, null, null, null, transactionsConfigProxy, null, null, null);
MatchFromMatchingService matchFromMatchingService = aMatchFromMatchingService().withIssuerId("issuer-id").build();
try {
controller.validateResponse(matchFromMatchingService);
fail("fail");
} catch (StateProcessingValidationException e) {
assertThat(e.getMessage()).isEqualTo(format("Response to request ID [{0}] came from [issuer-id] and was expected to come from [{1}]", state.getRequestId(), matchingServiceEntityId));
}
}
use of uk.gov.ida.hub.policy.domain.MatchFromMatchingService 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