use of uk.gov.ida.eventsink.EventDetailsKey in project verify-hub by alphagov.
the class HealthCheckEventLoggerTest method shouldLogToEventSinkIfTheExceptionIsUnaudited.
@Test
public void shouldLogToEventSinkIfTheExceptionIsUnaudited() {
URI uri = URI.create("uri-geller");
ApplicationException unauditedException = ApplicationException.createUnauditedException(ExceptionType.INVALID_SAML, UUID.randomUUID(), uri);
ImmutableMap<EventDetailsKey, String> details = ImmutableMap.of(downstream_uri, unauditedException.getUri().or(URI.create("uri-not-present")).toASCIIString(), message, unauditedException.getMessage());
EventSinkHubEvent event = new EventSinkHubEvent(serviceInfo, NO_SESSION_CONTEXT_IN_ERROR, ERROR_EVENT, details);
eventLogger.logException(unauditedException, "test error message");
ArgumentCaptor<EventSinkHubEvent> eventSinkCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
ArgumentCaptor<EventSinkHubEvent> eventEmitterCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
verify(eventSinkProxy, times(1)).logHubEvent(eventSinkCaptor.capture());
verify(eventEmitter, times(1)).record(eventEmitterCaptor.capture());
assertThat(event).isEqualToComparingOnlyGivenFields(eventSinkCaptor.getValue(), "originatingService", "sessionId", "eventType", "details");
assertThat(event).isEqualToComparingOnlyGivenFields(eventEmitterCaptor.getValue(), "originatingService", "sessionId", "eventType", "details");
}
use of uk.gov.ida.eventsink.EventDetailsKey in project verify-hub by alphagov.
the class HubEventLogger method logRequestFromHub.
public void logRequestFromHub(SessionId sessionId, String transactionEntityId) {
Map<EventDetailsKey, String> details = new HashMap<>();
details.put(hub_event_type, RECEIVED_AUTHN_REQUEST_FROM_HUB);
details.put(transaction_entity_id, transactionEntityId);
EventSinkHubEvent eventSinkHubEvent = new EventSinkHubEvent(serviceInfo, sessionId, HUB_EVENT, details);
eventSinkProxy.logHubEvent(eventSinkHubEvent);
eventEmitter.record(eventSinkHubEvent);
}
use of uk.gov.ida.eventsink.EventDetailsKey in project verify-hub by alphagov.
the class HubEventLogger method logSessionTimeoutEvent.
public void logSessionTimeoutEvent(SessionId sessionId, DateTime sessionExpiryTimestamp, String transactionEntityId, String requestId) {
Map<EventDetailsKey, String> details = new HashMap<>();
details.put(session_event_type, SESSION_TIMEOUT);
details.put(session_expiry_time, sessionExpiryTimestamp.toString());
details.put(transaction_entity_id, transactionEntityId);
details.put(request_id, requestId);
EventSinkHubEvent eventSinkHubEvent = new EventSinkHubEvent(serviceInfo, sessionId, SESSION_EVENT, details);
eventSinkProxy.logHubEvent(eventSinkHubEvent);
eventEmitter.record(eventSinkHubEvent);
}
use of uk.gov.ida.eventsink.EventDetailsKey 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.eventsink.EventDetailsKey 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)));
}
Aggregations