use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase6 method testCase6_4_2.
/**
* invalid text message, 3 fragments.
* <p>
* fragment #1 is valid and ends in the middle of an incomplete code point.
* <p>
* fragment #2 finishes the UTF8 code point but it is invalid
* <p>
* fragment #3 contains the remainder of the message.
* @throws Exception on test failure
*/
@Test
@Slow
public void testCase6_4_2() throws Exception {
// split code point
byte[] part1 = Hex.asByteArray("CEBAE1BDB9CF83CEBCCEB5F4");
// continue code point & invalid
byte[] part2 = Hex.asByteArray("90");
// continue code point & finish
byte[] part3 = Hex.asByteArray("8080656469746564");
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(new TextFrame().setPayload(ByteBuffer.wrap(part1)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part2)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part3)).setFin(true));
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase6 method testCase6_4_4.
/**
* invalid text message, 1 frame/fragment (slowly, and split within code points)
* @throws Exception on test failure
*/
@Test
@Slow
public void testCase6_4_4() throws Exception {
byte[] invalid = Hex.asByteArray("CEBAE1BDB9CF83CEBCCEB5F49080808080656469746564");
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload(ByteBuffer.wrap(invalid)));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging scope = new StacklessLogging(Parser.class)) {
fuzzer.connect();
ByteBuffer net = fuzzer.asNetworkBuffer(send);
fuzzer.send(net, 6);
fuzzer.send(net, 11);
TimeUnit.SECONDS.sleep(1);
fuzzer.send(net, 1);
TimeUnit.SECONDS.sleep(1);
// the rest
fuzzer.send(net, 100);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase6 method testCase6_4_1.
/**
* invalid text message, 3 fragments.
* <p>
* fragment #1 and fragment #3 are both valid in themselves.
* <p>
* fragment #2 contains the invalid utf8 code point.
* @throws Exception on test failure
*/
@Test
@Slow
public void testCase6_4_1() throws Exception {
byte[] part1 = StringUtil.getUtf8Bytes("κόσμε");
// invalid
byte[] part2 = Hex.asByteArray("F4908080");
byte[] part3 = StringUtil.getUtf8Bytes("edited");
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(new TextFrame().setPayload(ByteBuffer.wrap(part1)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part2)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part3)).setFin(true));
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase6 method testCase6_1_2.
/**
* text message, 0 length, 3 fragments
* @throws Exception on test failure
*/
@Test
public void testCase6_1_2() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setFin(false));
send.add(new ContinuationFrame().setFin(false));
send.add(new ContinuationFrame().setFin(true));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame());
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase6 method testCase6_2_4.
/**
* valid utf8 text message, many fragments (1 byte each)
* @throws Exception on test failure
*/
@Test
public void testCase6_2_4() throws Exception {
byte[] msg = Hex.asByteArray("CEBAE1BDB9CF83CEBCCEB5");
List<WebSocketFrame> send = new ArrayList<>();
fragmentText(send, msg);
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame().setPayload(ByteBuffer.wrap(msg)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
Aggregations