use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent in project verify-hub by alphagov.
the class AttributeQueryRequestRunnableTest method run_shouldNotifySamlEngineAndLogErrorWhenMatchingServiceRequestIsNotProperlySigned.
@Test
public void run_shouldNotifySamlEngineAndLogErrorWhenMatchingServiceRequestIsNotProperlySigned() {
when(executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto)).thenThrow(new InvalidSamlRequestInAttributeQueryException("Attribute Query had invalid Saml", new Exception()));
attributeQueryRequestRunnable.run();
final ArgumentCaptor<EventSinkHubEvent> loggedHubEvent = ArgumentCaptor.forClass(EventSinkHubEvent.class);
final ArgumentCaptor<EventSinkHubEvent> emitterLoggedHubEvent = ArgumentCaptor.forClass(EventSinkHubEvent.class);
verify(eventSinkProxy).logHubEvent(loggedHubEvent.capture());
verify(eventEmitter).record(emitterLoggedHubEvent.capture());
assertThat(loggedHubEvent.getValue().getSessionId()).isEqualTo(sessionId.toString());
assertThat(emitterLoggedHubEvent.getValue().getSessionId()).isEqualTo(sessionId.toString());
verify(hubMatchingServiceResponseReceiverProxy).notifyHubOfMatchingServiceRequestFailure(sessionId);
verify(timeoutEvaluator, times(2)).hasAttributeQueryTimedOut(attributeQueryContainerDto);
assertThat(loggedHubEvent.getValue().getDetails().get(message)).contains("Incorrect message provided by caller");
assertThat(emitterLoggedHubEvent.getValue().getDetails().get(message)).contains("Incorrect message provided by caller");
}
use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent 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 EventSinkHubEvent expectedEvent = new EventSinkHubEvent(SERVICE_INFO, SESSION_ID, EXTERNAL_COMMUNICATION_EVENT, Map.of(external_communication_type, MATCHING_SERVICE_REQUEST, message_id, MESSAGE_ID, external_endpoint, ENDPOINT_URL.toString(), external_ip_address, ENDPOINT_IP_ADDRESS));
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent in project verify-hub by alphagov.
the class ExternalCommunicationEventLogger method logExternalCommunicationEvent.
private void logExternalCommunicationEvent(String messageId, SessionId sessionId, URI targetUrl, String externalCommunicationType, IncludeIpAddressState includeIpAddressState, Map<EventDetailsKey, String> details) {
details.put(external_communication_type, externalCommunicationType);
details.put(message_id, messageId);
details.put(external_endpoint, targetUrl.toString());
if (includeIpAddressState == IncludeIpAddressState.WITH_RESOLVED_IP_ADDRESS) {
details.put(external_ip_address, ipAddressResolver.lookupIpAddress(targetUrl));
}
final EventSinkHubEvent hubEvent = new EventSinkHubEvent(serviceInfo, sessionId, EXTERNAL_COMMUNICATION_EVENT, details);
eventSinkProxy.logHubEvent(hubEvent);
eventEmitter.record(hubEvent);
}
Aggregations