mirror of
https://github.com/mariadb-corporation/mariadb-connector-j.git
synced 2025-07-23 05:12:56 +00:00
[misc] test stability improvement
This commit is contained in:
@ -293,6 +293,13 @@ public class Common {
|
||||
return System.getProperty("os.name").toLowerCase().contains("win");
|
||||
}
|
||||
|
||||
public static String getHostSuffix() {
|
||||
if ("local".equals(System.getenv().getOrDefault("LOCAL_DB", "container"))) {
|
||||
return "@'localhost'";
|
||||
}
|
||||
return "@'%'";
|
||||
}
|
||||
|
||||
public int getJavaVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
if (version.startsWith("1.")) {
|
||||
|
@ -175,7 +175,9 @@ public class ConfigurationTest extends Common {
|
||||
// could be different, because charset default might differ from server default
|
||||
assertTrue(
|
||||
rs.getString(2).equals(rs.getString(1))
|
||||
|| "utf8mb4_unicode_ci".equals(rs.getString(1)));
|
||||
|| "utf8mb4_unicode_ci".equals(rs.getString(1))
|
||||
|| "utf8mb4_general_ci".equals(rs.getString(1)),
|
||||
"collation was " + rs.getString(1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +188,9 @@ public class ConfigurationTest extends Common {
|
||||
// could be different, because charset default might differ from server default
|
||||
if (rs.getString(1).startsWith("utf8mb4")) {
|
||||
assertTrue(
|
||||
rs.getString(2).equals(rs.getString(1)) || "utf8mb4_unicode_ci".equals(rs.getString(1)));
|
||||
rs.getString(2).equals(rs.getString(1))
|
||||
|| "utf8mb4_unicode_ci".equals(rs.getString(1))
|
||||
|| "utf8mb4_general_ci".equals(rs.getString(1)));
|
||||
}
|
||||
|
||||
assertThrowsContains(
|
||||
|
@ -748,32 +748,39 @@ public class ConnectionTest extends Common {
|
||||
Assumptions.assumeTrue(false, "server doesn't have ed25519 plugin, cancelling test");
|
||||
}
|
||||
try {
|
||||
stmt.execute("drop user verificationEd25519AuthPlugin@'%'");
|
||||
stmt.execute("drop user verificationEd25519AuthPlugin" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
try {
|
||||
if (minVersion(10, 4, 0)) {
|
||||
stmt.execute(
|
||||
"CREATE USER IF NOT EXISTS verificationEd25519AuthPlugin@'%' IDENTIFIED "
|
||||
"CREATE USER IF NOT EXISTS verificationEd25519AuthPlugin"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED "
|
||||
+ "VIA ed25519 USING PASSWORD('MySup8%rPassw@ord')");
|
||||
} else {
|
||||
stmt.execute(
|
||||
"CREATE USER IF NOT EXISTS verificationEd25519AuthPlugin@'%' IDENTIFIED "
|
||||
"CREATE USER IF NOT EXISTS verificationEd25519AuthPlugin"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED "
|
||||
+ "VIA ed25519 USING '6aW9C7ENlasUfymtfMvMZZtnkCVlcb1ssxOLJ0kj/AA'");
|
||||
}
|
||||
} catch (SQLException sqle) {
|
||||
// already existing
|
||||
}
|
||||
stmt.execute(
|
||||
"GRANT SELECT on " + sharedConn.getCatalog() + ".* to verificationEd25519AuthPlugin@'%'");
|
||||
"GRANT SELECT on "
|
||||
+ sharedConn.getCatalog()
|
||||
+ ".* to verificationEd25519AuthPlugin"
|
||||
+ getHostSuffix());
|
||||
|
||||
try (Connection connection =
|
||||
createCon("user=verificationEd25519AuthPlugin&password=MySup8%rPassw@ord")) {
|
||||
// must have succeeded
|
||||
connection.getCatalog();
|
||||
}
|
||||
stmt.execute("drop user verificationEd25519AuthPlugin@'%'");
|
||||
stmt.execute("drop user verificationEd25519AuthPlugin" + getHostSuffix());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -788,13 +795,16 @@ public class ConnectionTest extends Common {
|
||||
Assumptions.assumeTrue(false, "server doesn't have auth_parsec plugin, cancelling test");
|
||||
}
|
||||
|
||||
stmt.execute("drop user IF EXISTS verifParsec@'%'");
|
||||
stmt.execute("drop user IF EXISTS verifParsec2@'%'");
|
||||
stmt.execute("drop user IF EXISTS verifParsec" + getHostSuffix());
|
||||
stmt.execute("drop user IF EXISTS verifParsec2" + getHostSuffix());
|
||||
stmt.execute(
|
||||
"CREATE USER verifParsec@'%' IDENTIFIED VIA parsec USING PASSWORD('MySup8%rPassw@ord')");
|
||||
stmt.execute("CREATE USER verifParsec2@'%' IDENTIFIED VIA parsec USING PASSWORD('')");
|
||||
stmt.execute("GRANT SELECT on `" + database + "`.* to verifParsec@'%'");
|
||||
stmt.execute("GRANT SELECT on `" + database + "`.* to verifParsec2@'%'");
|
||||
"CREATE USER verifParsec"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED VIA parsec USING PASSWORD('MySup8%rPassw@ord')");
|
||||
stmt.execute(
|
||||
"CREATE USER verifParsec2" + getHostSuffix() + " IDENTIFIED VIA parsec USING PASSWORD('')");
|
||||
stmt.execute("GRANT SELECT on `" + database + "`.* to verifParsec" + getHostSuffix());
|
||||
stmt.execute("GRANT SELECT on `" + database + "`.* to verifParsec2" + getHostSuffix());
|
||||
|
||||
String version = System.getProperty("java.version");
|
||||
int majorVersion =
|
||||
@ -820,8 +830,8 @@ public class ConnectionTest extends Common {
|
||||
SQLException.class,
|
||||
() -> createCon("user=verifParsec2&password=MySup8%rPassw@ord&restrictedAuth=dialog"),
|
||||
"Client restrict authentication plugin to a limited set");
|
||||
stmt.execute("drop user verifParsec@'%'");
|
||||
stmt.execute("drop user verifParsec2@'%'");
|
||||
stmt.execute("drop user verifParsec" + getHostSuffix());
|
||||
stmt.execute("drop user verifParsec2" + getHostSuffix());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -846,12 +856,13 @@ public class ConnectionTest extends Common {
|
||||
String pamUser = System.getenv("TEST_PAM_USER");
|
||||
String pamPwd = System.getenv("TEST_PAM_PWD");
|
||||
try {
|
||||
stmt.execute("DROP USER '" + pamUser + "'@'%'");
|
||||
stmt.execute("DROP USER '" + pamUser + "'" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
stmt.execute("CREATE USER '" + pamUser + "'@'%' IDENTIFIED VIA pam USING 'mariadb'");
|
||||
stmt.execute("GRANT SELECT ON *.* TO '" + pamUser + "'@'%' IDENTIFIED VIA pam");
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON *.* TO '" + pamUser + "'" + getHostSuffix() + " IDENTIFIED VIA pam");
|
||||
|
||||
stmt.execute("FLUSH PRIVILEGES");
|
||||
|
||||
@ -899,7 +910,7 @@ public class ConnectionTest extends Common {
|
||||
() -> DriverManager.getConnection(connStr + "&restrictedAuth=other"),
|
||||
"Client restrict authentication plugin to a limited set of authentication");
|
||||
|
||||
stmt.execute("drop user " + pamUser + "@'%'");
|
||||
stmt.execute("drop user " + pamUser + getHostSuffix());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1441,17 +1452,19 @@ public class ConnectionTest extends Common {
|
||||
Assumptions.assumeTrue(srvHasCapability(Capabilities.CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS));
|
||||
boolean forced = false;
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
System.out.println("getHostSuffix(): " + getHostSuffix());
|
||||
try {
|
||||
stmt.execute("DROP USER IF EXISTS 'expired_pwd_user'@'%'");
|
||||
stmt.execute("CREATE USER 'expired_pwd_user'@'%' IDENTIFIED by '!Passw0rd3Works'");
|
||||
stmt.execute("GRANT all on *.* to 'expired_pwd_user'");
|
||||
stmt.execute("DROP USER IF EXISTS 'expired_pwd_user'" + getHostSuffix());
|
||||
stmt.execute(
|
||||
"CREATE USER 'expired_pwd_user'" + getHostSuffix() + " IDENTIFIED by '!Passw0rd3Works'");
|
||||
stmt.execute("GRANT all on *.* to 'expired_pwd_user'" + getHostSuffix());
|
||||
|
||||
String connStr =
|
||||
String.format(
|
||||
"jdbc:mariadb://%s:%s/%s?user=%s&password=%s&%s&allowPublicKeyRetrieval=true",
|
||||
hostname, port, database, "expired_pwd_user", "!Passw0rd3Works", defaultOther);
|
||||
|
||||
stmt.execute("ALTER USER 'expired_pwd_user'@'%' PASSWORD EXPIRE");
|
||||
stmt.execute("ALTER USER 'expired_pwd_user'" + getHostSuffix() + " PASSWORD EXPIRE");
|
||||
stmt.execute("FLUSH PRIVILEGES");
|
||||
if (isMariaDBServer()) {
|
||||
// force
|
||||
|
@ -35,22 +35,18 @@ public class CredentialPluginTest extends Common {
|
||||
&& (isMariaDBServer() || !minVersion(8, 0, 0));
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
if (useOldNotation) {
|
||||
stmt.execute("CREATE USER 'identityUser'@'localhost'");
|
||||
stmt.execute("CREATE USER 'identityUser'" + getHostSuffix());
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON "
|
||||
+ sharedConn.getCatalog()
|
||||
+ ".* TO 'identityUser'@'localhost' IDENTIFIED BY '!Passw0rd3Works'");
|
||||
stmt.execute("CREATE USER 'identityUser'@'%'");
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON "
|
||||
+ sharedConn.getCatalog()
|
||||
+ ".* TO 'identityUser'@'%' IDENTIFIED BY '!Passw0rd3Works'");
|
||||
+ ".* TO 'identityUser'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED BY '!Passw0rd3Works'");
|
||||
} else {
|
||||
stmt.execute("CREATE USER 'identityUser'@'localhost' IDENTIFIED BY '!Passw0rd3Works'");
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO 'identityUser'@'localhost'");
|
||||
stmt.execute("CREATE USER 'identityUser'@'%' IDENTIFIED BY '!Passw0rd3Works'");
|
||||
stmt.execute("GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO 'identityUser'@'%'");
|
||||
"CREATE USER 'identityUser'" + getHostSuffix() + " IDENTIFIED BY '!Passw0rd3Works'");
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO 'identityUser'" + getHostSuffix());
|
||||
}
|
||||
stmt.execute("FLUSH PRIVILEGES");
|
||||
}
|
||||
@ -64,12 +60,7 @@ public class CredentialPluginTest extends Common {
|
||||
public static void drop() throws SQLException {
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
try {
|
||||
stmt.execute("DROP USER 'identityUser'@'%'");
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
try {
|
||||
stmt.execute("DROP USER 'identityUser'@'localhost'");
|
||||
stmt.execute("DROP USER 'identityUser'" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
|
@ -134,26 +134,31 @@ public class DataSourceTest extends Common {
|
||||
&& !"skysql-ha".equals(System.getenv("srv")));
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
try {
|
||||
stmt.execute("DROP USER 'dsUser'@'%'");
|
||||
stmt.execute("DROP USER 'dsUser'" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
|
||||
if (minVersion(8, 0, 0)) {
|
||||
if (isMariaDBServer() || minVersion(8, 4, 0)) {
|
||||
stmt.execute("CREATE USER 'dsUser'@'%' IDENTIFIED BY 'MySup8%rPassw@ord'");
|
||||
stmt.execute(
|
||||
"CREATE USER 'dsUser'" + getHostSuffix() + " IDENTIFIED BY 'MySup8%rPassw@ord'");
|
||||
} else {
|
||||
stmt.execute(
|
||||
"CREATE USER 'dsUser'@'%' IDENTIFIED WITH mysql_native_password BY"
|
||||
"CREATE USER 'dsUser'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH mysql_native_password BY"
|
||||
+ " 'MySup8%rPassw@ord'");
|
||||
}
|
||||
stmt.execute("GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO 'dsUser'@'%'");
|
||||
stmt.execute("GRANT ALL ON *.* TO 'dsUser'" + getHostSuffix());
|
||||
} else {
|
||||
stmt.execute("CREATE USER 'dsUser'@'%'");
|
||||
stmt.execute("CREATE USER 'dsUser'" + getHostSuffix());
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON "
|
||||
+ sharedConn.getCatalog()
|
||||
+ ".* TO 'dsUser'@'%' IDENTIFIED BY 'MySup8%rPassw@ord'");
|
||||
+ ".* TO 'dsUser'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED BY 'MySup8%rPassw@ord'");
|
||||
}
|
||||
stmt.execute("FLUSH PRIVILEGES");
|
||||
|
||||
@ -171,7 +176,7 @@ public class DataSourceTest extends Common {
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
stmt.execute("DROP USER 'dsUser'@'%'");
|
||||
stmt.execute("DROP USER 'dsUser'" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
|
@ -48,11 +48,12 @@ public class PoolDataSourceTest extends Common {
|
||||
&& (isMariaDBServer() || !minVersion(8, 0, 0));
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
if (useOldNotation) {
|
||||
stmt.execute("CREATE USER 'poolUser'@'%'");
|
||||
stmt.execute("GRANT ALL ON *.* TO 'poolUser'@'%' IDENTIFIED BY '!Passw0rd3Works'");
|
||||
stmt.execute("CREATE USER 'poolUser'" + getHostSuffix());
|
||||
stmt.execute(
|
||||
"GRANT ALL ON *.* TO 'poolUser'" + getHostSuffix() + " IDENTIFIED BY '!Passw0rd3Works'");
|
||||
} else {
|
||||
stmt.execute("CREATE USER 'poolUser'@'%' IDENTIFIED BY '!Passw0rd3Works'");
|
||||
stmt.execute("GRANT ALL ON *.* TO 'poolUser'@'%'");
|
||||
stmt.execute("CREATE USER 'poolUser'" + getHostSuffix() + " IDENTIFIED BY '!Passw0rd3Works'");
|
||||
stmt.execute("GRANT ALL ON *.* TO 'poolUser'" + getHostSuffix());
|
||||
}
|
||||
stmt.execute(
|
||||
"CREATE TABLE testResetRollback(id int not null primary key auto_increment, test"
|
||||
@ -64,7 +65,7 @@ public class PoolDataSourceTest extends Common {
|
||||
@AfterAll
|
||||
public static void drop() throws SQLException {
|
||||
try (Statement stmt = sharedConn.createStatement()) {
|
||||
stmt.execute("DROP USER IF EXISTS 'poolUser'@'%'");
|
||||
stmt.execute("DROP USER IF EXISTS 'poolUser'" + getHostSuffix());
|
||||
stmt.execute("DROP TABLE IF EXISTS testResetRollback");
|
||||
}
|
||||
}
|
||||
@ -79,7 +80,6 @@ public class PoolDataSourceTest extends Common {
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("show status where `variable_name` = 'Threads_connected'");
|
||||
if (rs.next()) {
|
||||
System.out.println("threads : " + rs.getInt(2));
|
||||
return rs.getInt(2);
|
||||
}
|
||||
return -1;
|
||||
@ -625,33 +625,6 @@ public class PoolDataSourceTest extends Common {
|
||||
Pools.close("PoolTest");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ensureClosed() throws Throwable {
|
||||
Thread.sleep(500); // ensure that previous close are effective
|
||||
int initialConnection = getCurrentConnections();
|
||||
Assumptions.assumeFalse(initialConnection == -1);
|
||||
|
||||
try (MariaDbPoolDataSource pool =
|
||||
new MariaDbPoolDataSource(mDefUrl + "&maxPoolSize=10&minPoolSize=1")) {
|
||||
|
||||
try (Connection connection = pool.getConnection()) {
|
||||
connection.isValid(10_000);
|
||||
}
|
||||
|
||||
assertTrue(getCurrentConnections() > initialConnection);
|
||||
|
||||
// reuse IdleConnection
|
||||
try (Connection connection = pool.getConnection()) {
|
||||
connection.isValid(10_000);
|
||||
}
|
||||
|
||||
Thread.sleep(500);
|
||||
assertTrue(getCurrentConnections() > initialConnection);
|
||||
}
|
||||
Thread.sleep(2000); // ensure that previous close are effective
|
||||
assertEquals(initialConnection, getCurrentConnections());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrongUrlHandling() throws SQLException {
|
||||
try (MariaDbPoolDataSource pool =
|
||||
|
@ -181,21 +181,30 @@ public class PooledConnectionTest extends Common {
|
||||
Assumptions.assumeTrue(
|
||||
!"maxscale".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv")));
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
stmt.execute("DROP USER IF EXISTS 'StatementErrorUser'@'%'");
|
||||
stmt.execute("DROP USER IF EXISTS 'StatementErrorUser'" + getHostSuffix());
|
||||
|
||||
if (minVersion(8, 0, 0)) {
|
||||
if (isMariaDBServer() || minVersion(8, 4, 0)) {
|
||||
stmt.execute("CREATE USER 'StatementErrorUser'@'%' IDENTIFIED BY" + " 'MySup8%rPassw@ord'");
|
||||
stmt.execute(
|
||||
"CREATE USER 'StatementErrorUser'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED BY"
|
||||
+ " 'MySup8%rPassw@ord'");
|
||||
} else {
|
||||
stmt.execute(
|
||||
"CREATE USER 'StatementErrorUser'@'%' IDENTIFIED WITH"
|
||||
"CREATE USER 'StatementErrorUser'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH"
|
||||
+ " mysql_native_password BY 'MySup8%rPassw@ord'");
|
||||
}
|
||||
stmt.execute("GRANT ALL ON *.* TO 'StatementErrorUser'@'%'");
|
||||
stmt.execute("GRANT ALL ON *.* TO 'StatementErrorUser'" + getHostSuffix());
|
||||
} else {
|
||||
stmt.execute("CREATE USER 'StatementErrorUser'@'%'");
|
||||
stmt.execute("CREATE USER 'StatementErrorUser'" + getHostSuffix());
|
||||
stmt.execute(
|
||||
"GRANT ALL ON *.* TO 'StatementErrorUser'@'%' IDENTIFIED BY" + " 'MySup8%rPassw@ord'");
|
||||
"GRANT ALL ON *.* TO 'StatementErrorUser'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED BY"
|
||||
+ " 'MySup8%rPassw@ord'");
|
||||
}
|
||||
stmt.execute("FLUSH PRIVILEGES");
|
||||
|
||||
@ -214,7 +223,7 @@ public class PooledConnectionTest extends Common {
|
||||
assertTrue(listener.statementClosed);
|
||||
pc.close();
|
||||
} finally {
|
||||
stmt.execute("DROP USER IF EXISTS 'StatementErrorUser'@'%'");
|
||||
stmt.execute("DROP USER IF EXISTS 'StatementErrorUser'" + getHostSuffix());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ public class Sha256AuthenticationTest extends Common {
|
||||
public static void drop() throws SQLException {
|
||||
if (sharedConn != null) {
|
||||
org.mariadb.jdbc.Statement stmt = sharedConn.createStatement();
|
||||
dropUserWithoutError(stmt, "'cachingSha256User'@'%'");
|
||||
dropUserWithoutError(stmt, "'cachingSha256User2'@'%'");
|
||||
dropUserWithoutError(stmt, "'cachingSha256User3'@'%'");
|
||||
dropUserWithoutError(stmt, "'cachingSha256User4'@'%'");
|
||||
dropUserWithoutError(stmt, "'cachingSha256User'" + getHostSuffix());
|
||||
dropUserWithoutError(stmt, "'cachingSha256User2'" + getHostSuffix());
|
||||
dropUserWithoutError(stmt, "'cachingSha256User3'" + getHostSuffix());
|
||||
dropUserWithoutError(stmt, "'cachingSha256User4'" + getHostSuffix());
|
||||
}
|
||||
// reason is that after nativePassword test, it sometime always return wrong authentication id
|
||||
// not cached
|
||||
@ -76,20 +76,28 @@ public class Sha256AuthenticationTest extends Common {
|
||||
}
|
||||
|
||||
stmt.execute(
|
||||
"CREATE USER 'cachingSha256User'@'%' IDENTIFIED WITH caching_sha2_password BY"
|
||||
"CREATE USER 'cachingSha256User'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH caching_sha2_password BY"
|
||||
+ " '!Passw0rd3Works'");
|
||||
stmt.execute(
|
||||
"CREATE USER 'cachingSha256User2'@'%' IDENTIFIED WITH caching_sha2_password BY ''");
|
||||
"CREATE USER 'cachingSha256User2'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH caching_sha2_password BY ''");
|
||||
stmt.execute(
|
||||
"CREATE USER 'cachingSha256User3'@'%' IDENTIFIED WITH caching_sha2_password BY"
|
||||
"CREATE USER 'cachingSha256User3'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH caching_sha2_password BY"
|
||||
+ " '!Passw0rd3Works'");
|
||||
stmt.execute(
|
||||
"CREATE USER 'cachingSha256User4'@'%' IDENTIFIED WITH caching_sha2_password BY"
|
||||
"CREATE USER 'cachingSha256User4'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH caching_sha2_password BY"
|
||||
+ " '!Passw0rd3Works'");
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User'@'%'");
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User2'@'%'");
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User3'@'%'");
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User4'@'%'");
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User'" + getHostSuffix());
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User2'" + getHostSuffix());
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User3'" + getHostSuffix());
|
||||
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User4'" + getHostSuffix());
|
||||
stmt.execute("FLUSH PRIVILEGES");
|
||||
}
|
||||
|
||||
@ -111,20 +119,22 @@ public class Sha256AuthenticationTest extends Common {
|
||||
!isWindows() && !isMariaDBServer() && rsaPublicKey != null && minVersion(8, 0, 0));
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
try {
|
||||
stmt.execute("DROP USER tmpUser@'%'");
|
||||
stmt.execute("DROP USER tmpUser" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
|
||||
stmt.execute(
|
||||
"CREATE USER tmpUser@'%' IDENTIFIED WITH mysql_native_password BY '!Passw0rd3Works'");
|
||||
stmt.execute("grant all on `" + sharedConn.getCatalog() + "`.* TO tmpUser@'%'");
|
||||
"CREATE USER tmpUser"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH mysql_native_password BY '!Passw0rd3Works'");
|
||||
stmt.execute("grant all on `" + sharedConn.getCatalog() + "`.* TO tmpUser" + getHostSuffix());
|
||||
stmt.execute("FLUSH PRIVILEGES"); // reset cache
|
||||
try (Connection con = createCon("user=tmpUser&password=!Passw0rd3Works")) {
|
||||
con.isValid(1);
|
||||
}
|
||||
try {
|
||||
stmt.execute("DROP USER tmpUser@'%' ");
|
||||
stmt.execute("DROP USER tmpUser" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
|
@ -58,27 +58,35 @@ public class SslTest extends Common {
|
||||
&& (isMariaDBServer() || !minVersion(8, 0, 0));
|
||||
Statement stmt = sharedConn.createStatement();
|
||||
if (useOldNotation) {
|
||||
stmt.execute("CREATE USER IF NOT EXISTS '" + user + "'@'%' " + requirement);
|
||||
stmt.execute(
|
||||
"CREATE USER IF NOT EXISTS '" + user + "'" + getHostSuffix() + " " + requirement);
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON *.* TO '"
|
||||
+ user
|
||||
+ "'@'%' IDENTIFIED BY '!Passw0rd3Works' "
|
||||
+ "'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED BY '!Passw0rd3Works' "
|
||||
+ requirement);
|
||||
} else {
|
||||
if (!isMariaDBServer() && minVersion(8, 0, 0)) {
|
||||
stmt.execute(
|
||||
"CREATE USER IF NOT EXISTS '"
|
||||
+ user
|
||||
+ "'@'%' IDENTIFIED WITH mysql_native_password BY '!Passw0rd3Works' "
|
||||
+ "'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED WITH mysql_native_password BY '!Passw0rd3Works' "
|
||||
+ requirement);
|
||||
} else {
|
||||
stmt.execute(
|
||||
"CREATE USER IF NOT EXISTS '"
|
||||
+ user
|
||||
+ "'@'%' IDENTIFIED BY '!Passw0rd3Works' "
|
||||
+ "'"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED BY '!Passw0rd3Works' "
|
||||
+ requirement);
|
||||
}
|
||||
stmt.execute("GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO '" + user + "'@'%' ");
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO '" + user + "'" + getHostSuffix());
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,15 +223,20 @@ public class SslTest extends Common {
|
||||
Assumptions.assumeTrue(false, "server doesn't have ed25519 plugin, cancelling test");
|
||||
}
|
||||
try {
|
||||
stmt.execute("drop user if exists verificationEd25519AuthPlugin@'%'");
|
||||
stmt.execute("drop user if exists verificationEd25519AuthPlugin" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
stmt.execute(
|
||||
"CREATE USER IF NOT EXISTS verificationEd25519AuthPlugin@'%' IDENTIFIED "
|
||||
"CREATE USER IF NOT EXISTS verificationEd25519AuthPlugin"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED "
|
||||
+ "VIA ed25519 USING PASSWORD('MySup8%rPassw@ord') REQUIRE SSL");
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO verificationEd25519AuthPlugin@'%' ");
|
||||
"GRANT SELECT ON "
|
||||
+ sharedConn.getCatalog()
|
||||
+ ".* TO verificationEd25519AuthPlugin"
|
||||
+ getHostSuffix());
|
||||
try (Connection con =
|
||||
createCon(
|
||||
"user=verificationEd25519AuthPlugin&password=MySup8%rPassw@ord&sslMode=verify-ca",
|
||||
@ -251,15 +264,20 @@ public class SslTest extends Common {
|
||||
Assumptions.assumeTrue(false, "server doesn't have auth_parsec plugin, cancelling test");
|
||||
}
|
||||
try {
|
||||
stmt.execute("drop user if exists verificationParsecAuthPlugin@'%'");
|
||||
stmt.execute("drop user if exists verificationParsecAuthPlugin" + getHostSuffix());
|
||||
} catch (SQLException e) {
|
||||
// eat
|
||||
}
|
||||
stmt.execute(
|
||||
"CREATE USER IF NOT EXISTS verificationParsecAuthPlugin@'%' IDENTIFIED "
|
||||
"CREATE USER IF NOT EXISTS verificationParsecAuthPlugin"
|
||||
+ getHostSuffix()
|
||||
+ " IDENTIFIED "
|
||||
+ "VIA parsec USING PASSWORD('MySup8%rPassw@ord') REQUIRE SSL");
|
||||
stmt.execute(
|
||||
"GRANT SELECT ON " + sharedConn.getCatalog() + ".* TO verificationParsecAuthPlugin@'%' ");
|
||||
"GRANT SELECT ON "
|
||||
+ sharedConn.getCatalog()
|
||||
+ ".* TO verificationParsecAuthPlugin"
|
||||
+ getHostSuffix());
|
||||
try (Connection con =
|
||||
createCon(
|
||||
"user=verificationParsecAuthPlugin&password=MySup8%rPassw@ord&sslMode=verify-ca",
|
||||
|
Reference in New Issue
Block a user