Skip to content

Commit 5698345

Browse files
authored
[Test] Modify assert statement for ssl handshake (#32072) (#40530)
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 e4d41d3 commit 5698345

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,6 +30,7 @@
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;
@@ -43,7 +44,7 @@
4344
import java.security.cert.CertificateFactory;
4445
import java.security.spec.PKCS8EncodedKeySpec;
4546

46-
import static org.hamcrest.Matchers.containsString;
47+
import static org.hamcrest.Matchers.instanceOf;
4748
import static org.junit.Assert.assertEquals;
4849
import static org.junit.Assert.assertThat;
4950
import static org.junit.Assert.fail;
@@ -78,17 +79,14 @@ public static void stopHttpServers() throws IOException {
7879
}
7980

8081
public void testBuilderUsesDefaultSSLContext() throws Exception {
81-
assumeFalse("Due to bug inside jdk, this test can't momentarily run with java 11. " +
82-
"See: https://github.com/elastic/elasticsearch/issues/31940",
83-
System.getProperty("java.version").contains("11"));
8482
final SSLContext defaultSSLContext = SSLContext.getDefault();
8583
try {
8684
try (RestClient client = buildRestClient()) {
8785
try {
8886
client.performRequest(new Request("GET", "/"));
8987
fail("connection should have been rejected due to SSL handshake");
9088
} catch (Exception e) {
91-
assertThat(e.getMessage(), containsString("General SSLEngine problem"));
89+
assertThat(e, instanceOf(SSLHandshakeException.class));
9290
}
9391
}
9492

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)