use of uk.gov.ida.eventsink.EventDetailsKey in project verify-hub by alphagov.
the class ExternalCommunicationEventLoggerTest method logAuthenticationRequest_shouldPassHubEventToEventSinkProxy.
@Test
public void logAuthenticationRequest_shouldPassHubEventToEventSinkProxy() {
externalCommunicationEventLogger.logIdpAuthnRequest(MESSAGE_ID, SESSION_ID, ENDPOINT_URL, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_THE_HUB);
final Map<EventDetailsKey, String> details = Maps.newHashMap();
details.put(external_communication_type, AUTHN_REQUEST);
details.put(message_id, MESSAGE_ID);
details.put(external_endpoint, ENDPOINT_URL.toString());
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_THE_HUB);
final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, EXTERNAL_COMMUNICATION_EVENT, 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 ExternalCommunicationEventLoggerTest method logResponseFromHub_shouldPassHubEventToEventSinkProxy.
@Test
public void logResponseFromHub_shouldPassHubEventToEventSinkProxy() {
externalCommunicationEventLogger.logResponseFromHub(MESSAGE_ID, SESSION_ID, ENDPOINT_URL, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_THE_HUB);
final Map<EventDetailsKey, String> details = Maps.newHashMap();
details.put(external_communication_type, RESPONSE_FROM_HUB);
details.put(message_id, MESSAGE_ID);
details.put(external_endpoint, ENDPOINT_URL.toString());
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_THE_HUB);
final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, EXTERNAL_COMMUNICATION_EVENT, 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 HealthCheckEventLogger method logException.
public void logException(ApplicationException exception, String message) {
LOG.warn(message, exception);
if (exception.isAudited() || !exception.requiresAuditing()) {
return;
}
ImmutableMap<EventDetailsKey, String> details = ImmutableMap.of(downstream_uri, exception.getUri().or(URI.create("uri-not-present")).toASCIIString(), EventDetailsKey.message, exception.getMessage());
EventSinkHubEvent hubEvent = new EventSinkHubEvent(serviceInfo, NO_SESSION_CONTEXT_IN_ERROR, ERROR_EVENT, details);
eventSinkProxy.logHubEvent(hubEvent);
eventEmitter.record(hubEvent);
}
use of uk.gov.ida.eventsink.EventDetailsKey in project verify-hub by alphagov.
the class AttributeQueryRequestRunnable method logAndAuditMessageError.
private void logAndAuditMessageError(Exception e, AttributeQueryContainerDto attributeQueryContainerDto, SessionId sessionId) {
String errorMessage = MatchingServiceRequestExceptionErrorMessageMapper.getErrorMessageForException(e);
Map<EventDetailsKey, String> details = new HashMap<>();
UUID errorId = UUID.randomUUID();
details.put(idp_entity_id, attributeQueryContainerDto.getIssuer());
details.put(message, errorMessage + e.getMessage());
details.put(error_id, errorId.toString());
EventSinkHubEvent hubEvent = new EventSinkHubEvent(serviceInfo, sessionId, EventSinkHubEventConstants.EventTypes.ERROR_EVENT, details);
eventSinkProxy.logHubEvent(hubEvent);
eventEmitter.record(hubEvent);
if (attributeQueryContainerDto.isOnboarding()) {
LOG.warn(LogFormatter.formatLog(errorId, e.getMessage()), e);
} else {
LOG.error(LogFormatter.formatLog(errorId, e.getMessage()), e);
}
}
use of uk.gov.ida.eventsink.EventDetailsKey in project verify-hub by alphagov.
the class ExternalCommunicationEventLoggerTest method logResponseFromHub_shouldPassHubEventToEventSinkProxy.
@Test
public void logResponseFromHub_shouldPassHubEventToEventSinkProxy() {
externalCommunicationEventLogger.logResponseFromHub(MESSAGE_ID, SESSION_ID, ENDPOINT_URL, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB);
final Map<EventDetailsKey, String> details = Maps.newHashMap();
details.put(external_communication_type, RESPONSE_FROM_HUB);
details.put(message_id, MESSAGE_ID);
details.put(external_endpoint, ENDPOINT_URL.toString());
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB);
final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, EXTERNAL_COMMUNICATION_EVENT, details);
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
Aggregations