aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests
diff options
context:
space:
mode:
authorAlex Auvolat <lx@deuxfleurs.fr>2025-02-19 17:04:10 +0100
committerAlex Auvolat <lx@deuxfleurs.fr>2025-02-19 17:04:10 +0100
commitbf27a3ec9844cf86f2a7ca67b94e7fb8db3873df (patch)
treeb6f1f1552f38de61ca8309942e5e2dd682a6e876 /src/garage/tests
parentf64ec6e542c73a4eaaf1962330c7bfe4d7c47461 (diff)
downloadgarage-bf27a3ec9844cf86f2a7ca67b94e7fb8db3873df.tar.gz
garage-bf27a3ec9844cf86f2a7ca67b94e7fb8db3873df.zip
web: implement x-amz-website-redirect-location
Diffstat (limited to 'src/garage/tests')
-rw-r--r--src/garage/tests/s3/website.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs
index 0cadc388..9a9e29f2 100644
--- a/src/garage/tests/s3/website.rs
+++ b/src/garage/tests/s3/website.rs
@@ -11,6 +11,7 @@ use http::{Request, StatusCode};
use http_body_util::BodyExt;
use http_body_util::Full as FullBody;
use hyper::body::Bytes;
+use hyper::header::LOCATION;
use hyper_util::client::legacy::Client;
use hyper_util::rt::TokioExecutor;
use serde_json::json;
@@ -295,6 +296,33 @@ async fn test_website_s3_api() {
);
}
+ // Test x-amz-website-redirect-location
+ {
+ ctx.client
+ .put_object()
+ .bucket(&bucket)
+ .key("test-redirect.html")
+ .website_redirect_location("https://perdu.com")
+ .send()
+ .await
+ .unwrap();
+
+ let req = Request::builder()
+ .method("GET")
+ .uri(format!(
+ "http://127.0.0.1:{}/test-redirect.html",
+ ctx.garage.web_port
+ ))
+ .header("Host", format!("{}.web.garage", BCKT_NAME))
+ .body(Body::new(Bytes::new()))
+ .unwrap();
+
+ let resp = client.request(req).await.unwrap();
+
+ assert_eq!(resp.status(), StatusCode::MOVED_PERMANENTLY);
+ assert_eq!(resp.headers().get(LOCATION).unwrap(), "https://perdu.com");
+ }
+
// Test CORS with an allowed preflight request
{
let req = Request::builder()