use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase3 method testCase3_7.
/**
* Send close frame with (RSV3 & RSV2 & RSV1), with no extensions defined.
* @throws Exception on test failure
*/
@Test
public void testCase3_7() throws Exception {
byte[] payload = new byte[8];
Arrays.fill(payload, (byte) 0xFF);
List<WebSocketFrame> send = new ArrayList<>();
WebSocketFrame frame = new CloseInfo(StatusCode.NORMAL).asFrame();
frame.setRsv1(true);
frame.setRsv2(true);
frame.setRsv3(true);
// intentionally bad
send.add(frame);
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging logging = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase4 method testCase4_2_4.
/**
* Send small text, then frame with opcode 14 (reserved), then ping
* @throws Exception on test failure
*/
@Test
public void testCase4_2_4() throws Exception {
ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad"));
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload("hello"));
// intentionally bad
send.add(new BadFrame((byte) 14).setPayload(buf));
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
// echo
expect.add(new TextFrame().setPayload("hello"));
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging logging = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase4 method testCase4_2_5.
/**
* Send small text, then frame with opcode 15 (reserved), then ping
* @throws Exception on test failure
*/
@Test
public void testCase4_2_5() throws Exception {
ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad"));
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload("hello"));
// intentionally bad
send.add(new BadFrame((byte) 15).setPayload(buf));
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
// echo
expect.add(new TextFrame().setPayload("hello"));
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging logging = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase4 method testCase4_1_1.
/**
* Send opcode 3 (reserved)
* @throws Exception on test failure
*/
@Test
public void testCase4_1_1() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
// intentionally bad
send.add(new BadFrame((byte) 3));
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging logging = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase4 method testCase4_2_2.
/**
* Send opcode 12 (reserved)
* @throws Exception on test failure
*/
@Test
public void testCase4_2_2() throws Exception {
ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad"));
List<WebSocketFrame> send = new ArrayList<>();
// intentionally bad
send.add(new BadFrame((byte) 12).setPayload(buf));
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging logging = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
Aggregations