From 9381ba38726b33d3332261cf0eea4fb63a21c91e Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Tue, 15 Oct 2024 16:07:57 -0400 Subject: [PATCH 01/13] relocate http related test utils into new crate as is --- rust-runtime/Cargo.lock | 5 +++ .../aws-smithy-http-client/Cargo.toml | 26 ++++++++++- .../aws-smithy-http-client/src/lib.rs | 4 ++ .../src}/test_util.rs | 10 ++--- .../src}/test_util/capture_request.rs | 0 .../src}/test_util/dvr.rs | 0 .../src}/test_util/dvr/record.rs | 0 .../src}/test_util/dvr/replay.rs | 2 +- .../src}/test_util/infallible.rs | 2 +- .../src}/test_util/never.rs | 12 +++--- .../src}/test_util/replay.rs | 8 ++-- .../src}/test_util/wire.rs | 43 ++++++++----------- .../test-data/example.com.json | 0 rust-runtime/aws-smithy-runtime/Cargo.toml | 1 + .../aws-smithy-runtime/src/client/http.rs | 3 +- 15 files changed, 73 insertions(+), 43 deletions(-) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util.rs (90%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/capture_request.rs (100%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/dvr.rs (100%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/dvr/record.rs (100%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/dvr/replay.rs (99%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/infallible.rs (97%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/never.rs (94%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/replay.rs (97%) rename rust-runtime/{aws-smithy-runtime/src/client/http => aws-smithy-http-client/src}/test_util/wire.rs (88%) rename rust-runtime/{aws-smithy-runtime => aws-smithy-http-client}/test-data/example.com.json (100%) diff --git a/rust-runtime/Cargo.lock b/rust-runtime/Cargo.lock index b054a9fb26..30bec23494 100644 --- a/rust-runtime/Cargo.lock +++ b/rust-runtime/Cargo.lock @@ -464,8 +464,10 @@ name = "aws-smithy-http-client" version = "1.0.0" dependencies = [ "aws-smithy-async 1.2.1", + "aws-smithy-protocol-test 0.63.0", "aws-smithy-runtime-api 1.7.3", "aws-smithy-types 1.2.7", + "bytes", "h2 0.4.6", "http 0.2.12", "http 1.1.0", @@ -475,10 +477,13 @@ dependencies = [ "hyper-rustls 0.24.2", "hyper-rustls 0.27.3", "hyper-util", + "indexmap 2.6.0", "once_cell", "pin-project-lite", "rustls 0.21.12", "rustls 0.23.14", + "serde", + "serde_json", "tokio", "tower 0.5.1", "tracing", diff --git a/rust-runtime/aws-smithy-http-client/Cargo.toml b/rust-runtime/aws-smithy-http-client/Cargo.toml index 3f8a24ace9..9050be0394 100644 --- a/rust-runtime/aws-smithy-http-client/Cargo.toml +++ b/rust-runtime/aws-smithy-http-client/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" repository = "/~https://github.com/smithy-lang/smithy-rs" [features] -legacy-tls-rustls = ["dep:legacy-hyper-rustls", "dep:legacy-rustls", "hyper-014"] hyper-014 = [ "aws-smithy-runtime-api/http-02x", "aws-smithy-types/http-body-0-4-x", @@ -27,6 +26,23 @@ hyper-1 = [ "dep:tower", ] +wire-mock = [ + "test-util", + # FIXME - replace/deprecate + "hyper-014", + "hyper-0-14?/server", +] + +test-util = [ + "dep:aws-smithy-protocol-test", + "dep:serde", + "dep:serde_json", + "dep:indexmap", + "dep:bytes" +] + +legacy-tls-rustls = ["dep:legacy-hyper-rustls", "dep:legacy-rustls", "hyper-014"] + # FIXME - s2n-tls option, distinguish between rustls and s2n crypto-ring = ["dep:rustls", "rustls?/ring", "dep:hyper-rustls", "hyper-1"] crypto-aws-lc = ["dep:rustls", "rustls?/aws_lc_rs", "dep:hyper-rustls", "hyper-1"] @@ -36,6 +52,7 @@ crypto-aws-lc-fips = ["dep:rustls", "rustls?/fips", "dep:hyper-rustls", "hyper-1 aws-smithy-async = { path = "../aws-smithy-async" } aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api", features = ["client"] } aws-smithy-types = { path = "../aws-smithy-types" } +aws-smithy-protocol-test = { path = "../aws-smithy-protocol-test", optional = true } h2 = { version = "0.4", default-features = false } # FIXME - do we need tokio enabled by default? tokio = { version = "1", features = [] } @@ -60,6 +77,13 @@ legacy-hyper-rustls = { package = "hyper-rustls", version = "0.24", features = [ legacy-rustls = { package = "rustls", version = "0.21.8", optional = true } # end legacy stack deps +# test util stack +bytes = { version = "1", optional = true } +serde = { version = "1.0.210", features = ["derive"], optional = true } +serde_json = { version = "1.0.128", features = ["preserve_order"], optional = true } +indexmap = { version = "2.6.0", features = ["serde"], optional = true } +# end test util stack + [dev-dependencies] aws-smithy-async = { path = "../aws-smithy-async", features = ["rt-tokio", "test-util"] } aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api", features = ["test-util"] } diff --git a/rust-runtime/aws-smithy-http-client/src/lib.rs b/rust-runtime/aws-smithy-http-client/src/lib.rs index 2520d287a6..562b54bd4f 100644 --- a/rust-runtime/aws-smithy-http-client/src/lib.rs +++ b/rust-runtime/aws-smithy-http-client/src/lib.rs @@ -11,6 +11,7 @@ //! //! # Crate Features //! +//! - `hyper-014`: (Deprecated) HTTP client implementation based on hyper-0.14.x. //! - `test-util`: Enables utilities for unit tests. DO NOT ENABLE IN PRODUCTION. #![warn( @@ -37,3 +38,6 @@ pub mod hyper_014 { /// Default HTTP and TLS connectors that use hyper 0.14.x and rustls. #[cfg(feature = "hyper-1")] pub mod hyper_1; + +#[cfg(feature = "test-util")] +pub mod test_util; diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs similarity index 90% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util.rs rename to rust-runtime/aws-smithy-http-client/src/test_util.rs index a1c4250fb2..cfca5cf03a 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -12,7 +12,7 @@ //! respond with a given response, then capture request can also be useful since //! you can optionally give it a response to return. #![cfg_attr( - feature = "connector-hyper-0-14-x", + feature = "hyper-014", doc = "- [`dvr`]: If you want to record real-world traffic and then replay it later, then DVR's" )] //! [`RecordingClient`](dvr::RecordingClient) and [`ReplayingClient`](dvr::ReplayingClient) @@ -29,7 +29,7 @@ //! - [`NeverClient`]: Useful for testing timeouts, where you want the client to never respond. //! #![cfg_attr( - feature = "connector-hyper-0-14-x", + feature = "hyper-014", doc = " There is also the [`NeverTcpConnector`], which makes it easy to test connect/read timeouts. @@ -39,7 +39,7 @@ Finally, for socket-level mocking, see the [`wire`] module. mod capture_request; pub use capture_request::{capture_request, CaptureRequestHandler, CaptureRequestReceiver}; -#[cfg(feature = "connector-hyper-0-14-x")] +#[cfg(feature = "hyper-014")] pub mod dvr; mod replay; @@ -51,8 +51,8 @@ pub use infallible::infallible_client_fn; mod never; pub use never::NeverClient; -#[cfg(feature = "connector-hyper-0-14-x")] +#[cfg(feature = "hyper-014")] pub use never::NeverTcpConnector; -#[cfg(all(feature = "connector-hyper-0-14-x", feature = "wire-mock"))] +#[cfg(all(feature = "hyper-014", feature = "wire-mock"))] pub mod wire; diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/capture_request.rs b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs similarity index 100% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/capture_request.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr.rs b/rust-runtime/aws-smithy-http-client/src/test_util/dvr.rs similarity index 100% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/dvr.rs diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr/record.rs b/rust-runtime/aws-smithy-http-client/src/test_util/dvr/record.rs similarity index 100% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr/record.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/dvr/record.rs diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr/replay.rs b/rust-runtime/aws-smithy-http-client/src/test_util/dvr/replay.rs similarity index 99% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr/replay.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/dvr/replay.rs index e4ad46494a..8e6eceeb94 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr/replay.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/dvr/replay.rs @@ -4,7 +4,7 @@ */ use super::{Action, ConnectionId, Direction, Event, NetworkTraffic}; -use crate::client::http::test_util::replay::DEFAULT_RELAXED_HEADERS; +use crate::test_util::replay::DEFAULT_RELAXED_HEADERS; use aws_smithy_protocol_test::MediaType; use aws_smithy_runtime_api::client::connector_metadata::ConnectorMetadata; use aws_smithy_runtime_api::client::http::{ diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/infallible.rs b/rust-runtime/aws-smithy-http-client/src/test_util/infallible.rs similarity index 97% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/infallible.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/infallible.rs index 0a9b925bde..09b2cde4ee 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/infallible.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/infallible.rs @@ -21,7 +21,7 @@ use std::sync::Arc; /// # Examples /// /// ```rust -/// use aws_smithy_runtime::client::http::test_util::infallible_client_fn; +/// use aws_smithy_http_client::test_util::infallible_client_fn; /// let http_client = infallible_client_fn(|_req| http_02x::Response::builder().status(200).body("OK!").unwrap()); /// ``` pub fn infallible_client_fn( diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/never.rs b/rust-runtime/aws-smithy-http-client/src/test_util/never.rs similarity index 94% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/never.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/never.rs index 69e5dd4879..85970ad35d 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/never.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/never.rs @@ -62,11 +62,11 @@ impl HttpClient for NeverClient { /// A TCP connector that never connects. // In the future, this can be available for multiple hyper version feature flags, with the impls gated between individual features -#[cfg(feature = "connector-hyper-0-14-x")] +#[cfg(feature = "hyper-014")] #[derive(Clone, Debug, Default)] pub struct NeverTcpConnector; -#[cfg(feature = "connector-hyper-0-14-x")] +#[cfg(feature = "hyper-014")] impl NeverTcpConnector { /// Creates a new `NeverTcpConnector`. pub fn new() -> Self { @@ -74,7 +74,7 @@ impl NeverTcpConnector { } } -#[cfg(feature = "connector-hyper-0-14-x")] +#[cfg(feature = "hyper-014")] impl hyper_0_14::service::Service for NeverTcpConnector { type Response = connection::NeverTcpConnection; type Error = aws_smithy_runtime_api::box_error::BoxError; @@ -97,7 +97,7 @@ impl hyper_0_14::service::Service for NeverTcpConnector { } } -#[cfg(feature = "connector-hyper-0-14-x")] +#[cfg(feature = "hyper-014")] mod connection { use hyper_0_14::client::connect::{Connected, Connection}; use std::io::Error; @@ -145,10 +145,10 @@ mod connection { } } -#[cfg(all(test, feature = "connector-hyper-0-14-x"))] +#[cfg(all(test, feature = "hyper-014"))] #[tokio::test] async fn never_tcp_connector_plugs_into_hyper_014() { - use crate::client::http::hyper_014::HyperClientBuilder; + use crate::hyper_014::HyperClientBuilder; use aws_smithy_async::rt::sleep::TokioSleep; use aws_smithy_async::time::SystemTimeSource; use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder; diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/replay.rs b/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs similarity index 97% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/replay.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/replay.rs index adbd5aa5bf..3c1de7d20d 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/replay.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs @@ -119,7 +119,7 @@ impl ValidateRequest { /// # Example /// /// ```no_run -/// use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient}; +/// use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient}; /// use aws_smithy_types::body::SdkBody; /// /// let http_client = StaticReplayClient::new(vec![ @@ -281,17 +281,17 @@ impl HttpClient for StaticReplayClient { #[cfg(test)] mod test { - use crate::client::http::test_util::{ReplayEvent, StaticReplayClient}; + use crate::test_util::{ReplayEvent, StaticReplayClient}; use aws_smithy_types::body::SdkBody; #[test] fn create_from_either_http_type() { let _client = StaticReplayClient::new(vec![ReplayEvent::new( - http1::Request::builder() + http_1x::Request::builder() .uri("test") .body(SdkBody::from("hello")) .unwrap(), - http1::Response::builder() + http_1x::Response::builder() .status(200) .body(SdkBody::from("hello")) .unwrap(), diff --git a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/wire.rs b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs similarity index 88% rename from rust-runtime/aws-smithy-runtime/src/client/http/test_util/wire.rs rename to rust-runtime/aws-smithy-http-client/src/test_util/wire.rs index 11415a494a..ce55b8bd01 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http/test_util/wire.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs @@ -12,8 +12,8 @@ //! # Examples //! ```no_run //! use aws_smithy_runtime_api::client::http::HttpConnectorSettings; -//! use aws_smithy_runtime::client::http::test_util::wire::{check_matches, ReplayedEvent, WireMockServer}; -//! use aws_smithy_runtime::{match_events, ev}; +//! use aws_smithy_http_client::test_util::wire::{check_matches, ReplayedEvent, WireMockServer}; +//! use aws_smithy_http_client::{match_events, ev}; //! # async fn example() { //! //! // This connection binds to a local address @@ -40,7 +40,7 @@ #![allow(missing_docs)] #[allow(deprecated)] -use crate::client::http::hyper_014::HyperClientBuilder; +use crate::hyper_014::HyperClientBuilder; use aws_smithy_async::future::never::Never; use aws_smithy_async::future::BoxFuture; use aws_smithy_runtime_api::client::http::SharedHttpClient; @@ -97,19 +97,14 @@ pub fn check_matches(events: &[RecordedEvent], matchers: &[Matcher]) { macro_rules! matcher { ($expect:tt) => { ( - Box::new( - |event: &$crate::client::http::test_util::wire::RecordedEvent| { - if !matches!(event, $expect) { - return Err(format!( - "expected `{}` but got {:?}", - stringify!($expect), - event - ) - .into()); - } - Ok(()) - }, - ), + Box::new(|event: &$crate::test_util::wire::RecordedEvent| { + if !matches!(event, $expect) { + return Err( + format!("expected `{}` but got {:?}", stringify!($expect), event).into(), + ); + } + Ok(()) + }), stringify!($expect), ) }; @@ -120,7 +115,7 @@ macro_rules! matcher { macro_rules! match_events { ($( $expect:pat),*) => { |events| { - $crate::client::http::test_util::wire::check_matches(events, &[$( $crate::matcher!($expect) ),*]); + $crate::test_util::wire::check_matches(events, &[$( $crate::matcher!($expect) ),*]); } }; } @@ -129,22 +124,22 @@ macro_rules! match_events { #[macro_export] macro_rules! ev { (http($status:expr)) => { - $crate::client::http::test_util::wire::RecordedEvent::Response( - $crate::client::http::test_util::wire::ReplayedEvent::HttpResponse { + $crate::test_util::wire::RecordedEvent::Response( + $crate::test_util::wire::ReplayedEvent::HttpResponse { status: $status, .. }, ) }; (dns) => { - $crate::client::http::test_util::wire::RecordedEvent::DnsLookup(_) + $crate::test_util::wire::RecordedEvent::DnsLookup(_) }; (connect) => { - $crate::client::http::test_util::wire::RecordedEvent::NewConnection + $crate::test_util::wire::RecordedEvent::NewConnection }; (timeout) => { - $crate::client::http::test_util::wire::RecordedEvent::Response( - $crate::client::http::test_util::wire::ReplayedEvent::Timeout, + $crate::test_util::wire::RecordedEvent::Response( + $crate::test_util::wire::ReplayedEvent::Timeout, ) }; } @@ -184,7 +179,7 @@ impl ReplayedEvent { /// Test server that binds to 127.0.0.1:0 /// -/// See the [module docs](crate::client::http::test_util::wire) for a usage example. +/// See the [module docs](crate::test_util::wire) for a usage example. /// /// Usage: /// - Call [`WireMockServer::start`] to start the server diff --git a/rust-runtime/aws-smithy-runtime/test-data/example.com.json b/rust-runtime/aws-smithy-http-client/test-data/example.com.json similarity index 100% rename from rust-runtime/aws-smithy-runtime/test-data/example.com.json rename to rust-runtime/aws-smithy-http-client/test-data/example.com.json diff --git a/rust-runtime/aws-smithy-runtime/Cargo.toml b/rust-runtime/aws-smithy-runtime/Cargo.toml index 6a8d8e6f2e..f85e51b1f2 100644 --- a/rust-runtime/aws-smithy-runtime/Cargo.toml +++ b/rust-runtime/aws-smithy-runtime/Cargo.toml @@ -16,6 +16,7 @@ connector-hyper-0-14-x = ["dep:aws-smithy-http-client", "aws-smithy-http-client? tls-rustls = ["dep:aws-smithy-http-client", "aws-smithy-http-client?/legacy-tls-rustls", "connector-hyper-0-14-x"] rt-tokio = ["tokio/rt"] +# FIXME - update once we know what this looks like from aws-smithy-http-client (also run udeps) # Features for testing test-util = [ "aws-smithy-runtime-api/test-util", diff --git a/rust-runtime/aws-smithy-runtime/src/client/http.rs b/rust-runtime/aws-smithy-runtime/src/client/http.rs index 8c1be0b48c..77d922afce 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http.rs +++ b/rust-runtime/aws-smithy-runtime/src/client/http.rs @@ -6,8 +6,9 @@ /// Interceptor for connection poisoning. pub mod connection_poisoning; +// FIXME - deprecate and re-export from aws-smithy-runtime #[cfg(feature = "test-util")] -pub mod test_util; +// pub mod test_util; /// Default HTTP and TLS connectors that use hyper 0.14.x and rustls. /// From e5b1c76003f5b90c4c72cd3efd9932804244ae87 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Wed, 16 Oct 2024 11:02:36 -0400 Subject: [PATCH 02/13] update replay and never modules to support both hyper versions --- .../aws-smithy-http-client/src/hyper_1.rs | 2 +- .../aws-smithy-http-client/src/test_util.rs | 4 +- .../src/test_util/never.rs | 114 +++++++++++++----- .../src/test_util/replay.rs | 7 +- 4 files changed, 94 insertions(+), 33 deletions(-) diff --git a/rust-runtime/aws-smithy-http-client/src/hyper_1.rs b/rust-runtime/aws-smithy-http-client/src/hyper_1.rs index aff7f7b5c4..3d6c8100cb 100644 --- a/rust-runtime/aws-smithy-http-client/src/hyper_1.rs +++ b/rust-runtime/aws-smithy-http-client/src/hyper_1.rs @@ -706,7 +706,7 @@ impl HyperClientBuilder { } } -fn build_with_fn( +pub(crate) fn build_with_fn( client_builder: Option, tcp_connector_fn: F, ) -> SharedHttpClient diff --git a/rust-runtime/aws-smithy-http-client/src/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs index cfca5cf03a..4cc6ea7694 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -29,7 +29,7 @@ //! - [`NeverClient`]: Useful for testing timeouts, where you want the client to never respond. //! #![cfg_attr( - feature = "hyper-014", + any(feature = "hyper-014", feature = "hyper-1"), doc = " There is also the [`NeverTcpConnector`], which makes it easy to test connect/read timeouts. @@ -51,7 +51,7 @@ pub use infallible::infallible_client_fn; mod never; pub use never::NeverClient; -#[cfg(feature = "hyper-014")] +#[cfg(any(feature = "hyper-014", feature = "hyper-1"))] pub use never::NeverTcpConnector; #[cfg(all(feature = "hyper-014", feature = "wire-mock"))] diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/never.rs b/rust-runtime/aws-smithy-http-client/src/test_util/never.rs index 85970ad35d..fd1633da36 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/never.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/never.rs @@ -62,11 +62,11 @@ impl HttpClient for NeverClient { /// A TCP connector that never connects. // In the future, this can be available for multiple hyper version feature flags, with the impls gated between individual features -#[cfg(feature = "hyper-014")] +#[cfg(any(feature = "hyper-014", feature = "hyper-1"))] #[derive(Clone, Debug, Default)] pub struct NeverTcpConnector; -#[cfg(feature = "hyper-014")] +#[cfg(any(feature = "hyper-014", feature = "hyper-1"))] impl NeverTcpConnector { /// Creates a new `NeverTcpConnector`. pub fn new() -> Self { @@ -76,7 +76,7 @@ impl NeverTcpConnector { #[cfg(feature = "hyper-014")] impl hyper_0_14::service::Service for NeverTcpConnector { - type Response = connection::NeverTcpConnection; + type Response = hyper_014_support::NeverTcpConnection; type Error = aws_smithy_runtime_api::box_error::BoxError; type Future = std::pin::Pin< Box> + Send + Sync>, @@ -97,8 +97,38 @@ impl hyper_0_14::service::Service for NeverTcpConnector { } } +#[cfg(feature = "hyper-1")] +mod hyper1_support { + use super::NeverTcpConnector; + use aws_smithy_async::future::never::Never; + use aws_smithy_runtime_api::client::result::ConnectorError; + use http_1x::Uri; + use hyper_util::rt::TokioIo; + use std::future::Future; + use std::pin::Pin; + use std::task::{Context, Poll}; + use tokio::net::TcpStream; + + impl tower::Service for NeverTcpConnector { + type Response = TokioIo; + type Error = ConnectorError; + type Future = Pin> + Send>>; + + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, _uri: Uri) -> Self::Future { + Box::pin(async move { + Never::new().await; + unreachable!() + }) + } + } +} + #[cfg(feature = "hyper-014")] -mod connection { +mod hyper_014_support { use hyper_0_14::client::connect::{Connected, Connection}; use std::io::Error; use std::pin::Pin; @@ -145,32 +175,62 @@ mod connection { } } -#[cfg(all(test, feature = "hyper-014"))] -#[tokio::test] -async fn never_tcp_connector_plugs_into_hyper_014() { - use crate::hyper_014::HyperClientBuilder; +#[cfg(test)] +mod test { + use super::NeverTcpConnector; use aws_smithy_async::rt::sleep::TokioSleep; use aws_smithy_async::time::SystemTimeSource; + use aws_smithy_runtime_api::client::http::{HttpClient, HttpConnector, HttpConnectorSettings}; + use aws_smithy_runtime_api::client::orchestrator::HttpRequest; use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder; use std::time::Duration; - // it should compile - let client = HyperClientBuilder::new().build(NeverTcpConnector::new()); - let components = RuntimeComponentsBuilder::for_tests() - .with_sleep_impl(Some(TokioSleep::new())) - .with_time_source(Some(SystemTimeSource::new())) - .build() - .unwrap(); - let http_connector = client.http_connector( - &HttpConnectorSettings::builder() - .connect_timeout(Duration::from_millis(100)) - .build(), - &components, - ); - - let err = http_connector - .call(HttpRequest::get("http://fakeuri.com").unwrap()) - .await - .expect_err("it should time out"); - assert!(dbg!(err).is_timeout()); + #[cfg(feature = "hyper-014")] + #[tokio::test] + async fn never_tcp_connector_plugs_into_hyper_014() { + use crate::hyper_014::HyperClientBuilder; + + // it should compile + let client = HyperClientBuilder::new().build(NeverTcpConnector::new()); + let components = RuntimeComponentsBuilder::for_tests() + .with_sleep_impl(Some(TokioSleep::new())) + .with_time_source(Some(SystemTimeSource::new())) + .build() + .unwrap(); + let http_connector = client.http_connector( + &HttpConnectorSettings::builder() + .connect_timeout(Duration::from_millis(100)) + .build(), + &components, + ); + + let err = http_connector + .call(HttpRequest::get("http://fakeuri.com").unwrap()) + .await + .expect_err("it should time out"); + assert!(dbg!(err).is_timeout()); + } + + #[cfg(feature = "hyper-1")] + #[tokio::test] + async fn never_tcp_connector_plugs_into_hyper_1() { + let client = crate::hyper_1::build_with_fn(None, NeverTcpConnector::new); + let components = RuntimeComponentsBuilder::for_tests() + .with_sleep_impl(Some(TokioSleep::new())) + .with_time_source(Some(SystemTimeSource::new())) + .build() + .unwrap(); + let http_connector = client.http_connector( + &HttpConnectorSettings::builder() + .connect_timeout(Duration::from_millis(100)) + .build(), + &components, + ); + + let err = http_connector + .call(HttpRequest::get("http://fakeuri.com").unwrap()) + .await + .expect_err("it should time out"); + assert!(dbg!(err).is_timeout()); + } } diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs b/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs index 3c1de7d20d..efae7fd4df 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs @@ -12,7 +12,7 @@ use aws_smithy_runtime_api::client::orchestrator::{HttpRequest, HttpResponse}; use aws_smithy_runtime_api::client::result::ConnectorError; use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents; use aws_smithy_runtime_api::shared::IntoShared; -use http_02x::header::CONTENT_TYPE; +use http_1x::header::CONTENT_TYPE; use std::ops::Deref; use std::sync::{Arc, Mutex, MutexGuard}; @@ -119,6 +119,7 @@ impl ValidateRequest { /// # Example /// /// ```no_run +/// # use http_1x as http; /// use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient}; /// use aws_smithy_types::body::SdkBody; /// @@ -127,9 +128,9 @@ impl ValidateRequest { /// ReplayEvent::new( /// // If `assert_requests_match` is called later, then this request will be matched /// // against the actual request that was made. -/// http_02x::Request::builder().uri("http://localhost:1234/foo").body(SdkBody::empty()).unwrap(), +/// http::Request::builder().uri("http://localhost:1234/foo").body(SdkBody::empty()).unwrap(), /// // This response will be given to the first request regardless of whether it matches the request above. -/// http_02x::Response::builder().status(200).body(SdkBody::empty()).unwrap(), +/// http::Response::builder().status(200).body(SdkBody::empty()).unwrap(), /// ), /// // The next ReplayEvent covers the second request/response pair... /// ]); From 632635303808e9574aee365012f4f0123b2c06a1 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Wed, 16 Oct 2024 11:34:33 -0400 Subject: [PATCH 03/13] update capture request to take generic argument --- .../aws-smithy-http-client/Cargo.toml | 5 +- .../aws-smithy-http-client/src/test_util.rs | 1 + .../src/test_util/capture_request.rs | 59 ++++++++++++++++--- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/rust-runtime/aws-smithy-http-client/Cargo.toml b/rust-runtime/aws-smithy-http-client/Cargo.toml index 9050be0394..3c71547aad 100644 --- a/rust-runtime/aws-smithy-http-client/Cargo.toml +++ b/rust-runtime/aws-smithy-http-client/Cargo.toml @@ -38,7 +38,10 @@ test-util = [ "dep:serde", "dep:serde_json", "dep:indexmap", - "dep:bytes" + "dep:bytes", + # for capture_request + "dep:http-1x", + "aws-smithy-runtime-api/http-1x" ] legacy-tls-rustls = ["dep:legacy-hyper-rustls", "dep:legacy-rustls", "hyper-014"] diff --git a/rust-runtime/aws-smithy-http-client/src/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs index 4cc6ea7694..4d8f2eff7a 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -36,6 +36,7 @@ There is also the [`NeverTcpConnector`], which makes it easy to test connect/rea Finally, for socket-level mocking, see the [`wire`] module. " )] + mod capture_request; pub use capture_request::{capture_request, CaptureRequestHandler, CaptureRequestReceiver}; diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs index 70836808a4..dccdd513fa 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs @@ -7,8 +7,9 @@ use aws_smithy_runtime_api::client::connector_metadata::ConnectorMetadata; use aws_smithy_runtime_api::client::http::{ HttpClient, HttpConnector, HttpConnectorFuture, HttpConnectorSettings, SharedHttpConnector, }; -use aws_smithy_runtime_api::client::orchestrator::HttpRequest; +use aws_smithy_runtime_api::client::orchestrator::{HttpRequest, HttpResponse}; use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents; +use aws_smithy_runtime_api::http::HttpError; use aws_smithy_runtime_api::shared::IntoShared; use aws_smithy_types::body::SdkBody; use std::fmt::Debug; @@ -17,7 +18,7 @@ use tokio::sync::oneshot; #[derive(Debug)] struct Inner { - response: Option>, + response: Option, sender: Option>, } @@ -101,19 +102,59 @@ impl CaptureRequestReceiver { /// ); /// ``` pub fn capture_request( - response: Option>, + response: Option>, ) -> (CaptureRequestHandler, CaptureRequestReceiver) { let (tx, rx) = oneshot::channel(); + let http_resp: HttpResponse = match response { + Some(resp) => resp.try_into().expect("valid HttpRequest"), + None => http_1x::Response::builder() + .status(200) + .body(SdkBody::empty()) + .expect("unreachable") + .try_into() + .expect("unreachable"), + }; ( CaptureRequestHandler(Arc::new(Mutex::new(Inner { - response: Some(response.unwrap_or_else(|| { - http_02x::Response::builder() - .status(200) - .body(SdkBody::empty()) - .expect("unreachable") - })), + response: Some(http_resp), sender: Some(tx), }))), CaptureRequestReceiver { receiver: rx }, ) } + +#[cfg(test)] +mod test { + use aws_smithy_runtime_api::client::http::HttpConnector; + use aws_smithy_runtime_api::client::orchestrator::HttpRequest; + use aws_smithy_types::body::SdkBody; + + #[cfg(feature = "hyper-014")] + #[tokio::test] + async fn test_can_plug_in_http_02x() { + use super::capture_request; + let (capture_client, request) = capture_request(Some( + http_02x::Response::builder() + .status(202) + .body(SdkBody::empty()) + .expect("unreachable"), + )); + + let resp = capture_client.call(HttpRequest::empty()).await.unwrap(); + assert_eq!(202, resp.status().as_u16()); + } + + #[tokio::test] + async fn test_can_plug_in_http_1x() { + use super::capture_request; + let (capture_client, request) = capture_request(Some( + http_1x::Response::builder() + .status(202) + .body(SdkBody::empty()) + .expect("unreachable"), + )); + + let resp = capture_client.call(HttpRequest::empty()).await.unwrap(); + assert_eq!(202, resp.status().as_u16()); + } +} From a282a97065f2050faa148d29a6db214993ea0528 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Thu, 17 Oct 2024 09:56:44 -0400 Subject: [PATCH 04/13] update dvr and friends to http1 --- rust-runtime/Cargo.lock | 1 + .../aws-smithy-http-client/Cargo.toml | 12 ++- .../aws-smithy-http-client/src/test_util.rs | 1 + .../src/test_util/body.rs | 95 +++++++++++++++++++ .../src/test_util/capture_request.rs | 6 +- .../src/test_util/dvr.rs | 41 +++++++- .../src/test_util/dvr/record.rs | 11 +-- .../src/test_util/dvr/replay.rs | 33 ++++--- 8 files changed, 176 insertions(+), 24 deletions(-) create mode 100644 rust-runtime/aws-smithy-http-client/src/test_util/body.rs diff --git a/rust-runtime/Cargo.lock b/rust-runtime/Cargo.lock index 30bec23494..14adf6f384 100644 --- a/rust-runtime/Cargo.lock +++ b/rust-runtime/Cargo.lock @@ -472,6 +472,7 @@ dependencies = [ "http 0.2.12", "http 1.1.0", "http-body 0.4.6", + "http-body 1.0.1", "hyper 0.14.30", "hyper 1.4.1", "hyper-rustls 0.24.2", diff --git a/rust-runtime/aws-smithy-http-client/Cargo.toml b/rust-runtime/aws-smithy-http-client/Cargo.toml index 3c71547aad..10b5d69341 100644 --- a/rust-runtime/aws-smithy-http-client/Cargo.toml +++ b/rust-runtime/aws-smithy-http-client/Cargo.toml @@ -41,7 +41,16 @@ test-util = [ "dep:bytes", # for capture_request "dep:http-1x", - "aws-smithy-runtime-api/http-1x" + "aws-smithy-runtime-api/http-1x", + # for dvr + "dep:http-body-1x", + "aws-smithy-types/http-body-1-x", +] + +legacy-test-util = [ + "test-util", + "dep:http-02x", + "aws-smithy-runtime-api/http-02x" ] legacy-tls-rustls = ["dep:legacy-hyper-rustls", "dep:legacy-rustls", "hyper-014"] @@ -67,6 +76,7 @@ tracing = "0.1" hyper = { version = "1", features = ["client", "http1", "http2"], optional = true } hyper-util = { version = "0.1.7", optional = true } http-1x = { package = "http", version = "1" , optional = true } +http-body-1x = { package = "http-body", version = "1", optional = true} hyper-rustls = { version = "0.27", features = ["http2", "http1", "native-tokio", "tls12"], default-features = false, optional = true } rustls = { version = "0.23", default-features = false, optional = true } tower = { version = "0.5.1", optional = true } diff --git a/rust-runtime/aws-smithy-http-client/src/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs index 4d8f2eff7a..e5aaf31486 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -55,5 +55,6 @@ pub use never::NeverClient; #[cfg(any(feature = "hyper-014", feature = "hyper-1"))] pub use never::NeverTcpConnector; +mod body; #[cfg(all(feature = "hyper-014", feature = "wire-mock"))] pub mod wire; diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/body.rs b/rust-runtime/aws-smithy-http-client/src/test_util/body.rs new file mode 100644 index 0000000000..031e1a7904 --- /dev/null +++ b/rust-runtime/aws-smithy-http-client/src/test_util/body.rs @@ -0,0 +1,95 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +use aws_smithy_runtime_api::box_error::BoxError; +use aws_smithy_types::body::SdkBody; +use bytes::Bytes; +use http_body_1x::{Frame, SizeHint}; +use pin_project_lite::pin_project; +use std::future::poll_fn; +use std::pin::{pin, Pin}; +use std::task::{Context, Poll}; +use tokio::sync::mpsc; + +/// Create a `SdkBody` with an associated sender half. +/// +/// Useful for sending data from another thread/task and test scenarios. +pub(crate) fn channel_body() -> (Sender, SdkBody) { + let (tx, rx) = mpsc::channel(1); + let sender = Sender { tx }; + let ch_body = ChannelBody { rx }; + (sender, SdkBody::from_body_1_x(ch_body)) +} + +/// Sender half of channel based `SdkBody` implementation useful for testing. +/// +/// Roughly a replacement for hyper 0.14.x `Sender` body. +/// +/// ## Body Closing +/// +/// The request body will always be closed normally when the sender is dropped. If you +/// want to close the connection with an incomplete response, call [`Sender::abort()`] method to +/// abort the body in an abnormal fashion. +#[derive(Debug)] +pub(crate) struct Sender { + tx: mpsc::Sender, BoxError>>, +} + +impl Sender { + /// Send data on data channel when it's ready + pub(crate) async fn send_data(&mut self, chunk: Bytes) -> Result<(), BoxError> { + let frame = Frame::data(chunk); + self.tx.send(Ok(frame)).await.map_err(|e| e.into()) + } + + // TODO(test-utils): we can add support for trailers if needed in the future + + /// Abort the body in an abnormal fashion + pub(crate) fn abort(self) { + let _ = self.tx.clone().try_send(Err("body write aborted".into())); + } +} + +pin_project! { + struct ChannelBody { + rx: mpsc::Receiver, BoxError>> + } +} + +impl http_body_1x::Body for ChannelBody { + type Data = Bytes; + type Error = BoxError; + + fn poll_frame( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll, Self::Error>>> { + let this = self.project(); + this.rx.poll_recv(cx) + } + + fn is_end_stream(&self) -> bool { + self.rx.is_closed() + } + + fn size_hint(&self) -> SizeHint { + SizeHint::default() + } +} + +pub(crate) async fn next_data_frame(body: &mut SdkBody) -> Option> { + use http_body_1x::Body; + let mut pinned = pin!(body); + match poll_fn(|cx| pinned.as_mut().poll_frame(cx)).await? { + Ok(frame) => { + if frame.is_data() { + Some(Ok(frame.into_data().unwrap())) + } else { + None + } + } + Err(err) => Some(Err(err)), + } +} diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs index dccdd513fa..57d8e3184a 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs @@ -129,11 +129,11 @@ mod test { use aws_smithy_runtime_api::client::orchestrator::HttpRequest; use aws_smithy_types::body::SdkBody; - #[cfg(feature = "hyper-014")] + #[cfg(feature = "legacy-test-util")] #[tokio::test] async fn test_can_plug_in_http_02x() { use super::capture_request; - let (capture_client, request) = capture_request(Some( + let (capture_client, _request) = capture_request(Some( http_02x::Response::builder() .status(202) .body(SdkBody::empty()) @@ -147,7 +147,7 @@ mod test { #[tokio::test] async fn test_can_plug_in_http_1x() { use super::capture_request; - let (capture_client, request) = capture_request(Some( + let (capture_client, _request) = capture_request(Some( http_1x::Response::builder() .status(202) .body(SdkBody::empty()) diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/dvr.rs b/rust-runtime/aws-smithy-http-client/src/test_util/dvr.rs index 181c340902..e0fd982d6d 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/dvr.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/dvr.rs @@ -128,6 +128,7 @@ pub struct Response { headers: IndexMap>, } +#[cfg(feature = "legacy-test-util")] impl From<&Request> for http_02x::Request<()> { fn from(request: &Request) -> Self { let mut builder = http_02x::Request::builder().uri(request.uri.as_str()); @@ -140,6 +141,18 @@ impl From<&Request> for http_02x::Request<()> { } } +impl From<&Request> for http_1x::Request<()> { + fn from(request: &Request) -> Self { + let mut builder = http_1x::Request::builder().uri(request.uri.as_str()); + for (k, values) in request.headers.iter() { + for v in values { + builder = builder.header(k, v); + } + } + builder.method(request.method.as_str()).body(()).unwrap() + } +} + impl<'a> From<&'a HttpRequest> for Request { fn from(req: &'a HttpRequest) -> Self { let uri = req.uri().to_string(); @@ -162,7 +175,7 @@ fn headers_to_map_http(headers: &Headers) -> IndexMap> { out } -fn headers_to_map_02x(headers: &http_02x::HeaderMap) -> IndexMap> { +fn headers_to_map(headers: &Headers) -> IndexMap> { let mut out: IndexMap<_, Vec<_>> = IndexMap::new(); for (header_name, header_value) in headers.iter() { let entry = out.entry(header_name.to_string()).or_default(); @@ -175,7 +188,8 @@ fn headers_to_map_02x(headers: &http_02x::HeaderMap) -> IndexMap IndexMap> { +#[cfg(feature = "legacy-test-util")] +fn headers_to_map_02x(headers: &http_02x::HeaderMap) -> IndexMap> { let mut out: IndexMap<_, Vec<_>> = IndexMap::new(); for (header_name, header_value) in headers.iter() { let entry = out.entry(header_name.to_string()).or_default(); @@ -188,6 +202,7 @@ fn headers_to_map(headers: &Headers) -> IndexMap> { out } +#[cfg(feature = "legacy-test-util")] impl<'a, B> From<&'a http_02x::Response> for Response { fn from(resp: &'a http_02x::Response) -> Self { let status = resp.status().as_u16(); @@ -196,6 +211,27 @@ impl<'a, B> From<&'a http_02x::Response> for Response { } } +fn headers_to_map_1x(headers: &http_1x::HeaderMap) -> IndexMap> { + let mut out: IndexMap<_, Vec<_>> = IndexMap::new(); + for (header_name, header_value) in headers.iter() { + let entry = out.entry(header_name.to_string()).or_default(); + entry.push( + std::str::from_utf8(header_value.as_ref()) + .unwrap() + .to_string(), + ); + } + out +} + +impl<'a, B> From<&'a http_1x::Response> for Response { + fn from(resp: &'a http_1x::Response) -> Self { + let status = resp.status().as_u16(); + let headers = headers_to_map_1x(resp.headers()); + Self { status, headers } + } +} + impl From<&HttpResponse> for Response { fn from(resp: &HttpResponse) -> Self { Self { @@ -343,6 +379,7 @@ mod tests { Ok(()) } + #[cfg(feature = "legacy-test-util")] #[tokio::test] async fn turtles_all_the_way_down() -> Result<(), Box> { // create a replaying connection from a recording, wrap a recording connection around it, diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/dvr/record.rs b/rust-runtime/aws-smithy-http-client/src/test_util/dvr/record.rs index 51e4619f37..7f5fb1dc4b 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/dvr/record.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/dvr/record.rs @@ -15,7 +15,6 @@ use aws_smithy_runtime_api::client::orchestrator::HttpRequest; use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents; use aws_smithy_runtime_api::shared::IntoShared; use aws_smithy_types::body::SdkBody; -use http_body_04x::Body; use std::path::Path; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex, MutexGuard}; @@ -74,12 +73,12 @@ pub struct RecordingClient { pub(crate) inner: SharedHttpConnector, } -#[cfg(feature = "tls-rustls")] +#[cfg(feature = "legacy-tls-rustls")] impl RecordingClient { /// Construct a recording connection wrapping a default HTTPS implementation without any timeouts. pub fn https() -> Self { #[allow(deprecated)] - use crate::client::http::hyper_014::HyperConnector; + use crate::hyper_014::HyperConnector; Self { data: Default::default(), num_events: Arc::new(AtomicUsize::new(0)), @@ -132,13 +131,13 @@ fn record_body( direction: Direction, event_bus: Arc>>, ) -> JoinHandle<()> { - let (sender, output_body) = hyper_0_14::Body::channel(); - let real_body = std::mem::replace(body, SdkBody::from_body_0_4(output_body)); + let (sender, output_body) = crate::test_util::body::channel_body(); + let real_body = std::mem::replace(body, output_body); tokio::spawn(async move { let mut real_body = real_body; let mut sender = sender; loop { - let data = real_body.data().await; + let data = crate::test_util::body::next_data_frame(&mut real_body).await; match data { Some(Ok(data)) => { event_bus.lock().unwrap().push(Event { diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/dvr/replay.rs b/rust-runtime/aws-smithy-http-client/src/test_util/dvr/replay.rs index 8e6eceeb94..cca272a81c 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/dvr/replay.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/dvr/replay.rs @@ -55,9 +55,9 @@ impl Waitable { #[derive(Clone)] pub struct ReplayingClient { live_events: Arc>>>, - verifiable_events: Arc>>, + verifiable_events: Arc>>, num_events: Arc, - recorded_requests: Arc>>>>, + recorded_requests: Arc>>>>, } // Ideally, this would just derive Debug, but that makes the tests in aws-config think they found AWS secrets @@ -207,6 +207,7 @@ impl ReplayingClient { } /// Return all the recorded requests for further analysis + #[cfg(feature = "legacy-test-util")] pub async fn take_requests(self) -> Vec> { let mut recorded_requests = std::mem::take(self.recorded_requests.lock().unwrap().deref_mut()); @@ -220,7 +221,17 @@ impl ReplayingClient { .await, ) } - out + out.into_iter() + .map(|v1r| { + let mut builder = http_02x::Request::builder() + .uri(v1r.uri().to_string()) + .method(v1r.method().as_str()); + for (k, v) in v1r.headers().iter() { + builder = builder.header(k.as_str(), v.as_bytes()) + } + builder.body(v1r.into_body()).expect("valid conversion") + }) + .collect() } /// Build a replay connection from a JSON file @@ -253,7 +264,7 @@ impl ReplayingClient { let initial_request = events.iter().next().expect("must have one event"); let request = match &initial_request.action { Action::Request { request } => { - http_02x::Request::from(request).map(|_| Bytes::from(body)) + http_1x::Request::from(request).map(|_| Bytes::from(body)) } _ => panic!("invalid first event"), }; @@ -271,7 +282,7 @@ impl ReplayingClient { } } -async fn replay_body(events: VecDeque, mut sender: hyper_0_14::body::Sender) { +async fn replay_body(events: VecDeque, mut sender: crate::test_util::body::Sender) { for event in events { match event.action { Action::Request { .. } => panic!(), @@ -315,8 +326,6 @@ async fn replay_body(events: VecDeque, mut sender: hyper_0_14::body::Send impl HttpConnector for ReplayingClient { fn call(&self, mut request: HttpRequest) -> HttpConnectorFuture { - use http_body_04x::Body; - let event_id = self.next_id(); tracing::debug!("received event {}: {request:?}", event_id.0); let mut events = match self.live_events.lock().unwrap().remove(&event_id) { @@ -330,17 +339,17 @@ impl HttpConnector for ReplayingClient { }; let _initial_request = events.pop_front().unwrap(); - let (sender, response_body) = hyper_0_14::Body::channel(); - let body = SdkBody::from_body_0_4(response_body); + let (sender, body) = crate::test_util::body::channel_body(); let recording = self.recorded_requests.clone(); let recorded_request = tokio::spawn(async move { let mut data_read = vec![]; - while let Some(data) = request.body_mut().data().await { + while let Some(data) = crate::test_util::body::next_data_frame(request.body_mut()).await + { data_read .extend_from_slice(data.expect("in memory request should not fail").as_ref()) } request - .try_into_http02x() + .try_into_http1x() .unwrap() .map(|_body| Bytes::from(data_read)) }); @@ -366,7 +375,7 @@ impl HttpConnector for ReplayingClient { Action::Response { response: Ok(response), } => { - let mut builder = http_02x::Response::builder().status(response.status); + let mut builder = http_1x::Response::builder().status(response.status); for (name, values) in response.headers { for value in values { builder = builder.header(&name, &value); From df2eb4260d97e5216b4a642b89753f8361ca707d Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Thu, 17 Oct 2024 10:44:37 -0400 Subject: [PATCH 05/13] duplicate infallible --- .../aws-smithy-http-client/src/test_util.rs | 4 + .../src/test_util/infallible.rs | 11 +-- .../src/test_util/legacy_infallible.rs | 83 +++++++++++++++++++ 3 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 rust-runtime/aws-smithy-http-client/src/test_util/legacy_infallible.rs diff --git a/rust-runtime/aws-smithy-http-client/src/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs index e5aaf31486..d79f6905e8 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -49,6 +49,10 @@ pub use replay::{ReplayEvent, StaticReplayClient}; mod infallible; pub use infallible::infallible_client_fn; +#[allow(missing_docs)] +#[cfg(feature = "legacy-test-util")] +pub mod legacy_infallible; + mod never; pub use never::NeverClient; diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/infallible.rs b/rust-runtime/aws-smithy-http-client/src/test_util/infallible.rs index 09b2cde4ee..a978962c21 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/infallible.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/infallible.rs @@ -21,11 +21,12 @@ use std::sync::Arc; /// # Examples /// /// ```rust +/// # use http_1x as http; /// use aws_smithy_http_client::test_util::infallible_client_fn; -/// let http_client = infallible_client_fn(|_req| http_02x::Response::builder().status(200).body("OK!").unwrap()); +/// let http_client = infallible_client_fn(|_req| http::Response::builder().status(200).body("OK!").unwrap()); /// ``` pub fn infallible_client_fn( - f: impl Fn(http_02x::Request) -> http_02x::Response + Send + Sync + 'static, + f: impl Fn(http_1x::Request) -> http_1x::Response + Send + Sync + 'static, ) -> SharedHttpClient where B: Into, @@ -37,7 +38,7 @@ where struct InfallibleClientFn { #[allow(clippy::type_complexity)] response: Arc< - dyn Fn(http_02x::Request) -> Result, ConnectorError> + dyn Fn(http_1x::Request) -> Result, ConnectorError> + Send + Sync, >, @@ -51,7 +52,7 @@ impl fmt::Debug for InfallibleClientFn { impl InfallibleClientFn { fn new>( - f: impl Fn(http_02x::Request) -> http_02x::Response + Send + Sync + 'static, + f: impl Fn(http_1x::Request) -> http_1x::Response + Send + Sync + 'static, ) -> Self { Self { response: Arc::new(move |request| Ok(f(request).map(|b| b.into()))), @@ -62,7 +63,7 @@ impl InfallibleClientFn { impl HttpConnector for InfallibleClientFn { fn call(&self, request: HttpRequest) -> HttpConnectorFuture { HttpConnectorFuture::ready( - (self.response)(request.try_into_http02x().unwrap()) + (self.response)(request.try_into_http1x().unwrap()) .map(|res| HttpResponse::try_from(res).unwrap()), ) } diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/legacy_infallible.rs b/rust-runtime/aws-smithy-http-client/src/test_util/legacy_infallible.rs new file mode 100644 index 0000000000..a96488714e --- /dev/null +++ b/rust-runtime/aws-smithy-http-client/src/test_util/legacy_infallible.rs @@ -0,0 +1,83 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +use aws_smithy_runtime_api::client::connector_metadata::ConnectorMetadata; +use aws_smithy_runtime_api::client::http::{ + HttpClient, HttpConnector, HttpConnectorFuture, HttpConnectorSettings, SharedHttpClient, + SharedHttpConnector, +}; +use aws_smithy_runtime_api::client::orchestrator::{HttpRequest, HttpResponse}; +use aws_smithy_runtime_api::client::result::ConnectorError; +use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents; +use aws_smithy_runtime_api::shared::IntoShared; +use aws_smithy_types::body::SdkBody; +use std::fmt; +use std::sync::Arc; + +/// Create a [`SharedHttpClient`] from `Fn(http:Request) -> http::Response` +/// +/// # Examples +/// +/// ```rust +/// use aws_smithy_http_client::test_util::legacy_infallible::infallible_client_fn; +/// let http_client = infallible_client_fn(|_req| http_02x::Response::builder().status(200).body("OK!").unwrap()); +/// ``` +pub fn infallible_client_fn( + f: impl Fn(http_02x::Request) -> http_02x::Response + Send + Sync + 'static, +) -> SharedHttpClient +where + B: Into, +{ + InfallibleClientFn::new(f).into_shared() +} + +#[derive(Clone)] +struct InfallibleClientFn { + #[allow(clippy::type_complexity)] + response: Arc< + dyn Fn(http_02x::Request) -> Result, ConnectorError> + + Send + + Sync, + >, +} + +impl fmt::Debug for InfallibleClientFn { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("InfallibleClientFn").finish() + } +} + +impl InfallibleClientFn { + fn new>( + f: impl Fn(http_02x::Request) -> http_02x::Response + Send + Sync + 'static, + ) -> Self { + Self { + response: Arc::new(move |request| Ok(f(request).map(|b| b.into()))), + } + } +} + +impl HttpConnector for InfallibleClientFn { + fn call(&self, request: HttpRequest) -> HttpConnectorFuture { + HttpConnectorFuture::ready( + (self.response)(request.try_into_http02x().unwrap()) + .map(|res| HttpResponse::try_from(res).unwrap()), + ) + } +} + +impl HttpClient for InfallibleClientFn { + fn http_connector( + &self, + _: &HttpConnectorSettings, + _: &RuntimeComponents, + ) -> SharedHttpConnector { + self.clone().into_shared() + } + + fn connector_metadata(&self) -> Option { + Some(ConnectorMetadata::new("infallible-client", None)) + } +} From 301a36b4c1b76f28f23a6a42d47af60fc26aed48 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Fri, 18 Oct 2024 11:01:45 -0400 Subject: [PATCH 06/13] refactor wire capture client to hyper1 stack --- rust-runtime/Cargo.lock | 2 + .../aws-smithy-http-client/Cargo.toml | 11 +- .../aws-smithy-http-client/src/test_util.rs | 3 +- .../src/test_util/capture_request.rs | 4 +- .../src/test_util/wire.rs | 167 ++++++++++++------ 5 files changed, 123 insertions(+), 64 deletions(-) diff --git a/rust-runtime/Cargo.lock b/rust-runtime/Cargo.lock index 14adf6f384..f9c6bb4b3f 100644 --- a/rust-runtime/Cargo.lock +++ b/rust-runtime/Cargo.lock @@ -473,6 +473,7 @@ dependencies = [ "http 1.1.0", "http-body 0.4.6", "http-body 1.0.1", + "http-body-util", "hyper 0.14.30", "hyper 1.4.1", "hyper-rustls 0.24.2", @@ -1901,6 +1902,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", diff --git a/rust-runtime/aws-smithy-http-client/Cargo.toml b/rust-runtime/aws-smithy-http-client/Cargo.toml index 10b5d69341..3806fc04ca 100644 --- a/rust-runtime/aws-smithy-http-client/Cargo.toml +++ b/rust-runtime/aws-smithy-http-client/Cargo.toml @@ -28,9 +28,13 @@ hyper-1 = [ wire-mock = [ "test-util", - # FIXME - replace/deprecate - "hyper-014", - "hyper-0-14?/server", + "hyper-1", + "hyper-util?/server", + "hyper-util?/server-auto", + "hyper-util?/service", + "hyper-util?/server-graceful", + "tokio/macros", + "dep:http-body-util", ] test-util = [ @@ -95,6 +99,7 @@ bytes = { version = "1", optional = true } serde = { version = "1.0.210", features = ["derive"], optional = true } serde_json = { version = "1.0.128", features = ["preserve_order"], optional = true } indexmap = { version = "2.6.0", features = ["serde"], optional = true } +http-body-util = { version = "0.1.2", optional = true } # end test util stack [dev-dependencies] diff --git a/rust-runtime/aws-smithy-http-client/src/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs index d79f6905e8..ffb0e50d09 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -49,6 +49,7 @@ pub use replay::{ReplayEvent, StaticReplayClient}; mod infallible; pub use infallible::infallible_client_fn; +// infallible based on http_02x stack had to be duplicated to avoid breaking API changes #[allow(missing_docs)] #[cfg(feature = "legacy-test-util")] pub mod legacy_infallible; @@ -60,5 +61,5 @@ pub use never::NeverClient; pub use never::NeverTcpConnector; mod body; -#[cfg(all(feature = "hyper-014", feature = "wire-mock"))] +#[cfg(all(feature = "hyper-1", feature = "wire-mock"))] pub mod wire; diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs index 57d8e3184a..222c6594a7 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs @@ -35,9 +35,7 @@ impl HttpConnector for CaptureRequestHandler { HttpConnectorFuture::ready(Ok(inner .response .take() - .expect("could not handle second request") - .try_into() - .unwrap())) + .expect("could not handle second request"))) } } diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs index ce55b8bd01..0e997fa226 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs @@ -39,23 +39,24 @@ #![allow(missing_docs)] -#[allow(deprecated)] -use crate::hyper_014::HyperClientBuilder; use aws_smithy_async::future::never::Never; use aws_smithy_async::future::BoxFuture; use aws_smithy_runtime_api::client::http::SharedHttpClient; use bytes::Bytes; -use hyper_0_14::client::connect::dns::Name; -use hyper_0_14::server::conn::AddrStream; -use hyper_0_14::service::{make_service_fn, service_fn, Service}; +use http_body_util::Full; +use hyper::service::service_fn; +use hyper_util::client::legacy::connect::dns::Name; +use hyper_util::rt::{TokioExecutor, TokioIo}; +use hyper_util::server::graceful::{GracefulConnection, GracefulShutdown}; use std::collections::HashSet; use std::convert::Infallible; use std::error::Error; +use std::future::Future; use std::iter::Once; -use std::net::{SocketAddr, TcpListener}; +use std::net::SocketAddr; use std::sync::{Arc, Mutex}; use std::task::{Context, Poll}; -use tokio::spawn; +use tokio::net::TcpListener; use tokio::sync::oneshot; /// An event recorded by [`WireMockServer`]. @@ -144,7 +145,6 @@ macro_rules! ev { }; } -use aws_smithy_runtime_api::shared::IntoShared; pub use {ev, match_events, matcher}; #[non_exhaustive] @@ -194,11 +194,40 @@ pub struct WireMockServer { shutdown_hook: oneshot::Sender<()>, } +#[derive(Debug, Clone)] +struct SharedGraceful { + graceful: Arc>>, +} + +impl SharedGraceful { + fn new() -> Self { + Self { + graceful: Arc::new(Mutex::new(Some(GracefulShutdown::new()))), + } + } + + fn watch(&self, conn: C) -> impl Future { + let graceful = self.graceful.lock().unwrap(); + graceful + .as_ref() + .expect("graceful not shutdown") + .watch(conn) + } + + async fn shutdown(&self) { + let graceful = { self.graceful.lock().unwrap().take() }; + + if let Some(graceful) = graceful { + graceful.shutdown().await; + } + } +} + impl WireMockServer { /// Start a wire mock server with the given events to replay. pub async fn start(mut response_events: Vec) -> Self { - let listener = TcpListener::bind("127.0.0.1:0").unwrap(); - let (tx, rx) = oneshot::channel(); + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + let (tx, mut rx) = oneshot::channel(); let listener_addr = listener.local_addr().unwrap(); response_events.reverse(); let response_events = Arc::new(Mutex::new(response_events)); @@ -206,48 +235,74 @@ impl WireMockServer { let wire_events = Arc::new(Mutex::new(vec![])); let wire_log_for_service = wire_events.clone(); let poisoned_conns: Arc>> = Default::default(); - let make_service = make_service_fn(move |connection: &AddrStream| { + let graceful = SharedGraceful::new(); + let conn_builder = Arc::new(hyper_util::server::conn::auto::Builder::new( + TokioExecutor::new(), + )); + + let server = async move { let poisoned_conns = poisoned_conns.clone(); let events = handler_events.clone(); let wire_log = wire_log_for_service.clone(); - let remote_addr = connection.remote_addr(); - tracing::info!("established connection: {:?}", connection); - wire_log.lock().unwrap().push(RecordedEvent::NewConnection); - async move { - Ok::<_, Infallible>(service_fn(move |_: http_02x::Request| { - if poisoned_conns.lock().unwrap().contains(&remote_addr) { - tracing::error!("poisoned connection {:?} was reused!", &remote_addr); - panic!("poisoned connection was reused!"); - } - let next_event = events.clone().lock().unwrap().pop(); - let wire_log = wire_log.clone(); - let poisoned_conns = poisoned_conns.clone(); - async move { - let next_event = next_event - .unwrap_or_else(|| panic!("no more events! Log: {:?}", wire_log)); - wire_log - .lock() - .unwrap() - .push(RecordedEvent::Response(next_event.clone())); - if next_event == ReplayedEvent::Timeout { - tracing::info!("{} is poisoned", remote_addr); - poisoned_conns.lock().unwrap().insert(remote_addr); - } - tracing::debug!("replying with {:?}", next_event); - let event = generate_response_event(next_event).await; - dbg!(event) + loop { + tokio::select! { + Ok((stream, remote_addr)) = listener.accept() => { + tracing::info!("established connection: {:?}", remote_addr); + let poisoned_conns = poisoned_conns.clone(); + let events = events.clone(); + let wire_log = wire_log.clone(); + wire_log.lock().unwrap().push(RecordedEvent::NewConnection); + let io = TokioIo::new(stream); + + let svc = service_fn(move |_req| { + let poisoned_conns = poisoned_conns.clone(); + let events = events.clone(); + let wire_log = wire_log.clone(); + async move { + if poisoned_conns.lock().unwrap().contains(&remote_addr) { + tracing::error!("poisoned connection {:?} was reused!", &remote_addr); + panic!("poisoned connection was reused!"); + } + let next_event = events.clone().lock().unwrap().pop(); + let next_event = next_event + .unwrap_or_else(|| panic!("no more events! Log: {:?}", wire_log)); + + wire_log + .lock() + .unwrap() + .push(RecordedEvent::Response(next_event.clone())); + + if next_event == ReplayedEvent::Timeout { + tracing::info!("{} is poisoned", remote_addr); + poisoned_conns.lock().unwrap().insert(remote_addr); + } + tracing::debug!("replying with {:?}", next_event); + let event = generate_response_event(next_event).await; + dbg!(event) + } + }); + + let conn_builder = conn_builder.clone(); + let graceful = graceful.clone(); + tokio::spawn(async move { + let conn = conn_builder.serve_connection(io, svc); + let fut = graceful.watch(conn); + if let Err(e) = fut.await { + panic!("Error serving connection: {:?}", e); + } + }); + }, + _ = &mut rx => { + tracing::info!("wire server: shutdown signalled"); + graceful.shutdown().await; + tracing::info!("wire server: shutdown complete!"); + break; } - })) + } } - }); - let server = hyper_0_14::Server::from_tcp(listener) - .unwrap() - .serve(make_service) - .with_graceful_shutdown(async { - rx.await.ok(); - tracing::info!("server shutdown!"); - }); - spawn(server); + }; + + tokio::spawn(server); Self { event_log: wire_events, bind_addr: listener_addr, @@ -277,12 +332,10 @@ impl WireMockServer { /// /// **Note**: This must be used in tandem with [`Self::dns_resolver`] pub fn http_client(&self) -> SharedHttpClient { - #[allow(deprecated)] - HyperClientBuilder::new() - .build(hyper_0_14::client::HttpConnector::new_with_resolver( - self.dns_resolver(), - )) - .into_shared() + let resolver = self.dns_resolver(); + crate::hyper_1::build_with_fn(None, move || { + hyper_util::client::legacy::connect::HttpConnector::new_with_resolver(resolver.clone()) + }) } /// Endpoint to use when connecting @@ -303,11 +356,11 @@ impl WireMockServer { async fn generate_response_event( event: ReplayedEvent, -) -> Result, Infallible> { +) -> Result>, Infallible> { let resp = match event { - ReplayedEvent::HttpResponse { status, body } => http_02x::Response::builder() + ReplayedEvent::HttpResponse { status, body } => http_1x::Response::builder() .status(status) - .body(hyper_0_14::Body::from(body)) + .body(Full::new(body)) .unwrap(), ReplayedEvent::Timeout => { Never::new().await; @@ -326,7 +379,7 @@ pub struct LoggingDnsResolver { socket_addr: SocketAddr, } -impl Service for LoggingDnsResolver { +impl tower::Service for LoggingDnsResolver { type Response = Once; type Error = Infallible; type Future = BoxFuture<'static, Self::Response, Self::Error>; From 240cef93c606f864b640779187f9644a28bc8c1f Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 21 Oct 2024 15:50:58 -0400 Subject: [PATCH 07/13] re-export legacy http test utils from smithy runtime --- aws/rust-runtime/Cargo.lock | 46 +++---- aws/rust-runtime/aws-config/Cargo.lock | 50 ++++---- aws/sdk/Cargo.lock | 114 +++++++++--------- .../no-default-features/Cargo.toml | 2 +- rust-runtime/Cargo.lock | 114 +++++++++--------- .../aws-smithy-http-client/Cargo.toml | 4 + .../aws-smithy-http-client/src/test_util.rs | 3 + .../src/test_util/capture_request.rs | 10 +- .../src/test_util/wire.rs | 27 ++++- rust-runtime/aws-smithy-runtime/Cargo.toml | 17 +-- .../aws-smithy-runtime/src/client/http.rs | 33 ++++- rust-runtime/aws-smithy-runtime/src/lib.rs | 8 ++ 12 files changed, 246 insertions(+), 182 deletions(-) diff --git a/aws/rust-runtime/Cargo.lock b/aws/rust-runtime/Cargo.lock index 4c05d84e6c..64d004222a 100644 --- a/aws/rust-runtime/Cargo.lock +++ b/aws/rust-runtime/Cargo.lock @@ -69,7 +69,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -529,9 +529,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -1146,9 +1146,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -1257,9 +1257,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libfuzzer-sys" @@ -1607,9 +1607,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -1991,14 +1991,14 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -2122,9 +2122,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -2161,7 +2161,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2255,7 +2255,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2306,7 +2306,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2366,7 +2366,7 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2433,9 +2433,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "valuable" @@ -2511,7 +2511,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-shared", ] @@ -2533,7 +2533,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2703,7 +2703,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] diff --git a/aws/rust-runtime/aws-config/Cargo.lock b/aws/rust-runtime/aws-config/Cargo.lock index 4c969b87a1..afb58fbf56 100644 --- a/aws/rust-runtime/aws-config/Cargo.lock +++ b/aws/rust-runtime/aws-config/Cargo.lock @@ -230,16 +230,23 @@ name = "aws-smithy-http-client" version = "1.0.0" dependencies = [ "aws-smithy-async", + "aws-smithy-protocol-test", "aws-smithy-runtime-api", "aws-smithy-types", + "bytes", "h2 0.4.6", "http 0.2.12", + "http 1.1.0", "http-body 0.4.6", + "http-body 1.0.1", "hyper", "hyper-rustls", + "indexmap", "once_cell", "pin-project-lite", "rustls", + "serde", + "serde_json", "tokio", "tracing", ] @@ -283,7 +290,6 @@ dependencies = [ "aws-smithy-async", "aws-smithy-http", "aws-smithy-http-client", - "aws-smithy-protocol-test", "aws-smithy-runtime-api", "aws-smithy-types", "bytes", @@ -292,13 +298,9 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper", - "indexmap", "once_cell", "pin-project-lite", "pin-utils", - "serde", - "serde_json", "tokio", "tracing", "tracing-subscriber", @@ -451,9 +453,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "shlex", ] @@ -829,9 +831,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -903,9 +905,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "lock_api" @@ -1146,9 +1148,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -1386,14 +1388,14 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "indexmap", "itoa", @@ -1487,9 +1489,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -1513,7 +1515,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1597,7 +1599,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1648,7 +1650,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1721,7 +1723,7 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1782,9 +1784,9 @@ checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "valuable" diff --git a/aws/sdk/Cargo.lock b/aws/sdk/Cargo.lock index d87a4c5dbe..8095f1c3f0 100644 --- a/aws/sdk/Cargo.lock +++ b/aws/sdk/Cargo.lock @@ -295,7 +295,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -312,7 +312,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -904,9 +904,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.56.0" +version = "1.57.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "cecd672c8d4265fd4fbecacd4a479180e616881bbe639250cf81ddb604e4c301" +checksum = "8888c238bf93c77c5df8274b3999fd7fc1bb3fb658616f40dfde9e4fcd9efd94" dependencies = [ "ahash", "aws-credential-types 1.2.1 (registry+/~https://github.com/rust-lang/crates.io-index)", @@ -1107,7 +1107,7 @@ dependencies = [ "futures-util", "hound", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "once_cell", "regex-lite", "serde_json", @@ -1326,7 +1326,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "once_cell", "percent-encoding", "pin-project-lite", @@ -1366,21 +1366,28 @@ name = "aws-smithy-http-client" version = "1.0.0" dependencies = [ "aws-smithy-async 1.2.1", + "aws-smithy-protocol-test 0.63.0", "aws-smithy-runtime-api 1.7.3", "aws-smithy-types 1.2.7", + "bytes", "h2 0.4.6", "http 0.2.12", "http 1.1.0", "http-body 0.4.6", - "hyper 0.14.30", - "hyper 1.4.1", + "http-body 1.0.1", + "http-body-util", + "hyper 0.14.31", + "hyper 1.5.0", "hyper-rustls 0.24.2", "hyper-rustls 0.27.3", "hyper-util", + "indexmap", "once_cell", "pin-project-lite", "rustls 0.21.12", - "rustls 0.23.14", + "rustls 0.23.15", + "serde", + "serde_json", "tokio", "tower", "tracing", @@ -1412,7 +1419,7 @@ dependencies = [ name = "aws-smithy-mocks-experimental" version = "0.2.1" dependencies = [ - "aws-sdk-s3 1.56.0", + "aws-sdk-s3 1.57.0", "aws-smithy-runtime-api 1.7.3", "aws-smithy-types 1.2.7", "tokio", @@ -1480,7 +1487,7 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", "indexmap", "once_cell", @@ -1502,7 +1509,6 @@ dependencies = [ "aws-smithy-async 1.2.1", "aws-smithy-http 0.60.11", "aws-smithy-http-client", - "aws-smithy-protocol-test 0.63.0", "aws-smithy-runtime-api 1.7.3", "aws-smithy-types 1.2.7", "bytes", @@ -1513,15 +1519,12 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", - "indexmap", "once_cell", "pin-project-lite", "pin-utils", "pretty_assertions", - "serde", - "serde_json", "tokio", "tracing", "tracing-subscriber", @@ -1577,7 +1580,7 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "http-body-util", - "hyper 0.14.30", + "hyper 0.14.31", "itoa", "lazy_static", "num-integer", @@ -1764,7 +1767,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.79", + "syn 2.0.82", "which", ] @@ -1881,9 +1884,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -2194,7 +2197,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2443,7 +2446,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2719,9 +2722,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -2743,9 +2746,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -2754,6 +2757,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -2769,7 +2773,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -2786,9 +2790,9 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", @@ -2807,7 +2811,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.4.1", + "hyper 1.5.0", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -2932,9 +2936,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libfuzzer-sys" @@ -3046,7 +3050,7 @@ checksum = "bd2209fff77f705b00c737016a48e73733d7fbccb8b007194db148f03561fb70" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3358,12 +3362,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.24" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" dependencies = [ "proc-macro2", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3392,9 +3396,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -3649,9 +3653,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.14" +version = "0.23.15" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "aws-lc-rs", "once_cell", @@ -3851,14 +3855,14 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "indexmap", "itoa", @@ -4010,9 +4014,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -4049,7 +4053,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -4144,7 +4148,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -4163,7 +4167,7 @@ version = "0.26.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pki-types", "tokio", ] @@ -4258,7 +4262,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -4331,7 +4335,7 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -4404,9 +4408,9 @@ checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "valuable" @@ -4503,7 +4507,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-shared", ] @@ -4537,7 +4541,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4794,7 +4798,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] diff --git a/aws/sdk/integration-tests/no-default-features/Cargo.toml b/aws/sdk/integration-tests/no-default-features/Cargo.toml index 9ed56d6c09..5c3d43ba16 100644 --- a/aws/sdk/integration-tests/no-default-features/Cargo.toml +++ b/aws/sdk/integration-tests/no-default-features/Cargo.toml @@ -17,7 +17,7 @@ publish = false aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false } aws-sdk-s3 = { path = "../../build/aws-sdk/sdk/s3", default-features = false } aws-smithy-async = { path = "../../build/aws-sdk/sdk/aws-smithy-async" } -aws-smithy-runtime= { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["test-util"] } +aws-smithy-runtime = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["test-util"] } aws-credential-types = { path = "../../build/aws-sdk/sdk/aws-credential-types", features = ["test-util"] } futures = "0.3.25" tokio = { version = "1.23.1", features = ["full", "test-util"] } diff --git a/rust-runtime/Cargo.lock b/rust-runtime/Cargo.lock index f9c6bb4b3f..a69597a340 100644 --- a/rust-runtime/Cargo.lock +++ b/rust-runtime/Cargo.lock @@ -112,7 +112,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -221,9 +221,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.56.0" +version = "1.57.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "cecd672c8d4265fd4fbecacd4a479180e616881bbe639250cf81ddb604e4c301" +checksum = "8888c238bf93c77c5df8274b3999fd7fc1bb3fb658616f40dfde9e4fcd9efd94" dependencies = [ "ahash", "aws-credential-types", @@ -424,7 +424,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "once_cell", "percent-encoding", "pin-project-lite", @@ -474,8 +474,8 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "http-body-util", - "hyper 0.14.30", - "hyper 1.4.1", + "hyper 0.14.31", + "hyper 1.5.0", "hyper-rustls 0.24.2", "hyper-rustls 0.27.3", "hyper-util", @@ -483,7 +483,7 @@ dependencies = [ "once_cell", "pin-project-lite", "rustls 0.21.12", - "rustls 0.23.14", + "rustls 0.23.15", "serde", "serde_json", "tokio", @@ -505,7 +505,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "lambda_http", "mime", "nom", @@ -535,7 +535,7 @@ dependencies = [ "futures", "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", "lambda_http", "num_cpus", @@ -655,7 +655,7 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", "indexmap 2.6.0", "once_cell", @@ -677,7 +677,6 @@ dependencies = [ "aws-smithy-async 1.2.1", "aws-smithy-http 0.60.11", "aws-smithy-http-client", - "aws-smithy-protocol-test 0.63.0", "aws-smithy-runtime-api 1.7.3", "aws-smithy-types 1.2.7", "bytes", @@ -688,15 +687,12 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls 0.24.2", - "indexmap 2.6.0", "once_cell", "pin-project-lite", "pin-utils", "pretty_assertions", - "serde", - "serde_json", "tokio", "tracing", "tracing-subscriber", @@ -752,7 +748,7 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "http-body-util", - "hyper 0.14.30", + "hyper 0.14.31", "itoa", "lazy_static", "num-integer", @@ -943,7 +939,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.79", + "syn 2.0.82", "which", ] @@ -1050,9 +1046,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -1378,7 +1374,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1594,7 +1590,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1867,9 +1863,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -1891,9 +1887,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -1918,7 +1914,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -1934,9 +1930,9 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", - "rustls 0.23.14", + "rustls 0.23.15", "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", @@ -1955,7 +1951,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.4.1", + "hyper 1.5.0", "pin-project-lite", "socket2", "tokio", @@ -2100,7 +2096,7 @@ dependencies = [ "futures", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "lambda_runtime", "mime", "percent-encoding", @@ -2124,7 +2120,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "http-serde", - "hyper 0.14.30", + "hyper 0.14.31", "lambda_runtime_api_client", "serde", "serde_json", @@ -2142,7 +2138,7 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "690c5ae01f3acac8c9c3348b556fc443054e9b7f1deaf53e9ebab716282bf0ed" dependencies = [ "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "tokio", "tower-service", ] @@ -2161,9 +2157,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libloading" @@ -2270,7 +2266,7 @@ checksum = "bd2209fff77f705b00c737016a48e73733d7fbccb8b007194db148f03561fb70" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2499,7 +2495,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2579,12 +2575,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.24" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" dependencies = [ "proc-macro2", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2613,9 +2609,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -2982,9 +2978,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.14" +version = "0.23.15" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "aws-lc-rs", "once_cell", @@ -3184,14 +3180,14 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "indexmap 2.6.0", "itoa", @@ -3361,9 +3357,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -3421,7 +3417,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3497,7 +3493,7 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "81294c017957a1a69794f506723519255879e15a870507faf45dfed288b763dd" dependencies = [ "futures-util", - "hyper 0.14.30", + "hyper 0.14.31", "pin-project-lite", "thiserror", "tokio", @@ -3530,7 +3526,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3549,7 +3545,7 @@ version = "0.26.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.14", + "rustls 0.23.15", "rustls-pki-types", "tokio", ] @@ -3693,7 +3689,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3766,7 +3762,7 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3845,9 +3841,9 @@ checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", "rand", @@ -3936,7 +3932,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-shared", ] @@ -3958,7 +3954,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4152,7 +4148,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] diff --git a/rust-runtime/aws-smithy-http-client/Cargo.toml b/rust-runtime/aws-smithy-http-client/Cargo.toml index 3806fc04ca..db297a5336 100644 --- a/rust-runtime/aws-smithy-http-client/Cargo.toml +++ b/rust-runtime/aws-smithy-http-client/Cargo.toml @@ -24,6 +24,10 @@ hyper-1 = [ "hyper-util?/client-legacy", "dep:http-1x", "dep:tower", + + # FIXME - should not be needed in base http implementation, only for https and only for specific tls impl + "dep:rustls", + "dep:hyper-rustls", ] wire-mock = [ diff --git a/rust-runtime/aws-smithy-http-client/src/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs index ffb0e50d09..b0e1923802 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -40,6 +40,9 @@ Finally, for socket-level mocking, see the [`wire`] module. mod capture_request; pub use capture_request::{capture_request, CaptureRequestHandler, CaptureRequestReceiver}; +#[cfg(feature = "legacy-test-util")] +pub use capture_request::legacy_capture_request; + #[cfg(feature = "hyper-014")] pub mod dvr; diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs index 222c6594a7..eacf483db3 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/capture_request.rs @@ -104,7 +104,7 @@ pub fn capture_request( ) -> (CaptureRequestHandler, CaptureRequestReceiver) { let (tx, rx) = oneshot::channel(); let http_resp: HttpResponse = match response { - Some(resp) => resp.try_into().expect("valid HttpRequest"), + Some(resp) => resp.try_into().expect("valid HttpResponse"), None => http_1x::Response::builder() .status(200) .body(SdkBody::empty()) @@ -121,6 +121,14 @@ pub fn capture_request( ) } +#[allow(missing_docs)] +#[cfg(feature = "legacy-test-util")] +pub fn legacy_capture_request( + response: Option>, +) -> (CaptureRequestHandler, CaptureRequestReceiver) { + capture_request(response) +} + #[cfg(test)] mod test { use aws_smithy_runtime_api::client::http::HttpConnector; diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs index 0e997fa226..f7819779f2 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs @@ -258,12 +258,12 @@ impl WireMockServer { let poisoned_conns = poisoned_conns.clone(); let events = events.clone(); let wire_log = wire_log.clone(); + if poisoned_conns.lock().unwrap().contains(&remote_addr) { + tracing::error!("poisoned connection {:?} was reused!", &remote_addr); + panic!("poisoned connection was reused!"); + } + let next_event = events.clone().lock().unwrap().pop(); async move { - if poisoned_conns.lock().unwrap().contains(&remote_addr) { - tracing::error!("poisoned connection {:?} was reused!", &remote_addr); - panic!("poisoned connection was reused!"); - } - let next_event = events.clone().lock().unwrap().pop(); let next_event = next_event .unwrap_or_else(|| panic!("no more events! Log: {:?}", wire_log)); @@ -400,3 +400,20 @@ impl tower::Service for LoggingDnsResolver { }) } } + +#[cfg(any(feature = "legacy-test-util", feature = "hyper-014"))] +impl hyper_0_14::service::Service for LoggingDnsResolver { + type Response = Once; + type Error = Infallible; + type Future = BoxFuture<'static, Self::Response, Self::Error>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + >::poll_ready(self, cx) + } + + fn call(&mut self, req: hyper_0_14::client::connect::dns::Name) -> Self::Future { + use std::str::FromStr; + let adapter = Name::from_str(req.as_str()).expect("valid conversion"); + >::call(self, adapter) + } +} diff --git a/rust-runtime/aws-smithy-runtime/Cargo.toml b/rust-runtime/aws-smithy-runtime/Cargo.toml index f85e51b1f2..2456338b05 100644 --- a/rust-runtime/aws-smithy-runtime/Cargo.toml +++ b/rust-runtime/aws-smithy-runtime/Cargo.toml @@ -16,24 +16,20 @@ connector-hyper-0-14-x = ["dep:aws-smithy-http-client", "aws-smithy-http-client? tls-rustls = ["dep:aws-smithy-http-client", "aws-smithy-http-client?/legacy-tls-rustls", "connector-hyper-0-14-x"] rt-tokio = ["tokio/rt"] -# FIXME - update once we know what this looks like from aws-smithy-http-client (also run udeps) # Features for testing test-util = [ "aws-smithy-runtime-api/test-util", - "dep:aws-smithy-protocol-test", "dep:tracing-subscriber", - "dep:serde", - "dep:serde_json", - "dep:indexmap", - # for now we need hyper-0-14 explicitly still as it's used internally - "dep:hyper-0-14" + "connector-hyper-0-14-x", + "aws-smithy-http-client/test-util", + "aws-smithy-http-client/legacy-test-util", ] -wire-mock = ["test-util", "connector-hyper-0-14-x", "hyper-0-14?/server"] + +wire-mock = ["test-util", "aws-smithy-http-client/wire-mock"] [dependencies] aws-smithy-async = { path = "../aws-smithy-async" } aws-smithy-http = { path = "../aws-smithy-http" } -aws-smithy-protocol-test = { path = "../aws-smithy-protocol-test", optional = true } aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api" } aws-smithy-types = { path = "../aws-smithy-types", features = ["http-body-0-4-x"] } aws-smithy-http-client = { path = "../aws-smithy-http-client", optional = true } @@ -51,9 +47,6 @@ hyper-rustls = { version = "0.24", features = ["rustls-native-certs", "http2"], once_cell = "1.18.0" pin-project-lite = "0.2.7" pin-utils = "0.1.0" -serde = { version = "1", features = ["derive"], optional = true } -serde_json = { version = "1", features = ["preserve_order"], optional = true } -indexmap = { version = "2", optional = true, features = ["serde"] } tokio = { version = "1.25", features = [] } tracing = "0.1.37" tracing-subscriber = { version = "0.3.16", optional = true, features = ["env-filter", "fmt", "json"] } diff --git a/rust-runtime/aws-smithy-runtime/src/client/http.rs b/rust-runtime/aws-smithy-runtime/src/client/http.rs index 77d922afce..2e8068413c 100644 --- a/rust-runtime/aws-smithy-runtime/src/client/http.rs +++ b/rust-runtime/aws-smithy-runtime/src/client/http.rs @@ -6,9 +6,38 @@ /// Interceptor for connection poisoning. pub mod connection_poisoning; -// FIXME - deprecate and re-export from aws-smithy-runtime +#[deprecated = "Direct HTTP test utility support from `aws-smithy-runtime` crate is deprecated. Please use the `test-util` feature from `aws-smithy-http-client` instead"] #[cfg(feature = "test-util")] -// pub mod test_util; +pub mod test_util { + #![allow(missing_docs)] + + pub use aws_smithy_http_client::test_util::{ + legacy_capture_request as capture_request, CaptureRequestHandler, CaptureRequestReceiver, + }; + + #[cfg(feature = "connector-hyper-0-14-x")] + pub mod dvr { + pub use aws_smithy_http_client::test_util::dvr::*; + } + + pub use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient}; + + pub use aws_smithy_http_client::test_util::legacy_infallible::infallible_client_fn; + + pub use aws_smithy_http_client::test_util::NeverClient; + + #[cfg(feature = "connector-hyper-0-14-x")] + pub use aws_smithy_http_client::test_util::NeverTcpConnector; + + #[cfg(all(feature = "connector-hyper-0-14-x", feature = "wire-mock"))] + #[macro_use] + pub mod wire { + pub use aws_smithy_http_client::test_util::wire::ev; + pub use aws_smithy_http_client::test_util::wire::match_events; + pub use aws_smithy_http_client::test_util::wire::matcher; + pub use aws_smithy_http_client::test_util::wire::*; + } +} /// Default HTTP and TLS connectors that use hyper 0.14.x and rustls. /// diff --git a/rust-runtime/aws-smithy-runtime/src/lib.rs b/rust-runtime/aws-smithy-runtime/src/lib.rs index 36dcd854ec..dd17c5bc77 100644 --- a/rust-runtime/aws-smithy-runtime/src/lib.rs +++ b/rust-runtime/aws-smithy-runtime/src/lib.rs @@ -34,3 +34,11 @@ pub mod static_partition_map; /// General testing utilities. #[cfg(feature = "test-util")] pub mod test_util; + +// legacy test-util, re-export of macros +#[cfg(feature = "wire-mock")] +pub use aws_smithy_http_client::test_util::wire::ev; +#[cfg(feature = "wire-mock")] +pub use aws_smithy_http_client::test_util::wire::match_events; +#[cfg(feature = "wire-mock")] +pub use aws_smithy_http_client::test_util::wire::matcher; From 3704ac26452367ca7b2ca8f3a601dc8456ff26cd Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 21 Oct 2024 16:03:39 -0400 Subject: [PATCH 08/13] cleanup toml --- rust-runtime/Cargo.lock | 1 - rust-runtime/aws-smithy-runtime/Cargo.toml | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/rust-runtime/Cargo.lock b/rust-runtime/Cargo.lock index a69597a340..8565981027 100644 --- a/rust-runtime/Cargo.lock +++ b/rust-runtime/Cargo.lock @@ -688,7 +688,6 @@ dependencies = [ "http-body 1.0.1", "httparse", "hyper 0.14.31", - "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", "pin-utils", diff --git a/rust-runtime/aws-smithy-runtime/Cargo.toml b/rust-runtime/aws-smithy-runtime/Cargo.toml index 2456338b05..125a2edf2a 100644 --- a/rust-runtime/aws-smithy-runtime/Cargo.toml +++ b/rust-runtime/aws-smithy-runtime/Cargo.toml @@ -42,8 +42,6 @@ http-body-04x = { package = "http-body", version = "0.4.4" } http-body-1x = { package = "http-body", version = "1" } # This avoids bringing `httparse` 1.9.0 and 1.9.1 through `hyper-0-14` that break unit tests of runtime crates httparse = "1.8.0" -hyper-0-14 = { package = "hyper", version = "0.14.26", default-features = false, optional = true } -hyper-rustls = { version = "0.24", features = ["rustls-native-certs", "http2"], optional = true } once_cell = "1.18.0" pin-project-lite = "0.2.7" pin-utils = "0.1.0" @@ -64,6 +62,7 @@ pretty_assertions = "1.4.0" tokio = { version = "1.25", features = ["macros", "rt", "rt-multi-thread", "test-util", "full"] } tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } tracing-test = "0.2.1" +# FIXME - migrate to hyper-1 hyper_0_14 = { package = "hyper", version = "0.14.27", features = ["client", "server", "tcp", "http1", "http2"] } http1 = { package = "http", version = "1" } From fc3640a6f3235fc9f6588a56eea70de818ad6094 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 21 Oct 2024 16:18:07 -0400 Subject: [PATCH 09/13] fix flag --- rust-runtime/aws-smithy-http-client/src/test_util.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust-runtime/aws-smithy-http-client/src/test_util.rs b/rust-runtime/aws-smithy-http-client/src/test_util.rs index b0e1923802..422187ea14 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util.rs @@ -12,7 +12,7 @@ //! respond with a given response, then capture request can also be useful since //! you can optionally give it a response to return. #![cfg_attr( - feature = "hyper-014", + feature = "hyper-1", doc = "- [`dvr`]: If you want to record real-world traffic and then replay it later, then DVR's" )] //! [`RecordingClient`](dvr::RecordingClient) and [`ReplayingClient`](dvr::ReplayingClient) @@ -43,7 +43,6 @@ pub use capture_request::{capture_request, CaptureRequestHandler, CaptureRequest #[cfg(feature = "legacy-test-util")] pub use capture_request::legacy_capture_request; -#[cfg(feature = "hyper-014")] pub mod dvr; mod replay; From d6bbf5953b6e3c437a99ce733d98159bd041e7d9 Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Mon, 21 Oct 2024 16:45:40 -0400 Subject: [PATCH 10/13] fix docs --- rust-runtime/aws-smithy-http-client/src/test_util/replay.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs b/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs index efae7fd4df..9d90a2d874 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/replay.rs @@ -149,7 +149,7 @@ impl ValidateRequest { /// ``` /// /// [`assert_requests_match`]: StaticReplayClient::assert_requests_match -/// [DVR]: crate::client::http::test_util::dvr +/// [DVR]: crate::test_util::dvr #[derive(Clone, Debug)] pub struct StaticReplayClient { data: Arc>, From 109d2136684451a75f60939ecfd976a335bd1d7e Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Tue, 22 Oct 2024 09:09:23 -0400 Subject: [PATCH 11/13] fix minimal version --- aws/rust-runtime/Cargo.lock | 16 ++++++++-------- aws/rust-runtime/aws-config/Cargo.lock | 16 ++++++++-------- aws/sdk/Cargo.lock | 17 ++++++++--------- rust-runtime/Cargo.lock | 16 ++++++++-------- rust-runtime/aws-smithy-http-client/Cargo.toml | 2 +- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/aws/rust-runtime/Cargo.lock b/aws/rust-runtime/Cargo.lock index 64d004222a..f6152a0690 100644 --- a/aws/rust-runtime/Cargo.lock +++ b/aws/rust-runtime/Cargo.lock @@ -488,9 +488,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "bytes-utils" @@ -1976,18 +1976,18 @@ checksum = "f97841a747eef040fcd2e7b3b9a220a7205926e60488e673d9e4926d27772ce5" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "1ac55e59090389fb9f0dd9e0f3c09615afed1d19094284d0b200441f13550793" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "54be4f245ce16bc58d57ef2716271d0d4519e0f6defa147f6e081005bcb278ff" dependencies = [ "proc-macro2", "quote", @@ -2231,9 +2231,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", diff --git a/aws/rust-runtime/aws-config/Cargo.lock b/aws/rust-runtime/aws-config/Cargo.lock index afb58fbf56..113aebf8fa 100644 --- a/aws/rust-runtime/aws-config/Cargo.lock +++ b/aws/rust-runtime/aws-config/Cargo.lock @@ -418,9 +418,9 @@ dependencies = [ [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "bytes-utils" @@ -1373,18 +1373,18 @@ checksum = "f97841a747eef040fcd2e7b3b9a220a7205926e60488e673d9e4926d27772ce5" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "1ac55e59090389fb9f0dd9e0f3c09615afed1d19094284d0b200441f13550793" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "54be4f245ce16bc58d57ef2716271d0d4519e0f6defa147f6e081005bcb278ff" dependencies = [ "proc-macro2", "quote", @@ -1575,9 +1575,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", diff --git a/aws/sdk/Cargo.lock b/aws/sdk/Cargo.lock index 8095f1c3f0..d067cbbc12 100644 --- a/aws/sdk/Cargo.lock +++ b/aws/sdk/Cargo.lock @@ -1520,7 +1520,6 @@ dependencies = [ "http-body 1.0.1", "httparse", "hyper 0.14.31", - "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", "pin-utils", @@ -1843,9 +1842,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "bytes-utils" @@ -3840,18 +3839,18 @@ checksum = "f97841a747eef040fcd2e7b3b9a220a7205926e60488e673d9e4926d27772ce5" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "1ac55e59090389fb9f0dd9e0f3c09615afed1d19094284d0b200441f13550793" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "54be4f245ce16bc58d57ef2716271d0d4519e0f6defa147f6e081005bcb278ff" dependencies = [ "proc-macro2", "quote", @@ -4124,9 +4123,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", diff --git a/rust-runtime/Cargo.lock b/rust-runtime/Cargo.lock index 8565981027..b77d643c18 100644 --- a/rust-runtime/Cargo.lock +++ b/rust-runtime/Cargo.lock @@ -1001,9 +1001,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" dependencies = [ "serde", ] @@ -3164,18 +3164,18 @@ checksum = "f97841a747eef040fcd2e7b3b9a220a7205926e60488e673d9e4926d27772ce5" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "1ac55e59090389fb9f0dd9e0f3c09615afed1d19094284d0b200441f13550793" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.211" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "54be4f245ce16bc58d57ef2716271d0d4519e0f6defa147f6e081005bcb278ff" dependencies = [ "proc-macro2", "quote", @@ -3501,9 +3501,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", diff --git a/rust-runtime/aws-smithy-http-client/Cargo.toml b/rust-runtime/aws-smithy-http-client/Cargo.toml index db297a5336..111fc3a60c 100644 --- a/rust-runtime/aws-smithy-http-client/Cargo.toml +++ b/rust-runtime/aws-smithy-http-client/Cargo.toml @@ -75,7 +75,7 @@ aws-smithy-types = { path = "../aws-smithy-types" } aws-smithy-protocol-test = { path = "../aws-smithy-protocol-test", optional = true } h2 = { version = "0.4", default-features = false } # FIXME - do we need tokio enabled by default? -tokio = { version = "1", features = [] } +tokio = { version = "1.40", features = [] } once_cell = "1.20.1" pin-project-lite = "0.2.14" tracing = "0.1" From bfa3a0748e243390c35afe5575b81928ea3777ce Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Wed, 23 Oct 2024 14:11:50 -0400 Subject: [PATCH 12/13] remove need to expose hyper_util type for DNS --- .../external-types.toml | 13 +++++++++++- .../src/test_util/wire.rs | 20 ++++++++++++------- .../ci-build/sdk-lints/src/lint_cargo_toml.rs | 5 +++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/rust-runtime/aws-smithy-http-client/external-types.toml b/rust-runtime/aws-smithy-http-client/external-types.toml index 80d6dc0bf6..368c5b8c10 100644 --- a/rust-runtime/aws-smithy-http-client/external-types.toml +++ b/rust-runtime/aws-smithy-http-client/external-types.toml @@ -1,8 +1,9 @@ allowed_external_types = [ "aws_smithy_runtime_api::*", "aws_smithy_async::*", + "aws_smithy_types::*", - # TODO(/~https://github.com/smithy-lang/smithy-rs/issues/1193): Once tooling permits it, only allow the following types in the `hyper-014` feature + # TODO(/~https://github.com/smithy-lang/smithy-rs/issues/1193): Once tooling permits it, only allow the following types based on the feature that exposes them "hyper::client::client::Builder", "hyper::client::connect::Connection", "tokio::io::async_read::AsyncRead", @@ -10,4 +11,14 @@ allowed_external_types = [ "http::uri::Uri", # Used in trait bounds for legacy hyper connector build method "tower_service::Service", + + "bytes::bytes::Bytes", + "serde::ser::Serialize", + "serde::de::Deserialize", + "hyper::client::connect::dns::Name", + "http::request::Request", + "http::response::Response", + "http::uri::Uri", + "tokio::net::tcp::stream::TcpStream", + "hyper_util::rt::tokio::TokioIo", ] diff --git a/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs index f7819779f2..fc0108f381 100644 --- a/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs +++ b/rust-runtime/aws-smithy-http-client/src/test_util/wire.rs @@ -322,10 +322,10 @@ impl WireMockServer { pub fn dns_resolver(&self) -> LoggingDnsResolver { let event_log = self.event_log.clone(); let bind_addr = self.bind_addr; - LoggingDnsResolver { + LoggingDnsResolver(InnerDnsResolver { log: event_log, socket_addr: bind_addr, - } + }) } /// Prebuilt [`HttpClient`](aws_smithy_runtime_api::client::http::HttpClient) with correctly wired DNS resolver. @@ -334,7 +334,9 @@ impl WireMockServer { pub fn http_client(&self) -> SharedHttpClient { let resolver = self.dns_resolver(); crate::hyper_1::build_with_fn(None, move || { - hyper_util::client::legacy::connect::HttpConnector::new_with_resolver(resolver.clone()) + hyper_util::client::legacy::connect::HttpConnector::new_with_resolver( + resolver.clone().0, + ) }) } @@ -374,12 +376,16 @@ async fn generate_response_event( /// /// Regardless of what hostname is requested, it will always return the same socket address. #[derive(Clone, Debug)] -pub struct LoggingDnsResolver { +pub struct LoggingDnsResolver(InnerDnsResolver); + +// internal implementation so we don't have to expose hyper_util +#[derive(Clone, Debug)] +struct InnerDnsResolver { log: Arc>>, socket_addr: SocketAddr, } -impl tower::Service for LoggingDnsResolver { +impl tower::Service for InnerDnsResolver { type Response = Once; type Error = Infallible; type Future = BoxFuture<'static, Self::Response, Self::Error>; @@ -408,12 +414,12 @@ impl hyper_0_14::service::Service for Lo type Future = BoxFuture<'static, Self::Response, Self::Error>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - >::poll_ready(self, cx) + self.0.poll_ready(cx) } fn call(&mut self, req: hyper_0_14::client::connect::dns::Name) -> Self::Future { use std::str::FromStr; let adapter = Name::from_str(req.as_str()).expect("valid conversion"); - >::call(self, adapter) + self.0.call(adapter) } } diff --git a/tools/ci-build/sdk-lints/src/lint_cargo_toml.rs b/tools/ci-build/sdk-lints/src/lint_cargo_toml.rs index 5f9b6385e1..2ea376b420 100644 --- a/tools/ci-build/sdk-lints/src/lint_cargo_toml.rs +++ b/tools/ci-build/sdk-lints/src/lint_cargo_toml.rs @@ -375,9 +375,10 @@ impl StableCratesExposeStableCrates { }) // TODO(tooling): When tooling allows, specify this at the crate level. These // are gated by the hyper-014 feature and carryover from relocating hyper-014.x - // support from aws-smithy-runtime + // support from aws-smithy-runtime. hyper_util is only exposed as part of test_util trait impl .filter(|tpe| { - !(name == "aws-smithy-http-client" && ["tower_service"].contains(&tpe.as_str())) + !(name == "aws-smithy-http-client" + && ["tower_service", "serde", "hyper_util"].contains(&tpe.as_str())) }) .map(|crte| { LintError::new(format!( From 87b3a7e8510124b8b45f65436d488de3078f178c Mon Sep 17 00:00:00 2001 From: Aaron J Todd Date: Wed, 23 Oct 2024 15:13:52 -0400 Subject: [PATCH 13/13] fix external types --- rust-runtime/aws-smithy-runtime/external-types.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust-runtime/aws-smithy-runtime/external-types.toml b/rust-runtime/aws-smithy-runtime/external-types.toml index 57a363ab6b..c2da47280b 100644 --- a/rust-runtime/aws-smithy-runtime/external-types.toml +++ b/rust-runtime/aws-smithy-runtime/external-types.toml @@ -24,6 +24,10 @@ allowed_external_types = [ "tokio::io::async_read::AsyncRead", "tokio::io::async_write::AsyncWrite", "aws_smithy_http_client::hyper_014", + "aws_smithy_http_client::test_util::*", + "aws_smithy_http_client::ev", + "aws_smithy_http_client::match_events", + "aws_smithy_http_client::matcher", # TODO(/~https://github.com/smithy-lang/smithy-rs/issues/1193): Once tooling permits it, only allow the following types in the `http-0-x` feature "http_body::Body"