This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 857a6897fd19a04fdc51d07a461ce8cb1c94e46e
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 | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/TestSsl.java 
b/test/org/apache/tomcat/util/net/TestSsl.java
index a1834c0994..4b1fdf30aa 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -265,15 +265,13 @@ public class TestSsl extends TomcatBaseTest {
     }
 
     @Test
-    public void testRenegotiateWorks() throws Exception {
-        Tomcat tomcat = getTomcatInstance();
+    public void testClientInitiatedRenegotiation() throws Exception {
 
+        Tomcat tomcat = getTomcatInstance();
         TesterSupport.initSsl(tomcat);
-
         TesterSupport.configureSSLImplementation(tomcat, 
sslImplementationName);
 
-        Assume.assumeTrue("SSL renegotiation has to be supported for this 
test",
-                
TesterSupport.isClientRenegotiationSupported(getTomcatInstance()));
+        boolean renegotiationSupported = 
TesterSupport.isClientRenegotiationSupported(getTomcatInstance());
 
         if (needApr) {
             AprLifecycleListener listener = new AprLifecycleListener();
@@ -283,12 +281,10 @@ public class TestSsl extends TomcatBaseTest {
         }
 
         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");
 
-
         tomcat.start();
 
         SSLContext sslCtx;
@@ -299,8 +295,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();
@@ -315,7 +310,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()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to