@Test public void testProcessBatchNoLogTimeStrategy() { when(mockAuditor.shouldLogForStatus(any(Status.class))).thenReturn(false); auditAdapter.auditBatch(mock(BatchStatement.class), mock(UUID.class), mockState, mock(BatchQueryOptions.class), Status.ATTEMPT, TIMESTAMP); verifyNoMoreInteractions(mockAuditor, mockAuditEntryBuilderFactory); }
public void auditBatch(BatchStatement statement, UUID uuid, ClientState state, BatchQueryOptions options, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry.Builder builder = entryBuilderFactory.createBatchEntryBuilder() .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .batch(uuid) .status(status) .timestamp(timestamp); if (status == Status.FAILED && auditor.shouldLogFailedBatchSummary()) { String failedBatchStatement = String.format(BATCH_FAILURE, uuid.toString()); auditor.audit(builder.operation(new SimpleAuditOperation(failedBatchStatement)).build()); } else { for (AuditEntry entry : getBatchOperations(builder, statement, state, options)) { auditor.audit(entry); } } } }
AuditAdapter { public void auditBatch(BatchStatement statement, UUID uuid, ClientState state, BatchQueryOptions options, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry.Builder builder = entryBuilderFactory.createBatchEntryBuilder() .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .batch(uuid) .status(status) .timestamp(timestamp); if (status == Status.FAILED && auditor.shouldLogFailedBatchSummary()) { String failedBatchStatement = String.format(BATCH_FAILURE, uuid.toString()); auditor.audit(builder.operation(new SimpleAuditOperation(failedBatchStatement)).build()); } else { for (AuditEntry entry : getBatchOperations(builder, statement, state, options)) { auditor.audit(entry); } } } } }
AuditAdapter { public void auditBatch(BatchStatement statement, UUID uuid, ClientState state, BatchQueryOptions options, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry.Builder builder = entryBuilderFactory.createBatchEntryBuilder() .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .batch(uuid) .status(status) .timestamp(timestamp); if (status == Status.FAILED && auditor.shouldLogFailedBatchSummary()) { String failedBatchStatement = String.format(BATCH_FAILURE, uuid.toString()); auditor.audit(builder.operation(new SimpleAuditOperation(failedBatchStatement)).build()); } else { for (AuditEntry entry : getBatchOperations(builder, statement, state, options)) { auditor.audit(entry); } } } } AuditAdapter(Auditor auditor, AuditEntryBuilderFactory entryBuilderFactory, BoundValueSuppressor boundValueSuppressor); }
AuditAdapter { public void auditBatch(BatchStatement statement, UUID uuid, ClientState state, BatchQueryOptions options, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry.Builder builder = entryBuilderFactory.createBatchEntryBuilder() .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .batch(uuid) .status(status) .timestamp(timestamp); if (status == Status.FAILED && auditor.shouldLogFailedBatchSummary()) { String failedBatchStatement = String.format(BATCH_FAILURE, uuid.toString()); auditor.audit(builder.operation(new SimpleAuditOperation(failedBatchStatement)).build()); } else { for (AuditEntry entry : getBatchOperations(builder, statement, state, options)) { auditor.audit(entry); } } } } AuditAdapter(Auditor auditor, AuditEntryBuilderFactory entryBuilderFactory, BoundValueSuppressor boundValueSuppressor); static AuditAdapter getInstance(); void setup(); void auditRegular(String operation, ClientState state, Status status, long timestamp); void auditPrepared(MD5Digest id, CQLStatement statement, ClientState state, QueryOptions options, Status status, long timestamp); void auditBatch(BatchStatement statement, UUID uuid, ClientState state, BatchQueryOptions options, Status status, long timestamp); void auditAuth(String username, Status status, long timestamp); void auditAuth(String userName, String subject, Status status, long timestamp); void mapIdToQuery(MD5Digest id, String query); Auditor getAuditor(); @VisibleForTesting void setBoundValueSuppressor(BoundValueSuppressor suppressor); @VisibleForTesting BoundValueSuppressor getBoundValueSuppressor(); }
AuditAdapter { public void auditBatch(BatchStatement statement, UUID uuid, ClientState state, BatchQueryOptions options, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry.Builder builder = entryBuilderFactory.createBatchEntryBuilder() .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .batch(uuid) .status(status) .timestamp(timestamp); if (status == Status.FAILED && auditor.shouldLogFailedBatchSummary()) { String failedBatchStatement = String.format(BATCH_FAILURE, uuid.toString()); auditor.audit(builder.operation(new SimpleAuditOperation(failedBatchStatement)).build()); } else { for (AuditEntry entry : getBatchOperations(builder, statement, state, options)) { auditor.audit(entry); } } } } AuditAdapter(Auditor auditor, AuditEntryBuilderFactory entryBuilderFactory, BoundValueSuppressor boundValueSuppressor); static AuditAdapter getInstance(); void setup(); void auditRegular(String operation, ClientState state, Status status, long timestamp); void auditPrepared(MD5Digest id, CQLStatement statement, ClientState state, QueryOptions options, Status status, long timestamp); void auditBatch(BatchStatement statement, UUID uuid, ClientState state, BatchQueryOptions options, Status status, long timestamp); void auditAuth(String username, Status status, long timestamp); void auditAuth(String userName, String subject, Status status, long timestamp); void mapIdToQuery(MD5Digest id, String query); Auditor getAuditor(); @VisibleForTesting void setBoundValueSuppressor(BoundValueSuppressor suppressor); @VisibleForTesting BoundValueSuppressor getBoundValueSuppressor();  }