add test for client sending over max concurrent limit (#105)

This commit is contained in:
Sean McArthur
2017-09-19 15:31:35 -07:00
committed by GitHub
parent db8c109817
commit 6ec7f38cd7
4 changed files with 90 additions and 1 deletions

View File

@@ -111,6 +111,64 @@ fn request_stream_id_overflows() {
h2.join(srv).wait().expect("wait");
}
#[test]
fn request_over_max_concurrent_streams_errors() {
let _ = ::env_logger::init();
let (io, srv) = mock::new();
let srv = srv.assert_client_handshake_with_settings(
frames::settings()
// super tiny server
.max_concurrent_streams(1)
)
.unwrap()
.recv_settings()
.recv_frame(
frames::headers(1)
.request("POST", "https://example.com/")
)
.send_frame(frames::headers(1).response(200))
.close();
let h2 = Client::handshake(io)
.expect("handshake")
.and_then(|mut h2| {
let request = Request::builder()
.method(Method::POST)
.uri("https://example.com/")
.body(())
.unwrap();
// first request is allowed
let req = h2.send_request(request, false)
.unwrap()
.unwrap();
// drive the connection some so we can receive the server settings
h2.drive(req)
})
.and_then(|(mut h2, _)| {
let request = Request::builder()
.method(Method::GET)
.uri("https://example.com/")
.body(())
.unwrap();
// second stream is over max concurrent
assert!(h2.poll_ready().expect("poll_ready").is_not_ready());
let err = h2.send_request(request, true).unwrap_err();
assert_eq!(err.to_string(), "user error: rejected");
h2.expect("h2")
});
h2.join(srv).wait().expect("wait");
}
#[test]
#[ignore]
fn request_without_scheme() {}