Search in sources :

Example 21 with EventDetailsKey

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

the class HubEventLoggerTest method shouldLogErrorEvent.

@Test
public void shouldLogErrorEvent() {
    eventLogger.logErrorEvent(ERROR_ID, SESSION_ID, ERROR_MESSAGE);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(message, ERROR_MESSAGE);
    details.put(error_id, ERROR_ID.toString());
    final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, ERROR_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.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 22 with EventDetailsKey

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

the class HubEventLoggerTest method shouldLogErrorEventContainingDownstreamUri.

@Test
public void shouldLogErrorEventContainingDownstreamUri() {
    final String downstreamUri = "uri";
    eventLogger.logErrorEvent(ERROR_ID, SESSION_ID, ERROR_MESSAGE, downstreamUri);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(downstream_uri, downstreamUri);
    details.put(message, ERROR_MESSAGE);
    details.put(error_id, ERROR_ID.toString());
    final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, ERROR_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.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 23 with EventDetailsKey

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

the class HubEventLoggerTest method logIdpAuthnPendingEvent_shouldLogEvent.

@Test
public void logIdpAuthnPendingEvent_shouldLogEvent() {
    eventLogger.logPausedRegistrationEvent(SESSION_ID, TRANSACTION_ENTITY_ID, SESSION_EXPIRY_TIMESTAMP, REQUEST_ID, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    details.put(session_event_type, IDP_AUTHN_PENDING);
    final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(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.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 24 with EventDetailsKey

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

the class HubEventLoggerTest method logIdpAuthnFailedEvent_shouldLogEvent.

@Test
public void logIdpAuthnFailedEvent_shouldLogEvent() {
    eventLogger.logIdpAuthnFailedEvent(SESSION_ID, TRANSACTION_ENTITY_ID, SESSION_EXPIRY_TIMESTAMP, REQUEST_ID, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(session_event_type, IDP_AUTHN_FAILED);
    details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(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.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 25 with EventDetailsKey

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

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