aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests/s3
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2023-01-30 10:50:47 +0000
committerAlex <alex@adnab.me>2023-01-30 10:50:47 +0000
commit4d3a5f29e08364c6854eaefbe1e7ca48228dcf32 (patch)
treea307744981862606cf799eb45c4e65abc0f53f9d /src/garage/tests/s3
parentdf30f3df4b2b6cb67c4e37117fb30d6f61cfefc5 (diff)
parent9c354f0a8ff258872aa3a4b7c116e1d66815afd1 (diff)
downloadgarage-4d3a5f29e08364c6854eaefbe1e7ca48228dcf32.tar.gz
garage-4d3a5f29e08364c6854eaefbe1e7ca48228dcf32.zip
Merge pull request 'api_server.rs: Adapted to use query string per Caddy upstream change' (#491) from jpds/garage:fix-caddy-ask-domain-query-string into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/491
Diffstat (limited to 'src/garage/tests/s3')
-rw-r--r--src/garage/tests/s3/website.rs71
1 files changed, 54 insertions, 17 deletions
diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs
index 4e136e1b..f61838e4 100644
--- a/src/garage/tests/s3/website.rs
+++ b/src/garage/tests/s3/website.rs
@@ -56,8 +56,11 @@ async fn test_website() {
let admin_req = || {
Request::builder()
.method("GET")
- .uri(format!("http://127.0.0.1:{}/check", ctx.garage.admin_port))
- .header("domain", BCKT_NAME.to_string())
+ .uri(format!(
+ "http://127.0.0.1:{0}/check?domain={1}",
+ ctx.garage.admin_port,
+ BCKT_NAME.to_string()
+ ))
.body(Body::empty())
.unwrap()
};
@@ -69,7 +72,7 @@ async fn test_website() {
res_body,
json!({
"code": "InvalidRequest",
- "message": "Bad request: Bucket is not authorized for website hosting",
+ "message": "Bad request: Bucket 'my-website' is not authorized for website hosting",
"region": "garage-integ-test",
"path": "/check",
})
@@ -91,8 +94,11 @@ async fn test_website() {
let admin_req = || {
Request::builder()
.method("GET")
- .uri(format!("http://127.0.0.1:{}/check", ctx.garage.admin_port))
- .header("domain", BCKT_NAME.to_string())
+ .uri(format!(
+ "http://127.0.0.1:{0}/check?domain={1}",
+ ctx.garage.admin_port,
+ BCKT_NAME.to_string()
+ ))
.body(Body::empty())
.unwrap()
};
@@ -101,7 +107,7 @@ async fn test_website() {
assert_eq!(admin_resp.status(), StatusCode::OK);
assert_eq!(
to_bytes(admin_resp.body_mut()).await.unwrap().as_ref(),
- b"Bucket authorized for website hosting"
+ format!("Bucket '{BCKT_NAME}' is authorized for website hosting").as_bytes()
);
ctx.garage
@@ -120,8 +126,11 @@ async fn test_website() {
let admin_req = || {
Request::builder()
.method("GET")
- .uri(format!("http://127.0.0.1:{}/check", ctx.garage.admin_port))
- .header("domain", BCKT_NAME.to_string())
+ .uri(format!(
+ "http://127.0.0.1:{0}/check?domain={1}",
+ ctx.garage.admin_port,
+ BCKT_NAME.to_string()
+ ))
.body(Body::empty())
.unwrap()
};
@@ -133,7 +142,7 @@ async fn test_website() {
res_body,
json!({
"code": "InvalidRequest",
- "message": "Bad request: Bucket is not authorized for website hosting",
+ "message": "Bad request: Bucket 'my-website' is not authorized for website hosting",
"region": "garage-integ-test",
"path": "/check",
})
@@ -408,7 +417,7 @@ async fn test_website_check_website_enabled() {
res_body,
json!({
"code": "InvalidRequest",
- "message": "Bad request: No domain header found",
+ "message": "Bad request: No domain query string found",
"region": "garage-integ-test",
"path": "/check",
})
@@ -417,8 +426,34 @@ async fn test_website_check_website_enabled() {
let admin_req = || {
Request::builder()
.method("GET")
- .uri(format!("http://127.0.0.1:{}/check", ctx.garage.admin_port))
- .header("domain", "foobar")
+ .uri(format!(
+ "http://127.0.0.1:{}/check?domain=",
+ ctx.garage.admin_port
+ ))
+ .body(Body::empty())
+ .unwrap()
+ };
+
+ let admin_resp = client.request(admin_req()).await.unwrap();
+ assert_eq!(admin_resp.status(), StatusCode::NOT_FOUND);
+ let res_body = json_body(admin_resp).await;
+ assert_json_eq!(
+ res_body,
+ json!({
+ "code": "NoSuchBucket",
+ "message": "Bucket not found: ",
+ "region": "garage-integ-test",
+ "path": "/check",
+ })
+ );
+
+ let admin_req = || {
+ Request::builder()
+ .method("GET")
+ .uri(format!(
+ "http://127.0.0.1:{}/check?domain=foobar",
+ ctx.garage.admin_port
+ ))
.body(Body::empty())
.unwrap()
};
@@ -439,20 +474,22 @@ async fn test_website_check_website_enabled() {
let admin_req = || {
Request::builder()
.method("GET")
- .uri(format!("http://127.0.0.1:{}/check", ctx.garage.admin_port))
- .header("domain", "☹")
+ .uri(format!(
+ "http://127.0.0.1:{}/check?domain=%E2%98%B9",
+ ctx.garage.admin_port
+ ))
.body(Body::empty())
.unwrap()
};
let admin_resp = client.request(admin_req()).await.unwrap();
- assert_eq!(admin_resp.status(), StatusCode::BAD_REQUEST);
+ assert_eq!(admin_resp.status(), StatusCode::NOT_FOUND);
let res_body = json_body(admin_resp).await;
assert_json_eq!(
res_body,
json!({
- "code": "InvalidRequest",
- "message": "Bad request: Invalid characters found in domain header: failed to convert header to a str",
+ "code": "NoSuchBucket",
+ "message": "Bucket not found: ☹",
"region": "garage-integ-test",
"path": "/check",
})