Skip to content

Commit d8fb5f0

Browse files
committed
TLS defaults updated and fix for tests failing with old MySQL servers.
1 parent 814147c commit d8fb5f0

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

src/testsuite/regression/ConnectionRegressionTest.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ public void testBug23626() throws Exception {
17181718
* if the test fails.
17191719
*/
17201720
public void testBug25545() throws Exception {
1721-
if (!versionMeetsMinimum(5, 0)) {
1721+
if (!versionMeetsMinimum(5, 0) || (!versionMeetsMinimum(5, 5) && !Util.jvmMeetsMinimum(8, 0))) {
17221722
return;
17231723
}
17241724

@@ -1758,6 +1758,9 @@ public void testBug25545() throws Exception {
17581758
* if the test fails.
17591759
*/
17601760
public void testBug36948() throws Exception {
1761+
if (!versionMeetsMinimum(5, 5)) {
1762+
return;
1763+
}
17611764
Connection _conn = null;
17621765

17631766
try {
@@ -7538,7 +7541,7 @@ private void testBug71084AssertCase(Properties connProps, String clientTZ, Strin
75387541
* if the test fails.
75397542
*/
75407543
public void testBug20685022() throws Exception {
7541-
if (!isCommunityEdition()) {
7544+
if (!isCommunityEdition() || !versionMeetsMinimum(5, 5)) {
75427545
return;
75437546
}
75447547

@@ -8340,6 +8343,10 @@ public SQLException interceptException(SQLException sqlEx, com.mysql.jdbc.Connec
83408343
* if the test fails.
83418344
*/
83428345
public void testBug21947042() throws Exception {
8346+
if (!versionMeetsMinimum(5, 5)) {
8347+
return;
8348+
}
8349+
83438350
Connection sslConn = null;
83448351
Properties props = new Properties();
83458352
props.setProperty("logger", BufferingLogger.class.getName());
@@ -8535,6 +8542,9 @@ public ResultSetInternalMethods preProcess(String sql, com.mysql.jdbc.Statement
85358542
* Test certificates from testsuite/ssl-test-certs must be installed on both servers.
85368543
*/
85378544
public void testTLSVersion() throws Exception {
8545+
if (!versionMeetsMinimum(5, 5) && !Util.jvmMeetsMinimum(8, 0)) {
8546+
return;
8547+
}
85388548
// Find out which TLS protocol versions are supported by this JVM.
85398549
SSLContext sslContext = SSLContext.getInstance("TLS");
85408550
sslContext.init(null, null, null);
@@ -8582,6 +8592,9 @@ public void testTLSVersion() throws Exception {
85828592
System.out.println("Highest common TLS protocol: " + highestCommonTlsVersion);
85838593

85848594
assertEquals(highestCommonTlsVersion, tlsVersionUsed);
8595+
} else if (((MySQLConnection) sslConn).versionMeetsMinimum(5, 6, 46)) {
8596+
assertEquals(jvmSupportedProtocols.contains("TLSv1.2") ? "TLSv1.2" : jvmSupportedProtocols.contains("TLSv1.1") ? "TLSv1.1" : "TLSv1",
8597+
tlsVersionUsed);
85858598
} else {
85868599
assertEquals("TLSv1", tlsVersionUsed);
85878600
}
@@ -8602,6 +8615,9 @@ public void testTLSVersion() throws Exception {
86028615
* Test certificates from testsuite/ssl-test-certs must be installed on both servers.
86038616
*/
86048617
public void testEnableTLSVersion() throws Exception {
8618+
if (!versionMeetsMinimum(5, 5)) {
8619+
return;
8620+
}
86058621
// Find out which TLS protocol versions are supported by this JVM.
86068622
SSLContext sslContext = SSLContext.getInstance("TLS");
86078623
sslContext.init(null, null, null);
@@ -8637,6 +8653,11 @@ public void testEnableTLSVersion() throws Exception {
86378653
System.out.println("Server supports TLS protocols: " + serverSupportedProtocols);
86388654
commonSupportedProtocols.addAll(serverSupportedProtocols);
86398655
commonSupportedProtocols.retainAll(jvmSupportedProtocols);
8656+
} else if (((MySQLConnection) sslConn).versionMeetsMinimum(5, 6, 46) && !((MySQLConnection) sslConn).versionMeetsMinimum(5, 7, 0)) {
8657+
commonSupportedProtocols.add("TLSv1");
8658+
commonSupportedProtocols.add("TLSv1.1");
8659+
commonSupportedProtocols.add("TLSv1.2");
8660+
commonSupportedProtocols.retainAll(jvmSupportedProtocols);
86408661
} else {
86418662
commonSupportedProtocols.add("TLSv1");
86428663
}
@@ -10153,6 +10174,10 @@ public void testBug70785() throws Exception {
1015310174
* packets flow faster and desynchronization occurs rarely, which is the root cause for this problem.
1015410175
*/
1015510176
public void testBug88242() throws Exception {
10177+
if (!versionMeetsMinimum(5, 5)) {
10178+
return;
10179+
}
10180+
1015610181
Properties props = new Properties();
1015710182
props.setProperty("useSSL", "true");
1015810183
props.setProperty("verifyServerCertificate", "false");

src/testsuite/regression/StatementRegressionTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7838,6 +7838,10 @@ public ResultSet call() throws Exception {
78387838
* Tests fix for Bug#23201930 - CLIENT HANG WHEN RSLT CUNCURRENCY=CONCUR_UPDATABLE AND RSLTSET TYPE=FORWARD_ONLY.
78397839
*/
78407840
public void testBug23201930() throws Exception {
7841+
if (!versionMeetsMinimum(5, 5)) {
7842+
return;
7843+
}
7844+
78417845
boolean useSSL = false;
78427846
boolean useSPS = false;
78437847
boolean useCursor = false;

src/testsuite/regression/SyntaxRegressionTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
33
44
The MySQL Connector/J is licensed under the terms of the GPLv2
55
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
@@ -1511,11 +1511,10 @@ public void testGisFunctions() throws Exception {
15111511
args.put("mpl", geoMultiPolygon);
15121512
args.put("gc", geoGeometryCollection);
15131513
args.put("gh", "'s14f5h28wc04jsq093jd'");
1514-
args.put("js",
1515-
"'{\"type\": \"GeometryCollection\", \"geometries\": [" + //
1516-
"{\"type\": \"Point\", \"coordinates\": [8, 0]}, " + //
1517-
"{\"type\": \"LineString\", \"coordinates\": [[0, 0], [8, 0], [4, 6], [0, 0]]}, " + //
1518-
"{\"type\": \"Polygon\", \"coordinates\": [[[0, 3], [8, 3], [4, 9], [0, 3]]]}]}'");
1514+
args.put("js", "'{\"type\": \"GeometryCollection\", \"geometries\": [" + //
1515+
"{\"type\": \"Point\", \"coordinates\": [8, 0]}, " + //
1516+
"{\"type\": \"LineString\", \"coordinates\": [[0, 0], [8, 0], [4, 6], [0, 0]]}, " + //
1517+
"{\"type\": \"Polygon\", \"coordinates\": [[[0, 3], [8, 3], [4, 9], [0, 3]]]}]}'");
15191518

15201519
final class GisFunction {
15211520
String function;
@@ -2025,7 +2024,7 @@ public void testInnodbTablespaceEncryption() throws Exception {
20252024
} else { // Syntax can still be tested by with different outcome.
20262025
System.out.println("Although not required it is recommended that the 'keyring_file' plugin is properly installed and configured to run this test.");
20272026

2028-
String err = versionMeetsMinimum(8, 0, 4)
2027+
String err = versionMeetsMinimum(8, 0, 4) || versionMeetsMinimum(5, 7, 22) && !versionMeetsMinimum(8, 0, 0)
20292028
? "Can't find master key from keyring, please check in the server log if a keyring plugin is loaded and initialized successfully."
20302029
: "Can't find master key from keyring, please check keyring plugin is loaded.";
20312030

src/testsuite/regression/jdbc4/ConnectionRegressionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
44
The MySQL Connector/J is licensed under the terms of the GPLv2
55
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
@@ -134,7 +134,7 @@ public void testBug75168() throws Exception {
134134
* if the test fails.
135135
*/
136136
public void testBug20685022() throws Exception {
137-
if (!isCommunityEdition()) {
137+
if (!isCommunityEdition() || !versionMeetsMinimum(5, 5)) {
138138
return;
139139
}
140140

src/testsuite/simple/ConnectionTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,10 @@ private void checkInterfaceImplemented(Method[] interfaceMethods, Class<?> imple
15971597
}
15981598

15991599
public void testNonVerifyServerCert() throws Exception {
1600+
if (!versionMeetsMinimum(5, 5)) {
1601+
return;
1602+
}
1603+
16001604
Properties props = new Properties();
16011605
props.setProperty("useSSL", "true");
16021606
props.setProperty("verifyServerCertificate", "false");

0 commit comments

Comments
 (0)