Search in sources :

Example 16 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent 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 17 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent 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 18 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent 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 19 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent 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)

Example 20 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent 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)

Aggregations

EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)26 Test (org.junit.Test)22 EventDetailsKey (uk.gov.ida.eventsink.EventDetailsKey)18 SessionId (uk.gov.ida.hub.policy.domain.SessionId)5 Matchers.anyString (org.mockito.Matchers.anyString)4 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)4 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)4 HashMap (java.util.HashMap)3 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)3 SessionIdBuilder.aSessionId (uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId)2 StateTransitionAction (uk.gov.ida.hub.policy.domain.StateTransitionAction)2 HasSessionId.hasSessionId (uk.gov.ida.hub.policy.matchers.HasSessionId.hasSessionId)2 URI (java.net.URI)1 FraudDetectedDetailsBuilder.aFraudDetectedDetails (uk.gov.ida.hub.policy.builder.domain.FraudDetectedDetailsBuilder.aFraudDetectedDetails)1 MatchFromMatchingServiceBuilder.aMatchFromMatchingService (uk.gov.ida.hub.policy.builder.domain.MatchFromMatchingServiceBuilder.aMatchFromMatchingService)1 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 SamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto)1 FraudDetectedDetails (uk.gov.ida.hub.policy.domain.FraudDetectedDetails)1 MatchFromMatchingService (uk.gov.ida.hub.policy.domain.MatchFromMatchingService)1 State (uk.gov.ida.hub.policy.domain.State)1