Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-websocket')
-rw-r--r--jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase3.java3
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AllTests.java15
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java1288
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_BadUTF.java157
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_GoodUTF.java134
5 files changed, 307 insertions, 1290 deletions
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase3.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase3.java
index 668fea4f5e..5fa055a79b 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase3.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase3.java
@@ -29,6 +29,9 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+/**
+ * Test various invalid frame situations
+ */
@RunWith(value = Parameterized.class)
public class TestABCase3
{
diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AllTests.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AllTests.java
index eb6267240a..ffd8e57e1a 100644
--- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AllTests.java
+++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AllTests.java
@@ -4,8 +4,19 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-@Suite.SuiteClasses(
-{ TestABCase1.class, TestABCase2.class, TestABCase3.class, TestABCase4.class, TestABCase5.class, TestABCase6.class, TestABCase7_9.class })
+// @formatter:off
+@Suite.SuiteClasses( {
+ TestABCase1.class,
+ TestABCase2.class,
+ TestABCase3.class,
+ TestABCase4.class,
+ TestABCase5.class,
+ TestABCase6.class,
+ TestABCase6_GoodUTF.class,
+ TestABCase6_BadUTF.class,
+ TestABCase7_9.class
+})
+// @formatter:on
public class AllTests
{
/* let junit do the rest */
diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java
index 418a445720..6834d78acc 100644
--- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java
+++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java
@@ -37,53 +37,6 @@ import org.junit.runner.RunWith;
@RunWith(AdvancedRunner.class)
public class TestABCase6 extends AbstractABCase
{
- private void assertBadTextPayload(byte[] invalid) throws Exception
- {
- List<WebSocketFrame> send = new ArrayList<>();
- send.add(new WebSocketFrame(OpCode.TEXT).setPayload(invalid));
- send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
-
- List<WebSocketFrame> expect = new ArrayList<>();
- expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
-
- Fuzzer fuzzer = new Fuzzer(this);
- try
- {
- fuzzer.connect();
- fuzzer.setSendMode(Fuzzer.SendMode.BULK);
- fuzzer.send(send);
- fuzzer.expect(expect);
- }
- finally
- {
- fuzzer.close();
- }
- }
-
- private void assertEchoTextMessage(byte[] msg) throws Exception
- {
- List<WebSocketFrame> send = new ArrayList<>();
- send.add(new WebSocketFrame(OpCode.TEXT).setPayload(msg));
- send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
-
- List<WebSocketFrame> expect = new ArrayList<>();
- expect.add(new WebSocketFrame(OpCode.TEXT).setPayload(msg));
- expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
-
- Fuzzer fuzzer = new Fuzzer(this);
- try
- {
- fuzzer.connect();
- fuzzer.setSendMode(Fuzzer.SendMode.BULK);
- fuzzer.send(send);
- fuzzer.expect(expect);
- }
- finally
- {
- fuzzer.close();
- }
- }
-
/**
* Split a message byte array into a series of fragments (frames + continuations) of 1 byte message contents each.
*/
@@ -194,519 +147,6 @@ public class TestABCase6 extends AbstractABCase
}
/**
- * invalid utf8 text message, 1 frame/fragment, 4 bytes
- */
- @Test
- public void testCase6_10_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F7BFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 5 bytes
- */
- @Test
- public void testCase6_10_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FBBFBFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 6 bytes
- */
- @Test
- public void testCase6_10_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FDBFBFBFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. 3 bytes, 1 codepoint (other boundary conditions)
- */
- @Test
- public void testCase6_11_1() throws Exception
- {
- byte msg[] = Hex.asByteArray("ED9FBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. 3 bytes, 1 codepoint (other boundary conditions)
- */
- @Test
- public void testCase6_11_2() throws Exception
- {
- byte msg[] = Hex.asByteArray("EE8080");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. 3 bytes, 1 codepoint (other boundary conditions)
- */
- @Test
- public void testCase6_11_3() throws Exception
- {
- byte msg[] = Hex.asByteArray("EFBFBD");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. 4 bytes, 1 codepoint (other boundary conditions)
- */
- @Test
- public void testCase6_11_4() throws Exception
- {
- byte msg[] = Hex.asByteArray("F48FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 4 bytes (other boundary conditions)
- */
- @Test
- public void testCase6_11_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F4908080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 1 byte (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("80");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 1 byte (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("BF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 2 bytes (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("80BF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 3 bytes (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("80BF80");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 4 bytes (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("80BF80BF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 5 bytes (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_6() throws Exception
- {
- byte invalid[] = Hex.asByteArray("80BF80BF80");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 6 bytes (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_7() throws Exception
- {
- byte invalid[] = Hex.asByteArray("80BF80BF80BF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. many bytes (unexpected continuation bytes)
- */
- @Test
- public void testCase6_12_8() throws Exception
- {
- byte invalid[] = Hex.asByteArray("808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9"
- + "FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBE");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. many bytes (lonely start characters)
- */
- @Test
- public void testCase6_13_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("C020C120C220C320C420C520C620C720C820C920CA20CB20CC20CD20CE20CF2"
- + "0D020D120D220D320D420D520D620D720D820D920DA20DB20DC20DD20DE20");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. many bytes (lonely start characters)
- */
- @Test
- public void testCase6_13_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("E020E120E220E320E420E520E620E720E820E920EA20EB20EC20ED20EE20");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. many bytes (lonely start characters)
- */
- @Test
- public void testCase6_13_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F020F120F220F320F420F520F620");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 6 bytes (lonely start characters)
- */
- @Test
- public void testCase6_13_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F820F920FA20");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. 2 bytes (lonely start characters)
- */
- @Test
- public void testCase6_13_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FC20");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("C0");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_10() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FDBFBFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("E080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F08080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F8808080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FC80808080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_6() throws Exception
- {
- byte invalid[] = Hex.asByteArray("DF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_7() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_8() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F7BFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (last continuation byte missing)
- */
- @Test
- public void testCase6_14_9() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FBBFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (incomplete sequences)
- */
- @Test
- public void testCase6_15_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("C0E080F08080F8808080FC80808080DFEFBFF7BFBFFBBFBFBFFDBFBFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (impossible bytes)
- */
- @Test
- public void testCase6_16_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FE");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (impossible bytes)
- */
- @Test
- public void testCase6_16_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (impossible bytes)
- */
- @Test
- public void testCase6_16_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FEFEFFFF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong ascii character)
- */
- @Test
- public void testCase6_17_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("C0AF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong ascii character)
- */
- @Test
- public void testCase6_17_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("E080AF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong ascii character)
- */
- @Test
- public void testCase6_17_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F08080AF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong ascii character)
- */
- @Test
- public void testCase6_17_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F8808080AF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong ascii character)
- */
- @Test
- public void testCase6_17_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FC80808080AF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (maximum overlong sequences)
- */
- @Test
- public void testCase6_18_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("C1BF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (maximum overlong sequences)
- */
- @Test
- public void testCase6_18_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("E09FBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (maximum overlong sequences)
- */
- @Test
- public void testCase6_18_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F08FBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (maximum overlong sequences)
- */
- @Test
- public void testCase6_18_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F887BFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (maximum overlong sequences)
- */
- @Test
- public void testCase6_18_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FC83BFBFBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong representation of the NUL character)
- */
- @Test
- public void testCase6_19_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("C080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong representation of the NUL character)
- */
- @Test
- public void testCase6_19_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("E08080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong representation of the NUL character)
- */
- @Test
- public void testCase6_19_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F0808080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong representation of the NUL character)
- */
- @Test
- public void testCase6_19_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F880808080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (overlong representation of the NUL character)
- */
- @Test
- public void testCase6_19_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FC8080808080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment.
- */
- @Test
- public void testCase6_2_1() throws Exception
- {
- String utf8 = "Hello-\uC2B5@\uC39F\uC3A4\uC3BC\uC3A0\uC3A1-UTF-8!!";
- byte msg[] = StringUtil.getUtf8Bytes(utf8);
- assertEchoTextMessage(msg);
- }
-
- /**
* valid utf8 text message, 2 fragments (on UTF8 code point boundary)
*/
@Test
@@ -800,516 +240,6 @@ public class TestABCase6 extends AbstractABCase
}
/**
- * invalid utf8 text message, 1 frame/fragment. (single UTF-16 surrogates)
- */
- @Test
- public void testCase6_20_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDA080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (single UTF-16 surrogates)
- */
- @Test
- public void testCase6_20_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDADBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (single UTF-16 surrogates)
- */
- @Test
- public void testCase6_20_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDAE80");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (single UTF-16 surrogates)
- */
- @Test
- public void testCase6_20_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDAFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (single UTF-16 surrogates)
- */
- @Test
- public void testCase6_20_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDB080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (single UTF-16 surrogates)
- */
- @Test
- public void testCase6_20_6() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDBE80");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (single UTF-16 surrogates)
- */
- @Test
- public void testCase6_20_7() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDA080EDB080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDA080EDBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDADBFEDB080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDADBFEDBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_5() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDAE80EDB080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_6() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDAE80EDBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_7() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDAFBFEDB080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment. (paired UTF-16 surrogates)
- */
- @Test
- public void testCase6_21_8() throws Exception
- {
- byte invalid[] = Hex.asByteArray("EDAFBFEDBFBF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_1() throws Exception
- {
- byte msg[] = Hex.asByteArray("EFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_10() throws Exception
- {
- byte msg[] = Hex.asByteArray("F18FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_11() throws Exception
- {
- byte msg[] = Hex.asByteArray("F19FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_12() throws Exception
- {
- byte msg[] = Hex.asByteArray("F19FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_13() throws Exception
- {
- byte msg[] = Hex.asByteArray("F1AFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_14() throws Exception
- {
- byte msg[] = Hex.asByteArray("F1AFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_15() throws Exception
- {
- byte msg[] = Hex.asByteArray("F1BFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_16() throws Exception
- {
- byte msg[] = Hex.asByteArray("F1BFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_17() throws Exception
- {
- byte msg[] = Hex.asByteArray("F28FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_18() throws Exception
- {
- byte msg[] = Hex.asByteArray("F28FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_19() throws Exception
- {
- byte msg[] = Hex.asByteArray("F29FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_2() throws Exception
- {
- byte msg[] = Hex.asByteArray("EFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_20() throws Exception
- {
- byte msg[] = Hex.asByteArray("F29FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_21() throws Exception
- {
- byte msg[] = Hex.asByteArray("F2AFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_22() throws Exception
- {
- byte msg[] = Hex.asByteArray("F2AFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_23() throws Exception
- {
- byte msg[] = Hex.asByteArray("F2BFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_24() throws Exception
- {
- byte msg[] = Hex.asByteArray("F2BFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_25() throws Exception
- {
- byte msg[] = Hex.asByteArray("F38FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_26() throws Exception
- {
- byte msg[] = Hex.asByteArray("F38FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_27() throws Exception
- {
- byte msg[] = Hex.asByteArray("F39FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_28() throws Exception
- {
- byte msg[] = Hex.asByteArray("F39FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_29() throws Exception
- {
- byte msg[] = Hex.asByteArray("F3AFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_3() throws Exception
- {
- byte msg[] = Hex.asByteArray("F09FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_30() throws Exception
- {
- byte msg[] = Hex.asByteArray("F3AFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_31() throws Exception
- {
- byte msg[] = Hex.asByteArray("F3BFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_32() throws Exception
- {
- byte msg[] = Hex.asByteArray("F3BFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_33() throws Exception
- {
- byte msg[] = Hex.asByteArray("F48FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_34() throws Exception
- {
- byte msg[] = Hex.asByteArray("F48FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_4() throws Exception
- {
- byte msg[] = Hex.asByteArray("F09FBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_5() throws Exception
- {
- byte msg[] = Hex.asByteArray("F0AFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_6() throws Exception
- {
- byte msg[] = Hex.asByteArray("F0AFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_7() throws Exception
- {
- byte msg[] = Hex.asByteArray("F0BFBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_8() throws Exception
- {
- byte msg[] = Hex.asByteArray("F0BFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (non character code points)
- */
- @Test
- public void testCase6_22_9() throws Exception
- {
- byte msg[] = Hex.asByteArray("F18FBFBE");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment. (unicode replacement character)
- */
- @Test
- public void testCase6_23_1() throws Exception
- {
- byte msg[] = Hex.asByteArray("EFBFBD");
- assertEchoTextMessage(msg);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragments
- */
- @Test
- public void testCase6_3_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("CEBAE1BDB9CF83CEBCCEB5EDA080656469746564");
- assertBadTextPayload(invalid);
- }
-
- /**
* invalid utf8 text message, many fragments (1 byte each)
*/
@Test
@@ -1487,222 +417,4 @@ public class TestABCase6 extends AbstractABCase
fuzzer.close();
}
}
-
- /**
- * valid utf8 text message, 1 frame/fragment.
- */
- @Test
- public void testCase6_5_1() throws Exception
- {
- byte msg[] = Hex.asByteArray("CEBAE1BDB9CF83CEBCCEB5");
- assertEchoTextMessage(msg);
- }
-
- /**
- * invalid utf8 (incomplete code point) text message, 1 frame/fragment.
- */
- @Test
- public void testCase6_6_1() throws Exception
- {
- byte incomplete[] = Hex.asByteArray("CE");
- assertBadTextPayload(incomplete);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 4 valid code points + 1 partial code point
- */
- @Test
- public void testCase6_6_10() throws Exception
- {
- byte invalid[] = Hex.asByteArray("CEBAE1BDB9CF83CEBCCE");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 5 valid code points (preserved on echo).
- */
- @Test
- public void testCase6_6_11() throws Exception
- {
- assertEchoTextMessage(Hex.asByteArray("CEBAE1BDB9CF83CEBCCEB5"));
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 1 valid code point (preserved on echo).
- */
- @Test
- public void testCase6_6_2() throws Exception
- {
- assertEchoTextMessage(Hex.asByteArray("CEBA"));
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 1 valid code point + 1 partial code point
- */
- @Test
- public void testCase6_6_3() throws Exception
- {
- byte invalid[] = Hex.asByteArray("CEBAE1");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 1 valid code point + 1 invalid code point
- */
- @Test
- public void testCase6_6_4() throws Exception
- {
- byte invalid[] = Hex.asByteArray("CEBAE1BD");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 2 valid code points (preserved on echo).
- */
- @Test
- public void testCase6_6_5() throws Exception
- {
- byte msg[] = Hex.asByteArray("CEBAE1BDB9");
- assertEchoTextMessage(msg);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 2 valid code points + 1 partial code point
- */
- @Test
- public void testCase6_6_6() throws Exception
- {
- byte invalid[] = Hex.asByteArray("CEBAE1BDB9CF");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 3 valid code points (preserved on echo).
- */
- @Test
- public void testCase6_6_7() throws Exception
- {
- byte msg[] = Hex.asByteArray("CEBAE1BDB9CF83");
- assertEchoTextMessage(msg);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 3 valid code points + 1 partial code point
- */
- @Test
- public void testCase6_6_8() throws Exception
- {
- byte invalid[] = Hex.asByteArray("CEBAE1BDB9CF83CE");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 4 valid code points (preserved on echo).
- */
- @Test
- public void testCase6_6_9() throws Exception
- {
- byte msg[] = Hex.asByteArray("CEBAE1BDB9CF83CEBC");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 1 byte, 1 codepoint
- */
- @Test
- public void testCase6_7_1() throws Exception
- {
- byte msg[] = Hex.asByteArray("00");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 2 bytes, 1 codepoint
- */
- @Test
- public void testCase6_7_2() throws Exception
- {
- byte msg[] = Hex.asByteArray("C280");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 3 bytes, 1 codepoint
- */
- @Test
- public void testCase6_7_3() throws Exception
- {
- byte msg[] = Hex.asByteArray("E0A080");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 4 bytes, 1 codepoint
- */
- @Test
- public void testCase6_7_4() throws Exception
- {
- byte msg[] = Hex.asByteArray("F0908080");
- assertEchoTextMessage(msg);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 5 bytes
- */
- @Test
- public void testCase6_8_1() throws Exception
- {
- byte invalid[] = Hex.asByteArray("F888808080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * invalid utf8 text message, 1 frame/fragment, 6 bytes
- */
- @Test
- public void testCase6_8_2() throws Exception
- {
- byte invalid[] = Hex.asByteArray("FC8480808080");
- assertBadTextPayload(invalid);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 1 byte, 1 codepoint
- */
- @Test
- public void testCase6_9_1() throws Exception
- {
- byte msg[] = Hex.asByteArray("7F");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 2 bytes, 1 codepoint
- */
- @Test
- public void testCase6_9_2() throws Exception
- {
- byte msg[] = Hex.asByteArray("DFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 3 bytes, 1 codepoint
- */
- @Test
- public void testCase6_9_3() throws Exception
- {
- byte msg[] = Hex.asByteArray("EFBFBF");
- assertEchoTextMessage(msg);
- }
-
- /**
- * valid utf8 text message, 1 frame/fragment, 4 bytes, 1 codepoint
- */
- @Test
- public void testCase6_9_4() throws Exception
- {
- byte msg[] = Hex.asByteArray("F48FBFBF");
- assertEchoTextMessage(msg);
- }
}
diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_BadUTF.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_BadUTF.java
new file mode 100644
index 0000000000..1d65e914ac
--- /dev/null
+++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_BadUTF.java
@@ -0,0 +1,157 @@
+package org.eclipse.jetty.websocket.server.ab;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.websocket.api.StatusCode;
+import org.eclipse.jetty.websocket.protocol.CloseInfo;
+import org.eclipse.jetty.websocket.protocol.OpCode;
+import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
+import org.eclipse.jetty.websocket.server.helper.Hex;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Tests of Known Bad UTF8 sequences that should trigger a {@link StatusCode#BAD_PAYLOAD} close and early connection termination
+ */
+@RunWith(Parameterized.class)
+public class TestABCase6_BadUTF extends AbstractABCase
+{
+ private static final Logger LOG = Log.getLogger(TestABCase6_BadUTF.class);
+
+ @Parameters
+ public static Collection<String[]> data()
+ {
+ // The various Good UTF8 sequences as a String (hex form)
+ List<String[]> data = new ArrayList<>();
+
+ // @formatter:off
+ // - differently unicode fragmented
+ data.add(new String[]{ "6.3.1", "CEBAE1BDB9CF83CEBCCEB5EDA080656469746564" });
+ // - partial/incomplete multi-byte code points
+ data.add(new String[]{ "6.6.1", "CE" });
+ data.add(new String[]{ "6.6.3", "CEBAE1" });
+ data.add(new String[]{ "6.6.4", "CEBAE1BD" });
+ data.add(new String[]{ "6.6.6", "CEBAE1BDB9CF" });
+ data.add(new String[]{ "6.6.8", "CEBAE1BDB9CF83CE" });
+ data.add(new String[]{ "6.6.10", "CEBAE1BDB9CF83CEBCCE" });
+ // - first possible sequence length 5/6 (invalid code points)
+ data.add(new String[]{ "6.8.1", "F888808080" });
+ data.add(new String[]{ "6.8.2", "FC8480808080" });
+ // - last possible sequence length (invalid code points)
+ data.add(new String[]{ "6.10.1", "F7BFBFBF" });
+ data.add(new String[]{ "6.10.2", "FBBFBFBFBF" });
+ data.add(new String[]{ "6.10.3", "FDBFBFBFBFBF" });
+ // - other boundary conditions
+ data.add(new String[]{ "6.11.5", "F4908080" });
+ // - unexpected continuation bytes
+ data.add(new String[]{ "6.12.1", "80" });
+ data.add(new String[]{ "6.12.2", "BF" });
+ data.add(new String[]{ "6.12.3", "80BF" });
+ data.add(new String[]{ "6.12.4", "80BF80" });
+ data.add(new String[]{ "6.12.5", "80BF80BF" });
+ data.add(new String[]{ "6.12.6", "80BF80BF80" });
+ data.add(new String[]{ "6.12.7", "80BF80BF80BF" });
+ data.add(new String[]{ "6.12.8", "808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9"
+ + "FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBE" });
+ // - lonely start characters
+ data.add(new String[]{ "6.13.1", "C020C120C220C320C420C520C620C720C820C920CA20CB20CC20CD20CE20CF2"
+ + "0D020D120D220D320D420D520D620D720D820D920DA20DB20DC20DD20DE20" });
+ data.add(new String[]{ "6.13.2", "E020E120E220E320E420E520E620E720E820E920EA20EB20EC20ED20EE20" });
+ data.add(new String[]{ "6.13.3", "F020F120F220F320F420F520F620" });
+ data.add(new String[]{ "6.13.4", "F820F920FA20" });
+ data.add(new String[]{ "6.13.5", "FC20" });
+ // - sequences with last continuation byte missing
+ data.add(new String[]{ "6.14.1", "C0" });
+ data.add(new String[]{ "6.14.2", "E080" });
+ data.add(new String[]{ "6.14.3", "F08080" });
+ data.add(new String[]{ "6.14.4", "F8808080" });
+ data.add(new String[]{ "6.14.5", "FC80808080" });
+ data.add(new String[]{ "6.14.6", "DF" });
+ data.add(new String[]{ "6.14.7", "EFBF" });
+ data.add(new String[]{ "6.14.8", "F7BFBF" });
+ data.add(new String[]{ "6.14.9", "FBBFBFBF" });
+ data.add(new String[]{ "6.14.10", "FDBFBFBFBF" });
+ // - concatenation of incomplete sequences
+ data.add(new String[]{ "6.15.1", "C0E080F08080F8808080FC80808080DFEFBFF7BFBFFBBFBFBFFDBFBFBFBF" });
+ // - impossible bytes
+ data.add(new String[]{ "6.16.1", "FE" });
+ data.add(new String[]{ "6.16.2", "FF" });
+ data.add(new String[]{ "6.16.3", "FEFEFFFF" });
+ // - overlong ascii characters
+ data.add(new String[]{ "6.17.1", "C0AF" });
+ data.add(new String[]{ "6.17.2", "E080AF" });
+ data.add(new String[]{ "6.17.3", "F08080AF" });
+ data.add(new String[]{ "6.17.4", "F8808080AF" });
+ data.add(new String[]{ "6.17.5", "FC80808080AF" });
+ // - maximum overlong sequences
+ data.add(new String[]{ "6.18.1", "C1BF" });
+ data.add(new String[]{ "6.18.2", "E09FBF" });
+ data.add(new String[]{ "6.18.3", "F08FBFBF" });
+ data.add(new String[]{ "6.18.4", "F887BFBFBF" });
+ data.add(new String[]{ "6.18.5", "FC83BFBFBFBF" });
+ // - overlong representation of NUL character
+ data.add(new String[]{ "6.19.1", "C080" });
+ data.add(new String[]{ "6.19.2", "E08080" });
+ data.add(new String[]{ "6.19.3", "F0808080" });
+ data.add(new String[]{ "6.19.4", "F880808080" });
+ data.add(new String[]{ "6.19.5", "FC8080808080" });
+ // - single UTF-16 surrogates
+ data.add(new String[]{ "6.20.1", "EDA080" });
+ data.add(new String[]{ "6.20.2", "EDADBF" });
+ data.add(new String[]{ "6.20.3", "EDAE80" });
+ data.add(new String[]{ "6.20.4", "EDAFBF" });
+ data.add(new String[]{ "6.20.5", "EDB080" });
+ data.add(new String[]{ "6.20.6", "EDBE80" });
+ data.add(new String[]{ "6.20.7", "EDBFBF" });
+ // - paired UTF-16 surrogates
+ data.add(new String[]{ "6.21.1", "EDA080EDB080" });
+ data.add(new String[]{ "6.21.2", "EDA080EDBFBF" });
+ data.add(new String[]{ "6.21.3", "EDADBFEDB080" });
+ data.add(new String[]{ "6.21.4", "EDADBFEDBFBF" });
+ data.add(new String[]{ "6.21.5", "EDAE80EDB080" });
+ data.add(new String[]{ "6.21.6", "EDAE80EDBFBF" });
+ data.add(new String[]{ "6.21.7", "EDAFBFEDB080" });
+ data.add(new String[]{ "6.21.8", "EDAFBFEDBFBF" });
+ // @formatter:on
+
+ return data;
+ }
+
+ private final byte[] invalid;
+
+ public TestABCase6_BadUTF(String testId, String hexMsg)
+ {
+ LOG.debug("Test ID: {}",testId);
+ this.invalid = Hex.asByteArray(hexMsg);
+ }
+
+ @Test
+ public void assertBadTextPayload() throws Exception
+ {
+ List<WebSocketFrame> send = new ArrayList<>();
+ send.add(new WebSocketFrame(OpCode.TEXT).setPayload(invalid));
+ send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
+
+ List<WebSocketFrame> expect = new ArrayList<>();
+ expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
+
+ Fuzzer fuzzer = new Fuzzer(this);
+ try
+ {
+ fuzzer.connect();
+ fuzzer.setSendMode(Fuzzer.SendMode.BULK);
+ fuzzer.send(send);
+ fuzzer.expect(expect);
+ }
+ finally
+ {
+ fuzzer.close();
+ }
+ }
+}
diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_GoodUTF.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_GoodUTF.java
new file mode 100644
index 0000000000..14685fdd1d
--- /dev/null
+++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6_GoodUTF.java
@@ -0,0 +1,134 @@
+package org.eclipse.jetty.websocket.server.ab;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.websocket.api.StatusCode;
+import org.eclipse.jetty.websocket.protocol.CloseInfo;
+import org.eclipse.jetty.websocket.protocol.OpCode;
+import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
+import org.eclipse.jetty.websocket.server.helper.Hex;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Tests of Known Good UTF8 sequences.
+ * <p>
+ * Should be preserved / echoed back, with normal close code.
+ */
+@RunWith(Parameterized.class)
+public class TestABCase6_GoodUTF extends AbstractABCase
+{
+ private static final Logger LOG = Log.getLogger(TestABCase6_GoodUTF.class);
+
+ @Parameters
+ public static Collection<String[]> data()
+ {
+ // The various Good UTF8 sequences as a String (hex form)
+ List<String[]> data = new ArrayList<>();
+
+ // @formatter:off
+ // - combination of simple 1 byte characters and unicode code points
+ data.add(new String[]{ "6.2.1", "48656C6C6F2DC2B540C39FC3B6C3A4C3BCC3A0C3A12D5554462D382121" });
+ // - simple valid UTF8 sequence
+ data.add(new String[]{ "6.5.1", "CEBAE1BDB9CF83CEBCCEB5" });
+ // - multi-byte code points
+ data.add(new String[]{ "6.6.11", "CEBAE1BDB9CF83CEBCCEB5" });
+ data.add(new String[]{ "6.6.2", "CEBA" });
+ data.add(new String[]{ "6.6.5", "CEBAE1BDB9" });
+ data.add(new String[]{ "6.6.7", "CEBAE1BDB9CF83" });
+ data.add(new String[]{ "6.6.9", "CEBAE1BDB9CF83CEBC" });
+ // - first possible sequence of a certain length (1 code point)
+ data.add(new String[]{ "6.7.1", "00" });
+ data.add(new String[]{ "6.7.2", "C280" });
+ data.add(new String[]{ "6.7.3", "E0A080" });
+ data.add(new String[]{ "6.7.4", "F0908080" });
+ // - last possible sequence of a certain length (1 code point)
+ data.add(new String[]{ "6.9.1", "7F" });
+ data.add(new String[]{ "6.9.2", "DFBF" });
+ data.add(new String[]{ "6.9.3", "EFBFBF" });
+ data.add(new String[]{ "6.9.4", "F48FBFBF" });
+ // - other boundary conditions
+ data.add(new String[]{ "6.11.1", "ED9FBF" });
+ data.add(new String[]{ "6.11.2", "EE8080" });
+ data.add(new String[]{ "6.11.3", "EFBFBD" });
+ data.add(new String[]{ "6.11.4", "F48FBFBF" });
+ // - non character code points
+ data.add(new String[]{ "6.22.1", "EFBFBE" });
+ data.add(new String[]{ "6.22.2", "EFBFBF" });
+ data.add(new String[]{ "6.22.3", "F09FBFBE" });
+ data.add(new String[]{ "6.22.4", "F09FBFBF" });
+ data.add(new String[]{ "6.22.5", "F0AFBFBE" });
+ data.add(new String[]{ "6.22.6", "F0AFBFBF" });
+ data.add(new String[]{ "6.22.7", "F0BFBFBE" });
+ data.add(new String[]{ "6.22.8", "F0BFBFBF" });
+ data.add(new String[]{ "6.22.9", "F18FBFBE" });
+ data.add(new String[]{ "6.22.10", "F18FBFBF" });
+ data.add(new String[]{ "6.22.11", "F19FBFBE" });
+ data.add(new String[]{ "6.22.12", "F19FBFBF" });
+ data.add(new String[]{ "6.22.13", "F1AFBFBE" });
+ data.add(new String[]{ "6.22.14", "F1AFBFBF" });
+ data.add(new String[]{ "6.22.15", "F1BFBFBE" });
+ data.add(new String[]{ "6.22.16", "F1BFBFBF" });
+ data.add(new String[]{ "6.22.17", "F28FBFBE" });
+ data.add(new String[]{ "6.22.18", "F28FBFBF" });
+ data.add(new String[]{ "6.22.19", "F29FBFBE" });
+ data.add(new String[]{ "6.22.20", "F29FBFBF" });
+ data.add(new String[]{ "6.22.21", "F2AFBFBE" });
+ data.add(new String[]{ "6.22.22", "F2AFBFBF" });
+ data.add(new String[]{ "6.22.23", "F2BFBFBE" });
+ data.add(new String[]{ "6.22.24", "F2BFBFBF" });
+ data.add(new String[]{ "6.22.25", "F38FBFBE" });
+ data.add(new String[]{ "6.22.26", "F38FBFBF" });
+ data.add(new String[]{ "6.22.27", "F39FBFBE" });
+ data.add(new String[]{ "6.22.28", "F39FBFBF" });
+ data.add(new String[]{ "6.22.29", "F3AFBFBE" });
+ data.add(new String[]{ "6.22.30", "F3AFBFBF" });
+ data.add(new String[]{ "6.22.31", "F3BFBFBE" });
+ data.add(new String[]{ "6.22.32", "F3BFBFBF" });
+ data.add(new String[]{ "6.22.33", "F48FBFBE" });
+ data.add(new String[]{ "6.22.34", "F48FBFBF" });
+ // - unicode replacement character
+ data.add(new String[]{ "6.23.1", "EFBFBD" });
+ // @formatter:on
+
+ return data;
+ }
+ private final byte[] msg;
+
+ public TestABCase6_GoodUTF(String testId, String hexMsg)
+ {
+ LOG.debug("Test ID: {}",testId);
+ this.msg = Hex.asByteArray(hexMsg);
+ }
+
+ @Test
+ public void assertEchoTextMessage() throws Exception
+ {
+ List<WebSocketFrame> send = new ArrayList<>();
+ send.add(new WebSocketFrame(OpCode.TEXT).setPayload(msg));
+ send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
+
+ List<WebSocketFrame> expect = new ArrayList<>();
+ expect.add(new WebSocketFrame(OpCode.TEXT).setPayload(msg));
+ expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
+
+ Fuzzer fuzzer = new Fuzzer(this);
+ try
+ {
+ fuzzer.connect();
+ fuzzer.setSendMode(Fuzzer.SendMode.BULK);
+ fuzzer.send(send);
+ fuzzer.expect(expect);
+ }
+ finally
+ {
+ fuzzer.close();
+ }
+ }
+}

Back to the top