Skip to content

Commit 6717df3

Browse files
authored
[Test] Modify assert statement for ssl handshake (#32072)
There have been changes in error messages for `SSLHandshakeException`. This has caused a couple of failures in our tests. This commit modifies test verification to assert on exception type of class `SSLHandshakeException`. There was another issue in Java11 which caused NPE. The bug has now been fixed on Java11 - early access build 22. Bug Ref: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8206355 Enable the skipped tests due to this bug. Closes #31940
1 parent 4b5071f commit 6717df3

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

client/rest/src/test/java/org/elasticsearch/client/RestClientBuilderIntegTests.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030

3131
import javax.net.ssl.KeyManagerFactory;
3232
import javax.net.ssl.SSLContext;
33+
import javax.net.ssl.SSLHandshakeException;
3334
import javax.net.ssl.TrustManagerFactory;
3435
import java.io.IOException;
3536
import java.io.InputStream;
3637
import java.net.InetAddress;
3738
import java.net.InetSocketAddress;
3839
import java.security.KeyStore;
3940

40-
import static org.hamcrest.Matchers.containsString;
41+
import static org.hamcrest.Matchers.instanceOf;
4142
import static org.junit.Assert.assertEquals;
4243
import static org.junit.Assert.assertThat;
4344
import static org.junit.Assert.fail;
@@ -72,17 +73,14 @@ public static void stopHttpServers() throws IOException {
7273
}
7374

7475
public void testBuilderUsesDefaultSSLContext() throws Exception {
75-
assumeFalse("Due to bug inside jdk, this test can't momentarily run with java 11. " +
76-
"See: https://github.com/elastic/elasticsearch/issues/31940",
77-
System.getProperty("java.version").contains("11"));
7876
final SSLContext defaultSSLContext = SSLContext.getDefault();
7977
try {
8078
try (RestClient client = buildRestClient()) {
8179
try {
8280
client.performRequest(new Request("GET", "/"));
8381
fail("connection should have been rejected due to SSL handshake");
8482
} catch (Exception e) {
85-
assertThat(e.getMessage(), containsString("General SSLEngine problem"));
83+
assertThat(e, instanceOf(SSLHandshakeException.class));
8684
}
8785
}
8886

x-pack/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ private boolean getMonitoringUsageExportersDefined() throws Exception {
127127
return monitoringUsage.get().getExporters().isEmpty() == false;
128128
}
129129

130-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/31940")
131130
public void testHTTPExporterWithSSL() throws Exception {
132131
// Ensures that the exporter is actually on
133132
assertBusy(() -> assertThat("[_http] exporter is not defined", getMonitoringUsageExportersDefined(), is(true)));

0 commit comments

Comments
 (0)