Search in sources :

Example 26 with EventDetailsKey

use of uk.gov.ida.eventsink.EventDetailsKey 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 27 with EventDetailsKey

use of uk.gov.ida.eventsink.EventDetailsKey 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)

Example 28 with EventDetailsKey

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_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_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)));
}
Also used : EventDetailsKey(uk.gov.ida.eventsink.EventDetailsKey) EventSinkHubEvent(uk.gov.ida.eventsink.EventSinkHubEvent) Test(org.junit.Test)

Aggregations

EventDetailsKey (uk.gov.ida.eventsink.EventDetailsKey)28 Test (org.junit.Test)23 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)18 EventSinkHubEvent (uk.gov.ida.eventsink.EventSinkHubEvent)10 HashMap (java.util.HashMap)5 URI (java.net.URI)1 UUID (java.util.UUID)1 ApplicationException (uk.gov.ida.exceptions.ApplicationException)1 FraudDetectedDetailsBuilder.aFraudDetectedDetails (uk.gov.ida.hub.policy.builder.domain.FraudDetectedDetailsBuilder.aFraudDetectedDetails)1 SamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto)1 FraudDetectedDetails (uk.gov.ida.hub.policy.domain.FraudDetectedDetails)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1 SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.proxy.SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto)1