1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | ::pin_project_lite::pin_project! {
|
3 3 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4 - | /// [`Float16Input`](crate::input::Float16Input) using modelled bindings.
|
5 - | pub struct Float16InputFuture {
|
6 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::Float16Input, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4 + | /// [`NoInputOutputInput`](crate::input::NoInputOutputInput) using modelled bindings.
|
5 + | pub struct NoInputOutputInputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NoInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
7 7 | }
|
8 8 | }
|
9 9 |
|
10 - | impl std::future::Future for Float16InputFuture {
|
10 + | impl std::future::Future for NoInputOutputInputFuture {
|
11 11 | type Output = Result<
|
12 - | crate::input::Float16Input,
|
12 + | crate::input::NoInputOutputInput,
|
13 13 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
14 14 | >;
|
15 15 |
|
16 16 | fn poll(
|
17 17 | self: std::pin::Pin<&mut Self>,
|
18 18 | cx: &mut std::task::Context<'_>,
|
19 19 | ) -> std::task::Poll<Self::Output> {
|
20 20 | let this = self.project();
|
21 21 | this.inner.as_mut().poll(cx)
|
22 22 | }
|
23 23 | }
|
24 24 |
|
25 25 | impl<B>
|
26 26 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
27 27 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
28 28 | B,
|
29 - | > for crate::input::Float16Input
|
29 + | > for crate::input::NoInputOutputInput
|
30 30 | where
|
31 31 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
32 32 | B: 'static,
|
33 33 |
|
34 34 | B::Data: Send,
|
35 35 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
36 36 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
37 37 | {
|
38 38 | type Rejection =
|
39 39 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
40 - | type Future = Float16InputFuture;
|
40 + | type Future = NoInputOutputInputFuture;
|
41 41 |
|
42 42 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
43 43 | let fut = async move {
|
44 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
45 - | request.headers(),
|
46 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
47 - | ) {
|
48 - | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
49 - | }
|
50 - | crate::protocol_serde::shape_float16::de_float16_http_request(request).await
|
44 + | crate::protocol_serde::shape_no_input_output::de_no_input_output_http_request(request)
|
45 + | .await
|
51 46 | };
|
52 47 | use ::futures_util::future::TryFutureExt;
|
53 48 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
54 49 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
55 50 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
56 51 | });
|
57 - | Float16InputFuture {
|
52 + | NoInputOutputInputFuture {
|
58 53 | inner: Box::pin(fut),
|
59 54 | }
|
60 55 | }
|
61 56 | }
|
62 57 | impl
|
63 58 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
64 59 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
65 - | > for crate::output::Float16Output
|
60 + | > for crate::output::NoInputOutputOutput
|
66 61 | {
|
67 62 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
68 - | match crate::protocol_serde::shape_float16::ser_float16_http_response(self) {
|
63 + | match crate::protocol_serde::shape_no_input_output::ser_no_input_output_http_response(self)
|
64 + | {
|
69 65 | Ok(response) => response,
|
70 66 | Err(e) => {
|
71 67 | ::tracing::error!(error = %e, "failed to serialize response");
|
72 68 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
73 69 | }
|
74 70 | }
|
75 71 | }
|
76 72 | }
|
77 73 |
|
78 - | ::pin_project_lite::pin_project! {
|
79 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
80 - | /// [`SparseNullsOperationInput`](crate::input::SparseNullsOperationInput) using modelled bindings.
|
81 - | pub struct SparseNullsOperationInputFuture {
|
82 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SparseNullsOperationInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
83 - | }
|
84 - | }
|
85 - |
|
86 - | impl std::future::Future for SparseNullsOperationInputFuture {
|
87 - | type Output = Result<
|
88 - | crate::input::SparseNullsOperationInput,
|
89 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
90 - | >;
|
91 - |
|
92 - | fn poll(
|
93 - | self: std::pin::Pin<&mut Self>,
|
94 - | cx: &mut std::task::Context<'_>,
|
95 - | ) -> std::task::Poll<Self::Output> {
|
96 - | let this = self.project();
|
97 - | this.inner.as_mut().poll(cx)
|
98 - | }
|
99 - | }
|
100 - |
|
101 - | impl<B>
|
102 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
103 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
104 - | B,
|
105 - | > for crate::input::SparseNullsOperationInput
|
106 - | where
|
107 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
108 - | B: 'static,
|
109 - |
|
110 - | B::Data: Send,
|
111 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
112 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
113 - | {
|
114 - | type Rejection =
|
115 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
116 - | type Future = SparseNullsOperationInputFuture;
|
74 + | #[allow(unreachable_code, unused_variables)]
|
75 + | #[cfg(test)]
|
76 + | mod no_input_output_test {
|
117 77 |
|
118 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
119 - | let fut = async move {
|
120 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
121 - | request.headers(),
|
122 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
123 - | ) {
|
124 - | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
125 - | }
|
126 - | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
127 - | .await
|
128 - | };
|
129 - | use ::futures_util::future::TryFutureExt;
|
130 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
131 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
132 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
133 - | });
|
134 - | SparseNullsOperationInputFuture {
|
135 - | inner: Box::pin(fut),
|
136 - | }
|
137 - | }
|
138 - | }
|
139 - | impl
|
140 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
141 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
142 - | > for crate::output::SparseNullsOperationOutput
|
143 - | {
|
144 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
145 - | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
146 - | Ok(response) => response,
|
147 - | Err(e) => {
|
148 - | ::tracing::error!(error = %e, "failed to serialize response");
|
149 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
150 - | }
|
78 + | /// Body is empty and no Content-Type header if no input
|
79 + | /// Test ID: no_input
|
80 + | #[::tokio::test]
|
81 + | #[::tracing_test::traced_test]
|
82 + | async fn no_input_request() {
|
83 + | #[allow(unused_mut)]
|
84 + | let mut http_request = ::http::Request::builder()
|
85 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
86 + | .method("POST")
|
87 + | .header("Accept", "application/cbor")
|
88 + | .header("smithy-protocol", "rpc-v2-cbor")
|
89 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
90 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
91 + | "".as_bytes(),
|
92 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
93 + | )),
|
94 + | ))
|
95 + | .unwrap();
|
96 + | #[allow(unused_mut)]
|
97 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
98 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
99 + | let service =
|
100 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
101 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
102 + | let sender = sender.clone();
|
103 + | async move {
|
104 + | let result = {
|
105 + | let expected = crate::input::NoInputOutputInput {};
|
106 + | ::pretty_assertions::assert_eq!(input, expected);
|
107 + | let output = crate::output::NoInputOutputOutput {};
|
108 + | output
|
109 + | };
|
110 + | sender.send(()).await.expect("receiver dropped early");
|
111 + | result
|
151 112 | }
|
113 + | })
|
114 + | .build_unchecked();
|
115 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
116 + | .await
|
117 + | .expect("unable to make an HTTP request");
|
118 + | assert!(
|
119 + | receiver.recv().await.is_some(),
|
120 + | "we expected operation handler to be invoked but it was not entered"
|
121 + | );
|
152 122 | }
|
153 - | }
|
154 - |
|
155 - | #[allow(unreachable_code, unused_variables)]
|
156 - | #[cfg(test)]
|
157 - | mod sparse_nulls_operation_test {
|
158 123 |
|
159 - | /// Serializes null values in maps
|
160 - | /// Test ID: RpcV2CborSparseMapsSerializeNullValues
|
124 + | /// Servers should accept CBOR empty struct if no input.
|
125 + | /// Test ID: NoInputServerAllowsEmptyCbor
|
161 126 | #[::tokio::test]
|
162 127 | #[::tracing_test::traced_test]
|
163 - | async fn rpc_v2_cbor_sparse_maps_serialize_null_values_request() {
|
128 + | async fn no_input_server_allows_empty_cbor_request() {
|
164 129 | #[allow(unused_mut)]
|
165 130 | let mut http_request = ::http::Request::builder()
|
166 - | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
131 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
167 132 | .method("POST")
|
168 133 | .header("Accept", "application/cbor")
|
169 134 | .header("Content-Type", "application/cbor")
|
170 135 | .header("smithy-protocol", "rpc-v2-cbor")
|
171 136 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
172 137 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
173 - | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==".as_bytes(),
|
174 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
138 + | "v/8=".as_bytes(),
|
139 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
175 140 | )),
|
176 141 | ))
|
177 142 | .unwrap();
|
178 143 | #[allow(unused_mut)]
|
179 144 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
180 145 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
181 146 | let service =
|
182 147 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
183 - | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
148 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
184 149 | let sender = sender.clone();
|
185 150 | async move {
|
186 151 | let result = {
|
187 - | let expected = crate::input::SparseNullsOperationInput {
|
188 - | sparse_string_map: ::std::option::Option::Some({
|
189 - | let mut ret = ::std::collections::HashMap::new();
|
190 - | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
191 - | ret
|
192 - | }),
|
193 - | sparse_string_list: ::std::option::Option::None,
|
194 - | };
|
152 + | let expected = crate::input::NoInputOutputInput {};
|
195 153 | ::pretty_assertions::assert_eq!(input, expected);
|
196 - | let output = crate::output::SparseNullsOperationOutput {
|
197 - | sparse_string_list: ::std::option::Option::None,
|
198 - | sparse_string_map: ::std::option::Option::None,
|
199 - | };
|
154 + | let output = crate::output::NoInputOutputOutput {};
|
200 155 | output
|
201 156 | };
|
202 157 | sender.send(()).await.expect("receiver dropped early");
|
203 158 | result
|
204 159 | }
|
205 160 | })
|
206 161 | .build_unchecked();
|
207 162 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
208 163 | .await
|
209 164 | .expect("unable to make an HTTP request");
|
210 165 | assert!(
|
211 166 | receiver.recv().await.is_some(),
|
212 167 | "we expected operation handler to be invoked but it was not entered"
|
213 168 | );
|
214 169 | }
|
215 170 |
|
216 - | /// Serializes null values in lists
|
217 - | /// Test ID: RpcV2CborSparseListsSerializeNull
|
171 + | /// Servers should accept an empty body if there is no input. Additionally,
|
172 + | /// they should not raise an error if the `Accept` header is set.
|
173 + | /// Test ID: NoInputServerAllowsEmptyBody
|
218 174 | #[::tokio::test]
|
219 175 | #[::tracing_test::traced_test]
|
220 - | async fn rpc_v2_cbor_sparse_lists_serialize_null_request() {
|
176 + | async fn no_input_server_allows_empty_body_request() {
|
221 177 | #[allow(unused_mut)]
|
222 178 | let mut http_request = ::http::Request::builder()
|
223 - | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
179 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
224 180 | .method("POST")
|
225 181 | .header("Accept", "application/cbor")
|
226 182 | .header("Content-Type", "application/cbor")
|
227 183 | .header("smithy-protocol", "rpc-v2-cbor")
|
228 184 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
229 185 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
230 - | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==".as_bytes(),
|
231 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
186 + | "".as_bytes(),
|
187 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
232 188 | )),
|
233 189 | ))
|
234 190 | .unwrap();
|
235 191 | #[allow(unused_mut)]
|
236 192 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
237 193 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
238 194 | let service =
|
239 195 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
240 - | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
196 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
241 197 | let sender = sender.clone();
|
242 198 | async move {
|
243 199 | let result = {
|
244 - | let expected = crate::input::SparseNullsOperationInput {
|
245 - | sparse_string_list: ::std::option::Option::Some(vec![
|
246 - | ::std::option::Option::None,
|
247 - | ]),
|
248 - | sparse_string_map: ::std::option::Option::None,
|
249 - | };
|
200 + | let expected = crate::input::NoInputOutputInput {};
|
250 201 | ::pretty_assertions::assert_eq!(input, expected);
|
251 - | let output = crate::output::SparseNullsOperationOutput {
|
252 - | sparse_string_list: ::std::option::Option::None,
|
253 - | sparse_string_map: ::std::option::Option::None,
|
254 - | };
|
202 + | let output = crate::output::NoInputOutputOutput {};
|
255 203 | output
|
256 204 | };
|
257 205 | sender.send(()).await.expect("receiver dropped early");
|
258 206 | result
|
259 207 | }
|
260 208 | })
|
261 209 | .build_unchecked();
|
262 210 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
263 211 | .await
|
264 212 | .expect("unable to make an HTTP request");
|
265 213 | assert!(
|
266 214 | receiver.recv().await.is_some(),
|
267 215 | "we expected operation handler to be invoked but it was not entered"
|
268 216 | );
|
269 217 | }
|
270 218 |
|
271 - | /// Deserializes null values in maps
|
272 - | /// Test ID: RpcV2CborSparseMapsDeserializeNullValues
|
219 + | /// A `Content-Type` header should not be set if the response body is empty.
|
220 + | /// Test ID: no_output
|
273 221 | #[::tokio::test]
|
274 222 | #[::tracing_test::traced_test]
|
275 - | async fn rpc_v2_cbor_sparse_maps_deserialize_null_values_response() {
|
276 - | let output = crate::output::SparseNullsOperationOutput {
|
277 - | sparse_string_map: ::std::option::Option::Some({
|
278 - | let mut ret = ::std::collections::HashMap::new();
|
279 - | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
280 - | ret
|
281 - | }),
|
282 - | sparse_string_list: ::std::option::Option::None,
|
283 - | };
|
223 + | async fn no_output_response() {
|
224 + | let output = crate::output::NoInputOutputOutput {};
|
284 225 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
285 226 | let http_response = output.into_response();
|
286 227 | ::pretty_assertions::assert_eq!(
|
287 228 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
288 229 | http_response.status()
|
289 230 | );
|
290 - | let expected_headers = [
|
291 - | ("Content-Type", "application/cbor"),
|
292 - | ("smithy-protocol", "rpc-v2-cbor"),
|
293 - | ];
|
231 + | let expected_headers = [("smithy-protocol", "rpc-v2-cbor")];
|
294 232 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
295 233 | http_response.headers(),
|
296 234 | expected_headers,
|
297 235 | ));
|
236 + | let forbidden_headers = &["Content-Type"];
|
237 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::forbid_headers(
|
238 + | http_response.headers(),
|
239 + | forbidden_headers,
|
240 + | ));
|
298 241 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
299 242 | .await
|
300 243 | .expect("unable to extract body to bytes");
|
301 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
302 - | &body,
|
303 - | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==",
|
304 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
305 - | ));
|
244 + | // No body.
|
245 + | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
306 246 | }
|
307 - |
|
308 - | /// Deserializes null values in lists
|
309 - | /// Test ID: RpcV2CborSparseListsDeserializeNull
|
310 - | #[::tokio::test]
|
311 - | #[::tracing_test::traced_test]
|
312 - | async fn rpc_v2_cbor_sparse_lists_deserialize_null_response() {
|
313 - | let output = crate::output::SparseNullsOperationOutput {
|
314 - | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
315 - | sparse_string_map: ::std::option::Option::None,
|
316 - | };
|
317 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
318 - | let http_response = output.into_response();
|
319 - | ::pretty_assertions::assert_eq!(
|
320 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
321 - | http_response.status()
|
322 - | );
|
323 - | let expected_headers = [
|
324 - | ("Content-Type", "application/cbor"),
|
325 - | ("smithy-protocol", "rpc-v2-cbor"),
|
326 - | ];
|
327 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
328 - | http_response.headers(),
|
329 - | expected_headers,
|
330 - | ));
|
331 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
332 - | .await
|
333 - | .expect("unable to extract body to bytes");
|
334 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
335 - | &body,
|
336 - | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==",
|
337 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
338 - | ));
|
339 - | }
|
340 - | }
|
247 + | }
|
341 248 |
|
342 249 | ::pin_project_lite::pin_project! {
|
343 250 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
344 - | /// [`OperationWithDefaultsInput`](crate::input::OperationWithDefaultsInput) using modelled bindings.
|
345 - | pub struct OperationWithDefaultsInputFuture {
|
346 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithDefaultsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
251 + | /// [`EmptyInputOutputInput`](crate::input::EmptyInputOutputInput) using modelled bindings.
|
252 + | pub struct EmptyInputOutputInputFuture {
|
253 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
347 254 | }
|
348 255 | }
|
349 256 |
|
350 - | impl std::future::Future for OperationWithDefaultsInputFuture {
|
257 + | impl std::future::Future for EmptyInputOutputInputFuture {
|
351 258 | type Output = Result<
|
352 - | crate::input::OperationWithDefaultsInput,
|
259 + | crate::input::EmptyInputOutputInput,
|
353 260 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
354 261 | >;
|
355 262 |
|
356 263 | fn poll(
|
357 264 | self: std::pin::Pin<&mut Self>,
|
358 265 | cx: &mut std::task::Context<'_>,
|
359 266 | ) -> std::task::Poll<Self::Output> {
|
360 267 | let this = self.project();
|
361 268 | this.inner.as_mut().poll(cx)
|
362 269 | }
|
363 270 | }
|
364 271 |
|
365 272 | impl<B>
|
366 273 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
367 274 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
368 275 | B,
|
369 - | > for crate::input::OperationWithDefaultsInput
|
276 + | > for crate::input::EmptyInputOutputInput
|
370 277 | where
|
371 278 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
372 279 | B: 'static,
|
373 280 |
|
374 281 | B::Data: Send,
|
375 282 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
376 283 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
377 284 | {
|
378 285 | type Rejection =
|
379 286 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
380 - | type Future = OperationWithDefaultsInputFuture;
|
287 + | type Future = EmptyInputOutputInputFuture;
|
381 288 |
|
382 289 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
383 290 | let fut = async move {
|
384 291 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
385 292 | request.headers(),
|
386 293 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
387 294 | ) {
|
388 295 | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
389 296 | }
|
390 - | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_request(request)
|
391 - | .await
|
297 + | crate::protocol_serde::shape_empty_input_output::de_empty_input_output_http_request(
|
298 + | request,
|
299 + | )
|
300 + | .await
|
392 301 | };
|
393 302 | use ::futures_util::future::TryFutureExt;
|
394 303 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
395 304 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
396 305 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
397 306 | });
|
398 - | OperationWithDefaultsInputFuture {
|
307 + | EmptyInputOutputInputFuture {
|
399 308 | inner: Box::pin(fut),
|
400 309 | }
|
401 310 | }
|
402 311 | }
|
403 312 | impl
|
404 313 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
405 314 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
406 - | > for crate::output::OperationWithDefaultsOutput
|
407 - | {
|
408 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
409 - | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_response(self) {
|
410 - | Ok(response) => response,
|
411 - | Err(e) => {
|
412 - | ::tracing::error!(error = %e, "failed to serialize response");
|
413 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
414 - | }
|
415 - | }
|
416 - | }
|
417 - | }
|
418 - | impl
|
419 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
420 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
421 - | > for crate::error::OperationWithDefaultsError
|
315 + | > for crate::output::EmptyInputOutputOutput
|
422 316 | {
|
423 317 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
424 - | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_error(&self) {
|
425 - | Ok(mut response) => {
|
426 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
427 - | response
|
428 - | },
|
318 + | match crate::protocol_serde::shape_empty_input_output::ser_empty_input_output_http_response(
|
319 + | self,
|
320 + | ) {
|
321 + | Ok(response) => response,
|
429 322 | Err(e) => {
|
430 323 | ::tracing::error!(error = %e, "failed to serialize response");
|
431 324 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
432 325 | }
|
433 326 | }
|
434 327 | }
|
435 328 | }
|
436 329 |
|
437 330 | #[allow(unreachable_code, unused_variables)]
|
438 331 | #[cfg(test)]
|
439 - | mod operation_with_defaults_test {
|
332 + | mod empty_input_output_test {
|
440 333 |
|
441 - | /// Server populates default values when missing in request body.
|
442 - | /// Test ID: RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody
|
334 + | /// When Input structure is empty we write CBOR equivalent of {}
|
335 + | /// Test ID: empty_input
|
443 336 | #[::tokio::test]
|
444 337 | #[::tracing_test::traced_test]
|
445 - | #[should_panic]
|
446 - | async fn rpc_v2_cbor_server_populates_defaults_when_missing_in_request_body_request() {
|
338 + | async fn empty_input_request() {
|
447 339 | #[allow(unused_mut)]
|
448 340 | let mut http_request = ::http::Request::builder()
|
449 - | .uri("/service/RpcV2Protocol/operation/OperationWithDefaults")
|
341 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
450 342 | .method("POST")
|
451 343 | .header("Accept", "application/cbor")
|
452 344 | .header("Content-Type", "application/cbor")
|
453 345 | .header("smithy-protocol", "rpc-v2-cbor")
|
454 346 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
455 347 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
456 - | "v2hkZWZhdWx0c6D/".as_bytes(),
|
348 + | "v/8=".as_bytes(),
|
457 349 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
458 350 | )),
|
459 351 | ))
|
460 352 | .unwrap();
|
461 353 | #[allow(unused_mut)]
|
462 354 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
463 355 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
464 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
465 - | config,
|
466 - | )
|
467 - | .operation_with_defaults(move |input: crate::input::OperationWithDefaultsInput| {
|
468 - | let sender = sender.clone();
|
469 - | async move {
|
470 - | let result = {
|
471 - | let expected = crate::input::OperationWithDefaultsInput {
|
472 - | defaults: ::std::option::Option::Some(crate::model::Defaults {
|
473 - | default_string: "hi".to_owned(),
|
474 - | default_boolean: true,
|
475 - | default_list: vec![],
|
476 - | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
477 - | 0, 0_f64,
|
478 - | ),
|
479 - | default_blob: ::aws_smithy_types::Blob::new("abc"),
|
480 - | default_byte: 1,
|
481 - | default_short: 1,
|
482 - | default_integer: 10,
|
483 - | default_long: 100,
|
484 - | default_float: 1.0_f32,
|
485 - | default_double: 1.0_f64,
|
486 - | default_map: ::std::collections::HashMap::new(),
|
487 - | default_enum: "FOO"
|
488 - | .parse::<crate::model::TestEnum>()
|
489 - | .expect("static value validated to member"),
|
490 - | default_int_enum: 1,
|
491 - | empty_string: "".to_owned(),
|
492 - | false_boolean: false,
|
493 - | empty_blob: ::aws_smithy_types::Blob::new(""),
|
494 - | zero_byte: 0,
|
495 - | zero_short: 0,
|
496 - | zero_integer: 0,
|
497 - | zero_long: 0,
|
498 - | zero_float: 0.0_f32,
|
499 - | zero_double: 0.0_f64,
|
500 - | }),
|
501 - | top_level_default: "hi".to_owned(),
|
502 - | other_top_level_default: 0,
|
503 - | client_optional_defaults: ::std::option::Option::None,
|
504 - | };
|
505 - | ::pretty_assertions::assert_eq!(input, expected);
|
506 - | let output = crate::output::OperationWithDefaultsOutput {
|
507 - | default_string: "".to_owned(),
|
508 - | default_boolean: false,
|
509 - | default_list: vec![],
|
510 - | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
511 - | 0, 0_f64,
|
512 - | ),
|
513 - | default_blob: ::aws_smithy_types::Blob::new(""),
|
514 - | default_byte: 0,
|
515 - | default_short: 0,
|
516 - | default_integer: 0,
|
517 - | default_long: 0,
|
518 - | default_float: 0_f32,
|
519 - | default_double: 0_f64,
|
520 - | default_map: ::std::collections::HashMap::new(),
|
521 - | default_enum: ""
|
522 - | .parse::<crate::model::TestEnum>()
|
523 - | .expect("static value validated to member"),
|
524 - | default_int_enum: 0,
|
525 - | empty_string: "".to_owned(),
|
526 - | false_boolean: false,
|
527 - | empty_blob: ::aws_smithy_types::Blob::new(""),
|
528 - | zero_byte: 0,
|
529 - | zero_short: 0,
|
530 - | zero_integer: 0,
|
531 - | zero_long: 0,
|
532 - | zero_float: 0_f32,
|
533 - | zero_double: 0_f64,
|
534 - | };
|
535 - | Ok(output)
|
536 - | };
|
537 - | sender.send(()).await.expect("receiver dropped early");
|
538 - | result
|
539 - | }
|
540 - | })
|
541 - | .build_unchecked();
|
356 + | let service =
|
357 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
358 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
359 + | let sender = sender.clone();
|
360 + | async move {
|
361 + | let result = {
|
362 + | let expected = crate::input::EmptyInputOutputInput {};
|
363 + | ::pretty_assertions::assert_eq!(input, expected);
|
364 + | let output = crate::output::EmptyInputOutputOutput {};
|
365 + | output
|
366 + | };
|
367 + | sender.send(()).await.expect("receiver dropped early");
|
368 + | result
|
369 + | }
|
370 + | })
|
371 + | .build_unchecked();
|
542 372 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
543 373 | .await
|
544 374 | .expect("unable to make an HTTP request");
|
545 375 | assert!(
|
546 376 | receiver.recv().await.is_some(),
|
547 377 | "we expected operation handler to be invoked but it was not entered"
|
548 378 | );
|
549 379 | }
|
550 380 |
|
551 - | /// Server populates default values in response when missing in params.
|
552 - | /// Test ID: RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams
|
381 + | /// When Input structure is empty the server should accept an empty body
|
382 + | /// Test ID: empty_input_no_body
|
553 383 | #[::tokio::test]
|
554 384 | #[::tracing_test::traced_test]
|
555 - | #[should_panic]
|
556 - | async fn rpc_v2_cbor_server_populates_defaults_in_response_when_missing_in_params_response() {
|
557 - | let output = crate::output::OperationWithDefaultsOutput {
|
558 - | default_string: "".to_owned(),
|
559 - | default_boolean: false,
|
560 - | default_list: vec![],
|
561 - | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64),
|
562 - | default_blob: ::aws_smithy_types::Blob::new(""),
|
563 - | default_byte: 0,
|
564 - | default_short: 0,
|
565 - | default_integer: 0,
|
566 - | default_long: 0,
|
567 - | default_float: 0_f32,
|
568 - | default_double: 0_f64,
|
569 - | default_map: ::std::collections::HashMap::new(),
|
570 - | default_enum: ""
|
571 - | .parse::<crate::model::TestEnum>()
|
572 - | .expect("static value validated to member"),
|
573 - | default_int_enum: 0,
|
574 - | empty_string: "".to_owned(),
|
575 - | false_boolean: false,
|
576 - | empty_blob: ::aws_smithy_types::Blob::new(""),
|
577 - | zero_byte: 0,
|
578 - | zero_short: 0,
|
579 - | zero_integer: 0,
|
580 - | zero_long: 0,
|
581 - | zero_float: 0_f32,
|
582 - | zero_double: 0_f64,
|
583 - | };
|
584 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
585 - | let http_response = output.into_response();
|
586 - | ::pretty_assertions::assert_eq!(
|
587 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
588 - | http_response.status()
|
385 + | async fn empty_input_no_body_request() {
|
386 + | #[allow(unused_mut)]
|
387 + | let mut http_request = ::http::Request::builder()
|
388 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
389 + | .method("POST")
|
390 + | .header("Accept", "application/cbor")
|
391 + | .header("Content-Type", "application/cbor")
|
392 + | .header("smithy-protocol", "rpc-v2-cbor")
|
393 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
394 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
395 + | "".as_bytes(),
|
396 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
397 + | )),
|
398 + | ))
|
399 + | .unwrap();
|
400 + | #[allow(unused_mut)]
|
401 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
402 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
403 + | let service =
|
404 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
405 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
406 + | let sender = sender.clone();
|
407 + | async move {
|
408 + | let result = {
|
409 + | let expected = crate::input::EmptyInputOutputInput {};
|
410 + | ::pretty_assertions::assert_eq!(input, expected);
|
411 + | let output = crate::output::EmptyInputOutputOutput {};
|
412 + | output
|
413 + | };
|
414 + | sender.send(()).await.expect("receiver dropped early");
|
415 + | result
|
416 + | }
|
417 + | })
|
418 + | .build_unchecked();
|
419 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
420 + | .await
|
421 + | .expect("unable to make an HTTP request");
|
422 + | assert!(
|
423 + | receiver.recv().await.is_some(),
|
424 + | "we expected operation handler to be invoked but it was not entered"
|
589 425 | );
|
590 - | let expected_headers = [
|
591 - | ("Content-Type", "application/cbor"),
|
592 - | ("smithy-protocol", "rpc-v2-cbor"),
|
593 - | ];
|
426 + | }
|
427 + |
|
428 + | /// When input structure, is empty the server should accept an empty body
|
429 + | /// even if the Accept header is set.
|
430 + | /// Test ID: empty_input_no_body_has_accept
|
431 + | #[::tokio::test]
|
432 + | #[::tracing_test::traced_test]
|
433 + | async fn empty_input_no_body_has_accept_request() {
|
434 + | #[allow(unused_mut)]
|
435 + | let mut http_request = ::http::Request::builder()
|
436 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
437 + | .method("POST")
|
438 + | .header("Accept", "application/cbor")
|
439 + | .header("Content-Type", "application/cbor")
|
440 + | .header("smithy-protocol", "rpc-v2-cbor")
|
441 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
442 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
443 + | "".as_bytes(),
|
444 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
445 + | )),
|
446 + | ))
|
447 + | .unwrap();
|
448 + | #[allow(unused_mut)]
|
449 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
450 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
451 + | let service =
|
452 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
453 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
454 + | let sender = sender.clone();
|
455 + | async move {
|
456 + | let result = {
|
457 + | let expected = crate::input::EmptyInputOutputInput {};
|
458 + | ::pretty_assertions::assert_eq!(input, expected);
|
459 + | let output = crate::output::EmptyInputOutputOutput {};
|
460 + | output
|
461 + | };
|
462 + | sender.send(()).await.expect("receiver dropped early");
|
463 + | result
|
464 + | }
|
465 + | })
|
466 + | .build_unchecked();
|
467 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
468 + | .await
|
469 + | .expect("unable to make an HTTP request");
|
470 + | assert!(
|
471 + | receiver.recv().await.is_some(),
|
472 + | "we expected operation handler to be invoked but it was not entered"
|
473 + | );
|
474 + | }
|
475 + |
|
476 + | /// When output structure is empty we write CBOR equivalent of {}
|
477 + | /// Test ID: empty_output
|
478 + | #[::tokio::test]
|
479 + | #[::tracing_test::traced_test]
|
480 + | async fn empty_output_response() {
|
481 + | let output = crate::output::EmptyInputOutputOutput {};
|
482 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
483 + | let http_response = output.into_response();
|
484 + | ::pretty_assertions::assert_eq!(
|
485 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
486 + | http_response.status()
|
487 + | );
|
488 + | let expected_headers = [
|
489 + | ("Content-Type", "application/cbor"),
|
490 + | ("smithy-protocol", "rpc-v2-cbor"),
|
491 + | ];
|
594 492 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
595 493 | http_response.headers(),
|
596 494 | expected_headers,
|
597 495 | ));
|
598 496 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
599 497 | .await
|
600 498 | .expect("unable to extract body to bytes");
|
601 - | ::aws_smithy_protocol_test::assert_ok(
|
602 - | ::aws_smithy_protocol_test::validate_body(&body, "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
603 - | );
|
499 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
500 + | &body,
|
501 + | "v/8=",
|
502 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
503 + | ));
|
604 504 | }
|
605 505 | }
|
606 506 |
|
607 507 | ::pin_project_lite::pin_project! {
|
608 508 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
609 - | /// [`FractionalSecondsInput`](crate::input::FractionalSecondsInput) using modelled bindings.
|
610 - | pub struct FractionalSecondsInputFuture {
|
611 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::FractionalSecondsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
509 + | /// [`OptionalInputOutputInput`](crate::input::OptionalInputOutputInput) using modelled bindings.
|
510 + | pub struct OptionalInputOutputInputFuture {
|
511 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OptionalInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
612 512 | }
|
613 513 | }
|
614 514 |
|
615 - | impl std::future::Future for FractionalSecondsInputFuture {
|
515 + | impl std::future::Future for OptionalInputOutputInputFuture {
|
616 516 | type Output = Result<
|
617 - | crate::input::FractionalSecondsInput,
|
517 + | crate::input::OptionalInputOutputInput,
|
618 518 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
619 519 | >;
|
620 520 |
|
621 521 | fn poll(
|
622 522 | self: std::pin::Pin<&mut Self>,
|
623 523 | cx: &mut std::task::Context<'_>,
|
624 524 | ) -> std::task::Poll<Self::Output> {
|
625 525 | let this = self.project();
|
626 526 | this.inner.as_mut().poll(cx)
|
627 527 | }
|
628 528 | }
|
629 529 |
|
630 530 | impl<B>
|
631 531 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
632 532 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
633 533 | B,
|
634 - | > for crate::input::FractionalSecondsInput
|
534 + | > for crate::input::OptionalInputOutputInput
|
635 535 | where
|
636 536 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
637 537 | B: 'static,
|
638 538 |
|
639 539 | B::Data: Send,
|
640 540 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
641 541 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
642 542 | {
|
643 543 | type Rejection =
|
644 544 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
645 - | type Future = FractionalSecondsInputFuture;
|
545 + | type Future = OptionalInputOutputInputFuture;
|
646 546 |
|
647 547 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
648 548 | let fut = async move {
|
649 549 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
650 550 | request.headers(),
|
651 551 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
652 552 | ) {
|
653 553 | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
654 554 | }
|
655 - | crate::protocol_serde::shape_fractional_seconds::de_fractional_seconds_http_request(
|
656 - | request,
|
657 - | )
|
658 - | .await
|
555 + | crate::protocol_serde::shape_optional_input_output::de_optional_input_output_http_request(request)
|
556 + | .await
|
659 557 | };
|
660 558 | use ::futures_util::future::TryFutureExt;
|
661 559 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
662 560 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
663 561 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
664 562 | });
|
665 - | FractionalSecondsInputFuture {
|
563 + | OptionalInputOutputInputFuture {
|
666 564 | inner: Box::pin(fut),
|
667 565 | }
|
668 566 | }
|
669 567 | }
|
670 568 | impl
|
671 569 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
672 570 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
673 - | > for crate::output::FractionalSecondsOutput
|
571 + | > for crate::output::OptionalInputOutputOutput
|
674 572 | {
|
675 573 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
676 - | match crate::protocol_serde::shape_fractional_seconds::ser_fractional_seconds_http_response(
|
677 - | self,
|
678 - | ) {
|
679 - | Ok(response) => response,
|
680 - | Err(e) => {
|
681 - | ::tracing::error!(error = %e, "failed to serialize response");
|
682 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
683 - | }
|
684 - | }
|
574 + | match crate::protocol_serde::shape_optional_input_output::ser_optional_input_output_http_response(self) {
|
575 + | Ok(response) => response,
|
576 + | Err(e) => {
|
577 + | ::tracing::error!(error = %e, "failed to serialize response");
|
578 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
579 + | }
|
580 + | }
|
581 + | }
|
582 + | }
|
583 + |
|
584 + | #[allow(unreachable_code, unused_variables)]
|
585 + | #[cfg(test)]
|
586 + | mod optional_input_output_test {
|
587 + |
|
588 + | /// When input is empty we write CBOR equivalent of {}
|
589 + | /// Test ID: optional_input
|
590 + | #[::tokio::test]
|
591 + | #[::tracing_test::traced_test]
|
592 + | async fn optional_input_request() {
|
593 + | #[allow(unused_mut)]
|
594 + | let mut http_request = ::http::Request::builder()
|
595 + | .uri("/service/RpcV2Protocol/operation/OptionalInputOutput")
|
596 + | .method("POST")
|
597 + | .header("Accept", "application/cbor")
|
598 + | .header("Content-Type", "application/cbor")
|
599 + | .header("smithy-protocol", "rpc-v2-cbor")
|
600 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
601 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
602 + | "v/8=".as_bytes(),
|
603 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
604 + | )),
|
605 + | ))
|
606 + | .unwrap();
|
607 + | #[allow(unused_mut)]
|
608 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
609 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
610 + | let service =
|
611 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
612 + | .optional_input_output(move |input: crate::input::OptionalInputOutputInput| {
|
613 + | let sender = sender.clone();
|
614 + | async move {
|
615 + | let result = {
|
616 + | let expected = crate::input::OptionalInputOutputInput {
|
617 + | value: ::std::option::Option::None,
|
618 + | };
|
619 + | ::pretty_assertions::assert_eq!(input, expected);
|
620 + | let output = crate::output::OptionalInputOutputOutput {
|
621 + | value: ::std::option::Option::None,
|
622 + | };
|
623 + | output
|
624 + | };
|
625 + | sender.send(()).await.expect("receiver dropped early");
|
626 + | result
|
627 + | }
|
628 + | })
|
629 + | .build_unchecked();
|
630 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
631 + | .await
|
632 + | .expect("unable to make an HTTP request");
|
633 + | assert!(
|
634 + | receiver.recv().await.is_some(),
|
635 + | "we expected operation handler to be invoked but it was not entered"
|
636 + | );
|
637 + | }
|
638 + |
|
639 + | /// When output is empty we write CBOR equivalent of {}
|
640 + | /// Test ID: optional_output
|
641 + | #[::tokio::test]
|
642 + | #[::tracing_test::traced_test]
|
643 + | async fn optional_output_response() {
|
644 + | let output = crate::output::OptionalInputOutputOutput {
|
645 + | value: ::std::option::Option::None,
|
646 + | };
|
647 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
648 + | let http_response = output.into_response();
|
649 + | ::pretty_assertions::assert_eq!(
|
650 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
651 + | http_response.status()
|
652 + | );
|
653 + | let expected_headers = [
|
654 + | ("Content-Type", "application/cbor"),
|
655 + | ("smithy-protocol", "rpc-v2-cbor"),
|
656 + | ];
|
657 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
658 + | http_response.headers(),
|
659 + | expected_headers,
|
660 + | ));
|
661 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
662 + | .await
|
663 + | .expect("unable to extract body to bytes");
|
664 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
665 + | &body,
|
666 + | "v/8=",
|
667 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
668 + | ));
|
685 669 | }
|
686 670 | }
|
687 671 |
|
688 672 | ::pin_project_lite::pin_project! {
|
689 673 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
690 - | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
691 - | pub struct GreetingWithErrorsInputFuture {
|
692 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GreetingWithErrorsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
674 + | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
675 + | pub struct SimpleScalarPropertiesInputFuture {
|
676 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
693 677 | }
|
694 678 | }
|
695 679 |
|
696 - | impl std::future::Future for GreetingWithErrorsInputFuture {
|
680 + | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
697 681 | type Output = Result<
|
698 - | crate::input::GreetingWithErrorsInput,
|
682 + | crate::input::SimpleScalarPropertiesInput,
|
699 683 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
700 684 | >;
|
701 685 |
|
702 686 | fn poll(
|
703 687 | self: std::pin::Pin<&mut Self>,
|
704 688 | cx: &mut std::task::Context<'_>,
|
705 689 | ) -> std::task::Poll<Self::Output> {
|
706 690 | let this = self.project();
|
707 691 | this.inner.as_mut().poll(cx)
|
708 692 | }
|
709 693 | }
|
710 694 |
|
711 695 | impl<B>
|
712 696 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
713 697 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
714 698 | B,
|
715 - | > for crate::input::GreetingWithErrorsInput
|
699 + | > for crate::input::SimpleScalarPropertiesInput
|
716 700 | where
|
717 701 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
718 702 | B: 'static,
|
719 703 |
|
720 704 | B::Data: Send,
|
721 705 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
722 706 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
723 707 | {
|
724 708 | type Rejection =
|
725 709 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
726 - | type Future = GreetingWithErrorsInputFuture;
|
710 + | type Future = SimpleScalarPropertiesInputFuture;
|
727 711 |
|
728 712 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
729 713 | let fut = async move {
|
730 714 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
731 715 | request.headers(),
|
732 716 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
733 717 | ) {
|
734 718 | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
735 719 | }
|
736 - | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
737 - | request,
|
738 - | )
|
739 - | .await
|
720 + | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
721 + | .await
|
740 722 | };
|
741 723 | use ::futures_util::future::TryFutureExt;
|
742 724 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
743 725 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
744 726 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
745 727 | });
|
746 - | GreetingWithErrorsInputFuture {
|
728 + | SimpleScalarPropertiesInputFuture {
|
747 729 | inner: Box::pin(fut),
|
748 730 | }
|
749 731 | }
|
750 732 | }
|
751 733 | impl
|
752 734 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
753 735 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
754 - | > for crate::output::GreetingWithErrorsOutput
|
736 + | > for crate::output::SimpleScalarPropertiesOutput
|
755 737 | {
|
756 738 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
757 - | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
739 + | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
758 740 | Ok(response) => response,
|
759 741 | Err(e) => {
|
760 742 | ::tracing::error!(error = %e, "failed to serialize response");
|
761 743 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
762 744 | }
|
763 745 | }
|
764 746 | }
|
765 747 | }
|
766 - | impl
|
767 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
768 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
769 - | > for crate::error::GreetingWithErrorsError
|
770 - | {
|
771 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
772 - | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
773 - | &self,
|
774 - | ) {
|
775 - | Ok(mut response) => {
|
776 - | response.extensions_mut().insert(
|
777 - | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
778 - | self.name(),
|
779 - | ),
|
780 - | );
|
781 - | response
|
782 - | }
|
783 - | Err(e) => {
|
784 - | ::tracing::error!(error = %e, "failed to serialize response");
|
785 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
786 - | }
|
787 - | }
|
788 - | }
|
789 - | }
|
790 748 |
|
791 749 | #[allow(unreachable_code, unused_variables)]
|
792 750 | #[cfg(test)]
|
793 - | mod greeting_with_errors_test {
|
751 + | mod simple_scalar_properties_test {
|
794 752 |
|
795 - | /// Parses simple RpcV2 Cbor errors
|
796 - | /// Test ID: RpcV2CborInvalidGreetingError
|
797 - | #[::tokio::test]
|
798 - | #[::tracing_test::traced_test]
|
799 - | async fn rpc_v2_cbor_invalid_greeting_error_response() {
|
800 - | let output = crate::error::InvalidGreeting {
|
801 - | message: ::std::option::Option::Some("Hi".to_owned()),
|
802 - | };
|
803 - | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
804 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
805 - | let http_response = output.into_response();
|
806 - | ::pretty_assertions::assert_eq!(
|
807 - | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
808 - | http_response.status()
|
809 - | );
|
810 - | let expected_headers = [
|
811 - | ("Content-Type", "application/cbor"),
|
812 - | ("smithy-protocol", "rpc-v2-cbor"),
|
813 - | ];
|
814 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
815 - | http_response.headers(),
|
816 - | expected_headers,
|
817 - | ));
|
818 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
819 - | .await
|
820 - | .expect("unable to extract body to bytes");
|
821 - | ::aws_smithy_protocol_test::assert_ok(
|
822 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
823 - | );
|
824 - | }
|
825 - |
|
826 - | /// Parses a complex error with no message member
|
827 - | /// Test ID: RpcV2CborComplexError
|
828 - | #[::tokio::test]
|
829 - | #[::tracing_test::traced_test]
|
830 - | async fn rpc_v2_cbor_complex_error_response() {
|
831 - | let output = crate::error::ComplexError {
|
832 - | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
833 - | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
834 - | foo: ::std::option::Option::Some("bar".to_owned()),
|
835 - | }),
|
836 - | };
|
837 - | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
838 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
839 - | let http_response = output.into_response();
|
840 - | ::pretty_assertions::assert_eq!(
|
841 - | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
842 - | http_response.status()
|
843 - | );
|
844 - | let expected_headers = [
|
845 - | ("Content-Type", "application/cbor"),
|
846 - | ("smithy-protocol", "rpc-v2-cbor"),
|
847 - | ];
|
848 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
849 - | http_response.headers(),
|
850 - | expected_headers,
|
851 - | ));
|
852 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
853 - | .await
|
854 - | .expect("unable to extract body to bytes");
|
855 - | ::aws_smithy_protocol_test::assert_ok(
|
856 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
857 - | );
|
858 - | }
|
859 - | /// Test ID: RpcV2CborEmptyComplexError
|
860 - | #[::tokio::test]
|
861 - | #[::tracing_test::traced_test]
|
862 - | async fn rpc_v2_cbor_empty_complex_error_response() {
|
863 - | let output = crate::error::ComplexError {
|
864 - | top_level: ::std::option::Option::None,
|
865 - | nested: ::std::option::Option::None,
|
866 - | };
|
867 - | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
868 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
869 - | let http_response = output.into_response();
|
870 - | ::pretty_assertions::assert_eq!(
|
871 - | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
872 - | http_response.status()
|
873 - | );
|
874 - | let expected_headers = [
|
875 - | ("Content-Type", "application/cbor"),
|
876 - | ("smithy-protocol", "rpc-v2-cbor"),
|
877 - | ];
|
878 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
879 - | http_response.headers(),
|
880 - | expected_headers,
|
881 - | ));
|
882 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
883 - | .await
|
884 - | .expect("unable to extract body to bytes");
|
885 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
886 - | &body,
|
887 - | "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/",
|
888 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
889 - | ));
|
890 - | }
|
891 - | }
|
892 - |
|
893 - | ::pin_project_lite::pin_project! {
|
894 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
895 - | /// [`RecursiveShapesInput`](crate::input::RecursiveShapesInput) using modelled bindings.
|
896 - | pub struct RecursiveShapesInputFuture {
|
897 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveShapesInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
898 - | }
|
899 - | }
|
900 - |
|
901 - | impl std::future::Future for RecursiveShapesInputFuture {
|
902 - | type Output = Result<
|
903 - | crate::input::RecursiveShapesInput,
|
904 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
905 - | >;
|
906 - |
|
907 - | fn poll(
|
908 - | self: std::pin::Pin<&mut Self>,
|
909 - | cx: &mut std::task::Context<'_>,
|
910 - | ) -> std::task::Poll<Self::Output> {
|
911 - | let this = self.project();
|
912 - | this.inner.as_mut().poll(cx)
|
913 - | }
|
914 - | }
|
915 - |
|
916 - | impl<B>
|
917 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
918 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
919 - | B,
|
920 - | > for crate::input::RecursiveShapesInput
|
921 - | where
|
922 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
923 - | B: 'static,
|
924 - |
|
925 - | B::Data: Send,
|
926 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
927 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
928 - | {
|
929 - | type Rejection =
|
930 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
931 - | type Future = RecursiveShapesInputFuture;
|
932 - |
|
933 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
934 - | let fut = async move {
|
935 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
936 - | request.headers(),
|
937 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
938 - | ) {
|
939 - | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
940 - | }
|
941 - | crate::protocol_serde::shape_recursive_shapes::de_recursive_shapes_http_request(request)
|
942 - | .await
|
943 - | };
|
944 - | use ::futures_util::future::TryFutureExt;
|
945 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
946 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
947 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
948 - | });
|
949 - | RecursiveShapesInputFuture {
|
950 - | inner: Box::pin(fut),
|
951 - | }
|
952 - | }
|
953 - | }
|
954 - | impl
|
955 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
956 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
957 - | > for crate::output::RecursiveShapesOutput
|
958 - | {
|
959 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
960 - | match crate::protocol_serde::shape_recursive_shapes::ser_recursive_shapes_http_response(
|
961 - | self,
|
962 - | ) {
|
963 - | Ok(response) => response,
|
964 - | Err(e) => {
|
965 - | ::tracing::error!(error = %e, "failed to serialize response");
|
966 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
967 - | }
|
968 - | }
|
969 - | }
|
970 - | }
|
971 - |
|
972 - | #[allow(unreachable_code, unused_variables)]
|
973 - | #[cfg(test)]
|
974 - | mod recursive_shapes_test {
|
975 - |
|
976 - | /// Serializes recursive structures
|
977 - | /// Test ID: RpcV2CborRecursiveShapes
|
753 + | /// Serializes simple scalar properties
|
754 + | /// Test ID: RpcV2CborSimpleScalarProperties
|
978 755 | #[::tokio::test]
|
979 756 | #[::tracing_test::traced_test]
|
980 - | async fn rpc_v2_cbor_recursive_shapes_request() {
|
757 + | async fn rpc_v2_cbor_simple_scalar_properties_request() {
|
981 758 | #[allow(unused_mut)]
|
982 759 | let mut http_request = ::http::Request::builder()
|
983 - | .uri("/service/RpcV2Protocol/operation/RecursiveShapes")
|
760 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
984 761 | .method("POST")
|
985 762 | .header("Accept", "application/cbor")
|
986 763 | .header("Content-Type", "application/cbor")
|
987 764 | .header("smithy-protocol", "rpc-v2-cbor")
|
988 765 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
989 766 | ::bytes::Bytes::copy_from_slice(
|
990 - | &::aws_smithy_protocol_test::decode_body_data("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
767 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
991 768 | )
|
992 769 | )).unwrap();
|
993 770 | #[allow(unused_mut)]
|
994 771 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
995 772 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
996 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
997 - | .recursive_shapes(move |input: crate::input::RecursiveShapesInput| {
|
998 - | let sender = sender.clone();
|
999 - | async move {
|
1000 - | let result = { let expected =
|
1001 - | crate::input::RecursiveShapesInput {
|
1002 - | nested:
|
1003 - | ::std::option::Option::Some(
|
1004 - | crate::model::RecursiveShapesInputOutputNested1 {
|
1005 - | foo:
|
1006 - | ::std::option::Option::Some(
|
1007 - | "Foo1".to_owned()
|
1008 - | )
|
1009 - | ,
|
1010 - | nested:
|
1011 - | ::std::option::Option::Some(
|
1012 - | ::std::boxed::Box::new(
|
1013 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1014 - | bar:
|
1015 - | ::std::option::Option::Some(
|
1016 - | "Bar1".to_owned()
|
1017 - | )
|
1018 - | ,
|
1019 - | recursive_member:
|
1020 - | ::std::option::Option::Some(
|
1021 - | crate::model::RecursiveShapesInputOutputNested1 {
|
1022 - | foo:
|
1023 - | ::std::option::Option::Some(
|
1024 - | "Foo2".to_owned()
|
1025 - | )
|
1026 - | ,
|
1027 - | nested:
|
1028 - | ::std::option::Option::Some(
|
1029 - | ::std::boxed::Box::new(
|
1030 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1031 - | bar:
|
1032 - | ::std::option::Option::Some(
|
1033 - | "Bar2".to_owned()
|
1034 - | )
|
1035 - | ,
|
1036 - | recursive_member:
|
1037 - | ::std::option::Option::None
|
1038 - | ,
|
1039 - | }
|
1040 - | )
|
1041 - | )
|
1042 - | ,
|
1043 - | }
|
1044 - | )
|
1045 - | ,
|
1046 - | }
|
1047 - | )
|
1048 - | )
|
1049 - | ,
|
1050 - | }
|
1051 - | )
|
1052 - | ,
|
1053 - | }
|
1054 - | ;
|
1055 - | ::pretty_assertions::assert_eq!(input, expected);
|
1056 - | let output =
|
1057 - | crate::output::RecursiveShapesOutput {
|
1058 - | nested:
|
1059 - | ::std::option::Option::None
|
1060 - | ,
|
1061 - | }
|
1062 - | ;
|
1063 - | output };
|
1064 - | sender.send(()).await.expect("receiver dropped early");
|
1065 - | result
|
1066 - | }
|
1067 - | })
|
1068 - | .build_unchecked();
|
773 + | let service =
|
774 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
775 + | .simple_scalar_properties(
|
776 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
777 + | let sender = sender.clone();
|
778 + | async move {
|
779 + | let result = {
|
780 + | use ::aws_smithy_protocol_test::FloatEquals;
|
781 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
782 + | byte_value: ::std::option::Option::Some(5),
|
783 + | double_value: ::std::option::Option::Some(1.889_f64),
|
784 + | false_boolean_value: ::std::option::Option::Some(false),
|
785 + | float_value: ::std::option::Option::Some(7.625_f32),
|
786 + | integer_value: ::std::option::Option::Some(256),
|
787 + | long_value: ::std::option::Option::Some(9873),
|
788 + | short_value: ::std::option::Option::Some(9898),
|
789 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
790 + | true_boolean_value: ::std::option::Option::Some(true),
|
791 + | blob_value: ::std::option::Option::Some(
|
792 + | ::aws_smithy_types::Blob::new("foo"),
|
793 + | ),
|
794 + | };
|
795 + | ::pretty_assertions::assert_eq!(
|
796 + | input.true_boolean_value,
|
797 + | expected.true_boolean_value,
|
798 + | "Unexpected value for `true_boolean_value`"
|
799 + | );
|
800 + | ::pretty_assertions::assert_eq!(
|
801 + | input.false_boolean_value,
|
802 + | expected.false_boolean_value,
|
803 + | "Unexpected value for `false_boolean_value`"
|
804 + | );
|
805 + | ::pretty_assertions::assert_eq!(
|
806 + | input.byte_value,
|
807 + | expected.byte_value,
|
808 + | "Unexpected value for `byte_value`"
|
809 + | );
|
810 + | assert!(
|
811 + | input.double_value.float_equals(&expected.double_value),
|
812 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
813 + | expected.double_value,
|
814 + | input.double_value
|
815 + | );
|
816 + | assert!(
|
817 + | input.float_value.float_equals(&expected.float_value),
|
818 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
819 + | expected.float_value,
|
820 + | input.float_value
|
821 + | );
|
822 + | ::pretty_assertions::assert_eq!(
|
823 + | input.integer_value,
|
824 + | expected.integer_value,
|
825 + | "Unexpected value for `integer_value`"
|
826 + | );
|
827 + | ::pretty_assertions::assert_eq!(
|
828 + | input.long_value,
|
829 + | expected.long_value,
|
830 + | "Unexpected value for `long_value`"
|
831 + | );
|
832 + | ::pretty_assertions::assert_eq!(
|
833 + | input.short_value,
|
834 + | expected.short_value,
|
835 + | "Unexpected value for `short_value`"
|
836 + | );
|
837 + | ::pretty_assertions::assert_eq!(
|
838 + | input.string_value,
|
839 + | expected.string_value,
|
840 + | "Unexpected value for `string_value`"
|
841 + | );
|
842 + | ::pretty_assertions::assert_eq!(
|
843 + | input.blob_value,
|
844 + | expected.blob_value,
|
845 + | "Unexpected value for `blob_value`"
|
846 + | );
|
847 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
848 + | true_boolean_value: ::std::option::Option::None,
|
849 + | false_boolean_value: ::std::option::Option::None,
|
850 + | byte_value: ::std::option::Option::None,
|
851 + | double_value: ::std::option::Option::None,
|
852 + | float_value: ::std::option::Option::None,
|
853 + | integer_value: ::std::option::Option::None,
|
854 + | long_value: ::std::option::Option::None,
|
855 + | short_value: ::std::option::Option::None,
|
856 + | string_value: ::std::option::Option::None,
|
857 + | blob_value: ::std::option::Option::None,
|
858 + | };
|
859 + | output
|
860 + | };
|
861 + | sender.send(()).await.expect("receiver dropped early");
|
862 + | result
|
863 + | }
|
864 + | },
|
865 + | )
|
866 + | .build_unchecked();
|
1069 867 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1070 868 | .await
|
1071 869 | .expect("unable to make an HTTP request");
|
1072 870 | assert!(
|
1073 871 | receiver.recv().await.is_some(),
|
1074 872 | "we expected operation handler to be invoked but it was not entered"
|
1075 873 | );
|
1076 874 | }
|
1077 875 |
|
1078 - | /// Serializes recursive structures
|
1079 - | /// Test ID: RpcV2CborRecursiveShapes
|
876 + | /// The server should be capable of deserializing simple scalar properties
|
877 + | /// encoded using a map with a definite length. The server should also be able to parse
|
878 + | /// a key encoded using an indefinite length string.
|
879 + | /// Test ID: RpcV2CborSimpleScalarPropertiesUsingIndefiniteLength
|
1080 880 | #[::tokio::test]
|
1081 881 | #[::tracing_test::traced_test]
|
1082 - | async fn rpc_v2_cbor_recursive_shapes_response() {
|
1083 - | let output = crate::output::RecursiveShapesOutput {
|
1084 - | nested: ::std::option::Option::Some(crate::model::RecursiveShapesInputOutputNested1 {
|
1085 - | foo: ::std::option::Option::Some("Foo1".to_owned()),
|
1086 - | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
1087 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1088 - | bar: ::std::option::Option::Some("Bar1".to_owned()),
|
1089 - | recursive_member: ::std::option::Option::Some(
|
1090 - | crate::model::RecursiveShapesInputOutputNested1 {
|
1091 - | foo: ::std::option::Option::Some("Foo2".to_owned()),
|
1092 - | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
1093 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1094 - | bar: ::std::option::Option::Some("Bar2".to_owned()),
|
1095 - | recursive_member: ::std::option::Option::None,
|
1096 - | },
|
1097 - | )),
|
1098 - | },
|
1099 - | ),
|
882 + | async fn rpc_v2_cbor_simple_scalar_properties_using_indefinite_length_request() {
|
883 + | #[allow(unused_mut)]
|
884 + | let mut http_request = ::http::Request::builder()
|
885 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
886 + | .method("POST")
|
887 + | .header("Accept", "application/cbor")
|
888 + | .header("Content-Type", "application/cbor")
|
889 + | .header("smithy-protocol", "rpc-v2-cbor")
|
890 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
891 + | ::bytes::Bytes::copy_from_slice(
|
892 + | &::aws_smithy_protocol_test::decode_body_data("qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA9AAAbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
893 + | )
|
894 + | )).unwrap();
|
895 + | #[allow(unused_mut)]
|
896 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
897 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
898 + | let service =
|
899 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
900 + | .simple_scalar_properties(
|
901 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
902 + | let sender = sender.clone();
|
903 + | async move {
|
904 + | let result = {
|
905 + | use ::aws_smithy_protocol_test::FloatEquals;
|
906 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
907 + | byte_value: ::std::option::Option::Some(5),
|
908 + | double_value: ::std::option::Option::Some(1.889_f64),
|
909 + | false_boolean_value: ::std::option::Option::Some(false),
|
910 + | float_value: ::std::option::Option::Some(7.625_f32),
|
911 + | integer_value: ::std::option::Option::Some(256),
|
912 + | long_value: ::std::option::Option::Some(9873),
|
913 + | short_value: ::std::option::Option::Some(9898),
|
914 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
915 + | true_boolean_value: ::std::option::Option::Some(true),
|
916 + | blob_value: ::std::option::Option::Some(
|
917 + | ::aws_smithy_types::Blob::new("foo"),
|
918 + | ),
|
919 + | };
|
920 + | ::pretty_assertions::assert_eq!(
|
921 + | input.true_boolean_value,
|
922 + | expected.true_boolean_value,
|
923 + | "Unexpected value for `true_boolean_value`"
|
924 + | );
|
925 + | ::pretty_assertions::assert_eq!(
|
926 + | input.false_boolean_value,
|
927 + | expected.false_boolean_value,
|
928 + | "Unexpected value for `false_boolean_value`"
|
929 + | );
|
930 + | ::pretty_assertions::assert_eq!(
|
931 + | input.byte_value,
|
932 + | expected.byte_value,
|
933 + | "Unexpected value for `byte_value`"
|
934 + | );
|
935 + | assert!(
|
936 + | input.double_value.float_equals(&expected.double_value),
|
937 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
938 + | expected.double_value,
|
939 + | input.double_value
|
940 + | );
|
941 + | assert!(
|
942 + | input.float_value.float_equals(&expected.float_value),
|
943 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
944 + | expected.float_value,
|
945 + | input.float_value
|
946 + | );
|
947 + | ::pretty_assertions::assert_eq!(
|
948 + | input.integer_value,
|
949 + | expected.integer_value,
|
950 + | "Unexpected value for `integer_value`"
|
951 + | );
|
952 + | ::pretty_assertions::assert_eq!(
|
953 + | input.long_value,
|
954 + | expected.long_value,
|
955 + | "Unexpected value for `long_value`"
|
956 + | );
|
957 + | ::pretty_assertions::assert_eq!(
|
958 + | input.short_value,
|
959 + | expected.short_value,
|
960 + | "Unexpected value for `short_value`"
|
961 + | );
|
962 + | ::pretty_assertions::assert_eq!(
|
963 + | input.string_value,
|
964 + | expected.string_value,
|
965 + | "Unexpected value for `string_value`"
|
966 + | );
|
967 + | ::pretty_assertions::assert_eq!(
|
968 + | input.blob_value,
|
969 + | expected.blob_value,
|
970 + | "Unexpected value for `blob_value`"
|
971 + | );
|
972 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
973 + | true_boolean_value: ::std::option::Option::None,
|
974 + | false_boolean_value: ::std::option::Option::None,
|
975 + | byte_value: ::std::option::Option::None,
|
976 + | double_value: ::std::option::Option::None,
|
977 + | float_value: ::std::option::Option::None,
|
978 + | integer_value: ::std::option::Option::None,
|
979 + | long_value: ::std::option::Option::None,
|
980 + | short_value: ::std::option::Option::None,
|
981 + | string_value: ::std::option::Option::None,
|
982 + | blob_value: ::std::option::Option::None,
|
983 + | };
|
984 + | output
|
985 + | };
|
986 + | sender.send(()).await.expect("receiver dropped early");
|
987 + | result
|
988 + | }
|
1100 989 | },
|
1101 - | )),
|
1102 - | }),
|
1103 - | };
|
1104 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1105 - | let http_response = output.into_response();
|
1106 - | ::pretty_assertions::assert_eq!(
|
1107 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1108 - | http_response.status()
|
1109 - | );
|
1110 - | let expected_headers = [
|
1111 - | ("Content-Type", "application/cbor"),
|
1112 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1113 - | ];
|
1114 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1115 - | http_response.headers(),
|
1116 - | expected_headers,
|
1117 - | ));
|
1118 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
990 + | )
|
991 + | .build_unchecked();
|
992 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1119 993 | .await
|
1120 - | .expect("unable to extract body to bytes");
|
1121 - | ::aws_smithy_protocol_test::assert_ok(
|
1122 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1123 - | );
|
1124 - | }
|
1125 - | }
|
1126 - |
|
1127 - | ::pin_project_lite::pin_project! {
|
1128 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1129 - | /// [`RpcV2CborSparseMapsInput`](crate::input::RpcV2CborSparseMapsInput) using modelled bindings.
|
1130 - | pub struct RpcV2CborSparseMapsInputFuture {
|
1131 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborSparseMapsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1132 - | }
|
1133 - | }
|
1134 - |
|
1135 - | impl std::future::Future for RpcV2CborSparseMapsInputFuture {
|
1136 - | type Output = Result<
|
1137 - | crate::input::RpcV2CborSparseMapsInput,
|
1138 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1139 - | >;
|
1140 - |
|
1141 - | fn poll(
|
1142 - | self: std::pin::Pin<&mut Self>,
|
1143 - | cx: &mut std::task::Context<'_>,
|
1144 - | ) -> std::task::Poll<Self::Output> {
|
1145 - | let this = self.project();
|
1146 - | this.inner.as_mut().poll(cx)
|
1147 - | }
|
1148 - | }
|
1149 - |
|
1150 - | impl<B>
|
1151 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1152 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1153 - | B,
|
1154 - | > for crate::input::RpcV2CborSparseMapsInput
|
1155 - | where
|
1156 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1157 - | B: 'static,
|
1158 - |
|
1159 - | B::Data: Send,
|
1160 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1161 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1162 - | {
|
1163 - | type Rejection =
|
1164 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1165 - | type Future = RpcV2CborSparseMapsInputFuture;
|
1166 - |
|
1167 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1168 - | let fut = async move {
|
1169 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1170 - | request.headers(),
|
1171 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1172 - | ) {
|
1173 - | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1174 - | }
|
1175 - | crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::de_rpc_v2_cbor_sparse_maps_http_request(request)
|
1176 - | .await
|
1177 - | };
|
1178 - | use ::futures_util::future::TryFutureExt;
|
1179 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1180 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1181 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
1182 - | });
|
1183 - | RpcV2CborSparseMapsInputFuture {
|
1184 - | inner: Box::pin(fut),
|
1185 - | }
|
1186 - | }
|
1187 - | }
|
1188 - | impl
|
1189 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1190 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1191 - | > for crate::output::RpcV2CborSparseMapsOutput
|
1192 - | {
|
1193 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1194 - | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_response(self) {
|
1195 - | Ok(response) => response,
|
1196 - | Err(e) => {
|
1197 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1198 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1199 - | }
|
1200 - | }
|
1201 - | }
|
1202 - | }
|
1203 - | impl
|
1204 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1205 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1206 - | > for crate::error::RpcV2CborSparseMapsError
|
1207 - | {
|
1208 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1209 - | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_error(&self) {
|
1210 - | Ok(mut response) => {
|
1211 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1212 - | response
|
1213 - | },
|
1214 - | Err(e) => {
|
1215 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1216 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1217 - | }
|
1218 - | }
|
994 + | .expect("unable to make an HTTP request");
|
995 + | assert!(
|
996 + | receiver.recv().await.is_some(),
|
997 + | "we expected operation handler to be invoked but it was not entered"
|
998 + | );
|
1219 999 | }
|
1220 - | }
|
1221 - |
|
1222 - | #[allow(unreachable_code, unused_variables)]
|
1223 - | #[cfg(test)]
|
1224 - | mod rpc_v2_cbor_sparse_maps_test {
|
1225 1000 |
|
1226 - | /// Serializes sparse maps
|
1227 - | /// Test ID: RpcV2CborSparseMaps
|
1001 + | /// RpcV2 Cbor should not deserialize null structure values
|
1002 + | /// Test ID: RpcV2CborServerDoesntDeSerializeNullStructureValues
|
1228 1003 | #[::tokio::test]
|
1229 1004 | #[::tracing_test::traced_test]
|
1230 - | async fn rpc_v2_cbor_sparse_maps_request() {
|
1005 + | async fn rpc_v2_cbor_server_doesnt_de_serialize_null_structure_values_request() {
|
1231 1006 | #[allow(unused_mut)]
|
1232 1007 | let mut http_request = ::http::Request::builder()
|
1233 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1008 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1234 1009 | .method("POST")
|
1235 1010 | .header("Accept", "application/cbor")
|
1236 1011 | .header("Content-Type", "application/cbor")
|
1237 1012 | .header("smithy-protocol", "rpc-v2-cbor")
|
1238 1013 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1239 1014 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1240 - | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////".as_bytes(),
|
1015 + | "v2tzdHJpbmdWYWx1Zfb/".as_bytes(),
|
1241 1016 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1242 1017 | )),
|
1243 1018 | ))
|
1244 1019 | .unwrap();
|
1245 1020 | #[allow(unused_mut)]
|
1246 1021 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1247 1022 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1248 1023 | let service =
|
1249 1024 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1250 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1251 - | let sender = sender.clone();
|
1252 - | async move {
|
1253 - | let result = {
|
1254 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1255 - | sparse_struct_map: ::std::option::Option::Some({
|
1256 - | let mut ret = ::std::collections::HashMap::new();
|
1257 - | ret.insert(
|
1258 - | "foo".to_owned(),
|
1259 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1260 - | hi: ::std::option::Option::Some("there".to_owned()),
|
1261 - | }),
|
1262 - | );
|
1263 - | ret.insert(
|
1264 - | "baz".to_owned(),
|
1265 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1266 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
1267 - | }),
|
1268 - | );
|
1269 - | ret
|
1270 - | }),
|
1271 - | sparse_number_map: ::std::option::Option::None,
|
1272 - | sparse_boolean_map: ::std::option::Option::None,
|
1273 - | sparse_string_map: ::std::option::Option::None,
|
1274 - | sparse_set_map: ::std::option::Option::None,
|
1275 - | };
|
1276 - | ::pretty_assertions::assert_eq!(input, expected);
|
1277 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1278 - | sparse_struct_map: ::std::option::Option::None,
|
1279 - | sparse_number_map: ::std::option::Option::None,
|
1280 - | sparse_boolean_map: ::std::option::Option::None,
|
1281 - | sparse_string_map: ::std::option::Option::None,
|
1282 - | sparse_set_map: ::std::option::Option::None,
|
1025 + | .simple_scalar_properties(
|
1026 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
1027 + | let sender = sender.clone();
|
1028 + | async move {
|
1029 + | let result = {
|
1030 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1031 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1032 + | true_boolean_value: ::std::option::Option::None,
|
1033 + | false_boolean_value: ::std::option::Option::None,
|
1034 + | byte_value: ::std::option::Option::None,
|
1035 + | double_value: ::std::option::Option::None,
|
1036 + | float_value: ::std::option::Option::None,
|
1037 + | integer_value: ::std::option::Option::None,
|
1038 + | long_value: ::std::option::Option::None,
|
1039 + | short_value: ::std::option::Option::None,
|
1040 + | string_value: ::std::option::Option::None,
|
1041 + | blob_value: ::std::option::Option::None,
|
1042 + | };
|
1043 + | ::pretty_assertions::assert_eq!(
|
1044 + | input.true_boolean_value,
|
1045 + | expected.true_boolean_value,
|
1046 + | "Unexpected value for `true_boolean_value`"
|
1047 + | );
|
1048 + | ::pretty_assertions::assert_eq!(
|
1049 + | input.false_boolean_value,
|
1050 + | expected.false_boolean_value,
|
1051 + | "Unexpected value for `false_boolean_value`"
|
1052 + | );
|
1053 + | ::pretty_assertions::assert_eq!(
|
1054 + | input.byte_value,
|
1055 + | expected.byte_value,
|
1056 + | "Unexpected value for `byte_value`"
|
1057 + | );
|
1058 + | assert!(
|
1059 + | input.double_value.float_equals(&expected.double_value),
|
1060 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1061 + | expected.double_value,
|
1062 + | input.double_value
|
1063 + | );
|
1064 + | assert!(
|
1065 + | input.float_value.float_equals(&expected.float_value),
|
1066 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1067 + | expected.float_value,
|
1068 + | input.float_value
|
1069 + | );
|
1070 + | ::pretty_assertions::assert_eq!(
|
1071 + | input.integer_value,
|
1072 + | expected.integer_value,
|
1073 + | "Unexpected value for `integer_value`"
|
1074 + | );
|
1075 + | ::pretty_assertions::assert_eq!(
|
1076 + | input.long_value,
|
1077 + | expected.long_value,
|
1078 + | "Unexpected value for `long_value`"
|
1079 + | );
|
1080 + | ::pretty_assertions::assert_eq!(
|
1081 + | input.short_value,
|
1082 + | expected.short_value,
|
1083 + | "Unexpected value for `short_value`"
|
1084 + | );
|
1085 + | ::pretty_assertions::assert_eq!(
|
1086 + | input.string_value,
|
1087 + | expected.string_value,
|
1088 + | "Unexpected value for `string_value`"
|
1089 + | );
|
1090 + | ::pretty_assertions::assert_eq!(
|
1091 + | input.blob_value,
|
1092 + | expected.blob_value,
|
1093 + | "Unexpected value for `blob_value`"
|
1094 + | );
|
1095 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1096 + | true_boolean_value: ::std::option::Option::None,
|
1097 + | false_boolean_value: ::std::option::Option::None,
|
1098 + | byte_value: ::std::option::Option::None,
|
1099 + | double_value: ::std::option::Option::None,
|
1100 + | float_value: ::std::option::Option::None,
|
1101 + | integer_value: ::std::option::Option::None,
|
1102 + | long_value: ::std::option::Option::None,
|
1103 + | short_value: ::std::option::Option::None,
|
1104 + | string_value: ::std::option::Option::None,
|
1105 + | blob_value: ::std::option::Option::None,
|
1106 + | };
|
1107 + | output
|
1283 1108 | };
|
1284 - | Ok(output)
|
1285 - | };
|
1286 - | sender.send(()).await.expect("receiver dropped early");
|
1287 - | result
|
1288 - | }
|
1289 - | })
|
1109 + | sender.send(()).await.expect("receiver dropped early");
|
1110 + | result
|
1111 + | }
|
1112 + | },
|
1113 + | )
|
1290 1114 | .build_unchecked();
|
1291 1115 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1292 1116 | .await
|
1293 1117 | .expect("unable to make an HTTP request");
|
1294 1118 | assert!(
|
1295 1119 | receiver.recv().await.is_some(),
|
1296 1120 | "we expected operation handler to be invoked but it was not entered"
|
1297 1121 | );
|
1298 1122 | }
|
1299 1123 |
|
1300 - | /// Serializes null map values in sparse maps
|
1301 - | /// Test ID: RpcV2CborSerializesNullMapValues
|
1124 + | /// Supports handling NaN float values.
|
1125 + | /// Test ID: RpcV2CborSupportsNaNFloatInputs
|
1302 1126 | #[::tokio::test]
|
1303 1127 | #[::tracing_test::traced_test]
|
1304 - | async fn rpc_v2_cbor_serializes_null_map_values_request() {
|
1305 - | #[allow(unused_mut)]
|
1306 - | let mut http_request = ::http::Request::builder()
|
1307 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1308 - | .method("POST")
|
1309 - | .header("Accept", "application/cbor")
|
1310 - | .header("Content-Type", "application/cbor")
|
1311 - | .header("smithy-protocol", "rpc-v2-cbor")
|
1312 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1313 - | ::bytes::Bytes::copy_from_slice(
|
1314 - | &::aws_smithy_protocol_test::decode_body_data("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1315 - | )
|
1316 - | )).unwrap();
|
1317 - | #[allow(unused_mut)]
|
1318 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1319 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1320 - | let service =
|
1321 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1322 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1323 - | let sender = sender.clone();
|
1324 - | async move {
|
1325 - | let result = {
|
1326 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1327 - | sparse_boolean_map: ::std::option::Option::Some({
|
1328 - | let mut ret = ::std::collections::HashMap::new();
|
1329 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1330 - | ret
|
1331 - | }),
|
1332 - | sparse_number_map: ::std::option::Option::Some({
|
1333 - | let mut ret = ::std::collections::HashMap::new();
|
1334 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1335 - | ret
|
1336 - | }),
|
1337 - | sparse_string_map: ::std::option::Option::Some({
|
1338 - | let mut ret = ::std::collections::HashMap::new();
|
1339 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1340 - | ret
|
1341 - | }),
|
1342 - | sparse_struct_map: ::std::option::Option::Some({
|
1343 - | let mut ret = ::std::collections::HashMap::new();
|
1344 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1345 - | ret
|
1346 - | }),
|
1347 - | sparse_set_map: ::std::option::Option::None,
|
1348 - | };
|
1349 - | ::pretty_assertions::assert_eq!(input, expected);
|
1350 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1351 - | sparse_struct_map: ::std::option::Option::None,
|
1352 - | sparse_number_map: ::std::option::Option::None,
|
1353 - | sparse_boolean_map: ::std::option::Option::None,
|
1354 - | sparse_string_map: ::std::option::Option::None,
|
1355 - | sparse_set_map: ::std::option::Option::None,
|
1356 - | };
|
1357 - | Ok(output)
|
1358 - | };
|
1359 - | sender.send(()).await.expect("receiver dropped early");
|
1360 - | result
|
1361 - | }
|
1362 - | })
|
1363 - | .build_unchecked();
|
1364 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1365 - | .await
|
1366 - | .expect("unable to make an HTTP request");
|
1367 - | assert!(
|
1368 - | receiver.recv().await.is_some(),
|
1369 - | "we expected operation handler to be invoked but it was not entered"
|
1370 - | );
|
1371 - | }
|
1372 - |
|
1373 - | /// A request that contains a sparse map of sets
|
1374 - | /// Test ID: RpcV2CborSerializesSparseSetMap
|
1375 - | #[::tokio::test]
|
1376 - | #[::tracing_test::traced_test]
|
1377 - | async fn rpc_v2_cbor_serializes_sparse_set_map_request() {
|
1128 + | async fn rpc_v2_cbor_supports_na_n_float_inputs_request() {
|
1378 1129 | #[allow(unused_mut)]
|
1379 1130 | let mut http_request = ::http::Request::builder()
|
1380 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1131 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1381 1132 | .method("POST")
|
1382 1133 | .header("Accept", "application/cbor")
|
1383 1134 | .header("Content-Type", "application/cbor")
|
1384 1135 | .header("smithy-protocol", "rpc-v2-cbor")
|
1385 1136 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1386 1137 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1387 - | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=".as_bytes(),
|
1138 + | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/".as_bytes(),
|
1388 1139 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1389 1140 | )),
|
1390 1141 | ))
|
1391 1142 | .unwrap();
|
1392 1143 | #[allow(unused_mut)]
|
1393 1144 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1394 1145 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1395 - | let service =
|
1396 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1397 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1398 - | let sender = sender.clone();
|
1399 - | async move {
|
1400 - | let result = {
|
1401 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1402 - | sparse_set_map: ::std::option::Option::Some({
|
1403 - | let mut ret = ::std::collections::HashMap::new();
|
1404 - | ret.insert(
|
1405 - | "x".to_owned(),
|
1406 - | ::std::option::Option::Some(
|
1407 - | vec![].try_into().expect("this is only used in tests"),
|
1408 - | ),
|
1409 - | );
|
1410 - | ret.insert(
|
1411 - | "y".to_owned(),
|
1412 - | ::std::option::Option::Some(
|
1413 - | vec!["a".to_owned(), "b".to_owned()]
|
1414 - | .try_into()
|
1415 - | .expect("this is only used in tests"),
|
1416 - | ),
|
1417 - | );
|
1418 - | ret
|
1419 - | }),
|
1420 - | sparse_struct_map: ::std::option::Option::None,
|
1421 - | sparse_number_map: ::std::option::Option::None,
|
1422 - | sparse_boolean_map: ::std::option::Option::None,
|
1423 - | sparse_string_map: ::std::option::Option::None,
|
1424 - | };
|
1425 - | ::pretty_assertions::assert_eq!(input, expected);
|
1426 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1427 - | sparse_struct_map: ::std::option::Option::None,
|
1428 - | sparse_number_map: ::std::option::Option::None,
|
1429 - | sparse_boolean_map: ::std::option::Option::None,
|
1430 - | sparse_string_map: ::std::option::Option::None,
|
1431 - | sparse_set_map: ::std::option::Option::None,
|
1432 - | };
|
1433 - | Ok(output)
|
1434 - | };
|
1435 - | sender.send(()).await.expect("receiver dropped early");
|
1436 - | result
|
1437 - | }
|
1438 - | })
|
1439 - | .build_unchecked();
|
1146 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
1147 + | config,
|
1148 + | )
|
1149 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
1150 + | let sender = sender.clone();
|
1151 + | async move {
|
1152 + | let result = {
|
1153 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1154 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1155 + | double_value: ::std::option::Option::Some(
|
1156 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1157 + | "NaN",
|
1158 + | )
|
1159 + | .expect("invalid string for number"),
|
1160 + | ),
|
1161 + | float_value: ::std::option::Option::Some(
|
1162 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1163 + | "NaN",
|
1164 + | )
|
1165 + | .expect("invalid string for number"),
|
1166 + | ),
|
1167 + | true_boolean_value: ::std::option::Option::None,
|
1168 + | false_boolean_value: ::std::option::Option::None,
|
1169 + | byte_value: ::std::option::Option::None,
|
1170 + | integer_value: ::std::option::Option::None,
|
1171 + | long_value: ::std::option::Option::None,
|
1172 + | short_value: ::std::option::Option::None,
|
1173 + | string_value: ::std::option::Option::None,
|
1174 + | blob_value: ::std::option::Option::None,
|
1175 + | };
|
1176 + | ::pretty_assertions::assert_eq!(
|
1177 + | input.true_boolean_value,
|
1178 + | expected.true_boolean_value,
|
1179 + | "Unexpected value for `true_boolean_value`"
|
1180 + | );
|
1181 + | ::pretty_assertions::assert_eq!(
|
1182 + | input.false_boolean_value,
|
1183 + | expected.false_boolean_value,
|
1184 + | "Unexpected value for `false_boolean_value`"
|
1185 + | );
|
1186 + | ::pretty_assertions::assert_eq!(
|
1187 + | input.byte_value,
|
1188 + | expected.byte_value,
|
1189 + | "Unexpected value for `byte_value`"
|
1190 + | );
|
1191 + | assert!(
|
1192 + | input.double_value.float_equals(&expected.double_value),
|
1193 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1194 + | expected.double_value,
|
1195 + | input.double_value
|
1196 + | );
|
1197 + | assert!(
|
1198 + | input.float_value.float_equals(&expected.float_value),
|
1199 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1200 + | expected.float_value,
|
1201 + | input.float_value
|
1202 + | );
|
1203 + | ::pretty_assertions::assert_eq!(
|
1204 + | input.integer_value,
|
1205 + | expected.integer_value,
|
1206 + | "Unexpected value for `integer_value`"
|
1207 + | );
|
1208 + | ::pretty_assertions::assert_eq!(
|
1209 + | input.long_value,
|
1210 + | expected.long_value,
|
1211 + | "Unexpected value for `long_value`"
|
1212 + | );
|
1213 + | ::pretty_assertions::assert_eq!(
|
1214 + | input.short_value,
|
1215 + | expected.short_value,
|
1216 + | "Unexpected value for `short_value`"
|
1217 + | );
|
1218 + | ::pretty_assertions::assert_eq!(
|
1219 + | input.string_value,
|
1220 + | expected.string_value,
|
1221 + | "Unexpected value for `string_value`"
|
1222 + | );
|
1223 + | ::pretty_assertions::assert_eq!(
|
1224 + | input.blob_value,
|
1225 + | expected.blob_value,
|
1226 + | "Unexpected value for `blob_value`"
|
1227 + | );
|
1228 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1229 + | true_boolean_value: ::std::option::Option::None,
|
1230 + | false_boolean_value: ::std::option::Option::None,
|
1231 + | byte_value: ::std::option::Option::None,
|
1232 + | double_value: ::std::option::Option::None,
|
1233 + | float_value: ::std::option::Option::None,
|
1234 + | integer_value: ::std::option::Option::None,
|
1235 + | long_value: ::std::option::Option::None,
|
1236 + | short_value: ::std::option::Option::None,
|
1237 + | string_value: ::std::option::Option::None,
|
1238 + | blob_value: ::std::option::Option::None,
|
1239 + | };
|
1240 + | output
|
1241 + | };
|
1242 + | sender.send(()).await.expect("receiver dropped early");
|
1243 + | result
|
1244 + | }
|
1245 + | })
|
1246 + | .build_unchecked();
|
1440 1247 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1441 1248 | .await
|
1442 1249 | .expect("unable to make an HTTP request");
|
1443 1250 | assert!(
|
1444 1251 | receiver.recv().await.is_some(),
|
1445 1252 | "we expected operation handler to be invoked but it was not entered"
|
1446 1253 | );
|
1447 1254 | }
|
1448 1255 |
|
1449 - | /// A request that contains a sparse map of sets.
|
1450 - | /// Test ID: RpcV2CborSerializesSparseSetMapAndRetainsNull
|
1256 + | /// Supports handling Infinity float values.
|
1257 + | /// Test ID: RpcV2CborSupportsInfinityFloatInputs
|
1451 1258 | #[::tokio::test]
|
1452 1259 | #[::tracing_test::traced_test]
|
1453 - | async fn rpc_v2_cbor_serializes_sparse_set_map_and_retains_null_request() {
|
1260 + | async fn rpc_v2_cbor_supports_infinity_float_inputs_request() {
|
1454 1261 | #[allow(unused_mut)]
|
1455 1262 | let mut http_request = ::http::Request::builder()
|
1456 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1263 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1457 1264 | .method("POST")
|
1458 1265 | .header("Accept", "application/cbor")
|
1459 1266 | .header("Content-Type", "application/cbor")
|
1460 1267 | .header("smithy-protocol", "rpc-v2-cbor")
|
1461 1268 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1462 1269 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1463 - | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=".as_bytes(),
|
1270 + | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/".as_bytes(),
|
1464 1271 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1465 1272 | )),
|
1466 1273 | ))
|
1467 1274 | .unwrap();
|
1468 1275 | #[allow(unused_mut)]
|
1469 1276 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1470 1277 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1471 - | let service =
|
1472 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1473 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1474 - | let sender = sender.clone();
|
1475 - | async move {
|
1476 - | let result = {
|
1477 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1478 - | sparse_set_map: ::std::option::Option::Some({
|
1479 - | let mut ret = ::std::collections::HashMap::new();
|
1480 - | ret.insert(
|
1481 - | "x".to_owned(),
|
1482 - | ::std::option::Option::Some(
|
1483 - | vec![].try_into().expect("this is only used in tests"),
|
1484 - | ),
|
1485 - | );
|
1486 - | ret.insert(
|
1487 - | "y".to_owned(),
|
1488 - | ::std::option::Option::Some(
|
1489 - | vec!["a".to_owned(), "b".to_owned()]
|
1490 - | .try_into()
|
1491 - | .expect("this is only used in tests"),
|
1492 - | ),
|
1493 - | );
|
1494 - | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1495 - | ret
|
1496 - | }),
|
1497 - | sparse_struct_map: ::std::option::Option::None,
|
1498 - | sparse_number_map: ::std::option::Option::None,
|
1499 - | sparse_boolean_map: ::std::option::Option::None,
|
1500 - | sparse_string_map: ::std::option::Option::None,
|
1501 - | };
|
1502 - | ::pretty_assertions::assert_eq!(input, expected);
|
1503 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1504 - | sparse_struct_map: ::std::option::Option::None,
|
1505 - | sparse_number_map: ::std::option::Option::None,
|
1506 - | sparse_boolean_map: ::std::option::Option::None,
|
1507 - | sparse_string_map: ::std::option::Option::None,
|
1508 - | sparse_set_map: ::std::option::Option::None,
|
1509 - | };
|
1510 - | Ok(output)
|
1511 - | };
|
1512 - | sender.send(()).await.expect("receiver dropped early");
|
1513 - | result
|
1514 - | }
|
1515 - | })
|
1516 - | .build_unchecked();
|
1278 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
1279 + | config,
|
1280 + | )
|
1281 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
1282 + | let sender = sender.clone();
|
1283 + | async move {
|
1284 + | let result = {
|
1285 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1286 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1287 + | double_value: ::std::option::Option::Some(
|
1288 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1289 + | "Infinity",
|
1290 + | )
|
1291 + | .expect("invalid string for number"),
|
1292 + | ),
|
1293 + | float_value: ::std::option::Option::Some(
|
1294 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1295 + | "Infinity",
|
1296 + | )
|
1297 + | .expect("invalid string for number"),
|
1298 + | ),
|
1299 + | true_boolean_value: ::std::option::Option::None,
|
1300 + | false_boolean_value: ::std::option::Option::None,
|
1301 + | byte_value: ::std::option::Option::None,
|
1302 + | integer_value: ::std::option::Option::None,
|
1303 + | long_value: ::std::option::Option::None,
|
1304 + | short_value: ::std::option::Option::None,
|
1305 + | string_value: ::std::option::Option::None,
|
1306 + | blob_value: ::std::option::Option::None,
|
1307 + | };
|
1308 + | ::pretty_assertions::assert_eq!(
|
1309 + | input.true_boolean_value,
|
1310 + | expected.true_boolean_value,
|
1311 + | "Unexpected value for `true_boolean_value`"
|
1312 + | );
|
1313 + | ::pretty_assertions::assert_eq!(
|
1314 + | input.false_boolean_value,
|
1315 + | expected.false_boolean_value,
|
1316 + | "Unexpected value for `false_boolean_value`"
|
1317 + | );
|
1318 + | ::pretty_assertions::assert_eq!(
|
1319 + | input.byte_value,
|
1320 + | expected.byte_value,
|
1321 + | "Unexpected value for `byte_value`"
|
1322 + | );
|
1323 + | assert!(
|
1324 + | input.double_value.float_equals(&expected.double_value),
|
1325 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1326 + | expected.double_value,
|
1327 + | input.double_value
|
1328 + | );
|
1329 + | assert!(
|
1330 + | input.float_value.float_equals(&expected.float_value),
|
1331 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1332 + | expected.float_value,
|
1333 + | input.float_value
|
1334 + | );
|
1335 + | ::pretty_assertions::assert_eq!(
|
1336 + | input.integer_value,
|
1337 + | expected.integer_value,
|
1338 + | "Unexpected value for `integer_value`"
|
1339 + | );
|
1340 + | ::pretty_assertions::assert_eq!(
|
1341 + | input.long_value,
|
1342 + | expected.long_value,
|
1343 + | "Unexpected value for `long_value`"
|
1344 + | );
|
1345 + | ::pretty_assertions::assert_eq!(
|
1346 + | input.short_value,
|
1347 + | expected.short_value,
|
1348 + | "Unexpected value for `short_value`"
|
1349 + | );
|
1350 + | ::pretty_assertions::assert_eq!(
|
1351 + | input.string_value,
|
1352 + | expected.string_value,
|
1353 + | "Unexpected value for `string_value`"
|
1354 + | );
|
1355 + | ::pretty_assertions::assert_eq!(
|
1356 + | input.blob_value,
|
1357 + | expected.blob_value,
|
1358 + | "Unexpected value for `blob_value`"
|
1359 + | );
|
1360 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1361 + | true_boolean_value: ::std::option::Option::None,
|
1362 + | false_boolean_value: ::std::option::Option::None,
|
1363 + | byte_value: ::std::option::Option::None,
|
1364 + | double_value: ::std::option::Option::None,
|
1365 + | float_value: ::std::option::Option::None,
|
1366 + | integer_value: ::std::option::Option::None,
|
1367 + | long_value: ::std::option::Option::None,
|
1368 + | short_value: ::std::option::Option::None,
|
1369 + | string_value: ::std::option::Option::None,
|
1370 + | blob_value: ::std::option::Option::None,
|
1371 + | };
|
1372 + | output
|
1373 + | };
|
1374 + | sender.send(()).await.expect("receiver dropped early");
|
1375 + | result
|
1376 + | }
|
1377 + | })
|
1378 + | .build_unchecked();
|
1517 1379 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1518 1380 | .await
|
1519 1381 | .expect("unable to make an HTTP request");
|
1520 1382 | assert!(
|
1521 1383 | receiver.recv().await.is_some(),
|
1522 1384 | "we expected operation handler to be invoked but it was not entered"
|
1523 1385 | );
|
1524 1386 | }
|
1525 1387 |
|
1526 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1527 - | /// Test ID: RpcV2CborSerializesZeroValuesInSparseMaps
|
1388 + | /// Supports handling Infinity float values.
|
1389 + | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatInputs
|
1528 1390 | #[::tokio::test]
|
1529 1391 | #[::tracing_test::traced_test]
|
1530 - | async fn rpc_v2_cbor_serializes_zero_values_in_sparse_maps_request() {
|
1392 + | async fn rpc_v2_cbor_supports_negative_infinity_float_inputs_request() {
|
1531 1393 | #[allow(unused_mut)]
|
1532 1394 | let mut http_request = ::http::Request::builder()
|
1533 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1395 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1534 1396 | .method("POST")
|
1535 1397 | .header("Accept", "application/cbor")
|
1536 1398 | .header("Content-Type", "application/cbor")
|
1537 1399 | .header("smithy-protocol", "rpc-v2-cbor")
|
1538 1400 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1539 1401 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1540 - | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//".as_bytes(),
|
1402 + | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/".as_bytes(),
|
1541 1403 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1542 1404 | )),
|
1543 1405 | ))
|
1544 1406 | .unwrap();
|
1545 1407 | #[allow(unused_mut)]
|
1546 1408 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1547 1409 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1410 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
1411 + | config,
|
1412 + | )
|
1413 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
1414 + | let sender = sender.clone();
|
1415 + | async move {
|
1416 + | let result = {
|
1417 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1418 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1419 + | double_value: ::std::option::Option::Some(
|
1420 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1421 + | "-Infinity",
|
1422 + | )
|
1423 + | .expect("invalid string for number"),
|
1424 + | ),
|
1425 + | float_value: ::std::option::Option::Some(
|
1426 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1427 + | "-Infinity",
|
1428 + | )
|
1429 + | .expect("invalid string for number"),
|
1430 + | ),
|
1431 + | true_boolean_value: ::std::option::Option::None,
|
1432 + | false_boolean_value: ::std::option::Option::None,
|
1433 + | byte_value: ::std::option::Option::None,
|
1434 + | integer_value: ::std::option::Option::None,
|
1435 + | long_value: ::std::option::Option::None,
|
1436 + | short_value: ::std::option::Option::None,
|
1437 + | string_value: ::std::option::Option::None,
|
1438 + | blob_value: ::std::option::Option::None,
|
1439 + | };
|
1440 + | ::pretty_assertions::assert_eq!(
|
1441 + | input.true_boolean_value,
|
1442 + | expected.true_boolean_value,
|
1443 + | "Unexpected value for `true_boolean_value`"
|
1444 + | );
|
1445 + | ::pretty_assertions::assert_eq!(
|
1446 + | input.false_boolean_value,
|
1447 + | expected.false_boolean_value,
|
1448 + | "Unexpected value for `false_boolean_value`"
|
1449 + | );
|
1450 + | ::pretty_assertions::assert_eq!(
|
1451 + | input.byte_value,
|
1452 + | expected.byte_value,
|
1453 + | "Unexpected value for `byte_value`"
|
1454 + | );
|
1455 + | assert!(
|
1456 + | input.double_value.float_equals(&expected.double_value),
|
1457 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1458 + | expected.double_value,
|
1459 + | input.double_value
|
1460 + | );
|
1461 + | assert!(
|
1462 + | input.float_value.float_equals(&expected.float_value),
|
1463 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1464 + | expected.float_value,
|
1465 + | input.float_value
|
1466 + | );
|
1467 + | ::pretty_assertions::assert_eq!(
|
1468 + | input.integer_value,
|
1469 + | expected.integer_value,
|
1470 + | "Unexpected value for `integer_value`"
|
1471 + | );
|
1472 + | ::pretty_assertions::assert_eq!(
|
1473 + | input.long_value,
|
1474 + | expected.long_value,
|
1475 + | "Unexpected value for `long_value`"
|
1476 + | );
|
1477 + | ::pretty_assertions::assert_eq!(
|
1478 + | input.short_value,
|
1479 + | expected.short_value,
|
1480 + | "Unexpected value for `short_value`"
|
1481 + | );
|
1482 + | ::pretty_assertions::assert_eq!(
|
1483 + | input.string_value,
|
1484 + | expected.string_value,
|
1485 + | "Unexpected value for `string_value`"
|
1486 + | );
|
1487 + | ::pretty_assertions::assert_eq!(
|
1488 + | input.blob_value,
|
1489 + | expected.blob_value,
|
1490 + | "Unexpected value for `blob_value`"
|
1491 + | );
|
1492 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1493 + | true_boolean_value: ::std::option::Option::None,
|
1494 + | false_boolean_value: ::std::option::Option::None,
|
1495 + | byte_value: ::std::option::Option::None,
|
1496 + | double_value: ::std::option::Option::None,
|
1497 + | float_value: ::std::option::Option::None,
|
1498 + | integer_value: ::std::option::Option::None,
|
1499 + | long_value: ::std::option::Option::None,
|
1500 + | short_value: ::std::option::Option::None,
|
1501 + | string_value: ::std::option::Option::None,
|
1502 + | blob_value: ::std::option::Option::None,
|
1503 + | };
|
1504 + | output
|
1505 + | };
|
1506 + | sender.send(()).await.expect("receiver dropped early");
|
1507 + | result
|
1508 + | }
|
1509 + | })
|
1510 + | .build_unchecked();
|
1511 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1512 + | .await
|
1513 + | .expect("unable to make an HTTP request");
|
1514 + | assert!(
|
1515 + | receiver.recv().await.is_some(),
|
1516 + | "we expected operation handler to be invoked but it was not entered"
|
1517 + | );
|
1518 + | }
|
1519 + |
|
1520 + | /// The server should be capable of deserializing indefinite length text strings.
|
1521 + | /// Test ID: RpcV2CborIndefiniteLengthStringsCanBeDeserialized
|
1522 + | #[::tokio::test]
|
1523 + | #[::tracing_test::traced_test]
|
1524 + | async fn rpc_v2_cbor_indefinite_length_strings_can_be_deserialized_request() {
|
1525 + | #[allow(unused_mut)]
|
1526 + | let mut http_request = ::http::Request::builder()
|
1527 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1528 + | .method("POST")
|
1529 + | .header("Accept", "application/cbor")
|
1530 + | .header("Content-Type", "application/cbor")
|
1531 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1532 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1533 + | ::bytes::Bytes::copy_from_slice(
|
1534 + | &::aws_smithy_protocol_test::decode_body_data("oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1535 + | )
|
1536 + | )).unwrap();
|
1537 + | #[allow(unused_mut)]
|
1538 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1539 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1548 1540 | let service =
|
1549 1541 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1550 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1551 - | let sender = sender.clone();
|
1552 - | async move {
|
1553 - | let result = {
|
1554 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1555 - | sparse_number_map: ::std::option::Option::Some({
|
1556 - | let mut ret = ::std::collections::HashMap::new();
|
1557 - | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1558 - | ret
|
1559 - | }),
|
1560 - | sparse_boolean_map: ::std::option::Option::Some({
|
1561 - | let mut ret = ::std::collections::HashMap::new();
|
1562 - | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
1563 - | ret
|
1564 - | }),
|
1565 - | sparse_struct_map: ::std::option::Option::None,
|
1566 - | sparse_string_map: ::std::option::Option::None,
|
1567 - | sparse_set_map: ::std::option::Option::None,
|
1542 + | .simple_scalar_properties(
|
1543 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
1544 + | let sender = sender.clone();
|
1545 + | async move {
|
1546 + | let result = {
|
1547 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1548 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1549 + | string_value: ::std::option::Option::Some(
|
1550 + | "An example indefinite string, chunked on comma".to_owned(),
|
1551 + | ),
|
1552 + | true_boolean_value: ::std::option::Option::None,
|
1553 + | false_boolean_value: ::std::option::Option::None,
|
1554 + | byte_value: ::std::option::Option::None,
|
1555 + | double_value: ::std::option::Option::None,
|
1556 + | float_value: ::std::option::Option::None,
|
1557 + | integer_value: ::std::option::Option::None,
|
1558 + | long_value: ::std::option::Option::None,
|
1559 + | short_value: ::std::option::Option::None,
|
1560 + | blob_value: ::std::option::Option::None,
|
1561 + | };
|
1562 + | ::pretty_assertions::assert_eq!(
|
1563 + | input.true_boolean_value,
|
1564 + | expected.true_boolean_value,
|
1565 + | "Unexpected value for `true_boolean_value`"
|
1566 + | );
|
1567 + | ::pretty_assertions::assert_eq!(
|
1568 + | input.false_boolean_value,
|
1569 + | expected.false_boolean_value,
|
1570 + | "Unexpected value for `false_boolean_value`"
|
1571 + | );
|
1572 + | ::pretty_assertions::assert_eq!(
|
1573 + | input.byte_value,
|
1574 + | expected.byte_value,
|
1575 + | "Unexpected value for `byte_value`"
|
1576 + | );
|
1577 + | assert!(
|
1578 + | input.double_value.float_equals(&expected.double_value),
|
1579 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1580 + | expected.double_value,
|
1581 + | input.double_value
|
1582 + | );
|
1583 + | assert!(
|
1584 + | input.float_value.float_equals(&expected.float_value),
|
1585 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1586 + | expected.float_value,
|
1587 + | input.float_value
|
1588 + | );
|
1589 + | ::pretty_assertions::assert_eq!(
|
1590 + | input.integer_value,
|
1591 + | expected.integer_value,
|
1592 + | "Unexpected value for `integer_value`"
|
1593 + | );
|
1594 + | ::pretty_assertions::assert_eq!(
|
1595 + | input.long_value,
|
1596 + | expected.long_value,
|
1597 + | "Unexpected value for `long_value`"
|
1598 + | );
|
1599 + | ::pretty_assertions::assert_eq!(
|
1600 + | input.short_value,
|
1601 + | expected.short_value,
|
1602 + | "Unexpected value for `short_value`"
|
1603 + | );
|
1604 + | ::pretty_assertions::assert_eq!(
|
1605 + | input.string_value,
|
1606 + | expected.string_value,
|
1607 + | "Unexpected value for `string_value`"
|
1608 + | );
|
1609 + | ::pretty_assertions::assert_eq!(
|
1610 + | input.blob_value,
|
1611 + | expected.blob_value,
|
1612 + | "Unexpected value for `blob_value`"
|
1613 + | );
|
1614 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1615 + | true_boolean_value: ::std::option::Option::None,
|
1616 + | false_boolean_value: ::std::option::Option::None,
|
1617 + | byte_value: ::std::option::Option::None,
|
1618 + | double_value: ::std::option::Option::None,
|
1619 + | float_value: ::std::option::Option::None,
|
1620 + | integer_value: ::std::option::Option::None,
|
1621 + | long_value: ::std::option::Option::None,
|
1622 + | short_value: ::std::option::Option::None,
|
1623 + | string_value: ::std::option::Option::None,
|
1624 + | blob_value: ::std::option::Option::None,
|
1625 + | };
|
1626 + | output
|
1568 1627 | };
|
1569 - | ::pretty_assertions::assert_eq!(input, expected);
|
1570 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1571 - | sparse_struct_map: ::std::option::Option::None,
|
1572 - | sparse_number_map: ::std::option::Option::None,
|
1573 - | sparse_boolean_map: ::std::option::Option::None,
|
1574 - | sparse_string_map: ::std::option::Option::None,
|
1575 - | sparse_set_map: ::std::option::Option::None,
|
1628 + | sender.send(()).await.expect("receiver dropped early");
|
1629 + | result
|
1630 + | }
|
1631 + | },
|
1632 + | )
|
1633 + | .build_unchecked();
|
1634 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1635 + | .await
|
1636 + | .expect("unable to make an HTTP request");
|
1637 + | assert!(
|
1638 + | receiver.recv().await.is_some(),
|
1639 + | "we expected operation handler to be invoked but it was not entered"
|
1640 + | );
|
1641 + | }
|
1642 + |
|
1643 + | /// The server should be capable of deserializing indefinite length byte strings.
|
1644 + | /// Test ID: RpcV2CborIndefiniteLengthByteStringsCanBeDeserialized
|
1645 + | #[::tokio::test]
|
1646 + | #[::tracing_test::traced_test]
|
1647 + | async fn rpc_v2_cbor_indefinite_length_byte_strings_can_be_deserialized_request() {
|
1648 + | #[allow(unused_mut)]
|
1649 + | let mut http_request = ::http::Request::builder()
|
1650 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1651 + | .method("POST")
|
1652 + | .header("Accept", "application/cbor")
|
1653 + | .header("Content-Type", "application/cbor")
|
1654 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1655 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1656 + | ::bytes::Bytes::copy_from_slice(
|
1657 + | &::aws_smithy_protocol_test::decode_body_data("oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1658 + | )
|
1659 + | )).unwrap();
|
1660 + | #[allow(unused_mut)]
|
1661 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1662 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1663 + | let service =
|
1664 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1665 + | .simple_scalar_properties(
|
1666 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
1667 + | let sender = sender.clone();
|
1668 + | async move {
|
1669 + | let result = {
|
1670 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1671 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1672 + | blob_value: ::std::option::Option::Some(
|
1673 + | ::aws_smithy_types::Blob::new(
|
1674 + | "An example indefinite-byte string, chunked on comma",
|
1675 + | ),
|
1676 + | ),
|
1677 + | true_boolean_value: ::std::option::Option::None,
|
1678 + | false_boolean_value: ::std::option::Option::None,
|
1679 + | byte_value: ::std::option::Option::None,
|
1680 + | double_value: ::std::option::Option::None,
|
1681 + | float_value: ::std::option::Option::None,
|
1682 + | integer_value: ::std::option::Option::None,
|
1683 + | long_value: ::std::option::Option::None,
|
1684 + | short_value: ::std::option::Option::None,
|
1685 + | string_value: ::std::option::Option::None,
|
1686 + | };
|
1687 + | ::pretty_assertions::assert_eq!(
|
1688 + | input.true_boolean_value,
|
1689 + | expected.true_boolean_value,
|
1690 + | "Unexpected value for `true_boolean_value`"
|
1691 + | );
|
1692 + | ::pretty_assertions::assert_eq!(
|
1693 + | input.false_boolean_value,
|
1694 + | expected.false_boolean_value,
|
1695 + | "Unexpected value for `false_boolean_value`"
|
1696 + | );
|
1697 + | ::pretty_assertions::assert_eq!(
|
1698 + | input.byte_value,
|
1699 + | expected.byte_value,
|
1700 + | "Unexpected value for `byte_value`"
|
1701 + | );
|
1702 + | assert!(
|
1703 + | input.double_value.float_equals(&expected.double_value),
|
1704 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1705 + | expected.double_value,
|
1706 + | input.double_value
|
1707 + | );
|
1708 + | assert!(
|
1709 + | input.float_value.float_equals(&expected.float_value),
|
1710 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1711 + | expected.float_value,
|
1712 + | input.float_value
|
1713 + | );
|
1714 + | ::pretty_assertions::assert_eq!(
|
1715 + | input.integer_value,
|
1716 + | expected.integer_value,
|
1717 + | "Unexpected value for `integer_value`"
|
1718 + | );
|
1719 + | ::pretty_assertions::assert_eq!(
|
1720 + | input.long_value,
|
1721 + | expected.long_value,
|
1722 + | "Unexpected value for `long_value`"
|
1723 + | );
|
1724 + | ::pretty_assertions::assert_eq!(
|
1725 + | input.short_value,
|
1726 + | expected.short_value,
|
1727 + | "Unexpected value for `short_value`"
|
1728 + | );
|
1729 + | ::pretty_assertions::assert_eq!(
|
1730 + | input.string_value,
|
1731 + | expected.string_value,
|
1732 + | "Unexpected value for `string_value`"
|
1733 + | );
|
1734 + | ::pretty_assertions::assert_eq!(
|
1735 + | input.blob_value,
|
1736 + | expected.blob_value,
|
1737 + | "Unexpected value for `blob_value`"
|
1738 + | );
|
1739 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1740 + | true_boolean_value: ::std::option::Option::None,
|
1741 + | false_boolean_value: ::std::option::Option::None,
|
1742 + | byte_value: ::std::option::Option::None,
|
1743 + | double_value: ::std::option::Option::None,
|
1744 + | float_value: ::std::option::Option::None,
|
1745 + | integer_value: ::std::option::Option::None,
|
1746 + | long_value: ::std::option::Option::None,
|
1747 + | short_value: ::std::option::Option::None,
|
1748 + | string_value: ::std::option::Option::None,
|
1749 + | blob_value: ::std::option::Option::None,
|
1750 + | };
|
1751 + | output
|
1576 1752 | };
|
1577 - | Ok(output)
|
1578 - | };
|
1579 - | sender.send(()).await.expect("receiver dropped early");
|
1580 - | result
|
1581 - | }
|
1582 - | })
|
1753 + | sender.send(()).await.expect("receiver dropped early");
|
1754 + | result
|
1755 + | }
|
1756 + | },
|
1757 + | )
|
1583 1758 | .build_unchecked();
|
1584 1759 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1585 1760 | .await
|
1586 1761 | .expect("unable to make an HTTP request");
|
1587 1762 | assert!(
|
1588 1763 | receiver.recv().await.is_some(),
|
1589 1764 | "we expected operation handler to be invoked but it was not entered"
|
1590 1765 | );
|
1591 1766 | }
|
1592 1767 |
|
1593 - | /// Deserializes sparse maps
|
1594 - | /// Test ID: RpcV2CborSparseJsonMaps
|
1768 + | /// Supports upcasting from a smaller byte representation of the same data type.
|
1769 + | /// Test ID: RpcV2CborSupportsUpcastingData
|
1595 1770 | #[::tokio::test]
|
1596 1771 | #[::tracing_test::traced_test]
|
1597 - | async fn rpc_v2_cbor_sparse_json_maps_response() {
|
1598 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1599 - | sparse_struct_map: ::std::option::Option::Some({
|
1600 - | let mut ret = ::std::collections::HashMap::new();
|
1601 - | ret.insert(
|
1602 - | "foo".to_owned(),
|
1603 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1604 - | hi: ::std::option::Option::Some("there".to_owned()),
|
1605 - | }),
|
1606 - | );
|
1607 - | ret.insert(
|
1608 - | "baz".to_owned(),
|
1609 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1610 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
1611 - | }),
|
1612 - | );
|
1613 - | ret
|
1614 - | }),
|
1615 - | sparse_number_map: ::std::option::Option::None,
|
1616 - | sparse_boolean_map: ::std::option::Option::None,
|
1617 - | sparse_string_map: ::std::option::Option::None,
|
1618 - | sparse_set_map: ::std::option::Option::None,
|
1619 - | };
|
1620 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1621 - | let http_response = output.into_response();
|
1622 - | ::pretty_assertions::assert_eq!(
|
1623 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1624 - | http_response.status()
|
1625 - | );
|
1626 - | let expected_headers = [
|
1627 - | ("Content-Type", "application/cbor"),
|
1628 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1629 - | ];
|
1630 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1631 - | http_response.headers(),
|
1632 - | expected_headers,
|
1633 - | ));
|
1634 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1635 - | .await
|
1636 - | .expect("unable to extract body to bytes");
|
1637 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1638 - | &body,
|
1639 - | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////",
|
1640 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1641 - | ));
|
1642 - | }
|
1643 - |
|
1644 - | /// Deserializes null map values
|
1645 - | /// Test ID: RpcV2CborDeserializesNullMapValues
|
1646 - | #[::tokio::test]
|
1647 - | #[::tracing_test::traced_test]
|
1648 - | async fn rpc_v2_cbor_deserializes_null_map_values_response() {
|
1649 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1650 - | sparse_boolean_map: ::std::option::Option::Some({
|
1651 - | let mut ret = ::std::collections::HashMap::new();
|
1652 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1653 - | ret
|
1654 - | }),
|
1655 - | sparse_number_map: ::std::option::Option::Some({
|
1656 - | let mut ret = ::std::collections::HashMap::new();
|
1657 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1658 - | ret
|
1659 - | }),
|
1660 - | sparse_string_map: ::std::option::Option::Some({
|
1661 - | let mut ret = ::std::collections::HashMap::new();
|
1662 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1663 - | ret
|
1664 - | }),
|
1665 - | sparse_struct_map: ::std::option::Option::Some({
|
1666 - | let mut ret = ::std::collections::HashMap::new();
|
1667 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1668 - | ret
|
1669 - | }),
|
1670 - | sparse_set_map: ::std::option::Option::None,
|
1671 - | };
|
1672 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1673 - | let http_response = output.into_response();
|
1674 - | ::pretty_assertions::assert_eq!(
|
1675 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1676 - | http_response.status()
|
1677 - | );
|
1678 - | let expected_headers = [
|
1679 - | ("Content-Type", "application/cbor"),
|
1680 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1681 - | ];
|
1682 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1683 - | http_response.headers(),
|
1684 - | expected_headers,
|
1685 - | ));
|
1686 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1772 + | async fn rpc_v2_cbor_supports_upcasting_data_request() {
|
1773 + | #[allow(unused_mut)]
|
1774 + | let mut http_request = ::http::Request::builder()
|
1775 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1776 + | .method("POST")
|
1777 + | .header("Accept", "application/cbor")
|
1778 + | .header("Content-Type", "application/cbor")
|
1779 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1780 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1781 + | ::bytes::Bytes::copy_from_slice(
|
1782 + | &::aws_smithy_protocol_test::decode_body_data("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1783 + | )
|
1784 + | )).unwrap();
|
1785 + | #[allow(unused_mut)]
|
1786 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1787 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1788 + | let service =
|
1789 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1790 + | .simple_scalar_properties(
|
1791 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
1792 + | let sender = sender.clone();
|
1793 + | async move {
|
1794 + | let result = {
|
1795 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1796 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1797 + | double_value: ::std::option::Option::Some(1.5_f64),
|
1798 + | float_value: ::std::option::Option::Some(7.625_f32),
|
1799 + | integer_value: ::std::option::Option::Some(56),
|
1800 + | long_value: ::std::option::Option::Some(256),
|
1801 + | short_value: ::std::option::Option::Some(10),
|
1802 + | true_boolean_value: ::std::option::Option::None,
|
1803 + | false_boolean_value: ::std::option::Option::None,
|
1804 + | byte_value: ::std::option::Option::None,
|
1805 + | string_value: ::std::option::Option::None,
|
1806 + | blob_value: ::std::option::Option::None,
|
1807 + | };
|
1808 + | ::pretty_assertions::assert_eq!(
|
1809 + | input.true_boolean_value,
|
1810 + | expected.true_boolean_value,
|
1811 + | "Unexpected value for `true_boolean_value`"
|
1812 + | );
|
1813 + | ::pretty_assertions::assert_eq!(
|
1814 + | input.false_boolean_value,
|
1815 + | expected.false_boolean_value,
|
1816 + | "Unexpected value for `false_boolean_value`"
|
1817 + | );
|
1818 + | ::pretty_assertions::assert_eq!(
|
1819 + | input.byte_value,
|
1820 + | expected.byte_value,
|
1821 + | "Unexpected value for `byte_value`"
|
1822 + | );
|
1823 + | assert!(
|
1824 + | input.double_value.float_equals(&expected.double_value),
|
1825 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1826 + | expected.double_value,
|
1827 + | input.double_value
|
1828 + | );
|
1829 + | assert!(
|
1830 + | input.float_value.float_equals(&expected.float_value),
|
1831 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1832 + | expected.float_value,
|
1833 + | input.float_value
|
1834 + | );
|
1835 + | ::pretty_assertions::assert_eq!(
|
1836 + | input.integer_value,
|
1837 + | expected.integer_value,
|
1838 + | "Unexpected value for `integer_value`"
|
1839 + | );
|
1840 + | ::pretty_assertions::assert_eq!(
|
1841 + | input.long_value,
|
1842 + | expected.long_value,
|
1843 + | "Unexpected value for `long_value`"
|
1844 + | );
|
1845 + | ::pretty_assertions::assert_eq!(
|
1846 + | input.short_value,
|
1847 + | expected.short_value,
|
1848 + | "Unexpected value for `short_value`"
|
1849 + | );
|
1850 + | ::pretty_assertions::assert_eq!(
|
1851 + | input.string_value,
|
1852 + | expected.string_value,
|
1853 + | "Unexpected value for `string_value`"
|
1854 + | );
|
1855 + | ::pretty_assertions::assert_eq!(
|
1856 + | input.blob_value,
|
1857 + | expected.blob_value,
|
1858 + | "Unexpected value for `blob_value`"
|
1859 + | );
|
1860 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1861 + | true_boolean_value: ::std::option::Option::None,
|
1862 + | false_boolean_value: ::std::option::Option::None,
|
1863 + | byte_value: ::std::option::Option::None,
|
1864 + | double_value: ::std::option::Option::None,
|
1865 + | float_value: ::std::option::Option::None,
|
1866 + | integer_value: ::std::option::Option::None,
|
1867 + | long_value: ::std::option::Option::None,
|
1868 + | short_value: ::std::option::Option::None,
|
1869 + | string_value: ::std::option::Option::None,
|
1870 + | blob_value: ::std::option::Option::None,
|
1871 + | };
|
1872 + | output
|
1873 + | };
|
1874 + | sender.send(()).await.expect("receiver dropped early");
|
1875 + | result
|
1876 + | }
|
1877 + | },
|
1878 + | )
|
1879 + | .build_unchecked();
|
1880 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1687 1881 | .await
|
1688 - | .expect("unable to extract body to bytes");
|
1689 - | ::aws_smithy_protocol_test::assert_ok(
|
1690 - | ::aws_smithy_protocol_test::validate_body(&body, "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1882 + | .expect("unable to make an HTTP request");
|
1883 + | assert!(
|
1884 + | receiver.recv().await.is_some(),
|
1885 + | "we expected operation handler to be invoked but it was not entered"
|
1691 1886 | );
|
1692 1887 | }
|
1693 1888 |
|
1694 - | /// A response that contains a sparse map of sets
|
1695 - | /// Test ID: RpcV2CborDeserializesSparseSetMap
|
1889 + | /// The server should skip over additional fields that are not part of the structure. This allows a
|
1890 + | /// client generated against a newer Smithy model to be able to communicate with a server that is
|
1891 + | /// generated against an older Smithy model.
|
1892 + | /// Test ID: RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByServers
|
1696 1893 | #[::tokio::test]
|
1697 1894 | #[::tracing_test::traced_test]
|
1698 - | async fn rpc_v2_cbor_deserializes_sparse_set_map_response() {
|
1699 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1700 - | sparse_set_map: ::std::option::Option::Some({
|
1701 - | let mut ret = ::std::collections::HashMap::new();
|
1702 - | ret.insert(
|
1703 - | "x".to_owned(),
|
1704 - | ::std::option::Option::Some(
|
1705 - | vec![].try_into().expect("this is only used in tests"),
|
1706 - | ),
|
1707 - | );
|
1708 - | ret.insert(
|
1709 - | "y".to_owned(),
|
1710 - | ::std::option::Option::Some(
|
1711 - | vec!["a".to_owned(), "b".to_owned()]
|
1712 - | .try_into()
|
1713 - | .expect("this is only used in tests"),
|
1714 - | ),
|
1715 - | );
|
1716 - | ret
|
1717 - | }),
|
1718 - | sparse_struct_map: ::std::option::Option::None,
|
1719 - | sparse_number_map: ::std::option::Option::None,
|
1720 - | sparse_boolean_map: ::std::option::Option::None,
|
1721 - | sparse_string_map: ::std::option::Option::None,
|
1722 - | };
|
1723 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1724 - | let http_response = output.into_response();
|
1725 - | ::pretty_assertions::assert_eq!(
|
1726 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1727 - | http_response.status()
|
1728 - | );
|
1729 - | let expected_headers = [
|
1730 - | ("Content-Type", "application/cbor"),
|
1731 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1732 - | ];
|
1733 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1734 - | http_response.headers(),
|
1735 - | expected_headers,
|
1736 - | ));
|
1737 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1738 - | .await
|
1739 - | .expect("unable to extract body to bytes");
|
1740 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1741 - | &body,
|
1742 - | "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=",
|
1743 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1744 - | ));
|
1745 - | }
|
1746 - |
|
1747 - | /// A response that contains a sparse map of sets with a null
|
1748 - | /// Test ID: RpcV2CborDeserializesSparseSetMapAndRetainsNull
|
1749 - | #[::tokio::test]
|
1750 - | #[::tracing_test::traced_test]
|
1751 - | async fn rpc_v2_cbor_deserializes_sparse_set_map_and_retains_null_response() {
|
1752 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1753 - | sparse_set_map: ::std::option::Option::Some({
|
1754 - | let mut ret = ::std::collections::HashMap::new();
|
1755 - | ret.insert(
|
1756 - | "x".to_owned(),
|
1757 - | ::std::option::Option::Some(
|
1758 - | vec![].try_into().expect("this is only used in tests"),
|
1759 - | ),
|
1760 - | );
|
1761 - | ret.insert(
|
1762 - | "y".to_owned(),
|
1763 - | ::std::option::Option::Some(
|
1764 - | vec!["a".to_owned(), "b".to_owned()]
|
1765 - | .try_into()
|
1766 - | .expect("this is only used in tests"),
|
1767 - | ),
|
1768 - | );
|
1769 - | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1770 - | ret
|
1771 - | }),
|
1772 - | sparse_struct_map: ::std::option::Option::None,
|
1773 - | sparse_number_map: ::std::option::Option::None,
|
1774 - | sparse_boolean_map: ::std::option::Option::None,
|
1775 - | sparse_string_map: ::std::option::Option::None,
|
1776 - | };
|
1777 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1778 - | let http_response = output.into_response();
|
1779 - | ::pretty_assertions::assert_eq!(
|
1780 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1781 - | http_response.status()
|
1782 - | );
|
1783 - | let expected_headers = [
|
1784 - | ("Content-Type", "application/cbor"),
|
1785 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1786 - | ];
|
1787 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1788 - | http_response.headers(),
|
1789 - | expected_headers,
|
1790 - | ));
|
1791 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1792 - | .await
|
1793 - | .expect("unable to extract body to bytes");
|
1794 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1795 - | &body,
|
1796 - | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=",
|
1797 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1798 - | ));
|
1799 - | }
|
1800 - |
|
1801 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1802 - | /// Test ID: RpcV2CborDeserializesZeroValuesInSparseMaps
|
1803 - | #[::tokio::test]
|
1804 - | #[::tracing_test::traced_test]
|
1805 - | async fn rpc_v2_cbor_deserializes_zero_values_in_sparse_maps_response() {
|
1806 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1807 - | sparse_number_map: ::std::option::Option::Some({
|
1808 - | let mut ret = ::std::collections::HashMap::new();
|
1809 - | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1810 - | ret
|
1811 - | }),
|
1812 - | sparse_boolean_map: ::std::option::Option::Some({
|
1813 - | let mut ret = ::std::collections::HashMap::new();
|
1814 - | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
1815 - | ret
|
1816 - | }),
|
1817 - | sparse_struct_map: ::std::option::Option::None,
|
1818 - | sparse_string_map: ::std::option::Option::None,
|
1819 - | sparse_set_map: ::std::option::Option::None,
|
1820 - | };
|
1821 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1822 - | let http_response = output.into_response();
|
1823 - | ::pretty_assertions::assert_eq!(
|
1824 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1825 - | http_response.status()
|
1826 - | );
|
1827 - | let expected_headers = [
|
1828 - | ("Content-Type", "application/cbor"),
|
1829 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1830 - | ];
|
1831 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1832 - | http_response.headers(),
|
1833 - | expected_headers,
|
1834 - | ));
|
1835 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1836 - | .await
|
1837 - | .expect("unable to extract body to bytes");
|
1838 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1839 - | &body,
|
1840 - | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//",
|
1841 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1842 - | ));
|
1843 - | }
|
1844 - | }
|
1845 - |
|
1846 - | ::pin_project_lite::pin_project! {
|
1847 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1848 - | /// [`RpcV2CborDenseMapsInput`](crate::input::RpcV2CborDenseMapsInput) using modelled bindings.
|
1849 - | pub struct RpcV2CborDenseMapsInputFuture {
|
1850 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborDenseMapsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1851 - | }
|
1852 - | }
|
1853 - |
|
1854 - | impl std::future::Future for RpcV2CborDenseMapsInputFuture {
|
1855 - | type Output = Result<
|
1856 - | crate::input::RpcV2CborDenseMapsInput,
|
1857 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1858 - | >;
|
1859 - |
|
1860 - | fn poll(
|
1861 - | self: std::pin::Pin<&mut Self>,
|
1862 - | cx: &mut std::task::Context<'_>,
|
1863 - | ) -> std::task::Poll<Self::Output> {
|
1864 - | let this = self.project();
|
1865 - | this.inner.as_mut().poll(cx)
|
1866 - | }
|
1867 - | }
|
1868 - |
|
1869 - | impl<B>
|
1870 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1871 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1872 - | B,
|
1873 - | > for crate::input::RpcV2CborDenseMapsInput
|
1874 - | where
|
1875 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1876 - | B: 'static,
|
1877 - |
|
1878 - | B::Data: Send,
|
1879 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1880 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1881 - | {
|
1882 - | type Rejection =
|
1883 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1884 - | type Future = RpcV2CborDenseMapsInputFuture;
|
1885 - |
|
1886 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1887 - | let fut = async move {
|
1888 - | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1889 - | request.headers(),
|
1890 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1891 - | ) {
|
1892 - | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1893 - | }
|
1894 - | crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::de_rpc_v2_cbor_dense_maps_http_request(request)
|
1895 - | .await
|
1896 - | };
|
1897 - | use ::futures_util::future::TryFutureExt;
|
1898 - | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1899 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1900 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
1901 - | });
|
1902 - | RpcV2CborDenseMapsInputFuture {
|
1903 - | inner: Box::pin(fut),
|
1904 - | }
|
1905 - | }
|
1906 - | }
|
1907 - | impl
|
1908 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1909 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1910 - | > for crate::output::RpcV2CborDenseMapsOutput
|
1911 - | {
|
1912 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1913 - | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_response(self) {
|
1914 - | Ok(response) => response,
|
1915 - | Err(e) => {
|
1916 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1917 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1918 - | }
|
1919 - | }
|
1920 - | }
|
1921 - | }
|
1922 - | impl
|
1923 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1924 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1925 - | > for crate::error::RpcV2CborDenseMapsError
|
1926 - | {
|
1927 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1928 - | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_error(&self) {
|
1929 - | Ok(mut response) => {
|
1930 - | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1931 - | response
|
1932 - | },
|
1933 - | Err(e) => {
|
1934 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1935 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1936 - | }
|
1937 - | }
|
1938 - | }
|
1939 - | }
|
1940 - |
|
1941 - | #[allow(unreachable_code, unused_variables)]
|
1942 - | #[cfg(test)]
|
1943 - | mod rpc_v2_cbor_dense_maps_test {
|
1944 - |
|
1945 - | /// Serializes maps
|
1946 - | /// Test ID: RpcV2CborMaps
|
1947 - | #[::tokio::test]
|
1948 - | #[::tracing_test::traced_test]
|
1949 - | async fn rpc_v2_cbor_maps_request() {
|
1895 + | async fn rpc_v2_cbor_extra_fields_in_the_body_should_be_skipped_by_servers_request() {
|
1950 1896 | #[allow(unused_mut)]
|
1951 - | let mut http_request = ::http::Request::builder()
|
1952 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
1953 - | .method("POST")
|
1954 - | .header("Accept", "application/cbor")
|
1955 - | .header("Content-Type", "application/cbor")
|
1956 - | .header("smithy-protocol", "rpc-v2-cbor")
|
1957 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1958 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1959 - | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==".as_bytes(),
|
1960 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1961 - | )),
|
1962 - | ))
|
1963 - | .unwrap();
|
1897 + | let mut http_request = ::http::Request::builder()
|
1898 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1899 + | .method("POST")
|
1900 + | .header("Accept", "application/cbor")
|
1901 + | .header("Content-Type", "application/cbor")
|
1902 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1903 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1904 + | ::bytes::Bytes::copy_from_slice(
|
1905 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABrZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1906 + | )
|
1907 + | )).unwrap();
|
1964 1908 | #[allow(unused_mut)]
|
1965 1909 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1966 1910 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1967 1911 | let service =
|
1968 1912 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1969 - | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
1970 - | let sender = sender.clone();
|
1971 - | async move {
|
1972 - | let result = {
|
1973 - | let expected = crate::input::RpcV2CborDenseMapsInput {
|
1974 - | dense_struct_map: ::std::option::Option::Some({
|
1975 - | let mut ret = ::std::collections::HashMap::new();
|
1976 - | ret.insert(
|
1977 - | "foo".to_owned(),
|
1978 - | crate::model::GreetingStruct {
|
1979 - | hi: ::std::option::Option::Some("there".to_owned()),
|
1980 - | },
|
1981 - | );
|
1982 - | ret.insert(
|
1983 - | "baz".to_owned(),
|
1984 - | crate::model::GreetingStruct {
|
1985 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
1986 - | },
|
1987 - | );
|
1988 - | ret
|
1989 - | }),
|
1990 - | dense_number_map: ::std::option::Option::None,
|
1991 - | dense_boolean_map: ::std::option::Option::None,
|
1992 - | dense_string_map: ::std::option::Option::None,
|
1993 - | dense_set_map: ::std::option::Option::None,
|
1994 - | };
|
1995 - | ::pretty_assertions::assert_eq!(input, expected);
|
1996 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
1997 - | dense_struct_map: ::std::option::Option::None,
|
1998 - | dense_number_map: ::std::option::Option::None,
|
1999 - | dense_boolean_map: ::std::option::Option::None,
|
2000 - | dense_string_map: ::std::option::Option::None,
|
2001 - | dense_set_map: ::std::option::Option::None,
|
1913 + | .simple_scalar_properties(
|
1914 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
1915 + | let sender = sender.clone();
|
1916 + | async move {
|
1917 + | let result = {
|
1918 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1919 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1920 + | byte_value: ::std::option::Option::Some(5),
|
1921 + | double_value: ::std::option::Option::Some(1.889_f64),
|
1922 + | false_boolean_value: ::std::option::Option::Some(false),
|
1923 + | float_value: ::std::option::Option::Some(7.625_f32),
|
1924 + | integer_value: ::std::option::Option::Some(256),
|
1925 + | long_value: ::std::option::Option::Some(9873),
|
1926 + | short_value: ::std::option::Option::Some(9898),
|
1927 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
1928 + | true_boolean_value: ::std::option::Option::Some(true),
|
1929 + | blob_value: ::std::option::Option::Some(
|
1930 + | ::aws_smithy_types::Blob::new("foo"),
|
1931 + | ),
|
1932 + | };
|
1933 + | ::pretty_assertions::assert_eq!(
|
1934 + | input.true_boolean_value,
|
1935 + | expected.true_boolean_value,
|
1936 + | "Unexpected value for `true_boolean_value`"
|
1937 + | );
|
1938 + | ::pretty_assertions::assert_eq!(
|
1939 + | input.false_boolean_value,
|
1940 + | expected.false_boolean_value,
|
1941 + | "Unexpected value for `false_boolean_value`"
|
1942 + | );
|
1943 + | ::pretty_assertions::assert_eq!(
|
1944 + | input.byte_value,
|
1945 + | expected.byte_value,
|
1946 + | "Unexpected value for `byte_value`"
|
1947 + | );
|
1948 + | assert!(
|
1949 + | input.double_value.float_equals(&expected.double_value),
|
1950 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1951 + | expected.double_value,
|
1952 + | input.double_value
|
1953 + | );
|
1954 + | assert!(
|
1955 + | input.float_value.float_equals(&expected.float_value),
|
1956 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1957 + | expected.float_value,
|
1958 + | input.float_value
|
1959 + | );
|
1960 + | ::pretty_assertions::assert_eq!(
|
1961 + | input.integer_value,
|
1962 + | expected.integer_value,
|
1963 + | "Unexpected value for `integer_value`"
|
1964 + | );
|
1965 + | ::pretty_assertions::assert_eq!(
|
1966 + | input.long_value,
|
1967 + | expected.long_value,
|
1968 + | "Unexpected value for `long_value`"
|
1969 + | );
|
1970 + | ::pretty_assertions::assert_eq!(
|
1971 + | input.short_value,
|
1972 + | expected.short_value,
|
1973 + | "Unexpected value for `short_value`"
|
1974 + | );
|
1975 + | ::pretty_assertions::assert_eq!(
|
1976 + | input.string_value,
|
1977 + | expected.string_value,
|
1978 + | "Unexpected value for `string_value`"
|
1979 + | );
|
1980 + | ::pretty_assertions::assert_eq!(
|
1981 + | input.blob_value,
|
1982 + | expected.blob_value,
|
1983 + | "Unexpected value for `blob_value`"
|
1984 + | );
|
1985 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1986 + | true_boolean_value: ::std::option::Option::None,
|
1987 + | false_boolean_value: ::std::option::Option::None,
|
1988 + | byte_value: ::std::option::Option::None,
|
1989 + | double_value: ::std::option::Option::None,
|
1990 + | float_value: ::std::option::Option::None,
|
1991 + | integer_value: ::std::option::Option::None,
|
1992 + | long_value: ::std::option::Option::None,
|
1993 + | short_value: ::std::option::Option::None,
|
1994 + | string_value: ::std::option::Option::None,
|
1995 + | blob_value: ::std::option::Option::None,
|
1996 + | };
|
1997 + | output
|
2002 1998 | };
|
2003 - | Ok(output)
|
2004 - | };
|
2005 - | sender.send(()).await.expect("receiver dropped early");
|
2006 - | result
|
2007 - | }
|
2008 - | })
|
1999 + | sender.send(()).await.expect("receiver dropped early");
|
2000 + | result
|
2001 + | }
|
2002 + | },
|
2003 + | )
|
2009 2004 | .build_unchecked();
|
2010 2005 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2011 2006 | .await
|
2012 2007 | .expect("unable to make an HTTP request");
|
2013 2008 | assert!(
|
2014 2009 | receiver.recv().await.is_some(),
|
2015 2010 | "we expected operation handler to be invoked but it was not entered"
|
2016 2011 | );
|
2017 2012 | }
|
2018 2013 |
|
2019 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
2020 - | /// Test ID: RpcV2CborSerializesZeroValuesInMaps
|
2014 + | /// Servers should tolerate requests without an Accept header set.
|
2015 + | /// Test ID: RpcV2CborServersShouldHandleNoAcceptHeader
|
2021 2016 | #[::tokio::test]
|
2022 2017 | #[::tracing_test::traced_test]
|
2023 - | async fn rpc_v2_cbor_serializes_zero_values_in_maps_request() {
|
2018 + | async fn rpc_v2_cbor_servers_should_handle_no_accept_header_request() {
|
2024 2019 | #[allow(unused_mut)]
|
2025 - | let mut http_request = ::http::Request::builder()
|
2026 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2027 - | .method("POST")
|
2028 - | .header("Accept", "application/cbor")
|
2029 - | .header("Content-Type", "application/cbor")
|
2030 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2031 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2032 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2033 - | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==".as_bytes(),
|
2034 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2035 - | )),
|
2036 - | ))
|
2037 - | .unwrap();
|
2020 + | let mut http_request = ::http::Request::builder()
|
2021 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
2022 + | .method("POST")
|
2023 + | .header("Content-Type", "application/cbor")
|
2024 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2025 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2026 + | ::bytes::Bytes::copy_from_slice(
|
2027 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2028 + | )
|
2029 + | )).unwrap();
|
2038 2030 | #[allow(unused_mut)]
|
2039 2031 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2040 2032 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2041 2033 | let service =
|
2042 2034 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2043 - | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
2044 - | let sender = sender.clone();
|
2045 - | async move {
|
2046 - | let result = {
|
2047 - | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2048 - | dense_number_map: ::std::option::Option::Some({
|
2049 - | let mut ret = ::std::collections::HashMap::new();
|
2050 - | ret.insert("x".to_owned(), 0);
|
2051 - | ret
|
2052 - | }),
|
2053 - | dense_boolean_map: ::std::option::Option::Some({
|
2054 - | let mut ret = ::std::collections::HashMap::new();
|
2055 - | ret.insert("x".to_owned(), false);
|
2056 - | ret
|
2057 - | }),
|
2058 - | dense_struct_map: ::std::option::Option::None,
|
2059 - | dense_string_map: ::std::option::Option::None,
|
2060 - | dense_set_map: ::std::option::Option::None,
|
2061 - | };
|
2062 - | ::pretty_assertions::assert_eq!(input, expected);
|
2063 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2064 - | dense_struct_map: ::std::option::Option::None,
|
2065 - | dense_number_map: ::std::option::Option::None,
|
2066 - | dense_boolean_map: ::std::option::Option::None,
|
2067 - | dense_string_map: ::std::option::Option::None,
|
2068 - | dense_set_map: ::std::option::Option::None,
|
2035 + | .simple_scalar_properties(
|
2036 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
2037 + | let sender = sender.clone();
|
2038 + | async move {
|
2039 + | let result = {
|
2040 + | use ::aws_smithy_protocol_test::FloatEquals;
|
2041 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
2042 + | byte_value: ::std::option::Option::Some(5),
|
2043 + | double_value: ::std::option::Option::Some(1.889_f64),
|
2044 + | false_boolean_value: ::std::option::Option::Some(false),
|
2045 + | float_value: ::std::option::Option::Some(7.625_f32),
|
2046 + | integer_value: ::std::option::Option::Some(256),
|
2047 + | long_value: ::std::option::Option::Some(9873),
|
2048 + | short_value: ::std::option::Option::Some(9898),
|
2049 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
2050 + | true_boolean_value: ::std::option::Option::Some(true),
|
2051 + | blob_value: ::std::option::Option::Some(
|
2052 + | ::aws_smithy_types::Blob::new("foo"),
|
2053 + | ),
|
2054 + | };
|
2055 + | ::pretty_assertions::assert_eq!(
|
2056 + | input.true_boolean_value,
|
2057 + | expected.true_boolean_value,
|
2058 + | "Unexpected value for `true_boolean_value`"
|
2059 + | );
|
2060 + | ::pretty_assertions::assert_eq!(
|
2061 + | input.false_boolean_value,
|
2062 + | expected.false_boolean_value,
|
2063 + | "Unexpected value for `false_boolean_value`"
|
2064 + | );
|
2065 + | ::pretty_assertions::assert_eq!(
|
2066 + | input.byte_value,
|
2067 + | expected.byte_value,
|
2068 + | "Unexpected value for `byte_value`"
|
2069 + | );
|
2070 + | assert!(
|
2071 + | input.double_value.float_equals(&expected.double_value),
|
2072 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
2073 + | expected.double_value,
|
2074 + | input.double_value
|
2075 + | );
|
2076 + | assert!(
|
2077 + | input.float_value.float_equals(&expected.float_value),
|
2078 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
2079 + | expected.float_value,
|
2080 + | input.float_value
|
2081 + | );
|
2082 + | ::pretty_assertions::assert_eq!(
|
2083 + | input.integer_value,
|
2084 + | expected.integer_value,
|
2085 + | "Unexpected value for `integer_value`"
|
2086 + | );
|
2087 + | ::pretty_assertions::assert_eq!(
|
2088 + | input.long_value,
|
2089 + | expected.long_value,
|
2090 + | "Unexpected value for `long_value`"
|
2091 + | );
|
2092 + | ::pretty_assertions::assert_eq!(
|
2093 + | input.short_value,
|
2094 + | expected.short_value,
|
2095 + | "Unexpected value for `short_value`"
|
2096 + | );
|
2097 + | ::pretty_assertions::assert_eq!(
|
2098 + | input.string_value,
|
2099 + | expected.string_value,
|
2100 + | "Unexpected value for `string_value`"
|
2101 + | );
|
2102 + | ::pretty_assertions::assert_eq!(
|
2103 + | input.blob_value,
|
2104 + | expected.blob_value,
|
2105 + | "Unexpected value for `blob_value`"
|
2106 + | );
|
2107 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2108 + | true_boolean_value: ::std::option::Option::None,
|
2109 + | false_boolean_value: ::std::option::Option::None,
|
2110 + | byte_value: ::std::option::Option::None,
|
2111 + | double_value: ::std::option::Option::None,
|
2112 + | float_value: ::std::option::Option::None,
|
2113 + | integer_value: ::std::option::Option::None,
|
2114 + | long_value: ::std::option::Option::None,
|
2115 + | short_value: ::std::option::Option::None,
|
2116 + | string_value: ::std::option::Option::None,
|
2117 + | blob_value: ::std::option::Option::None,
|
2118 + | };
|
2119 + | output
|
2069 2120 | };
|
2070 - | Ok(output)
|
2071 - | };
|
2072 - | sender.send(()).await.expect("receiver dropped early");
|
2073 - | result
|
2074 - | }
|
2075 - | })
|
2121 + | sender.send(()).await.expect("receiver dropped early");
|
2122 + | result
|
2123 + | }
|
2124 + | },
|
2125 + | )
|
2076 2126 | .build_unchecked();
|
2077 2127 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2078 2128 | .await
|
2079 2129 | .expect("unable to make an HTTP request");
|
2080 2130 | assert!(
|
2081 2131 | receiver.recv().await.is_some(),
|
2082 2132 | "we expected operation handler to be invoked but it was not entered"
|
2083 2133 | );
|
2084 2134 | }
|
2085 2135 |
|
2086 - | /// A request that contains a dense map of sets.
|
2087 - | /// Test ID: RpcV2CborSerializesDenseSetMap
|
2136 + | /// Serializes simple scalar properties
|
2137 + | /// Test ID: RpcV2CborSimpleScalarProperties
|
2088 2138 | #[::tokio::test]
|
2089 2139 | #[::tracing_test::traced_test]
|
2090 - | async fn rpc_v2_cbor_serializes_dense_set_map_request() {
|
2091 - | #[allow(unused_mut)]
|
2092 - | let mut http_request = ::http::Request::builder()
|
2093 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2094 - | .method("POST")
|
2095 - | .header("Accept", "application/cbor")
|
2096 - | .header("Content-Type", "application/cbor")
|
2097 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2098 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2099 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2100 - | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi".as_bytes(),
|
2101 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2102 - | )),
|
2103 - | ))
|
2104 - | .unwrap();
|
2105 - | #[allow(unused_mut)]
|
2106 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2107 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2108 - | let service =
|
2109 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2110 - | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
2111 - | let sender = sender.clone();
|
2112 - | async move {
|
2113 - | let result = {
|
2114 - | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2115 - | dense_set_map: ::std::option::Option::Some({
|
2116 - | let mut ret = ::std::collections::HashMap::new();
|
2117 - | ret.insert(
|
2118 - | "x".to_owned(),
|
2119 - | vec![].try_into().expect("this is only used in tests"),
|
2120 - | );
|
2121 - | ret.insert(
|
2122 - | "y".to_owned(),
|
2123 - | vec!["a".to_owned(), "b".to_owned()]
|
2124 - | .try_into()
|
2125 - | .expect("this is only used in tests"),
|
2126 - | );
|
2127 - | ret
|
2128 - | }),
|
2129 - | dense_struct_map: ::std::option::Option::None,
|
2130 - | dense_number_map: ::std::option::Option::None,
|
2131 - | dense_boolean_map: ::std::option::Option::None,
|
2132 - | dense_string_map: ::std::option::Option::None,
|
2133 - | };
|
2134 - | ::pretty_assertions::assert_eq!(input, expected);
|
2135 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2136 - | dense_struct_map: ::std::option::Option::None,
|
2137 - | dense_number_map: ::std::option::Option::None,
|
2138 - | dense_boolean_map: ::std::option::Option::None,
|
2139 - | dense_string_map: ::std::option::Option::None,
|
2140 - | dense_set_map: ::std::option::Option::None,
|
2141 - | };
|
2142 - | Ok(output)
|
2143 - | };
|
2144 - | sender.send(()).await.expect("receiver dropped early");
|
2145 - | result
|
2146 - | }
|
2147 - | })
|
2148 - | .build_unchecked();
|
2149 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2140 + | async fn rpc_v2_cbor_simple_scalar_properties_response() {
|
2141 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2142 + | true_boolean_value: ::std::option::Option::Some(true),
|
2143 + | false_boolean_value: ::std::option::Option::Some(false),
|
2144 + | byte_value: ::std::option::Option::Some(5),
|
2145 + | double_value: ::std::option::Option::Some(1.889_f64),
|
2146 + | float_value: ::std::option::Option::Some(7.625_f32),
|
2147 + | integer_value: ::std::option::Option::Some(256),
|
2148 + | short_value: ::std::option::Option::Some(9898),
|
2149 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
2150 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new("foo")),
|
2151 + | long_value: ::std::option::Option::None,
|
2152 + | };
|
2153 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2154 + | let http_response = output.into_response();
|
2155 + | ::pretty_assertions::assert_eq!(
|
2156 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2157 + | http_response.status()
|
2158 + | );
|
2159 + | let expected_headers = [
|
2160 + | ("Content-Type", "application/cbor"),
|
2161 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2162 + | ];
|
2163 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2164 + | http_response.headers(),
|
2165 + | expected_headers,
|
2166 + | ));
|
2167 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2150 2168 | .await
|
2151 - | .expect("unable to make an HTTP request");
|
2152 - | assert!(
|
2153 - | receiver.recv().await.is_some(),
|
2154 - | "we expected operation handler to be invoked but it was not entered"
|
2169 + | .expect("unable to extract body to bytes");
|
2170 + | ::aws_smithy_protocol_test::assert_ok(
|
2171 + | ::aws_smithy_protocol_test::validate_body(&body, "v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2155 2172 | );
|
2156 2173 | }
|
2157 2174 |
|
2158 - | /// Deserializes maps
|
2159 - | /// Test ID: RpcV2CborMaps
|
2175 + | /// RpcV2 Cbor should not serialize null structure values
|
2176 + | /// Test ID: RpcV2CborServerDoesntSerializeNullStructureValues
|
2160 2177 | #[::tokio::test]
|
2161 2178 | #[::tracing_test::traced_test]
|
2162 - | async fn rpc_v2_cbor_maps_response() {
|
2163 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2164 - | dense_struct_map: ::std::option::Option::Some({
|
2165 - | let mut ret = ::std::collections::HashMap::new();
|
2166 - | ret.insert(
|
2167 - | "foo".to_owned(),
|
2168 - | crate::model::GreetingStruct {
|
2169 - | hi: ::std::option::Option::Some("there".to_owned()),
|
2170 - | },
|
2171 - | );
|
2172 - | ret.insert(
|
2173 - | "baz".to_owned(),
|
2174 - | crate::model::GreetingStruct {
|
2175 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
2176 - | },
|
2177 - | );
|
2178 - | ret
|
2179 - | }),
|
2180 - | dense_number_map: ::std::option::Option::None,
|
2181 - | dense_boolean_map: ::std::option::Option::None,
|
2182 - | dense_string_map: ::std::option::Option::None,
|
2183 - | dense_set_map: ::std::option::Option::None,
|
2179 + | async fn rpc_v2_cbor_server_doesnt_serialize_null_structure_values_response() {
|
2180 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2181 + | string_value: ::std::option::Option::None,
|
2182 + | true_boolean_value: ::std::option::Option::None,
|
2183 + | false_boolean_value: ::std::option::Option::None,
|
2184 + | byte_value: ::std::option::Option::None,
|
2185 + | double_value: ::std::option::Option::None,
|
2186 + | float_value: ::std::option::Option::None,
|
2187 + | integer_value: ::std::option::Option::None,
|
2188 + | long_value: ::std::option::Option::None,
|
2189 + | short_value: ::std::option::Option::None,
|
2190 + | blob_value: ::std::option::Option::None,
|
2184 2191 | };
|
2185 2192 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2186 2193 | let http_response = output.into_response();
|
2187 2194 | ::pretty_assertions::assert_eq!(
|
2188 2195 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2189 2196 | http_response.status()
|
2190 2197 | );
|
2191 2198 | let expected_headers = [
|
2192 2199 | ("Content-Type", "application/cbor"),
|
2193 2200 | ("smithy-protocol", "rpc-v2-cbor"),
|
2194 2201 | ];
|
2195 2202 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2196 2203 | http_response.headers(),
|
2197 2204 | expected_headers,
|
2198 2205 | ));
|
2199 2206 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2200 2207 | .await
|
2201 2208 | .expect("unable to extract body to bytes");
|
2202 2209 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2203 2210 | &body,
|
2204 - | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==",
|
2211 + | "v/8=",
|
2205 2212 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2206 2213 | ));
|
2207 2214 | }
|
2208 2215 |
|
2209 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
2210 - | /// Test ID: RpcV2CborDeserializesZeroValuesInMaps
|
2216 + | /// Supports handling NaN float values.
|
2217 + | /// Test ID: RpcV2CborSupportsNaNFloatOutputs
|
2211 2218 | #[::tokio::test]
|
2212 2219 | #[::tracing_test::traced_test]
|
2213 - | async fn rpc_v2_cbor_deserializes_zero_values_in_maps_response() {
|
2214 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2215 - | dense_number_map: ::std::option::Option::Some({
|
2216 - | let mut ret = ::std::collections::HashMap::new();
|
2217 - | ret.insert("x".to_owned(), 0);
|
2218 - | ret
|
2219 - | }),
|
2220 - | dense_boolean_map: ::std::option::Option::Some({
|
2221 - | let mut ret = ::std::collections::HashMap::new();
|
2222 - | ret.insert("x".to_owned(), false);
|
2223 - | ret
|
2224 - | }),
|
2225 - | dense_struct_map: ::std::option::Option::None,
|
2226 - | dense_string_map: ::std::option::Option::None,
|
2227 - | dense_set_map: ::std::option::Option::None,
|
2220 + | async fn rpc_v2_cbor_supports_na_n_float_outputs_response() {
|
2221 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2222 + | double_value: ::std::option::Option::Some(
|
2223 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
2224 + | .expect("invalid string for number"),
|
2225 + | ),
|
2226 + | float_value: ::std::option::Option::Some(
|
2227 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
2228 + | .expect("invalid string for number"),
|
2229 + | ),
|
2230 + | true_boolean_value: ::std::option::Option::None,
|
2231 + | false_boolean_value: ::std::option::Option::None,
|
2232 + | byte_value: ::std::option::Option::None,
|
2233 + | integer_value: ::std::option::Option::None,
|
2234 + | long_value: ::std::option::Option::None,
|
2235 + | short_value: ::std::option::Option::None,
|
2236 + | string_value: ::std::option::Option::None,
|
2237 + | blob_value: ::std::option::Option::None,
|
2228 2238 | };
|
2229 2239 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2230 2240 | let http_response = output.into_response();
|
2231 2241 | ::pretty_assertions::assert_eq!(
|
2232 2242 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2233 2243 | http_response.status()
|
2234 2244 | );
|
2235 2245 | let expected_headers = [
|
2236 2246 | ("Content-Type", "application/cbor"),
|
2237 2247 | ("smithy-protocol", "rpc-v2-cbor"),
|
2238 2248 | ];
|
2239 2249 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2240 2250 | http_response.headers(),
|
2241 2251 | expected_headers,
|
2242 2252 | ));
|
2243 2253 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2244 2254 | .await
|
2245 2255 | .expect("unable to extract body to bytes");
|
2246 2256 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2247 2257 | &body,
|
2248 - | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==",
|
2258 + | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/",
|
2249 2259 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2250 2260 | ));
|
2251 2261 | }
|
2252 2262 |
|
2253 - | /// A response that contains a dense map of sets
|
2254 - | /// Test ID: RpcV2CborDeserializesDenseSetMap
|
2263 + | /// Supports handling Infinity float values.
|
2264 + | /// Test ID: RpcV2CborSupportsInfinityFloatOutputs
|
2255 2265 | #[::tokio::test]
|
2256 2266 | #[::tracing_test::traced_test]
|
2257 - | async fn rpc_v2_cbor_deserializes_dense_set_map_response() {
|
2258 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2259 - | dense_set_map: ::std::option::Option::Some({
|
2260 - | let mut ret = ::std::collections::HashMap::new();
|
2261 - | ret.insert(
|
2262 - | "x".to_owned(),
|
2263 - | vec![].try_into().expect("this is only used in tests"),
|
2264 - | );
|
2265 - | ret.insert(
|
2266 - | "y".to_owned(),
|
2267 - | vec!["a".to_owned(), "b".to_owned()]
|
2268 - | .try_into()
|
2269 - | .expect("this is only used in tests"),
|
2270 - | );
|
2271 - | ret
|
2272 - | }),
|
2273 - | dense_struct_map: ::std::option::Option::None,
|
2274 - | dense_number_map: ::std::option::Option::None,
|
2275 - | dense_boolean_map: ::std::option::Option::None,
|
2276 - | dense_string_map: ::std::option::Option::None,
|
2267 + | async fn rpc_v2_cbor_supports_infinity_float_outputs_response() {
|
2268 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2269 + | double_value: ::std::option::Option::Some(
|
2270 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
2271 + | .expect("invalid string for number"),
|
2272 + | ),
|
2273 + | float_value: ::std::option::Option::Some(
|
2274 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
2275 + | .expect("invalid string for number"),
|
2276 + | ),
|
2277 + | true_boolean_value: ::std::option::Option::None,
|
2278 + | false_boolean_value: ::std::option::Option::None,
|
2279 + | byte_value: ::std::option::Option::None,
|
2280 + | integer_value: ::std::option::Option::None,
|
2281 + | long_value: ::std::option::Option::None,
|
2282 + | short_value: ::std::option::Option::None,
|
2283 + | string_value: ::std::option::Option::None,
|
2284 + | blob_value: ::std::option::Option::None,
|
2277 2285 | };
|
2278 2286 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2279 2287 | let http_response = output.into_response();
|
2280 2288 | ::pretty_assertions::assert_eq!(
|
2281 2289 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2282 2290 | http_response.status()
|
2283 2291 | );
|
2284 2292 | let expected_headers = [
|
2285 2293 | ("Content-Type", "application/cbor"),
|
2286 2294 | ("smithy-protocol", "rpc-v2-cbor"),
|
2287 2295 | ];
|
2288 2296 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2289 2297 | http_response.headers(),
|
2290 2298 | expected_headers,
|
2291 2299 | ));
|
2292 2300 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2293 2301 | .await
|
2294 2302 | .expect("unable to extract body to bytes");
|
2295 2303 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2296 2304 | &body,
|
2297 - | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi",
|
2305 + | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/",
|
2298 2306 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2299 2307 | ));
|
2300 2308 | }
|
2301 - | }
|
2302 - |
|
2303 - | ::pin_project_lite::pin_project! {
|
2304 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2305 - | /// [`RpcV2CborListsInput`](crate::input::RpcV2CborListsInput) using modelled bindings.
|
2306 - | pub struct RpcV2CborListsInputFuture {
|
2307 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborListsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2308 - | }
|
2309 - | }
|
2310 - |
|
2311 - | impl std::future::Future for RpcV2CborListsInputFuture {
|
2312 - | type Output = Result<
|
2313 - | crate::input::RpcV2CborListsInput,
|
2314 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
2315 - | >;
|
2316 - |
|
2317 - | fn poll(
|
2318 - | self: std::pin::Pin<&mut Self>,
|
2319 - | cx: &mut std::task::Context<'_>,
|
2320 - | ) -> std::task::Poll<Self::Output> {
|
2321 - | let this = self.project();
|
2322 - | this.inner.as_mut().poll(cx)
|
2323 - | }
|
2324 - | }
|
2325 2309 |
|
2326 - | impl<B>
|
2327 - | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2328 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2329 - | B,
|
2330 - | > for crate::input::RpcV2CborListsInput
|
2331 - | where
|
2332 - | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2333 - | B: 'static,
|
2334 - |
|
2335 - | B::Data: Send,
|
2336 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
2337 - | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2338 - | {
|
2339 - | type Rejection =
|
2340 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
2341 - | type Future = RpcV2CborListsInputFuture;
|
2310 + | /// Supports handling Negative Infinity float values.
|
2311 + | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatOutputs
|
2312 + | #[::tokio::test]
|
2313 + | #[::tracing_test::traced_test]
|
2314 + | async fn rpc_v2_cbor_supports_negative_infinity_float_outputs_response() {
|
2315 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2316 + | double_value: ::std::option::Option::Some(
|
2317 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
2318 + | .expect("invalid string for number"),
|
2319 + | ),
|
2320 + | float_value: ::std::option::Option::Some(
|
2321 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
2322 + | .expect("invalid string for number"),
|
2323 + | ),
|
2324 + | true_boolean_value: ::std::option::Option::None,
|
2325 + | false_boolean_value: ::std::option::Option::None,
|
2326 + | byte_value: ::std::option::Option::None,
|
2327 + | integer_value: ::std::option::Option::None,
|
2328 + | long_value: ::std::option::Option::None,
|
2329 + | short_value: ::std::option::Option::None,
|
2330 + | string_value: ::std::option::Option::None,
|
2331 + | blob_value: ::std::option::Option::None,
|
2332 + | };
|
2333 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2334 + | let http_response = output.into_response();
|
2335 + | ::pretty_assertions::assert_eq!(
|
2336 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2337 + | http_response.status()
|
2338 + | );
|
2339 + | let expected_headers = [
|
2340 + | ("Content-Type", "application/cbor"),
|
2341 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2342 + | ];
|
2343 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2344 + | http_response.headers(),
|
2345 + | expected_headers,
|
2346 + | ));
|
2347 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2348 + | .await
|
2349 + | .expect("unable to extract body to bytes");
|
2350 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2351 + | &body,
|
2352 + | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/",
|
2353 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2354 + | ));
|
2355 + | }
|
2356 + | }
|
2357 + |
|
2358 + | ::pin_project_lite::pin_project! {
|
2359 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2360 + | /// [`RpcV2CborListsInput`](crate::input::RpcV2CborListsInput) using modelled bindings.
|
2361 + | pub struct RpcV2CborListsInputFuture {
|
2362 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborListsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2363 + | }
|
2364 + | }
|
2365 + |
|
2366 + | impl std::future::Future for RpcV2CborListsInputFuture {
|
2367 + | type Output = Result<
|
2368 + | crate::input::RpcV2CborListsInput,
|
2369 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
2370 + | >;
|
2371 + |
|
2372 + | fn poll(
|
2373 + | self: std::pin::Pin<&mut Self>,
|
2374 + | cx: &mut std::task::Context<'_>,
|
2375 + | ) -> std::task::Poll<Self::Output> {
|
2376 + | let this = self.project();
|
2377 + | this.inner.as_mut().poll(cx)
|
2378 + | }
|
2379 + | }
|
2380 + |
|
2381 + | impl<B>
|
2382 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2383 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2384 + | B,
|
2385 + | > for crate::input::RpcV2CborListsInput
|
2386 + | where
|
2387 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2388 + | B: 'static,
|
2389 + |
|
2390 + | B::Data: Send,
|
2391 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
2392 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2393 + | {
|
2394 + | type Rejection =
|
2395 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
2396 + | type Future = RpcV2CborListsInputFuture;
|
2342 2397 |
|
2343 2398 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2344 2399 | let fut = async move {
|
2345 2400 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2346 2401 | request.headers(),
|
2347 2402 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
2348 2403 | ) {
|
2349 2404 | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
2350 2405 | }
|
2351 2406 | crate::protocol_serde::shape_rpc_v2_cbor_lists::de_rpc_v2_cbor_lists_http_request(
|
2899 2954 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2900 2955 | &body,
|
2901 2956 | "v2pzdHJpbmdMaXN0n///",
|
2902 2957 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2903 2958 | ));
|
2904 2959 | }
|
2905 2960 | }
|
2906 2961 |
|
2907 2962 | ::pin_project_lite::pin_project! {
|
2908 2963 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2909 - | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
2910 - | pub struct SimpleScalarPropertiesInputFuture {
|
2911 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2964 + | /// [`RpcV2CborDenseMapsInput`](crate::input::RpcV2CborDenseMapsInput) using modelled bindings.
|
2965 + | pub struct RpcV2CborDenseMapsInputFuture {
|
2966 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborDenseMapsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2912 2967 | }
|
2913 2968 | }
|
2914 2969 |
|
2915 - | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
2970 + | impl std::future::Future for RpcV2CborDenseMapsInputFuture {
|
2916 2971 | type Output = Result<
|
2917 - | crate::input::SimpleScalarPropertiesInput,
|
2972 + | crate::input::RpcV2CborDenseMapsInput,
|
2918 2973 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
2919 2974 | >;
|
2920 2975 |
|
2921 2976 | fn poll(
|
2922 2977 | self: std::pin::Pin<&mut Self>,
|
2923 2978 | cx: &mut std::task::Context<'_>,
|
2924 2979 | ) -> std::task::Poll<Self::Output> {
|
2925 2980 | let this = self.project();
|
2926 2981 | this.inner.as_mut().poll(cx)
|
2927 2982 | }
|
2928 2983 | }
|
2929 2984 |
|
2930 2985 | impl<B>
|
2931 2986 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2932 2987 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2933 2988 | B,
|
2934 - | > for crate::input::SimpleScalarPropertiesInput
|
2989 + | > for crate::input::RpcV2CborDenseMapsInput
|
2935 2990 | where
|
2936 2991 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2937 2992 | B: 'static,
|
2938 2993 |
|
2939 2994 | B::Data: Send,
|
2940 2995 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
2941 2996 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2942 2997 | {
|
2943 2998 | type Rejection =
|
2944 2999 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
2945 - | type Future = SimpleScalarPropertiesInputFuture;
|
3000 + | type Future = RpcV2CborDenseMapsInputFuture;
|
2946 3001 |
|
2947 3002 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2948 3003 | let fut = async move {
|
2949 3004 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2950 3005 | request.headers(),
|
2951 3006 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
2952 3007 | ) {
|
2953 3008 | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
2954 3009 | }
|
2955 - | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
3010 + | crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::de_rpc_v2_cbor_dense_maps_http_request(request)
|
2956 3011 | .await
|
2957 3012 | };
|
2958 3013 | use ::futures_util::future::TryFutureExt;
|
2959 3014 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
2960 3015 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2961 3016 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
2962 3017 | });
|
2963 - | SimpleScalarPropertiesInputFuture {
|
3018 + | RpcV2CborDenseMapsInputFuture {
|
2964 3019 | inner: Box::pin(fut),
|
2965 3020 | }
|
2966 3021 | }
|
2967 3022 | }
|
2968 3023 | impl
|
2969 3024 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2970 3025 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2971 - | > for crate::output::SimpleScalarPropertiesOutput
|
3026 + | > for crate::output::RpcV2CborDenseMapsOutput
|
2972 3027 | {
|
2973 3028 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2974 - | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
3029 + | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_response(self) {
|
2975 3030 | Ok(response) => response,
|
2976 3031 | Err(e) => {
|
2977 3032 | ::tracing::error!(error = %e, "failed to serialize response");
|
2978 3033 | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2979 3034 | }
|
2980 3035 | }
|
2981 3036 | }
|
2982 3037 | }
|
3038 + | impl
|
3039 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3040 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3041 + | > for crate::error::RpcV2CborDenseMapsError
|
3042 + | {
|
3043 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3044 + | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_error(&self) {
|
3045 + | Ok(mut response) => {
|
3046 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
3047 + | response
|
3048 + | },
|
3049 + | Err(e) => {
|
3050 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3051 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3052 + | }
|
3053 + | }
|
3054 + | }
|
3055 + | }
|
2983 3056 |
|
2984 3057 | #[allow(unreachable_code, unused_variables)]
|
2985 3058 | #[cfg(test)]
|
2986 - | mod simple_scalar_properties_test {
|
3059 + | mod rpc_v2_cbor_dense_maps_test {
|
2987 3060 |
|
2988 - | /// Serializes simple scalar properties
|
2989 - | /// Test ID: RpcV2CborSimpleScalarProperties
|
3061 + | /// Serializes maps
|
3062 + | /// Test ID: RpcV2CborMaps
|
2990 3063 | #[::tokio::test]
|
2991 3064 | #[::tracing_test::traced_test]
|
2992 - | async fn rpc_v2_cbor_simple_scalar_properties_request() {
|
3065 + | async fn rpc_v2_cbor_maps_request() {
|
2993 3066 | #[allow(unused_mut)]
|
2994 - | let mut http_request = ::http::Request::builder()
|
2995 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
2996 - | .method("POST")
|
2997 - | .header("Accept", "application/cbor")
|
2998 - | .header("Content-Type", "application/cbor")
|
2999 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3000 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3001 - | ::bytes::Bytes::copy_from_slice(
|
3002 - | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3003 - | )
|
3004 - | )).unwrap();
|
3067 + | let mut http_request = ::http::Request::builder()
|
3068 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
3069 + | .method("POST")
|
3070 + | .header("Accept", "application/cbor")
|
3071 + | .header("Content-Type", "application/cbor")
|
3072 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3073 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3074 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3075 + | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==".as_bytes(),
|
3076 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3077 + | )),
|
3078 + | ))
|
3079 + | .unwrap();
|
3005 3080 | #[allow(unused_mut)]
|
3006 3081 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3007 3082 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3008 3083 | let service =
|
3009 3084 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3010 - | .simple_scalar_properties(
|
3011 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3012 - | let sender = sender.clone();
|
3013 - | async move {
|
3014 - | let result = {
|
3015 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3016 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3017 - | byte_value: ::std::option::Option::Some(5),
|
3018 - | double_value: ::std::option::Option::Some(1.889_f64),
|
3019 - | false_boolean_value: ::std::option::Option::Some(false),
|
3020 - | float_value: ::std::option::Option::Some(7.625_f32),
|
3021 - | integer_value: ::std::option::Option::Some(256),
|
3022 - | long_value: ::std::option::Option::Some(9873),
|
3023 - | short_value: ::std::option::Option::Some(9898),
|
3024 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
3025 - | true_boolean_value: ::std::option::Option::Some(true),
|
3026 - | blob_value: ::std::option::Option::Some(
|
3027 - | ::aws_smithy_types::Blob::new("foo"),
|
3028 - | ),
|
3029 - | };
|
3030 - | ::pretty_assertions::assert_eq!(
|
3031 - | input.true_boolean_value,
|
3032 - | expected.true_boolean_value,
|
3033 - | "Unexpected value for `true_boolean_value`"
|
3034 - | );
|
3035 - | ::pretty_assertions::assert_eq!(
|
3036 - | input.false_boolean_value,
|
3037 - | expected.false_boolean_value,
|
3038 - | "Unexpected value for `false_boolean_value`"
|
3039 - | );
|
3040 - | ::pretty_assertions::assert_eq!(
|
3041 - | input.byte_value,
|
3042 - | expected.byte_value,
|
3043 - | "Unexpected value for `byte_value`"
|
3044 - | );
|
3045 - | assert!(
|
3046 - | input.double_value.float_equals(&expected.double_value),
|
3047 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3048 - | expected.double_value,
|
3049 - | input.double_value
|
3050 - | );
|
3051 - | assert!(
|
3052 - | input.float_value.float_equals(&expected.float_value),
|
3053 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3054 - | expected.float_value,
|
3055 - | input.float_value
|
3056 - | );
|
3057 - | ::pretty_assertions::assert_eq!(
|
3058 - | input.integer_value,
|
3059 - | expected.integer_value,
|
3060 - | "Unexpected value for `integer_value`"
|
3061 - | );
|
3062 - | ::pretty_assertions::assert_eq!(
|
3063 - | input.long_value,
|
3064 - | expected.long_value,
|
3065 - | "Unexpected value for `long_value`"
|
3066 - | );
|
3067 - | ::pretty_assertions::assert_eq!(
|
3068 - | input.short_value,
|
3069 - | expected.short_value,
|
3070 - | "Unexpected value for `short_value`"
|
3071 - | );
|
3072 - | ::pretty_assertions::assert_eq!(
|
3073 - | input.string_value,
|
3074 - | expected.string_value,
|
3075 - | "Unexpected value for `string_value`"
|
3076 - | );
|
3077 - | ::pretty_assertions::assert_eq!(
|
3078 - | input.blob_value,
|
3079 - | expected.blob_value,
|
3080 - | "Unexpected value for `blob_value`"
|
3081 - | );
|
3082 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3083 - | true_boolean_value: ::std::option::Option::None,
|
3084 - | false_boolean_value: ::std::option::Option::None,
|
3085 - | byte_value: ::std::option::Option::None,
|
3086 - | double_value: ::std::option::Option::None,
|
3087 - | float_value: ::std::option::Option::None,
|
3088 - | integer_value: ::std::option::Option::None,
|
3089 - | long_value: ::std::option::Option::None,
|
3090 - | short_value: ::std::option::Option::None,
|
3091 - | string_value: ::std::option::Option::None,
|
3092 - | blob_value: ::std::option::Option::None,
|
3093 - | };
|
3094 - | output
|
3095 - | };
|
3096 - | sender.send(()).await.expect("receiver dropped early");
|
3097 - | result
|
3098 - | }
|
3099 - | },
|
3100 - | )
|
3101 - | .build_unchecked();
|
3102 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3103 - | .await
|
3104 - | .expect("unable to make an HTTP request");
|
3105 - | assert!(
|
3106 - | receiver.recv().await.is_some(),
|
3085 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
3086 + | let sender = sender.clone();
|
3087 + | async move {
|
3088 + | let result = {
|
3089 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
3090 + | dense_struct_map: ::std::option::Option::Some({
|
3091 + | let mut ret = ::std::collections::HashMap::new();
|
3092 + | ret.insert(
|
3093 + | "foo".to_owned(),
|
3094 + | crate::model::GreetingStruct {
|
3095 + | hi: ::std::option::Option::Some("there".to_owned()),
|
3096 + | },
|
3097 + | );
|
3098 + | ret.insert(
|
3099 + | "baz".to_owned(),
|
3100 + | crate::model::GreetingStruct {
|
3101 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
3102 + | },
|
3103 + | );
|
3104 + | ret
|
3105 + | }),
|
3106 + | dense_number_map: ::std::option::Option::None,
|
3107 + | dense_boolean_map: ::std::option::Option::None,
|
3108 + | dense_string_map: ::std::option::Option::None,
|
3109 + | dense_set_map: ::std::option::Option::None,
|
3110 + | };
|
3111 + | ::pretty_assertions::assert_eq!(input, expected);
|
3112 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3113 + | dense_struct_map: ::std::option::Option::None,
|
3114 + | dense_number_map: ::std::option::Option::None,
|
3115 + | dense_boolean_map: ::std::option::Option::None,
|
3116 + | dense_string_map: ::std::option::Option::None,
|
3117 + | dense_set_map: ::std::option::Option::None,
|
3118 + | };
|
3119 + | Ok(output)
|
3120 + | };
|
3121 + | sender.send(()).await.expect("receiver dropped early");
|
3122 + | result
|
3123 + | }
|
3124 + | })
|
3125 + | .build_unchecked();
|
3126 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3127 + | .await
|
3128 + | .expect("unable to make an HTTP request");
|
3129 + | assert!(
|
3130 + | receiver.recv().await.is_some(),
|
3107 3131 | "we expected operation handler to be invoked but it was not entered"
|
3108 3132 | );
|
3109 3133 | }
|
3110 3134 |
|
3111 - | /// The server should be capable of deserializing simple scalar properties
|
3112 - | /// encoded using a map with a definite length. The server should also be able to parse
|
3113 - | /// a key encoded using an indefinite length string.
|
3114 - | /// Test ID: RpcV2CborSimpleScalarPropertiesUsingIndefiniteLength
|
3135 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
3136 + | /// Test ID: RpcV2CborSerializesZeroValuesInMaps
|
3115 3137 | #[::tokio::test]
|
3116 3138 | #[::tracing_test::traced_test]
|
3117 - | async fn rpc_v2_cbor_simple_scalar_properties_using_indefinite_length_request() {
|
3139 + | async fn rpc_v2_cbor_serializes_zero_values_in_maps_request() {
|
3118 3140 | #[allow(unused_mut)]
|
3119 - | let mut http_request = ::http::Request::builder()
|
3120 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3121 - | .method("POST")
|
3122 - | .header("Accept", "application/cbor")
|
3123 - | .header("Content-Type", "application/cbor")
|
3124 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3125 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3126 - | ::bytes::Bytes::copy_from_slice(
|
3127 - | &::aws_smithy_protocol_test::decode_body_data("qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA9AAAbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3128 - | )
|
3129 - | )).unwrap();
|
3141 + | let mut http_request = ::http::Request::builder()
|
3142 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
3143 + | .method("POST")
|
3144 + | .header("Accept", "application/cbor")
|
3145 + | .header("Content-Type", "application/cbor")
|
3146 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3147 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3148 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3149 + | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==".as_bytes(),
|
3150 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3151 + | )),
|
3152 + | ))
|
3153 + | .unwrap();
|
3130 3154 | #[allow(unused_mut)]
|
3131 3155 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3132 3156 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3133 3157 | let service =
|
3134 3158 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3135 - | .simple_scalar_properties(
|
3136 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3137 - | let sender = sender.clone();
|
3138 - | async move {
|
3139 - | let result = {
|
3140 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3141 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3142 - | byte_value: ::std::option::Option::Some(5),
|
3143 - | double_value: ::std::option::Option::Some(1.889_f64),
|
3144 - | false_boolean_value: ::std::option::Option::Some(false),
|
3145 - | float_value: ::std::option::Option::Some(7.625_f32),
|
3146 - | integer_value: ::std::option::Option::Some(256),
|
3147 - | long_value: ::std::option::Option::Some(9873),
|
3148 - | short_value: ::std::option::Option::Some(9898),
|
3149 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
3150 - | true_boolean_value: ::std::option::Option::Some(true),
|
3151 - | blob_value: ::std::option::Option::Some(
|
3152 - | ::aws_smithy_types::Blob::new("foo"),
|
3153 - | ),
|
3154 - | };
|
3155 - | ::pretty_assertions::assert_eq!(
|
3156 - | input.true_boolean_value,
|
3157 - | expected.true_boolean_value,
|
3158 - | "Unexpected value for `true_boolean_value`"
|
3159 - | );
|
3160 - | ::pretty_assertions::assert_eq!(
|
3161 - | input.false_boolean_value,
|
3162 - | expected.false_boolean_value,
|
3163 - | "Unexpected value for `false_boolean_value`"
|
3164 - | );
|
3165 - | ::pretty_assertions::assert_eq!(
|
3166 - | input.byte_value,
|
3167 - | expected.byte_value,
|
3168 - | "Unexpected value for `byte_value`"
|
3169 - | );
|
3170 - | assert!(
|
3171 - | input.double_value.float_equals(&expected.double_value),
|
3172 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3173 - | expected.double_value,
|
3174 - | input.double_value
|
3175 - | );
|
3176 - | assert!(
|
3177 - | input.float_value.float_equals(&expected.float_value),
|
3178 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3179 - | expected.float_value,
|
3180 - | input.float_value
|
3181 - | );
|
3182 - | ::pretty_assertions::assert_eq!(
|
3183 - | input.integer_value,
|
3184 - | expected.integer_value,
|
3185 - | "Unexpected value for `integer_value`"
|
3186 - | );
|
3187 - | ::pretty_assertions::assert_eq!(
|
3188 - | input.long_value,
|
3189 - | expected.long_value,
|
3190 - | "Unexpected value for `long_value`"
|
3191 - | );
|
3192 - | ::pretty_assertions::assert_eq!(
|
3193 - | input.short_value,
|
3194 - | expected.short_value,
|
3195 - | "Unexpected value for `short_value`"
|
3196 - | );
|
3197 - | ::pretty_assertions::assert_eq!(
|
3198 - | input.string_value,
|
3199 - | expected.string_value,
|
3200 - | "Unexpected value for `string_value`"
|
3201 - | );
|
3202 - | ::pretty_assertions::assert_eq!(
|
3203 - | input.blob_value,
|
3204 - | expected.blob_value,
|
3205 - | "Unexpected value for `blob_value`"
|
3206 - | );
|
3207 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3208 - | true_boolean_value: ::std::option::Option::None,
|
3209 - | false_boolean_value: ::std::option::Option::None,
|
3210 - | byte_value: ::std::option::Option::None,
|
3211 - | double_value: ::std::option::Option::None,
|
3212 - | float_value: ::std::option::Option::None,
|
3213 - | integer_value: ::std::option::Option::None,
|
3214 - | long_value: ::std::option::Option::None,
|
3215 - | short_value: ::std::option::Option::None,
|
3216 - | string_value: ::std::option::Option::None,
|
3217 - | blob_value: ::std::option::Option::None,
|
3218 - | };
|
3219 - | output
|
3159 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
3160 + | let sender = sender.clone();
|
3161 + | async move {
|
3162 + | let result = {
|
3163 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
3164 + | dense_number_map: ::std::option::Option::Some({
|
3165 + | let mut ret = ::std::collections::HashMap::new();
|
3166 + | ret.insert("x".to_owned(), 0);
|
3167 + | ret
|
3168 + | }),
|
3169 + | dense_boolean_map: ::std::option::Option::Some({
|
3170 + | let mut ret = ::std::collections::HashMap::new();
|
3171 + | ret.insert("x".to_owned(), false);
|
3172 + | ret
|
3173 + | }),
|
3174 + | dense_struct_map: ::std::option::Option::None,
|
3175 + | dense_string_map: ::std::option::Option::None,
|
3176 + | dense_set_map: ::std::option::Option::None,
|
3220 3177 | };
|
3221 - | sender.send(()).await.expect("receiver dropped early");
|
3222 - | result
|
3223 - | }
|
3224 - | },
|
3225 - | )
|
3178 + | ::pretty_assertions::assert_eq!(input, expected);
|
3179 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3180 + | dense_struct_map: ::std::option::Option::None,
|
3181 + | dense_number_map: ::std::option::Option::None,
|
3182 + | dense_boolean_map: ::std::option::Option::None,
|
3183 + | dense_string_map: ::std::option::Option::None,
|
3184 + | dense_set_map: ::std::option::Option::None,
|
3185 + | };
|
3186 + | Ok(output)
|
3187 + | };
|
3188 + | sender.send(()).await.expect("receiver dropped early");
|
3189 + | result
|
3190 + | }
|
3191 + | })
|
3226 3192 | .build_unchecked();
|
3227 3193 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3228 3194 | .await
|
3229 3195 | .expect("unable to make an HTTP request");
|
3230 3196 | assert!(
|
3231 3197 | receiver.recv().await.is_some(),
|
3232 3198 | "we expected operation handler to be invoked but it was not entered"
|
3233 3199 | );
|
3234 3200 | }
|
3235 3201 |
|
3236 - | /// RpcV2 Cbor should not deserialize null structure values
|
3237 - | /// Test ID: RpcV2CborServerDoesntDeSerializeNullStructureValues
|
3202 + | /// A request that contains a dense map of sets.
|
3203 + | /// Test ID: RpcV2CborSerializesDenseSetMap
|
3238 3204 | #[::tokio::test]
|
3239 3205 | #[::tracing_test::traced_test]
|
3240 - | async fn rpc_v2_cbor_server_doesnt_de_serialize_null_structure_values_request() {
|
3206 + | async fn rpc_v2_cbor_serializes_dense_set_map_request() {
|
3241 3207 | #[allow(unused_mut)]
|
3242 3208 | let mut http_request = ::http::Request::builder()
|
3243 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3209 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
3244 3210 | .method("POST")
|
3245 3211 | .header("Accept", "application/cbor")
|
3246 3212 | .header("Content-Type", "application/cbor")
|
3247 3213 | .header("smithy-protocol", "rpc-v2-cbor")
|
3248 3214 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3249 3215 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3250 - | "v2tzdHJpbmdWYWx1Zfb/".as_bytes(),
|
3216 + | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi".as_bytes(),
|
3251 3217 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3252 3218 | )),
|
3253 3219 | ))
|
3254 3220 | .unwrap();
|
3255 3221 | #[allow(unused_mut)]
|
3256 3222 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3257 3223 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3258 3224 | let service =
|
3259 3225 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3260 - | .simple_scalar_properties(
|
3261 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3262 - | let sender = sender.clone();
|
3263 - | async move {
|
3264 - | let result = {
|
3265 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3266 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3267 - | true_boolean_value: ::std::option::Option::None,
|
3268 - | false_boolean_value: ::std::option::Option::None,
|
3269 - | byte_value: ::std::option::Option::None,
|
3270 - | double_value: ::std::option::Option::None,
|
3271 - | float_value: ::std::option::Option::None,
|
3272 - | integer_value: ::std::option::Option::None,
|
3273 - | long_value: ::std::option::Option::None,
|
3274 - | short_value: ::std::option::Option::None,
|
3275 - | string_value: ::std::option::Option::None,
|
3276 - | blob_value: ::std::option::Option::None,
|
3277 - | };
|
3278 - | ::pretty_assertions::assert_eq!(
|
3279 - | input.true_boolean_value,
|
3280 - | expected.true_boolean_value,
|
3281 - | "Unexpected value for `true_boolean_value`"
|
3282 - | );
|
3283 - | ::pretty_assertions::assert_eq!(
|
3284 - | input.false_boolean_value,
|
3285 - | expected.false_boolean_value,
|
3286 - | "Unexpected value for `false_boolean_value`"
|
3287 - | );
|
3288 - | ::pretty_assertions::assert_eq!(
|
3289 - | input.byte_value,
|
3290 - | expected.byte_value,
|
3291 - | "Unexpected value for `byte_value`"
|
3292 - | );
|
3293 - | assert!(
|
3294 - | input.double_value.float_equals(&expected.double_value),
|
3295 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3296 - | expected.double_value,
|
3297 - | input.double_value
|
3298 - | );
|
3299 - | assert!(
|
3300 - | input.float_value.float_equals(&expected.float_value),
|
3301 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3302 - | expected.float_value,
|
3303 - | input.float_value
|
3304 - | );
|
3305 - | ::pretty_assertions::assert_eq!(
|
3306 - | input.integer_value,
|
3307 - | expected.integer_value,
|
3308 - | "Unexpected value for `integer_value`"
|
3309 - | );
|
3310 - | ::pretty_assertions::assert_eq!(
|
3311 - | input.long_value,
|
3312 - | expected.long_value,
|
3313 - | "Unexpected value for `long_value`"
|
3314 - | );
|
3315 - | ::pretty_assertions::assert_eq!(
|
3316 - | input.short_value,
|
3317 - | expected.short_value,
|
3318 - | "Unexpected value for `short_value`"
|
3319 - | );
|
3320 - | ::pretty_assertions::assert_eq!(
|
3321 - | input.string_value,
|
3322 - | expected.string_value,
|
3323 - | "Unexpected value for `string_value`"
|
3324 - | );
|
3325 - | ::pretty_assertions::assert_eq!(
|
3326 - | input.blob_value,
|
3327 - | expected.blob_value,
|
3328 - | "Unexpected value for `blob_value`"
|
3329 - | );
|
3330 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3331 - | true_boolean_value: ::std::option::Option::None,
|
3332 - | false_boolean_value: ::std::option::Option::None,
|
3333 - | byte_value: ::std::option::Option::None,
|
3334 - | double_value: ::std::option::Option::None,
|
3335 - | float_value: ::std::option::Option::None,
|
3336 - | integer_value: ::std::option::Option::None,
|
3337 - | long_value: ::std::option::Option::None,
|
3338 - | short_value: ::std::option::Option::None,
|
3339 - | string_value: ::std::option::Option::None,
|
3340 - | blob_value: ::std::option::Option::None,
|
3341 - | };
|
3342 - | output
|
3226 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
3227 + | let sender = sender.clone();
|
3228 + | async move {
|
3229 + | let result = {
|
3230 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
3231 + | dense_set_map: ::std::option::Option::Some({
|
3232 + | let mut ret = ::std::collections::HashMap::new();
|
3233 + | ret.insert(
|
3234 + | "x".to_owned(),
|
3235 + | vec![].try_into().expect("this is only used in tests"),
|
3236 + | );
|
3237 + | ret.insert(
|
3238 + | "y".to_owned(),
|
3239 + | vec!["a".to_owned(), "b".to_owned()]
|
3240 + | .try_into()
|
3241 + | .expect("this is only used in tests"),
|
3242 + | );
|
3243 + | ret
|
3244 + | }),
|
3245 + | dense_struct_map: ::std::option::Option::None,
|
3246 + | dense_number_map: ::std::option::Option::None,
|
3247 + | dense_boolean_map: ::std::option::Option::None,
|
3248 + | dense_string_map: ::std::option::Option::None,
|
3343 3249 | };
|
3344 - | sender.send(()).await.expect("receiver dropped early");
|
3345 - | result
|
3346 - | }
|
3347 - | },
|
3348 - | )
|
3250 + | ::pretty_assertions::assert_eq!(input, expected);
|
3251 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3252 + | dense_struct_map: ::std::option::Option::None,
|
3253 + | dense_number_map: ::std::option::Option::None,
|
3254 + | dense_boolean_map: ::std::option::Option::None,
|
3255 + | dense_string_map: ::std::option::Option::None,
|
3256 + | dense_set_map: ::std::option::Option::None,
|
3257 + | };
|
3258 + | Ok(output)
|
3259 + | };
|
3260 + | sender.send(()).await.expect("receiver dropped early");
|
3261 + | result
|
3262 + | }
|
3263 + | })
|
3349 3264 | .build_unchecked();
|
3350 3265 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3351 3266 | .await
|
3352 3267 | .expect("unable to make an HTTP request");
|
3353 3268 | assert!(
|
3354 3269 | receiver.recv().await.is_some(),
|
3355 3270 | "we expected operation handler to be invoked but it was not entered"
|
3356 3271 | );
|
3357 3272 | }
|
3358 3273 |
|
3359 - | /// Supports handling NaN float values.
|
3360 - | /// Test ID: RpcV2CborSupportsNaNFloatInputs
|
3274 + | /// Deserializes maps
|
3275 + | /// Test ID: RpcV2CborMaps
|
3361 3276 | #[::tokio::test]
|
3362 3277 | #[::tracing_test::traced_test]
|
3363 - | async fn rpc_v2_cbor_supports_na_n_float_inputs_request() {
|
3364 - | #[allow(unused_mut)]
|
3365 - | let mut http_request = ::http::Request::builder()
|
3366 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3367 - | .method("POST")
|
3368 - | .header("Accept", "application/cbor")
|
3369 - | .header("Content-Type", "application/cbor")
|
3370 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3371 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3372 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3373 - | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/".as_bytes(),
|
3374 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3375 - | )),
|
3376 - | ))
|
3377 - | .unwrap();
|
3378 - | #[allow(unused_mut)]
|
3379 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3380 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3381 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
3382 - | config,
|
3383 - | )
|
3384 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3385 - | let sender = sender.clone();
|
3386 - | async move {
|
3387 - | let result = {
|
3388 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3389 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3390 - | double_value: ::std::option::Option::Some(
|
3391 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3392 - | "NaN",
|
3393 - | )
|
3394 - | .expect("invalid string for number"),
|
3395 - | ),
|
3396 - | float_value: ::std::option::Option::Some(
|
3397 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3398 - | "NaN",
|
3399 - | )
|
3400 - | .expect("invalid string for number"),
|
3401 - | ),
|
3402 - | true_boolean_value: ::std::option::Option::None,
|
3403 - | false_boolean_value: ::std::option::Option::None,
|
3404 - | byte_value: ::std::option::Option::None,
|
3405 - | integer_value: ::std::option::Option::None,
|
3406 - | long_value: ::std::option::Option::None,
|
3407 - | short_value: ::std::option::Option::None,
|
3408 - | string_value: ::std::option::Option::None,
|
3409 - | blob_value: ::std::option::Option::None,
|
3410 - | };
|
3411 - | ::pretty_assertions::assert_eq!(
|
3412 - | input.true_boolean_value,
|
3413 - | expected.true_boolean_value,
|
3414 - | "Unexpected value for `true_boolean_value`"
|
3415 - | );
|
3416 - | ::pretty_assertions::assert_eq!(
|
3417 - | input.false_boolean_value,
|
3418 - | expected.false_boolean_value,
|
3419 - | "Unexpected value for `false_boolean_value`"
|
3420 - | );
|
3421 - | ::pretty_assertions::assert_eq!(
|
3422 - | input.byte_value,
|
3423 - | expected.byte_value,
|
3424 - | "Unexpected value for `byte_value`"
|
3425 - | );
|
3426 - | assert!(
|
3427 - | input.double_value.float_equals(&expected.double_value),
|
3428 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3429 - | expected.double_value,
|
3430 - | input.double_value
|
3431 - | );
|
3432 - | assert!(
|
3433 - | input.float_value.float_equals(&expected.float_value),
|
3434 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3435 - | expected.float_value,
|
3436 - | input.float_value
|
3437 - | );
|
3438 - | ::pretty_assertions::assert_eq!(
|
3439 - | input.integer_value,
|
3440 - | expected.integer_value,
|
3441 - | "Unexpected value for `integer_value`"
|
3442 - | );
|
3443 - | ::pretty_assertions::assert_eq!(
|
3444 - | input.long_value,
|
3445 - | expected.long_value,
|
3446 - | "Unexpected value for `long_value`"
|
3447 - | );
|
3448 - | ::pretty_assertions::assert_eq!(
|
3449 - | input.short_value,
|
3450 - | expected.short_value,
|
3451 - | "Unexpected value for `short_value`"
|
3452 - | );
|
3453 - | ::pretty_assertions::assert_eq!(
|
3454 - | input.string_value,
|
3455 - | expected.string_value,
|
3456 - | "Unexpected value for `string_value`"
|
3457 - | );
|
3458 - | ::pretty_assertions::assert_eq!(
|
3459 - | input.blob_value,
|
3460 - | expected.blob_value,
|
3461 - | "Unexpected value for `blob_value`"
|
3462 - | );
|
3463 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3464 - | true_boolean_value: ::std::option::Option::None,
|
3465 - | false_boolean_value: ::std::option::Option::None,
|
3466 - | byte_value: ::std::option::Option::None,
|
3467 - | double_value: ::std::option::Option::None,
|
3468 - | float_value: ::std::option::Option::None,
|
3469 - | integer_value: ::std::option::Option::None,
|
3470 - | long_value: ::std::option::Option::None,
|
3471 - | short_value: ::std::option::Option::None,
|
3472 - | string_value: ::std::option::Option::None,
|
3473 - | blob_value: ::std::option::Option::None,
|
3474 - | };
|
3475 - | output
|
3476 - | };
|
3477 - | sender.send(()).await.expect("receiver dropped early");
|
3478 - | result
|
3479 - | }
|
3480 - | })
|
3481 - | .build_unchecked();
|
3482 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3483 - | .await
|
3484 - | .expect("unable to make an HTTP request");
|
3485 - | assert!(
|
3486 - | receiver.recv().await.is_some(),
|
3487 - | "we expected operation handler to be invoked but it was not entered"
|
3278 + | async fn rpc_v2_cbor_maps_response() {
|
3279 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3280 + | dense_struct_map: ::std::option::Option::Some({
|
3281 + | let mut ret = ::std::collections::HashMap::new();
|
3282 + | ret.insert(
|
3283 + | "foo".to_owned(),
|
3284 + | crate::model::GreetingStruct {
|
3285 + | hi: ::std::option::Option::Some("there".to_owned()),
|
3286 + | },
|
3287 + | );
|
3288 + | ret.insert(
|
3289 + | "baz".to_owned(),
|
3290 + | crate::model::GreetingStruct {
|
3291 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
3292 + | },
|
3293 + | );
|
3294 + | ret
|
3295 + | }),
|
3296 + | dense_number_map: ::std::option::Option::None,
|
3297 + | dense_boolean_map: ::std::option::Option::None,
|
3298 + | dense_string_map: ::std::option::Option::None,
|
3299 + | dense_set_map: ::std::option::Option::None,
|
3300 + | };
|
3301 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3302 + | let http_response = output.into_response();
|
3303 + | ::pretty_assertions::assert_eq!(
|
3304 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3305 + | http_response.status()
|
3488 3306 | );
|
3307 + | let expected_headers = [
|
3308 + | ("Content-Type", "application/cbor"),
|
3309 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3310 + | ];
|
3311 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3312 + | http_response.headers(),
|
3313 + | expected_headers,
|
3314 + | ));
|
3315 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3316 + | .await
|
3317 + | .expect("unable to extract body to bytes");
|
3318 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3319 + | &body,
|
3320 + | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==",
|
3321 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3322 + | ));
|
3489 3323 | }
|
3490 3324 |
|
3491 - | /// Supports handling Infinity float values.
|
3492 - | /// Test ID: RpcV2CborSupportsInfinityFloatInputs
|
3325 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
3326 + | /// Test ID: RpcV2CborDeserializesZeroValuesInMaps
|
3493 3327 | #[::tokio::test]
|
3494 3328 | #[::tracing_test::traced_test]
|
3495 - | async fn rpc_v2_cbor_supports_infinity_float_inputs_request() {
|
3496 - | #[allow(unused_mut)]
|
3497 - | let mut http_request = ::http::Request::builder()
|
3498 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3499 - | .method("POST")
|
3500 - | .header("Accept", "application/cbor")
|
3501 - | .header("Content-Type", "application/cbor")
|
3502 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3503 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3504 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3505 - | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/".as_bytes(),
|
3506 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3507 - | )),
|
3508 - | ))
|
3509 - | .unwrap();
|
3510 - | #[allow(unused_mut)]
|
3511 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3512 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3513 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
3514 - | config,
|
3515 - | )
|
3516 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3517 - | let sender = sender.clone();
|
3518 - | async move {
|
3519 - | let result = {
|
3520 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3521 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3522 - | double_value: ::std::option::Option::Some(
|
3523 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3524 - | "Infinity",
|
3525 - | )
|
3526 - | .expect("invalid string for number"),
|
3527 - | ),
|
3528 - | float_value: ::std::option::Option::Some(
|
3529 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3530 - | "Infinity",
|
3531 - | )
|
3532 - | .expect("invalid string for number"),
|
3533 - | ),
|
3534 - | true_boolean_value: ::std::option::Option::None,
|
3535 - | false_boolean_value: ::std::option::Option::None,
|
3536 - | byte_value: ::std::option::Option::None,
|
3537 - | integer_value: ::std::option::Option::None,
|
3538 - | long_value: ::std::option::Option::None,
|
3539 - | short_value: ::std::option::Option::None,
|
3540 - | string_value: ::std::option::Option::None,
|
3541 - | blob_value: ::std::option::Option::None,
|
3542 - | };
|
3543 - | ::pretty_assertions::assert_eq!(
|
3544 - | input.true_boolean_value,
|
3545 - | expected.true_boolean_value,
|
3546 - | "Unexpected value for `true_boolean_value`"
|
3547 - | );
|
3548 - | ::pretty_assertions::assert_eq!(
|
3549 - | input.false_boolean_value,
|
3550 - | expected.false_boolean_value,
|
3551 - | "Unexpected value for `false_boolean_value`"
|
3552 - | );
|
3553 - | ::pretty_assertions::assert_eq!(
|
3554 - | input.byte_value,
|
3555 - | expected.byte_value,
|
3556 - | "Unexpected value for `byte_value`"
|
3557 - | );
|
3558 - | assert!(
|
3559 - | input.double_value.float_equals(&expected.double_value),
|
3560 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3561 - | expected.double_value,
|
3562 - | input.double_value
|
3563 - | );
|
3564 - | assert!(
|
3565 - | input.float_value.float_equals(&expected.float_value),
|
3566 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3567 - | expected.float_value,
|
3568 - | input.float_value
|
3569 - | );
|
3570 - | ::pretty_assertions::assert_eq!(
|
3571 - | input.integer_value,
|
3572 - | expected.integer_value,
|
3573 - | "Unexpected value for `integer_value`"
|
3574 - | );
|
3575 - | ::pretty_assertions::assert_eq!(
|
3576 - | input.long_value,
|
3577 - | expected.long_value,
|
3578 - | "Unexpected value for `long_value`"
|
3579 - | );
|
3580 - | ::pretty_assertions::assert_eq!(
|
3581 - | input.short_value,
|
3582 - | expected.short_value,
|
3583 - | "Unexpected value for `short_value`"
|
3584 - | );
|
3585 - | ::pretty_assertions::assert_eq!(
|
3586 - | input.string_value,
|
3587 - | expected.string_value,
|
3588 - | "Unexpected value for `string_value`"
|
3589 - | );
|
3590 - | ::pretty_assertions::assert_eq!(
|
3591 - | input.blob_value,
|
3592 - | expected.blob_value,
|
3593 - | "Unexpected value for `blob_value`"
|
3594 - | );
|
3595 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3596 - | true_boolean_value: ::std::option::Option::None,
|
3597 - | false_boolean_value: ::std::option::Option::None,
|
3598 - | byte_value: ::std::option::Option::None,
|
3599 - | double_value: ::std::option::Option::None,
|
3600 - | float_value: ::std::option::Option::None,
|
3601 - | integer_value: ::std::option::Option::None,
|
3602 - | long_value: ::std::option::Option::None,
|
3603 - | short_value: ::std::option::Option::None,
|
3604 - | string_value: ::std::option::Option::None,
|
3605 - | blob_value: ::std::option::Option::None,
|
3606 - | };
|
3607 - | output
|
3608 - | };
|
3609 - | sender.send(()).await.expect("receiver dropped early");
|
3610 - | result
|
3611 - | }
|
3612 - | })
|
3613 - | .build_unchecked();
|
3614 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3615 - | .await
|
3616 - | .expect("unable to make an HTTP request");
|
3617 - | assert!(
|
3618 - | receiver.recv().await.is_some(),
|
3619 - | "we expected operation handler to be invoked but it was not entered"
|
3329 + | async fn rpc_v2_cbor_deserializes_zero_values_in_maps_response() {
|
3330 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3331 + | dense_number_map: ::std::option::Option::Some({
|
3332 + | let mut ret = ::std::collections::HashMap::new();
|
3333 + | ret.insert("x".to_owned(), 0);
|
3334 + | ret
|
3335 + | }),
|
3336 + | dense_boolean_map: ::std::option::Option::Some({
|
3337 + | let mut ret = ::std::collections::HashMap::new();
|
3338 + | ret.insert("x".to_owned(), false);
|
3339 + | ret
|
3340 + | }),
|
3341 + | dense_struct_map: ::std::option::Option::None,
|
3342 + | dense_string_map: ::std::option::Option::None,
|
3343 + | dense_set_map: ::std::option::Option::None,
|
3344 + | };
|
3345 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3346 + | let http_response = output.into_response();
|
3347 + | ::pretty_assertions::assert_eq!(
|
3348 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3349 + | http_response.status()
|
3620 3350 | );
|
3351 + | let expected_headers = [
|
3352 + | ("Content-Type", "application/cbor"),
|
3353 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3354 + | ];
|
3355 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3356 + | http_response.headers(),
|
3357 + | expected_headers,
|
3358 + | ));
|
3359 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3360 + | .await
|
3361 + | .expect("unable to extract body to bytes");
|
3362 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3363 + | &body,
|
3364 + | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==",
|
3365 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3366 + | ));
|
3621 3367 | }
|
3622 3368 |
|
3623 - | /// Supports handling Infinity float values.
|
3624 - | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatInputs
|
3369 + | /// A response that contains a dense map of sets
|
3370 + | /// Test ID: RpcV2CborDeserializesDenseSetMap
|
3625 3371 | #[::tokio::test]
|
3626 3372 | #[::tracing_test::traced_test]
|
3627 - | async fn rpc_v2_cbor_supports_negative_infinity_float_inputs_request() {
|
3628 - | #[allow(unused_mut)]
|
3629 - | let mut http_request = ::http::Request::builder()
|
3630 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3631 - | .method("POST")
|
3632 - | .header("Accept", "application/cbor")
|
3633 - | .header("Content-Type", "application/cbor")
|
3634 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3635 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3636 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3637 - | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/".as_bytes(),
|
3638 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3639 - | )),
|
3640 - | ))
|
3641 - | .unwrap();
|
3642 - | #[allow(unused_mut)]
|
3643 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3644 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3645 - | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
3646 - | config,
|
3647 - | )
|
3648 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3649 - | let sender = sender.clone();
|
3650 - | async move {
|
3651 - | let result = {
|
3652 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3653 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3654 - | double_value: ::std::option::Option::Some(
|
3655 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3656 - | "-Infinity",
|
3657 - | )
|
3658 - | .expect("invalid string for number"),
|
3659 - | ),
|
3660 - | float_value: ::std::option::Option::Some(
|
3661 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3662 - | "-Infinity",
|
3663 - | )
|
3664 - | .expect("invalid string for number"),
|
3665 - | ),
|
3666 - | true_boolean_value: ::std::option::Option::None,
|
3667 - | false_boolean_value: ::std::option::Option::None,
|
3668 - | byte_value: ::std::option::Option::None,
|
3669 - | integer_value: ::std::option::Option::None,
|
3670 - | long_value: ::std::option::Option::None,
|
3671 - | short_value: ::std::option::Option::None,
|
3672 - | string_value: ::std::option::Option::None,
|
3673 - | blob_value: ::std::option::Option::None,
|
3674 - | };
|
3675 - | ::pretty_assertions::assert_eq!(
|
3676 - | input.true_boolean_value,
|
3677 - | expected.true_boolean_value,
|
3678 - | "Unexpected value for `true_boolean_value`"
|
3679 - | );
|
3680 - | ::pretty_assertions::assert_eq!(
|
3681 - | input.false_boolean_value,
|
3682 - | expected.false_boolean_value,
|
3683 - | "Unexpected value for `false_boolean_value`"
|
3684 - | );
|
3685 - | ::pretty_assertions::assert_eq!(
|
3686 - | input.byte_value,
|
3687 - | expected.byte_value,
|
3688 - | "Unexpected value for `byte_value`"
|
3689 - | );
|
3690 - | assert!(
|
3691 - | input.double_value.float_equals(&expected.double_value),
|
3692 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3693 - | expected.double_value,
|
3694 - | input.double_value
|
3695 - | );
|
3696 - | assert!(
|
3697 - | input.float_value.float_equals(&expected.float_value),
|
3698 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3699 - | expected.float_value,
|
3700 - | input.float_value
|
3701 - | );
|
3702 - | ::pretty_assertions::assert_eq!(
|
3703 - | input.integer_value,
|
3704 - | expected.integer_value,
|
3705 - | "Unexpected value for `integer_value`"
|
3706 - | );
|
3707 - | ::pretty_assertions::assert_eq!(
|
3708 - | input.long_value,
|
3709 - | expected.long_value,
|
3710 - | "Unexpected value for `long_value`"
|
3711 - | );
|
3712 - | ::pretty_assertions::assert_eq!(
|
3713 - | input.short_value,
|
3714 - | expected.short_value,
|
3715 - | "Unexpected value for `short_value`"
|
3716 - | );
|
3717 - | ::pretty_assertions::assert_eq!(
|
3718 - | input.string_value,
|
3719 - | expected.string_value,
|
3720 - | "Unexpected value for `string_value`"
|
3721 - | );
|
3722 - | ::pretty_assertions::assert_eq!(
|
3723 - | input.blob_value,
|
3724 - | expected.blob_value,
|
3725 - | "Unexpected value for `blob_value`"
|
3726 - | );
|
3727 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3728 - | true_boolean_value: ::std::option::Option::None,
|
3729 - | false_boolean_value: ::std::option::Option::None,
|
3730 - | byte_value: ::std::option::Option::None,
|
3731 - | double_value: ::std::option::Option::None,
|
3732 - | float_value: ::std::option::Option::None,
|
3733 - | integer_value: ::std::option::Option::None,
|
3734 - | long_value: ::std::option::Option::None,
|
3735 - | short_value: ::std::option::Option::None,
|
3736 - | string_value: ::std::option::Option::None,
|
3737 - | blob_value: ::std::option::Option::None,
|
3738 - | };
|
3739 - | output
|
3740 - | };
|
3741 - | sender.send(()).await.expect("receiver dropped early");
|
3742 - | result
|
3743 - | }
|
3744 - | })
|
3745 - | .build_unchecked();
|
3746 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3747 - | .await
|
3748 - | .expect("unable to make an HTTP request");
|
3749 - | assert!(
|
3750 - | receiver.recv().await.is_some(),
|
3751 - | "we expected operation handler to be invoked but it was not entered"
|
3373 + | async fn rpc_v2_cbor_deserializes_dense_set_map_response() {
|
3374 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3375 + | dense_set_map: ::std::option::Option::Some({
|
3376 + | let mut ret = ::std::collections::HashMap::new();
|
3377 + | ret.insert(
|
3378 + | "x".to_owned(),
|
3379 + | vec![].try_into().expect("this is only used in tests"),
|
3380 + | );
|
3381 + | ret.insert(
|
3382 + | "y".to_owned(),
|
3383 + | vec!["a".to_owned(), "b".to_owned()]
|
3384 + | .try_into()
|
3385 + | .expect("this is only used in tests"),
|
3386 + | );
|
3387 + | ret
|
3388 + | }),
|
3389 + | dense_struct_map: ::std::option::Option::None,
|
3390 + | dense_number_map: ::std::option::Option::None,
|
3391 + | dense_boolean_map: ::std::option::Option::None,
|
3392 + | dense_string_map: ::std::option::Option::None,
|
3393 + | };
|
3394 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3395 + | let http_response = output.into_response();
|
3396 + | ::pretty_assertions::assert_eq!(
|
3397 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3398 + | http_response.status()
|
3752 3399 | );
|
3400 + | let expected_headers = [
|
3401 + | ("Content-Type", "application/cbor"),
|
3402 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3403 + | ];
|
3404 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3405 + | http_response.headers(),
|
3406 + | expected_headers,
|
3407 + | ));
|
3408 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3409 + | .await
|
3410 + | .expect("unable to extract body to bytes");
|
3411 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3412 + | &body,
|
3413 + | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi",
|
3414 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3415 + | ));
|
3753 3416 | }
|
3417 + | }
|
3754 3418 |
|
3755 - | /// The server should be capable of deserializing indefinite length text strings.
|
3756 - | /// Test ID: RpcV2CborIndefiniteLengthStringsCanBeDeserialized
|
3757 - | #[::tokio::test]
|
3758 - | #[::tracing_test::traced_test]
|
3759 - | async fn rpc_v2_cbor_indefinite_length_strings_can_be_deserialized_request() {
|
3760 - | #[allow(unused_mut)]
|
3761 - | let mut http_request = ::http::Request::builder()
|
3762 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3763 - | .method("POST")
|
3764 - | .header("Accept", "application/cbor")
|
3765 - | .header("Content-Type", "application/cbor")
|
3766 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3767 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3768 - | ::bytes::Bytes::copy_from_slice(
|
3769 - | &::aws_smithy_protocol_test::decode_body_data("oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3770 - | )
|
3771 - | )).unwrap();
|
3772 - | #[allow(unused_mut)]
|
3773 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3774 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3775 - | let service =
|
3776 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3777 - | .simple_scalar_properties(
|
3778 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3779 - | let sender = sender.clone();
|
3780 - | async move {
|
3781 - | let result = {
|
3782 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3783 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3784 - | string_value: ::std::option::Option::Some(
|
3785 - | "An example indefinite string, chunked on comma".to_owned(),
|
3786 - | ),
|
3787 - | true_boolean_value: ::std::option::Option::None,
|
3788 - | false_boolean_value: ::std::option::Option::None,
|
3789 - | byte_value: ::std::option::Option::None,
|
3790 - | double_value: ::std::option::Option::None,
|
3791 - | float_value: ::std::option::Option::None,
|
3792 - | integer_value: ::std::option::Option::None,
|
3793 - | long_value: ::std::option::Option::None,
|
3794 - | short_value: ::std::option::Option::None,
|
3795 - | blob_value: ::std::option::Option::None,
|
3796 - | };
|
3797 - | ::pretty_assertions::assert_eq!(
|
3798 - | input.true_boolean_value,
|
3799 - | expected.true_boolean_value,
|
3800 - | "Unexpected value for `true_boolean_value`"
|
3801 - | );
|
3802 - | ::pretty_assertions::assert_eq!(
|
3803 - | input.false_boolean_value,
|
3804 - | expected.false_boolean_value,
|
3805 - | "Unexpected value for `false_boolean_value`"
|
3806 - | );
|
3807 - | ::pretty_assertions::assert_eq!(
|
3808 - | input.byte_value,
|
3809 - | expected.byte_value,
|
3810 - | "Unexpected value for `byte_value`"
|
3811 - | );
|
3812 - | assert!(
|
3813 - | input.double_value.float_equals(&expected.double_value),
|
3814 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3815 - | expected.double_value,
|
3816 - | input.double_value
|
3817 - | );
|
3818 - | assert!(
|
3819 - | input.float_value.float_equals(&expected.float_value),
|
3820 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3821 - | expected.float_value,
|
3822 - | input.float_value
|
3823 - | );
|
3824 - | ::pretty_assertions::assert_eq!(
|
3825 - | input.integer_value,
|
3826 - | expected.integer_value,
|
3827 - | "Unexpected value for `integer_value`"
|
3828 - | );
|
3829 - | ::pretty_assertions::assert_eq!(
|
3830 - | input.long_value,
|
3831 - | expected.long_value,
|
3832 - | "Unexpected value for `long_value`"
|
3833 - | );
|
3834 - | ::pretty_assertions::assert_eq!(
|
3835 - | input.short_value,
|
3836 - | expected.short_value,
|
3837 - | "Unexpected value for `short_value`"
|
3838 - | );
|
3839 - | ::pretty_assertions::assert_eq!(
|
3840 - | input.string_value,
|
3841 - | expected.string_value,
|
3842 - | "Unexpected value for `string_value`"
|
3843 - | );
|
3844 - | ::pretty_assertions::assert_eq!(
|
3845 - | input.blob_value,
|
3846 - | expected.blob_value,
|
3847 - | "Unexpected value for `blob_value`"
|
3848 - | );
|
3849 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3850 - | true_boolean_value: ::std::option::Option::None,
|
3851 - | false_boolean_value: ::std::option::Option::None,
|
3852 - | byte_value: ::std::option::Option::None,
|
3853 - | double_value: ::std::option::Option::None,
|
3854 - | float_value: ::std::option::Option::None,
|
3855 - | integer_value: ::std::option::Option::None,
|
3856 - | long_value: ::std::option::Option::None,
|
3857 - | short_value: ::std::option::Option::None,
|
3858 - | string_value: ::std::option::Option::None,
|
3859 - | blob_value: ::std::option::Option::None,
|
3860 - | };
|
3861 - | output
|
3862 - | };
|
3863 - | sender.send(()).await.expect("receiver dropped early");
|
3864 - | result
|
3419 + | ::pin_project_lite::pin_project! {
|
3420 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3421 + | /// [`RpcV2CborSparseMapsInput`](crate::input::RpcV2CborSparseMapsInput) using modelled bindings.
|
3422 + | pub struct RpcV2CborSparseMapsInputFuture {
|
3423 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborSparseMapsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
3424 + | }
|
3425 + | }
|
3426 + |
|
3427 + | impl std::future::Future for RpcV2CborSparseMapsInputFuture {
|
3428 + | type Output = Result<
|
3429 + | crate::input::RpcV2CborSparseMapsInput,
|
3430 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
3431 + | >;
|
3432 + |
|
3433 + | fn poll(
|
3434 + | self: std::pin::Pin<&mut Self>,
|
3435 + | cx: &mut std::task::Context<'_>,
|
3436 + | ) -> std::task::Poll<Self::Output> {
|
3437 + | let this = self.project();
|
3438 + | this.inner.as_mut().poll(cx)
|
3439 + | }
|
3440 + | }
|
3441 + |
|
3442 + | impl<B>
|
3443 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
3444 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3445 + | B,
|
3446 + | > for crate::input::RpcV2CborSparseMapsInput
|
3447 + | where
|
3448 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
3449 + | B: 'static,
|
3450 + |
|
3451 + | B::Data: Send,
|
3452 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
3453 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
3454 + | {
|
3455 + | type Rejection =
|
3456 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
3457 + | type Future = RpcV2CborSparseMapsInputFuture;
|
3458 + |
|
3459 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3460 + | let fut = async move {
|
3461 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
3462 + | request.headers(),
|
3463 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
3464 + | ) {
|
3465 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
3466 + | }
|
3467 + | crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::de_rpc_v2_cbor_sparse_maps_http_request(request)
|
3468 + | .await
|
3469 + | };
|
3470 + | use ::futures_util::future::TryFutureExt;
|
3471 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
3472 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3473 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
3474 + | });
|
3475 + | RpcV2CborSparseMapsInputFuture {
|
3476 + | inner: Box::pin(fut),
|
3477 + | }
|
3478 + | }
|
3479 + | }
|
3480 + | impl
|
3481 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3482 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3483 + | > for crate::output::RpcV2CborSparseMapsOutput
|
3484 + | {
|
3485 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3486 + | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_response(self) {
|
3487 + | Ok(response) => response,
|
3488 + | Err(e) => {
|
3489 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3490 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3865 3491 | }
|
3866 - | },
|
3867 - | )
|
3868 - | .build_unchecked();
|
3869 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3870 - | .await
|
3871 - | .expect("unable to make an HTTP request");
|
3872 - | assert!(
|
3873 - | receiver.recv().await.is_some(),
|
3874 - | "we expected operation handler to be invoked but it was not entered"
|
3875 - | );
|
3492 + | }
|
3493 + | }
|
3494 + | }
|
3495 + | impl
|
3496 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
3497 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3498 + | > for crate::error::RpcV2CborSparseMapsError
|
3499 + | {
|
3500 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
3501 + | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_error(&self) {
|
3502 + | Ok(mut response) => {
|
3503 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
3504 + | response
|
3505 + | },
|
3506 + | Err(e) => {
|
3507 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3508 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3509 + | }
|
3510 + | }
|
3876 3511 | }
|
3512 + | }
|
3877 3513 |
|
3878 - | /// The server should be capable of deserializing indefinite length byte strings.
|
3879 - | /// Test ID: RpcV2CborIndefiniteLengthByteStringsCanBeDeserialized
|
3880 - | #[::tokio::test]
|
3881 - | #[::tracing_test::traced_test]
|
3882 - | async fn rpc_v2_cbor_indefinite_length_byte_strings_can_be_deserialized_request() {
|
3883 - | #[allow(unused_mut)]
|
3884 - | let mut http_request = ::http::Request::builder()
|
3885 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3886 - | .method("POST")
|
3887 - | .header("Accept", "application/cbor")
|
3888 - | .header("Content-Type", "application/cbor")
|
3889 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3890 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3891 - | ::bytes::Bytes::copy_from_slice(
|
3892 - | &::aws_smithy_protocol_test::decode_body_data("oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3893 - | )
|
3894 - | )).unwrap();
|
3895 - | #[allow(unused_mut)]
|
3896 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3897 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3898 - | let service =
|
3899 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3900 - | .simple_scalar_properties(
|
3901 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3902 - | let sender = sender.clone();
|
3903 - | async move {
|
3904 - | let result = {
|
3905 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3906 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3907 - | blob_value: ::std::option::Option::Some(
|
3908 - | ::aws_smithy_types::Blob::new(
|
3909 - | "An example indefinite-byte string, chunked on comma",
|
3910 - | ),
|
3911 - | ),
|
3912 - | true_boolean_value: ::std::option::Option::None,
|
3913 - | false_boolean_value: ::std::option::Option::None,
|
3914 - | byte_value: ::std::option::Option::None,
|
3915 - | double_value: ::std::option::Option::None,
|
3916 - | float_value: ::std::option::Option::None,
|
3917 - | integer_value: ::std::option::Option::None,
|
3918 - | long_value: ::std::option::Option::None,
|
3919 - | short_value: ::std::option::Option::None,
|
3920 - | string_value: ::std::option::Option::None,
|
3921 - | };
|
3922 - | ::pretty_assertions::assert_eq!(
|
3923 - | input.true_boolean_value,
|
3924 - | expected.true_boolean_value,
|
3925 - | "Unexpected value for `true_boolean_value`"
|
3926 - | );
|
3927 - | ::pretty_assertions::assert_eq!(
|
3928 - | input.false_boolean_value,
|
3929 - | expected.false_boolean_value,
|
3930 - | "Unexpected value for `false_boolean_value`"
|
3931 - | );
|
3932 - | ::pretty_assertions::assert_eq!(
|
3933 - | input.byte_value,
|
3934 - | expected.byte_value,
|
3935 - | "Unexpected value for `byte_value`"
|
3936 - | );
|
3937 - | assert!(
|
3938 - | input.double_value.float_equals(&expected.double_value),
|
3939 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3940 - | expected.double_value,
|
3941 - | input.double_value
|
3942 - | );
|
3943 - | assert!(
|
3944 - | input.float_value.float_equals(&expected.float_value),
|
3945 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3946 - | expected.float_value,
|
3947 - | input.float_value
|
3948 - | );
|
3949 - | ::pretty_assertions::assert_eq!(
|
3950 - | input.integer_value,
|
3951 - | expected.integer_value,
|
3952 - | "Unexpected value for `integer_value`"
|
3953 - | );
|
3954 - | ::pretty_assertions::assert_eq!(
|
3955 - | input.long_value,
|
3956 - | expected.long_value,
|
3957 - | "Unexpected value for `long_value`"
|
3958 - | );
|
3959 - | ::pretty_assertions::assert_eq!(
|
3960 - | input.short_value,
|
3961 - | expected.short_value,
|
3962 - | "Unexpected value for `short_value`"
|
3963 - | );
|
3964 - | ::pretty_assertions::assert_eq!(
|
3965 - | input.string_value,
|
3966 - | expected.string_value,
|
3967 - | "Unexpected value for `string_value`"
|
3968 - | );
|
3969 - | ::pretty_assertions::assert_eq!(
|
3970 - | input.blob_value,
|
3971 - | expected.blob_value,
|
3972 - | "Unexpected value for `blob_value`"
|
3973 - | );
|
3974 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3975 - | true_boolean_value: ::std::option::Option::None,
|
3976 - | false_boolean_value: ::std::option::Option::None,
|
3977 - | byte_value: ::std::option::Option::None,
|
3978 - | double_value: ::std::option::Option::None,
|
3979 - | float_value: ::std::option::Option::None,
|
3980 - | integer_value: ::std::option::Option::None,
|
3981 - | long_value: ::std::option::Option::None,
|
3982 - | short_value: ::std::option::Option::None,
|
3983 - | string_value: ::std::option::Option::None,
|
3984 - | blob_value: ::std::option::Option::None,
|
3985 - | };
|
3986 - | output
|
3514 + | #[allow(unreachable_code, unused_variables)]
|
3515 + | #[cfg(test)]
|
3516 + | mod rpc_v2_cbor_sparse_maps_test {
|
3517 + |
|
3518 + | /// Serializes sparse maps
|
3519 + | /// Test ID: RpcV2CborSparseMaps
|
3520 + | #[::tokio::test]
|
3521 + | #[::tracing_test::traced_test]
|
3522 + | async fn rpc_v2_cbor_sparse_maps_request() {
|
3523 + | #[allow(unused_mut)]
|
3524 + | let mut http_request = ::http::Request::builder()
|
3525 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3526 + | .method("POST")
|
3527 + | .header("Accept", "application/cbor")
|
3528 + | .header("Content-Type", "application/cbor")
|
3529 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3530 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3531 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3532 + | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////".as_bytes(),
|
3533 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3534 + | )),
|
3535 + | ))
|
3536 + | .unwrap();
|
3537 + | #[allow(unused_mut)]
|
3538 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3539 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3540 + | let service =
|
3541 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3542 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3543 + | let sender = sender.clone();
|
3544 + | async move {
|
3545 + | let result = {
|
3546 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3547 + | sparse_struct_map: ::std::option::Option::Some({
|
3548 + | let mut ret = ::std::collections::HashMap::new();
|
3549 + | ret.insert(
|
3550 + | "foo".to_owned(),
|
3551 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
3552 + | hi: ::std::option::Option::Some("there".to_owned()),
|
3553 + | }),
|
3554 + | );
|
3555 + | ret.insert(
|
3556 + | "baz".to_owned(),
|
3557 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
3558 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
3559 + | }),
|
3560 + | );
|
3561 + | ret
|
3562 + | }),
|
3563 + | sparse_number_map: ::std::option::Option::None,
|
3564 + | sparse_boolean_map: ::std::option::Option::None,
|
3565 + | sparse_string_map: ::std::option::Option::None,
|
3566 + | sparse_set_map: ::std::option::Option::None,
|
3987 3567 | };
|
3988 - | sender.send(()).await.expect("receiver dropped early");
|
3989 - | result
|
3990 - | }
|
3991 - | },
|
3992 - | )
|
3568 + | ::pretty_assertions::assert_eq!(input, expected);
|
3569 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3570 + | sparse_struct_map: ::std::option::Option::None,
|
3571 + | sparse_number_map: ::std::option::Option::None,
|
3572 + | sparse_boolean_map: ::std::option::Option::None,
|
3573 + | sparse_string_map: ::std::option::Option::None,
|
3574 + | sparse_set_map: ::std::option::Option::None,
|
3575 + | };
|
3576 + | Ok(output)
|
3577 + | };
|
3578 + | sender.send(()).await.expect("receiver dropped early");
|
3579 + | result
|
3580 + | }
|
3581 + | })
|
3993 3582 | .build_unchecked();
|
3994 3583 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3995 3584 | .await
|
3996 3585 | .expect("unable to make an HTTP request");
|
3997 3586 | assert!(
|
3998 3587 | receiver.recv().await.is_some(),
|
3999 3588 | "we expected operation handler to be invoked but it was not entered"
|
4000 3589 | );
|
4001 3590 | }
|
4002 3591 |
|
4003 - | /// Supports upcasting from a smaller byte representation of the same data type.
|
4004 - | /// Test ID: RpcV2CborSupportsUpcastingData
|
3592 + | /// Serializes null map values in sparse maps
|
3593 + | /// Test ID: RpcV2CborSerializesNullMapValues
|
4005 3594 | #[::tokio::test]
|
4006 3595 | #[::tracing_test::traced_test]
|
4007 - | async fn rpc_v2_cbor_supports_upcasting_data_request() {
|
3596 + | async fn rpc_v2_cbor_serializes_null_map_values_request() {
|
4008 3597 | #[allow(unused_mut)]
|
4009 3598 | let mut http_request = ::http::Request::builder()
|
4010 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3599 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
4011 3600 | .method("POST")
|
4012 3601 | .header("Accept", "application/cbor")
|
4013 3602 | .header("Content-Type", "application/cbor")
|
4014 3603 | .header("smithy-protocol", "rpc-v2-cbor")
|
4015 3604 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4016 3605 | ::bytes::Bytes::copy_from_slice(
|
4017 - | &::aws_smithy_protocol_test::decode_body_data("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3606 + | &::aws_smithy_protocol_test::decode_body_data("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4018 3607 | )
|
4019 3608 | )).unwrap();
|
4020 3609 | #[allow(unused_mut)]
|
4021 3610 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4022 3611 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4023 3612 | let service =
|
4024 3613 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4025 - | .simple_scalar_properties(
|
4026 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
4027 - | let sender = sender.clone();
|
4028 - | async move {
|
4029 - | let result = {
|
4030 - | use ::aws_smithy_protocol_test::FloatEquals;
|
4031 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
4032 - | double_value: ::std::option::Option::Some(1.5_f64),
|
4033 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4034 - | integer_value: ::std::option::Option::Some(56),
|
4035 - | long_value: ::std::option::Option::Some(256),
|
4036 - | short_value: ::std::option::Option::Some(10),
|
4037 - | true_boolean_value: ::std::option::Option::None,
|
4038 - | false_boolean_value: ::std::option::Option::None,
|
4039 - | byte_value: ::std::option::Option::None,
|
4040 - | string_value: ::std::option::Option::None,
|
4041 - | blob_value: ::std::option::Option::None,
|
4042 - | };
|
4043 - | ::pretty_assertions::assert_eq!(
|
4044 - | input.true_boolean_value,
|
4045 - | expected.true_boolean_value,
|
4046 - | "Unexpected value for `true_boolean_value`"
|
4047 - | );
|
4048 - | ::pretty_assertions::assert_eq!(
|
4049 - | input.false_boolean_value,
|
4050 - | expected.false_boolean_value,
|
4051 - | "Unexpected value for `false_boolean_value`"
|
4052 - | );
|
4053 - | ::pretty_assertions::assert_eq!(
|
4054 - | input.byte_value,
|
4055 - | expected.byte_value,
|
4056 - | "Unexpected value for `byte_value`"
|
4057 - | );
|
4058 - | assert!(
|
4059 - | input.double_value.float_equals(&expected.double_value),
|
4060 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4061 - | expected.double_value,
|
4062 - | input.double_value
|
4063 - | );
|
4064 - | assert!(
|
4065 - | input.float_value.float_equals(&expected.float_value),
|
4066 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4067 - | expected.float_value,
|
4068 - | input.float_value
|
4069 - | );
|
4070 - | ::pretty_assertions::assert_eq!(
|
4071 - | input.integer_value,
|
4072 - | expected.integer_value,
|
4073 - | "Unexpected value for `integer_value`"
|
4074 - | );
|
4075 - | ::pretty_assertions::assert_eq!(
|
4076 - | input.long_value,
|
4077 - | expected.long_value,
|
4078 - | "Unexpected value for `long_value`"
|
4079 - | );
|
4080 - | ::pretty_assertions::assert_eq!(
|
4081 - | input.short_value,
|
4082 - | expected.short_value,
|
4083 - | "Unexpected value for `short_value`"
|
4084 - | );
|
4085 - | ::pretty_assertions::assert_eq!(
|
4086 - | input.string_value,
|
4087 - | expected.string_value,
|
4088 - | "Unexpected value for `string_value`"
|
4089 - | );
|
4090 - | ::pretty_assertions::assert_eq!(
|
4091 - | input.blob_value,
|
4092 - | expected.blob_value,
|
4093 - | "Unexpected value for `blob_value`"
|
4094 - | );
|
4095 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4096 - | true_boolean_value: ::std::option::Option::None,
|
4097 - | false_boolean_value: ::std::option::Option::None,
|
4098 - | byte_value: ::std::option::Option::None,
|
4099 - | double_value: ::std::option::Option::None,
|
4100 - | float_value: ::std::option::Option::None,
|
4101 - | integer_value: ::std::option::Option::None,
|
4102 - | long_value: ::std::option::Option::None,
|
4103 - | short_value: ::std::option::Option::None,
|
4104 - | string_value: ::std::option::Option::None,
|
4105 - | blob_value: ::std::option::Option::None,
|
4106 - | };
|
4107 - | output
|
3614 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3615 + | let sender = sender.clone();
|
3616 + | async move {
|
3617 + | let result = {
|
3618 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3619 + | sparse_boolean_map: ::std::option::Option::Some({
|
3620 + | let mut ret = ::std::collections::HashMap::new();
|
3621 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3622 + | ret
|
3623 + | }),
|
3624 + | sparse_number_map: ::std::option::Option::Some({
|
3625 + | let mut ret = ::std::collections::HashMap::new();
|
3626 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3627 + | ret
|
3628 + | }),
|
3629 + | sparse_string_map: ::std::option::Option::Some({
|
3630 + | let mut ret = ::std::collections::HashMap::new();
|
3631 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3632 + | ret
|
3633 + | }),
|
3634 + | sparse_struct_map: ::std::option::Option::Some({
|
3635 + | let mut ret = ::std::collections::HashMap::new();
|
3636 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3637 + | ret
|
3638 + | }),
|
3639 + | sparse_set_map: ::std::option::Option::None,
|
3640 + | };
|
3641 + | ::pretty_assertions::assert_eq!(input, expected);
|
3642 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3643 + | sparse_struct_map: ::std::option::Option::None,
|
3644 + | sparse_number_map: ::std::option::Option::None,
|
3645 + | sparse_boolean_map: ::std::option::Option::None,
|
3646 + | sparse_string_map: ::std::option::Option::None,
|
3647 + | sparse_set_map: ::std::option::Option::None,
|
3648 + | };
|
3649 + | Ok(output)
|
3650 + | };
|
3651 + | sender.send(()).await.expect("receiver dropped early");
|
3652 + | result
|
3653 + | }
|
3654 + | })
|
3655 + | .build_unchecked();
|
3656 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3657 + | .await
|
3658 + | .expect("unable to make an HTTP request");
|
3659 + | assert!(
|
3660 + | receiver.recv().await.is_some(),
|
3661 + | "we expected operation handler to be invoked but it was not entered"
|
3662 + | );
|
3663 + | }
|
3664 + |
|
3665 + | /// A request that contains a sparse map of sets
|
3666 + | /// Test ID: RpcV2CborSerializesSparseSetMap
|
3667 + | #[::tokio::test]
|
3668 + | #[::tracing_test::traced_test]
|
3669 + | async fn rpc_v2_cbor_serializes_sparse_set_map_request() {
|
3670 + | #[allow(unused_mut)]
|
3671 + | let mut http_request = ::http::Request::builder()
|
3672 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3673 + | .method("POST")
|
3674 + | .header("Accept", "application/cbor")
|
3675 + | .header("Content-Type", "application/cbor")
|
3676 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3677 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3678 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3679 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=".as_bytes(),
|
3680 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3681 + | )),
|
3682 + | ))
|
3683 + | .unwrap();
|
3684 + | #[allow(unused_mut)]
|
3685 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3686 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3687 + | let service =
|
3688 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3689 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3690 + | let sender = sender.clone();
|
3691 + | async move {
|
3692 + | let result = {
|
3693 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3694 + | sparse_set_map: ::std::option::Option::Some({
|
3695 + | let mut ret = ::std::collections::HashMap::new();
|
3696 + | ret.insert(
|
3697 + | "x".to_owned(),
|
3698 + | ::std::option::Option::Some(
|
3699 + | vec![].try_into().expect("this is only used in tests"),
|
3700 + | ),
|
3701 + | );
|
3702 + | ret.insert(
|
3703 + | "y".to_owned(),
|
3704 + | ::std::option::Option::Some(
|
3705 + | vec!["a".to_owned(), "b".to_owned()]
|
3706 + | .try_into()
|
3707 + | .expect("this is only used in tests"),
|
3708 + | ),
|
3709 + | );
|
3710 + | ret
|
3711 + | }),
|
3712 + | sparse_struct_map: ::std::option::Option::None,
|
3713 + | sparse_number_map: ::std::option::Option::None,
|
3714 + | sparse_boolean_map: ::std::option::Option::None,
|
3715 + | sparse_string_map: ::std::option::Option::None,
|
4108 3716 | };
|
4109 - | sender.send(()).await.expect("receiver dropped early");
|
4110 - | result
|
4111 - | }
|
4112 - | },
|
4113 - | )
|
3717 + | ::pretty_assertions::assert_eq!(input, expected);
|
3718 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3719 + | sparse_struct_map: ::std::option::Option::None,
|
3720 + | sparse_number_map: ::std::option::Option::None,
|
3721 + | sparse_boolean_map: ::std::option::Option::None,
|
3722 + | sparse_string_map: ::std::option::Option::None,
|
3723 + | sparse_set_map: ::std::option::Option::None,
|
3724 + | };
|
3725 + | Ok(output)
|
3726 + | };
|
3727 + | sender.send(()).await.expect("receiver dropped early");
|
3728 + | result
|
3729 + | }
|
3730 + | })
|
4114 3731 | .build_unchecked();
|
4115 3732 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4116 3733 | .await
|
4117 3734 | .expect("unable to make an HTTP request");
|
4118 3735 | assert!(
|
4119 3736 | receiver.recv().await.is_some(),
|
4120 3737 | "we expected operation handler to be invoked but it was not entered"
|
4121 3738 | );
|
4122 3739 | }
|
4123 3740 |
|
4124 - | /// The server should skip over additional fields that are not part of the structure. This allows a
|
4125 - | /// client generated against a newer Smithy model to be able to communicate with a server that is
|
4126 - | /// generated against an older Smithy model.
|
4127 - | /// Test ID: RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByServers
|
3741 + | /// A request that contains a sparse map of sets.
|
3742 + | /// Test ID: RpcV2CborSerializesSparseSetMapAndRetainsNull
|
4128 3743 | #[::tokio::test]
|
4129 3744 | #[::tracing_test::traced_test]
|
4130 - | async fn rpc_v2_cbor_extra_fields_in_the_body_should_be_skipped_by_servers_request() {
|
3745 + | async fn rpc_v2_cbor_serializes_sparse_set_map_and_retains_null_request() {
|
4131 3746 | #[allow(unused_mut)]
|
4132 - | let mut http_request = ::http::Request::builder()
|
4133 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4134 - | .method("POST")
|
4135 - | .header("Accept", "application/cbor")
|
4136 - | .header("Content-Type", "application/cbor")
|
4137 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4138 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4139 - | ::bytes::Bytes::copy_from_slice(
|
4140 - | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABrZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4141 - | )
|
4142 - | )).unwrap();
|
3747 + | let mut http_request = ::http::Request::builder()
|
3748 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3749 + | .method("POST")
|
3750 + | .header("Accept", "application/cbor")
|
3751 + | .header("Content-Type", "application/cbor")
|
3752 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3753 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3754 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3755 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=".as_bytes(),
|
3756 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3757 + | )),
|
3758 + | ))
|
3759 + | .unwrap();
|
4143 3760 | #[allow(unused_mut)]
|
4144 3761 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4145 3762 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4146 3763 | let service =
|
4147 3764 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4148 - | .simple_scalar_properties(
|
4149 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
4150 - | let sender = sender.clone();
|
4151 - | async move {
|
4152 - | let result = {
|
4153 - | use ::aws_smithy_protocol_test::FloatEquals;
|
4154 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
4155 - | byte_value: ::std::option::Option::Some(5),
|
4156 - | double_value: ::std::option::Option::Some(1.889_f64),
|
4157 - | false_boolean_value: ::std::option::Option::Some(false),
|
4158 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4159 - | integer_value: ::std::option::Option::Some(256),
|
4160 - | long_value: ::std::option::Option::Some(9873),
|
4161 - | short_value: ::std::option::Option::Some(9898),
|
4162 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4163 - | true_boolean_value: ::std::option::Option::Some(true),
|
4164 - | blob_value: ::std::option::Option::Some(
|
4165 - | ::aws_smithy_types::Blob::new("foo"),
|
4166 - | ),
|
4167 - | };
|
4168 - | ::pretty_assertions::assert_eq!(
|
4169 - | input.true_boolean_value,
|
4170 - | expected.true_boolean_value,
|
4171 - | "Unexpected value for `true_boolean_value`"
|
4172 - | );
|
4173 - | ::pretty_assertions::assert_eq!(
|
4174 - | input.false_boolean_value,
|
4175 - | expected.false_boolean_value,
|
4176 - | "Unexpected value for `false_boolean_value`"
|
4177 - | );
|
4178 - | ::pretty_assertions::assert_eq!(
|
4179 - | input.byte_value,
|
4180 - | expected.byte_value,
|
4181 - | "Unexpected value for `byte_value`"
|
4182 - | );
|
4183 - | assert!(
|
4184 - | input.double_value.float_equals(&expected.double_value),
|
4185 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4186 - | expected.double_value,
|
4187 - | input.double_value
|
4188 - | );
|
4189 - | assert!(
|
4190 - | input.float_value.float_equals(&expected.float_value),
|
4191 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4192 - | expected.float_value,
|
4193 - | input.float_value
|
4194 - | );
|
4195 - | ::pretty_assertions::assert_eq!(
|
4196 - | input.integer_value,
|
4197 - | expected.integer_value,
|
4198 - | "Unexpected value for `integer_value`"
|
4199 - | );
|
4200 - | ::pretty_assertions::assert_eq!(
|
4201 - | input.long_value,
|
4202 - | expected.long_value,
|
4203 - | "Unexpected value for `long_value`"
|
4204 - | );
|
4205 - | ::pretty_assertions::assert_eq!(
|
4206 - | input.short_value,
|
4207 - | expected.short_value,
|
4208 - | "Unexpected value for `short_value`"
|
4209 - | );
|
4210 - | ::pretty_assertions::assert_eq!(
|
4211 - | input.string_value,
|
4212 - | expected.string_value,
|
4213 - | "Unexpected value for `string_value`"
|
4214 - | );
|
4215 - | ::pretty_assertions::assert_eq!(
|
4216 - | input.blob_value,
|
4217 - | expected.blob_value,
|
4218 - | "Unexpected value for `blob_value`"
|
4219 - | );
|
4220 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4221 - | true_boolean_value: ::std::option::Option::None,
|
4222 - | false_boolean_value: ::std::option::Option::None,
|
4223 - | byte_value: ::std::option::Option::None,
|
4224 - | double_value: ::std::option::Option::None,
|
4225 - | float_value: ::std::option::Option::None,
|
4226 - | integer_value: ::std::option::Option::None,
|
4227 - | long_value: ::std::option::Option::None,
|
4228 - | short_value: ::std::option::Option::None,
|
4229 - | string_value: ::std::option::Option::None,
|
4230 - | blob_value: ::std::option::Option::None,
|
4231 - | };
|
4232 - | output
|
3765 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3766 + | let sender = sender.clone();
|
3767 + | async move {
|
3768 + | let result = {
|
3769 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3770 + | sparse_set_map: ::std::option::Option::Some({
|
3771 + | let mut ret = ::std::collections::HashMap::new();
|
3772 + | ret.insert(
|
3773 + | "x".to_owned(),
|
3774 + | ::std::option::Option::Some(
|
3775 + | vec![].try_into().expect("this is only used in tests"),
|
3776 + | ),
|
3777 + | );
|
3778 + | ret.insert(
|
3779 + | "y".to_owned(),
|
3780 + | ::std::option::Option::Some(
|
3781 + | vec!["a".to_owned(), "b".to_owned()]
|
3782 + | .try_into()
|
3783 + | .expect("this is only used in tests"),
|
3784 + | ),
|
3785 + | );
|
3786 + | ret.insert("z".to_owned(), ::std::option::Option::None);
|
3787 + | ret
|
3788 + | }),
|
3789 + | sparse_struct_map: ::std::option::Option::None,
|
3790 + | sparse_number_map: ::std::option::Option::None,
|
3791 + | sparse_boolean_map: ::std::option::Option::None,
|
3792 + | sparse_string_map: ::std::option::Option::None,
|
4233 3793 | };
|
4234 - | sender.send(()).await.expect("receiver dropped early");
|
4235 - | result
|
4236 - | }
|
4237 - | },
|
4238 - | )
|
3794 + | ::pretty_assertions::assert_eq!(input, expected);
|
3795 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3796 + | sparse_struct_map: ::std::option::Option::None,
|
3797 + | sparse_number_map: ::std::option::Option::None,
|
3798 + | sparse_boolean_map: ::std::option::Option::None,
|
3799 + | sparse_string_map: ::std::option::Option::None,
|
3800 + | sparse_set_map: ::std::option::Option::None,
|
3801 + | };
|
3802 + | Ok(output)
|
3803 + | };
|
3804 + | sender.send(()).await.expect("receiver dropped early");
|
3805 + | result
|
3806 + | }
|
3807 + | })
|
3808 + | .build_unchecked();
|
3809 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3810 + | .await
|
3811 + | .expect("unable to make an HTTP request");
|
3812 + | assert!(
|
3813 + | receiver.recv().await.is_some(),
|
3814 + | "we expected operation handler to be invoked but it was not entered"
|
3815 + | );
|
3816 + | }
|
3817 + |
|
3818 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
3819 + | /// Test ID: RpcV2CborSerializesZeroValuesInSparseMaps
|
3820 + | #[::tokio::test]
|
3821 + | #[::tracing_test::traced_test]
|
3822 + | async fn rpc_v2_cbor_serializes_zero_values_in_sparse_maps_request() {
|
3823 + | #[allow(unused_mut)]
|
3824 + | let mut http_request = ::http::Request::builder()
|
3825 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3826 + | .method("POST")
|
3827 + | .header("Accept", "application/cbor")
|
3828 + | .header("Content-Type", "application/cbor")
|
3829 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3830 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3831 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3832 + | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//".as_bytes(),
|
3833 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3834 + | )),
|
3835 + | ))
|
3836 + | .unwrap();
|
3837 + | #[allow(unused_mut)]
|
3838 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3839 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3840 + | let service =
|
3841 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3842 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3843 + | let sender = sender.clone();
|
3844 + | async move {
|
3845 + | let result = {
|
3846 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3847 + | sparse_number_map: ::std::option::Option::Some({
|
3848 + | let mut ret = ::std::collections::HashMap::new();
|
3849 + | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
3850 + | ret
|
3851 + | }),
|
3852 + | sparse_boolean_map: ::std::option::Option::Some({
|
3853 + | let mut ret = ::std::collections::HashMap::new();
|
3854 + | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
3855 + | ret
|
3856 + | }),
|
3857 + | sparse_struct_map: ::std::option::Option::None,
|
3858 + | sparse_string_map: ::std::option::Option::None,
|
3859 + | sparse_set_map: ::std::option::Option::None,
|
3860 + | };
|
3861 + | ::pretty_assertions::assert_eq!(input, expected);
|
3862 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3863 + | sparse_struct_map: ::std::option::Option::None,
|
3864 + | sparse_number_map: ::std::option::Option::None,
|
3865 + | sparse_boolean_map: ::std::option::Option::None,
|
3866 + | sparse_string_map: ::std::option::Option::None,
|
3867 + | sparse_set_map: ::std::option::Option::None,
|
3868 + | };
|
3869 + | Ok(output)
|
3870 + | };
|
3871 + | sender.send(()).await.expect("receiver dropped early");
|
3872 + | result
|
3873 + | }
|
3874 + | })
|
4239 3875 | .build_unchecked();
|
4240 3876 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4241 3877 | .await
|
4242 3878 | .expect("unable to make an HTTP request");
|
4243 3879 | assert!(
|
4244 3880 | receiver.recv().await.is_some(),
|
4245 3881 | "we expected operation handler to be invoked but it was not entered"
|
4246 3882 | );
|
4247 3883 | }
|
4248 3884 |
|
4249 - | /// Servers should tolerate requests without an Accept header set.
|
4250 - | /// Test ID: RpcV2CborServersShouldHandleNoAcceptHeader
|
3885 + | /// Deserializes sparse maps
|
3886 + | /// Test ID: RpcV2CborSparseJsonMaps
|
3887 + | #[::tokio::test]
|
3888 + | #[::tracing_test::traced_test]
|
3889 + | async fn rpc_v2_cbor_sparse_json_maps_response() {
|
3890 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3891 + | sparse_struct_map: ::std::option::Option::Some({
|
3892 + | let mut ret = ::std::collections::HashMap::new();
|
3893 + | ret.insert(
|
3894 + | "foo".to_owned(),
|
3895 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
3896 + | hi: ::std::option::Option::Some("there".to_owned()),
|
3897 + | }),
|
3898 + | );
|
3899 + | ret.insert(
|
3900 + | "baz".to_owned(),
|
3901 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
3902 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
3903 + | }),
|
3904 + | );
|
3905 + | ret
|
3906 + | }),
|
3907 + | sparse_number_map: ::std::option::Option::None,
|
3908 + | sparse_boolean_map: ::std::option::Option::None,
|
3909 + | sparse_string_map: ::std::option::Option::None,
|
3910 + | sparse_set_map: ::std::option::Option::None,
|
3911 + | };
|
3912 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3913 + | let http_response = output.into_response();
|
3914 + | ::pretty_assertions::assert_eq!(
|
3915 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3916 + | http_response.status()
|
3917 + | );
|
3918 + | let expected_headers = [
|
3919 + | ("Content-Type", "application/cbor"),
|
3920 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3921 + | ];
|
3922 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3923 + | http_response.headers(),
|
3924 + | expected_headers,
|
3925 + | ));
|
3926 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3927 + | .await
|
3928 + | .expect("unable to extract body to bytes");
|
3929 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3930 + | &body,
|
3931 + | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////",
|
3932 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3933 + | ));
|
3934 + | }
|
3935 + |
|
3936 + | /// Deserializes null map values
|
3937 + | /// Test ID: RpcV2CborDeserializesNullMapValues
|
3938 + | #[::tokio::test]
|
3939 + | #[::tracing_test::traced_test]
|
3940 + | async fn rpc_v2_cbor_deserializes_null_map_values_response() {
|
3941 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3942 + | sparse_boolean_map: ::std::option::Option::Some({
|
3943 + | let mut ret = ::std::collections::HashMap::new();
|
3944 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3945 + | ret
|
3946 + | }),
|
3947 + | sparse_number_map: ::std::option::Option::Some({
|
3948 + | let mut ret = ::std::collections::HashMap::new();
|
3949 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3950 + | ret
|
3951 + | }),
|
3952 + | sparse_string_map: ::std::option::Option::Some({
|
3953 + | let mut ret = ::std::collections::HashMap::new();
|
3954 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3955 + | ret
|
3956 + | }),
|
3957 + | sparse_struct_map: ::std::option::Option::Some({
|
3958 + | let mut ret = ::std::collections::HashMap::new();
|
3959 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3960 + | ret
|
3961 + | }),
|
3962 + | sparse_set_map: ::std::option::Option::None,
|
3963 + | };
|
3964 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
3965 + | let http_response = output.into_response();
|
3966 + | ::pretty_assertions::assert_eq!(
|
3967 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3968 + | http_response.status()
|
3969 + | );
|
3970 + | let expected_headers = [
|
3971 + | ("Content-Type", "application/cbor"),
|
3972 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3973 + | ];
|
3974 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3975 + | http_response.headers(),
|
3976 + | expected_headers,
|
3977 + | ));
|
3978 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3979 + | .await
|
3980 + | .expect("unable to extract body to bytes");
|
3981 + | ::aws_smithy_protocol_test::assert_ok(
|
3982 + | ::aws_smithy_protocol_test::validate_body(&body, "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3983 + | );
|
3984 + | }
|
3985 + |
|
3986 + | /// A response that contains a sparse map of sets
|
3987 + | /// Test ID: RpcV2CborDeserializesSparseSetMap
|
3988 + | #[::tokio::test]
|
3989 + | #[::tracing_test::traced_test]
|
3990 + | async fn rpc_v2_cbor_deserializes_sparse_set_map_response() {
|
3991 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3992 + | sparse_set_map: ::std::option::Option::Some({
|
3993 + | let mut ret = ::std::collections::HashMap::new();
|
3994 + | ret.insert(
|
3995 + | "x".to_owned(),
|
3996 + | ::std::option::Option::Some(
|
3997 + | vec![].try_into().expect("this is only used in tests"),
|
3998 + | ),
|
3999 + | );
|
4000 + | ret.insert(
|
4001 + | "y".to_owned(),
|
4002 + | ::std::option::Option::Some(
|
4003 + | vec!["a".to_owned(), "b".to_owned()]
|
4004 + | .try_into()
|
4005 + | .expect("this is only used in tests"),
|
4006 + | ),
|
4007 + | );
|
4008 + | ret
|
4009 + | }),
|
4010 + | sparse_struct_map: ::std::option::Option::None,
|
4011 + | sparse_number_map: ::std::option::Option::None,
|
4012 + | sparse_boolean_map: ::std::option::Option::None,
|
4013 + | sparse_string_map: ::std::option::Option::None,
|
4014 + | };
|
4015 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4016 + | let http_response = output.into_response();
|
4017 + | ::pretty_assertions::assert_eq!(
|
4018 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4019 + | http_response.status()
|
4020 + | );
|
4021 + | let expected_headers = [
|
4022 + | ("Content-Type", "application/cbor"),
|
4023 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4024 + | ];
|
4025 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4026 + | http_response.headers(),
|
4027 + | expected_headers,
|
4028 + | ));
|
4029 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4030 + | .await
|
4031 + | .expect("unable to extract body to bytes");
|
4032 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4033 + | &body,
|
4034 + | "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=",
|
4035 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4036 + | ));
|
4037 + | }
|
4038 + |
|
4039 + | /// A response that contains a sparse map of sets with a null
|
4040 + | /// Test ID: RpcV2CborDeserializesSparseSetMapAndRetainsNull
|
4041 + | #[::tokio::test]
|
4042 + | #[::tracing_test::traced_test]
|
4043 + | async fn rpc_v2_cbor_deserializes_sparse_set_map_and_retains_null_response() {
|
4044 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4045 + | sparse_set_map: ::std::option::Option::Some({
|
4046 + | let mut ret = ::std::collections::HashMap::new();
|
4047 + | ret.insert(
|
4048 + | "x".to_owned(),
|
4049 + | ::std::option::Option::Some(
|
4050 + | vec![].try_into().expect("this is only used in tests"),
|
4051 + | ),
|
4052 + | );
|
4053 + | ret.insert(
|
4054 + | "y".to_owned(),
|
4055 + | ::std::option::Option::Some(
|
4056 + | vec!["a".to_owned(), "b".to_owned()]
|
4057 + | .try_into()
|
4058 + | .expect("this is only used in tests"),
|
4059 + | ),
|
4060 + | );
|
4061 + | ret.insert("z".to_owned(), ::std::option::Option::None);
|
4062 + | ret
|
4063 + | }),
|
4064 + | sparse_struct_map: ::std::option::Option::None,
|
4065 + | sparse_number_map: ::std::option::Option::None,
|
4066 + | sparse_boolean_map: ::std::option::Option::None,
|
4067 + | sparse_string_map: ::std::option::Option::None,
|
4068 + | };
|
4069 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4070 + | let http_response = output.into_response();
|
4071 + | ::pretty_assertions::assert_eq!(
|
4072 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4073 + | http_response.status()
|
4074 + | );
|
4075 + | let expected_headers = [
|
4076 + | ("Content-Type", "application/cbor"),
|
4077 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4078 + | ];
|
4079 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4080 + | http_response.headers(),
|
4081 + | expected_headers,
|
4082 + | ));
|
4083 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4084 + | .await
|
4085 + | .expect("unable to extract body to bytes");
|
4086 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4087 + | &body,
|
4088 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=",
|
4089 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4090 + | ));
|
4091 + | }
|
4092 + |
|
4093 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
4094 + | /// Test ID: RpcV2CborDeserializesZeroValuesInSparseMaps
|
4095 + | #[::tokio::test]
|
4096 + | #[::tracing_test::traced_test]
|
4097 + | async fn rpc_v2_cbor_deserializes_zero_values_in_sparse_maps_response() {
|
4098 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4099 + | sparse_number_map: ::std::option::Option::Some({
|
4100 + | let mut ret = ::std::collections::HashMap::new();
|
4101 + | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
4102 + | ret
|
4103 + | }),
|
4104 + | sparse_boolean_map: ::std::option::Option::Some({
|
4105 + | let mut ret = ::std::collections::HashMap::new();
|
4106 + | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
4107 + | ret
|
4108 + | }),
|
4109 + | sparse_struct_map: ::std::option::Option::None,
|
4110 + | sparse_string_map: ::std::option::Option::None,
|
4111 + | sparse_set_map: ::std::option::Option::None,
|
4112 + | };
|
4113 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4114 + | let http_response = output.into_response();
|
4115 + | ::pretty_assertions::assert_eq!(
|
4116 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4117 + | http_response.status()
|
4118 + | );
|
4119 + | let expected_headers = [
|
4120 + | ("Content-Type", "application/cbor"),
|
4121 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4122 + | ];
|
4123 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4124 + | http_response.headers(),
|
4125 + | expected_headers,
|
4126 + | ));
|
4127 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4128 + | .await
|
4129 + | .expect("unable to extract body to bytes");
|
4130 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4131 + | &body,
|
4132 + | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//",
|
4133 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4134 + | ));
|
4135 + | }
|
4136 + | }
|
4137 + |
|
4138 + | ::pin_project_lite::pin_project! {
|
4139 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4140 + | /// [`RecursiveShapesInput`](crate::input::RecursiveShapesInput) using modelled bindings.
|
4141 + | pub struct RecursiveShapesInputFuture {
|
4142 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveShapesInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4143 + | }
|
4144 + | }
|
4145 + |
|
4146 + | impl std::future::Future for RecursiveShapesInputFuture {
|
4147 + | type Output = Result<
|
4148 + | crate::input::RecursiveShapesInput,
|
4149 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4150 + | >;
|
4151 + |
|
4152 + | fn poll(
|
4153 + | self: std::pin::Pin<&mut Self>,
|
4154 + | cx: &mut std::task::Context<'_>,
|
4155 + | ) -> std::task::Poll<Self::Output> {
|
4156 + | let this = self.project();
|
4157 + | this.inner.as_mut().poll(cx)
|
4158 + | }
|
4159 + | }
|
4160 + |
|
4161 + | impl<B>
|
4162 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4163 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4164 + | B,
|
4165 + | > for crate::input::RecursiveShapesInput
|
4166 + | where
|
4167 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4168 + | B: 'static,
|
4169 + |
|
4170 + | B::Data: Send,
|
4171 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4172 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4173 + | {
|
4174 + | type Rejection =
|
4175 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4176 + | type Future = RecursiveShapesInputFuture;
|
4177 + |
|
4178 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4179 + | let fut = async move {
|
4180 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4181 + | request.headers(),
|
4182 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4183 + | ) {
|
4184 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4185 + | }
|
4186 + | crate::protocol_serde::shape_recursive_shapes::de_recursive_shapes_http_request(request)
|
4187 + | .await
|
4188 + | };
|
4189 + | use ::futures_util::future::TryFutureExt;
|
4190 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4191 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4192 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
4193 + | });
|
4194 + | RecursiveShapesInputFuture {
|
4195 + | inner: Box::pin(fut),
|
4196 + | }
|
4197 + | }
|
4198 + | }
|
4199 + | impl
|
4200 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4201 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4202 + | > for crate::output::RecursiveShapesOutput
|
4203 + | {
|
4204 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4205 + | match crate::protocol_serde::shape_recursive_shapes::ser_recursive_shapes_http_response(
|
4206 + | self,
|
4207 + | ) {
|
4208 + | Ok(response) => response,
|
4209 + | Err(e) => {
|
4210 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4211 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4212 + | }
|
4213 + | }
|
4214 + | }
|
4215 + | }
|
4216 + |
|
4217 + | #[allow(unreachable_code, unused_variables)]
|
4218 + | #[cfg(test)]
|
4219 + | mod recursive_shapes_test {
|
4220 + |
|
4221 + | /// Serializes recursive structures
|
4222 + | /// Test ID: RpcV2CborRecursiveShapes
|
4251 4223 | #[::tokio::test]
|
4252 4224 | #[::tracing_test::traced_test]
|
4253 - | async fn rpc_v2_cbor_servers_should_handle_no_accept_header_request() {
|
4225 + | async fn rpc_v2_cbor_recursive_shapes_request() {
|
4254 4226 | #[allow(unused_mut)]
|
4255 4227 | let mut http_request = ::http::Request::builder()
|
4256 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4228 + | .uri("/service/RpcV2Protocol/operation/RecursiveShapes")
|
4257 4229 | .method("POST")
|
4230 + | .header("Accept", "application/cbor")
|
4258 4231 | .header("Content-Type", "application/cbor")
|
4259 4232 | .header("smithy-protocol", "rpc-v2-cbor")
|
4260 4233 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4261 4234 | ::bytes::Bytes::copy_from_slice(
|
4262 - | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4235 + | &::aws_smithy_protocol_test::decode_body_data("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4263 4236 | )
|
4264 4237 | )).unwrap();
|
4265 4238 | #[allow(unused_mut)]
|
4266 4239 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4267 4240 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4268 - | let service =
|
4269 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4270 - | .simple_scalar_properties(
|
4271 - | move |input: crate::input::SimpleScalarPropertiesInput| {
|
4272 - | let sender = sender.clone();
|
4273 - | async move {
|
4274 - | let result = {
|
4275 - | use ::aws_smithy_protocol_test::FloatEquals;
|
4276 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
4277 - | byte_value: ::std::option::Option::Some(5),
|
4278 - | double_value: ::std::option::Option::Some(1.889_f64),
|
4279 - | false_boolean_value: ::std::option::Option::Some(false),
|
4280 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4281 - | integer_value: ::std::option::Option::Some(256),
|
4282 - | long_value: ::std::option::Option::Some(9873),
|
4283 - | short_value: ::std::option::Option::Some(9898),
|
4284 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4285 - | true_boolean_value: ::std::option::Option::Some(true),
|
4286 - | blob_value: ::std::option::Option::Some(
|
4287 - | ::aws_smithy_types::Blob::new("foo"),
|
4288 - | ),
|
4289 - | };
|
4290 - | ::pretty_assertions::assert_eq!(
|
4291 - | input.true_boolean_value,
|
4292 - | expected.true_boolean_value,
|
4293 - | "Unexpected value for `true_boolean_value`"
|
4294 - | );
|
4295 - | ::pretty_assertions::assert_eq!(
|
4296 - | input.false_boolean_value,
|
4297 - | expected.false_boolean_value,
|
4298 - | "Unexpected value for `false_boolean_value`"
|
4299 - | );
|
4300 - | ::pretty_assertions::assert_eq!(
|
4301 - | input.byte_value,
|
4302 - | expected.byte_value,
|
4303 - | "Unexpected value for `byte_value`"
|
4304 - | );
|
4305 - | assert!(
|
4306 - | input.double_value.float_equals(&expected.double_value),
|
4307 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4308 - | expected.double_value,
|
4309 - | input.double_value
|
4310 - | );
|
4311 - | assert!(
|
4312 - | input.float_value.float_equals(&expected.float_value),
|
4313 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4314 - | expected.float_value,
|
4315 - | input.float_value
|
4316 - | );
|
4317 - | ::pretty_assertions::assert_eq!(
|
4318 - | input.integer_value,
|
4319 - | expected.integer_value,
|
4320 - | "Unexpected value for `integer_value`"
|
4321 - | );
|
4322 - | ::pretty_assertions::assert_eq!(
|
4323 - | input.long_value,
|
4324 - | expected.long_value,
|
4325 - | "Unexpected value for `long_value`"
|
4326 - | );
|
4327 - | ::pretty_assertions::assert_eq!(
|
4328 - | input.short_value,
|
4329 - | expected.short_value,
|
4330 - | "Unexpected value for `short_value`"
|
4331 - | );
|
4332 - | ::pretty_assertions::assert_eq!(
|
4333 - | input.string_value,
|
4334 - | expected.string_value,
|
4335 - | "Unexpected value for `string_value`"
|
4336 - | );
|
4337 - | ::pretty_assertions::assert_eq!(
|
4338 - | input.blob_value,
|
4339 - | expected.blob_value,
|
4340 - | "Unexpected value for `blob_value`"
|
4341 - | );
|
4342 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4343 - | true_boolean_value: ::std::option::Option::None,
|
4344 - | false_boolean_value: ::std::option::Option::None,
|
4345 - | byte_value: ::std::option::Option::None,
|
4346 - | double_value: ::std::option::Option::None,
|
4347 - | float_value: ::std::option::Option::None,
|
4348 - | integer_value: ::std::option::Option::None,
|
4349 - | long_value: ::std::option::Option::None,
|
4350 - | short_value: ::std::option::Option::None,
|
4351 - | string_value: ::std::option::Option::None,
|
4352 - | blob_value: ::std::option::Option::None,
|
4353 - | };
|
4354 - | output
|
4355 - | };
|
4356 - | sender.send(()).await.expect("receiver dropped early");
|
4357 - | result
|
4241 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4242 + | .recursive_shapes(move |input: crate::input::RecursiveShapesInput| {
|
4243 + | let sender = sender.clone();
|
4244 + | async move {
|
4245 + | let result = { let expected =
|
4246 + | crate::input::RecursiveShapesInput {
|
4247 + | nested:
|
4248 + | ::std::option::Option::Some(
|
4249 + | crate::model::RecursiveShapesInputOutputNested1 {
|
4250 + | foo:
|
4251 + | ::std::option::Option::Some(
|
4252 + | "Foo1".to_owned()
|
4253 + | )
|
4254 + | ,
|
4255 + | nested:
|
4256 + | ::std::option::Option::Some(
|
4257 + | ::std::boxed::Box::new(
|
4258 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4259 + | bar:
|
4260 + | ::std::option::Option::Some(
|
4261 + | "Bar1".to_owned()
|
4262 + | )
|
4263 + | ,
|
4264 + | recursive_member:
|
4265 + | ::std::option::Option::Some(
|
4266 + | crate::model::RecursiveShapesInputOutputNested1 {
|
4267 + | foo:
|
4268 + | ::std::option::Option::Some(
|
4269 + | "Foo2".to_owned()
|
4270 + | )
|
4271 + | ,
|
4272 + | nested:
|
4273 + | ::std::option::Option::Some(
|
4274 + | ::std::boxed::Box::new(
|
4275 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4276 + | bar:
|
4277 + | ::std::option::Option::Some(
|
4278 + | "Bar2".to_owned()
|
4279 + | )
|
4280 + | ,
|
4281 + | recursive_member:
|
4282 + | ::std::option::Option::None
|
4283 + | ,
|
4284 + | }
|
4285 + | )
|
4286 + | )
|
4287 + | ,
|
4288 + | }
|
4289 + | )
|
4290 + | ,
|
4291 + | }
|
4292 + | )
|
4293 + | )
|
4294 + | ,
|
4358 4295 | }
|
4359 - | },
|
4360 - | )
|
4361 - | .build_unchecked();
|
4296 + | )
|
4297 + | ,
|
4298 + | }
|
4299 + | ;
|
4300 + | ::pretty_assertions::assert_eq!(input, expected);
|
4301 + | let output =
|
4302 + | crate::output::RecursiveShapesOutput {
|
4303 + | nested:
|
4304 + | ::std::option::Option::None
|
4305 + | ,
|
4306 + | }
|
4307 + | ;
|
4308 + | output };
|
4309 + | sender.send(()).await.expect("receiver dropped early");
|
4310 + | result
|
4311 + | }
|
4312 + | })
|
4313 + | .build_unchecked();
|
4362 4314 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4363 4315 | .await
|
4364 4316 | .expect("unable to make an HTTP request");
|
4365 4317 | assert!(
|
4366 4318 | receiver.recv().await.is_some(),
|
4367 4319 | "we expected operation handler to be invoked but it was not entered"
|
4368 4320 | );
|
4369 4321 | }
|
4370 4322 |
|
4371 - | /// Serializes simple scalar properties
|
4372 - | /// Test ID: RpcV2CborSimpleScalarProperties
|
4323 + | /// Serializes recursive structures
|
4324 + | /// Test ID: RpcV2CborRecursiveShapes
|
4373 4325 | #[::tokio::test]
|
4374 4326 | #[::tracing_test::traced_test]
|
4375 - | async fn rpc_v2_cbor_simple_scalar_properties_response() {
|
4376 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4377 - | true_boolean_value: ::std::option::Option::Some(true),
|
4378 - | false_boolean_value: ::std::option::Option::Some(false),
|
4379 - | byte_value: ::std::option::Option::Some(5),
|
4380 - | double_value: ::std::option::Option::Some(1.889_f64),
|
4381 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4382 - | integer_value: ::std::option::Option::Some(256),
|
4383 - | short_value: ::std::option::Option::Some(9898),
|
4384 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4385 - | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new("foo")),
|
4386 - | long_value: ::std::option::Option::None,
|
4327 + | async fn rpc_v2_cbor_recursive_shapes_response() {
|
4328 + | let output = crate::output::RecursiveShapesOutput {
|
4329 + | nested: ::std::option::Option::Some(crate::model::RecursiveShapesInputOutputNested1 {
|
4330 + | foo: ::std::option::Option::Some("Foo1".to_owned()),
|
4331 + | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
4332 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4333 + | bar: ::std::option::Option::Some("Bar1".to_owned()),
|
4334 + | recursive_member: ::std::option::Option::Some(
|
4335 + | crate::model::RecursiveShapesInputOutputNested1 {
|
4336 + | foo: ::std::option::Option::Some("Foo2".to_owned()),
|
4337 + | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
4338 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4339 + | bar: ::std::option::Option::Some("Bar2".to_owned()),
|
4340 + | recursive_member: ::std::option::Option::None,
|
4341 + | },
|
4342 + | )),
|
4343 + | },
|
4344 + | ),
|
4345 + | },
|
4346 + | )),
|
4347 + | }),
|
4387 4348 | };
|
4388 4349 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4389 4350 | let http_response = output.into_response();
|
4390 4351 | ::pretty_assertions::assert_eq!(
|
4391 4352 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4392 4353 | http_response.status()
|
4393 4354 | );
|
4394 4355 | let expected_headers = [
|
4395 4356 | ("Content-Type", "application/cbor"),
|
4396 4357 | ("smithy-protocol", "rpc-v2-cbor"),
|
4397 4358 | ];
|
4398 4359 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4399 4360 | http_response.headers(),
|
4400 4361 | expected_headers,
|
4401 4362 | ));
|
4402 4363 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4403 4364 | .await
|
4404 4365 | .expect("unable to extract body to bytes");
|
4405 4366 | ::aws_smithy_protocol_test::assert_ok(
|
4406 - | ::aws_smithy_protocol_test::validate_body(&body, "v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4367 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4407 4368 | );
|
4408 4369 | }
|
4370 + | }
|
4409 4371 |
|
4410 - | /// RpcV2 Cbor should not serialize null structure values
|
4411 - | /// Test ID: RpcV2CborServerDoesntSerializeNullStructureValues
|
4412 - | #[::tokio::test]
|
4413 - | #[::tracing_test::traced_test]
|
4414 - | async fn rpc_v2_cbor_server_doesnt_serialize_null_structure_values_response() {
|
4415 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4416 - | string_value: ::std::option::Option::None,
|
4417 - | true_boolean_value: ::std::option::Option::None,
|
4418 - | false_boolean_value: ::std::option::Option::None,
|
4419 - | byte_value: ::std::option::Option::None,
|
4420 - | double_value: ::std::option::Option::None,
|
4421 - | float_value: ::std::option::Option::None,
|
4422 - | integer_value: ::std::option::Option::None,
|
4423 - | long_value: ::std::option::Option::None,
|
4424 - | short_value: ::std::option::Option::None,
|
4425 - | blob_value: ::std::option::Option::None,
|
4426 - | };
|
4427 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4428 - | let http_response = output.into_response();
|
4429 - | ::pretty_assertions::assert_eq!(
|
4430 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4431 - | http_response.status()
|
4432 - | );
|
4433 - | let expected_headers = [
|
4434 - | ("Content-Type", "application/cbor"),
|
4435 - | ("smithy-protocol", "rpc-v2-cbor"),
|
4436 - | ];
|
4437 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4438 - | http_response.headers(),
|
4439 - | expected_headers,
|
4440 - | ));
|
4441 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4372 + | ::pin_project_lite::pin_project! {
|
4373 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4374 + | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
4375 + | pub struct GreetingWithErrorsInputFuture {
|
4376 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GreetingWithErrorsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4377 + | }
|
4378 + | }
|
4379 + |
|
4380 + | impl std::future::Future for GreetingWithErrorsInputFuture {
|
4381 + | type Output = Result<
|
4382 + | crate::input::GreetingWithErrorsInput,
|
4383 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4384 + | >;
|
4385 + |
|
4386 + | fn poll(
|
4387 + | self: std::pin::Pin<&mut Self>,
|
4388 + | cx: &mut std::task::Context<'_>,
|
4389 + | ) -> std::task::Poll<Self::Output> {
|
4390 + | let this = self.project();
|
4391 + | this.inner.as_mut().poll(cx)
|
4392 + | }
|
4393 + | }
|
4394 + |
|
4395 + | impl<B>
|
4396 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4397 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4398 + | B,
|
4399 + | > for crate::input::GreetingWithErrorsInput
|
4400 + | where
|
4401 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4402 + | B: 'static,
|
4403 + |
|
4404 + | B::Data: Send,
|
4405 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4406 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4407 + | {
|
4408 + | type Rejection =
|
4409 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4410 + | type Future = GreetingWithErrorsInputFuture;
|
4411 + |
|
4412 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4413 + | let fut = async move {
|
4414 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4415 + | request.headers(),
|
4416 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4417 + | ) {
|
4418 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4419 + | }
|
4420 + | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
4421 + | request,
|
4422 + | )
|
4442 4423 | .await
|
4443 - | .expect("unable to extract body to bytes");
|
4444 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4445 - | &body,
|
4446 - | "v/8=",
|
4447 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4448 - | ));
|
4424 + | };
|
4425 + | use ::futures_util::future::TryFutureExt;
|
4426 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4427 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4428 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
4429 + | });
|
4430 + | GreetingWithErrorsInputFuture {
|
4431 + | inner: Box::pin(fut),
|
4432 + | }
|
4433 + | }
|
4434 + | }
|
4435 + | impl
|
4436 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4437 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4438 + | > for crate::output::GreetingWithErrorsOutput
|
4439 + | {
|
4440 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4441 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
4442 + | Ok(response) => response,
|
4443 + | Err(e) => {
|
4444 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4445 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4446 + | }
|
4447 + | }
|
4448 + | }
|
4449 + | }
|
4450 + | impl
|
4451 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4452 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4453 + | > for crate::error::GreetingWithErrorsError
|
4454 + | {
|
4455 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4456 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
4457 + | &self,
|
4458 + | ) {
|
4459 + | Ok(mut response) => {
|
4460 + | response.extensions_mut().insert(
|
4461 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
4462 + | self.name(),
|
4463 + | ),
|
4464 + | );
|
4465 + | response
|
4466 + | }
|
4467 + | Err(e) => {
|
4468 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4469 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4470 + | }
|
4471 + | }
|
4449 4472 | }
|
4473 + | }
|
4450 4474 |
|
4451 - | /// Supports handling NaN float values.
|
4452 - | /// Test ID: RpcV2CborSupportsNaNFloatOutputs
|
4475 + | #[allow(unreachable_code, unused_variables)]
|
4476 + | #[cfg(test)]
|
4477 + | mod greeting_with_errors_test {
|
4478 + |
|
4479 + | /// Parses simple RpcV2 Cbor errors
|
4480 + | /// Test ID: RpcV2CborInvalidGreetingError
|
4453 4481 | #[::tokio::test]
|
4454 4482 | #[::tracing_test::traced_test]
|
4455 - | async fn rpc_v2_cbor_supports_na_n_float_outputs_response() {
|
4456 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4457 - | double_value: ::std::option::Option::Some(
|
4458 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4459 - | .expect("invalid string for number"),
|
4460 - | ),
|
4461 - | float_value: ::std::option::Option::Some(
|
4462 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4463 - | .expect("invalid string for number"),
|
4464 - | ),
|
4465 - | true_boolean_value: ::std::option::Option::None,
|
4466 - | false_boolean_value: ::std::option::Option::None,
|
4467 - | byte_value: ::std::option::Option::None,
|
4468 - | integer_value: ::std::option::Option::None,
|
4469 - | long_value: ::std::option::Option::None,
|
4470 - | short_value: ::std::option::Option::None,
|
4471 - | string_value: ::std::option::Option::None,
|
4472 - | blob_value: ::std::option::Option::None,
|
4483 + | async fn rpc_v2_cbor_invalid_greeting_error_response() {
|
4484 + | let output = crate::error::InvalidGreeting {
|
4485 + | message: ::std::option::Option::Some("Hi".to_owned()),
|
4473 4486 | };
|
4487 + | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
4474 4488 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4475 4489 | let http_response = output.into_response();
|
4476 4490 | ::pretty_assertions::assert_eq!(
|
4477 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4491 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4478 4492 | http_response.status()
|
4479 4493 | );
|
4480 4494 | let expected_headers = [
|
4481 4495 | ("Content-Type", "application/cbor"),
|
4482 4496 | ("smithy-protocol", "rpc-v2-cbor"),
|
4483 4497 | ];
|
4484 4498 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4485 4499 | http_response.headers(),
|
4486 4500 | expected_headers,
|
4487 4501 | ));
|
4488 4502 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4489 4503 | .await
|
4490 4504 | .expect("unable to extract body to bytes");
|
4491 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4492 - | &body,
|
4493 - | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/",
|
4494 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4495 - | ));
|
4505 + | ::aws_smithy_protocol_test::assert_ok(
|
4506 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4507 + | );
|
4496 4508 | }
|
4497 4509 |
|
4498 - | /// Supports handling Infinity float values.
|
4499 - | /// Test ID: RpcV2CborSupportsInfinityFloatOutputs
|
4510 + | /// Parses a complex error with no message member
|
4511 + | /// Test ID: RpcV2CborComplexError
|
4500 4512 | #[::tokio::test]
|
4501 4513 | #[::tracing_test::traced_test]
|
4502 - | async fn rpc_v2_cbor_supports_infinity_float_outputs_response() {
|
4503 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4504 - | double_value: ::std::option::Option::Some(
|
4505 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4506 - | .expect("invalid string for number"),
|
4507 - | ),
|
4508 - | float_value: ::std::option::Option::Some(
|
4509 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4510 - | .expect("invalid string for number"),
|
4511 - | ),
|
4512 - | true_boolean_value: ::std::option::Option::None,
|
4513 - | false_boolean_value: ::std::option::Option::None,
|
4514 - | byte_value: ::std::option::Option::None,
|
4515 - | integer_value: ::std::option::Option::None,
|
4516 - | long_value: ::std::option::Option::None,
|
4517 - | short_value: ::std::option::Option::None,
|
4518 - | string_value: ::std::option::Option::None,
|
4519 - | blob_value: ::std::option::Option::None,
|
4514 + | async fn rpc_v2_cbor_complex_error_response() {
|
4515 + | let output = crate::error::ComplexError {
|
4516 + | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
4517 + | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
4518 + | foo: ::std::option::Option::Some("bar".to_owned()),
|
4519 + | }),
|
4520 4520 | };
|
4521 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
4521 4522 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4522 4523 | let http_response = output.into_response();
|
4523 4524 | ::pretty_assertions::assert_eq!(
|
4524 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4525 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4525 4526 | http_response.status()
|
4526 4527 | );
|
4527 4528 | let expected_headers = [
|
4528 4529 | ("Content-Type", "application/cbor"),
|
4529 4530 | ("smithy-protocol", "rpc-v2-cbor"),
|
4530 4531 | ];
|
4531 4532 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4532 4533 | http_response.headers(),
|
4533 4534 | expected_headers,
|
4534 4535 | ));
|
4535 4536 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4536 - | .await
|
4537 - | .expect("unable to extract body to bytes");
|
4538 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4539 - | &body,
|
4540 - | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/",
|
4541 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4542 - | ));
|
4537 + | .await
|
4538 + | .expect("unable to extract body to bytes");
|
4539 + | ::aws_smithy_protocol_test::assert_ok(
|
4540 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4541 + | );
|
4543 4542 | }
|
4544 - |
|
4545 - | /// Supports handling Negative Infinity float values.
|
4546 - | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatOutputs
|
4543 + | /// Test ID: RpcV2CborEmptyComplexError
|
4547 4544 | #[::tokio::test]
|
4548 4545 | #[::tracing_test::traced_test]
|
4549 - | async fn rpc_v2_cbor_supports_negative_infinity_float_outputs_response() {
|
4550 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4551 - | double_value: ::std::option::Option::Some(
|
4552 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4553 - | .expect("invalid string for number"),
|
4554 - | ),
|
4555 - | float_value: ::std::option::Option::Some(
|
4556 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4557 - | .expect("invalid string for number"),
|
4558 - | ),
|
4559 - | true_boolean_value: ::std::option::Option::None,
|
4560 - | false_boolean_value: ::std::option::Option::None,
|
4561 - | byte_value: ::std::option::Option::None,
|
4562 - | integer_value: ::std::option::Option::None,
|
4563 - | long_value: ::std::option::Option::None,
|
4564 - | short_value: ::std::option::Option::None,
|
4565 - | string_value: ::std::option::Option::None,
|
4566 - | blob_value: ::std::option::Option::None,
|
4546 + | async fn rpc_v2_cbor_empty_complex_error_response() {
|
4547 + | let output = crate::error::ComplexError {
|
4548 + | top_level: ::std::option::Option::None,
|
4549 + | nested: ::std::option::Option::None,
|
4567 4550 | };
|
4551 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
4568 4552 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4569 4553 | let http_response = output.into_response();
|
4570 4554 | ::pretty_assertions::assert_eq!(
|
4571 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4555 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4572 4556 | http_response.status()
|
4573 4557 | );
|
4574 4558 | let expected_headers = [
|
4575 4559 | ("Content-Type", "application/cbor"),
|
4576 4560 | ("smithy-protocol", "rpc-v2-cbor"),
|
4577 4561 | ];
|
4578 4562 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4579 4563 | http_response.headers(),
|
4580 4564 | expected_headers,
|
4581 4565 | ));
|
4582 4566 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4583 4567 | .await
|
4584 4568 | .expect("unable to extract body to bytes");
|
4585 4569 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4586 4570 | &body,
|
4587 - | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/",
|
4571 + | "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/",
|
4588 4572 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4589 4573 | ));
|
4590 4574 | }
|
4591 4575 | }
|
4592 4576 |
|
4593 4577 | ::pin_project_lite::pin_project! {
|
4594 4578 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4595 - | /// [`OptionalInputOutputInput`](crate::input::OptionalInputOutputInput) using modelled bindings.
|
4596 - | pub struct OptionalInputOutputInputFuture {
|
4597 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OptionalInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4579 + | /// [`FractionalSecondsInput`](crate::input::FractionalSecondsInput) using modelled bindings.
|
4580 + | pub struct FractionalSecondsInputFuture {
|
4581 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::FractionalSecondsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4598 4582 | }
|
4599 4583 | }
|
4600 4584 |
|
4601 - | impl std::future::Future for OptionalInputOutputInputFuture {
|
4585 + | impl std::future::Future for FractionalSecondsInputFuture {
|
4602 4586 | type Output = Result<
|
4603 - | crate::input::OptionalInputOutputInput,
|
4587 + | crate::input::FractionalSecondsInput,
|
4604 4588 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4605 4589 | >;
|
4606 4590 |
|
4607 4591 | fn poll(
|
4608 4592 | self: std::pin::Pin<&mut Self>,
|
4609 4593 | cx: &mut std::task::Context<'_>,
|
4610 4594 | ) -> std::task::Poll<Self::Output> {
|
4611 4595 | let this = self.project();
|
4612 4596 | this.inner.as_mut().poll(cx)
|
4613 4597 | }
|
4614 4598 | }
|
4615 4599 |
|
4616 4600 | impl<B>
|
4617 4601 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4618 4602 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4619 4603 | B,
|
4620 - | > for crate::input::OptionalInputOutputInput
|
4604 + | > for crate::input::FractionalSecondsInput
|
4621 4605 | where
|
4622 4606 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4623 4607 | B: 'static,
|
4624 4608 |
|
4625 4609 | B::Data: Send,
|
4626 4610 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4627 4611 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4628 4612 | {
|
4629 4613 | type Rejection =
|
4630 4614 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4631 - | type Future = OptionalInputOutputInputFuture;
|
4615 + | type Future = FractionalSecondsInputFuture;
|
4632 4616 |
|
4633 4617 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4634 4618 | let fut = async move {
|
4635 4619 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4636 4620 | request.headers(),
|
4637 4621 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4638 4622 | ) {
|
4639 4623 | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4640 4624 | }
|
4641 - | crate::protocol_serde::shape_optional_input_output::de_optional_input_output_http_request(request)
|
4642 - | .await
|
4625 + | crate::protocol_serde::shape_fractional_seconds::de_fractional_seconds_http_request(
|
4626 + | request,
|
4627 + | )
|
4628 + | .await
|
4643 4629 | };
|
4644 4630 | use ::futures_util::future::TryFutureExt;
|
4645 4631 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4646 4632 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4647 4633 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
4648 4634 | });
|
4649 - | OptionalInputOutputInputFuture {
|
4635 + | FractionalSecondsInputFuture {
|
4650 4636 | inner: Box::pin(fut),
|
4651 4637 | }
|
4652 4638 | }
|
4653 4639 | }
|
4654 4640 | impl
|
4655 4641 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4656 4642 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4657 - | > for crate::output::OptionalInputOutputOutput
|
4643 + | > for crate::output::FractionalSecondsOutput
|
4658 4644 | {
|
4659 4645 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4660 - | match crate::protocol_serde::shape_optional_input_output::ser_optional_input_output_http_response(self) {
|
4661 - | Ok(response) => response,
|
4662 - | Err(e) => {
|
4663 - | ::tracing::error!(error = %e, "failed to serialize response");
|
4664 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4665 - | }
|
4666 - | }
|
4667 - | }
|
4668 - | }
|
4669 - |
|
4670 - | #[allow(unreachable_code, unused_variables)]
|
4671 - | #[cfg(test)]
|
4672 - | mod optional_input_output_test {
|
4673 - |
|
4674 - | /// When input is empty we write CBOR equivalent of {}
|
4675 - | /// Test ID: optional_input
|
4676 - | #[::tokio::test]
|
4677 - | #[::tracing_test::traced_test]
|
4678 - | async fn optional_input_request() {
|
4679 - | #[allow(unused_mut)]
|
4680 - | let mut http_request = ::http::Request::builder()
|
4681 - | .uri("/service/RpcV2Protocol/operation/OptionalInputOutput")
|
4682 - | .method("POST")
|
4683 - | .header("Accept", "application/cbor")
|
4684 - | .header("Content-Type", "application/cbor")
|
4685 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4686 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4687 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4688 - | "v/8=".as_bytes(),
|
4689 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4690 - | )),
|
4691 - | ))
|
4692 - | .unwrap();
|
4693 - | #[allow(unused_mut)]
|
4694 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4695 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4696 - | let service =
|
4697 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4698 - | .optional_input_output(move |input: crate::input::OptionalInputOutputInput| {
|
4699 - | let sender = sender.clone();
|
4700 - | async move {
|
4701 - | let result = {
|
4702 - | let expected = crate::input::OptionalInputOutputInput {
|
4703 - | value: ::std::option::Option::None,
|
4704 - | };
|
4705 - | ::pretty_assertions::assert_eq!(input, expected);
|
4706 - | let output = crate::output::OptionalInputOutputOutput {
|
4707 - | value: ::std::option::Option::None,
|
4708 - | };
|
4709 - | output
|
4710 - | };
|
4711 - | sender.send(()).await.expect("receiver dropped early");
|
4712 - | result
|
4713 - | }
|
4714 - | })
|
4715 - | .build_unchecked();
|
4716 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4717 - | .await
|
4718 - | .expect("unable to make an HTTP request");
|
4719 - | assert!(
|
4720 - | receiver.recv().await.is_some(),
|
4721 - | "we expected operation handler to be invoked but it was not entered"
|
4722 - | );
|
4723 - | }
|
4724 - |
|
4725 - | /// When output is empty we write CBOR equivalent of {}
|
4726 - | /// Test ID: optional_output
|
4727 - | #[::tokio::test]
|
4728 - | #[::tracing_test::traced_test]
|
4729 - | async fn optional_output_response() {
|
4730 - | let output = crate::output::OptionalInputOutputOutput {
|
4731 - | value: ::std::option::Option::None,
|
4732 - | };
|
4733 - | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4734 - | let http_response = output.into_response();
|
4735 - | ::pretty_assertions::assert_eq!(
|
4736 - | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4737 - | http_response.status()
|
4738 - | );
|
4739 - | let expected_headers = [
|
4740 - | ("Content-Type", "application/cbor"),
|
4741 - | ("smithy-protocol", "rpc-v2-cbor"),
|
4742 - | ];
|
4743 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4744 - | http_response.headers(),
|
4745 - | expected_headers,
|
4746 - | ));
|
4747 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4748 - | .await
|
4749 - | .expect("unable to extract body to bytes");
|
4750 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4751 - | &body,
|
4752 - | "v/8=",
|
4753 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4754 - | ));
|
4646 + | match crate::protocol_serde::shape_fractional_seconds::ser_fractional_seconds_http_response(
|
4647 + | self,
|
4648 + | ) {
|
4649 + | Ok(response) => response,
|
4650 + | Err(e) => {
|
4651 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4652 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4653 + | }
|
4654 + | }
|
4755 4655 | }
|
4756 4656 | }
|
4757 4657 |
|
4758 4658 | ::pin_project_lite::pin_project! {
|
4759 4659 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4760 - | /// [`EmptyInputOutputInput`](crate::input::EmptyInputOutputInput) using modelled bindings.
|
4761 - | pub struct EmptyInputOutputInputFuture {
|
4762 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4660 + | /// [`OperationWithDefaultsInput`](crate::input::OperationWithDefaultsInput) using modelled bindings.
|
4661 + | pub struct OperationWithDefaultsInputFuture {
|
4662 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithDefaultsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4763 4663 | }
|
4764 4664 | }
|
4765 4665 |
|
4766 - | impl std::future::Future for EmptyInputOutputInputFuture {
|
4666 + | impl std::future::Future for OperationWithDefaultsInputFuture {
|
4767 4667 | type Output = Result<
|
4768 - | crate::input::EmptyInputOutputInput,
|
4668 + | crate::input::OperationWithDefaultsInput,
|
4769 4669 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4770 4670 | >;
|
4771 4671 |
|
4772 4672 | fn poll(
|
4773 4673 | self: std::pin::Pin<&mut Self>,
|
4774 4674 | cx: &mut std::task::Context<'_>,
|
4775 4675 | ) -> std::task::Poll<Self::Output> {
|
4776 4676 | let this = self.project();
|
4777 4677 | this.inner.as_mut().poll(cx)
|
4778 4678 | }
|
4779 4679 | }
|
4780 4680 |
|
4781 4681 | impl<B>
|
4782 4682 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4783 4683 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4784 4684 | B,
|
4785 - | > for crate::input::EmptyInputOutputInput
|
4685 + | > for crate::input::OperationWithDefaultsInput
|
4786 4686 | where
|
4787 4687 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4788 4688 | B: 'static,
|
4789 4689 |
|
4790 4690 | B::Data: Send,
|
4791 4691 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4792 4692 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4793 4693 | {
|
4794 4694 | type Rejection =
|
4795 4695 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4796 - | type Future = EmptyInputOutputInputFuture;
|
4696 + | type Future = OperationWithDefaultsInputFuture;
|
4797 4697 |
|
4798 4698 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4799 4699 | let fut = async move {
|
4800 4700 | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4801 4701 | request.headers(),
|
4802 4702 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4803 4703 | ) {
|
4804 4704 | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4805 4705 | }
|
4806 - | crate::protocol_serde::shape_empty_input_output::de_empty_input_output_http_request(
|
4807 - | request,
|
4808 - | )
|
4809 - | .await
|
4706 + | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_request(request)
|
4707 + | .await
|
4810 4708 | };
|
4811 4709 | use ::futures_util::future::TryFutureExt;
|
4812 4710 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4813 4711 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4814 4712 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
4815 4713 | });
|
4816 - | EmptyInputOutputInputFuture {
|
4817 - | inner: Box::pin(fut),
|
4818 - | }
|
4819 - | }
|
4820 - | }
|
4821 - | impl
|
4822 - | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4823 - | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4824 - | > for crate::output::EmptyInputOutputOutput
|
4825 - | {
|
4826 - | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4827 - | match crate::protocol_serde::shape_empty_input_output::ser_empty_input_output_http_response(
|
4828 - | self,
|
4829 - | ) {
|
4830 - | Ok(response) => response,
|
4831 - | Err(e) => {
|
4832 - | ::tracing::error!(error = %e, "failed to serialize response");
|
4833 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4834 - | }
|
4835 - | }
|
4836 - | }
|
4837 - | }
|
4838 - |
|
4839 - | #[allow(unreachable_code, unused_variables)]
|
4840 - | #[cfg(test)]
|
4841 - | mod empty_input_output_test {
|
4842 - |
|
4843 - | /// When Input structure is empty we write CBOR equivalent of {}
|
4844 - | /// Test ID: empty_input
|
4845 - | #[::tokio::test]
|
4846 - | #[::tracing_test::traced_test]
|
4847 - | async fn empty_input_request() {
|
4848 - | #[allow(unused_mut)]
|
4849 - | let mut http_request = ::http::Request::builder()
|
4850 - | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4851 - | .method("POST")
|
4852 - | .header("Accept", "application/cbor")
|
4853 - | .header("Content-Type", "application/cbor")
|
4854 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4855 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4856 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4857 - | "v/8=".as_bytes(),
|
4858 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4859 - | )),
|
4860 - | ))
|
4861 - | .unwrap();
|
4862 - | #[allow(unused_mut)]
|
4863 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4864 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4865 - | let service =
|
4866 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4867 - | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4868 - | let sender = sender.clone();
|
4869 - | async move {
|
4870 - | let result = {
|
4871 - | let expected = crate::input::EmptyInputOutputInput {};
|
4872 - | ::pretty_assertions::assert_eq!(input, expected);
|
4873 - | let output = crate::output::EmptyInputOutputOutput {};
|
4874 - | output
|
4875 - | };
|
4876 - | sender.send(()).await.expect("receiver dropped early");
|
4877 - | result
|
4878 - | }
|
4879 - | })
|
4880 - | .build_unchecked();
|
4881 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4882 - | .await
|
4883 - | .expect("unable to make an HTTP request");
|
4884 - | assert!(
|
4885 - | receiver.recv().await.is_some(),
|
4886 - | "we expected operation handler to be invoked but it was not entered"
|
4887 - | );
|
4714 + | OperationWithDefaultsInputFuture {
|
4715 + | inner: Box::pin(fut),
|
4716 + | }
|
4888 4717 | }
|
4889 - |
|
4890 - | /// When Input structure is empty the server should accept an empty body
|
4891 - | /// Test ID: empty_input_no_body
|
4892 - | #[::tokio::test]
|
4893 - | #[::tracing_test::traced_test]
|
4894 - | async fn empty_input_no_body_request() {
|
4895 - | #[allow(unused_mut)]
|
4896 - | let mut http_request = ::http::Request::builder()
|
4897 - | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4898 - | .method("POST")
|
4899 - | .header("Accept", "application/cbor")
|
4900 - | .header("Content-Type", "application/cbor")
|
4901 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4902 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4903 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4904 - | "".as_bytes(),
|
4905 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4906 - | )),
|
4907 - | ))
|
4908 - | .unwrap();
|
4909 - | #[allow(unused_mut)]
|
4910 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4911 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4912 - | let service =
|
4913 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4914 - | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4915 - | let sender = sender.clone();
|
4916 - | async move {
|
4917 - | let result = {
|
4918 - | let expected = crate::input::EmptyInputOutputInput {};
|
4919 - | ::pretty_assertions::assert_eq!(input, expected);
|
4920 - | let output = crate::output::EmptyInputOutputOutput {};
|
4921 - | output
|
4922 - | };
|
4923 - | sender.send(()).await.expect("receiver dropped early");
|
4924 - | result
|
4718 + | }
|
4719 + | impl
|
4720 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4721 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4722 + | > for crate::output::OperationWithDefaultsOutput
|
4723 + | {
|
4724 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4725 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_response(self) {
|
4726 + | Ok(response) => response,
|
4727 + | Err(e) => {
|
4728 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4729 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4730 + | }
|
4925 4731 | }
|
4926 - | })
|
4927 - | .build_unchecked();
|
4928 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4929 - | .await
|
4930 - | .expect("unable to make an HTTP request");
|
4931 - | assert!(
|
4932 - | receiver.recv().await.is_some(),
|
4933 - | "we expected operation handler to be invoked but it was not entered"
|
4934 - | );
|
4935 4732 | }
|
4733 + | }
|
4734 + | impl
|
4735 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4736 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4737 + | > for crate::error::OperationWithDefaultsError
|
4738 + | {
|
4739 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4740 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_error(&self) {
|
4741 + | Ok(mut response) => {
|
4742 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
4743 + | response
|
4744 + | },
|
4745 + | Err(e) => {
|
4746 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4747 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4748 + | }
|
4749 + | }
|
4750 + | }
|
4751 + | }
|
4936 4752 |
|
4937 - | /// When input structure, is empty the server should accept an empty body
|
4938 - | /// even if the Accept header is set.
|
4939 - | /// Test ID: empty_input_no_body_has_accept
|
4753 + | #[allow(unreachable_code, unused_variables)]
|
4754 + | #[cfg(test)]
|
4755 + | mod operation_with_defaults_test {
|
4756 + |
|
4757 + | /// Server populates default values when missing in request body.
|
4758 + | /// Test ID: RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody
|
4940 4759 | #[::tokio::test]
|
4941 4760 | #[::tracing_test::traced_test]
|
4942 - | async fn empty_input_no_body_has_accept_request() {
|
4761 + | #[should_panic]
|
4762 + | async fn rpc_v2_cbor_server_populates_defaults_when_missing_in_request_body_request() {
|
4943 4763 | #[allow(unused_mut)]
|
4944 4764 | let mut http_request = ::http::Request::builder()
|
4945 - | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4765 + | .uri("/service/RpcV2Protocol/operation/OperationWithDefaults")
|
4946 4766 | .method("POST")
|
4947 4767 | .header("Accept", "application/cbor")
|
4948 4768 | .header("Content-Type", "application/cbor")
|
4949 4769 | .header("smithy-protocol", "rpc-v2-cbor")
|
4950 4770 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4951 4771 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4952 - | "".as_bytes(),
|
4772 + | "v2hkZWZhdWx0c6D/".as_bytes(),
|
4953 4773 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4954 4774 | )),
|
4955 4775 | ))
|
4956 4776 | .unwrap();
|
4957 4777 | #[allow(unused_mut)]
|
4958 4778 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4959 4779 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4960 - | let service =
|
4961 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4962 - | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4963 - | let sender = sender.clone();
|
4964 - | async move {
|
4965 - | let result = {
|
4966 - | let expected = crate::input::EmptyInputOutputInput {};
|
4967 - | ::pretty_assertions::assert_eq!(input, expected);
|
4968 - | let output = crate::output::EmptyInputOutputOutput {};
|
4969 - | output
|
4970 - | };
|
4971 - | sender.send(()).await.expect("receiver dropped early");
|
4972 - | result
|
4973 - | }
|
4974 - | })
|
4975 - | .build_unchecked();
|
4780 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
4781 + | config,
|
4782 + | )
|
4783 + | .operation_with_defaults(move |input: crate::input::OperationWithDefaultsInput| {
|
4784 + | let sender = sender.clone();
|
4785 + | async move {
|
4786 + | let result = {
|
4787 + | let expected = crate::input::OperationWithDefaultsInput {
|
4788 + | defaults: ::std::option::Option::Some(crate::model::Defaults {
|
4789 + | default_string: "hi".to_owned(),
|
4790 + | default_boolean: true,
|
4791 + | default_list: vec![],
|
4792 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
4793 + | 0, 0_f64,
|
4794 + | ),
|
4795 + | default_blob: ::aws_smithy_types::Blob::new("abc"),
|
4796 + | default_byte: 1,
|
4797 + | default_short: 1,
|
4798 + | default_integer: 10,
|
4799 + | default_long: 100,
|
4800 + | default_float: 1.0_f32,
|
4801 + | default_double: 1.0_f64,
|
4802 + | default_map: ::std::collections::HashMap::new(),
|
4803 + | default_enum: "FOO"
|
4804 + | .parse::<crate::model::TestEnum>()
|
4805 + | .expect("static value validated to member"),
|
4806 + | default_int_enum: 1,
|
4807 + | empty_string: "".to_owned(),
|
4808 + | false_boolean: false,
|
4809 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
4810 + | zero_byte: 0,
|
4811 + | zero_short: 0,
|
4812 + | zero_integer: 0,
|
4813 + | zero_long: 0,
|
4814 + | zero_float: 0.0_f32,
|
4815 + | zero_double: 0.0_f64,
|
4816 + | }),
|
4817 + | top_level_default: "hi".to_owned(),
|
4818 + | other_top_level_default: 0,
|
4819 + | client_optional_defaults: ::std::option::Option::None,
|
4820 + | };
|
4821 + | ::pretty_assertions::assert_eq!(input, expected);
|
4822 + | let output = crate::output::OperationWithDefaultsOutput {
|
4823 + | default_string: "".to_owned(),
|
4824 + | default_boolean: false,
|
4825 + | default_list: vec![],
|
4826 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
4827 + | 0, 0_f64,
|
4828 + | ),
|
4829 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
4830 + | default_byte: 0,
|
4831 + | default_short: 0,
|
4832 + | default_integer: 0,
|
4833 + | default_long: 0,
|
4834 + | default_float: 0_f32,
|
4835 + | default_double: 0_f64,
|
4836 + | default_map: ::std::collections::HashMap::new(),
|
4837 + | default_enum: ""
|
4838 + | .parse::<crate::model::TestEnum>()
|
4839 + | .expect("static value validated to member"),
|
4840 + | default_int_enum: 0,
|
4841 + | empty_string: "".to_owned(),
|
4842 + | false_boolean: false,
|
4843 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
4844 + | zero_byte: 0,
|
4845 + | zero_short: 0,
|
4846 + | zero_integer: 0,
|
4847 + | zero_long: 0,
|
4848 + | zero_float: 0_f32,
|
4849 + | zero_double: 0_f64,
|
4850 + | };
|
4851 + | Ok(output)
|
4852 + | };
|
4853 + | sender.send(()).await.expect("receiver dropped early");
|
4854 + | result
|
4855 + | }
|
4856 + | })
|
4857 + | .build_unchecked();
|
4976 4858 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4977 4859 | .await
|
4978 4860 | .expect("unable to make an HTTP request");
|
4979 4861 | assert!(
|
4980 4862 | receiver.recv().await.is_some(),
|
4981 4863 | "we expected operation handler to be invoked but it was not entered"
|
4982 4864 | );
|
4983 4865 | }
|
4984 4866 |
|
4985 - | /// When output structure is empty we write CBOR equivalent of {}
|
4986 - | /// Test ID: empty_output
|
4867 + | /// Server populates default values in response when missing in params.
|
4868 + | /// Test ID: RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams
|
4987 4869 | #[::tokio::test]
|
4988 4870 | #[::tracing_test::traced_test]
|
4989 - | async fn empty_output_response() {
|
4990 - | let output = crate::output::EmptyInputOutputOutput {};
|
4871 + | #[should_panic]
|
4872 + | async fn rpc_v2_cbor_server_populates_defaults_in_response_when_missing_in_params_response() {
|
4873 + | let output = crate::output::OperationWithDefaultsOutput {
|
4874 + | default_string: "".to_owned(),
|
4875 + | default_boolean: false,
|
4876 + | default_list: vec![],
|
4877 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64),
|
4878 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
4879 + | default_byte: 0,
|
4880 + | default_short: 0,
|
4881 + | default_integer: 0,
|
4882 + | default_long: 0,
|
4883 + | default_float: 0_f32,
|
4884 + | default_double: 0_f64,
|
4885 + | default_map: ::std::collections::HashMap::new(),
|
4886 + | default_enum: ""
|
4887 + | .parse::<crate::model::TestEnum>()
|
4888 + | .expect("static value validated to member"),
|
4889 + | default_int_enum: 0,
|
4890 + | empty_string: "".to_owned(),
|
4891 + | false_boolean: false,
|
4892 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
4893 + | zero_byte: 0,
|
4894 + | zero_short: 0,
|
4895 + | zero_integer: 0,
|
4896 + | zero_long: 0,
|
4897 + | zero_float: 0_f32,
|
4898 + | zero_double: 0_f64,
|
4899 + | };
|
4991 4900 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4992 4901 | let http_response = output.into_response();
|
4993 4902 | ::pretty_assertions::assert_eq!(
|
4994 4903 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4995 4904 | http_response.status()
|
4996 4905 | );
|
4997 4906 | let expected_headers = [
|
4998 4907 | ("Content-Type", "application/cbor"),
|
4999 4908 | ("smithy-protocol", "rpc-v2-cbor"),
|
5000 4909 | ];
|
5001 4910 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5002 4911 | http_response.headers(),
|
5003 4912 | expected_headers,
|
5004 4913 | ));
|
5005 4914 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5006 4915 | .await
|
5007 4916 | .expect("unable to extract body to bytes");
|
5008 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5009 - | &body,
|
5010 - | "v/8=",
|
5011 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5012 - | ));
|
4917 + | ::aws_smithy_protocol_test::assert_ok(
|
4918 + | ::aws_smithy_protocol_test::validate_body(&body, "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4919 + | );
|
5013 4920 | }
|
5014 4921 | }
|
5015 4922 |
|
5016 4923 | ::pin_project_lite::pin_project! {
|
5017 4924 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5018 - | /// [`NoInputOutputInput`](crate::input::NoInputOutputInput) using modelled bindings.
|
5019 - | pub struct NoInputOutputInputFuture {
|
5020 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NoInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4925 + | /// [`SparseNullsOperationInput`](crate::input::SparseNullsOperationInput) using modelled bindings.
|
4926 + | pub struct SparseNullsOperationInputFuture {
|
4927 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SparseNullsOperationInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5021 4928 | }
|
5022 4929 | }
|
5023 4930 |
|
5024 - | impl std::future::Future for NoInputOutputInputFuture {
|
4931 + | impl std::future::Future for SparseNullsOperationInputFuture {
|
5025 4932 | type Output = Result<
|
5026 - | crate::input::NoInputOutputInput,
|
4933 + | crate::input::SparseNullsOperationInput,
|
5027 4934 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
5028 4935 | >;
|
5029 4936 |
|
5030 4937 | fn poll(
|
5031 4938 | self: std::pin::Pin<&mut Self>,
|
5032 4939 | cx: &mut std::task::Context<'_>,
|
5033 4940 | ) -> std::task::Poll<Self::Output> {
|
5034 4941 | let this = self.project();
|
5035 4942 | this.inner.as_mut().poll(cx)
|
5036 4943 | }
|
5037 4944 | }
|
5038 4945 |
|
5039 4946 | impl<B>
|
5040 4947 | ::aws_smithy_legacy_http_server::request::FromRequest<
|
5041 4948 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5042 4949 | B,
|
5043 - | > for crate::input::NoInputOutputInput
|
4950 + | > for crate::input::SparseNullsOperationInput
|
5044 4951 | where
|
5045 4952 | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
5046 4953 | B: 'static,
|
5047 4954 |
|
5048 4955 | B::Data: Send,
|
5049 4956 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
5050 4957 | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
5051 4958 | {
|
5052 4959 | type Rejection =
|
5053 4960 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
5054 - | type Future = NoInputOutputInputFuture;
|
4961 + | type Future = SparseNullsOperationInputFuture;
|
5055 4962 |
|
5056 4963 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5057 4964 | let fut = async move {
|
5058 - | crate::protocol_serde::shape_no_input_output::de_no_input_output_http_request(request)
|
5059 - | .await
|
4965 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4966 + | request.headers(),
|
4967 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4968 + | ) {
|
4969 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4970 + | }
|
4971 + | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
4972 + | .await
|
5060 4973 | };
|
5061 4974 | use ::futures_util::future::TryFutureExt;
|
5062 4975 | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
5063 4976 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5064 4977 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
5065 4978 | });
|
5066 - | NoInputOutputInputFuture {
|
4979 + | SparseNullsOperationInputFuture {
|
5067 4980 | inner: Box::pin(fut),
|
5068 4981 | }
|
5069 4982 | }
|
5070 4983 | }
|
5071 4984 | impl
|
5072 4985 | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
5073 4986 | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5074 - | > for crate::output::NoInputOutputOutput
|
4987 + | > for crate::output::SparseNullsOperationOutput
|
5075 4988 | {
|
5076 4989 | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
5077 - | match crate::protocol_serde::shape_no_input_output::ser_no_input_output_http_response(self)
|
5078 - | {
|
5079 - | Ok(response) => response,
|
5080 - | Err(e) => {
|
5081 - | ::tracing::error!(error = %e, "failed to serialize response");
|
5082 - | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5083 - | }
|
5084 - | }
|
4990 + | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
4991 + | Ok(response) => response,
|
4992 + | Err(e) => {
|
4993 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4994 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4995 + | }
|
4996 + | }
|
5085 4997 | }
|
5086 4998 | }
|
5087 4999 |
|
5088 5000 | #[allow(unreachable_code, unused_variables)]
|
5089 5001 | #[cfg(test)]
|
5090 - | mod no_input_output_test {
|
5002 + | mod sparse_nulls_operation_test {
|
5091 5003 |
|
5092 - | /// Body is empty and no Content-Type header if no input
|
5093 - | /// Test ID: no_input
|
5004 + | /// Serializes null values in maps
|
5005 + | /// Test ID: RpcV2CborSparseMapsSerializeNullValues
|
5094 5006 | #[::tokio::test]
|
5095 5007 | #[::tracing_test::traced_test]
|
5096 - | async fn no_input_request() {
|
5008 + | async fn rpc_v2_cbor_sparse_maps_serialize_null_values_request() {
|
5097 5009 | #[allow(unused_mut)]
|
5098 5010 | let mut http_request = ::http::Request::builder()
|
5099 - | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5011 + | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
5100 5012 | .method("POST")
|
5101 5013 | .header("Accept", "application/cbor")
|
5014 + | .header("Content-Type", "application/cbor")
|
5102 5015 | .header("smithy-protocol", "rpc-v2-cbor")
|
5103 5016 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5104 5017 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5105 - | "".as_bytes(),
|
5106 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5018 + | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==".as_bytes(),
|
5019 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5107 5020 | )),
|
5108 5021 | ))
|
5109 5022 | .unwrap();
|
5110 5023 | #[allow(unused_mut)]
|
5111 5024 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5112 5025 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5113 5026 | let service =
|
5114 5027 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5115 - | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5028 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
5116 5029 | let sender = sender.clone();
|
5117 5030 | async move {
|
5118 5031 | let result = {
|
5119 - | let expected = crate::input::NoInputOutputInput {};
|
5032 + | let expected = crate::input::SparseNullsOperationInput {
|
5033 + | sparse_string_map: ::std::option::Option::Some({
|
5034 + | let mut ret = ::std::collections::HashMap::new();
|
5035 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
5036 + | ret
|
5037 + | }),
|
5038 + | sparse_string_list: ::std::option::Option::None,
|
5039 + | };
|
5120 5040 | ::pretty_assertions::assert_eq!(input, expected);
|
5121 - | let output = crate::output::NoInputOutputOutput {};
|
5041 + | let output = crate::output::SparseNullsOperationOutput {
|
5042 + | sparse_string_list: ::std::option::Option::None,
|
5043 + | sparse_string_map: ::std::option::Option::None,
|
5044 + | };
|
5122 5045 | output
|
5123 5046 | };
|
5124 5047 | sender.send(()).await.expect("receiver dropped early");
|
5125 5048 | result
|
5126 5049 | }
|
5127 5050 | })
|
5128 5051 | .build_unchecked();
|
5129 5052 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5130 5053 | .await
|
5131 5054 | .expect("unable to make an HTTP request");
|
5132 5055 | assert!(
|
5133 5056 | receiver.recv().await.is_some(),
|
5134 5057 | "we expected operation handler to be invoked but it was not entered"
|
5135 5058 | );
|
5136 5059 | }
|
5137 5060 |
|
5138 - | /// Servers should accept CBOR empty struct if no input.
|
5139 - | /// Test ID: NoInputServerAllowsEmptyCbor
|
5061 + | /// Serializes null values in lists
|
5062 + | /// Test ID: RpcV2CborSparseListsSerializeNull
|
5140 5063 | #[::tokio::test]
|
5141 5064 | #[::tracing_test::traced_test]
|
5142 - | async fn no_input_server_allows_empty_cbor_request() {
|
5065 + | async fn rpc_v2_cbor_sparse_lists_serialize_null_request() {
|
5143 5066 | #[allow(unused_mut)]
|
5144 5067 | let mut http_request = ::http::Request::builder()
|
5145 - | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5068 + | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
5146 5069 | .method("POST")
|
5147 5070 | .header("Accept", "application/cbor")
|
5148 5071 | .header("Content-Type", "application/cbor")
|
5149 5072 | .header("smithy-protocol", "rpc-v2-cbor")
|
5150 5073 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5151 5074 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5152 - | "v/8=".as_bytes(),
|
5153 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5075 + | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==".as_bytes(),
|
5076 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5154 5077 | )),
|
5155 5078 | ))
|
5156 5079 | .unwrap();
|
5157 5080 | #[allow(unused_mut)]
|
5158 5081 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5159 5082 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5160 5083 | let service =
|
5161 5084 | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5162 - | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5085 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
5163 5086 | let sender = sender.clone();
|
5164 5087 | async move {
|
5165 5088 | let result = {
|
5166 - | let expected = crate::input::NoInputOutputInput {};
|
5089 + | let expected = crate::input::SparseNullsOperationInput {
|
5090 + | sparse_string_list: ::std::option::Option::Some(vec![
|
5091 + | ::std::option::Option::None,
|
5092 + | ]),
|
5093 + | sparse_string_map: ::std::option::Option::None,
|
5094 + | };
|
5167 5095 | ::pretty_assertions::assert_eq!(input, expected);
|
5168 - | let output = crate::output::NoInputOutputOutput {};
|
5096 + | let output = crate::output::SparseNullsOperationOutput {
|
5097 + | sparse_string_list: ::std::option::Option::None,
|
5098 + | sparse_string_map: ::std::option::Option::None,
|
5099 + | };
|
5169 5100 | output
|
5170 5101 | };
|
5171 5102 | sender.send(()).await.expect("receiver dropped early");
|
5172 5103 | result
|
5173 5104 | }
|
5174 5105 | })
|
5175 5106 | .build_unchecked();
|
5176 5107 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5177 5108 | .await
|
5178 5109 | .expect("unable to make an HTTP request");
|
5179 5110 | assert!(
|
5180 5111 | receiver.recv().await.is_some(),
|
5181 5112 | "we expected operation handler to be invoked but it was not entered"
|
5182 5113 | );
|
5183 5114 | }
|
5184 5115 |
|
5185 - | /// Servers should accept an empty body if there is no input. Additionally,
|
5186 - | /// they should not raise an error if the `Accept` header is set.
|
5187 - | /// Test ID: NoInputServerAllowsEmptyBody
|
5116 + | /// Deserializes null values in maps
|
5117 + | /// Test ID: RpcV2CborSparseMapsDeserializeNullValues
|
5188 5118 | #[::tokio::test]
|
5189 5119 | #[::tracing_test::traced_test]
|
5190 - | async fn no_input_server_allows_empty_body_request() {
|
5191 - | #[allow(unused_mut)]
|
5192 - | let mut http_request = ::http::Request::builder()
|
5193 - | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5194 - | .method("POST")
|
5195 - | .header("Accept", "application/cbor")
|
5196 - | .header("Content-Type", "application/cbor")
|
5197 - | .header("smithy-protocol", "rpc-v2-cbor")
|
5198 - | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5199 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5200 - | "".as_bytes(),
|
5201 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5202 - | )),
|
5203 - | ))
|
5204 - | .unwrap();
|
5205 - | #[allow(unused_mut)]
|
5206 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5207 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5208 - | let service =
|
5209 - | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5210 - | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5211 - | let sender = sender.clone();
|
5212 - | async move {
|
5213 - | let result = {
|
5214 - | let expected = crate::input::NoInputOutputInput {};
|
5215 - | ::pretty_assertions::assert_eq!(input, expected);
|
5216 - | let output = crate::output::NoInputOutputOutput {};
|
5217 - | output
|
5218 - | };
|
5219 - | sender.send(()).await.expect("receiver dropped early");
|
5220 - | result
|
5221 - | }
|
5222 - | })
|
5223 - | .build_unchecked();
|
5224 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5225 - | .await
|
5226 - | .expect("unable to make an HTTP request");
|
5227 - | assert!(
|
5228 - | receiver.recv().await.is_some(),
|
5229 - | "we expected operation handler to be invoked but it was not entered"
|
5120 + | async fn rpc_v2_cbor_sparse_maps_deserialize_null_values_response() {
|
5121 + | let output = crate::output::SparseNullsOperationOutput {
|
5122 + | sparse_string_map: ::std::option::Option::Some({
|
5123 + | let mut ret = ::std::collections::HashMap::new();
|
5124 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
5125 + | ret
|
5126 + | }),
|
5127 + | sparse_string_list: ::std::option::Option::None,
|
5128 + | };
|
5129 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
5130 + | let http_response = output.into_response();
|
5131 + | ::pretty_assertions::assert_eq!(
|
5132 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5133 + | http_response.status()
|
5230 5134 | );
|
5135 + | let expected_headers = [
|
5136 + | ("Content-Type", "application/cbor"),
|
5137 + | ("smithy-protocol", "rpc-v2-cbor"),
|
5138 + | ];
|
5139 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5140 + | http_response.headers(),
|
5141 + | expected_headers,
|
5142 + | ));
|
5143 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5144 + | .await
|
5145 + | .expect("unable to extract body to bytes");
|
5146 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5147 + | &body,
|
5148 + | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==",
|
5149 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5150 + | ));
|
5231 5151 | }
|
5232 5152 |
|
5233 - | /// A `Content-Type` header should not be set if the response body is empty.
|
5234 - | /// Test ID: no_output
|
5153 + | /// Deserializes null values in lists
|
5154 + | /// Test ID: RpcV2CborSparseListsDeserializeNull
|
5235 5155 | #[::tokio::test]
|
5236 5156 | #[::tracing_test::traced_test]
|
5237 - | async fn no_output_response() {
|
5238 - | let output = crate::output::NoInputOutputOutput {};
|
5157 + | async fn rpc_v2_cbor_sparse_lists_deserialize_null_response() {
|
5158 + | let output = crate::output::SparseNullsOperationOutput {
|
5159 + | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
5160 + | sparse_string_map: ::std::option::Option::None,
|
5161 + | };
|
5239 5162 | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
5240 5163 | let http_response = output.into_response();
|
5241 5164 | ::pretty_assertions::assert_eq!(
|
5242 5165 | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5243 5166 | http_response.status()
|
5244 5167 | );
|
5245 - | let expected_headers = [("smithy-protocol", "rpc-v2-cbor")];
|
5168 + | let expected_headers = [
|
5169 + | ("Content-Type", "application/cbor"),
|
5170 + | ("smithy-protocol", "rpc-v2-cbor"),
|
5171 + | ];
|
5246 5172 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5247 5173 | http_response.headers(),
|
5248 5174 | expected_headers,
|
5249 5175 | ));
|
5250 - | let forbidden_headers = &["Content-Type"];
|
5251 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::forbid_headers(
|
5252 - | http_response.headers(),
|
5253 - | forbidden_headers,
|
5254 - | ));
|
5255 5176 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5256 5177 | .await
|
5257 5178 | .expect("unable to extract body to bytes");
|
5258 - | // No body.
|
5259 - | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
5179 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5180 + | &body,
|
5181 + | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==",
|
5182 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5183 + | ));
|
5184 + | }
|
5185 + | }
|
5186 + |
|
5187 + | ::pin_project_lite::pin_project! {
|
5188 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5189 + | /// [`Float16Input`](crate::input::Float16Input) using modelled bindings.
|
5190 + | pub struct Float16InputFuture {
|
5191 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::Float16Input, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5192 + | }
|
5193 + | }
|
5194 + |
|
5195 + | impl std::future::Future for Float16InputFuture {
|
5196 + | type Output = Result<
|
5197 + | crate::input::Float16Input,
|
5198 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
5199 + | >;
|
5200 + |
|
5201 + | fn poll(
|
5202 + | self: std::pin::Pin<&mut Self>,
|
5203 + | cx: &mut std::task::Context<'_>,
|
5204 + | ) -> std::task::Poll<Self::Output> {
|
5205 + | let this = self.project();
|
5206 + | this.inner.as_mut().poll(cx)
|
5207 + | }
|
5208 + | }
|
5209 + |
|
5210 + | impl<B>
|
5211 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
5212 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5213 + | B,
|
5214 + | > for crate::input::Float16Input
|
5215 + | where
|
5216 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
5217 + | B: 'static,
|
5218 + |
|
5219 + | B::Data: Send,
|
5220 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
5221 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
5222 + | {
|
5223 + | type Rejection =
|
5224 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
5225 + | type Future = Float16InputFuture;
|
5226 + |
|
5227 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5228 + | let fut = async move {
|
5229 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
5230 + | request.headers(),
|
5231 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
5232 + | ) {
|
5233 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
5234 + | }
|
5235 + | crate::protocol_serde::shape_float16::de_float16_http_request(request).await
|
5236 + | };
|
5237 + | use ::futures_util::future::TryFutureExt;
|
5238 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
5239 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5240 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
5241 + | });
|
5242 + | Float16InputFuture {
|
5243 + | inner: Box::pin(fut),
|
5244 + | }
|
5245 + | }
|
5246 + | }
|
5247 + | impl
|
5248 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
5249 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5250 + | > for crate::output::Float16Output
|
5251 + | {
|
5252 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
5253 + | match crate::protocol_serde::shape_float16::ser_float16_http_response(self) {
|
5254 + | Ok(response) => response,
|
5255 + | Err(e) => {
|
5256 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5257 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5258 + | }
|
5259 + | }
|
5260 5260 | }
|
5261 5261 | }
|