diff options
author | Jonathan Davies <jpds@protonmail.com> | 2023-01-29 20:27:15 +0000 |
---|---|---|
committer | Jonathan Davies <jpds@protonmail.com> | 2023-01-29 20:34:41 +0000 |
commit | 9c354f0a8ff258872aa3a4b7c116e1d66815afd1 (patch) | |
tree | a307744981862606cf799eb45c4e65abc0f53f9d | |
parent | 004bb5b4f1b2086914376265425fd46df5059db3 (diff) | |
download | garage-9c354f0a8ff258872aa3a4b7c116e1d66815afd1.tar.gz garage-9c354f0a8ff258872aa3a4b7c116e1d66815afd1.zip |
Improved bucket authorization response strings.
-rw-r--r-- | src/api/admin/api_server.rs | 16 | ||||
-rw-r--r-- | src/garage/tests/s3/website.rs | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/api/admin/api_server.rs b/src/api/admin/api_server.rs index dae42059..58dd38d8 100644 --- a/src/api/admin/api_server.rs +++ b/src/api/admin/api_server.rs @@ -119,12 +119,16 @@ impl AdminApiServer { let bucket_website_config = bucket_state.website_config.get(); match bucket_website_config { - Some(_v) => Ok(Response::builder() - .status(StatusCode::OK) - .body(Body::from("Bucket authorized for website hosting"))?), - None => Err(Error::bad_request( - "Bucket is not authorized for website hosting", - )), + Some(_v) => { + Ok(Response::builder() + .status(StatusCode::OK) + .body(Body::from(format!( + "Bucket '{domain}' is authorized for website hosting" + )))?) + } + None => Err(Error::bad_request(format!( + "Bucket '{domain}' is not authorized for website hosting" + ))), } } diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index 7579058d..f61838e4 100644 --- a/src/garage/tests/s3/website.rs +++ b/src/garage/tests/s3/website.rs @@ -72,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", }) @@ -107,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 @@ -142,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", }) |