Skip to content

Commit

Permalink
[misc] code style correction
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Nov 7, 2022
1 parent 9843769 commit 79c4ad3
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public void authenticate(
new SspiUtil.ManagedSecBufferDesc(Sspi.SECBUFFER_TOKEN, tokenForTheClientOnTheServer);
clientContext.initialize(clientContext.getHandle(), continueToken, servicePrincipalName);


} while (true);

clientContext.dispose();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/mariadb/jdbc/integration/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public static boolean minVersion(int major, int minor, int 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;
&& sharedConn.getContext().getVersion().getMinorVersion() == minor
&& sharedConn.getContext().getVersion().getPatchVersion() == patch;
}

public static Connection createCon() throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,8 @@ 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));
// 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 @@ -996,11 +996,10 @@ 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));
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ 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));
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,10 @@ 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));
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ 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));
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,10 @@ 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));
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ 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));
// 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 @@ -109,11 +108,11 @@ 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@'%'");
//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));

//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")) {
Expand All @@ -130,8 +129,8 @@ 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));
// 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=")) {
Expand All @@ -143,8 +142,8 @@ 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));
// 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");
Expand All @@ -161,8 +160,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));
// 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 @@ -173,8 +172,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));
// 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 @@ -211,8 +210,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));
// 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 @@ -223,8 +222,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));
// 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
4 changes: 2 additions & 2 deletions src/test/java/org/mariadb/jdbc/integration/SslTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +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));
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public void updateBlobClob() throws SQLException, IOException {
stmt.execute("START TRANSACTION ");
try {
PreparedStatement prep =
sharedConn.prepareStatement("insert into updateBlob (id, strm) values (?,?)");
sharedConn.prepareStatement("insert into updateBlob (id, strm) values (?,?)");
byte[] theBlob = {1, 2, 3, 4, 5, 6};
InputStream stream = new ByteArrayInputStream(theBlob);

Expand All @@ -623,8 +623,10 @@ public void updateBlobClob() throws SQLException, IOException {
byte[] updatedBlob = "abcdef".getBytes(StandardCharsets.UTF_8);

try (PreparedStatement preparedStatement =
sharedConn.prepareStatement(
"select * from updateBlob", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
sharedConn.prepareStatement(
"select * from updateBlob",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE)) {
ResultSet rs = preparedStatement.executeQuery();
assertTrue(rs.next());

Expand Down Expand Up @@ -678,8 +680,10 @@ public void updateBlobClob() throws SQLException, IOException {
}

try (PreparedStatement preparedStatement =
sharedConn.prepareStatement(
"select * from updateBlob", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
sharedConn.prepareStatement(
"select * from updateBlob",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE)) {
ResultSet rs = preparedStatement.executeQuery();
assertTrue(rs.next());
checkResult(rs, updatedBlob);
Expand Down

0 comments on commit 79c4ad3

Please sign in to comment.