use of uk.gov.ida.hub.shared.eventsink.EventDetails in project verify-hub by alphagov.
the class ExceptionAuditorTest method shouldAuditUnauditedException.
@Test
public void shouldAuditUnauditedException() {
DateTime expectedTimestamp = DateTime.now();
DateTimeFreezer.freezeTime(expectedTimestamp);
final UUID errorId = UUID.randomUUID();
ApplicationException exception = createUnauditedException(ExceptionType.DUPLICATE_SESSION, errorId, URI.create("/some-uri"));
exceptionAuditor.auditException(exception, Optional.of(SESSION_ID));
ArgumentCaptor<EventDetails> argumentCaptor = ArgumentCaptor.forClass(EventDetails.class);
verify(eventSinkMessageSender).audit(eq(exception), eq(errorId), eq(SESSION_ID), argumentCaptor.capture());
final EventDetails event = argumentCaptor.getValue();
assertThat(event.getKey()).isEqualTo(downstream_uri);
assertThat(event.getValue()).isEqualTo(exception.getUri().get().toASCIIString());
}
use of uk.gov.ida.hub.shared.eventsink.EventDetails in project verify-hub by alphagov.
the class ExceptionAuditor method auditException.
public boolean auditException(ApplicationException exception, Optional<SessionId> sessionId) {
boolean isAudited = exception.isAudited();
if (!isAudited && exception.requiresAuditing()) {
EventDetails eventDetails = new EventDetails(downstream_uri, exception.getUri().orElse(URI.create("uri-not-present")).toASCIIString());
eventSinkMessageSender.audit(exception, exception.getErrorId(), sessionId.orElse(SessionId.NO_SESSION_CONTEXT_IN_ERROR), eventDetails);
isAudited = true;
}
return isAudited;
}
Aggregations