use of com.sequenceiq.cloudbreak.audit.model.AuditEvent in project cloudbreak by hortonworks.
the class AuditServiceTest method testAuditServiceEvent.
@Test
public void testAuditServiceEvent() {
String auditMessage = "audit service message";
underTest.auditAutoscaleServiceEvent(ScalingStatus.SUCCESS, auditMessage, "clusterCrn", "user-account", System.currentTimeMillis());
ArgumentCaptor<AuditEvent> captor = ArgumentCaptor.forClass(AuditEvent.class);
verify(auditClient, times(1)).createAuditEvent(captor.capture());
AuditEvent auditEvent = captor.getValue();
assertEquals("user-account", auditEvent.getAccountId());
assertEquals(AUTOSCALE_DATAHUB_CLUSTER, auditEvent.getEventName());
assertEquals(Crn.Service.DATAHUB, auditEvent.getEventSource());
assertEquals(Crn.Service.DATAHUB.getName(), ((ActorService) auditEvent.getActor()).getActorServiceName());
ServiceEventData serviceEventData = (ServiceEventData) auditEvent.getEventData();
assertNotNull("Event Data should be intialized", serviceEventData.getEventDetails());
assertTrue("Time stamp should be intialized", serviceEventData.getEventDetails().contains("timestamp"));
}
use of com.sequenceiq.cloudbreak.audit.model.AuditEvent in project cloudbreak by hortonworks.
the class CDPAuditStructuredEventHandler method accept.
@Override
public void accept(Event<T> structuredEvent) {
try {
T data = structuredEvent.getData();
CDPOperationDetails operation = data.getOperation();
CDPEventDataExtractor<T> extractor = eventDataExtractorMap.get(operation.getEventType().name().toLowerCase() + "CDPEventDataExtractor");
LOGGER.info("Extract audit event as {}", extractor);
AuditEvent event = AuditEvent.builder().withAccountId(operation.getAccountId()).withActor(ActorCrn.builder().withActorCrn(operation.getUserCrn()).build()).withEventData(extractor.eventData(data)).withEventName(extractor.eventName(data)).withEventSource(extractor.eventSource(data)).withSourceIp(extractor.sourceIp(data)).build();
auditClient.createAuditEvent(event);
} catch (UnsupportedOperationException e) {
LOGGER.debug("Audit log is unnecessary: {}", e.getMessage());
} catch (Exception e) {
LOGGER.warn("Cannot perform auditing: {}", e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.audit.model.AuditEvent in project cloudbreak by hortonworks.
the class LegacyAuditStructuredEventHandler method accept.
@Override
public void accept(Event<T> structuredEvent) {
try {
T data = structuredEvent.getData();
OperationDetails operation = data.getOperation();
LegacyEventDataExtractor<T> extractor = eventDataExtractorMap.get(operation.getEventType().name().toLowerCase() + "LegacyEventDataExtractor");
LOGGER.info("Extract audit event as {}", extractor);
AuditEvent event = AuditEvent.builder().withAccountId(operation.getTenant()).withActor(ActorCrn.builder().withActorCrn(operation.getUserCrn()).build()).withEventData(extractor.eventData(data)).withEventName(extractor.eventName(data)).withEventSource(extractor.eventSource(data)).withSourceIp(extractor.sourceIp(data)).build();
auditClient.createAuditEvent(event);
} catch (UnsupportedOperationException e) {
LOGGER.debug("Audit log is unnecessary: {}", e.getMessage());
} catch (Exception e) {
LOGGER.error("Cannot perform auditing: {}", e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.audit.model.AuditEvent in project cloudbreak by hortonworks.
the class AuditEventToGrpcAuditEventConverterTest method convertNoEventData.
@Test
void convertNoEventData() {
ActorBase actor = ActorService.builder().withActorServiceName(ACTOR_SERVICE_NAME).build();
AuditEvent source = makeAuditEvent(actor, null);
underTest.convert(source);
assertGeneric();
}
use of com.sequenceiq.cloudbreak.audit.model.AuditEvent in project cloudbreak by hortonworks.
the class AuditEventToGrpcAuditEventConverterTest method testWhenResultEventDataIsNullThenNoUtilizerCallHappens.
@Test
void testWhenResultEventDataIsNullThenNoUtilizerCallHappens() {
ActorBase actor = ActorCrn.builder().withActorCrn(USER_CRN).build();
AuditEvent source = makeMinimalAuditEvent(actor, null);
underTest.convert(source);
verify(mockAuditEventBuilderUpdater, never()).update(any(), any());
}
Aggregations