@Test public void testProcessRegular() { when(mockUser.getName()).thenReturn(USER); when(mockState.getRemoteAddress()).thenReturn(clientSocketAddress); AuditEntry.Builder entryBuilder = AuditEntry.newBuilder().permissions(PERMISSIONS).resource(RESOURCE); when(mockAuditEntryBuilderFactory.createEntryBuilder(eq(STATEMENT), eq(mockState))).thenReturn(entryBuilder); auditAdapter.auditRegular(STATEMENT, mockState, Status.ATTEMPT, TIMESTAMP); AuditEntry entry = getAuditEntry(); assertThat(entry.getClientAddress()).isEqualTo(clientSocketAddress); assertThat(entry.getCoordinatorAddress()).isEqualTo(FBUtilities.getBroadcastAddress()); assertThat(entry.getOperation().getOperationString()).isEqualTo(STATEMENT); assertThat(entry.getUser()).isEqualTo(USER); assertThat(entry.getStatus()).isEqualTo(Status.ATTEMPT); assertThat(entry.getBatchId()).isEmpty(); assertThat(entry.getPermissions()).isEqualTo(PERMISSIONS); assertThat(entry.getResource()).isEqualTo(RESOURCE); assertThat(entry.getTimestamp()).isEqualTo(TIMESTAMP); }
public void auditRegular(String operation, ClientState state, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry logEntry = entryBuilderFactory.createEntryBuilder(operation, state) .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .operation(new SimpleAuditOperation(operation)) .status(status) .timestamp(timestamp) .build(); auditor.audit(logEntry); } }
AuditAdapter { public void auditRegular(String operation, ClientState state, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry logEntry = entryBuilderFactory.createEntryBuilder(operation, state) .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .operation(new SimpleAuditOperation(operation)) .status(status) .timestamp(timestamp) .build(); auditor.audit(logEntry); } } }
AuditAdapter { public void auditRegular(String operation, ClientState state, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry logEntry = entryBuilderFactory.createEntryBuilder(operation, state) .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .operation(new SimpleAuditOperation(operation)) .status(status) .timestamp(timestamp) .build(); auditor.audit(logEntry); } } AuditAdapter(Auditor auditor, AuditEntryBuilderFactory entryBuilderFactory, BoundValueSuppressor boundValueSuppressor); }
AuditAdapter { public void auditRegular(String operation, ClientState state, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry logEntry = entryBuilderFactory.createEntryBuilder(operation, state) .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .operation(new SimpleAuditOperation(operation)) .status(status) .timestamp(timestamp) .build(); auditor.audit(logEntry); } } 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 auditRegular(String operation, ClientState state, Status status, long timestamp) { if (auditor.shouldLogForStatus(status)) { AuditEntry logEntry = entryBuilderFactory.createEntryBuilder(operation, state) .client(state.getRemoteAddress()) .coordinator(FBUtilities.getBroadcastAddress()) .user(state.getUser().getName()) .operation(new SimpleAuditOperation(operation)) .status(status) .timestamp(timestamp) .build(); auditor.audit(logEntry); } } 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();  }