Skip to content

Commit c8ce979

Browse files
committed
fixed created user and profile to cleanup first
1 parent c02ea43 commit c8ce979

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

jdbc-v2/src/test/java/com/clickhouse/jdbc/ReadonlyProfileTest.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,33 @@ public void setup() throws SQLException {
2424
com.clickhouse.client.ClickHouseServerForTest.beforeSuite();
2525
try (Connection conn = getJdbcConnection();
2626
Statement stmt = conn.createStatement()) {
27-
stmt.execute("CREATE SETTINGS PROFILE IF NOT EXISTS profile_readonly_1 SETTINGS readonly=1");
28-
stmt.execute("CREATE SETTINGS PROFILE IF NOT EXISTS profile_readonly_2 SETTINGS readonly=2");
29-
stmt.execute("CREATE USER IF NOT EXISTS user_readonly_1 IDENTIFIED WITH plaintext_password BY '" + password + "' SETTINGS PROFILE profile_readonly_1");
30-
stmt.execute("CREATE USER IF NOT EXISTS user_readonly_2 IDENTIFIED WITH plaintext_password BY '" + password + "' SETTINGS PROFILE profile_readonly_2");
27+
stmt.execute("CREATE SETTINGS PROFILE IF NOT EXISTS jdbc_test_profile_readonly_1 SETTINGS readonly=1");
28+
stmt.execute("CREATE SETTINGS PROFILE IF NOT EXISTS jdbc_test_profile_readonly_2 SETTINGS readonly=2");
29+
stmt.execute("DROP USER IF EXISTS jdbc_test_user_readonly_1");
30+
stmt.execute("DROP USER IF EXISTS jdbc_test_user_readonly_2");
31+
stmt.execute("CREATE USER jdbc_test_user_readonly_1 IDENTIFIED WITH plaintext_password BY '" + password + "' SETTINGS PROFILE jdbc_test_profile_readonly_1");
32+
stmt.execute("CREATE USER jdbc_test_user_readonly_2 IDENTIFIED WITH plaintext_password BY '" + password + "' SETTINGS PROFILE jdbc_test_profile_readonly_2");
3133
String db = getDatabase();
32-
stmt.execute("GRANT SELECT ON " + db + ".* TO user_readonly_1");
33-
stmt.execute("GRANT SELECT ON " + db + ".* TO user_readonly_2");
34+
stmt.execute("GRANT SELECT ON " + db + ".* TO jdbc_test_user_readonly_1");
35+
stmt.execute("GRANT SELECT ON " + db + ".* TO jdbc_test_user_readonly_2");
3436
}
3537
}
3638

3739
@AfterClass(groups = { "integration" })
3840
public void teardown() throws SQLException {
3941
try (Connection conn = getJdbcConnection();
4042
Statement stmt = conn.createStatement()) {
41-
stmt.execute("DROP USER IF EXISTS user_readonly_1");
42-
stmt.execute("DROP USER IF EXISTS user_readonly_2");
43-
stmt.execute("DROP SETTINGS PROFILE IF EXISTS profile_readonly_1");
44-
stmt.execute("DROP SETTINGS PROFILE IF EXISTS profile_readonly_2");
43+
stmt.execute("DROP USER IF EXISTS jdbc_test_user_readonly_1");
44+
stmt.execute("DROP USER IF EXISTS jdbc_test_user_readonly_2");
45+
stmt.execute("DROP SETTINGS PROFILE IF EXISTS jdbc_test_profile_readonly_1");
46+
stmt.execute("DROP SETTINGS PROFILE IF EXISTS jdbc_test_profile_readonly_2");
4547
}
4648
}
4749

4850
@Test(groups = { "integration" })
4951
public void testReadonly1CannotChangeSettings() throws Exception {
5052
Properties properties = new Properties();
51-
properties.setProperty("user", "user_readonly_1");
53+
properties.setProperty("user", "jdbc_test_user_readonly_1");
5254
properties.setProperty("password", password);
5355
properties.put(ClientConfigProperties.serverSetting(ServerSettings.OUTPUT_FORMAT_BINARY_WRITE_JSON_AS_STRING), "1");
5456

@@ -69,7 +71,7 @@ public void testReadonly2CanChangeSettings() throws Exception {
6971
}
7072

7173
Properties properties = new Properties();
72-
properties.setProperty("user", "user_readonly_2");
74+
properties.setProperty("user", "jdbc_test_user_readonly_2");
7375
properties.setProperty("password", password);
7476
properties.put(ClientConfigProperties.serverSetting(ServerSettings.OUTPUT_FORMAT_BINARY_WRITE_JSON_AS_STRING), "1");
7577
properties.put(ClientConfigProperties.serverSetting("allow_experimental_json_type"), "1");

0 commit comments

Comments
 (0)