This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 324e5483251526c7e6b5ee71150c41f5b6d73103 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, 18 insertions(+), 15 deletions(-) diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java index 16eebd05c8..2d15123757 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 fe05118d28..38603a75c5 100644 --- a/test/org/apache/tomcat/util/net/TesterSupport.java +++ b/test/org/apache/tomcat/util/net/TesterSupport.java @@ -249,10 +249,7 @@ 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") && isMacOs())) { - // 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