use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink.
@Test
public void cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink() {
final String requestId = "requestId";
final SessionId sessionId = SessionId.createNewSessionId();
Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
final EventSinkHubEvent eventSinkHubEvent = argumentCaptor.getValue();
assertThat(eventSinkHubEvent.getEventType()).isEqualTo(EventSinkHubEventConstants.EventTypes.SESSION_EVENT);
assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
assertThat(eventSinkHubEvent.getSessionId()).isEqualTo(sessionId.getSessionId());
assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.request_id)).isEqualTo(requestId);
assertThat(eventSinkHubEvent.getOriginatingService()).isEqualTo(serviceInfo.getName());
}
use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.
the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink.
@Test
public void cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink() {
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, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isNotEqualTo(CYCLE3_MATCH);
assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
}
use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.
the class HubEventLoggerTest method logIdpSelectedEvent_shouldLogEventWithIdpSelected.
@Test
public void logIdpSelectedEvent_shouldLogEventWithIdpSelected() {
final IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withLevelsOfAssurance(Arrays.asList(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2)).withSessionExpiryTimestamp(SESSION_EXPIRY_TIMESTAMP).withIdpEntityId(IDP_ENTITY_ID).withRequestIssuerEntityId(TRANSACTION_ENTITY_ID).withRequestId(REQUEST_ID).withSessionId(SESSION_ID).build();
eventLogger.logIdpSelectedEvent(state, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
final Map<EventDetailsKey, String> details = Maps.newHashMap();
details.put(session_event_type, IDP_SELECTED);
details.put(idp_entity_id, IDP_ENTITY_ID);
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
details.put(minimum_level_of_assurance, MINIMUM_LEVEL_OF_ASSURANCE.name());
details.put(required_level_of_assurance, REQUIRED_LEVEL_OF_ASSURANCE.name());
final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(details);
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.
the class HubEventLoggerTest method logIdpAuthnSucceededEvent_shouldContainLevelsOfAssuranceInDetailsFieldForBilling.
@Test
public void logIdpAuthnSucceededEvent_shouldContainLevelsOfAssuranceInDetailsFieldForBilling() {
eventLogger.logIdpAuthnSucceededEvent(SESSION_ID, SESSION_EXPIRY_TIMESTAMP, IDP_ENTITY_ID, TRANSACTION_ENTITY_ID, PERSISTENT_ID, REQUEST_ID, MINIMUM_LEVEL_OF_ASSURANCE, REQUIRED_LEVEL_OF_ASSURANCE, PROVIDED_LEVEL_OF_ASSURANCE, Optional.fromNullable(PRINCIPAL_IP_ADDRESS_SEEN_BY_IDP), PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
final Map<EventDetailsKey, String> details = Maps.newHashMap();
details.put(idp_entity_id, IDP_ENTITY_ID);
details.put(pid, PERSISTENT_ID.getNameId());
details.put(minimum_level_of_assurance, MINIMUM_LEVEL_OF_ASSURANCE.name());
details.put(required_level_of_assurance, REQUIRED_LEVEL_OF_ASSURANCE.name());
details.put(provided_level_of_assurance, PROVIDED_LEVEL_OF_ASSURANCE.name());
details.put(principal_ip_address_as_seen_by_idp, PRINCIPAL_IP_ADDRESS_SEEN_BY_IDP);
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
details.put(session_event_type, IDP_AUTHN_SUCCEEDED);
final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(details);
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.
the class HubEventLoggerTest method logIdpFraudEvent_shouldLogFraudEventWithDetails.
@Test
public void logIdpFraudEvent_shouldLogFraudEventWithDetails() {
final String fraudEventId = "fraudEventId";
final String fraudIndicator = "FI02";
final FraudDetectedDetails fraudDetectedDetailsDto = aFraudDetectedDetails().withFraudEventId(fraudEventId).withFraudIndicator(fraudIndicator).build();
eventLogger.logIdpFraudEvent(SESSION_ID, IDP_ENTITY_ID, TRANSACTION_ENTITY_ID, PERSISTENT_ID, SESSION_EXPIRY_TIMESTAMP, fraudDetectedDetailsDto, Optional.of(PRINCIPAL_IP_ADDRESS_SEEN_BY_IDP), PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB, REQUEST_ID);
final Map<EventDetailsKey, String> details = Maps.newHashMap();
details.put(session_event_type, FRAUD_DETECTED);
details.put(idp_entity_id, IDP_ENTITY_ID);
details.put(pid, PERSISTENT_ID.getNameId());
details.put(idp_fraud_event_id, fraudEventId);
details.put(gpg45_status, fraudIndicator);
details.put(principal_ip_address_as_seen_by_idp, PRINCIPAL_IP_ADDRESS_SEEN_BY_IDP);
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(details);
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
Aggregations