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);
}
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));
}
}
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());
}
Aggregations