mirror of https://github.com/fafhrd91/actix-web
test: add round-trip coverage for QUERY test-server helpers
Exercise each new helper against a live server: - actix_test::TestServer::query() through a web::query() route, request body included - actix_http_test::TestServer::query() over plaintext HTTP/1 - actix_http_test::TestServer::squery() over rustls, asserting the request arrives as QUERY over HTTP/2 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1ff366517d
commit
fcbf37f4bc
|
|
@ -192,6 +192,25 @@ async fn h2_1() -> io::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn h2_squery() -> io::Result<()> {
|
||||
let mut srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h2(|req: Request| {
|
||||
assert_eq!(req.method().as_str(), "QUERY");
|
||||
assert_eq!(req.version(), Version::HTTP_2);
|
||||
ok::<_, Error>(Response::ok())
|
||||
})
|
||||
.rustls_0_23(tls_config_h2())
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.squery("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
srv.stop().await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn h2_tcp_nodelay_override_true() -> io::Result<()> {
|
||||
let mut srv = test_server(move || {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,24 @@ async fn h1_2() {
|
|||
srv.stop().await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn h1_query() {
|
||||
let mut srv = test_server(|| {
|
||||
HttpService::build()
|
||||
.h1(|req: Request| {
|
||||
assert_eq!(req.method().as_str(), "QUERY");
|
||||
ok::<_, Infallible>(Response::ok())
|
||||
})
|
||||
.tcp()
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.query("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
|
||||
srv.stop().await;
|
||||
}
|
||||
|
||||
#[derive(Debug, Display, Error)]
|
||||
#[display("expect failed")]
|
||||
struct ExpectFailed;
|
||||
|
|
|
|||
|
|
@ -291,6 +291,24 @@ async fn test_head_binary() {
|
|||
srv.stop().await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_query_method() {
|
||||
let srv = actix_test::start_with(actix_test::config().h1(), || {
|
||||
App::new().service(
|
||||
web::resource("/")
|
||||
.route(web::query().to(|body: Bytes| async { HttpResponse::Ok().body(body) })),
|
||||
)
|
||||
});
|
||||
|
||||
let mut res = srv.query("/").send_body("query body").await.unwrap();
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
|
||||
let bytes = res.body().await.unwrap();
|
||||
assert_eq!(bytes, Bytes::from_static(b"query body"));
|
||||
|
||||
srv.stop().await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_no_chunking() {
|
||||
let srv = actix_test::start_with(actix_test::config().h1(), || {
|
||||
|
|
|
|||
Loading…
Reference in New Issue