This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 1064d250c9463d3604d14de6229cf9edd4f04710 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jan 3 10:38:03 2024 +0000 Refactor test to test renegotiation failure rather than skipping test --- test/org/apache/tomcat/util/net/TestSsl.java | 28 +++++++++++++--------- test/org/apache/tomcat/util/net/TesterSupport.java | 5 ---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java index cf81df6d22..4ae2f00260 100644 --- a/test/org/apache/tomcat/util/net/TestSsl.java +++ b/test/org/apache/tomcat/util/net/TestSsl.java @@ -39,7 +39,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Assert; -import org.junit.Assume; import org.junit.Test; import org.apache.catalina.Context; @@ -205,20 +204,18 @@ public class TestSsl extends TomcatBaseTest { } @Test - public void testRenegotiateWorks() throws Exception { + public void testClientInitiatedRenegotiation() throws Exception { + Tomcat tomcat = getTomcatInstance(); + TesterSupport.initSsl(tomcat); - Assume.assumeTrue("SSL renegotiation has to be supported for this test", - TesterSupport.isClientRenegotiationSupported(getTomcatInstance())); + boolean renegotiationSupported = TesterSupport.isClientRenegotiationSupported(getTomcatInstance()); Context root = tomcat.addContext("", TEMP_DIR); - Wrapper w = - Tomcat.addServlet(root, "tester", new TesterServlet()); + Wrapper w = Tomcat.addServlet(root, "tester", new TesterServlet()); w.setAsyncSupported(true); root.addServletMappingDecoded("/", "tester"); - TesterSupport.initSsl(tomcat); - tomcat.start(); SSLContext sslCtx; @@ -232,8 +229,7 @@ public class TestSsl extends TomcatBaseTest { } sslCtx.init(null, TesterSupport.getTrustManagers(), null); SSLSocketFactory socketFactory = sslCtx.getSocketFactory(); - SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost", - getPort()); + SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost", getPort()); OutputStream os = socket.getOutputStream(); InputStream is = socket.getInputStream(); @@ -248,7 +244,17 @@ public class TestSsl extends TomcatBaseTest { socket.startHandshake(); - doRequest(os, r); + try { + doRequest(os, r); + if (!renegotiationSupported) { + Assert.fail("Renegotiation started when it should have failed"); + } + } catch (IOException e) { + if (renegotiationSupported) { + Assert.fail("Renegotiation failed when it should be supported"); + } + return; + } // Handshake complete appears to be called asynchronously int wait = 0; while (wait < 5000 && !listener.isComplete()) { diff --git a/test/org/apache/tomcat/util/net/TesterSupport.java b/test/org/apache/tomcat/util/net/TesterSupport.java index 4e9838698d..c8c138cfc0 100644 --- a/test/org/apache/tomcat/util/net/TesterSupport.java +++ b/test/org/apache/tomcat/util/net/TesterSupport.java @@ -60,7 +60,6 @@ import org.apache.catalina.startup.Tomcat; import org.apache.tomcat.jni.Library; import org.apache.tomcat.jni.LibraryNotFoundError; import org.apache.tomcat.jni.SSL; -import org.apache.tomcat.util.compat.JrePlatform; import org.apache.tomcat.util.descriptor.web.LoginConfig; import org.apache.tomcat.util.descriptor.web.SecurityCollection; import org.apache.tomcat.util.descriptor.web.SecurityConstraint; @@ -248,10 +247,6 @@ public final class TesterSupport { // Disabled by default in 1.1.20 windows binary (2010-07-27) return false; } - if (protocol.contains("NioProtocol") || (protocol.contains("Nio2Protocol") && JrePlatform.IS_MAC_OS)) { - // Doesn't work on all platforms - see BZ 56448. - return false; - } String sslImplementation = System.getProperty("tomcat.test.sslImplementation"); if (sslImplementation != null && !"${test.sslImplementation}".equals(sslImplementation)) { // Assume custom SSL is not supporting this --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org