diff --git a/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyAudit.java b/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyAudit.java index 60e5f922..0acbac40 100644 --- a/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyAudit.java +++ b/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyAudit.java @@ -98,9 +98,9 @@ public static void beforeClass() throws Exception session.execute("ALTER ROLE cassandra WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/system_schema' }"); session.execute("ALTER ROLE cassandra WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/system_virtual_schema' }"); - session.execute("CREATE KEYSPACE ecks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); - session.execute("CREATE TABLE ecks.ectbl (partk int PRIMARY KEY, clustk text, value text)"); - session.execute("CREATE TABLE ecks.ectypetbl (partk int PRIMARY KEY, v0 text, v1 ascii, v2 bigint, v3 blob, v4 boolean, " + session.execute("CREATE KEYSPACE ecks_itva WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); + session.execute("CREATE TABLE ecks_itva.ectbl (partk int PRIMARY KEY, clustk text, value text)"); + session.execute("CREATE TABLE ecks_itva.ectypetbl (partk int PRIMARY KEY, v0 text, v1 ascii, v2 bigint, v3 blob, v4 boolean, " + "v5 date, v6 decimal, v7 double, v8 float, v9 inet, v10 int, v11 smallint, v12 time, v13 timestamp, " + "v14 uuid, v15 varchar, v16 varint)"); @@ -111,12 +111,12 @@ public static void beforeClass() throws Exception session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/system'}"); session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/system_schema'}"); session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/system_virtual_schema'}"); - session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks/ectbl'}"); + session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks_itva/ectbl'}"); session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/nonexistingks'}"); - session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks/nonexistingtbl'}"); + session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks_itva/nonexistingtbl'}"); session.execute("ALTER ROLE sam WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'connections'}"); - session.execute("GRANT MODIFY ON ecks.ectbl TO sam"); - session.execute("GRANT SELECT ON ecks.ectbl TO sam"); + session.execute("GRANT MODIFY ON ecks_itva.ectbl TO sam"); + session.execute("GRANT SELECT ON ecks_itva.ectbl TO sam"); session.execute("CREATE ROLE foo WITH PASSWORD = 'secret' AND LOGIN = true AND SUPERUSER = true"); session.execute("ALTER ROLE foo WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data'}"); @@ -132,9 +132,9 @@ public static void beforeClass() throws Exception session.execute("CREATE ROLE yser2 WITH PASSWORD = 'secret' AND LOGIN = true AND SUPERUSER = true"); - session.execute("CREATE KEYSPACE ecks2 WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); + session.execute("CREATE KEYSPACE ecks_itva2 WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); - session.execute("CREATE KEYSPACE ecks3 WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); + session.execute("CREATE KEYSPACE ecks_itva3 WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); } @Before @@ -155,7 +155,7 @@ public void after() @AfterClass public static void afterClass() { - session.execute("DROP KEYSPACE IF EXISTS ecks"); + session.execute("DROP KEYSPACE IF EXISTS ecks_itva"); session.execute("DROP ROLE IF EXISTS ecuser"); session.execute("DROP ROLE IF EXISTS foo"); session.execute("DROP ROLE IF EXISTS bar"); @@ -266,18 +266,18 @@ public void testValidSimpleStatementsAreLogged() public void testValidPreparedStatementsAreLogged() { PreparedStatement preparedInsertStatement = session - .prepare("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); + .prepare("INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); PreparedStatement preparedSelectStatement = session - .prepare("SELECT * FROM ecks.ectbl WHERE partk = ?"); - PreparedStatement preparedDeleteStatement = session.prepare("DELETE FROM ecks.ectbl WHERE partk = ?"); + .prepare("SELECT * FROM ecks_itva.ectbl WHERE partk = ?"); + PreparedStatement preparedDeleteStatement = session.prepare("DELETE FROM ecks_itva.ectbl WHERE partk = ?"); List expectedStatements = Arrays.asList( - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)[1, '1', 'valid']", - "SELECT * FROM ecks.ectbl WHERE partk = ?[1]", - "DELETE FROM ecks.ectbl WHERE partk = ?[1]", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)[2, '2', 'valid']", - "SELECT * FROM ecks.ectbl WHERE partk = ?[2]", - "DELETE FROM ecks.ectbl WHERE partk = ?[2]"); + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, ?)[1, '1', 'valid']", + "SELECT * FROM ecks_itva.ectbl WHERE partk = ?[1]", + "DELETE FROM ecks_itva.ectbl WHERE partk = ?[1]", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, ?)[2, '2', 'valid']", + "SELECT * FROM ecks_itva.ectbl WHERE partk = ?[2]", + "DELETE FROM ecks_itva.ectbl WHERE partk = ?[2]"); for (int i = 1; i <= 2; i++) { @@ -301,22 +301,22 @@ public void testValidPreparedStatementsAreLogged() public void testValidBatchStatementsAreLogged() { PreparedStatement preparedInsertStatement1 = session - .prepare("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); + .prepare("INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); PreparedStatement preparedInsertStatement2 = session - .prepare("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, 'valid')"); + .prepare("INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, 'valid')"); List expectedStatements = Arrays.asList( - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)[1, '1', 'valid']", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)[2, '2', 'valid']", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, 'valid')[3, '3']", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, 'valid')[5, '5']"); + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, ?)[1, '1', 'valid']", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, ?)[2, '2', 'valid']", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, 'valid')[3, '3']", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, 'valid')[5, '5']"); BatchStatement batch = BatchStatement.builder(DefaultBatchType.UNLOGGED) .addStatement(preparedInsertStatement1.bind(1, "1", "valid")) .addStatement(preparedInsertStatement1.bind(2, "2", "valid")) .addStatement(preparedInsertStatement2.bind(3, "3")) - .addStatement(SimpleStatement.newInstance("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')")) + .addStatement(SimpleStatement.newInstance("INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')")) .addStatement(preparedInsertStatement2.bind(5, "5")) .build(); session.execute(batch); @@ -337,11 +337,11 @@ public void testValidBatchStatementsAreLogged() public void testValidNonPreparedBatchStatementsAreLogged() { List allStatements = Arrays.asList( - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (1, '1', 'valid')", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (2, '2', 'valid')", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (3, '3', 'valid')", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (5, '5', 'valid')"); + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (1, '1', 'valid')", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (2, '2', 'valid')", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (3, '3', 'valid')", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (5, '5', 'valid')"); StringBuilder batchStatementBuilder = new StringBuilder("BEGIN UNLOGGED BATCH "); for (String statement : allStatements) @@ -369,8 +369,8 @@ public void testValidNonPreparedBatchStatementsAreLogged() public void testValidPreparedBatchStatementsAreLogged() { String statement = "BEGIN UNLOGGED BATCH USING TIMESTAMP ? " + - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?); " + - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, 'valid'); " + + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, ?); " + + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (?, ?, 'valid'); " + "APPLY BATCH;"; List expectedStatements = Collections.singletonList(statement + "[1234, 1, '1', 'valid', 3, '3']"); @@ -393,12 +393,12 @@ public void testValidPreparedBatchStatementsAreLogged() public void testValidPreparedStatementTypesAreLogged() throws Exception { PreparedStatement preparedStatement = session - .prepare("INSERT INTO ecks.ectypetbl " + .prepare("INSERT INTO ecks_itva.ectypetbl " + "(partk, v0, v1, v2, v4, v5, v9, v13, v15)" + " VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?, ?)"); - String expectedStatement = "INSERT INTO ecks.ectypetbl " + String expectedStatement = "INSERT INTO ecks_itva.ectypetbl " + "(partk, v0, v1, v2, v4, v5, v9, v13, v15)" + " VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?, ?)[1, 'text', 'ascii', 123123123123123123, true, '1976-02-25', '8.8.8.8', '2004-05-29T14:29:00.000Z', 'varchar']"; @@ -425,7 +425,7 @@ public void testValidPreparedStatementTypesAreLogged() throws Exception @Test public void testValidSimpleStatementTypesAreLogged() { - String statement = "INSERT INTO ecks.ectypetbl " + String statement = "INSERT INTO ecks_itva.ectypetbl " + "(partk, v0, v1, v2, v4, v5, v9, v13, v15)" + " VALUES " + "(1, 'text', 'ascii', 123123123123123123, true, '1976-02-25', '8.8.8.8', '2004-05-29T14:29:00.000Z', 'varchar')"; @@ -476,9 +476,9 @@ public void testWhitelistedUserValidStatementsWithUseAreNotLogged() // Driver or Cassandra will add double-quotes to ks on one of the connections if statemens doesn't have it here. // TODO: Research if this is "bug" in Cassandra, driver or ecAudit? List statements = Arrays.asList( - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (1, 'one', 'valid')", - "SELECT * FROM ecks.ectbl", - "USE \"ecks\"", + "INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (1, 'one', 'valid')", + "SELECT * FROM ecks_itva.ectbl", + "USE \"ecks_itva\"", "INSERT INTO ectbl (partk, clustk, value) VALUES (1, 'one', 'valid')", "SELECT * FROM ectbl"); @@ -501,7 +501,7 @@ public void testWhitelistedUserValidStatementsWithUseAreNotLogged() .stream() .map(ILoggingEvent::getFormattedMessage) .collect(Collectors.toList())) - .containsOnlyElementsOf(expectedAttemptsAsUser(Arrays.asList("USE \"ecks\""), user)); + .containsOnlyElementsOf(expectedAttemptsAsUser(Arrays.asList("USE \"ecks_itva\""), user)); } /** @@ -517,23 +517,23 @@ public void testMultipleUseStatementsPreserveOrder() String user = "sam"; try (CqlSession privateSession = cdt.createSession(user, "secret")) { - executeOneUseWithFollowingSelect(user, privateSession, "USE \"ecks\""); - executeOneUseWithFollowingSelect(user, privateSession, "USE \"ecks2\""); - executeOneUseWithFollowingSelect(user, privateSession, "USE \"ecks3\""); + executeOneUseWithFollowingSelect(user, privateSession, "USE \"ecks_itva\""); + executeOneUseWithFollowingSelect(user, privateSession, "USE \"ecks_itva2\""); + executeOneUseWithFollowingSelect(user, privateSession, "USE \"ecks_itva3\""); } } private void executeOneUseWithFollowingSelect(String user, CqlSession privateSession, String useStatement) { ArgumentCaptor loggingEventCaptor1 = ArgumentCaptor.forClass(ILoggingEvent.class); privateSession.execute(useStatement); - privateSession.execute("SELECT * FROM ecks.ectypetbl"); + privateSession.execute("SELECT * FROM ecks_itva.ectypetbl"); verify(mockAuditAppender, atLeast(2)).doAppend(loggingEventCaptor1.capture()); List loggingEvents1 = loggingEventCaptor1.getAllValues(); assertThat(loggingEvents1 .stream() .map(ILoggingEvent::getFormattedMessage) .collect(Collectors.toList())) - .containsOnlyElementsOf(expectedAttemptsAsUser(Arrays.asList(useStatement, "SELECT * FROM ecks.ectypetbl"), user)); + .containsOnlyElementsOf(expectedAttemptsAsUser(Arrays.asList(useStatement, "SELECT * FROM ecks_itva.ectypetbl"), user)); reset(mockAuditAppender); } @@ -542,11 +542,11 @@ public void testFailedStatementsAreLogged() { List statements = Arrays.asList( "CREATE ROLE ecuser WITH PASSWORD = 'secret' AND LOGIN = true", - "CREATE KEYSPACE ecks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false", - "CREATE TABLE ecks.ectbl (partk int PRIMARY KEY, clustk text, value text)", + "CREATE KEYSPACE ecks_itva WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false", + "CREATE TABLE ecks_itva.ectbl (partk int PRIMARY KEY, clustk text, value text)", "INSERT INTO invalidks.invalidtbl (partk, clustk, value) VALUES (1, 'one', 'valid')", "SELECT * FROM invalidks.invalidtbl", - "SELECT * FROM ecks.invalidtbl", + "SELECT * FROM ecks_itva.invalidtbl", "DELETE FROM invalidks.invalidtbl WHERE partk = 2", "DROP KEYSPACE invalidks", "DROP ROLE invaliduser", @@ -573,9 +573,9 @@ public void testFailedWhitelistedStatementsAreNotLogged() { List statements = Arrays.asList( "SELECT * FROM nonexistingks.nonexistingtbl", - "SELECT * FROM ecks.nonexistingtbl", + "SELECT * FROM ecks_itva.nonexistingtbl", "INSERT INTO nonexistingks.nonexistingtbl (partk, clustk, value) VALUES (1, 'one', 'valid')", - "INSERT INTO ecks.nonexistingtbl (partk, clustk, value) VALUES (1, 'one', 'valid')"); + "INSERT INTO ecks_itva.nonexistingtbl (partk, clustk, value) VALUES (1, 'one', 'valid')"); try (CqlSession privateSession = cdt.createSession("sam", "secret")) { @@ -598,7 +598,7 @@ public void testFailedWhitelistedBatchStatementIsNotLogged() for (String statement : statements) { BatchStatement batch = BatchStatement.builder(DefaultBatchType.UNLOGGED) - .addStatement(SimpleStatement.newInstance("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')")) + .addStatement(SimpleStatement.newInstance("INSERT INTO ecks_itva.ectbl (partk, clustk, value) VALUES (4, '4', 'valid')")) .addStatement(SimpleStatement.newInstance(statement)) .build(); assertThatExceptionOfType(InvalidQueryException.class).isThrownBy(() -> privateSession.execute(batch)); diff --git a/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyThreadedAudit.java b/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyThreadedAudit.java index 4f96d6d9..e0172c88 100644 --- a/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyThreadedAudit.java +++ b/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyThreadedAudit.java @@ -71,16 +71,16 @@ public static void beforeClass() throws Exception try (CqlSession session = cdt.createSession()) { - session.execute("CREATE KEYSPACE ecks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); - session.execute("CREATE TABLE ecks.ectbl (partk int PRIMARY KEY, clustk text, value text)"); + session.execute("CREATE KEYSPACE ecks_itvta WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); + session.execute("CREATE TABLE ecks_itvta.ectbl (partk int PRIMARY KEY, clustk text, value text)"); session.execute("CREATE ROLE test_role WITH LOGIN = false"); session.execute("ALTER ROLE test_role WITH OPTIONS = { 'grant_audit_whitelist_for_select' : 'data/system' }"); session.execute("ALTER ROLE test_role WITH OPTIONS = { 'grant_audit_whitelist_for_select' : 'data/system_schema' }"); session.execute("ALTER ROLE test_role WITH OPTIONS = { 'grant_audit_whitelist_for_select' : 'data/system_virtual_schema' }"); session.execute("ALTER ROLE test_role WITH OPTIONS = { 'grant_audit_whitelist_for_execute' : 'connections' }"); - session.execute("GRANT MODIFY ON ecks.ectbl TO test_role"); - session.execute("GRANT SELECT ON ecks.ectbl TO test_role"); + session.execute("GRANT MODIFY ON ecks_itvta.ectbl TO test_role"); + session.execute("GRANT SELECT ON ecks_itvta.ectbl TO test_role"); for (int i = 0; i < USER_COUNT; i++) { @@ -110,7 +110,7 @@ public static void afterClass() { try (CqlSession session = cdt.createSession()) { - session.execute("DROP KEYSPACE IF EXISTS ecks"); + session.execute("DROP KEYSPACE IF EXISTS ecks_itvta"); session.execute("DROP ROLE IF EXISTS test_role"); for (int i = 0; i < USER_COUNT; i++) { @@ -179,21 +179,21 @@ public List call() try (CqlSession privateSession = cdt.createSession(username, "secret")) { PreparedStatement preparedInsertStatement = privateSession - .prepare("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); + .prepare("INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); PreparedStatement preparedSelectStatement = privateSession - .prepare("SELECT * FROM ecks.ectbl WHERE partk = ?"); + .prepare("SELECT * FROM ecks_itvta.ectbl WHERE partk = ?"); PreparedStatement preparedDeleteStatement = privateSession - .prepare("DELETE FROM ecks.ectbl WHERE partk = ?"); + .prepare("DELETE FROM ecks_itvta.ectbl WHERE partk = ?"); List expectedStatements = new ArrayList<>(); for (int i = 0; i < 100; i++) { expectedStatements.addAll(Arrays.asList( - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)[" + i + ", '" + i + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, ?)[" + i + ", '" + i + "', 'valid']", - "SELECT * FROM ecks.ectbl WHERE partk = ?[" + i + "]", - "DELETE FROM ecks.ectbl WHERE partk = ?[" + i + "]")); + "SELECT * FROM ecks_itvta.ectbl WHERE partk = ?[" + i + "]", + "DELETE FROM ecks_itvta.ectbl WHERE partk = ?[" + i + "]")); privateSession.execute(preparedInsertStatement.bind(i, Integer.toString(i), "valid")); privateSession.execute(preparedSelectStatement.bind(i)); @@ -220,22 +220,22 @@ public List call() try (CqlSession session = cdt.createSession(username, "secret")) { PreparedStatement preparedInsertStatement1 = session - .prepare("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); + .prepare("INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, ?)"); PreparedStatement preparedInsertStatement2 = session - .prepare("INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, 'static')"); + .prepare("INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, 'static')"); PreparedStatement preparedInsertStatement3 = session - .prepare("INSERT INTO ecks.ectbl (partk, clustk) VALUES (?, ?)"); + .prepare("INSERT INTO ecks_itvta.ectbl (partk, clustk) VALUES (?, ?)"); List expectedStatements = new ArrayList<>(); for (int i = 0; i < 10; i++) { expectedStatements.addAll(Arrays.asList( - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)[" + (100 + i) + ", '1', 'b1']", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?)[" + (200 + i) + ", '2', 'b2']", - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, 'static')[" + (300 + i) + ", '3']", - "INSERT INTO ecks.ectbl (partk, clustk) VALUES (?, ?)[" + (400 + i) + ", '4']", - "INSERT INTO ecks.ectbl (partk, clustk) VALUES (?, ?)[" + (500 + i) + ", '5']")); + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, ?)[" + (100 + i) + ", '1', 'b1']", + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, ?)[" + (200 + i) + ", '2', 'b2']", + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, 'static')[" + (300 + i) + ", '3']", + "INSERT INTO ecks_itvta.ectbl (partk, clustk) VALUES (?, ?)[" + (400 + i) + ", '4']", + "INSERT INTO ecks_itvta.ectbl (partk, clustk) VALUES (?, ?)[" + (500 + i) + ", '5']")); BatchStatement batch = BatchStatement.builder(DefaultBatchType.UNLOGGED) .addStatement(preparedInsertStatement1.bind(100 + i, "1", "b1")) .addStatement(preparedInsertStatement1.bind(200 + i, "2", "b2")) @@ -270,11 +270,11 @@ public List call() for (int i = 0; i < 10; i++) { String batchStatement = "BEGIN UNLOGGED BATCH " + - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (" + (100 + i) + ", '1', 'b1'); " + - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (" + (200 + i) + ", '2', 'b2'); " + - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (" + (300 + i) + ", '3', 'static'); " + - "INSERT INTO ecks.ectbl (partk, clustk) VALUES (" + (400 + i) + ", '4'); " + - "INSERT INTO ecks.ectbl (partk, clustk) VALUES (" + (500 + i) + ", '5'); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (" + (100 + i) + ", '1', 'b1'); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (" + (200 + i) + ", '2', 'b2'); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (" + (300 + i) + ", '3', 'static'); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk) VALUES (" + (400 + i) + ", '4'); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk) VALUES (" + (500 + i) + ", '5'); " + "APPLY BATCH;"; expectedStatements.add(batchStatement); session.execute(batchStatement); @@ -300,9 +300,9 @@ public List call() try (CqlSession session = cdt.createSession(username, "secret")) { String batch = "BEGIN UNLOGGED BATCH USING TIMESTAMP ? " + - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, ?); " + - "INSERT INTO ecks.ectbl (partk, clustk, value) VALUES (?, ?, 'static'); " + - "INSERT INTO ecks.ectbl (partk, clustk) VALUES (?, ?); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, ?); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk, value) VALUES (?, ?, 'static'); " + + "INSERT INTO ecks_itvta.ectbl (partk, clustk) VALUES (?, ?); " + "APPLY BATCH;"; PreparedStatement preparedBatchStatement = session.prepare(batch); diff --git a/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyWhitelistManagement.java b/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyWhitelistManagement.java index 57ad3ffb..b338e860 100644 --- a/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyWhitelistManagement.java +++ b/integration-test-standard/src/test/java/com/ericsson/bss/cassandra/ecaudit/integration/standard/ITVerifyWhitelistManagement.java @@ -70,20 +70,20 @@ public static void beforeClass() throws Exception session = cdt.createSession(); - session.execute("CREATE KEYSPACE ecks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); - session.execute("CREATE TABLE ecks.ectbl (partk int PRIMARY KEY, clustk text, value text)"); + session.execute("CREATE KEYSPACE ecks_itvwm WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1} AND DURABLE_WRITES = false"); + session.execute("CREATE TABLE ecks_itvwm.ectbl (partk int PRIMARY KEY, clustk text, value text)"); session.execute("CREATE ROLE ordinary_user WITH PASSWORD = 'secret' AND LOGIN = true"); - session.execute("GRANT SELECT ON TABLE ecks.ectbl TO ordinary_user"); + session.execute("GRANT SELECT ON TABLE ecks_itvwm.ectbl TO ordinary_user"); session.execute("CREATE ROLE create_user WITH PASSWORD = 'secret' AND LOGIN = true"); - session.execute("GRANT SELECT ON TABLE ecks.ectbl TO create_user"); + session.execute("GRANT SELECT ON TABLE ecks_itvwm.ectbl TO create_user"); session.execute("GRANT CREATE ON ALL ROLES TO create_user"); session.execute("CREATE ROLE other_user WITH PASSWORD = 'secret' AND LOGIN = true AND SUPERUSER = false"); session.execute("CREATE ROLE authorized_user WITH PASSWORD = 'secret' AND LOGIN = true"); - session.execute("GRANT SELECT ON TABLE ecks.ectbl TO authorized_user"); + session.execute("GRANT SELECT ON TABLE ecks_itvwm.ectbl TO authorized_user"); session.execute("GRANT CREATE ON ALL ROLES TO authorized_user"); session.execute("GRANT AUTHORIZE ON ALL KEYSPACES TO authorized_user"); @@ -98,7 +98,7 @@ public static void beforeClass() throws Exception session.execute("CREATE ROLE whitelist_role WITH LOGIN = false"); session.execute("ALTER ROLE whitelist_role WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data' }"); session.execute("CREATE ROLE trusted_user WITH PASSWORD = 'secret' AND LOGIN = true"); - session.execute("GRANT SELECT ON TABLE ecks.ectbl TO trusted_user"); + session.execute("GRANT SELECT ON TABLE ecks_itvwm.ectbl TO trusted_user"); session.execute("GRANT AUTHORIZE ON ROLE whitelist_role TO trusted_user"); session.execute("GRANT CREATE ON ALL ROLES TO trusted_user"); @@ -116,7 +116,7 @@ public void after() @AfterClass public static void afterClass() { - session.execute("DROP KEYSPACE IF EXISTS ecks"); + session.execute("DROP KEYSPACE IF EXISTS ecks_itvwm"); session.execute("DROP ROLE IF EXISTS whitelist_role"); session.execute("DROP ROLE IF EXISTS ordinary_user"); session.execute("DROP ROLE IF EXISTS create_user"); @@ -241,9 +241,9 @@ public void testSuperUserCanWhitelistOnData() public void testSuperUserCanWhitelistOnDataPartly() { given_temporary_user(superSession); - superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks/ectbl' }"); + superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks_itvwm/ectbl' }"); - assertRoleOperations("temporary_user", "data/ecks/ectbl", asList("ALTER", "DROP", "SELECT", "MODIFY", "AUTHORIZE", "UNMASK", "SELECT_MASKED")); + assertRoleOperations("temporary_user", "data/ecks_itvwm/ectbl", asList("ALTER", "DROP", "SELECT", "MODIFY", "AUTHORIZE", "UNMASK", "SELECT_MASKED")); } @Test @@ -266,23 +266,23 @@ public void testSuperUserCanNotWhitelistOnInvalidKeyspace() public void testSuperUserCanWhitelistOnNonexistingTable() { given_temporary_user(superSession); - superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks/unknowntbl' }"); + superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks_itvwm/unknowntbl' }"); - assertRoleOperations("temporary_user", "data/ecks/unknowntbl", asList("ALTER", "DROP", "SELECT", "MODIFY", "AUTHORIZE", "UNMASK", "SELECT_MASKED")); + assertRoleOperations("temporary_user", "data/ecks_itvwm/unknowntbl", asList("ALTER", "DROP", "SELECT", "MODIFY", "AUTHORIZE", "UNMASK", "SELECT_MASKED")); } @Test (expected = InvalidQueryException.class) public void testSuperUserCanNotWhitelistOnInvalidTable() { given_temporary_user(superSession); - superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks/unknown?tbl' }"); + superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks_itvwm/unknown?tbl' }"); } @Test (expected = InvalidQueryException.class) public void testSuperUserCanNotWhitelistTwoOperationsInOneStatement() { given_temporary_user(superSession); - superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_select' : 'data/ecks' ,'grant_audit_whitelist_for_modify' : 'data/ecks'}"); + superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_select' : 'data/ecks_itvwm' ,'grant_audit_whitelist_for_modify' : 'data/ecks_itvwm'}"); } @Test @@ -339,7 +339,7 @@ public void testSuperUserCanWhitelistOnRoles() public void testSuperUserCanNotWhitelistOnInvalidDataResource() { given_temporary_user(superSession); - superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks/unknowntbl/invalid' }"); + superSession.execute("ALTER ROLE temporary_user WITH OPTIONS = { 'grant_audit_whitelist_for_all' : 'data/ecks_itvwm/unknowntbl/invalid' }"); } @Test (expected = InvalidQueryException.class)