Skip to content

Commit

Permalink
[misc] skip test with FLUSH PRIVILEGES with MySQL server 8.0.31 tha…
Browse files Browse the repository at this point in the history
…t broke server public key retrieval afterwhile
  • Loading branch information
rusher committed Nov 2, 2022
1 parent 79eb340 commit 63f0264
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/test/java/org/mariadb/jdbc/integration/Common.java
Expand Up @@ -119,6 +119,12 @@ public static boolean minVersion(int major, int minor, int patch) {
return sharedConn.getContext().getVersion().versionGreaterOrEqual(major, minor, patch);
}

public static boolean exactVersion(int major, int minor, int patch) {
return sharedConn.getContext().getVersion().getMajorVersion() == major
&& sharedConn.getContext().getVersion().getMinorVersion() == minor
&& sharedConn.getContext().getVersion().getPatchVersion() == patch;
}

public static Connection createCon() throws SQLException {
return (Connection) DriverManager.getConnection(mDefUrl);
}
Expand Down
Expand Up @@ -862,6 +862,9 @@ public void pamAuthPlugin() throws Throwable {
}
stmt.execute("CREATE USER '" + pamUser + "'@'%' IDENTIFIED VIA pam USING 'mariadb'");
stmt.execute("GRANT SELECT ON *.* TO '" + pamUser + "'@'%' IDENTIFIED VIA pam");

//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");

int testPort = port;
Expand Down Expand Up @@ -993,8 +996,11 @@ public void localSocket() throws Exception {

stmt.execute("CREATE USER testSocket IDENTIFIED BY 'heyPassw!µ20§rd'");
stmt.execute("GRANT SELECT on *.* to testSocket IDENTIFIED BY 'heyPassw!µ20§rd'");
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");


String url =
String.format(
"jdbc:mariadb:///%s?user=testSocket&password=heyPassw!µ20§rd&localSocket=%s&tcpAbortiveClose&tcpKeepAlive",
Expand Down
Expand Up @@ -50,7 +50,10 @@ public static void beforeTest() throws SQLException {
stmt.execute("CREATE USER 'identityUser'@'%' IDENTIFIED BY '!Passw0rd3Works'");
stmt.execute("GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO 'identityUser'@'%'");
}
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");

}

/**
Expand Down
Expand Up @@ -150,8 +150,11 @@ public void switchUser() throws SQLException {
+ sharedConn.getCatalog()
+ ".* TO 'dsUser'@'%' IDENTIFIED BY 'MySup8%rPassw@ord'");
}
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");


DataSource ds = new MariaDbDataSource(mDefUrl + "&allowPublicKeyRetrieval");
try (Connection con1 = ds.getConnection()) {
try (Connection con2 = ds.getConnection("dsUser", "MySup8%rPassw@ord")) {
Expand Down
Expand Up @@ -53,7 +53,10 @@ public static void beforeClassDataSourceTest() throws SQLException {
stmt.execute(
"CREATE TABLE testResetRollback(id int not null primary key auto_increment, test varchar(20))");
stmt.execute("FLUSH TABLES");
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");

}

@AfterAll
Expand Down
Expand Up @@ -240,8 +240,11 @@ public void testPooledConnectionStatementError() throws Exception {
+ sharedConn.getCatalog()
+ ".* TO 'dsUser'@'%' IDENTIFIED BY 'MySup8%rPassw@ord'");
}
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");


ConnectionPoolDataSource ds = new MariaDbDataSource(mDefUrl);
PooledConnection pc = ds.getPooledConnection("dsUser", "MySup8%rPassw@ord");
MyEventListener listener = new MyEventListener();
Expand Down
Expand Up @@ -77,7 +77,10 @@ public static void init() throws Exception {
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User2'@'%'");
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User3'@'%'");
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User4'@'%'");
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");

}

private static String checkFileExists(String path) throws IOException {
Expand Down Expand Up @@ -106,7 +109,13 @@ public void nativePassword() throws Exception {
stmt.execute(
"CREATE USER tmpUser@'%' IDENTIFIED WITH mysql_native_password BY '!Passw0rd3Works'");
stmt.execute("grant all on `" + sharedConn.getCatalog() + "`.* TO tmpUser@'%'");
stmt.execute("FLUSH PRIVILEGES"); // reset cache
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));

//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");

try (Connection con = createCon("user=tmpUser&password=!Passw0rd3Works")) {
con.isValid(1);
}
Expand All @@ -121,7 +130,10 @@ public void nativePassword() throws Exception {
public void cachingSha256Empty() throws Exception {
Assumptions.assumeTrue(
!isWindows() && !isMariaDBServer() && rsaPublicKey != null && minVersion(8, 0, 0));
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache

try (Connection con = createCon("user=cachingSha256User2&allowPublicKeyRetrieval&password=")) {
con.isValid(1);
}
Expand All @@ -131,7 +143,10 @@ public void cachingSha256Empty() throws Exception {
public void wrongRsaPath() throws Exception {
Assumptions.assumeTrue(
!isWindows() && !isMariaDBServer() && rsaPublicKey != null && minVersion(8, 0, 0));
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache

File tempFile = File.createTempFile("log", ".tmp");
Common.assertThrowsContains(
SQLException.class,
Expand All @@ -146,6 +161,8 @@ public void wrongRsaPath() throws Exception {
@Test
public void cachingSha256Allow() throws Exception {
Assumptions.assumeTrue(!isMariaDBServer() && rsaPublicKey != null && minVersion(8, 0, 0));
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache
try (Connection con =
createCon("user=cachingSha256User3&allowPublicKeyRetrieval&password=!Passw0rd3Works")) {
Expand All @@ -156,6 +173,8 @@ public void cachingSha256Allow() throws Exception {
@Test
public void cachingSha256PluginTest() throws Exception {
Assumptions.assumeTrue(!isMariaDBServer() && rsaPublicKey != null && minVersion(8, 0, 0));
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache

try (Connection con =
Expand Down Expand Up @@ -192,6 +211,8 @@ public void cachingSha256PluginTest() throws Exception {
@Test
public void cachingSha256PluginTestWithoutServerRsaKey() throws Exception {
Assumptions.assumeTrue(!isWindows() && minVersion(8, 0, 0));
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache
try (Connection con =
createCon("user=cachingSha256User&password=!Passw0rd3Works&allowPublicKeyRetrieval")) {
Expand All @@ -202,6 +223,8 @@ public void cachingSha256PluginTestWithoutServerRsaKey() throws Exception {
@Test
public void cachingSha256PluginTestException() throws Exception {
Assumptions.assumeTrue(!isMariaDBServer() && minVersion(8, 0, 0));
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache

Common.assertThrowsContains(
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/mariadb/jdbc/integration/SslTest.java
Expand Up @@ -44,6 +44,8 @@ public static void beforeAll2() throws SQLException {
createSslUser("mutualAuthUser", "REQUIRE X509");

Statement stmt = sharedConn.createStatement();
//mysql 8.0.31 broken public key retrieval, so avoid FLUSHING for now
Assumptions.assumeTrue(!isMariaDBServer() && !exactVersion(8, 0 ,31));
stmt.execute("FLUSH PRIVILEGES");
sslPort =
System.getenv("TEST_MAXSCALE_TLS_PORT") == null
Expand Down

0 comments on commit 63f0264

Please sign in to comment.