add test when stream window overflows before conn window

This commit is contained in:
Sean McArthur
2017-09-11 15:05:52 -07:00
parent e2cda1860b
commit 3ec0e85e56
6 changed files with 151 additions and 77 deletions

View File

@@ -225,8 +225,14 @@ fn recv_data_overflows_connection_window() {
.and_then(|resp| {
assert_eq!(resp.status(), StatusCode::OK);
let body = resp.into_parts().1;
// FIXME: body stream should error also
body.concat2().unwrap()
body.concat2().then(|res| {
let err = res.unwrap_err();
assert_eq!(
err.to_string(),
"protocol error: flow-control protocol violated"
);
Ok::<(), ()>(())
})
});
// client should see a flow control error
@@ -244,11 +250,76 @@ fn recv_data_overflows_connection_window() {
}
#[test]
#[ignore]
fn recv_data_overflows_stream_window() {
// this tests for when streams have smaller windows than their connection
let _ = ::env_logger::init();
let (io, srv) = mock::new();
let mock = srv.assert_client_handshake().unwrap()
.ignore_settings()
.recv_frame(
frames::headers(1)
.request("GET", "https://http2.akamai.com/")
.eos()
)
.send_frame(
frames::headers(1)
.response(200)
)
// fill the whole window
.send_frame(frames::data(1, vec![0u8; 16_384]))
// this frame overflows the window!
.send_frame(frames::data(1, &[0; 16][..]).eos())
// expecting goaway for the conn
// TODO: change to a RST_STREAM eventually
.recv_frame(frames::go_away(0).flow_control())
// close the connection
.map(drop);
let h2 = Client::builder()
.initial_window_size(16_384)
.handshake::<_, Bytes>(io)
.unwrap()
.and_then(|mut h2| {
let request = Request::builder()
.method(Method::GET)
.uri("https://http2.akamai.com/")
.body(())
.unwrap();
let req = h2.request(request, true)
.unwrap()
.unwrap()
.and_then(|resp| {
assert_eq!(resp.status(), StatusCode::OK);
let body = resp.into_parts().1;
body.concat2().then(|res| {
let err = res.unwrap_err();
assert_eq!(
err.to_string(),
"protocol error: flow-control protocol violated"
);
Ok::<(), ()>(())
})
});
// client should see a flow control error
let conn = h2.then(|res| {
let err = res.unwrap_err();
assert_eq!(
err.to_string(),
"protocol error: flow-control protocol violated"
);
Ok::<(), ()>(())
});
conn.unwrap().join(req)
});
h2.join(mock).wait().unwrap();
}
#[test]
#[ignore]
fn recv_window_update_causes_overflow() {