aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-05 14:02:45 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-05 14:02:45 +0100
commit6e4229e29c1ee3e0b7f3511f80b6108e3beb1efd (patch)
treea35c1c632a8cac2694eb8b614a5db3085d3a5e80 /src
parentc0a7552015ff26ba542970449f1bc3df4ee9b173 (diff)
downloadgarage-6e4229e29c1ee3e0b7f3511f80b6108e3beb1efd.tar.gz
garage-6e4229e29c1ee3e0b7f3511f80b6108e3beb1efd.zip
[dep-upgrade-202402] update aws-sdk dependencies
Diffstat (limited to 'src')
-rw-r--r--src/garage/tests/common/client.rs2
-rw-r--r--src/garage/tests/s3/multipart.rs30
-rw-r--r--src/garage/tests/s3/objects.rs24
-rw-r--r--src/garage/tests/s3/streaming_signature.rs16
-rw-r--r--src/garage/tests/s3/website.rs29
-rw-r--r--src/k2v-client/Cargo.toml1
-rw-r--r--src/k2v-client/error.rs2
-rw-r--r--src/k2v-client/lib.rs38
8 files changed, 88 insertions, 54 deletions
diff --git a/src/garage/tests/common/client.rs b/src/garage/tests/common/client.rs
index ef4daa5d..ffa4cae8 100644
--- a/src/garage/tests/common/client.rs
+++ b/src/garage/tests/common/client.rs
@@ -1,3 +1,4 @@
+use aws_sdk_s3::config::BehaviorVersion;
use aws_sdk_s3::config::Credentials;
use aws_sdk_s3::{Client, Config};
@@ -11,6 +12,7 @@ pub fn build_client(key: &Key) -> Client {
.endpoint_url(format!("http://127.0.0.1:{}", DEFAULT_PORT))
.region(super::REGION)
.credentials_provider(credentials)
+ .behavior_version(BehaviorVersion::v2023_11_09())
.build();
Client::from_conf(config)
diff --git a/src/garage/tests/s3/multipart.rs b/src/garage/tests/s3/multipart.rs
index 09ae5e5b..51c9df74 100644
--- a/src/garage/tests/s3/multipart.rs
+++ b/src/garage/tests/s3/multipart.rs
@@ -154,7 +154,7 @@ async fn test_multipart_upload() {
.await
.unwrap();
- assert_eq!(r.content_length, (SZ_5MB * 3) as i64);
+ assert_eq!(r.content_length.unwrap(), (SZ_5MB * 3) as i64);
}
{
@@ -183,7 +183,7 @@ async fn test_multipart_upload() {
.unwrap();
eprintln!("get_object with part_number = {}", part_number);
- assert_eq!(o.content_length, SZ_5MB as i64);
+ assert_eq!(o.content_length.unwrap(), SZ_5MB as i64);
assert_bytes_eq!(o.body, data);
}
}
@@ -249,14 +249,14 @@ async fn test_uploadlistpart() {
let ps = r.parts.unwrap();
assert_eq!(ps.len(), 1);
- assert_eq!(ps[0].part_number, 2);
+ assert_eq!(ps[0].part_number.unwrap(), 2);
let fp = &ps[0];
assert!(fp.last_modified.is_some());
assert_eq!(
fp.e_tag.as_ref().unwrap(),
"\"3366bb9dcf710d6801b5926467d02e19\""
);
- assert_eq!(fp.size, SZ_5MB as i64);
+ assert_eq!(fp.size.unwrap(), SZ_5MB as i64);
}
let p2 = ctx
@@ -286,23 +286,23 @@ async fn test_uploadlistpart() {
let ps = r.parts.unwrap();
assert_eq!(ps.len(), 2);
- assert_eq!(ps[0].part_number, 1);
+ assert_eq!(ps[0].part_number.unwrap(), 1);
let fp = &ps[0];
assert!(fp.last_modified.is_some());
assert_eq!(
fp.e_tag.as_ref().unwrap(),
"\"3c484266f9315485694556e6c693bfa2\""
);
- assert_eq!(fp.size, SZ_5MB as i64);
+ assert_eq!(fp.size.unwrap(), SZ_5MB as i64);
- assert_eq!(ps[1].part_number, 2);
+ assert_eq!(ps[1].part_number.unwrap(), 2);
let sp = &ps[1];
assert!(sp.last_modified.is_some());
assert_eq!(
sp.e_tag.as_ref().unwrap(),
"\"3366bb9dcf710d6801b5926467d02e19\""
);
- assert_eq!(sp.size, SZ_5MB as i64);
+ assert_eq!(sp.size.unwrap(), SZ_5MB as i64);
}
{
@@ -320,14 +320,14 @@ async fn test_uploadlistpart() {
assert!(r.part_number_marker.is_none());
assert_eq!(r.next_part_number_marker.as_deref(), Some("1"));
- assert_eq!(r.max_parts, 1_i32);
- assert!(r.is_truncated);
+ assert_eq!(r.max_parts.unwrap(), 1_i32);
+ assert!(r.is_truncated.unwrap());
assert_eq!(r.key.unwrap(), "a");
assert_eq!(r.upload_id.unwrap().as_str(), uid.as_str());
let parts = r.parts.unwrap();
assert_eq!(parts.len(), 1);
let fp = &parts[0];
- assert_eq!(fp.part_number, 1);
+ assert_eq!(fp.part_number.unwrap(), 1);
assert_eq!(
fp.e_tag.as_ref().unwrap(),
"\"3c484266f9315485694556e6c693bfa2\""
@@ -349,19 +349,19 @@ async fn test_uploadlistpart() {
r2.part_number_marker.as_ref().unwrap(),
r.next_part_number_marker.as_ref().unwrap()
);
- assert_eq!(r2.max_parts, 1_i32);
+ assert_eq!(r2.max_parts.unwrap(), 1_i32);
assert_eq!(r2.key.unwrap(), "a");
assert_eq!(r2.upload_id.unwrap().as_str(), uid.as_str());
let parts = r2.parts.unwrap();
assert_eq!(parts.len(), 1);
let fp = &parts[0];
- assert_eq!(fp.part_number, 2);
+ assert_eq!(fp.part_number.unwrap(), 2);
assert_eq!(
fp.e_tag.as_ref().unwrap(),
"\"3366bb9dcf710d6801b5926467d02e19\""
);
//assert!(r2.is_truncated); // WHY? (this was the test before)
- assert!(!r2.is_truncated);
+ assert!(!r2.is_truncated.unwrap());
}
let cmp = CompletedMultipartUpload::builder()
@@ -411,7 +411,7 @@ async fn test_uploadlistpart() {
.await
.unwrap();
- assert_eq!(r.content_length, (SZ_5MB * 2) as i64);
+ assert_eq!(r.content_length.unwrap(), (SZ_5MB * 2) as i64);
}
}
diff --git a/src/garage/tests/s3/objects.rs b/src/garage/tests/s3/objects.rs
index 27697d45..ca35b435 100644
--- a/src/garage/tests/s3/objects.rs
+++ b/src/garage/tests/s3/objects.rs
@@ -50,9 +50,9 @@ async fn test_putobject() {
// assert_eq!(o.version_id.unwrap(), _version);
assert_eq!(o.content_type.unwrap(), content_type);
assert!(o.last_modified.is_some());
- assert_eq!(o.content_length, 0);
- assert_eq!(o.parts_count, 0);
- assert_eq!(o.tag_count, 0);
+ assert_eq!(o.content_length.unwrap(), 0);
+ assert_eq!(o.parts_count, None);
+ assert_eq!(o.tag_count, None);
}
{
@@ -86,9 +86,9 @@ async fn test_putobject() {
assert_bytes_eq!(o.body, b"hi");
assert_eq!(o.e_tag.unwrap(), etag);
assert!(o.last_modified.is_some());
- assert_eq!(o.content_length, 2);
- assert_eq!(o.parts_count, 0);
- assert_eq!(o.tag_count, 0);
+ assert_eq!(o.content_length.unwrap(), 2);
+ assert_eq!(o.parts_count, None);
+ assert_eq!(o.tag_count, None);
}
{
@@ -119,9 +119,9 @@ async fn test_putobject() {
assert_bytes_eq!(o.body, b"");
assert_eq!(o.e_tag.unwrap(), etag);
assert!(o.last_modified.is_some());
- assert_eq!(o.content_length, 0);
- assert_eq!(o.parts_count, 0);
- assert_eq!(o.tag_count, 0);
+ assert_eq!(o.content_length.unwrap(), 0);
+ assert_eq!(o.parts_count, None);
+ assert_eq!(o.tag_count, None);
}
}
@@ -205,7 +205,7 @@ async fn test_deleteobject() {
.await
.unwrap();
if i > 0 {
- to_del = to_del.objects(ObjectIdentifier::builder().key(k).build());
+ to_del = to_del.objects(ObjectIdentifier::builder().key(k).build().unwrap());
}
}
@@ -223,7 +223,7 @@ async fn test_deleteobject() {
.unwrap();
if i > 0 {
- to_del = to_del.objects(ObjectIdentifier::builder().key(k).build());
+ to_del = to_del.objects(ObjectIdentifier::builder().key(k).build().unwrap());
}
}
@@ -247,7 +247,7 @@ async fn test_deleteobject() {
.client
.delete_objects()
.bucket(&bucket)
- .delete(to_del.build())
+ .delete(to_del.build().unwrap())
.send()
.await
.unwrap();
diff --git a/src/garage/tests/s3/streaming_signature.rs b/src/garage/tests/s3/streaming_signature.rs
index b7a1acae..224b9ed5 100644
--- a/src/garage/tests/s3/streaming_signature.rs
+++ b/src/garage/tests/s3/streaming_signature.rs
@@ -57,9 +57,9 @@ async fn test_putobject_streaming() {
// assert_eq!(o.version_id.unwrap(), _version);
assert_eq!(o.content_type.unwrap(), content_type);
assert!(o.last_modified.is_some());
- assert_eq!(o.content_length, 0);
- assert_eq!(o.parts_count, 0);
- assert_eq!(o.tag_count, 0);
+ assert_eq!(o.content_length.unwrap(), 0);
+ assert_eq!(o.parts_count, None);
+ assert_eq!(o.tag_count, None);
}
{
@@ -95,9 +95,9 @@ async fn test_putobject_streaming() {
assert_bytes_eq!(o.body, BODY);
assert_eq!(o.e_tag.unwrap(), etag);
assert!(o.last_modified.is_some());
- assert_eq!(o.content_length, 62);
- assert_eq!(o.parts_count, 0);
- assert_eq!(o.tag_count, 0);
+ assert_eq!(o.content_length.unwrap(), 62);
+ assert_eq!(o.parts_count, None);
+ assert_eq!(o.tag_count, None);
}
}
@@ -187,7 +187,7 @@ async fn test_put_website_streaming() {
.await
.unwrap();
- assert_eq!(o.index_document.unwrap().suffix.unwrap(), "home.html");
- assert_eq!(o.error_document.unwrap().key.unwrap(), "err/error.html");
+ assert_eq!(o.index_document.unwrap().suffix, "home.html");
+ assert_eq!(o.error_document.unwrap().key, "err/error.html");
}
}
diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs
index eeafb5fa..59c990f8 100644
--- a/src/garage/tests/s3/website.rs
+++ b/src/garage/tests/s3/website.rs
@@ -181,8 +181,18 @@ async fn test_website_s3_api() {
.unwrap();
let conf = WebsiteConfiguration::builder()
- .index_document(IndexDocument::builder().suffix("home.html").build())
- .error_document(ErrorDocument::builder().key("err/error.html").build())
+ .index_document(
+ IndexDocument::builder()
+ .suffix("home.html")
+ .build()
+ .unwrap(),
+ )
+ .error_document(
+ ErrorDocument::builder()
+ .key("err/error.html")
+ .build()
+ .unwrap(),
+ )
.build();
ctx.client
@@ -201,9 +211,11 @@ async fn test_website_s3_api() {
.allowed_methods("GET")
.allowed_methods("PUT")
.allowed_origins("*")
- .build(),
+ .build()
+ .unwrap(),
)
- .build();
+ .build()
+ .unwrap();
ctx.client
.put_bucket_cors()
@@ -222,19 +234,16 @@ async fn test_website_s3_api() {
.await
.unwrap();
- let main_rule = cors_res.cors_rules().unwrap().iter().next().unwrap();
+ let main_rule = cors_res.cors_rules().iter().next().unwrap();
assert_eq!(main_rule.id.as_ref().unwrap(), "main-rule");
assert_eq!(
main_rule.allowed_headers.as_ref().unwrap(),
&vec!["*".to_string()]
);
+ assert_eq!(&main_rule.allowed_origins, &vec!["*".to_string()]);
assert_eq!(
- main_rule.allowed_origins.as_ref().unwrap(),
- &vec!["*".to_string()]
- );
- assert_eq!(
- main_rule.allowed_methods.as_ref().unwrap(),
+ &main_rule.allowed_methods,
&vec!["GET".to_string(), "PUT".to_string()]
);
}
diff --git a/src/k2v-client/Cargo.toml b/src/k2v-client/Cargo.toml
index 7c0462a5..9f27c47d 100644
--- a/src/k2v-client/Cargo.toml
+++ b/src/k2v-client/Cargo.toml
@@ -15,6 +15,7 @@ hex.workspace = true
http.workspace = true
log.workspace = true
aws-sigv4.workspace = true
+aws-sdk-config.workspace = true
percent-encoding.workspace = true
hyper = { workspace = true, default-features = false, features = ["client", "http1", "http2"] }
hyper-rustls.workspace = true
diff --git a/src/k2v-client/error.rs b/src/k2v-client/error.rs
index 564ce497..aa84ee9f 100644
--- a/src/k2v-client/error.rs
+++ b/src/k2v-client/error.rs
@@ -27,7 +27,7 @@ pub enum Error {
#[error("deserialization error: {0}")]
Deserialization(#[from] serde_json::Error),
#[error("invalid signature parameters: {0}")]
- SignParameters(#[from] aws_sigv4::signing_params::BuildError),
+ SignParameters(#[from] aws_sigv4::sign::v4::signing_params::BuildError),
#[error("could not sign request: {0}")]
SignRequest(#[from] aws_sigv4::http_request::SigningError),
#[error("request timed out")]
diff --git a/src/k2v-client/lib.rs b/src/k2v-client/lib.rs
index 4aa7a20a..4977ce85 100644
--- a/src/k2v-client/lib.rs
+++ b/src/k2v-client/lib.rs
@@ -13,7 +13,9 @@ use hyper::{body::Bytes, Body};
use hyper::{client::connect::HttpConnector, Client as HttpClient};
use hyper_rustls::HttpsConnector;
-use aws_sigv4::http_request::{sign, SignableRequest, SigningParams, SigningSettings};
+use aws_sdk_config::config::Credentials;
+use aws_sigv4::http_request::{sign, SignableBody, SignableRequest, SigningSettings};
+use aws_sigv4::sign::v4::SigningParams;
use serde::de::Error as DeError;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -363,21 +365,37 @@ impl K2vClient {
// Sign request
let signing_settings = SigningSettings::default();
+ let identity = Credentials::new(
+ &self.config.aws_access_key_id,
+ &self.config.aws_secret_access_key,
+ None,
+ None,
+ "k2v-client",
+ )
+ .into();
let signing_params = SigningParams::builder()
- .access_key(&self.config.aws_access_key_id)
- .secret_key(&self.config.aws_secret_access_key)
+ .identity(&identity)
.region(&self.config.region)
- .service_name(SERVICE)
+ .name(SERVICE)
.time(SystemTime::now())
.settings(signing_settings)
- .build()?;
+ .build()?
+ .into();
// Convert the HTTP request into a signable request
- let signable_request = SignableRequest::from(&req);
+ let signable_request = SignableRequest::new(
+ req.method().as_str(),
+ req.uri().to_string(),
+ // TODO: get rid of Unwrap
+ req.headers()
+ .iter()
+ .map(|(x, y)| (x.as_str(), y.to_str().unwrap())),
+ SignableBody::Bytes(req.body().as_ref()),
+ )?;
// Sign and then apply the signature to the request
let (signing_instructions, _signature) =
sign(signable_request, &signing_params)?.into_parts();
- signing_instructions.apply_to_request(&mut req);
+ signing_instructions.apply_to_request_http0x(&mut req);
// Send and wait for timeout
let res = tokio::select! {
@@ -451,7 +469,11 @@ impl K2vClient {
}
fn build_url<V: AsRef<str>>(&self, partition_key: Option<&str>, query: &[(&str, V)]) -> String {
- let mut url = format!("{}/{}", self.config.endpoint, self.config.bucket);
+ let mut url = format!(
+ "{}/{}",
+ self.config.endpoint.trim_end_matches('/'),
+ self.config.bucket
+ );
if let Some(pk) = partition_key {
url.push('/');
url.extend(utf8_percent_encode(pk, &PATH_ENCODE_SET));