Update testsuite / pom.xml to be able to build with Java15 (#10210)
Motivation: We need to make some slightly changes to be able to build on Java15 as some previous deprecated methods now throw UnsupportedOperationException Modifications: - Add code to handle UnsupportedOperationException - Revert previous applied workaround for bug that was fixed in Java15 - Add maven profile Result: Be able to build with latest Java15 EA release
This commit is contained in:
parent
5a08dc0d9a
commit
9778f05e14
@ -57,7 +57,10 @@ final class Conscrypt {
|
|||||||
*/
|
*/
|
||||||
static boolean isAvailable() {
|
static boolean isAvailable() {
|
||||||
return CAN_INSTANCE_PROVIDER && IS_CONSCRYPT_SSLENGINE != null &&
|
return CAN_INSTANCE_PROVIDER && IS_CONSCRYPT_SSLENGINE != null &&
|
||||||
(PlatformDependent.javaVersion() >= 8 || PlatformDependent.isAndroid());
|
((PlatformDependent.javaVersion() >= 8 &&
|
||||||
|
// Only works on Java14 and earlier for now
|
||||||
|
// See https://github.com/google/conscrypt/issues/838
|
||||||
|
PlatformDependent.javaVersion() < 15) || PlatformDependent.isAndroid());
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isEngineSupported(SSLEngine engine) {
|
static boolean isEngineSupported(SSLEngine engine) {
|
||||||
|
@ -1003,8 +1003,13 @@ public abstract class SSLEngineTest {
|
|||||||
assertEquals(1, session.getPeerCertificates().length);
|
assertEquals(1, session.getPeerCertificates().length);
|
||||||
assertArrayEquals(certBytes, session.getPeerCertificates()[0].getEncoded());
|
assertArrayEquals(certBytes, session.getPeerCertificates()[0].getEncoded());
|
||||||
|
|
||||||
assertEquals(1, session.getPeerCertificateChain().length);
|
try {
|
||||||
assertArrayEquals(certBytes, session.getPeerCertificateChain()[0].getEncoded());
|
assertEquals(1, session.getPeerCertificateChain().length);
|
||||||
|
assertArrayEquals(certBytes, session.getPeerCertificateChain()[0].getEncoded());
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||||
|
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals(1, session.getLocalCertificates().length);
|
assertEquals(1, session.getLocalCertificates().length);
|
||||||
assertArrayEquals(certBytes, session.getLocalCertificates()[0].getEncoded());
|
assertArrayEquals(certBytes, session.getLocalCertificates()[0].getEncoded());
|
||||||
@ -1740,20 +1745,36 @@ public abstract class SSLEngineTest {
|
|||||||
Throwable cause = ((SslHandshakeCompletionEvent) evt).cause();
|
Throwable cause = ((SslHandshakeCompletionEvent) evt).cause();
|
||||||
if (cause == null) {
|
if (cause == null) {
|
||||||
SSLSession session = ((SslHandler) ctx.pipeline().first()).engine().getSession();
|
SSLSession session = ((SslHandler) ctx.pipeline().first()).engine().getSession();
|
||||||
X509Certificate[] peerCertificateChain = session.getPeerCertificateChain();
|
|
||||||
Certificate[] peerCertificates = session.getPeerCertificates();
|
Certificate[] peerCertificates = session.getPeerCertificates();
|
||||||
if (peerCertificateChain == null) {
|
if (peerCertificates == null) {
|
||||||
promise.setFailure(new NullPointerException("peerCertificateChain"));
|
|
||||||
} else if (peerCertificates == null) {
|
|
||||||
promise.setFailure(new NullPointerException("peerCertificates"));
|
promise.setFailure(new NullPointerException("peerCertificates"));
|
||||||
} else if (peerCertificateChain.length + peerCertificates.length != 4) {
|
return;
|
||||||
String excTxtFmt = "peerCertificateChain.length:%s, peerCertificates.length:%s";
|
}
|
||||||
promise.setFailure(new IllegalStateException(String.format(excTxtFmt,
|
try {
|
||||||
peerCertificateChain.length,
|
X509Certificate[] peerCertificateChain = session.getPeerCertificateChain();
|
||||||
peerCertificates.length)));
|
if (peerCertificateChain == null) {
|
||||||
} else {
|
promise.setFailure(new NullPointerException("peerCertificateChain"));
|
||||||
for (int i = 0; i < peerCertificateChain.length; i++) {
|
} else if (peerCertificateChain.length + peerCertificates.length != 4) {
|
||||||
if (peerCertificateChain[i] == null || peerCertificates[i] == null) {
|
String excTxtFmt = "peerCertificateChain.length:%s, peerCertificates.length:%s";
|
||||||
|
promise.setFailure(new IllegalStateException(String.format(excTxtFmt,
|
||||||
|
peerCertificateChain.length,
|
||||||
|
peerCertificates.length)));
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < peerCertificateChain.length; i++) {
|
||||||
|
if (peerCertificateChain[i] == null || peerCertificates[i] == null) {
|
||||||
|
promise.setFailure(
|
||||||
|
new IllegalStateException("Certificate in chain is null"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
promise.setSuccess(null);
|
||||||
|
}
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||||
|
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||||
|
assertEquals(2, peerCertificates.length);
|
||||||
|
for (int i = 0; i < peerCertificates.length; i++) {
|
||||||
|
if (peerCertificates[i] == null) {
|
||||||
promise.setFailure(
|
promise.setFailure(
|
||||||
new IllegalStateException("Certificate in chain is null"));
|
new IllegalStateException("Certificate in chain is null"));
|
||||||
return;
|
return;
|
||||||
@ -2981,7 +3002,7 @@ public abstract class SSLEngineTest {
|
|||||||
|
|
||||||
// Workaround for JDK 14 regression.
|
// Workaround for JDK 14 regression.
|
||||||
// See https://bugs.openjdk.java.net/browse/JDK-8242008
|
// See https://bugs.openjdk.java.net/browse/JDK-8242008
|
||||||
if (PlatformDependent.javaVersion() < 14) {
|
if (PlatformDependent.javaVersion() != 14) {
|
||||||
assertNotNull(serverSession.getSessionContext());
|
assertNotNull(serverSession.getSessionContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3016,9 +3037,15 @@ public abstract class SSLEngineTest {
|
|||||||
assertEquals(1, serverPeerCertificates.length);
|
assertEquals(1, serverPeerCertificates.length);
|
||||||
assertArrayEquals(clientLocalCertificates[0].getEncoded(), serverPeerCertificates[0].getEncoded());
|
assertArrayEquals(clientLocalCertificates[0].getEncoded(), serverPeerCertificates[0].getEncoded());
|
||||||
|
|
||||||
X509Certificate[] serverPeerX509Certificates = serverSession.getPeerCertificateChain();
|
try {
|
||||||
assertEquals(1, serverPeerX509Certificates.length);
|
X509Certificate[] serverPeerX509Certificates = serverSession.getPeerCertificateChain();
|
||||||
assertArrayEquals(clientLocalCertificates[0].getEncoded(), serverPeerX509Certificates[0].getEncoded());
|
assertEquals(1, serverPeerX509Certificates.length);
|
||||||
|
assertArrayEquals(clientLocalCertificates[0].getEncoded(),
|
||||||
|
serverPeerX509Certificates[0].getEncoded());
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||||
|
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||||
|
}
|
||||||
|
|
||||||
Principal clientLocalPrincipial = clientSession.getLocalPrincipal();
|
Principal clientLocalPrincipial = clientSession.getLocalPrincipal();
|
||||||
assertNotNull(clientLocalPrincipial);
|
assertNotNull(clientLocalPrincipial);
|
||||||
@ -3041,6 +3068,9 @@ public abstract class SSLEngineTest {
|
|||||||
fail();
|
fail();
|
||||||
} catch (SSLPeerUnverifiedException expected) {
|
} catch (SSLPeerUnverifiedException expected) {
|
||||||
// As we did not use mutual auth this is expected
|
// As we did not use mutual auth this is expected
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||||
|
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -3055,10 +3085,14 @@ public abstract class SSLEngineTest {
|
|||||||
assertEquals(1, clientPeerCertificates.length);
|
assertEquals(1, clientPeerCertificates.length);
|
||||||
assertArrayEquals(serverLocalCertificates[0].getEncoded(), clientPeerCertificates[0].getEncoded());
|
assertArrayEquals(serverLocalCertificates[0].getEncoded(), clientPeerCertificates[0].getEncoded());
|
||||||
|
|
||||||
X509Certificate[] clientPeerX509Certificates = clientSession.getPeerCertificateChain();
|
try {
|
||||||
assertEquals(1, clientPeerX509Certificates.length);
|
X509Certificate[] clientPeerX509Certificates = clientSession.getPeerCertificateChain();
|
||||||
assertArrayEquals(serverLocalCertificates[0].getEncoded(), clientPeerX509Certificates[0].getEncoded());
|
assertEquals(1, clientPeerX509Certificates.length);
|
||||||
|
assertArrayEquals(serverLocalCertificates[0].getEncoded(), clientPeerX509Certificates[0].getEncoded());
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
// See https://bugs.openjdk.java.net/browse/JDK-8241039
|
||||||
|
assertTrue(PlatformDependent.javaVersion() >= 15);
|
||||||
|
}
|
||||||
Principal clientPeerPrincipal = clientSession.getPeerPrincipal();
|
Principal clientPeerPrincipal = clientSession.getPeerPrincipal();
|
||||||
assertEquals(serverLocalPrincipal, clientPeerPrincipal);
|
assertEquals(serverLocalPrincipal, clientPeerPrincipal);
|
||||||
} finally {
|
} finally {
|
||||||
|
20
pom.xml
20
pom.xml
@ -98,6 +98,26 @@
|
|||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
<!-- JDK14 -->
|
<!-- JDK14 -->
|
||||||
|
<profile>
|
||||||
|
<id>java15</id>
|
||||||
|
<activation>
|
||||||
|
<jdk>15</jdk>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<!-- Not use alpn agent as Java11+ supports alpn out of the box -->
|
||||||
|
<argLine.alpnAgent />
|
||||||
|
<forbiddenapis.skip>true</forbiddenapis.skip>
|
||||||
|
<!-- Needed because of https://issues.apache.org/jira/browse/MENFORCER-275 -->
|
||||||
|
<enforcer.plugin.version>3.0.0-M3</enforcer.plugin.version>
|
||||||
|
<!-- 1.4.x does not work in Java10+ -->
|
||||||
|
<jboss.marshalling.version>2.0.5.Final</jboss.marshalling.version>
|
||||||
|
<!-- This is the minimum supported by Java12+ -->
|
||||||
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
|
<!-- pax-exam does not work on latest Java12 EA 22 build -->
|
||||||
|
<skipOsgiTestsuite>true</skipOsgiTestsuite>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>java14</id>
|
<id>java14</id>
|
||||||
<activation>
|
<activation>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user