From 3b2ba9896ae0ef2c9a11c2e43141e251943c5d82 Mon Sep 17 00:00:00 2001 From: dilanSachi Date: Tue, 27 Jun 2023 16:35:37 +0530 Subject: [PATCH] Update test cases to fix ssl failures --- .../wso2/transport/http/netty/https/SSLProtocolsTest.java | 7 +++---- .../http/netty/https/SSLProtocolsWithCertsTest.java | 7 +++---- .../ssl/WebSocketSSLHandshakeFailureTestCase.java | 4 +++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsTest.java b/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsTest.java index 8806b5390..301b14b00 100644 --- a/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsTest.java +++ b/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsTest.java @@ -33,6 +33,7 @@ import org.wso2.transport.http.netty.contract.config.Parameter; import org.wso2.transport.http.netty.contract.config.SenderConfiguration; import org.wso2.transport.http.netty.contract.exceptions.ServerConnectorException; +import org.wso2.transport.http.netty.contract.exceptions.SslException; import org.wso2.transport.http.netty.contractimpl.DefaultHttpWsConnectorFactory; import org.wso2.transport.http.netty.message.HttpCarbonMessage; import org.wso2.transport.http.netty.message.HttpMessageDataStreamer; @@ -70,7 +71,7 @@ public static Object[][] cipherSuites() { // true = expecting a SSL hand shake failure. // false = expecting no errors. - return new Object[][] { { "TLSv1.1", "TLSv1.1", false, TestUtil.SERVER_PORT1 }, + return new Object[][] { { "TLSv1.2", "TLSv1.2", false, TestUtil.SERVER_PORT1 }, { "TLSv1.1", "TLSv1.2", true, TestUtil.SERVER_PORT2 } }; } @@ -150,9 +151,7 @@ private void testSSLProtocols(boolean hasException, int serverPort) { assertNotNull(listener.getThrowables()); boolean hasSSLException = false; for (Throwable throwable : listener.getThrowables()) { - if (throwable.getMessage() != null && ( - throwable.getMessage().contains("javax.net.ssl.SSLHandshakeException") || throwable - .getMessage().contains("handshake_failure"))) { + if (throwable instanceof SslException) { hasSSLException = true; break; } diff --git a/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsWithCertsTest.java b/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsWithCertsTest.java index a5593179e..c310e7598 100644 --- a/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsWithCertsTest.java +++ b/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/https/SSLProtocolsWithCertsTest.java @@ -33,6 +33,7 @@ import org.wso2.transport.http.netty.contract.config.Parameter; import org.wso2.transport.http.netty.contract.config.SenderConfiguration; import org.wso2.transport.http.netty.contract.exceptions.ServerConnectorException; +import org.wso2.transport.http.netty.contract.exceptions.SslException; import org.wso2.transport.http.netty.contractimpl.DefaultHttpWsConnectorFactory; import org.wso2.transport.http.netty.message.HttpCarbonMessage; import org.wso2.transport.http.netty.message.HttpMessageDataStreamer; @@ -68,7 +69,7 @@ public class SSLProtocolsWithCertsTest { public static Object[][] cipherSuites() { // true = expecting a SSL hand shake failure. // false = expecting no errors. - return new Object[][] { { "TLSv1.1", "TLSv1.1", false, TestUtil.SERVER_PORT1 }, + return new Object[][] { { "TLSv1.2", "TLSv1.2", false, TestUtil.SERVER_PORT1 }, { "TLSv1.1", "TLSv1.2", true, TestUtil.SERVER_PORT2 } }; } @@ -146,9 +147,7 @@ private void testSSLProtocols(boolean hasException, int serverPort) { assertNotNull(listener.getThrowables()); boolean hasSSLException = false; for (Throwable throwable : listener.getThrowables()) { - if (throwable.getMessage() != null && ( - throwable.getMessage().contains("javax.net.ssl.SSLHandshakeException") || throwable - .getMessage().contains("handshake_failure"))) { + if (throwable instanceof SslException) { hasSSLException = true; break; } diff --git a/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/websocket/ssl/WebSocketSSLHandshakeFailureTestCase.java b/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/websocket/ssl/WebSocketSSLHandshakeFailureTestCase.java index f1d09619a..c0de2d5c9 100644 --- a/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/websocket/ssl/WebSocketSSLHandshakeFailureTestCase.java +++ b/components/org.wso2.transport.http.netty/src/test/java/org/wso2/transport/http/netty/websocket/ssl/WebSocketSSLHandshakeFailureTestCase.java @@ -40,6 +40,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; +import javax.net.ssl.SSLException; + import static org.wso2.transport.http.netty.util.TestUtil.WEBSOCKET_REMOTE_SERVER_PORT; import static org.wso2.transport.http.netty.util.TestUtil.WEBSOCKET_SECURE_REMOTE_SERVER_URL; import static org.wso2.transport.http.netty.util.TestUtil.WEBSOCKET_TEST_IDLE_TIMEOUT; @@ -116,7 +118,7 @@ public void testClientConnectionWithSSL() throws Throwable { Assert.assertNull(webSocketConnectionAtomicReference.get()); Assert.assertNotNull(throwable); - Assert.assertEquals(throwable.getMessage(), "General SSLEngine problem"); + Assert.assertTrue(throwable instanceof SSLException); } @AfterClass