Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Makes SslClientAuthFunctionalTest work with both java 8 and 11 #10157

Open
wants to merge 1 commit into
base: 7.3.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static io.confluent.ksql.serde.FormatFactory.KAFKA;
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
import static java.util.Collections.emptyMap;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
Expand All @@ -44,6 +45,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLHandshakeException;

import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException;
import kafka.zookeeper.ZooKeeperClientException;
import org.apache.kafka.common.config.SslConfigs;
import org.junit.Before;
Expand Down Expand Up @@ -112,7 +115,10 @@ public void shouldNotBeAbleToUseCliIfClientDoesNotProvideCertificate() {

// Then:
assertThat(e.getCause(), (is(instanceOf(ExecutionException.class))));
assertThat(e.getCause(), (hasCause(is(instanceOf(SSLHandshakeException.class)))));
// Make this compatible with both java 8 and 11.
assertThat(e.getCause(), anyOf(
hasCause(hasCause(is(instanceOf(SSLHandshakeException.class)))),
hasCause(is(instanceOf(SSLHandshakeException.class)))));
}

@Test
Expand All @@ -133,10 +139,16 @@ public void shouldNotBeAbleToUseWssIfClientDoesNotTrustServerCert() {
givenClientConfiguredWithoutCertificate();

// When:
assertThrows(
SSLHandshakeException.class,
() -> WebsocketUtils.makeWsRequest(JSON_KSQL_REQUEST, clientProps, REST_APP)
final Exception e = assertThrows(
Exception.class,
() -> WebsocketUtils.makeWsRequest(JSON_KSQL_REQUEST, clientProps, REST_APP)
);
assertThat(e, anyOf(is(instanceOf(RuntimeException.class)),
is(instanceOf(SSLHandshakeException.class))));
if (e instanceof RuntimeException) {
assertThat(e.getCause(), is(instanceOf(ExecutionException.class)));
assertThat(e.getCause(), hasCause(instanceOf(WebSocketHandshakeException.class)));
}
}

@Test
Expand Down