use of com.webpieces.http2.api.dto.lowlevel.GoAwayFrame in project webpieces by deanhiller.
the class TestS5x1StreamStates method testSection5_1BadFrameReceivedInReservedRemoteState.
/**
* reserved local
*
* A PRIORITY or WINDOW_UPDATE frame MAY be received in this state. Receiving any
* type of frame other than RST_STREAM, PRIORITY, or WINDOW_UPDATE on a stream
* in this state MUST be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
*/
@Test
public void testSection5_1BadFrameReceivedInReservedRemoteState() {
MockStreamWriter mockWriter = new MockStreamWriter();
XFuture<StreamWriter> futA = XFuture.completedFuture(mockWriter);
MockStreamRef mockStream = new MockStreamRef(futA);
mockListener.addMockStreamToReturn(mockStream);
Http2Request request = Http2Requests.createRequest(1, true);
mockChannel.send(request);
PassedIn in = mockListener.getSingleRequest();
ResponseStream stream = in.stream;
Http2Push push = Http2Requests.createPush(request.getStreamId());
stream.openPushStream().process(push);
Http2Msg pushMsg = mockChannel.getFrameAndClear();
Assert.assertEquals(push, pushMsg);
// send bad frame in this state
DataFrame data = Http2Requests.createData1(push.getPromisedStreamId(), false);
mockChannel.send(data);
Assert.assertTrue(mockStream.isCancelled());
// remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(Http2ErrorCode.PROTOCOL_ERROR, goAway.getKnownErrorCode());
DataWrapper debugData = goAway.getDebugData();
String msg = debugData.createStringFromUtf8(0, debugData.getReadableSize());
Assert.assertEquals("ConnectionException: HttpSocket[Http2ChannelCache1]:stream2:(BAD_FRAME_RECEIVED_FOR_THIS_STATE) " + "No transition defined on statemachine for event=RECV_DATA when in state=Reserved(local)", msg);
Assert.assertTrue(mockChannel.isClosed());
}
use of com.webpieces.http2.api.dto.lowlevel.GoAwayFrame in project webpieces by deanhiller.
the class TestS5x1StreamStates method testSection5_1_1BadEvenStreamId.
/**
* The identifier of a newly established stream MUST be numerically
* greater than all streams that the initiating endpoint has opened
* or reserved. This governs streams that are opened using a HEADERS
* frame and streams that are reserved using PUSH_PROMISE. An endpoint
* that receives an unexpected stream identifier MUST respond with
* a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
*/
@Test
public void testSection5_1_1BadEvenStreamId() {
Http2Request request = Http2Requests.createRequest(2, true);
mockChannel.send(request);
// no request comes in
Assert.assertEquals(0, mockListener.getNumRequestsThatCameIn());
Assert.assertTrue(mockListener.isClosed());
// remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(Http2ErrorCode.PROTOCOL_ERROR, goAway.getKnownErrorCode());
DataWrapper debugData = goAway.getDebugData();
String msg = debugData.createStringFromUtf8(0, debugData.getReadableSize());
Assert.assertTrue(msg.contains("Bad stream id. Even stream ids not allowed in requests to a server request="));
Assert.assertTrue(mockChannel.isClosed());
}
use of com.webpieces.http2.api.dto.lowlevel.GoAwayFrame in project webpieces by deanhiller.
the class TestS6x5SettingsFrameErrors method testSection6_5SettingsStreamIdNonZeroValue.
@Test
public void testSection6_5SettingsStreamIdNonZeroValue() {
// server's settings frame is finally coming in as well with maxConcurrent=1
String badStreamIdSettings = // length
"00 00 0C" + // type
"04" + // flags
"00" + // R + streamid
"00 00 00 01" + // setting 1 (enable push)
"00 02 00 00 00 01" + // setting 2 (max streams)
"00 03 00 00 01 00";
mockChannel.sendHexBack(badStreamIdSettings);
// remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(Http2ErrorCode.PROTOCOL_ERROR, goAway.getKnownErrorCode());
Assert.assertTrue(mockChannel.isClosed());
}
use of com.webpieces.http2.api.dto.lowlevel.GoAwayFrame in project webpieces by deanhiller.
the class TestS6x5SettingsFrameErrors method testSection6_5_2MaxFrameSizeOutsideAllowedRange.
@Test
public void testSection6_5_2MaxFrameSizeOutsideAllowedRange() {
// server's settings frame is finally coming in as well with maxConcurrent=1
String badStreamIdSettings = // length
"00 00 0C" + // type
"04" + // flags
"00" + // R + streamid
"00 00 00 00" + // setting 1 (enable push)
"00 02 00 00 00 01" + // setting 2 (initial window size)
"00 05 00 00 00 00";
mockChannel.sendHexBack(badStreamIdSettings);
// remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(Http2ErrorCode.PROTOCOL_ERROR, goAway.getKnownErrorCode());
Assert.assertTrue(mockChannel.isClosed());
}
use of com.webpieces.http2.api.dto.lowlevel.GoAwayFrame in project webpieces by deanhiller.
the class TestS6x5SettingsFrameErrors method testSection6_5AckNonEmptyPayload.
@Test
public void testSection6_5AckNonEmptyPayload() {
String badAckFrame = // length
"00 00 01" + // type
"04" + // flags (ack)
"01" + // R + streamid
"00 00 00 00" + // payload
"00";
// ack client frame
mockChannel.sendHexBack(badAckFrame);
// remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
DataWrapper debugData = goAway.getDebugData();
String msg = debugData.createStringFromUtf8(0, debugData.getReadableSize());
Assert.assertEquals("ConnectionException: stream0:(FRAME_SIZE_INCORRECT) size of payload of a settings frame ack must be 0 but was=1", msg);
Assert.assertTrue(mockChannel.isClosed());
}
Aggregations