Search in sources :

Example 11 with EventDetailsKey

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

the class HubEventLoggerTest method logIdpFraudEvent_shouldLogFraudEventWithDetails.

@Test
public void logIdpFraudEvent_shouldLogFraudEventWithDetails() {
    final String fraudEventId = "fraudEventId";
    final String fraudIndicator = "FI02";
    final FraudDetectedDetails fraudDetectedDetailsDto = aFraudDetectedDetails().withFraudEventId(fraudEventId).withFraudIndicator(fraudIndicator).build();
    eventLogger.logIdpFraudEvent(SESSION_ID, IDP_ENTITY_ID, TRANSACTION_ENTITY_ID, PERSISTENT_ID, SESSION_EXPIRY_TIMESTAMP, fraudDetectedDetailsDto, Optional.of(PRINCIPAL_IP_ADDRESS_SEEN_BY_IDP), PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB, REQUEST_ID);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(session_event_type, FRAUD_DETECTED);
    details.put(idp_entity_id, IDP_ENTITY_ID);
    details.put(pid, PERSISTENT_ID.getNameId());
    details.put(idp_fraud_event_id, fraudEventId);
    details.put(gpg45_status, fraudIndicator);
    details.put(principal_ip_address_as_seen_by_idp, PRINCIPAL_IP_ADDRESS_SEEN_BY_IDP);
    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) FraudDetectedDetailsBuilder.aFraudDetectedDetails(uk.gov.ida.hub.policy.builder.domain.FraudDetectedDetailsBuilder.aFraudDetectedDetails) FraudDetectedDetails(uk.gov.ida.hub.policy.domain.FraudDetectedDetails) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 12 with EventDetailsKey

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

the class HubEventLoggerTest method logMatchingServiceUserAccountCreationRequestSentEvent_shouldLogEvent.

@Test
public void logMatchingServiceUserAccountCreationRequestSentEvent_shouldLogEvent() {
    eventLogger.logMatchingServiceUserAccountCreationRequestSentEvent(SESSION_ID, TRANSACTION_ENTITY_ID, SESSION_EXPIRY_TIMESTAMP, REQUEST_ID);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(session_event_type, USER_ACCOUNT_CREATION_REQUEST_SENT);
    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 13 with EventDetailsKey

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

the class HubEventLoggerTest method shouldLogErrorEventContainingAnErrorMessage.

@Test
public void shouldLogErrorEventContainingAnErrorMessage() {
    eventLogger.logErrorEvent(ERROR_MESSAGE, SESSION_ID);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(message, ERROR_MESSAGE);
    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 14 with EventDetailsKey

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

the class HubEventLoggerTest method logIdpRequesterErrorEvent_shouldLogEvent.

@Test
public void logIdpRequesterErrorEvent_shouldLogEvent() {
    final String errorMessage = "some error message";
    eventLogger.logIdpRequesterErrorEvent(SESSION_ID, TRANSACTION_ENTITY_ID, SESSION_EXPIRY_TIMESTAMP, REQUEST_ID, Optional.fromNullable(errorMessage), PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(message, errorMessage);
    details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    details.put(session_event_type, REQUESTER_ERROR);
    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 15 with EventDetailsKey

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

the class HubEventLoggerTest method shouldLogErrorEventContainingIDPEntityId.

@Test
public void shouldLogErrorEventContainingIDPEntityId() {
    final String idpEntityId = "IDP entity id";
    eventLogger.logErrorEvent(ERROR_ID, idpEntityId, SESSION_ID);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(idp_entity_id, idpEntityId);
    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)

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