Search in sources :

Example 6 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink.

@Test
public void cycle3NoMatchResponseFromMatchingService_shouldLogCycle3NoMatchEventToEventSink() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
    final EventSinkHubEvent eventSinkHubEvent = argumentCaptor.getValue();
    assertThat(eventSinkHubEvent.getEventType()).isEqualTo(EventSinkHubEventConstants.EventTypes.SESSION_EVENT);
    assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
    assertThat(eventSinkHubEvent.getSessionId()).isEqualTo(sessionId.getSessionId());
    assertThat(eventSinkHubEvent.getDetails().get(EventDetailsKey.request_id)).isEqualTo(requestId);
    assertThat(eventSinkHubEvent.getOriginatingService()).isEqualTo(serviceInfo.getName());
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 7 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink.

@Test
public void cycle3NoMatchResponseFromMatchingService_shouldNotLogCycle3MatchEventToEventSink() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, mock(StateTransitionAction.class), policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    NoMatchFromMatchingService noMatchFromMatchingService = new NoMatchFromMatchingService(matchingServiceEntityId, requestId);
    controller.handleNoMatchResponseFromMatchingService(noMatchFromMatchingService);
    verify(eventSinkProxy, times(1)).logHubEvent(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isNotEqualTo(CYCLE3_MATCH);
    assertThat(argumentCaptor.getValue().getDetails().get(EventDetailsKey.session_event_type)).isEqualTo(CYCLE3_NO_MATCH);
}
Also used : NoMatchFromMatchingService(uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService) StateTransitionAction(uk.gov.ida.hub.policy.domain.StateTransitionAction) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 8 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.

the class HubEventLoggerTest method logIdpSelectedEvent_shouldLogEventWithIdpSelected.

@Test
public void logIdpSelectedEvent_shouldLogEventWithIdpSelected() {
    final IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().withLevelsOfAssurance(Arrays.asList(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_2)).withSessionExpiryTimestamp(SESSION_EXPIRY_TIMESTAMP).withIdpEntityId(IDP_ENTITY_ID).withRequestIssuerEntityId(TRANSACTION_ENTITY_ID).withRequestId(REQUEST_ID).withSessionId(SESSION_ID).build();
    eventLogger.logIdpSelectedEvent(state, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(session_event_type, IDP_SELECTED);
    details.put(idp_entity_id, IDP_ENTITY_ID);
    details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    details.put(minimum_level_of_assurance, MINIMUM_LEVEL_OF_ASSURANCE.name());
    details.put(required_level_of_assurance, REQUIRED_LEVEL_OF_ASSURANCE.name());
    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) IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 9 with EventSinkHubEvent

use of uk.gov.ida.hub.policy.domain.EventSinkHubEvent in project verify-hub by alphagov.

the class HubEventLoggerTest method logIdpAuthnSucceededEvent_shouldContainLevelsOfAssuranceInDetailsFieldForBilling.

@Test
public void logIdpAuthnSucceededEvent_shouldContainLevelsOfAssuranceInDetailsFieldForBilling() {
    eventLogger.logIdpAuthnSucceededEvent(SESSION_ID, SESSION_EXPIRY_TIMESTAMP, IDP_ENTITY_ID, TRANSACTION_ENTITY_ID, PERSISTENT_ID, REQUEST_ID, MINIMUM_LEVEL_OF_ASSURANCE, REQUIRED_LEVEL_OF_ASSURANCE, PROVIDED_LEVEL_OF_ASSURANCE, Optional.fromNullable(PRINCIPAL_IP_ADDRESS_SEEN_BY_IDP), PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
    final Map<EventDetailsKey, String> details = Maps.newHashMap();
    details.put(idp_entity_id, IDP_ENTITY_ID);
    details.put(pid, PERSISTENT_ID.getNameId());
    details.put(minimum_level_of_assurance, MINIMUM_LEVEL_OF_ASSURANCE.name());
    details.put(required_level_of_assurance, REQUIRED_LEVEL_OF_ASSURANCE.name());
    details.put(provided_level_of_assurance, PROVIDED_LEVEL_OF_ASSURANCE.name());
    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);
    details.put(session_event_type, IDP_AUTHN_SUCCEEDED);
    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 10 with EventSinkHubEvent

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

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