Skip to content

Commit

Permalink
Test that client closes connection on rogue HEADERS frames
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Apr 12, 2023
1 parent 45b9bcc commit 2fc7097
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/h2-tests/tests/client_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,52 @@ async fn extended_connect_request() {
join(srv, h2).await;
}

#[tokio::test]
async fn rogue_server_odd_headers() {
h2_support::trace_init!();
let (io, mut srv) = mock::new();

let srv = async move {
let settings = srv.assert_client_handshake().await;
assert_default_settings!(settings);
srv.send_frame(frames::headers(1)).await;
srv.recv_frame(frames::go_away(0).protocol_error()).await;
};

let h2 = async move {
let (_client, h2) = client::handshake(io).await.unwrap();

let err = h2.await.unwrap_err();
assert!(err.is_go_away());
assert_eq!(err.reason(), Some(Reason::PROTOCOL_ERROR));
};

join(srv, h2).await;
}

#[tokio::test]
async fn rogue_server_even_headers() {
h2_support::trace_init!();
let (io, mut srv) = mock::new();

let srv = async move {
let settings = srv.assert_client_handshake().await;
assert_default_settings!(settings);
srv.send_frame(frames::headers(2)).await;
srv.recv_frame(frames::go_away(0).protocol_error()).await;
};

let h2 = async move {
let (_client, h2) = client::handshake(io).await.unwrap();

let err = h2.await.unwrap_err();
assert!(err.is_go_away());
assert_eq!(err.reason(), Some(Reason::PROTOCOL_ERROR));
};

join(srv, h2).await;
}

const SETTINGS: &[u8] = &[0, 0, 0, 4, 0, 0, 0, 0, 0];
const SETTINGS_ACK: &[u8] = &[0, 0, 0, 4, 1, 0, 0, 0, 0];

Expand Down

0 comments on commit 2fc7097

Please sign in to comment.