use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent 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 EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, EXTERNAL_COMMUNICATION_EVENT, Map.of(external_communication_type, RESPONSE_FROM_HUB, message_id, MESSAGE_ID, external_endpoint, ENDPOINT_URL.toString(), principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB));
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent in project verify-hub by alphagov.
the class AttributeQueryRequestRunnable method auditAndLogTimeoutException.
private void auditAndLogTimeoutException(SessionId sessionId, AttributeQueryContainerDto attributeQueryContainerDto, AttributeQueryTimeoutException exception, String message) {
Map<EventDetailsKey, String> details = new HashMap<>();
details.put(idp_entity_id, attributeQueryContainerDto.getIssuer());
String errorId = UUID.randomUUID().toString();
details.put(error_id, errorId);
details.put(EventDetailsKey.message, message);
EventSinkHubEvent hubEvent = new EventSinkHubEvent(serviceInfo, sessionId, EventSinkHubEventConstants.EventTypes.ERROR_EVENT, details);
eventSinkProxy.logHubEvent(hubEvent);
eventEmitter.record(hubEvent);
LOG.warn(format(message + " It has been Audited with error id: {0}.", errorId), exception);
}
use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent 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_HUB);
final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, EXTERNAL_COMMUNICATION_EVENT, Map.of(external_communication_type, AUTHN_REQUEST, message_id, MESSAGE_ID, external_endpoint, ENDPOINT_URL.toString(), principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB));
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent in project verify-hub by alphagov.
the class ExternalCommunicationEventLoggerTest method logMatchingServiceRequest_shouldPassHubEventToEventSinkProxyNew.
@Test
public void logMatchingServiceRequest_shouldPassHubEventToEventSinkProxyNew() {
externalCommunicationEventLogger.logMatchingServiceRequest(MESSAGE_ID, SESSION_ID, ENDPOINT_URL);
final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, EXTERNAL_COMMUNICATION_EVENT, Map.of(external_communication_type, MATCHING_SERVICE_REQUEST, message_id, MESSAGE_ID, external_endpoint, ENDPOINT_URL.toString(), external_ip_address, ENDPOINT_IP_ADDRESS));
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent in project verify-hub by alphagov.
the class AttributeQueryRequestRunnableTest method run_shouldSayIfTimeoutWasBeforeSendingMessage.
@Test
public void run_shouldSayIfTimeoutWasBeforeSendingMessage() {
doThrow(new AttributeQueryTimeoutException()).when(timeoutEvaluator).hasAttributeQueryTimedOut(attributeQueryContainerDto);
attributeQueryRequestRunnable.run();
final ArgumentCaptor<EventSinkHubEvent> loggedHubEvent = ArgumentCaptor.forClass(EventSinkHubEvent.class);
final ArgumentCaptor<EventSinkHubEvent> emitterLoggedHubEvent = ArgumentCaptor.forClass(EventSinkHubEvent.class);
verify(eventSinkProxy).logHubEvent(loggedHubEvent.capture());
verify(eventEmitter).record(emitterLoggedHubEvent.capture());
assertThat(loggedHubEvent.getValue().getDetails().get(EventDetailsKey.message)).isEqualTo("Matching service attribute timed out before even being sent.");
assertThat(emitterLoggedHubEvent.getValue().getDetails().get(EventDetailsKey.message)).isEqualTo("Matching service attribute timed out before even being sent.");
}
Aggregations