Search in sources :

Example 11 with EventSinkHubEvent

use of uk.gov.ida.eventsink.EventSinkHubEvent in project verify-hub by alphagov.

the class AttributeQueryRequestRunnableTest method run__shouldNotNotifySamlEngineWhenAttributeQueryHasTimedOutBeforeBeingSentToMSA.

@Test
public void run__shouldNotNotifySamlEngineWhenAttributeQueryHasTimedOutBeforeBeingSentToMSA() {
    doThrow(new AttributeQueryTimeoutException("Attribute Query timed out by 1 seconds.")).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().getSessionId()).isEqualTo(sessionId.toString());
    assertThat(emitterLoggedHubEvent.getValue().getSessionId()).isEqualTo(sessionId.toString());
    verify(hubMatchingServiceResponseReceiverProxy, times(0)).notifyHubOfMatchingServiceRequestFailure(sessionId);
    verify(timeoutEvaluator, times(1)).hasAttributeQueryTimedOut(attributeQueryContainerDto);
    assertThat(loggedHubEvent.getValue().getDetails().get(message)).contains("Matching service attribute timed out before even being sent.");
    assertThat(emitterLoggedHubEvent.getValue().getDetails().get(message)).contains("Matching service attribute timed out before even being sent.");
}
Also used : AttributeQueryTimeoutException(uk.gov.ida.hub.samlsoapproxy.exceptions.AttributeQueryTimeoutException) EventSinkHubEvent(uk.gov.ida.eventsink.EventSinkHubEvent) Test(org.junit.Test)

Example 12 with EventSinkHubEvent

use of uk.gov.ida.eventsink.EventSinkHubEvent in project verify-hub by alphagov.

the class ExternalCommunicationEventLogger method logExternalCommunicationEvent.

private void logExternalCommunicationEvent(String messageId, SessionId sessionId, URI targetUrl, String externalCommunicationType, IncludeIpAddressState includeIpAddressState, Map<EventDetailsKey, String> details) {
    details.put(external_communication_type, externalCommunicationType);
    details.put(message_id, messageId);
    details.put(external_endpoint, targetUrl.toString());
    if (includeIpAddressState == IncludeIpAddressState.WITH_RESOLVED_IP_ADDRESS) {
        details.put(external_ip_address, ipAddressResolver.lookupIpAddress(targetUrl));
    }
    final EventSinkHubEvent hubEvent = new EventSinkHubEvent(serviceInfo, sessionId, EXTERNAL_COMMUNICATION_EVENT, details);
    eventSinkProxy.logHubEvent(hubEvent);
    eventEmitter.record(hubEvent);
}
Also used : EventSinkHubEvent(uk.gov.ida.eventsink.EventSinkHubEvent)

Example 13 with EventSinkHubEvent

use of uk.gov.ida.eventsink.EventSinkHubEvent in project verify-hub by alphagov.

the class ExternalCommunicationEventLoggerTest method logMatchingServiceRequest_shouldPassHubEventToEventSinkProxy.

@Test
public void logMatchingServiceRequest_shouldPassHubEventToEventSinkProxy() {
    externalCommunicationEventLogger.logMatchingServiceRequest(MESSAGE_ID, SESSION_ID, ENDPOINT_URL);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(external_communication_type, MATCHING_SERVICE_REQUEST);
    details.put(message_id, MESSAGE_ID);
    details.put(external_endpoint, ENDPOINT_URL.toString());
    details.put(external_ip_address, ENDPOINT_IP_ADDRESS);
    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)));
}
Also used : EventDetailsKey(uk.gov.ida.eventsink.EventDetailsKey) EventSinkHubEvent(uk.gov.ida.eventsink.EventSinkHubEvent) Test(org.junit.Test)

Example 14 with EventSinkHubEvent

use of uk.gov.ida.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);
}
Also used : HashMap(java.util.HashMap) EventDetailsKey(uk.gov.ida.eventsink.EventDetailsKey) EventSinkHubEvent(uk.gov.ida.eventsink.EventSinkHubEvent)

Example 15 with EventSinkHubEvent

use of uk.gov.ida.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 Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(external_communication_type, MATCHING_SERVICE_REQUEST);
    details.put(message_id, MESSAGE_ID);
    details.put(external_endpoint, ENDPOINT_URL.toString());
    details.put(external_ip_address, ENDPOINT_IP_ADDRESS.toString());
    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)));
}
Also used : EventDetailsKey(uk.gov.ida.eventsink.EventDetailsKey) EventSinkHubEvent(uk.gov.ida.eventsink.EventSinkHubEvent) Test(org.junit.Test)

Aggregations

EventSinkHubEvent (uk.gov.ida.eventsink.EventSinkHubEvent)18 Test (org.junit.Test)13 EventDetailsKey (uk.gov.ida.eventsink.EventDetailsKey)10 AttributeQueryTimeoutException (uk.gov.ida.hub.samlsoapproxy.exceptions.AttributeQueryTimeoutException)5 SamlTransformationErrorException (uk.gov.ida.saml.core.validation.SamlTransformationErrorException)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Element (org.w3c.dom.Element)2 SAXException (org.xml.sax.SAXException)2 CertificateChainValidationException (uk.gov.ida.common.shared.security.verification.exceptions.CertificateChainValidationException)2 InvalidSamlRequestInAttributeQueryException (uk.gov.ida.hub.samlsoapproxy.exceptions.InvalidSamlRequestInAttributeQueryException)2 URI (java.net.URI)1 UUID (java.util.UUID)1 ApplicationException (uk.gov.ida.exceptions.ApplicationException)1