tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1696508 - in /tomcat/trunk: java/org/apache/coyote/http2/FrameType.java test/org/apache/coyote/http2/TestHttp2Section_6_9.java
Date Tue, 18 Aug 2015 21:38:01 GMT
Author: markt
Date: Tue Aug 18 21:38:01 2015
New Revision: 1696508

URL: http://svn.apache.org/r1696508
Log:
Add some initial tests for section 6.9
Fix a bug in the HTTP/2 parsers handling of window update frames with the wrong length (it
should trigger a connection error)

Added:
    tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java   (with props)
Modified:
    tomcat/trunk/java/org/apache/coyote/http2/FrameType.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/FrameType.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/FrameType.java?rev=1696508&r1=1696507&r2=1696508&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/FrameType.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/FrameType.java Tue Aug 18 21:38:01 2015
@@ -30,7 +30,7 @@ public enum FrameType {
     PUSH_PROMISE  (5,   false,  true, (x) -> x >= 4,      true),
     PING          (6,    true, false, (x) -> x == 8,     false),
     GOAWAY        (7,    true, false, (x) -> x >= 8,     false),
-    WINDOW_UPDATE (8,    true,  true, (x) -> x == 4,     false),
+    WINDOW_UPDATE (8,    true,  true, (x) -> x == 4,      true),
     CONTINUATION  (9,   false,  true, null,               true),
     UNKNOWN       (256,  true,  true, null,              false);
 

Added: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java?rev=1696508&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java (added)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java Tue Aug 18 21:38:01
2015
@@ -0,0 +1,98 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.coyote.http2;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Unit tests for Section 6.9 of
+ * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
+ * <br>
+ * The order of tests in this class is aligned with the order of the
+ * requirements in the RFC.
+ */
+public class TestHttp2Section_6_9 extends Http2TestBase {
+
+    @Test
+    public void testZeroWindowUpdateConnection() throws Exception {
+        http2Connect();
+
+        sendWindowUpdate(0, 0);
+
+        parser.readFrame(true);
+
+        Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+                "0-Goaway-[1]-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]-["));
+    }
+
+
+    @Test
+    public void testZeroWindowUpdateStream() throws Exception {
+        http2Connect();
+
+        sendPriority(3,  0,  15);
+
+        sendWindowUpdate(3, 0);
+
+        parser.readFrame(true);
+
+        Assert.assertEquals("3-RST-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]",
+                output.getTrace());
+    }
+
+
+    @Test
+    public void testWindowUpdateOnClosedStream() throws Exception {
+        http2Connect();
+
+        // Should not be an error so should be nothing to read
+        sendWindowUpdate(1, 200);
+
+        // So the next request should process normally
+        sendSimpleGetRequest(3);
+        readSimpleGetResponse();
+        Assert.assertEquals(getSimpleResponseTrace(3), output.getTrace());
+    }
+
+
+    // TODO: Test always accounting for changes in flow control windows even if
+    //       the frame is in error.
+
+
+    @Test
+    public void testWindowUpdateWrongLength() throws Exception {
+        http2Connect();
+
+        byte[] zeroLengthWindowFrame = new byte[9];
+        // Length zero
+        ByteUtil.setOneBytes(zeroLengthWindowFrame, 3, FrameType.WINDOW_UPDATE.getIdByte());
+        // No flags
+        // Stream 1
+        ByteUtil.set31Bits(zeroLengthWindowFrame, 5, 1);
+
+        os.write(zeroLengthWindowFrame);
+        os.flush();
+
+        parser.readFrame(true);
+
+        Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
+                "0-Goaway-[1]-[" + Http2Error.FRAME_SIZE_ERROR.getCode() + "]-["));
+    }
+
+    // TODO: Remaining 6.9 tests
+}

Propchange: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java
------------------------------------------------------------------------------
    svn:eol-style = native



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


Mime
View raw message