Skip to content

Commit

Permalink
Add a test for rejecting forbidden headers
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottt committed Oct 26, 2023
1 parent 192b047 commit fe05c4d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use test_programs::wasi::http::types::{FieldsType, Headers};

fn main() {
let hdrs = Headers::new(FieldsType::Request, &[]);
assert!(hdrs
.set(&"transfer-encoding".to_owned(), &[b"bad".to_vec()])
.is_err());

assert!(hdrs
.append(&"tRaNsFeR-eNcOdInG".to_owned(), &b"bad".to_vec())
.is_err());
}
6 changes: 6 additions & 0 deletions crates/wasi-http/tests/all/async_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ async fn http_outbound_request_invalid_version() -> Result<()> {
run(HTTP_OUTBOUND_REQUEST_INVALID_VERSION_COMPONENT, &server).await
}

#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn http_outbound_request_invalid_header() -> Result<()> {
let server = Server::http2()?;
run(HTTP_OUTBOUND_REQUEST_INVALID_HEADER_COMPONENT, &server).await
}

#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn http_outbound_request_unknown_method() -> Result<()> {
let server = Server::http1()?;
Expand Down
6 changes: 6 additions & 0 deletions crates/wasi-http/tests/all/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ fn http_outbound_request_invalid_version() -> Result<()> {
run(HTTP_OUTBOUND_REQUEST_INVALID_VERSION_COMPONENT, &server)
}

#[test_log::test]
fn http_outbound_request_invalid_header() -> Result<()> {
let server = Server::http2()?;
run(HTTP_OUTBOUND_REQUEST_INVALID_HEADER_COMPONENT, &server)
}

#[test_log::test]
fn http_outbound_request_unknown_method() -> Result<()> {
let server = Server::http1()?;
Expand Down

0 comments on commit fe05c4d

Please sign in to comment.