Skip to content

Commit

Permalink
Merge pull request #462 from dilanSachi/master
Browse files Browse the repository at this point in the history
Update test cases to fix ssl failures
  • Loading branch information
dilanSachi committed Jun 27, 2023
2 parents 8249d00 + 3b2ba98 commit 4c6c6ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 } };
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 } };
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4c6c6ea

Please sign in to comment.