aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests/s3/website.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-05 19:57:35 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-05 19:57:35 +0100
commit81ccd4586ebdf707dfd37d4802e0cf475e11e004 (patch)
tree66355871fc313bf4cdde0866b335b4408597745d /src/garage/tests/s3/website.rs
parenta22bd319202f05bce4ad13072238c7ba81d518fb (diff)
downloadgarage-81ccd4586ebdf707dfd37d4802e0cf475e11e004.tar.gz
garage-81ccd4586ebdf707dfd37d4802e0cf475e11e004.zip
[dep-upgrade-202402] upgrade to http/hyper 1.x for tests
Diffstat (limited to 'src/garage/tests/s3/website.rs')
-rw-r--r--src/garage/tests/s3/website.rs47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs
index 94acafc7..19f53fcd 100644
--- a/src/garage/tests/s3/website.rs
+++ b/src/garage/tests/s3/website.rs
@@ -8,15 +8,18 @@ use aws_sdk_s3::{
types::{CorsConfiguration, CorsRule, ErrorDocument, IndexDocument, WebsiteConfiguration},
};
use http::{Request, StatusCode};
-use hyper::{
- body::{Body, HttpBody},
- Client,
-};
+use http_body_util::BodyExt;
+use http_body_util::Full as FullBody;
+use hyper::body::Bytes;
+use hyper_util::client::legacy::Client;
+use hyper_util::rt::TokioExecutor;
use serde_json::json;
const BODY: &[u8; 16] = b"<h1>bonjour</h1>";
const BODY_ERR: &[u8; 6] = b"erreur";
+pub type Body = FullBody<Bytes>;
+
#[tokio::test]
async fn test_website() {
const BCKT_NAME: &str = "my-website";
@@ -34,14 +37,14 @@ async fn test_website() {
.await
.unwrap();
- let client = Client::new();
+ let client = Client::builder(TokioExecutor::new()).build_http();
let req = || {
Request::builder()
.method("GET")
.uri(format!("http://127.0.0.1:{}/", ctx.garage.web_port))
.header("Host", format!("{}.web.garage", BCKT_NAME))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};
@@ -49,7 +52,7 @@ async fn test_website() {
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
assert_ne!(
- resp.into_body().collect().await.unwrap().to_bytes(),
+ BodyExt::collect(resp.into_body()).await.unwrap().to_bytes(),
BODY.as_ref()
); /* check that we do not leak body */
@@ -61,7 +64,7 @@ async fn test_website() {
ctx.garage.admin_port,
BCKT_NAME.to_string()
))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};
@@ -103,7 +106,7 @@ async fn test_website() {
"http://127.0.0.1:{0}/check?domain={1}",
ctx.garage.admin_port, bname
))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};
@@ -136,7 +139,7 @@ async fn test_website() {
ctx.garage.admin_port,
BCKT_NAME.to_string()
))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};
@@ -248,7 +251,7 @@ async fn test_website_s3_api() {
);
}
- let client = Client::new();
+ let client = Client::builder(TokioExecutor::new()).build_http();
// Test direct requests with CORS
{
@@ -257,7 +260,7 @@ async fn test_website_s3_api() {
.uri(format!("http://127.0.0.1:{}/site/", ctx.garage.web_port))
.header("Host", format!("{}.web.garage", BCKT_NAME))
.header("Origin", "https://example.com")
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap();
let resp = client.request(req).await.unwrap();
@@ -282,7 +285,7 @@ async fn test_website_s3_api() {
ctx.garage.web_port
))
.header("Host", format!("{}.web.garage", BCKT_NAME))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap();
let resp = client.request(req).await.unwrap();
@@ -302,7 +305,7 @@ async fn test_website_s3_api() {
.header("Host", format!("{}.web.garage", BCKT_NAME))
.header("Origin", "https://example.com")
.header("Access-Control-Request-Method", "PUT")
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap();
let resp = client.request(req).await.unwrap();
@@ -326,7 +329,7 @@ async fn test_website_s3_api() {
.header("Host", format!("{}.web.garage", BCKT_NAME))
.header("Origin", "https://example.com")
.header("Access-Control-Request-Method", "DELETE")
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap();
let resp = client.request(req).await.unwrap();
@@ -367,7 +370,7 @@ async fn test_website_s3_api() {
.header("Host", format!("{}.web.garage", BCKT_NAME))
.header("Origin", "https://example.com")
.header("Access-Control-Request-Method", "PUT")
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap();
let resp = client.request(req).await.unwrap();
@@ -393,7 +396,7 @@ async fn test_website_s3_api() {
.method("GET")
.uri(format!("http://127.0.0.1:{}/site/", ctx.garage.web_port))
.header("Host", format!("{}.web.garage", BCKT_NAME))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap();
let resp = client.request(req).await.unwrap();
@@ -409,13 +412,13 @@ async fn test_website_s3_api() {
async fn test_website_check_domain() {
let ctx = common::context();
- let client = Client::new();
+ let client = Client::builder(TokioExecutor::new()).build_http();
let admin_req = || {
Request::builder()
.method("GET")
.uri(format!("http://127.0.0.1:{}/check", ctx.garage.admin_port))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};
@@ -439,7 +442,7 @@ async fn test_website_check_domain() {
"http://127.0.0.1:{}/check?domain=",
ctx.garage.admin_port
))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};
@@ -463,7 +466,7 @@ async fn test_website_check_domain() {
"http://127.0.0.1:{}/check?domain=foobar",
ctx.garage.admin_port
))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};
@@ -487,7 +490,7 @@ async fn test_website_check_domain() {
"http://127.0.0.1:{}/check?domain=%E2%98%B9",
ctx.garage.admin_port
))
- .body(Body::empty())
+ .body(Body::new(Bytes::new()))
.unwrap()
};