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 cb137e09d3445e0edaf69ccc75fea5eb0c60ce3d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 24 15:57:14 2020 +0100

    Improve test for invalid client preface
---
 .../apache/coyote/http2/TestHttp2Section_3_5.java  | 32 ++++++++++++++++++----
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/test/org/apache/coyote/http2/TestHttp2Section_3_5.java 
b/test/org/apache/coyote/http2/TestHttp2Section_3_5.java
index dc09ca4..e9a9e0e 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_3_5.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_3_5.java
@@ -18,22 +18,42 @@ package org.apache.coyote.http2;
 
 import java.io.IOException;
 
+import org.junit.Assert;
 import org.junit.Test;
 
 public class TestHttp2Section_3_5 extends Http2TestBase {
 
-    @Test(expected=IOException.class)
+    @Test
     public void testNoConnectionPreface() throws Exception {
         enableHttp2();
         configureAndStartWebApplication();
         openClientConnection();
         doHttpUpgrade();
-        // Should send client preface here
-        sendPing();
-        // Send several pings else server will block waiting for the client
-        // preface which is longer than a single ping.
+
+        // Server settings
+        parser.readFrame(true);
+        Assert.assertEquals("0-Settings-[3]-[200]\n" +
+                "0-Settings-End\n"
+                , output.getTrace());
+        output.clearTrace();
+
+        // Should send client preface here. This will trigger an error.
+        // Send two pings (2*(9+8)=34 bytes) as server looks for entire preface
+        // of 24 bytes.
         sendPing();
         sendPing();
-        validateHttp2InitialResponse();
+
+        // If the client preface had been valid, this would be an
+        // acknowledgement. Of the settings. As the preface was invalid, it
+        // should be a GOAWAY frame.
+        try {
+            parser.readFrame(true);
+            Assert.assertTrue(output.getTrace(), 
output.getTrace().startsWith("0-Goaway-[1]-[1]-["));
+        } catch (IOException ioe) {
+            // Ignore
+            // This is expected on some platforms and depends on timing. Once
+            // the server closes the connection the client may see an exception
+            // when trying to read the GOAWAY frame.
+        }
     }
 }


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

Reply via email to