Search in sources :

Example 16 with EventDetailsKey

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

the class HubEventLoggerTest method logCycle3DataObtained_shouldLogEvent.

@Test
public void logCycle3DataObtained_shouldLogEvent() {
    eventLogger.logCycle3DataObtained(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, CYCLE3_DATA_OBTAINED);
    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 17 with EventDetailsKey

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

the class HubEventLoggerTest method logSessionOpenEvent_shouldSendEvent.

@Test
public void logSessionOpenEvent_shouldSendEvent() {
    final SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().withId(REQUEST_ID).withIssuer(TRANSACTION_ENTITY_ID).build();
    eventLogger.logSessionStartedEvent(samlResponse, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB, SESSION_EXPIRY_TIMESTAMP, SESSION_ID, MINIMUM_LEVEL_OF_ASSURANCE, REQUIRED_LEVEL_OF_ASSURANCE);
    final Map<EventDetailsKey, String> details = new HashMap<>();
    details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    details.put(message_id, samlResponse.getId());
    details.put(minimum_level_of_assurance, MINIMUM_LEVEL_OF_ASSURANCE.name());
    details.put(required_level_of_assurance, REQUIRED_LEVEL_OF_ASSURANCE.name());
    details.put(session_event_type, SESSION_STARTED);
    final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(details);
    verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
    verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
Also used : HashMap(java.util.HashMap) EventDetailsKey(uk.gov.ida.eventsink.EventDetailsKey) SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.proxy.SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto) SamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 18 with EventDetailsKey

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

the class HubEventLoggerTest method logEventSinkHubEvent_shouldSendEvent.

@Test
public void logEventSinkHubEvent_shouldSendEvent() {
    eventLogger.logRequestFromHub(SESSION_ID, TRANSACTION_ENTITY_ID);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(hub_event_type, RECEIVED_AUTHN_REQUEST_FROM_HUB);
    details.put(transaction_entity_id, TRANSACTION_ENTITY_ID);
    final EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, HUB_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 19 with EventDetailsKey

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

the class HubEventLoggerTest method logIdpNoAuthnContext_shouldLogEvent.

@Test
public void logIdpNoAuthnContext_shouldLogEvent() {
    eventLogger.logNoAuthnContextEvent(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, NO_AUTHN_CONTEXT);
    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 20 with EventDetailsKey

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

the class HubEventLoggerTest method logSessionTimeoutEvent_shouldSendEvent.

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

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