Skip to content

Commit

Permalink
#226 fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Chandler committed Oct 23, 2023
1 parent cd18152 commit 3005874
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void auditRegular(String operation, ClientState state, Status status, lon
auditor.audit(logEntry);
}
}

/**
* Audit a regular CQL statement.
*
Expand All @@ -132,6 +133,7 @@ public void auditPrepare(String operation, ClientState state, Status status, lon
auditor.audit(logEntry);
}
}

/**
* Audit a prepared statement.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public void setWhitelistCacheActiveUpdate(boolean whitelistCacheActiveUpdate)
loadConfigIfNeeded();
yamlConfig.setWhitelistCacheActiveUpdate(whitelistCacheActiveUpdate);
}

public boolean isSuppressPrepareStatements()
{
loadConfigIfNeeded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ public void setWhitelistCacheActiveUpdate(Boolean whitelistCacheActiveUpdate)
{
this.whitelist_cache_active_update = whitelistCacheActiveUpdate;
}

public Boolean isSuppressPrepareStatements()
{
return suppress_prepare_statements == null
? Boolean.TRUE
: suppress_prepare_statements;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public String getOperationString()
{
return operationString;
}

@Override
public String getNakedOperationString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void setup()
@Override
public boolean shouldLogPrepareStatements() { return true; }


/**
* Returns true if the supplied log entry's role or any other role granted to it (directly or indirectly) is
* white-listed for the log entry's specified operations and resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public void setup()
yamlFilter.setup();
roleFilter.setup();
}

@Override
public boolean shouldLogPrepareStatements()
{
return yamlFilter.shouldLogPrepareStatements();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ public void testPrepareAndGetPrepared()
verify(mockHandler, times(1)).prepare(eq(query), eq(mockClientState), eq(customPayload));
verify(mockHandler, times(1)).getPrepared(eq(statementId));
verify(mockAdapter, times(1)).auditPrepare(eq(query), eq(mockClientState), eq(Status.ATTEMPT), longThat(isCloseToNow()));



}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ public void testPrepareStatement()
session.execute(prepared.bind(42, "Kalle"));
assertThat(getLogEntries()).containsOnly( "client:'127.0.0.1'|user:'anonymous'|status:'ATTEMPT'|operation:'Prepared: INSERT INTO school.students (key, value) VALUES (?, ?)'",
"client:'127.0.0.1'|user:'anonymous'|status:'ATTEMPT'|operation:'INSERT INTO school.students (key, value) VALUES (?, ?)[42, 'Kalle']'");

// assertThat(getLogEntries()).containsOnly("client:'127.0.0.1'|user:'anonymous'|status:'ATTEMPT'|operation:'INSERT INTO school.students (key, value) VALUES (?, ?)[42, 'Kalle']'");
}
@Test
public void testFailedPrepareStatement()
Expand All @@ -121,10 +119,8 @@ public void testFailedPrepareStatement()

assertThat(getLogEntries()).containsOnly( "client:'127.0.0.1'|user:'anonymous'|status:'ATTEMPT'|operation:'Prepared: INSERT INTO school.invalidestudents (key, value) VALUES (?, ?)'",
"client:'127.0.0.1'|user:'anonymous'|status:'FAILED'|operation:'Prepared: INSERT INTO school.invalidestudents (key, value) VALUES (?, ?)'");

// verify(mockAuditAppender, never() ).doAppend(loggingEventCaptor.capture());

}

@Test
public void testGrantFails()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void testPrepareStatement()
assertThat(getLogEntries()).containsOnly( "client:'127.0.0.1'|user:'anonymous'|status:'ATTEMPT'|operation:'Prepared: INSERT INTO school.students (key, value) VALUES (?, ?)'",
"client:'127.0.0.1'|user:'anonymous'|status:'ATTEMPT'|operation:'INSERT INTO school.students (key, value) VALUES (?, ?)[42, 'Kalle']'");
}

@Test
public void testFailedPrepareStatement()
{
Expand All @@ -108,8 +109,7 @@ public void testFailedPrepareStatement()
assertThat(getLogEntries()).containsOnly( "client:'127.0.0.1'|user:'anonymous'|status:'ATTEMPT'|operation:'Prepared: INSERT INTO school.invalidestudents (key, value) VALUES (?, ?)'",
"client:'127.0.0.1'|user:'anonymous'|status:'FAILED'|operation:'Prepared: INSERT INTO school.invalidestudents (key, value) VALUES (?, ?)'");
}



private void givenTable(String keyspace, String table)
{
session.execute("CREATE KEYSPACE IF NOT EXISTS " + keyspace + " WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false");
Expand Down

0 comments on commit 3005874

Please sign in to comment.