From 4297233d3e4aea1760d81de747ad3468553be41b Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 5 May 2023 21:17:19 +0100 Subject: garage/Cargo.toml: Updated aws-sdk-s3 to 0.28, added aws-config. --- src/garage/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/garage') diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index 52d0ea79..a41faaad 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -61,7 +61,8 @@ opentelemetry-otlp = { version = "0.10", optional = true } prometheus = { version = "0.13", optional = true } [dev-dependencies] -aws-sdk-s3 = "0.19" +aws-config = "0.55.2" +aws-sdk-s3 = "0.28" chrono = "0.4" http = "0.2" hmac = "0.12" -- cgit v1.2.3 From 7f8bf2d801c55e15b5056ae08cd443325f7989b8 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 5 May 2023 21:18:29 +0100 Subject: src/garage/tests: Updated types for aws-sdk-s3 bump. --- src/garage/tests/bucket.rs | 4 ++-- src/garage/tests/common/client.rs | 11 ++++++----- src/garage/tests/common/mod.rs | 5 +++-- src/garage/tests/s3/multipart.rs | 4 ++-- src/garage/tests/s3/objects.rs | 4 ++-- src/garage/tests/s3/simple.rs | 2 +- src/garage/tests/s3/website.rs | 4 ++-- 7 files changed, 18 insertions(+), 16 deletions(-) (limited to 'src/garage') diff --git a/src/garage/tests/bucket.rs b/src/garage/tests/bucket.rs index 0dec3cfa..83487bf8 100644 --- a/src/garage/tests/bucket.rs +++ b/src/garage/tests/bucket.rs @@ -1,7 +1,7 @@ use crate::common; use crate::common::ext::CommandExt; -use aws_sdk_s3::model::BucketLocationConstraint; -use aws_sdk_s3::output::DeleteBucketOutput; +use aws_sdk_s3::operation::delete_bucket::DeleteBucketOutput; +use aws_sdk_s3::types::BucketLocationConstraint; #[tokio::test] async fn test_bucket_all() { diff --git a/src/garage/tests/common/client.rs b/src/garage/tests/common/client.rs index e9d4849a..ef4daa5d 100644 --- a/src/garage/tests/common/client.rs +++ b/src/garage/tests/common/client.rs @@ -1,15 +1,16 @@ -use aws_sdk_s3::{Client, Config, Credentials, Endpoint}; +use aws_sdk_s3::config::Credentials; +use aws_sdk_s3::{Client, Config}; -use super::garage::{Instance, Key}; +use super::garage::Key; +use crate::common::garage::DEFAULT_PORT; -pub fn build_client(instance: &Instance, key: &Key) -> Client { +pub fn build_client(key: &Key) -> Client { let credentials = Credentials::new(&key.id, &key.secret, None, None, "garage-integ-test"); - let endpoint = Endpoint::immutable(instance.s3_uri()); let config = Config::builder() + .endpoint_url(format!("http://127.0.0.1:{}", DEFAULT_PORT)) .region(super::REGION) .credentials_provider(credentials) - .endpoint_resolver(endpoint) .build(); Client::from_conf(config) diff --git a/src/garage/tests/common/mod.rs b/src/garage/tests/common/mod.rs index 0b8c6755..54efd1ea 100644 --- a/src/garage/tests/common/mod.rs +++ b/src/garage/tests/common/mod.rs @@ -1,4 +1,5 @@ -use aws_sdk_s3::{Client, Region}; +use aws_sdk_s3::config::Region; +use aws_sdk_s3::Client; use ext::*; use k2v_client::K2vClient; @@ -32,7 +33,7 @@ impl Context { fn new() -> Self { let garage = garage::instance(); let key = garage.key(None); - let client = client::build_client(garage, &key); + let client = client::build_client(&key); let custom_request = CustomRequester::new_s3(garage, &key); let k2v_request = CustomRequester::new_k2v(garage, &key); diff --git a/src/garage/tests/s3/multipart.rs b/src/garage/tests/s3/multipart.rs index 895a2993..aeff94b4 100644 --- a/src/garage/tests/s3/multipart.rs +++ b/src/garage/tests/s3/multipart.rs @@ -1,6 +1,6 @@ use crate::common; -use aws_sdk_s3::model::{CompletedMultipartUpload, CompletedPart}; -use aws_sdk_s3::types::ByteStream; +use aws_sdk_s3::primitives::ByteStream; +use aws_sdk_s3::types::{CompletedMultipartUpload, CompletedPart}; const SZ_5MB: usize = 5 * 1024 * 1024; const SZ_10MB: usize = 10 * 1024 * 1024; diff --git a/src/garage/tests/s3/objects.rs b/src/garage/tests/s3/objects.rs index 65f9e867..27697d45 100644 --- a/src/garage/tests/s3/objects.rs +++ b/src/garage/tests/s3/objects.rs @@ -1,6 +1,6 @@ use crate::common; -use aws_sdk_s3::model::{Delete, ObjectIdentifier}; -use aws_sdk_s3::types::ByteStream; +use aws_sdk_s3::primitives::ByteStream; +use aws_sdk_s3::types::{Delete, ObjectIdentifier}; const STD_KEY: &str = "hello world"; const CTRL_KEY: &str = "\x00\x01\x02\x00"; diff --git a/src/garage/tests/s3/simple.rs b/src/garage/tests/s3/simple.rs index f54ae9ac..41ec44c6 100644 --- a/src/garage/tests/s3/simple.rs +++ b/src/garage/tests/s3/simple.rs @@ -2,7 +2,7 @@ use crate::common; #[tokio::test] async fn test_simple() { - use aws_sdk_s3::types::ByteStream; + use aws_sdk_s3::primitives::ByteStream; let ctx = common::context(); let bucket = ctx.create_bucket("test-simple"); diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index f61838e4..ab9b12b9 100644 --- a/src/garage/tests/s3/website.rs +++ b/src/garage/tests/s3/website.rs @@ -4,8 +4,8 @@ use crate::k2v::json_body; use assert_json_diff::assert_json_eq; use aws_sdk_s3::{ - model::{CorsConfiguration, CorsRule, ErrorDocument, IndexDocument, WebsiteConfiguration}, - types::ByteStream, + primitives::ByteStream, + types::{CorsConfiguration, CorsRule, ErrorDocument, IndexDocument, WebsiteConfiguration}, }; use http::{Request, StatusCode}; use hyper::{ -- cgit v1.2.3 From a6da7e588f438b6aa491554eb426242730015d63 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Sun, 25 Jun 2023 21:45:53 +0100 Subject: tests/bucket.rs: Adjusted as previously used function is now private. --- src/garage/tests/bucket.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/garage') diff --git a/src/garage/tests/bucket.rs b/src/garage/tests/bucket.rs index 83487bf8..2dda7e6f 100644 --- a/src/garage/tests/bucket.rs +++ b/src/garage/tests/bucket.rs @@ -1,7 +1,6 @@ use crate::common; use crate::common::ext::CommandExt; use aws_sdk_s3::operation::delete_bucket::DeleteBucketOutput; -use aws_sdk_s3::types::BucketLocationConstraint; #[tokio::test] async fn test_bucket_all() { @@ -63,10 +62,7 @@ async fn test_bucket_all() { .await .unwrap(); - match r.location_constraint.unwrap() { - BucketLocationConstraint::Unknown(v) if v.as_str() == "garage-integ-test" => (), - _ => unreachable!("wrong region"), - } + assert_eq!(r.location_constraint.unwrap().as_str(), "garage-integ-test"); } { // (Stub) check GetVersioning -- cgit v1.2.3 From b1ca1784a12f2eed4cb9d85cdf8c3c1b8a0147da Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 14 Jul 2023 14:25:33 +0300 Subject: src/garage/cli: fix typo --- src/garage/cli/structs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/garage') diff --git a/src/garage/cli/structs.rs b/src/garage/cli/structs.rs index 01ae92da..6e585e53 100644 --- a/src/garage/cli/structs.rs +++ b/src/garage/cli/structs.rs @@ -216,7 +216,7 @@ pub struct WebsiteOpt { #[structopt(short = "i", long = "index-document", default_value = "index.html")] pub index_document: String, - /// Error document: the optionnal document returned when an error occurs + /// Error document: the optional document returned when an error occurs #[structopt(short = "e", long = "error-document")] pub error_document: Option, } -- cgit v1.2.3 From 24e533f2623ac6ebbdac92efa9c08b6092c59daf Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 8 Aug 2023 11:05:42 +0200 Subject: support {s3,web}.root_domains in /check endpoint --- src/garage/tests/s3/website.rs | 47 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'src/garage') diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index ab9b12b9..7c2b0deb 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 'my-website' is not authorized for website hosting", + "message": "Bad request: Domain 'my-website' is not managed by Garage", "region": "garage-integ-test", "path": "/check", }) @@ -91,24 +91,29 @@ async fn test_website() { BODY.as_ref() ); - let admin_req = || { - Request::builder() - .method("GET") - .uri(format!( - "http://127.0.0.1:{0}/check?domain={1}", - ctx.garage.admin_port, - BCKT_NAME.to_string() - )) - .body(Body::empty()) - .unwrap() - }; - - let mut admin_resp = client.request(admin_req()).await.unwrap(); - assert_eq!(admin_resp.status(), StatusCode::OK); - assert_eq!( - to_bytes(admin_resp.body_mut()).await.unwrap().as_ref(), - format!("Bucket '{BCKT_NAME}' is authorized for website hosting").as_bytes() - ); + for bname in [ + BCKT_NAME.to_string(), + format!("{BCKT_NAME}.web.garage"), + format!("{BCKT_NAME}.s3.garage"), + ] { + let admin_req = || { + Request::builder() + .method("GET") + .uri(format!( + "http://127.0.0.1:{0}/check?domain={1}", + ctx.garage.admin_port, bname + )) + .body(Body::empty()) + .unwrap() + }; + + let mut admin_resp = client.request(admin_req()).await.unwrap(); + assert_eq!(admin_resp.status(), StatusCode::OK); + assert_eq!( + to_bytes(admin_resp.body_mut()).await.unwrap().as_ref(), + format!("Domain '{bname}' is managed by Garage").as_bytes() + ); + } ctx.garage .command() @@ -142,7 +147,7 @@ async fn test_website() { res_body, json!({ "code": "InvalidRequest", - "message": "Bad request: Bucket 'my-website' is not authorized for website hosting", + "message": "Bad request: Domain 'my-website' is not managed by Garage", "region": "garage-integ-test", "path": "/check", }) @@ -397,7 +402,7 @@ async fn test_website_s3_api() { } #[tokio::test] -async fn test_website_check_website_enabled() { +async fn test_website_check_domain() { let ctx = common::context(); let client = Client::new(); -- cgit v1.2.3 From 5185701aa82b34dde63c47b76a1e8f1a1d033019 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Tue, 1 Aug 2023 14:20:39 +0100 Subject: cargo: Updated: * addr2line v0.19.0 -> v0.20.0 * async-compression v0.4.0 -> v0.4.1 * clap v4.3.8 -> v4.3.19 * hyper v0.14.26 -> v0.14.27 * ipnet v2.7.2 -> v2.8.0 * rmp v0.8.11 -> v0.8.12 * serde v1.0.164 -> v1.0.188 * tokio v1.29.0 -> v1.31.0 * zstd v0.12.3+zstd.1.5.2 -> v0.12.4 * Others in `cargo update` --- src/garage/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/garage') diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index a41faaad..a6187729 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -33,7 +33,7 @@ garage_web.workspace = true backtrace = "0.3" bytes = "1.0" -bytesize = "1.1" +bytesize = "1.2" timeago = { version = "0.4", default-features = false } parse_duration = "2.1" hex = "0.4" -- cgit v1.2.3 From e66c78d6eaeb01b64911013b3a36d798c561acb8 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 28 Aug 2023 12:32:57 +0200 Subject: integration test: move json_body to root of crate --- src/garage/tests/common/mod.rs | 5 +++++ src/garage/tests/k2v/batch.rs | 2 +- src/garage/tests/k2v/item.rs | 2 +- src/garage/tests/k2v/mod.rs | 13 ------------- src/garage/tests/k2v/poll.rs | 2 +- src/garage/tests/lib.rs | 13 +++++++++++++ src/garage/tests/s3/website.rs | 2 +- 7 files changed, 22 insertions(+), 17 deletions(-) (limited to 'src/garage') diff --git a/src/garage/tests/common/mod.rs b/src/garage/tests/common/mod.rs index 54efd1ea..1273bad1 100644 --- a/src/garage/tests/common/mod.rs +++ b/src/garage/tests/common/mod.rs @@ -1,6 +1,7 @@ use aws_sdk_s3::config::Region; use aws_sdk_s3::Client; use ext::*; +#[cfg(feature = "k2v")] use k2v_client::K2vClient; #[macro_use] @@ -21,6 +22,7 @@ pub struct Context { pub key: garage::Key, pub client: Client, pub custom_request: CustomRequester, + #[cfg(feature = "k2v")] pub k2v: K2VContext, } @@ -35,6 +37,7 @@ impl Context { let key = garage.key(None); let client = client::build_client(&key); let custom_request = CustomRequester::new_s3(garage, &key); + #[cfg(feature = "k2v")] let k2v_request = CustomRequester::new_k2v(garage, &key); Context { @@ -42,6 +45,7 @@ impl Context { client, key, custom_request, + #[cfg(feature = "k2v")] k2v: K2VContext { request: k2v_request, }, @@ -72,6 +76,7 @@ impl Context { } /// Build a K2vClient for a given bucket + #[cfg(feature = "k2v")] pub fn k2v_client(&self, bucket: &str) -> K2vClient { let config = k2v_client::K2vClientConfig { region: REGION.to_string(), diff --git a/src/garage/tests/k2v/batch.rs b/src/garage/tests/k2v/batch.rs index 595d0ba8..71de91bf 100644 --- a/src/garage/tests/k2v/batch.rs +++ b/src/garage/tests/k2v/batch.rs @@ -6,7 +6,7 @@ use assert_json_diff::assert_json_eq; use base64::prelude::*; use serde_json::json; -use super::json_body; +use crate::json_body; use hyper::{Method, StatusCode}; #[tokio::test] diff --git a/src/garage/tests/k2v/item.rs b/src/garage/tests/k2v/item.rs index 588836c7..25d9cce4 100644 --- a/src/garage/tests/k2v/item.rs +++ b/src/garage/tests/k2v/item.rs @@ -6,7 +6,7 @@ use assert_json_diff::assert_json_eq; use base64::prelude::*; use serde_json::json; -use super::json_body; +use crate::json_body; use hyper::{Method, StatusCode}; #[tokio::test] diff --git a/src/garage/tests/k2v/mod.rs b/src/garage/tests/k2v/mod.rs index a009460e..241e3dc2 100644 --- a/src/garage/tests/k2v/mod.rs +++ b/src/garage/tests/k2v/mod.rs @@ -3,16 +3,3 @@ pub mod errorcodes; pub mod item; pub mod poll; pub mod simple; - -use hyper::{Body, Response}; - -pub async fn json_body(res: Response) -> serde_json::Value { - let res_body: serde_json::Value = serde_json::from_slice( - &hyper::body::to_bytes(res.into_body()) - .await - .unwrap() - .to_vec()[..], - ) - .unwrap(); - res_body -} diff --git a/src/garage/tests/k2v/poll.rs b/src/garage/tests/k2v/poll.rs index dd44aed9..452317c2 100644 --- a/src/garage/tests/k2v/poll.rs +++ b/src/garage/tests/k2v/poll.rs @@ -5,8 +5,8 @@ use std::time::Duration; use assert_json_diff::assert_json_eq; use serde_json::json; -use super::json_body; use crate::common; +use crate::json_body; #[tokio::test] async fn test_poll_item() { diff --git a/src/garage/tests/lib.rs b/src/garage/tests/lib.rs index e450baac..ab92bc0a 100644 --- a/src/garage/tests/lib.rs +++ b/src/garage/tests/lib.rs @@ -10,3 +10,16 @@ mod s3; mod k2v; #[cfg(feature = "k2v")] mod k2v_client; + +use hyper::{Body, Response}; + +pub async fn json_body(res: Response) -> serde_json::Value { + let res_body: serde_json::Value = serde_json::from_slice( + &hyper::body::to_bytes(res.into_body()) + .await + .unwrap() + .to_vec()[..], + ) + .unwrap(); + res_body +} diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index 7c2b0deb..ac724430 100644 --- a/src/garage/tests/s3/website.rs +++ b/src/garage/tests/s3/website.rs @@ -1,6 +1,6 @@ use crate::common; use crate::common::ext::*; -use crate::k2v::json_body; +use crate::json_body; use assert_json_diff::assert_json_eq; use aws_sdk_s3::{ -- cgit v1.2.3 From 769b6fe054b97c11ed187871a3e67663869f9415 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 28 Aug 2023 12:40:28 +0200 Subject: fix test_website_check_domain --- src/garage/tests/s3/website.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/garage') diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index ac724430..eeafb5fa 100644 --- a/src/garage/tests/s3/website.rs +++ b/src/garage/tests/s3/website.rs @@ -440,13 +440,13 @@ async fn test_website_check_domain() { }; let admin_resp = client.request(admin_req()).await.unwrap(); - assert_eq!(admin_resp.status(), StatusCode::NOT_FOUND); + assert_eq!(admin_resp.status(), StatusCode::BAD_REQUEST); let res_body = json_body(admin_resp).await; assert_json_eq!( res_body, json!({ - "code": "NoSuchBucket", - "message": "Bucket not found: ", + "code": "InvalidRequest", + "message": "Bad request: Domain '' is not managed by Garage", "region": "garage-integ-test", "path": "/check", }) @@ -464,13 +464,13 @@ async fn test_website_check_domain() { }; let admin_resp = client.request(admin_req()).await.unwrap(); - assert_eq!(admin_resp.status(), StatusCode::NOT_FOUND); + assert_eq!(admin_resp.status(), StatusCode::BAD_REQUEST); let res_body = json_body(admin_resp).await; assert_json_eq!( res_body, json!({ - "code": "NoSuchBucket", - "message": "Bucket not found: foobar", + "code": "InvalidRequest", + "message": "Bad request: Domain 'foobar' is not managed by Garage", "region": "garage-integ-test", "path": "/check", }) @@ -488,13 +488,13 @@ async fn test_website_check_domain() { }; let admin_resp = client.request(admin_req()).await.unwrap(); - assert_eq!(admin_resp.status(), StatusCode::NOT_FOUND); + assert_eq!(admin_resp.status(), StatusCode::BAD_REQUEST); let res_body = json_body(admin_resp).await; assert_json_eq!( res_body, json!({ - "code": "NoSuchBucket", - "message": "Bucket not found: ☹", + "code": "InvalidRequest", + "message": "Bad request: Domain '☹' is not managed by Garage", "region": "garage-integ-test", "path": "/check", }) -- cgit v1.2.3 From cece1be1bb3aa779b0e01af475572d734c5e51f7 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 28 Aug 2023 13:17:26 +0200 Subject: bump version to 0.8.3 --- src/garage/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/garage') diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index a6187729..4d0eca46 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage" -version = "0.8.2" +version = "0.8.3" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" -- cgit v1.2.3