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_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_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_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_http_server::request::FromRequest<
|
27 27 | ::aws_smithy_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_http_server::body::HttpBody + Send,
|
32 32 | B: 'static,
|
33 33 |
|
34 34 | B::Data: Send,
|
35 35 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
36 36 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
37 37 | {
|
38 38 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
39 - | type Future = Float16InputFuture;
|
39 + | type Future = NoInputOutputInputFuture;
|
40 40 |
|
41 41 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
42 42 | let fut = async move {
|
43 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
44 - | request.headers(),
|
45 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
46 - | ) {
|
47 - | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
48 - | }
|
49 - | crate::protocol_serde::shape_float16::de_float16_http_request(request).await
|
43 + | crate::protocol_serde::shape_no_input_output::de_no_input_output_http_request(request)
|
44 + | .await
|
50 45 | };
|
51 46 | use ::futures_util::future::TryFutureExt;
|
52 47 | let fut = fut.map_err(
|
53 48 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
54 49 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
55 50 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
56 51 | e,
|
57 52 | )
|
58 53 | },
|
59 54 | );
|
60 - | Float16InputFuture {
|
55 + | NoInputOutputInputFuture {
|
61 56 | inner: Box::pin(fut),
|
62 57 | }
|
63 58 | }
|
64 59 | }
|
65 60 | impl
|
66 61 | ::aws_smithy_http_server::response::IntoResponse<
|
67 62 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
68 - | > for crate::output::Float16Output
|
63 + | > for crate::output::NoInputOutputOutput
|
69 64 | {
|
70 65 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
71 - | match crate::protocol_serde::shape_float16::ser_float16_http_response(self) {
|
66 + | match crate::protocol_serde::shape_no_input_output::ser_no_input_output_http_response(self)
|
67 + | {
|
72 68 | Ok(response) => response,
|
73 69 | Err(e) => {
|
74 70 | ::tracing::error!(error = %e, "failed to serialize response");
|
75 71 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
76 72 | }
|
77 73 | }
|
78 74 | }
|
79 75 | }
|
80 76 |
|
81 - | ::pin_project_lite::pin_project! {
|
82 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
83 - | /// [`SparseNullsOperationInput`](crate::input::SparseNullsOperationInput) using modelled bindings.
|
84 - | pub struct SparseNullsOperationInputFuture {
|
85 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SparseNullsOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
86 - | }
|
87 - | }
|
88 - |
|
89 - | impl std::future::Future for SparseNullsOperationInputFuture {
|
90 - | type Output = Result<
|
91 - | crate::input::SparseNullsOperationInput,
|
92 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
93 - | >;
|
94 - |
|
95 - | fn poll(
|
96 - | self: std::pin::Pin<&mut Self>,
|
97 - | cx: &mut std::task::Context<'_>,
|
98 - | ) -> std::task::Poll<Self::Output> {
|
99 - | let this = self.project();
|
100 - | this.inner.as_mut().poll(cx)
|
101 - | }
|
102 - | }
|
103 - |
|
104 - | impl<B>
|
105 - | ::aws_smithy_http_server::request::FromRequest<
|
106 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
107 - | B,
|
108 - | > for crate::input::SparseNullsOperationInput
|
109 - | where
|
110 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
111 - | B: 'static,
|
112 - |
|
113 - | B::Data: Send,
|
114 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
115 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
116 - | {
|
117 - | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
118 - | type Future = SparseNullsOperationInputFuture;
|
77 + | #[allow(unreachable_code, unused_variables)]
|
78 + | #[cfg(test)]
|
79 + | mod no_input_output_test {
|
119 80 |
|
120 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
121 - | let fut = async move {
|
122 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
123 - | request.headers(),
|
124 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
125 - | ) {
|
126 - | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
81 + | /// Body is empty and no Content-Type header if no input
|
82 + | /// Test ID: no_input
|
83 + | #[::tokio::test]
|
84 + | #[::tracing_test::traced_test]
|
85 + | async fn no_input_request() {
|
86 + | #[allow(unused_mut)]
|
87 + | let mut http_request = ::http_1x::Request::builder()
|
88 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
89 + | .method("POST")
|
90 + | .header("Accept", "application/cbor")
|
91 + | .header("smithy-protocol", "rpc-v2-cbor")
|
92 + | .body(::aws_smithy_http_server::body::boxed(
|
93 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
94 + | &::aws_smithy_protocol_test::decode_body_data(
|
95 + | "".as_bytes(),
|
96 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
97 + | ),
|
98 + | )),
|
99 + | ))
|
100 + | .unwrap();
|
101 + | #[allow(unused_mut)]
|
102 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
103 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
104 + | let service = crate::service::RpcV2Protocol::builder::<
|
105 + | ::aws_smithy_http_server::body::BoxBody,
|
106 + | _,
|
107 + | _,
|
108 + | _,
|
109 + | >(config)
|
110 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
111 + | let sender = sender.clone();
|
112 + | async move {
|
113 + | let result = {
|
114 + | let expected = crate::input::NoInputOutputInput {};
|
115 + | ::pretty_assertions::assert_eq!(input, expected);
|
116 + | let output = crate::output::NoInputOutputOutput {};
|
117 + | output
|
118 + | };
|
119 + | sender.send(()).await.expect("receiver dropped early");
|
120 + | result
|
127 121 | }
|
128 - | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
129 - | .await
|
130 - | };
|
131 - | use ::futures_util::future::TryFutureExt;
|
132 - | let fut = fut.map_err(
|
133 - | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
134 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
135 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
136 - | e,
|
137 - | )
|
138 - | },
|
122 + | })
|
123 + | .build_unchecked();
|
124 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
125 + | .await
|
126 + | .expect("unable to make an HTTP request");
|
127 + | assert!(
|
128 + | receiver.recv().await.is_some(),
|
129 + | "we expected operation handler to be invoked but it was not entered"
|
139 130 | );
|
140 - | SparseNullsOperationInputFuture {
|
141 - | inner: Box::pin(fut),
|
142 - | }
|
143 - | }
|
144 - | }
|
145 - | impl
|
146 - | ::aws_smithy_http_server::response::IntoResponse<
|
147 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
148 - | > for crate::output::SparseNullsOperationOutput
|
149 - | {
|
150 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
151 - | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
152 - | Ok(response) => response,
|
153 - | Err(e) => {
|
154 - | ::tracing::error!(error = %e, "failed to serialize response");
|
155 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
156 - | }
|
157 - | }
|
158 131 | }
|
159 - | }
|
160 - |
|
161 - | #[allow(unreachable_code, unused_variables)]
|
162 - | #[cfg(test)]
|
163 - | mod sparse_nulls_operation_test {
|
164 132 |
|
165 - | /// Serializes null values in maps
|
166 - | /// Test ID: RpcV2CborSparseMapsSerializeNullValues
|
133 + | /// Servers should accept CBOR empty struct if no input.
|
134 + | /// Test ID: NoInputServerAllowsEmptyCbor
|
167 135 | #[::tokio::test]
|
168 136 | #[::tracing_test::traced_test]
|
169 - | async fn rpc_v2_cbor_sparse_maps_serialize_null_values_request() {
|
137 + | async fn no_input_server_allows_empty_cbor_request() {
|
170 138 | #[allow(unused_mut)]
|
171 139 | let mut http_request = ::http_1x::Request::builder()
|
172 - | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
140 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
173 141 | .method("POST")
|
174 142 | .header("Accept", "application/cbor")
|
175 143 | .header("Content-Type", "application/cbor")
|
176 144 | .header("smithy-protocol", "rpc-v2-cbor")
|
177 145 | .body(::aws_smithy_http_server::body::boxed(
|
178 146 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
179 147 | &::aws_smithy_protocol_test::decode_body_data(
|
180 - | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==".as_bytes(),
|
181 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
148 + | "v/8=".as_bytes(),
|
149 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
182 150 | ),
|
183 151 | )),
|
184 152 | ))
|
185 153 | .unwrap();
|
186 154 | #[allow(unused_mut)]
|
187 155 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
188 156 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
189 157 | let service = crate::service::RpcV2Protocol::builder::<
|
190 158 | ::aws_smithy_http_server::body::BoxBody,
|
191 159 | _,
|
192 160 | _,
|
193 161 | _,
|
194 162 | >(config)
|
195 - | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
163 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
196 164 | let sender = sender.clone();
|
197 165 | async move {
|
198 166 | let result = {
|
199 - | let expected = crate::input::SparseNullsOperationInput {
|
200 - | sparse_string_map: ::std::option::Option::Some({
|
201 - | let mut ret = ::std::collections::HashMap::new();
|
202 - | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
203 - | ret
|
204 - | }),
|
205 - | sparse_string_list: ::std::option::Option::None,
|
206 - | };
|
167 + | let expected = crate::input::NoInputOutputInput {};
|
207 168 | ::pretty_assertions::assert_eq!(input, expected);
|
208 - | let output = crate::output::SparseNullsOperationOutput {
|
209 - | sparse_string_list: ::std::option::Option::None,
|
210 - | sparse_string_map: ::std::option::Option::None,
|
211 - | };
|
169 + | let output = crate::output::NoInputOutputOutput {};
|
212 170 | output
|
213 171 | };
|
214 172 | sender.send(()).await.expect("receiver dropped early");
|
215 173 | result
|
216 174 | }
|
217 175 | })
|
218 176 | .build_unchecked();
|
219 177 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
220 178 | .await
|
221 179 | .expect("unable to make an HTTP request");
|
222 180 | assert!(
|
223 181 | receiver.recv().await.is_some(),
|
224 182 | "we expected operation handler to be invoked but it was not entered"
|
225 183 | );
|
226 184 | }
|
227 185 |
|
228 - | /// Serializes null values in lists
|
229 - | /// Test ID: RpcV2CborSparseListsSerializeNull
|
186 + | /// Servers should accept an empty body if there is no input. Additionally,
|
187 + | /// they should not raise an error if the `Accept` header is set.
|
188 + | /// Test ID: NoInputServerAllowsEmptyBody
|
230 189 | #[::tokio::test]
|
231 190 | #[::tracing_test::traced_test]
|
232 - | async fn rpc_v2_cbor_sparse_lists_serialize_null_request() {
|
191 + | async fn no_input_server_allows_empty_body_request() {
|
233 192 | #[allow(unused_mut)]
|
234 193 | let mut http_request = ::http_1x::Request::builder()
|
235 - | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
194 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
236 195 | .method("POST")
|
237 196 | .header("Accept", "application/cbor")
|
238 197 | .header("Content-Type", "application/cbor")
|
239 198 | .header("smithy-protocol", "rpc-v2-cbor")
|
240 199 | .body(::aws_smithy_http_server::body::boxed(
|
241 200 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
242 201 | &::aws_smithy_protocol_test::decode_body_data(
|
243 - | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==".as_bytes(),
|
244 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
202 + | "".as_bytes(),
|
203 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
245 204 | ),
|
246 205 | )),
|
247 206 | ))
|
248 207 | .unwrap();
|
249 208 | #[allow(unused_mut)]
|
250 209 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
251 210 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
252 211 | let service = crate::service::RpcV2Protocol::builder::<
|
253 212 | ::aws_smithy_http_server::body::BoxBody,
|
254 213 | _,
|
255 214 | _,
|
256 215 | _,
|
257 216 | >(config)
|
258 - | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
217 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
259 218 | let sender = sender.clone();
|
260 219 | async move {
|
261 220 | let result = {
|
262 - | let expected = crate::input::SparseNullsOperationInput {
|
263 - | sparse_string_list: ::std::option::Option::Some(vec![
|
264 - | ::std::option::Option::None,
|
265 - | ]),
|
266 - | sparse_string_map: ::std::option::Option::None,
|
267 - | };
|
221 + | let expected = crate::input::NoInputOutputInput {};
|
268 222 | ::pretty_assertions::assert_eq!(input, expected);
|
269 - | let output = crate::output::SparseNullsOperationOutput {
|
270 - | sparse_string_list: ::std::option::Option::None,
|
271 - | sparse_string_map: ::std::option::Option::None,
|
272 - | };
|
223 + | let output = crate::output::NoInputOutputOutput {};
|
273 224 | output
|
274 225 | };
|
275 226 | sender.send(()).await.expect("receiver dropped early");
|
276 227 | result
|
277 228 | }
|
278 229 | })
|
279 230 | .build_unchecked();
|
280 231 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
281 232 | .await
|
282 233 | .expect("unable to make an HTTP request");
|
283 234 | assert!(
|
284 235 | receiver.recv().await.is_some(),
|
285 236 | "we expected operation handler to be invoked but it was not entered"
|
286 237 | );
|
287 238 | }
|
288 239 |
|
289 - | /// Deserializes null values in maps
|
290 - | /// Test ID: RpcV2CborSparseMapsDeserializeNullValues
|
240 + | /// A `Content-Type` header should not be set if the response body is empty.
|
241 + | /// Test ID: no_output
|
291 242 | #[::tokio::test]
|
292 243 | #[::tracing_test::traced_test]
|
293 - | async fn rpc_v2_cbor_sparse_maps_deserialize_null_values_response() {
|
294 - | let output = crate::output::SparseNullsOperationOutput {
|
295 - | sparse_string_map: ::std::option::Option::Some({
|
296 - | let mut ret = ::std::collections::HashMap::new();
|
297 - | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
298 - | ret
|
299 - | }),
|
300 - | sparse_string_list: ::std::option::Option::None,
|
301 - | };
|
244 + | async fn no_output_response() {
|
245 + | let output = crate::output::NoInputOutputOutput {};
|
302 246 | use ::aws_smithy_http_server::response::IntoResponse;
|
303 247 | let http_response = output.into_response();
|
304 248 | ::pretty_assertions::assert_eq!(
|
305 249 | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
306 250 | http_response.status()
|
307 251 | );
|
308 - | let expected_headers = [
|
309 - | ("Content-Type", "application/cbor"),
|
310 - | ("smithy-protocol", "rpc-v2-cbor"),
|
311 - | ];
|
252 + | let expected_headers = [("smithy-protocol", "rpc-v2-cbor")];
|
312 253 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
313 254 | http_response.headers(),
|
314 255 | expected_headers,
|
315 256 | ));
|
257 + | let forbidden_headers = &["Content-Type"];
|
258 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::forbid_headers(
|
259 + | http_response.headers(),
|
260 + | forbidden_headers,
|
261 + | ));
|
316 262 | use ::http_body_util::BodyExt;
|
317 263 | let body = http_response
|
318 264 | .into_body()
|
319 265 | .collect()
|
320 266 | .await
|
321 267 | .expect("unable to collect body")
|
322 268 | .to_bytes();
|
323 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
324 - | &body,
|
325 - | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==",
|
326 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
327 - | ));
|
269 + | // No body.
|
270 + | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
328 271 | }
|
329 - |
|
330 - | /// Deserializes null values in lists
|
331 - | /// Test ID: RpcV2CborSparseListsDeserializeNull
|
332 - | #[::tokio::test]
|
333 - | #[::tracing_test::traced_test]
|
334 - | async fn rpc_v2_cbor_sparse_lists_deserialize_null_response() {
|
335 - | let output = crate::output::SparseNullsOperationOutput {
|
336 - | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
337 - | sparse_string_map: ::std::option::Option::None,
|
338 - | };
|
339 - | use ::aws_smithy_http_server::response::IntoResponse;
|
340 - | let http_response = output.into_response();
|
341 - | ::pretty_assertions::assert_eq!(
|
342 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
343 - | http_response.status()
|
344 - | );
|
345 - | let expected_headers = [
|
346 - | ("Content-Type", "application/cbor"),
|
347 - | ("smithy-protocol", "rpc-v2-cbor"),
|
348 - | ];
|
349 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
350 - | http_response.headers(),
|
351 - | expected_headers,
|
352 - | ));
|
353 - | use ::http_body_util::BodyExt;
|
354 - | let body = http_response
|
355 - | .into_body()
|
356 - | .collect()
|
357 - | .await
|
358 - | .expect("unable to collect body")
|
359 - | .to_bytes();
|
360 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
361 - | &body,
|
362 - | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==",
|
363 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
364 - | ));
|
365 - | }
|
366 - | }
|
272 + | }
|
367 273 |
|
368 274 | ::pin_project_lite::pin_project! {
|
369 275 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
370 - | /// [`OperationWithDefaultsInput`](crate::input::OperationWithDefaultsInput) using modelled bindings.
|
371 - | pub struct OperationWithDefaultsInputFuture {
|
372 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithDefaultsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
276 + | /// [`EmptyInputOutputInput`](crate::input::EmptyInputOutputInput) using modelled bindings.
|
277 + | pub struct EmptyInputOutputInputFuture {
|
278 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
373 279 | }
|
374 280 | }
|
375 281 |
|
376 - | impl std::future::Future for OperationWithDefaultsInputFuture {
|
282 + | impl std::future::Future for EmptyInputOutputInputFuture {
|
377 283 | type Output = Result<
|
378 - | crate::input::OperationWithDefaultsInput,
|
284 + | crate::input::EmptyInputOutputInput,
|
379 285 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
380 286 | >;
|
381 287 |
|
382 288 | fn poll(
|
383 289 | self: std::pin::Pin<&mut Self>,
|
384 290 | cx: &mut std::task::Context<'_>,
|
385 291 | ) -> std::task::Poll<Self::Output> {
|
386 292 | let this = self.project();
|
387 293 | this.inner.as_mut().poll(cx)
|
388 294 | }
|
389 295 | }
|
390 296 |
|
391 297 | impl<B>
|
392 298 | ::aws_smithy_http_server::request::FromRequest<
|
393 299 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
394 300 | B,
|
395 - | > for crate::input::OperationWithDefaultsInput
|
301 + | > for crate::input::EmptyInputOutputInput
|
396 302 | where
|
397 303 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
398 304 | B: 'static,
|
399 305 |
|
400 306 | B::Data: Send,
|
401 307 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
402 308 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
403 309 | {
|
404 310 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
405 - | type Future = OperationWithDefaultsInputFuture;
|
311 + | type Future = EmptyInputOutputInputFuture;
|
406 312 |
|
407 313 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
408 314 | let fut = async move {
|
409 315 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
410 316 | request.headers(),
|
411 317 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
412 318 | ) {
|
413 319 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
414 320 | }
|
415 - | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_request(request)
|
416 - | .await
|
321 + | crate::protocol_serde::shape_empty_input_output::de_empty_input_output_http_request(
|
322 + | request,
|
323 + | )
|
324 + | .await
|
417 325 | };
|
418 326 | use ::futures_util::future::TryFutureExt;
|
419 327 | let fut = fut.map_err(
|
420 328 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
421 329 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
422 330 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
423 331 | e,
|
424 332 | )
|
425 333 | },
|
426 334 | );
|
427 - | OperationWithDefaultsInputFuture {
|
335 + | EmptyInputOutputInputFuture {
|
428 336 | inner: Box::pin(fut),
|
429 337 | }
|
430 338 | }
|
431 339 | }
|
432 340 | impl
|
433 341 | ::aws_smithy_http_server::response::IntoResponse<
|
434 342 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
435 - | > for crate::output::OperationWithDefaultsOutput
|
436 - | {
|
437 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
438 - | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_response(self) {
|
439 - | Ok(response) => response,
|
440 - | Err(e) => {
|
441 - | ::tracing::error!(error = %e, "failed to serialize response");
|
442 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
443 - | }
|
444 - | }
|
445 - | }
|
446 - | }
|
447 - | impl
|
448 - | ::aws_smithy_http_server::response::IntoResponse<
|
449 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
450 - | > for crate::error::OperationWithDefaultsError
|
343 + | > for crate::output::EmptyInputOutputOutput
|
451 344 | {
|
452 345 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
453 - | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_error(&self) {
|
454 - | Ok(mut response) => {
|
455 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
456 - | response
|
457 - | },
|
346 + | match crate::protocol_serde::shape_empty_input_output::ser_empty_input_output_http_response(
|
347 + | self,
|
348 + | ) {
|
349 + | Ok(response) => response,
|
458 350 | Err(e) => {
|
459 351 | ::tracing::error!(error = %e, "failed to serialize response");
|
460 352 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
461 353 | }
|
462 354 | }
|
463 355 | }
|
464 356 | }
|
465 357 |
|
466 358 | #[allow(unreachable_code, unused_variables)]
|
467 359 | #[cfg(test)]
|
468 - | mod operation_with_defaults_test {
|
360 + | mod empty_input_output_test {
|
469 361 |
|
470 - | /// Server populates default values when missing in request body.
|
471 - | /// Test ID: RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody
|
362 + | /// When Input structure is empty we write CBOR equivalent of {}
|
363 + | /// Test ID: empty_input
|
472 364 | #[::tokio::test]
|
473 365 | #[::tracing_test::traced_test]
|
474 - | #[should_panic]
|
475 - | async fn rpc_v2_cbor_server_populates_defaults_when_missing_in_request_body_request() {
|
366 + | async fn empty_input_request() {
|
476 367 | #[allow(unused_mut)]
|
477 368 | let mut http_request = ::http_1x::Request::builder()
|
478 - | .uri("/service/RpcV2Protocol/operation/OperationWithDefaults")
|
369 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
479 370 | .method("POST")
|
480 371 | .header("Accept", "application/cbor")
|
481 372 | .header("Content-Type", "application/cbor")
|
482 373 | .header("smithy-protocol", "rpc-v2-cbor")
|
483 374 | .body(::aws_smithy_http_server::body::boxed(
|
484 375 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
485 376 | &::aws_smithy_protocol_test::decode_body_data(
|
486 - | "v2hkZWZhdWx0c6D/".as_bytes(),
|
377 + | "v/8=".as_bytes(),
|
487 378 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
488 379 | ),
|
489 380 | )),
|
490 381 | ))
|
491 382 | .unwrap();
|
492 383 | #[allow(unused_mut)]
|
493 384 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
494 385 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
495 386 | let service = crate::service::RpcV2Protocol::builder::<
|
496 387 | ::aws_smithy_http_server::body::BoxBody,
|
497 388 | _,
|
498 389 | _,
|
499 390 | _,
|
500 391 | >(config)
|
501 - | .operation_with_defaults(move |input: crate::input::OperationWithDefaultsInput| {
|
392 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
502 393 | let sender = sender.clone();
|
503 394 | async move {
|
504 395 | let result = {
|
505 - | let expected = crate::input::OperationWithDefaultsInput {
|
506 - | defaults: ::std::option::Option::Some(crate::model::Defaults {
|
507 - | default_string: "hi".to_owned(),
|
508 - | default_boolean: true,
|
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("abc"),
|
514 - | default_byte: 1,
|
515 - | default_short: 1,
|
516 - | default_integer: 10,
|
517 - | default_long: 100,
|
518 - | default_float: 1.0_f32,
|
519 - | default_double: 1.0_f64,
|
520 - | default_map: ::std::collections::HashMap::new(),
|
521 - | default_enum: "FOO"
|
522 - | .parse::<crate::model::TestEnum>()
|
523 - | .expect("static value validated to member"),
|
524 - | default_int_enum: 1,
|
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.0_f32,
|
533 - | zero_double: 0.0_f64,
|
534 - | }),
|
535 - | top_level_default: "hi".to_owned(),
|
536 - | other_top_level_default: 0,
|
537 - | client_optional_defaults: ::std::option::Option::None,
|
538 - | };
|
396 + | let expected = crate::input::EmptyInputOutputInput {};
|
539 397 | ::pretty_assertions::assert_eq!(input, expected);
|
540 - | let output = crate::output::OperationWithDefaultsOutput {
|
541 - | default_string: "".to_owned(),
|
542 - | default_boolean: false,
|
543 - | default_list: vec![],
|
544 - | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
545 - | 0, 0_f64,
|
546 - | ),
|
547 - | default_blob: ::aws_smithy_types::Blob::new(""),
|
548 - | default_byte: 0,
|
549 - | default_short: 0,
|
550 - | default_integer: 0,
|
551 - | default_long: 0,
|
552 - | default_float: 0_f32,
|
553 - | default_double: 0_f64,
|
554 - | default_map: ::std::collections::HashMap::new(),
|
555 - | default_enum: ""
|
556 - | .parse::<crate::model::TestEnum>()
|
557 - | .expect("static value validated to member"),
|
558 - | default_int_enum: 0,
|
559 - | empty_string: "".to_owned(),
|
560 - | false_boolean: false,
|
561 - | empty_blob: ::aws_smithy_types::Blob::new(""),
|
562 - | zero_byte: 0,
|
563 - | zero_short: 0,
|
564 - | zero_integer: 0,
|
565 - | zero_long: 0,
|
566 - | zero_float: 0_f32,
|
567 - | zero_double: 0_f64,
|
568 - | };
|
569 - | Ok(output)
|
398 + | let output = crate::output::EmptyInputOutputOutput {};
|
399 + | output
|
570 400 | };
|
571 401 | sender.send(()).await.expect("receiver dropped early");
|
572 402 | result
|
573 403 | }
|
574 404 | })
|
575 405 | .build_unchecked();
|
576 406 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
577 407 | .await
|
578 408 | .expect("unable to make an HTTP request");
|
579 409 | assert!(
|
580 410 | receiver.recv().await.is_some(),
|
581 411 | "we expected operation handler to be invoked but it was not entered"
|
582 412 | );
|
583 413 | }
|
584 414 |
|
585 - | /// Server populates default values in response when missing in params.
|
586 - | /// Test ID: RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams
|
415 + | /// When Input structure is empty the server should accept an empty body
|
416 + | /// Test ID: empty_input_no_body
|
587 417 | #[::tokio::test]
|
588 418 | #[::tracing_test::traced_test]
|
589 - | #[should_panic]
|
590 - | async fn rpc_v2_cbor_server_populates_defaults_in_response_when_missing_in_params_response() {
|
591 - | let output = crate::output::OperationWithDefaultsOutput {
|
592 - | default_string: "".to_owned(),
|
593 - | default_boolean: false,
|
594 - | default_list: vec![],
|
595 - | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64),
|
596 - | default_blob: ::aws_smithy_types::Blob::new(""),
|
597 - | default_byte: 0,
|
598 - | default_short: 0,
|
599 - | default_integer: 0,
|
600 - | default_long: 0,
|
601 - | default_float: 0_f32,
|
602 - | default_double: 0_f64,
|
603 - | default_map: ::std::collections::HashMap::new(),
|
604 - | default_enum: ""
|
605 - | .parse::<crate::model::TestEnum>()
|
606 - | .expect("static value validated to member"),
|
607 - | default_int_enum: 0,
|
608 - | empty_string: "".to_owned(),
|
609 - | false_boolean: false,
|
610 - | empty_blob: ::aws_smithy_types::Blob::new(""),
|
611 - | zero_byte: 0,
|
612 - | zero_short: 0,
|
613 - | zero_integer: 0,
|
614 - | zero_long: 0,
|
615 - | zero_float: 0_f32,
|
616 - | zero_double: 0_f64,
|
617 - | };
|
618 - | use ::aws_smithy_http_server::response::IntoResponse;
|
619 - | let http_response = output.into_response();
|
620 - | ::pretty_assertions::assert_eq!(
|
621 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
622 - | http_response.status()
|
623 - | );
|
624 - | let expected_headers = [
|
625 - | ("Content-Type", "application/cbor"),
|
626 - | ("smithy-protocol", "rpc-v2-cbor"),
|
627 - | ];
|
628 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
629 - | http_response.headers(),
|
630 - | expected_headers,
|
631 - | ));
|
632 - | use ::http_body_util::BodyExt;
|
633 - | let body = http_response
|
634 - | .into_body()
|
635 - | .collect()
|
419 + | async fn empty_input_no_body_request() {
|
420 + | #[allow(unused_mut)]
|
421 + | let mut http_request = ::http_1x::Request::builder()
|
422 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
423 + | .method("POST")
|
424 + | .header("Accept", "application/cbor")
|
425 + | .header("Content-Type", "application/cbor")
|
426 + | .header("smithy-protocol", "rpc-v2-cbor")
|
427 + | .body(::aws_smithy_http_server::body::boxed(
|
428 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
429 + | &::aws_smithy_protocol_test::decode_body_data(
|
430 + | "".as_bytes(),
|
431 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
432 + | ),
|
433 + | )),
|
434 + | ))
|
435 + | .unwrap();
|
436 + | #[allow(unused_mut)]
|
437 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
438 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
439 + | let service = crate::service::RpcV2Protocol::builder::<
|
440 + | ::aws_smithy_http_server::body::BoxBody,
|
441 + | _,
|
442 + | _,
|
443 + | _,
|
444 + | >(config)
|
445 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
446 + | let sender = sender.clone();
|
447 + | async move {
|
448 + | let result = {
|
449 + | let expected = crate::input::EmptyInputOutputInput {};
|
450 + | ::pretty_assertions::assert_eq!(input, expected);
|
451 + | let output = crate::output::EmptyInputOutputOutput {};
|
452 + | output
|
453 + | };
|
454 + | sender.send(()).await.expect("receiver dropped early");
|
455 + | result
|
456 + | }
|
457 + | })
|
458 + | .build_unchecked();
|
459 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
636 460 | .await
|
637 - | .expect("unable to collect body")
|
638 - | .to_bytes();
|
639 - | ::aws_smithy_protocol_test::assert_ok(
|
640 - | ::aws_smithy_protocol_test::validate_body(&body, "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
461 + | .expect("unable to make an HTTP request");
|
462 + | assert!(
|
463 + | receiver.recv().await.is_some(),
|
464 + | "we expected operation handler to be invoked but it was not entered"
|
465 + | );
|
466 + | }
|
467 + |
|
468 + | /// When input structure, is empty the server should accept an empty body
|
469 + | /// even if the Accept header is set.
|
470 + | /// Test ID: empty_input_no_body_has_accept
|
471 + | #[::tokio::test]
|
472 + | #[::tracing_test::traced_test]
|
473 + | async fn empty_input_no_body_has_accept_request() {
|
474 + | #[allow(unused_mut)]
|
475 + | let mut http_request = ::http_1x::Request::builder()
|
476 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
477 + | .method("POST")
|
478 + | .header("Accept", "application/cbor")
|
479 + | .header("Content-Type", "application/cbor")
|
480 + | .header("smithy-protocol", "rpc-v2-cbor")
|
481 + | .body(::aws_smithy_http_server::body::boxed(
|
482 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
483 + | &::aws_smithy_protocol_test::decode_body_data(
|
484 + | "".as_bytes(),
|
485 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
486 + | ),
|
487 + | )),
|
488 + | ))
|
489 + | .unwrap();
|
490 + | #[allow(unused_mut)]
|
491 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
492 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
493 + | let service = crate::service::RpcV2Protocol::builder::<
|
494 + | ::aws_smithy_http_server::body::BoxBody,
|
495 + | _,
|
496 + | _,
|
497 + | _,
|
498 + | >(config)
|
499 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
500 + | let sender = sender.clone();
|
501 + | async move {
|
502 + | let result = {
|
503 + | let expected = crate::input::EmptyInputOutputInput {};
|
504 + | ::pretty_assertions::assert_eq!(input, expected);
|
505 + | let output = crate::output::EmptyInputOutputOutput {};
|
506 + | output
|
507 + | };
|
508 + | sender.send(()).await.expect("receiver dropped early");
|
509 + | result
|
510 + | }
|
511 + | })
|
512 + | .build_unchecked();
|
513 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
514 + | .await
|
515 + | .expect("unable to make an HTTP request");
|
516 + | assert!(
|
517 + | receiver.recv().await.is_some(),
|
518 + | "we expected operation handler to be invoked but it was not entered"
|
519 + | );
|
520 + | }
|
521 + |
|
522 + | /// When output structure is empty we write CBOR equivalent of {}
|
523 + | /// Test ID: empty_output
|
524 + | #[::tokio::test]
|
525 + | #[::tracing_test::traced_test]
|
526 + | async fn empty_output_response() {
|
527 + | let output = crate::output::EmptyInputOutputOutput {};
|
528 + | use ::aws_smithy_http_server::response::IntoResponse;
|
529 + | let http_response = output.into_response();
|
530 + | ::pretty_assertions::assert_eq!(
|
531 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
532 + | http_response.status()
|
641 533 | );
|
534 + | let expected_headers = [
|
535 + | ("Content-Type", "application/cbor"),
|
536 + | ("smithy-protocol", "rpc-v2-cbor"),
|
537 + | ];
|
538 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
539 + | http_response.headers(),
|
540 + | expected_headers,
|
541 + | ));
|
542 + | use ::http_body_util::BodyExt;
|
543 + | let body = http_response
|
544 + | .into_body()
|
545 + | .collect()
|
546 + | .await
|
547 + | .expect("unable to collect body")
|
548 + | .to_bytes();
|
549 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
550 + | &body,
|
551 + | "v/8=",
|
552 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
553 + | ));
|
642 554 | }
|
643 555 | }
|
644 556 |
|
645 557 | ::pin_project_lite::pin_project! {
|
646 558 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
647 - | /// [`FractionalSecondsInput`](crate::input::FractionalSecondsInput) using modelled bindings.
|
648 - | pub struct FractionalSecondsInputFuture {
|
649 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::FractionalSecondsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
559 + | /// [`OptionalInputOutputInput`](crate::input::OptionalInputOutputInput) using modelled bindings.
|
560 + | pub struct OptionalInputOutputInputFuture {
|
561 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OptionalInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
650 562 | }
|
651 563 | }
|
652 564 |
|
653 - | impl std::future::Future for FractionalSecondsInputFuture {
|
565 + | impl std::future::Future for OptionalInputOutputInputFuture {
|
654 566 | type Output = Result<
|
655 - | crate::input::FractionalSecondsInput,
|
567 + | crate::input::OptionalInputOutputInput,
|
656 568 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
657 569 | >;
|
658 570 |
|
659 571 | fn poll(
|
660 572 | self: std::pin::Pin<&mut Self>,
|
661 573 | cx: &mut std::task::Context<'_>,
|
662 574 | ) -> std::task::Poll<Self::Output> {
|
663 575 | let this = self.project();
|
664 576 | this.inner.as_mut().poll(cx)
|
665 577 | }
|
666 578 | }
|
667 579 |
|
668 580 | impl<B>
|
669 581 | ::aws_smithy_http_server::request::FromRequest<
|
670 582 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
671 583 | B,
|
672 - | > for crate::input::FractionalSecondsInput
|
584 + | > for crate::input::OptionalInputOutputInput
|
673 585 | where
|
674 586 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
675 587 | B: 'static,
|
676 588 |
|
677 589 | B::Data: Send,
|
678 590 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
679 591 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
680 592 | {
|
681 593 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
682 - | type Future = FractionalSecondsInputFuture;
|
594 + | type Future = OptionalInputOutputInputFuture;
|
683 595 |
|
684 596 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
685 597 | let fut = async move {
|
686 598 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
687 599 | request.headers(),
|
688 600 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
689 601 | ) {
|
690 602 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
691 603 | }
|
692 - | crate::protocol_serde::shape_fractional_seconds::de_fractional_seconds_http_request(
|
693 - | request,
|
694 - | )
|
695 - | .await
|
604 + | crate::protocol_serde::shape_optional_input_output::de_optional_input_output_http_request(request)
|
605 + | .await
|
696 606 | };
|
697 607 | use ::futures_util::future::TryFutureExt;
|
698 608 | let fut = fut.map_err(
|
699 609 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
700 610 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
701 611 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
702 612 | e,
|
703 613 | )
|
704 614 | },
|
705 615 | );
|
706 - | FractionalSecondsInputFuture {
|
616 + | OptionalInputOutputInputFuture {
|
707 617 | inner: Box::pin(fut),
|
708 618 | }
|
709 619 | }
|
710 620 | }
|
711 621 | impl
|
712 622 | ::aws_smithy_http_server::response::IntoResponse<
|
713 623 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
714 - | > for crate::output::FractionalSecondsOutput
|
624 + | > for crate::output::OptionalInputOutputOutput
|
715 625 | {
|
716 626 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
717 - | match crate::protocol_serde::shape_fractional_seconds::ser_fractional_seconds_http_response(
|
718 - | self,
|
719 - | ) {
|
720 - | Ok(response) => response,
|
721 - | Err(e) => {
|
722 - | ::tracing::error!(error = %e, "failed to serialize response");
|
723 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
627 + | match crate::protocol_serde::shape_optional_input_output::ser_optional_input_output_http_response(self) {
|
628 + | Ok(response) => response,
|
629 + | Err(e) => {
|
630 + | ::tracing::error!(error = %e, "failed to serialize response");
|
631 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
632 + | }
|
633 + | }
|
634 + | }
|
635 + | }
|
636 + |
|
637 + | #[allow(unreachable_code, unused_variables)]
|
638 + | #[cfg(test)]
|
639 + | mod optional_input_output_test {
|
640 + |
|
641 + | /// When input is empty we write CBOR equivalent of {}
|
642 + | /// Test ID: optional_input
|
643 + | #[::tokio::test]
|
644 + | #[::tracing_test::traced_test]
|
645 + | async fn optional_input_request() {
|
646 + | #[allow(unused_mut)]
|
647 + | let mut http_request = ::http_1x::Request::builder()
|
648 + | .uri("/service/RpcV2Protocol/operation/OptionalInputOutput")
|
649 + | .method("POST")
|
650 + | .header("Accept", "application/cbor")
|
651 + | .header("Content-Type", "application/cbor")
|
652 + | .header("smithy-protocol", "rpc-v2-cbor")
|
653 + | .body(::aws_smithy_http_server::body::boxed(
|
654 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
655 + | &::aws_smithy_protocol_test::decode_body_data(
|
656 + | "v/8=".as_bytes(),
|
657 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
658 + | ),
|
659 + | )),
|
660 + | ))
|
661 + | .unwrap();
|
662 + | #[allow(unused_mut)]
|
663 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
664 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
665 + | let service = crate::service::RpcV2Protocol::builder::<
|
666 + | ::aws_smithy_http_server::body::BoxBody,
|
667 + | _,
|
668 + | _,
|
669 + | _,
|
670 + | >(config)
|
671 + | .optional_input_output(move |input: crate::input::OptionalInputOutputInput| {
|
672 + | let sender = sender.clone();
|
673 + | async move {
|
674 + | let result = {
|
675 + | let expected = crate::input::OptionalInputOutputInput {
|
676 + | value: ::std::option::Option::None,
|
677 + | };
|
678 + | ::pretty_assertions::assert_eq!(input, expected);
|
679 + | let output = crate::output::OptionalInputOutputOutput {
|
680 + | value: ::std::option::Option::None,
|
681 + | };
|
682 + | output
|
683 + | };
|
684 + | sender.send(()).await.expect("receiver dropped early");
|
685 + | result
|
724 686 | }
|
725 - | }
|
687 + | })
|
688 + | .build_unchecked();
|
689 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
690 + | .await
|
691 + | .expect("unable to make an HTTP request");
|
692 + | assert!(
|
693 + | receiver.recv().await.is_some(),
|
694 + | "we expected operation handler to be invoked but it was not entered"
|
695 + | );
|
696 + | }
|
697 + |
|
698 + | /// When output is empty we write CBOR equivalent of {}
|
699 + | /// Test ID: optional_output
|
700 + | #[::tokio::test]
|
701 + | #[::tracing_test::traced_test]
|
702 + | async fn optional_output_response() {
|
703 + | let output = crate::output::OptionalInputOutputOutput {
|
704 + | value: ::std::option::Option::None,
|
705 + | };
|
706 + | use ::aws_smithy_http_server::response::IntoResponse;
|
707 + | let http_response = output.into_response();
|
708 + | ::pretty_assertions::assert_eq!(
|
709 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
710 + | http_response.status()
|
711 + | );
|
712 + | let expected_headers = [
|
713 + | ("Content-Type", "application/cbor"),
|
714 + | ("smithy-protocol", "rpc-v2-cbor"),
|
715 + | ];
|
716 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
717 + | http_response.headers(),
|
718 + | expected_headers,
|
719 + | ));
|
720 + | use ::http_body_util::BodyExt;
|
721 + | let body = http_response
|
722 + | .into_body()
|
723 + | .collect()
|
724 + | .await
|
725 + | .expect("unable to collect body")
|
726 + | .to_bytes();
|
727 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
728 + | &body,
|
729 + | "v/8=",
|
730 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
731 + | ));
|
726 732 | }
|
727 733 | }
|
728 734 |
|
729 735 | ::pin_project_lite::pin_project! {
|
730 736 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
731 - | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
732 - | pub struct GreetingWithErrorsInputFuture {
|
733 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GreetingWithErrorsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
737 + | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
738 + | pub struct SimpleScalarPropertiesInputFuture {
|
739 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
734 740 | }
|
735 741 | }
|
736 742 |
|
737 - | impl std::future::Future for GreetingWithErrorsInputFuture {
|
743 + | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
738 744 | type Output = Result<
|
739 - | crate::input::GreetingWithErrorsInput,
|
745 + | crate::input::SimpleScalarPropertiesInput,
|
740 746 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
741 747 | >;
|
742 748 |
|
743 749 | fn poll(
|
744 750 | self: std::pin::Pin<&mut Self>,
|
745 751 | cx: &mut std::task::Context<'_>,
|
746 752 | ) -> std::task::Poll<Self::Output> {
|
747 753 | let this = self.project();
|
748 754 | this.inner.as_mut().poll(cx)
|
749 755 | }
|
750 756 | }
|
751 757 |
|
752 758 | impl<B>
|
753 759 | ::aws_smithy_http_server::request::FromRequest<
|
754 760 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
755 761 | B,
|
756 - | > for crate::input::GreetingWithErrorsInput
|
762 + | > for crate::input::SimpleScalarPropertiesInput
|
757 763 | where
|
758 764 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
759 765 | B: 'static,
|
760 766 |
|
761 767 | B::Data: Send,
|
762 768 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
763 769 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
764 770 | {
|
765 771 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
766 - | type Future = GreetingWithErrorsInputFuture;
|
772 + | type Future = SimpleScalarPropertiesInputFuture;
|
767 773 |
|
768 774 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
769 775 | let fut = async move {
|
770 776 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
771 777 | request.headers(),
|
772 778 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
773 779 | ) {
|
774 780 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
775 781 | }
|
776 - | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
777 - | request,
|
778 - | )
|
779 - | .await
|
782 + | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
783 + | .await
|
780 784 | };
|
781 785 | use ::futures_util::future::TryFutureExt;
|
782 786 | let fut = fut.map_err(
|
783 787 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
784 788 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
785 789 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
786 790 | e,
|
787 791 | )
|
788 792 | },
|
789 793 | );
|
790 - | GreetingWithErrorsInputFuture {
|
794 + | SimpleScalarPropertiesInputFuture {
|
791 795 | inner: Box::pin(fut),
|
792 796 | }
|
793 797 | }
|
794 798 | }
|
795 799 | impl
|
796 800 | ::aws_smithy_http_server::response::IntoResponse<
|
797 801 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
798 - | > for crate::output::GreetingWithErrorsOutput
|
802 + | > for crate::output::SimpleScalarPropertiesOutput
|
799 803 | {
|
800 804 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
801 - | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
805 + | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
802 806 | Ok(response) => response,
|
803 807 | Err(e) => {
|
804 808 | ::tracing::error!(error = %e, "failed to serialize response");
|
805 809 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
806 810 | }
|
807 811 | }
|
808 812 | }
|
809 813 | }
|
810 - | impl
|
811 - | ::aws_smithy_http_server::response::IntoResponse<
|
812 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
813 - | > for crate::error::GreetingWithErrorsError
|
814 - | {
|
815 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
816 - | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
817 - | &self,
|
818 - | ) {
|
819 - | Ok(mut response) => {
|
820 - | response.extensions_mut().insert(
|
821 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
822 - | );
|
823 - | response
|
824 - | }
|
825 - | Err(e) => {
|
826 - | ::tracing::error!(error = %e, "failed to serialize response");
|
827 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
828 - | }
|
829 - | }
|
830 - | }
|
831 - | }
|
832 - |
|
833 - | #[allow(unreachable_code, unused_variables)]
|
834 - | #[cfg(test)]
|
835 - | mod greeting_with_errors_test {
|
836 - |
|
837 - | /// Parses simple RpcV2 Cbor errors
|
838 - | /// Test ID: RpcV2CborInvalidGreetingError
|
839 - | #[::tokio::test]
|
840 - | #[::tracing_test::traced_test]
|
841 - | async fn rpc_v2_cbor_invalid_greeting_error_response() {
|
842 - | let output = crate::error::InvalidGreeting {
|
843 - | message: ::std::option::Option::Some("Hi".to_owned()),
|
844 - | };
|
845 - | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
846 - | use ::aws_smithy_http_server::response::IntoResponse;
|
847 - | let http_response = output.into_response();
|
848 - | ::pretty_assertions::assert_eq!(
|
849 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
850 - | http_response.status()
|
851 - | );
|
852 - | let expected_headers = [
|
853 - | ("Content-Type", "application/cbor"),
|
854 - | ("smithy-protocol", "rpc-v2-cbor"),
|
855 - | ];
|
856 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
857 - | http_response.headers(),
|
858 - | expected_headers,
|
859 - | ));
|
860 - | use ::http_body_util::BodyExt;
|
861 - | let body = http_response
|
862 - | .into_body()
|
863 - | .collect()
|
864 - | .await
|
865 - | .expect("unable to collect body")
|
866 - | .to_bytes();
|
867 - | ::aws_smithy_protocol_test::assert_ok(
|
868 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
869 - | );
|
870 - | }
|
871 - |
|
872 - | /// Parses a complex error with no message member
|
873 - | /// Test ID: RpcV2CborComplexError
|
874 - | #[::tokio::test]
|
875 - | #[::tracing_test::traced_test]
|
876 - | async fn rpc_v2_cbor_complex_error_response() {
|
877 - | let output = crate::error::ComplexError {
|
878 - | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
879 - | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
880 - | foo: ::std::option::Option::Some("bar".to_owned()),
|
881 - | }),
|
882 - | };
|
883 - | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
884 - | use ::aws_smithy_http_server::response::IntoResponse;
|
885 - | let http_response = output.into_response();
|
886 - | ::pretty_assertions::assert_eq!(
|
887 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
888 - | http_response.status()
|
889 - | );
|
890 - | let expected_headers = [
|
891 - | ("Content-Type", "application/cbor"),
|
892 - | ("smithy-protocol", "rpc-v2-cbor"),
|
893 - | ];
|
894 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
895 - | http_response.headers(),
|
896 - | expected_headers,
|
897 - | ));
|
898 - | use ::http_body_util::BodyExt;
|
899 - | let body = http_response
|
900 - | .into_body()
|
901 - | .collect()
|
902 - | .await
|
903 - | .expect("unable to collect body")
|
904 - | .to_bytes();
|
905 - | ::aws_smithy_protocol_test::assert_ok(
|
906 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
907 - | );
|
908 - | }
|
909 - | /// Test ID: RpcV2CborEmptyComplexError
|
910 - | #[::tokio::test]
|
911 - | #[::tracing_test::traced_test]
|
912 - | async fn rpc_v2_cbor_empty_complex_error_response() {
|
913 - | let output = crate::error::ComplexError {
|
914 - | top_level: ::std::option::Option::None,
|
915 - | nested: ::std::option::Option::None,
|
916 - | };
|
917 - | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
918 - | use ::aws_smithy_http_server::response::IntoResponse;
|
919 - | let http_response = output.into_response();
|
920 - | ::pretty_assertions::assert_eq!(
|
921 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
922 - | http_response.status()
|
923 - | );
|
924 - | let expected_headers = [
|
925 - | ("Content-Type", "application/cbor"),
|
926 - | ("smithy-protocol", "rpc-v2-cbor"),
|
927 - | ];
|
928 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
929 - | http_response.headers(),
|
930 - | expected_headers,
|
931 - | ));
|
932 - | use ::http_body_util::BodyExt;
|
933 - | let body = http_response
|
934 - | .into_body()
|
935 - | .collect()
|
936 - | .await
|
937 - | .expect("unable to collect body")
|
938 - | .to_bytes();
|
939 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
940 - | &body,
|
941 - | "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/",
|
942 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
943 - | ));
|
944 - | }
|
945 - | }
|
946 - |
|
947 - | ::pin_project_lite::pin_project! {
|
948 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
949 - | /// [`RecursiveShapesInput`](crate::input::RecursiveShapesInput) using modelled bindings.
|
950 - | pub struct RecursiveShapesInputFuture {
|
951 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveShapesInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
952 - | }
|
953 - | }
|
954 - |
|
955 - | impl std::future::Future for RecursiveShapesInputFuture {
|
956 - | type Output = Result<
|
957 - | crate::input::RecursiveShapesInput,
|
958 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
959 - | >;
|
960 - |
|
961 - | fn poll(
|
962 - | self: std::pin::Pin<&mut Self>,
|
963 - | cx: &mut std::task::Context<'_>,
|
964 - | ) -> std::task::Poll<Self::Output> {
|
965 - | let this = self.project();
|
966 - | this.inner.as_mut().poll(cx)
|
967 - | }
|
968 - | }
|
969 - |
|
970 - | impl<B>
|
971 - | ::aws_smithy_http_server::request::FromRequest<
|
972 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
973 - | B,
|
974 - | > for crate::input::RecursiveShapesInput
|
975 - | where
|
976 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
977 - | B: 'static,
|
978 - |
|
979 - | B::Data: Send,
|
980 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
981 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
982 - | {
|
983 - | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
984 - | type Future = RecursiveShapesInputFuture;
|
985 - |
|
986 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
987 - | let fut = async move {
|
988 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
989 - | request.headers(),
|
990 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
991 - | ) {
|
992 - | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
993 - | }
|
994 - | crate::protocol_serde::shape_recursive_shapes::de_recursive_shapes_http_request(request)
|
995 - | .await
|
996 - | };
|
997 - | use ::futures_util::future::TryFutureExt;
|
998 - | let fut = fut.map_err(
|
999 - | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1000 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1001 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
1002 - | e,
|
1003 - | )
|
1004 - | },
|
1005 - | );
|
1006 - | RecursiveShapesInputFuture {
|
1007 - | inner: Box::pin(fut),
|
1008 - | }
|
1009 - | }
|
1010 - | }
|
1011 - | impl
|
1012 - | ::aws_smithy_http_server::response::IntoResponse<
|
1013 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1014 - | > for crate::output::RecursiveShapesOutput
|
1015 - | {
|
1016 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1017 - | match crate::protocol_serde::shape_recursive_shapes::ser_recursive_shapes_http_response(
|
1018 - | self,
|
1019 - | ) {
|
1020 - | Ok(response) => response,
|
1021 - | Err(e) => {
|
1022 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1023 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1024 - | }
|
1025 - | }
|
1026 - | }
|
1027 - | }
|
1028 814 |
|
1029 815 | #[allow(unreachable_code, unused_variables)]
|
1030 816 | #[cfg(test)]
|
1031 - | mod recursive_shapes_test {
|
817 + | mod simple_scalar_properties_test {
|
1032 818 |
|
1033 - | /// Serializes recursive structures
|
1034 - | /// Test ID: RpcV2CborRecursiveShapes
|
819 + | /// Serializes simple scalar properties
|
820 + | /// Test ID: RpcV2CborSimpleScalarProperties
|
1035 821 | #[::tokio::test]
|
1036 822 | #[::tracing_test::traced_test]
|
1037 - | async fn rpc_v2_cbor_recursive_shapes_request() {
|
823 + | async fn rpc_v2_cbor_simple_scalar_properties_request() {
|
1038 824 | #[allow(unused_mut)]
|
1039 825 | let mut http_request = ::http_1x::Request::builder()
|
1040 - | .uri("/service/RpcV2Protocol/operation/RecursiveShapes")
|
826 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1041 827 | .method("POST")
|
1042 828 | .header("Accept", "application/cbor")
|
1043 829 | .header("Content-Type", "application/cbor")
|
1044 830 | .header("smithy-protocol", "rpc-v2-cbor")
|
1045 831 | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1046 832 | ::bytes::Bytes::copy_from_slice(
|
1047 - | &::aws_smithy_protocol_test::decode_body_data("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
833 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1048 834 | )
|
1049 835 | ))).unwrap();
|
1050 836 | #[allow(unused_mut)]
|
1051 837 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1052 838 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1053 - | let service = crate::service::RpcV2Protocol::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1054 - | .recursive_shapes(move |input: crate::input::RecursiveShapesInput| {
|
1055 - | let sender = sender.clone();
|
1056 - | async move {
|
1057 - | let result = { let expected =
|
1058 - | crate::input::RecursiveShapesInput {
|
1059 - | nested:
|
1060 - | ::std::option::Option::Some(
|
1061 - | crate::model::RecursiveShapesInputOutputNested1 {
|
1062 - | foo:
|
1063 - | ::std::option::Option::Some(
|
1064 - | "Foo1".to_owned()
|
1065 - | )
|
1066 - | ,
|
1067 - | nested:
|
1068 - | ::std::option::Option::Some(
|
1069 - | ::std::boxed::Box::new(
|
1070 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1071 - | bar:
|
1072 - | ::std::option::Option::Some(
|
1073 - | "Bar1".to_owned()
|
1074 - | )
|
1075 - | ,
|
1076 - | recursive_member:
|
1077 - | ::std::option::Option::Some(
|
1078 - | crate::model::RecursiveShapesInputOutputNested1 {
|
1079 - | foo:
|
1080 - | ::std::option::Option::Some(
|
1081 - | "Foo2".to_owned()
|
1082 - | )
|
1083 - | ,
|
1084 - | nested:
|
1085 - | ::std::option::Option::Some(
|
1086 - | ::std::boxed::Box::new(
|
1087 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1088 - | bar:
|
1089 - | ::std::option::Option::Some(
|
1090 - | "Bar2".to_owned()
|
1091 - | )
|
1092 - | ,
|
1093 - | recursive_member:
|
1094 - | ::std::option::Option::None
|
1095 - | ,
|
1096 - | }
|
1097 - | )
|
1098 - | )
|
1099 - | ,
|
1100 - | }
|
1101 - | )
|
1102 - | ,
|
1103 - | }
|
1104 - | )
|
1105 - | )
|
1106 - | ,
|
1107 - | }
|
1108 - | )
|
1109 - | ,
|
1110 - | }
|
1111 - | ;
|
1112 - | ::pretty_assertions::assert_eq!(input, expected);
|
1113 - | let output =
|
1114 - | crate::output::RecursiveShapesOutput {
|
1115 - | nested:
|
1116 - | ::std::option::Option::None
|
1117 - | ,
|
839 + | let service = crate::service::RpcV2Protocol::builder::<
|
840 + | ::aws_smithy_http_server::body::BoxBody,
|
841 + | _,
|
842 + | _,
|
843 + | _,
|
844 + | >(config)
|
845 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
846 + | let sender = sender.clone();
|
847 + | async move {
|
848 + | let result = {
|
849 + | use ::aws_smithy_protocol_test::FloatEquals;
|
850 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
851 + | byte_value: ::std::option::Option::Some(5),
|
852 + | double_value: ::std::option::Option::Some(1.889_f64),
|
853 + | false_boolean_value: ::std::option::Option::Some(false),
|
854 + | float_value: ::std::option::Option::Some(7.625_f32),
|
855 + | integer_value: ::std::option::Option::Some(256),
|
856 + | long_value: ::std::option::Option::Some(9873),
|
857 + | short_value: ::std::option::Option::Some(9898),
|
858 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
859 + | true_boolean_value: ::std::option::Option::Some(true),
|
860 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
861 + | "foo",
|
862 + | )),
|
863 + | };
|
864 + | ::pretty_assertions::assert_eq!(
|
865 + | input.true_boolean_value,
|
866 + | expected.true_boolean_value,
|
867 + | "Unexpected value for `true_boolean_value`"
|
868 + | );
|
869 + | ::pretty_assertions::assert_eq!(
|
870 + | input.false_boolean_value,
|
871 + | expected.false_boolean_value,
|
872 + | "Unexpected value for `false_boolean_value`"
|
873 + | );
|
874 + | ::pretty_assertions::assert_eq!(
|
875 + | input.byte_value,
|
876 + | expected.byte_value,
|
877 + | "Unexpected value for `byte_value`"
|
878 + | );
|
879 + | assert!(
|
880 + | input.double_value.float_equals(&expected.double_value),
|
881 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
882 + | expected.double_value,
|
883 + | input.double_value
|
884 + | );
|
885 + | assert!(
|
886 + | input.float_value.float_equals(&expected.float_value),
|
887 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
888 + | expected.float_value,
|
889 + | input.float_value
|
890 + | );
|
891 + | ::pretty_assertions::assert_eq!(
|
892 + | input.integer_value,
|
893 + | expected.integer_value,
|
894 + | "Unexpected value for `integer_value`"
|
895 + | );
|
896 + | ::pretty_assertions::assert_eq!(
|
897 + | input.long_value,
|
898 + | expected.long_value,
|
899 + | "Unexpected value for `long_value`"
|
900 + | );
|
901 + | ::pretty_assertions::assert_eq!(
|
902 + | input.short_value,
|
903 + | expected.short_value,
|
904 + | "Unexpected value for `short_value`"
|
905 + | );
|
906 + | ::pretty_assertions::assert_eq!(
|
907 + | input.string_value,
|
908 + | expected.string_value,
|
909 + | "Unexpected value for `string_value`"
|
910 + | );
|
911 + | ::pretty_assertions::assert_eq!(
|
912 + | input.blob_value,
|
913 + | expected.blob_value,
|
914 + | "Unexpected value for `blob_value`"
|
915 + | );
|
916 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
917 + | true_boolean_value: ::std::option::Option::None,
|
918 + | false_boolean_value: ::std::option::Option::None,
|
919 + | byte_value: ::std::option::Option::None,
|
920 + | double_value: ::std::option::Option::None,
|
921 + | float_value: ::std::option::Option::None,
|
922 + | integer_value: ::std::option::Option::None,
|
923 + | long_value: ::std::option::Option::None,
|
924 + | short_value: ::std::option::Option::None,
|
925 + | string_value: ::std::option::Option::None,
|
926 + | blob_value: ::std::option::Option::None,
|
927 + | };
|
928 + | output
|
929 + | };
|
930 + | sender.send(()).await.expect("receiver dropped early");
|
931 + | result
|
1118 932 | }
|
1119 - | ;
|
1120 - | output };
|
1121 - | sender.send(()).await.expect("receiver dropped early");
|
1122 - | result
|
1123 - | }
|
1124 - | })
|
1125 - | .build_unchecked();
|
933 + | })
|
934 + | .build_unchecked();
|
1126 935 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1127 936 | .await
|
1128 937 | .expect("unable to make an HTTP request");
|
1129 938 | assert!(
|
1130 939 | receiver.recv().await.is_some(),
|
1131 940 | "we expected operation handler to be invoked but it was not entered"
|
1132 941 | );
|
1133 942 | }
|
1134 943 |
|
1135 - | /// Serializes recursive structures
|
1136 - | /// Test ID: RpcV2CborRecursiveShapes
|
944 + | /// The server should be capable of deserializing simple scalar properties
|
945 + | /// encoded using a map with a definite length. The server should also be able to parse
|
946 + | /// a key encoded using an indefinite length string.
|
947 + | /// Test ID: RpcV2CborSimpleScalarPropertiesUsingIndefiniteLength
|
1137 948 | #[::tokio::test]
|
1138 949 | #[::tracing_test::traced_test]
|
1139 - | async fn rpc_v2_cbor_recursive_shapes_response() {
|
1140 - | let output = crate::output::RecursiveShapesOutput {
|
1141 - | nested: ::std::option::Option::Some(crate::model::RecursiveShapesInputOutputNested1 {
|
1142 - | foo: ::std::option::Option::Some("Foo1".to_owned()),
|
1143 - | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
1144 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1145 - | bar: ::std::option::Option::Some("Bar1".to_owned()),
|
1146 - | recursive_member: ::std::option::Option::Some(
|
1147 - | crate::model::RecursiveShapesInputOutputNested1 {
|
1148 - | foo: ::std::option::Option::Some("Foo2".to_owned()),
|
1149 - | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
1150 - | crate::model::RecursiveShapesInputOutputNested2 {
|
1151 - | bar: ::std::option::Option::Some("Bar2".to_owned()),
|
1152 - | recursive_member: ::std::option::Option::None,
|
1153 - | },
|
1154 - | )),
|
1155 - | },
|
1156 - | ),
|
1157 - | },
|
1158 - | )),
|
1159 - | }),
|
1160 - | };
|
1161 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1162 - | let http_response = output.into_response();
|
1163 - | ::pretty_assertions::assert_eq!(
|
1164 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1165 - | http_response.status()
|
1166 - | );
|
1167 - | let expected_headers = [
|
1168 - | ("Content-Type", "application/cbor"),
|
1169 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1170 - | ];
|
1171 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1172 - | http_response.headers(),
|
1173 - | expected_headers,
|
1174 - | ));
|
1175 - | use ::http_body_util::BodyExt;
|
1176 - | let body = http_response
|
1177 - | .into_body()
|
1178 - | .collect()
|
1179 - | .await
|
1180 - | .expect("unable to collect body")
|
1181 - | .to_bytes();
|
1182 - | ::aws_smithy_protocol_test::assert_ok(
|
1183 - | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1184 - | );
|
1185 - | }
|
1186 - | }
|
1187 - |
|
1188 - | ::pin_project_lite::pin_project! {
|
1189 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1190 - | /// [`RpcV2CborSparseMapsInput`](crate::input::RpcV2CborSparseMapsInput) using modelled bindings.
|
1191 - | pub struct RpcV2CborSparseMapsInputFuture {
|
1192 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborSparseMapsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1193 - | }
|
1194 - | }
|
1195 - |
|
1196 - | impl std::future::Future for RpcV2CborSparseMapsInputFuture {
|
1197 - | type Output = Result<
|
1198 - | crate::input::RpcV2CborSparseMapsInput,
|
1199 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1200 - | >;
|
1201 - |
|
1202 - | fn poll(
|
1203 - | self: std::pin::Pin<&mut Self>,
|
1204 - | cx: &mut std::task::Context<'_>,
|
1205 - | ) -> std::task::Poll<Self::Output> {
|
1206 - | let this = self.project();
|
1207 - | this.inner.as_mut().poll(cx)
|
1208 - | }
|
1209 - | }
|
1210 - |
|
1211 - | impl<B>
|
1212 - | ::aws_smithy_http_server::request::FromRequest<
|
1213 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1214 - | B,
|
1215 - | > for crate::input::RpcV2CborSparseMapsInput
|
1216 - | where
|
1217 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1218 - | B: 'static,
|
1219 - |
|
1220 - | B::Data: Send,
|
1221 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1222 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1223 - | {
|
1224 - | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1225 - | type Future = RpcV2CborSparseMapsInputFuture;
|
1226 - |
|
1227 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1228 - | let fut = async move {
|
1229 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1230 - | request.headers(),
|
1231 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1232 - | ) {
|
1233 - | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1234 - | }
|
1235 - | crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::de_rpc_v2_cbor_sparse_maps_http_request(request)
|
1236 - | .await
|
1237 - | };
|
1238 - | use ::futures_util::future::TryFutureExt;
|
1239 - | let fut = fut.map_err(
|
1240 - | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1241 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1242 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
1243 - | e,
|
1244 - | )
|
1245 - | },
|
1246 - | );
|
1247 - | RpcV2CborSparseMapsInputFuture {
|
1248 - | inner: Box::pin(fut),
|
1249 - | }
|
1250 - | }
|
1251 - | }
|
1252 - | impl
|
1253 - | ::aws_smithy_http_server::response::IntoResponse<
|
1254 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1255 - | > for crate::output::RpcV2CborSparseMapsOutput
|
1256 - | {
|
1257 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1258 - | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_response(self) {
|
1259 - | Ok(response) => response,
|
1260 - | Err(e) => {
|
1261 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1262 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1263 - | }
|
1264 - | }
|
1265 - | }
|
1266 - | }
|
1267 - | impl
|
1268 - | ::aws_smithy_http_server::response::IntoResponse<
|
1269 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1270 - | > for crate::error::RpcV2CborSparseMapsError
|
1271 - | {
|
1272 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1273 - | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_error(&self) {
|
1274 - | Ok(mut response) => {
|
1275 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1276 - | response
|
1277 - | },
|
1278 - | Err(e) => {
|
1279 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1280 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1281 - | }
|
1282 - | }
|
1283 - | }
|
1284 - | }
|
1285 - |
|
1286 - | #[allow(unreachable_code, unused_variables)]
|
1287 - | #[cfg(test)]
|
1288 - | mod rpc_v2_cbor_sparse_maps_test {
|
1289 - |
|
1290 - | /// Serializes sparse maps
|
1291 - | /// Test ID: RpcV2CborSparseMaps
|
1292 - | #[::tokio::test]
|
1293 - | #[::tracing_test::traced_test]
|
1294 - | async fn rpc_v2_cbor_sparse_maps_request() {
|
1295 - | #[allow(unused_mut)]
|
1296 - | let mut http_request = ::http_1x::Request::builder()
|
1297 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1298 - | .method("POST")
|
1299 - | .header("Accept", "application/cbor")
|
1300 - | .header("Content-Type", "application/cbor")
|
1301 - | .header("smithy-protocol", "rpc-v2-cbor")
|
1302 - | .body(::aws_smithy_http_server::body::boxed(
|
1303 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1304 - | &::aws_smithy_protocol_test::decode_body_data(
|
1305 - | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////"
|
1306 - | .as_bytes(),
|
1307 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1308 - | ),
|
1309 - | )),
|
1310 - | ))
|
1311 - | .unwrap();
|
1312 - | #[allow(unused_mut)]
|
1313 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1314 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1315 - | let service = crate::service::RpcV2Protocol::builder::<
|
1316 - | ::aws_smithy_http_server::body::BoxBody,
|
1317 - | _,
|
1318 - | _,
|
1319 - | _,
|
1320 - | >(config)
|
1321 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1322 - | let sender = sender.clone();
|
1323 - | async move {
|
1324 - | let result = {
|
1325 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1326 - | sparse_struct_map: ::std::option::Option::Some({
|
1327 - | let mut ret = ::std::collections::HashMap::new();
|
1328 - | ret.insert(
|
1329 - | "foo".to_owned(),
|
1330 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1331 - | hi: ::std::option::Option::Some("there".to_owned()),
|
1332 - | }),
|
1333 - | );
|
1334 - | ret.insert(
|
1335 - | "baz".to_owned(),
|
1336 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1337 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
1338 - | }),
|
1339 - | );
|
1340 - | ret
|
1341 - | }),
|
1342 - | sparse_number_map: ::std::option::Option::None,
|
1343 - | sparse_boolean_map: ::std::option::Option::None,
|
1344 - | sparse_string_map: ::std::option::Option::None,
|
1345 - | sparse_set_map: ::std::option::Option::None,
|
1346 - | };
|
1347 - | ::pretty_assertions::assert_eq!(input, expected);
|
1348 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1349 - | sparse_struct_map: ::std::option::Option::None,
|
1350 - | sparse_number_map: ::std::option::Option::None,
|
1351 - | sparse_boolean_map: ::std::option::Option::None,
|
1352 - | sparse_string_map: ::std::option::Option::None,
|
1353 - | sparse_set_map: ::std::option::Option::None,
|
1354 - | };
|
1355 - | Ok(output)
|
1356 - | };
|
1357 - | sender.send(()).await.expect("receiver dropped early");
|
1358 - | result
|
1359 - | }
|
1360 - | })
|
1361 - | .build_unchecked();
|
1362 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1363 - | .await
|
1364 - | .expect("unable to make an HTTP request");
|
1365 - | assert!(
|
1366 - | receiver.recv().await.is_some(),
|
1367 - | "we expected operation handler to be invoked but it was not entered"
|
1368 - | );
|
1369 - | }
|
1370 - |
|
1371 - | /// Serializes null map values in sparse maps
|
1372 - | /// Test ID: RpcV2CborSerializesNullMapValues
|
1373 - | #[::tokio::test]
|
1374 - | #[::tracing_test::traced_test]
|
1375 - | async fn rpc_v2_cbor_serializes_null_map_values_request() {
|
950 + | async fn rpc_v2_cbor_simple_scalar_properties_using_indefinite_length_request() {
|
1376 951 | #[allow(unused_mut)]
|
1377 952 | let mut http_request = ::http_1x::Request::builder()
|
1378 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
953 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1379 954 | .method("POST")
|
1380 955 | .header("Accept", "application/cbor")
|
1381 956 | .header("Content-Type", "application/cbor")
|
1382 957 | .header("smithy-protocol", "rpc-v2-cbor")
|
1383 958 | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1384 959 | ::bytes::Bytes::copy_from_slice(
|
1385 - | &::aws_smithy_protocol_test::decode_body_data("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
960 + | &::aws_smithy_protocol_test::decode_body_data("qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA9AAAbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1386 961 | )
|
1387 962 | ))).unwrap();
|
1388 963 | #[allow(unused_mut)]
|
1389 964 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1390 965 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1391 966 | let service = crate::service::RpcV2Protocol::builder::<
|
1392 967 | ::aws_smithy_http_server::body::BoxBody,
|
1393 968 | _,
|
1394 969 | _,
|
1395 970 | _,
|
1396 971 | >(config)
|
1397 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
972 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
1398 973 | let sender = sender.clone();
|
1399 974 | async move {
|
1400 975 | let result = {
|
1401 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1402 - | sparse_boolean_map: ::std::option::Option::Some({
|
1403 - | let mut ret = ::std::collections::HashMap::new();
|
1404 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1405 - | ret
|
1406 - | }),
|
1407 - | sparse_number_map: ::std::option::Option::Some({
|
1408 - | let mut ret = ::std::collections::HashMap::new();
|
1409 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1410 - | ret
|
1411 - | }),
|
1412 - | sparse_string_map: ::std::option::Option::Some({
|
1413 - | let mut ret = ::std::collections::HashMap::new();
|
1414 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1415 - | ret
|
1416 - | }),
|
1417 - | sparse_struct_map: ::std::option::Option::Some({
|
1418 - | let mut ret = ::std::collections::HashMap::new();
|
1419 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1420 - | ret
|
1421 - | }),
|
1422 - | sparse_set_map: ::std::option::Option::None,
|
976 + | use ::aws_smithy_protocol_test::FloatEquals;
|
977 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
978 + | byte_value: ::std::option::Option::Some(5),
|
979 + | double_value: ::std::option::Option::Some(1.889_f64),
|
980 + | false_boolean_value: ::std::option::Option::Some(false),
|
981 + | float_value: ::std::option::Option::Some(7.625_f32),
|
982 + | integer_value: ::std::option::Option::Some(256),
|
983 + | long_value: ::std::option::Option::Some(9873),
|
984 + | short_value: ::std::option::Option::Some(9898),
|
985 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
986 + | true_boolean_value: ::std::option::Option::Some(true),
|
987 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
988 + | "foo",
|
989 + | )),
|
1423 990 | };
|
1424 - | ::pretty_assertions::assert_eq!(input, expected);
|
1425 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1426 - | sparse_struct_map: ::std::option::Option::None,
|
1427 - | sparse_number_map: ::std::option::Option::None,
|
1428 - | sparse_boolean_map: ::std::option::Option::None,
|
1429 - | sparse_string_map: ::std::option::Option::None,
|
1430 - | sparse_set_map: ::std::option::Option::None,
|
991 + | ::pretty_assertions::assert_eq!(
|
992 + | input.true_boolean_value,
|
993 + | expected.true_boolean_value,
|
994 + | "Unexpected value for `true_boolean_value`"
|
995 + | );
|
996 + | ::pretty_assertions::assert_eq!(
|
997 + | input.false_boolean_value,
|
998 + | expected.false_boolean_value,
|
999 + | "Unexpected value for `false_boolean_value`"
|
1000 + | );
|
1001 + | ::pretty_assertions::assert_eq!(
|
1002 + | input.byte_value,
|
1003 + | expected.byte_value,
|
1004 + | "Unexpected value for `byte_value`"
|
1005 + | );
|
1006 + | assert!(
|
1007 + | input.double_value.float_equals(&expected.double_value),
|
1008 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1009 + | expected.double_value,
|
1010 + | input.double_value
|
1011 + | );
|
1012 + | assert!(
|
1013 + | input.float_value.float_equals(&expected.float_value),
|
1014 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1015 + | expected.float_value,
|
1016 + | input.float_value
|
1017 + | );
|
1018 + | ::pretty_assertions::assert_eq!(
|
1019 + | input.integer_value,
|
1020 + | expected.integer_value,
|
1021 + | "Unexpected value for `integer_value`"
|
1022 + | );
|
1023 + | ::pretty_assertions::assert_eq!(
|
1024 + | input.long_value,
|
1025 + | expected.long_value,
|
1026 + | "Unexpected value for `long_value`"
|
1027 + | );
|
1028 + | ::pretty_assertions::assert_eq!(
|
1029 + | input.short_value,
|
1030 + | expected.short_value,
|
1031 + | "Unexpected value for `short_value`"
|
1032 + | );
|
1033 + | ::pretty_assertions::assert_eq!(
|
1034 + | input.string_value,
|
1035 + | expected.string_value,
|
1036 + | "Unexpected value for `string_value`"
|
1037 + | );
|
1038 + | ::pretty_assertions::assert_eq!(
|
1039 + | input.blob_value,
|
1040 + | expected.blob_value,
|
1041 + | "Unexpected value for `blob_value`"
|
1042 + | );
|
1043 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1044 + | true_boolean_value: ::std::option::Option::None,
|
1045 + | false_boolean_value: ::std::option::Option::None,
|
1046 + | byte_value: ::std::option::Option::None,
|
1047 + | double_value: ::std::option::Option::None,
|
1048 + | float_value: ::std::option::Option::None,
|
1049 + | integer_value: ::std::option::Option::None,
|
1050 + | long_value: ::std::option::Option::None,
|
1051 + | short_value: ::std::option::Option::None,
|
1052 + | string_value: ::std::option::Option::None,
|
1053 + | blob_value: ::std::option::Option::None,
|
1431 1054 | };
|
1432 - | Ok(output)
|
1055 + | output
|
1433 1056 | };
|
1434 1057 | sender.send(()).await.expect("receiver dropped early");
|
1435 1058 | result
|
1436 1059 | }
|
1437 1060 | })
|
1438 1061 | .build_unchecked();
|
1439 1062 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1440 1063 | .await
|
1441 1064 | .expect("unable to make an HTTP request");
|
1442 1065 | assert!(
|
1443 1066 | receiver.recv().await.is_some(),
|
1444 1067 | "we expected operation handler to be invoked but it was not entered"
|
1445 1068 | );
|
1446 1069 | }
|
1447 1070 |
|
1448 - | /// A request that contains a sparse map of sets
|
1449 - | /// Test ID: RpcV2CborSerializesSparseSetMap
|
1071 + | /// RpcV2 Cbor should not deserialize null structure values
|
1072 + | /// Test ID: RpcV2CborServerDoesntDeSerializeNullStructureValues
|
1450 1073 | #[::tokio::test]
|
1451 1074 | #[::tracing_test::traced_test]
|
1452 - | async fn rpc_v2_cbor_serializes_sparse_set_map_request() {
|
1075 + | async fn rpc_v2_cbor_server_doesnt_de_serialize_null_structure_values_request() {
|
1453 1076 | #[allow(unused_mut)]
|
1454 1077 | let mut http_request = ::http_1x::Request::builder()
|
1455 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1078 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1456 1079 | .method("POST")
|
1457 1080 | .header("Accept", "application/cbor")
|
1458 1081 | .header("Content-Type", "application/cbor")
|
1459 1082 | .header("smithy-protocol", "rpc-v2-cbor")
|
1460 1083 | .body(::aws_smithy_http_server::body::boxed(
|
1461 1084 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1462 1085 | &::aws_smithy_protocol_test::decode_body_data(
|
1463 - | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=".as_bytes(),
|
1086 + | "v2tzdHJpbmdWYWx1Zfb/".as_bytes(),
|
1464 1087 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1465 1088 | ),
|
1466 1089 | )),
|
1467 1090 | ))
|
1468 1091 | .unwrap();
|
1469 1092 | #[allow(unused_mut)]
|
1470 1093 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1471 1094 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1472 1095 | let service = crate::service::RpcV2Protocol::builder::<
|
1473 1096 | ::aws_smithy_http_server::body::BoxBody,
|
1474 1097 | _,
|
1475 1098 | _,
|
1476 1099 | _,
|
1477 1100 | >(config)
|
1478 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1101 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
1479 1102 | let sender = sender.clone();
|
1480 1103 | async move {
|
1481 1104 | let result = {
|
1482 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1483 - | sparse_set_map: ::std::option::Option::Some({
|
1484 - | let mut ret = ::std::collections::HashMap::new();
|
1485 - | ret.insert(
|
1486 - | "x".to_owned(),
|
1487 - | ::std::option::Option::Some(
|
1488 - | vec![].try_into().expect("this is only used in tests"),
|
1489 - | ),
|
1490 - | );
|
1491 - | ret.insert(
|
1492 - | "y".to_owned(),
|
1493 - | ::std::option::Option::Some(
|
1494 - | vec!["a".to_owned(), "b".to_owned()]
|
1495 - | .try_into()
|
1496 - | .expect("this is only used in tests"),
|
1497 - | ),
|
1498 - | );
|
1499 - | ret
|
1500 - | }),
|
1501 - | sparse_struct_map: ::std::option::Option::None,
|
1502 - | sparse_number_map: ::std::option::Option::None,
|
1503 - | sparse_boolean_map: ::std::option::Option::None,
|
1504 - | sparse_string_map: ::std::option::Option::None,
|
1105 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1106 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1107 + | true_boolean_value: ::std::option::Option::None,
|
1108 + | false_boolean_value: ::std::option::Option::None,
|
1109 + | byte_value: ::std::option::Option::None,
|
1110 + | double_value: ::std::option::Option::None,
|
1111 + | float_value: ::std::option::Option::None,
|
1112 + | integer_value: ::std::option::Option::None,
|
1113 + | long_value: ::std::option::Option::None,
|
1114 + | short_value: ::std::option::Option::None,
|
1115 + | string_value: ::std::option::Option::None,
|
1116 + | blob_value: ::std::option::Option::None,
|
1505 1117 | };
|
1506 - | ::pretty_assertions::assert_eq!(input, expected);
|
1507 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1508 - | sparse_struct_map: ::std::option::Option::None,
|
1509 - | sparse_number_map: ::std::option::Option::None,
|
1510 - | sparse_boolean_map: ::std::option::Option::None,
|
1511 - | sparse_string_map: ::std::option::Option::None,
|
1512 - | sparse_set_map: ::std::option::Option::None,
|
1118 + | ::pretty_assertions::assert_eq!(
|
1119 + | input.true_boolean_value,
|
1120 + | expected.true_boolean_value,
|
1121 + | "Unexpected value for `true_boolean_value`"
|
1122 + | );
|
1123 + | ::pretty_assertions::assert_eq!(
|
1124 + | input.false_boolean_value,
|
1125 + | expected.false_boolean_value,
|
1126 + | "Unexpected value for `false_boolean_value`"
|
1127 + | );
|
1128 + | ::pretty_assertions::assert_eq!(
|
1129 + | input.byte_value,
|
1130 + | expected.byte_value,
|
1131 + | "Unexpected value for `byte_value`"
|
1132 + | );
|
1133 + | assert!(
|
1134 + | input.double_value.float_equals(&expected.double_value),
|
1135 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1136 + | expected.double_value,
|
1137 + | input.double_value
|
1138 + | );
|
1139 + | assert!(
|
1140 + | input.float_value.float_equals(&expected.float_value),
|
1141 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1142 + | expected.float_value,
|
1143 + | input.float_value
|
1144 + | );
|
1145 + | ::pretty_assertions::assert_eq!(
|
1146 + | input.integer_value,
|
1147 + | expected.integer_value,
|
1148 + | "Unexpected value for `integer_value`"
|
1149 + | );
|
1150 + | ::pretty_assertions::assert_eq!(
|
1151 + | input.long_value,
|
1152 + | expected.long_value,
|
1153 + | "Unexpected value for `long_value`"
|
1154 + | );
|
1155 + | ::pretty_assertions::assert_eq!(
|
1156 + | input.short_value,
|
1157 + | expected.short_value,
|
1158 + | "Unexpected value for `short_value`"
|
1159 + | );
|
1160 + | ::pretty_assertions::assert_eq!(
|
1161 + | input.string_value,
|
1162 + | expected.string_value,
|
1163 + | "Unexpected value for `string_value`"
|
1164 + | );
|
1165 + | ::pretty_assertions::assert_eq!(
|
1166 + | input.blob_value,
|
1167 + | expected.blob_value,
|
1168 + | "Unexpected value for `blob_value`"
|
1169 + | );
|
1170 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1171 + | true_boolean_value: ::std::option::Option::None,
|
1172 + | false_boolean_value: ::std::option::Option::None,
|
1173 + | byte_value: ::std::option::Option::None,
|
1174 + | double_value: ::std::option::Option::None,
|
1175 + | float_value: ::std::option::Option::None,
|
1176 + | integer_value: ::std::option::Option::None,
|
1177 + | long_value: ::std::option::Option::None,
|
1178 + | short_value: ::std::option::Option::None,
|
1179 + | string_value: ::std::option::Option::None,
|
1180 + | blob_value: ::std::option::Option::None,
|
1513 1181 | };
|
1514 - | Ok(output)
|
1182 + | output
|
1515 1183 | };
|
1516 1184 | sender.send(()).await.expect("receiver dropped early");
|
1517 1185 | result
|
1518 1186 | }
|
1519 1187 | })
|
1520 1188 | .build_unchecked();
|
1521 1189 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1522 1190 | .await
|
1523 1191 | .expect("unable to make an HTTP request");
|
1524 1192 | assert!(
|
1525 1193 | receiver.recv().await.is_some(),
|
1526 1194 | "we expected operation handler to be invoked but it was not entered"
|
1527 1195 | );
|
1528 1196 | }
|
1529 1197 |
|
1530 - | /// A request that contains a sparse map of sets.
|
1531 - | /// Test ID: RpcV2CborSerializesSparseSetMapAndRetainsNull
|
1198 + | /// Supports handling NaN float values.
|
1199 + | /// Test ID: RpcV2CborSupportsNaNFloatInputs
|
1532 1200 | #[::tokio::test]
|
1533 1201 | #[::tracing_test::traced_test]
|
1534 - | async fn rpc_v2_cbor_serializes_sparse_set_map_and_retains_null_request() {
|
1202 + | async fn rpc_v2_cbor_supports_na_n_float_inputs_request() {
|
1535 1203 | #[allow(unused_mut)]
|
1536 1204 | let mut http_request = ::http_1x::Request::builder()
|
1537 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1205 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1538 1206 | .method("POST")
|
1539 1207 | .header("Accept", "application/cbor")
|
1540 1208 | .header("Content-Type", "application/cbor")
|
1541 1209 | .header("smithy-protocol", "rpc-v2-cbor")
|
1542 1210 | .body(::aws_smithy_http_server::body::boxed(
|
1543 1211 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1544 1212 | &::aws_smithy_protocol_test::decode_body_data(
|
1545 - | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=".as_bytes(),
|
1213 + | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/".as_bytes(),
|
1546 1214 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1547 1215 | ),
|
1548 1216 | )),
|
1549 1217 | ))
|
1550 1218 | .unwrap();
|
1551 1219 | #[allow(unused_mut)]
|
1552 1220 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1553 1221 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1554 1222 | let service = crate::service::RpcV2Protocol::builder::<
|
1555 1223 | ::aws_smithy_http_server::body::BoxBody,
|
1556 1224 | _,
|
1557 1225 | _,
|
1558 1226 | _,
|
1559 1227 | >(config)
|
1560 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1228 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
1561 1229 | let sender = sender.clone();
|
1562 1230 | async move {
|
1563 1231 | let result = {
|
1564 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1565 - | sparse_set_map: ::std::option::Option::Some({
|
1566 - | let mut ret = ::std::collections::HashMap::new();
|
1567 - | ret.insert(
|
1568 - | "x".to_owned(),
|
1569 - | ::std::option::Option::Some(
|
1570 - | vec![].try_into().expect("this is only used in tests"),
|
1571 - | ),
|
1572 - | );
|
1573 - | ret.insert(
|
1574 - | "y".to_owned(),
|
1575 - | ::std::option::Option::Some(
|
1576 - | vec!["a".to_owned(), "b".to_owned()]
|
1577 - | .try_into()
|
1578 - | .expect("this is only used in tests"),
|
1579 - | ),
|
1580 - | );
|
1581 - | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1582 - | ret
|
1583 - | }),
|
1584 - | sparse_struct_map: ::std::option::Option::None,
|
1585 - | sparse_number_map: ::std::option::Option::None,
|
1586 - | sparse_boolean_map: ::std::option::Option::None,
|
1587 - | sparse_string_map: ::std::option::Option::None,
|
1232 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1233 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1234 + | double_value: ::std::option::Option::Some(
|
1235 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1236 + | "NaN",
|
1237 + | )
|
1238 + | .expect("invalid string for number"),
|
1239 + | ),
|
1240 + | float_value: ::std::option::Option::Some(
|
1241 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1242 + | "NaN",
|
1243 + | )
|
1244 + | .expect("invalid string for number"),
|
1245 + | ),
|
1246 + | true_boolean_value: ::std::option::Option::None,
|
1247 + | false_boolean_value: ::std::option::Option::None,
|
1248 + | byte_value: ::std::option::Option::None,
|
1249 + | integer_value: ::std::option::Option::None,
|
1250 + | long_value: ::std::option::Option::None,
|
1251 + | short_value: ::std::option::Option::None,
|
1252 + | string_value: ::std::option::Option::None,
|
1253 + | blob_value: ::std::option::Option::None,
|
1588 1254 | };
|
1589 - | ::pretty_assertions::assert_eq!(input, expected);
|
1590 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1591 - | sparse_struct_map: ::std::option::Option::None,
|
1592 - | sparse_number_map: ::std::option::Option::None,
|
1593 - | sparse_boolean_map: ::std::option::Option::None,
|
1594 - | sparse_string_map: ::std::option::Option::None,
|
1595 - | sparse_set_map: ::std::option::Option::None,
|
1255 + | ::pretty_assertions::assert_eq!(
|
1256 + | input.true_boolean_value,
|
1257 + | expected.true_boolean_value,
|
1258 + | "Unexpected value for `true_boolean_value`"
|
1259 + | );
|
1260 + | ::pretty_assertions::assert_eq!(
|
1261 + | input.false_boolean_value,
|
1262 + | expected.false_boolean_value,
|
1263 + | "Unexpected value for `false_boolean_value`"
|
1264 + | );
|
1265 + | ::pretty_assertions::assert_eq!(
|
1266 + | input.byte_value,
|
1267 + | expected.byte_value,
|
1268 + | "Unexpected value for `byte_value`"
|
1269 + | );
|
1270 + | assert!(
|
1271 + | input.double_value.float_equals(&expected.double_value),
|
1272 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1273 + | expected.double_value,
|
1274 + | input.double_value
|
1275 + | );
|
1276 + | assert!(
|
1277 + | input.float_value.float_equals(&expected.float_value),
|
1278 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1279 + | expected.float_value,
|
1280 + | input.float_value
|
1281 + | );
|
1282 + | ::pretty_assertions::assert_eq!(
|
1283 + | input.integer_value,
|
1284 + | expected.integer_value,
|
1285 + | "Unexpected value for `integer_value`"
|
1286 + | );
|
1287 + | ::pretty_assertions::assert_eq!(
|
1288 + | input.long_value,
|
1289 + | expected.long_value,
|
1290 + | "Unexpected value for `long_value`"
|
1291 + | );
|
1292 + | ::pretty_assertions::assert_eq!(
|
1293 + | input.short_value,
|
1294 + | expected.short_value,
|
1295 + | "Unexpected value for `short_value`"
|
1296 + | );
|
1297 + | ::pretty_assertions::assert_eq!(
|
1298 + | input.string_value,
|
1299 + | expected.string_value,
|
1300 + | "Unexpected value for `string_value`"
|
1301 + | );
|
1302 + | ::pretty_assertions::assert_eq!(
|
1303 + | input.blob_value,
|
1304 + | expected.blob_value,
|
1305 + | "Unexpected value for `blob_value`"
|
1306 + | );
|
1307 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1308 + | true_boolean_value: ::std::option::Option::None,
|
1309 + | false_boolean_value: ::std::option::Option::None,
|
1310 + | byte_value: ::std::option::Option::None,
|
1311 + | double_value: ::std::option::Option::None,
|
1312 + | float_value: ::std::option::Option::None,
|
1313 + | integer_value: ::std::option::Option::None,
|
1314 + | long_value: ::std::option::Option::None,
|
1315 + | short_value: ::std::option::Option::None,
|
1316 + | string_value: ::std::option::Option::None,
|
1317 + | blob_value: ::std::option::Option::None,
|
1596 1318 | };
|
1597 - | Ok(output)
|
1319 + | output
|
1598 1320 | };
|
1599 1321 | sender.send(()).await.expect("receiver dropped early");
|
1600 1322 | result
|
1601 1323 | }
|
1602 1324 | })
|
1603 1325 | .build_unchecked();
|
1604 1326 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1605 1327 | .await
|
1606 1328 | .expect("unable to make an HTTP request");
|
1607 1329 | assert!(
|
1608 1330 | receiver.recv().await.is_some(),
|
1609 1331 | "we expected operation handler to be invoked but it was not entered"
|
1610 1332 | );
|
1611 1333 | }
|
1612 1334 |
|
1613 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1614 - | /// Test ID: RpcV2CborSerializesZeroValuesInSparseMaps
|
1335 + | /// Supports handling Infinity float values.
|
1336 + | /// Test ID: RpcV2CborSupportsInfinityFloatInputs
|
1615 1337 | #[::tokio::test]
|
1616 1338 | #[::tracing_test::traced_test]
|
1617 - | async fn rpc_v2_cbor_serializes_zero_values_in_sparse_maps_request() {
|
1339 + | async fn rpc_v2_cbor_supports_infinity_float_inputs_request() {
|
1618 1340 | #[allow(unused_mut)]
|
1619 1341 | let mut http_request = ::http_1x::Request::builder()
|
1620 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1342 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1621 1343 | .method("POST")
|
1622 1344 | .header("Accept", "application/cbor")
|
1623 1345 | .header("Content-Type", "application/cbor")
|
1624 1346 | .header("smithy-protocol", "rpc-v2-cbor")
|
1625 1347 | .body(::aws_smithy_http_server::body::boxed(
|
1626 1348 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1627 1349 | &::aws_smithy_protocol_test::decode_body_data(
|
1628 - | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//".as_bytes(),
|
1350 + | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/".as_bytes(),
|
1629 1351 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1630 1352 | ),
|
1631 1353 | )),
|
1632 1354 | ))
|
1633 1355 | .unwrap();
|
1634 1356 | #[allow(unused_mut)]
|
1635 1357 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1636 1358 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1637 1359 | let service = crate::service::RpcV2Protocol::builder::<
|
1638 1360 | ::aws_smithy_http_server::body::BoxBody,
|
1639 1361 | _,
|
1640 1362 | _,
|
1641 1363 | _,
|
1642 1364 | >(config)
|
1643 - | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1365 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
1644 1366 | let sender = sender.clone();
|
1645 1367 | async move {
|
1646 1368 | let result = {
|
1647 - | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1648 - | sparse_number_map: ::std::option::Option::Some({
|
1649 - | let mut ret = ::std::collections::HashMap::new();
|
1650 - | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1651 - | ret
|
1652 - | }),
|
1653 - | sparse_boolean_map: ::std::option::Option::Some({
|
1654 - | let mut ret = ::std::collections::HashMap::new();
|
1655 - | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
1656 - | ret
|
1657 - | }),
|
1658 - | sparse_struct_map: ::std::option::Option::None,
|
1659 - | sparse_string_map: ::std::option::Option::None,
|
1660 - | sparse_set_map: ::std::option::Option::None,
|
1369 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1370 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1371 + | double_value: ::std::option::Option::Some(
|
1372 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1373 + | "Infinity",
|
1374 + | )
|
1375 + | .expect("invalid string for number"),
|
1376 + | ),
|
1377 + | float_value: ::std::option::Option::Some(
|
1378 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1379 + | "Infinity",
|
1380 + | )
|
1381 + | .expect("invalid string for number"),
|
1382 + | ),
|
1383 + | true_boolean_value: ::std::option::Option::None,
|
1384 + | false_boolean_value: ::std::option::Option::None,
|
1385 + | byte_value: ::std::option::Option::None,
|
1386 + | integer_value: ::std::option::Option::None,
|
1387 + | long_value: ::std::option::Option::None,
|
1388 + | short_value: ::std::option::Option::None,
|
1389 + | string_value: ::std::option::Option::None,
|
1390 + | blob_value: ::std::option::Option::None,
|
1661 1391 | };
|
1662 - | ::pretty_assertions::assert_eq!(input, expected);
|
1663 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1664 - | sparse_struct_map: ::std::option::Option::None,
|
1665 - | sparse_number_map: ::std::option::Option::None,
|
1666 - | sparse_boolean_map: ::std::option::Option::None,
|
1667 - | sparse_string_map: ::std::option::Option::None,
|
1668 - | sparse_set_map: ::std::option::Option::None,
|
1392 + | ::pretty_assertions::assert_eq!(
|
1393 + | input.true_boolean_value,
|
1394 + | expected.true_boolean_value,
|
1395 + | "Unexpected value for `true_boolean_value`"
|
1396 + | );
|
1397 + | ::pretty_assertions::assert_eq!(
|
1398 + | input.false_boolean_value,
|
1399 + | expected.false_boolean_value,
|
1400 + | "Unexpected value for `false_boolean_value`"
|
1401 + | );
|
1402 + | ::pretty_assertions::assert_eq!(
|
1403 + | input.byte_value,
|
1404 + | expected.byte_value,
|
1405 + | "Unexpected value for `byte_value`"
|
1406 + | );
|
1407 + | assert!(
|
1408 + | input.double_value.float_equals(&expected.double_value),
|
1409 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1410 + | expected.double_value,
|
1411 + | input.double_value
|
1412 + | );
|
1413 + | assert!(
|
1414 + | input.float_value.float_equals(&expected.float_value),
|
1415 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1416 + | expected.float_value,
|
1417 + | input.float_value
|
1418 + | );
|
1419 + | ::pretty_assertions::assert_eq!(
|
1420 + | input.integer_value,
|
1421 + | expected.integer_value,
|
1422 + | "Unexpected value for `integer_value`"
|
1423 + | );
|
1424 + | ::pretty_assertions::assert_eq!(
|
1425 + | input.long_value,
|
1426 + | expected.long_value,
|
1427 + | "Unexpected value for `long_value`"
|
1428 + | );
|
1429 + | ::pretty_assertions::assert_eq!(
|
1430 + | input.short_value,
|
1431 + | expected.short_value,
|
1432 + | "Unexpected value for `short_value`"
|
1433 + | );
|
1434 + | ::pretty_assertions::assert_eq!(
|
1435 + | input.string_value,
|
1436 + | expected.string_value,
|
1437 + | "Unexpected value for `string_value`"
|
1438 + | );
|
1439 + | ::pretty_assertions::assert_eq!(
|
1440 + | input.blob_value,
|
1441 + | expected.blob_value,
|
1442 + | "Unexpected value for `blob_value`"
|
1443 + | );
|
1444 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1445 + | true_boolean_value: ::std::option::Option::None,
|
1446 + | false_boolean_value: ::std::option::Option::None,
|
1447 + | byte_value: ::std::option::Option::None,
|
1448 + | double_value: ::std::option::Option::None,
|
1449 + | float_value: ::std::option::Option::None,
|
1450 + | integer_value: ::std::option::Option::None,
|
1451 + | long_value: ::std::option::Option::None,
|
1452 + | short_value: ::std::option::Option::None,
|
1453 + | string_value: ::std::option::Option::None,
|
1454 + | blob_value: ::std::option::Option::None,
|
1669 1455 | };
|
1670 - | Ok(output)
|
1456 + | output
|
1671 1457 | };
|
1672 1458 | sender.send(()).await.expect("receiver dropped early");
|
1673 1459 | result
|
1674 1460 | }
|
1675 1461 | })
|
1676 1462 | .build_unchecked();
|
1677 1463 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1678 1464 | .await
|
1679 1465 | .expect("unable to make an HTTP request");
|
1680 1466 | assert!(
|
1681 1467 | receiver.recv().await.is_some(),
|
1682 1468 | "we expected operation handler to be invoked but it was not entered"
|
1683 1469 | );
|
1684 1470 | }
|
1685 1471 |
|
1686 - | /// Deserializes sparse maps
|
1687 - | /// Test ID: RpcV2CborSparseJsonMaps
|
1688 - | #[::tokio::test]
|
1689 - | #[::tracing_test::traced_test]
|
1690 - | async fn rpc_v2_cbor_sparse_json_maps_response() {
|
1691 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1692 - | sparse_struct_map: ::std::option::Option::Some({
|
1693 - | let mut ret = ::std::collections::HashMap::new();
|
1694 - | ret.insert(
|
1695 - | "foo".to_owned(),
|
1696 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1697 - | hi: ::std::option::Option::Some("there".to_owned()),
|
1698 - | }),
|
1699 - | );
|
1700 - | ret.insert(
|
1701 - | "baz".to_owned(),
|
1702 - | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1703 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
1704 - | }),
|
1705 - | );
|
1706 - | ret
|
1707 - | }),
|
1708 - | sparse_number_map: ::std::option::Option::None,
|
1709 - | sparse_boolean_map: ::std::option::Option::None,
|
1710 - | sparse_string_map: ::std::option::Option::None,
|
1711 - | sparse_set_map: ::std::option::Option::None,
|
1712 - | };
|
1713 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1714 - | let http_response = output.into_response();
|
1715 - | ::pretty_assertions::assert_eq!(
|
1716 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1717 - | http_response.status()
|
1718 - | );
|
1719 - | let expected_headers = [
|
1720 - | ("Content-Type", "application/cbor"),
|
1721 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1722 - | ];
|
1723 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1724 - | http_response.headers(),
|
1725 - | expected_headers,
|
1726 - | ));
|
1727 - | use ::http_body_util::BodyExt;
|
1728 - | let body = http_response
|
1729 - | .into_body()
|
1730 - | .collect()
|
1731 - | .await
|
1732 - | .expect("unable to collect body")
|
1733 - | .to_bytes();
|
1734 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1735 - | &body,
|
1736 - | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////",
|
1737 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1738 - | ));
|
1739 - | }
|
1740 - |
|
1741 - | /// Deserializes null map values
|
1742 - | /// Test ID: RpcV2CborDeserializesNullMapValues
|
1743 - | #[::tokio::test]
|
1744 - | #[::tracing_test::traced_test]
|
1745 - | async fn rpc_v2_cbor_deserializes_null_map_values_response() {
|
1746 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1747 - | sparse_boolean_map: ::std::option::Option::Some({
|
1748 - | let mut ret = ::std::collections::HashMap::new();
|
1749 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1750 - | ret
|
1751 - | }),
|
1752 - | sparse_number_map: ::std::option::Option::Some({
|
1753 - | let mut ret = ::std::collections::HashMap::new();
|
1754 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1755 - | ret
|
1756 - | }),
|
1757 - | sparse_string_map: ::std::option::Option::Some({
|
1758 - | let mut ret = ::std::collections::HashMap::new();
|
1759 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1760 - | ret
|
1761 - | }),
|
1762 - | sparse_struct_map: ::std::option::Option::Some({
|
1763 - | let mut ret = ::std::collections::HashMap::new();
|
1764 - | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1765 - | ret
|
1766 - | }),
|
1767 - | sparse_set_map: ::std::option::Option::None,
|
1768 - | };
|
1769 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1770 - | let http_response = output.into_response();
|
1771 - | ::pretty_assertions::assert_eq!(
|
1772 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1773 - | http_response.status()
|
1774 - | );
|
1775 - | let expected_headers = [
|
1776 - | ("Content-Type", "application/cbor"),
|
1777 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1778 - | ];
|
1779 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1780 - | http_response.headers(),
|
1781 - | expected_headers,
|
1782 - | ));
|
1783 - | use ::http_body_util::BodyExt;
|
1784 - | let body = http_response
|
1785 - | .into_body()
|
1786 - | .collect()
|
1787 - | .await
|
1788 - | .expect("unable to collect body")
|
1789 - | .to_bytes();
|
1790 - | ::aws_smithy_protocol_test::assert_ok(
|
1791 - | ::aws_smithy_protocol_test::validate_body(&body, "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1792 - | );
|
1793 - | }
|
1794 - |
|
1795 - | /// A response that contains a sparse map of sets
|
1796 - | /// Test ID: RpcV2CborDeserializesSparseSetMap
|
1472 + | /// Supports handling Infinity float values.
|
1473 + | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatInputs
|
1797 1474 | #[::tokio::test]
|
1798 1475 | #[::tracing_test::traced_test]
|
1799 - | async fn rpc_v2_cbor_deserializes_sparse_set_map_response() {
|
1800 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1801 - | sparse_set_map: ::std::option::Option::Some({
|
1802 - | let mut ret = ::std::collections::HashMap::new();
|
1803 - | ret.insert(
|
1804 - | "x".to_owned(),
|
1805 - | ::std::option::Option::Some(
|
1806 - | vec![].try_into().expect("this is only used in tests"),
|
1807 - | ),
|
1808 - | );
|
1809 - | ret.insert(
|
1810 - | "y".to_owned(),
|
1811 - | ::std::option::Option::Some(
|
1812 - | vec!["a".to_owned(), "b".to_owned()]
|
1813 - | .try_into()
|
1814 - | .expect("this is only used in tests"),
|
1815 - | ),
|
1816 - | );
|
1817 - | ret
|
1818 - | }),
|
1819 - | sparse_struct_map: ::std::option::Option::None,
|
1820 - | sparse_number_map: ::std::option::Option::None,
|
1821 - | sparse_boolean_map: ::std::option::Option::None,
|
1822 - | sparse_string_map: ::std::option::Option::None,
|
1823 - | };
|
1824 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1825 - | let http_response = output.into_response();
|
1826 - | ::pretty_assertions::assert_eq!(
|
1827 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1828 - | http_response.status()
|
1829 - | );
|
1830 - | let expected_headers = [
|
1831 - | ("Content-Type", "application/cbor"),
|
1832 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1833 - | ];
|
1834 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1835 - | http_response.headers(),
|
1836 - | expected_headers,
|
1837 - | ));
|
1838 - | use ::http_body_util::BodyExt;
|
1839 - | let body = http_response
|
1840 - | .into_body()
|
1841 - | .collect()
|
1842 - | .await
|
1843 - | .expect("unable to collect body")
|
1844 - | .to_bytes();
|
1845 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1846 - | &body,
|
1847 - | "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=",
|
1848 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1849 - | ));
|
1850 - | }
|
1851 - |
|
1852 - | /// A response that contains a sparse map of sets with a null
|
1853 - | /// Test ID: RpcV2CborDeserializesSparseSetMapAndRetainsNull
|
1854 - | #[::tokio::test]
|
1855 - | #[::tracing_test::traced_test]
|
1856 - | async fn rpc_v2_cbor_deserializes_sparse_set_map_and_retains_null_response() {
|
1857 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1858 - | sparse_set_map: ::std::option::Option::Some({
|
1859 - | let mut ret = ::std::collections::HashMap::new();
|
1860 - | ret.insert(
|
1861 - | "x".to_owned(),
|
1862 - | ::std::option::Option::Some(
|
1863 - | vec![].try_into().expect("this is only used in tests"),
|
1864 - | ),
|
1865 - | );
|
1866 - | ret.insert(
|
1867 - | "y".to_owned(),
|
1868 - | ::std::option::Option::Some(
|
1869 - | vec!["a".to_owned(), "b".to_owned()]
|
1870 - | .try_into()
|
1871 - | .expect("this is only used in tests"),
|
1872 - | ),
|
1873 - | );
|
1874 - | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1875 - | ret
|
1876 - | }),
|
1877 - | sparse_struct_map: ::std::option::Option::None,
|
1878 - | sparse_number_map: ::std::option::Option::None,
|
1879 - | sparse_boolean_map: ::std::option::Option::None,
|
1880 - | sparse_string_map: ::std::option::Option::None,
|
1881 - | };
|
1882 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1883 - | let http_response = output.into_response();
|
1884 - | ::pretty_assertions::assert_eq!(
|
1885 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1886 - | http_response.status()
|
1887 - | );
|
1888 - | let expected_headers = [
|
1889 - | ("Content-Type", "application/cbor"),
|
1890 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1891 - | ];
|
1892 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1893 - | http_response.headers(),
|
1894 - | expected_headers,
|
1895 - | ));
|
1896 - | use ::http_body_util::BodyExt;
|
1897 - | let body = http_response
|
1898 - | .into_body()
|
1899 - | .collect()
|
1900 - | .await
|
1901 - | .expect("unable to collect body")
|
1902 - | .to_bytes();
|
1903 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1904 - | &body,
|
1905 - | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=",
|
1906 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1907 - | ));
|
1908 - | }
|
1909 - |
|
1910 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1911 - | /// Test ID: RpcV2CborDeserializesZeroValuesInSparseMaps
|
1912 - | #[::tokio::test]
|
1913 - | #[::tracing_test::traced_test]
|
1914 - | async fn rpc_v2_cbor_deserializes_zero_values_in_sparse_maps_response() {
|
1915 - | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1916 - | sparse_number_map: ::std::option::Option::Some({
|
1917 - | let mut ret = ::std::collections::HashMap::new();
|
1918 - | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1919 - | ret
|
1920 - | }),
|
1921 - | sparse_boolean_map: ::std::option::Option::Some({
|
1922 - | let mut ret = ::std::collections::HashMap::new();
|
1923 - | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
1924 - | ret
|
1925 - | }),
|
1926 - | sparse_struct_map: ::std::option::Option::None,
|
1927 - | sparse_string_map: ::std::option::Option::None,
|
1928 - | sparse_set_map: ::std::option::Option::None,
|
1929 - | };
|
1930 - | use ::aws_smithy_http_server::response::IntoResponse;
|
1931 - | let http_response = output.into_response();
|
1932 - | ::pretty_assertions::assert_eq!(
|
1933 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1934 - | http_response.status()
|
1935 - | );
|
1936 - | let expected_headers = [
|
1937 - | ("Content-Type", "application/cbor"),
|
1938 - | ("smithy-protocol", "rpc-v2-cbor"),
|
1939 - | ];
|
1940 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1941 - | http_response.headers(),
|
1942 - | expected_headers,
|
1943 - | ));
|
1944 - | use ::http_body_util::BodyExt;
|
1945 - | let body = http_response
|
1946 - | .into_body()
|
1947 - | .collect()
|
1948 - | .await
|
1949 - | .expect("unable to collect body")
|
1950 - | .to_bytes();
|
1951 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1952 - | &body,
|
1953 - | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//",
|
1954 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1955 - | ));
|
1956 - | }
|
1957 - | }
|
1958 - |
|
1959 - | ::pin_project_lite::pin_project! {
|
1960 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1961 - | /// [`RpcV2CborDenseMapsInput`](crate::input::RpcV2CborDenseMapsInput) using modelled bindings.
|
1962 - | pub struct RpcV2CborDenseMapsInputFuture {
|
1963 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborDenseMapsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1964 - | }
|
1965 - | }
|
1966 - |
|
1967 - | impl std::future::Future for RpcV2CborDenseMapsInputFuture {
|
1968 - | type Output = Result<
|
1969 - | crate::input::RpcV2CborDenseMapsInput,
|
1970 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1971 - | >;
|
1972 - |
|
1973 - | fn poll(
|
1974 - | self: std::pin::Pin<&mut Self>,
|
1975 - | cx: &mut std::task::Context<'_>,
|
1976 - | ) -> std::task::Poll<Self::Output> {
|
1977 - | let this = self.project();
|
1978 - | this.inner.as_mut().poll(cx)
|
1979 - | }
|
1980 - | }
|
1981 - |
|
1982 - | impl<B>
|
1983 - | ::aws_smithy_http_server::request::FromRequest<
|
1984 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1985 - | B,
|
1986 - | > for crate::input::RpcV2CborDenseMapsInput
|
1987 - | where
|
1988 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1989 - | B: 'static,
|
1990 - |
|
1991 - | B::Data: Send,
|
1992 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1993 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1994 - | {
|
1995 - | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1996 - | type Future = RpcV2CborDenseMapsInputFuture;
|
1997 - |
|
1998 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1999 - | let fut = async move {
|
2000 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
2001 - | request.headers(),
|
2002 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
2003 - | ) {
|
2004 - | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
2005 - | }
|
2006 - | crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::de_rpc_v2_cbor_dense_maps_http_request(request)
|
2007 - | .await
|
2008 - | };
|
2009 - | use ::futures_util::future::TryFutureExt;
|
2010 - | let fut = fut.map_err(
|
2011 - | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
2012 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2013 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
2014 - | e,
|
2015 - | )
|
2016 - | },
|
2017 - | );
|
2018 - | RpcV2CborDenseMapsInputFuture {
|
2019 - | inner: Box::pin(fut),
|
2020 - | }
|
2021 - | }
|
2022 - | }
|
2023 - | impl
|
2024 - | ::aws_smithy_http_server::response::IntoResponse<
|
2025 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2026 - | > for crate::output::RpcV2CborDenseMapsOutput
|
2027 - | {
|
2028 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2029 - | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_response(self) {
|
2030 - | Ok(response) => response,
|
2031 - | Err(e) => {
|
2032 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2033 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2034 - | }
|
2035 - | }
|
2036 - | }
|
2037 - | }
|
2038 - | impl
|
2039 - | ::aws_smithy_http_server::response::IntoResponse<
|
2040 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2041 - | > for crate::error::RpcV2CborDenseMapsError
|
2042 - | {
|
2043 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2044 - | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_error(&self) {
|
2045 - | Ok(mut response) => {
|
2046 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
2047 - | response
|
2048 - | },
|
2049 - | Err(e) => {
|
2050 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2051 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2052 - | }
|
2053 - | }
|
2054 - | }
|
2055 - | }
|
2056 - |
|
2057 - | #[allow(unreachable_code, unused_variables)]
|
2058 - | #[cfg(test)]
|
2059 - | mod rpc_v2_cbor_dense_maps_test {
|
2060 - |
|
2061 - | /// Serializes maps
|
2062 - | /// Test ID: RpcV2CborMaps
|
2063 - | #[::tokio::test]
|
2064 - | #[::tracing_test::traced_test]
|
2065 - | async fn rpc_v2_cbor_maps_request() {
|
2066 - | #[allow(unused_mut)]
|
2067 - | let mut http_request = ::http_1x::Request::builder()
|
2068 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2069 - | .method("POST")
|
2070 - | .header("Accept", "application/cbor")
|
2071 - | .header("Content-Type", "application/cbor")
|
2072 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2073 - | .body(::aws_smithy_http_server::body::boxed(
|
2074 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2075 - | &::aws_smithy_protocol_test::decode_body_data(
|
2076 - | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==".as_bytes(),
|
2077 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1476 + | async fn rpc_v2_cbor_supports_negative_infinity_float_inputs_request() {
|
1477 + | #[allow(unused_mut)]
|
1478 + | let mut http_request = ::http_1x::Request::builder()
|
1479 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1480 + | .method("POST")
|
1481 + | .header("Accept", "application/cbor")
|
1482 + | .header("Content-Type", "application/cbor")
|
1483 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1484 + | .body(::aws_smithy_http_server::body::boxed(
|
1485 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1486 + | &::aws_smithy_protocol_test::decode_body_data(
|
1487 + | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/".as_bytes(),
|
1488 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2078 1489 | ),
|
2079 1490 | )),
|
2080 1491 | ))
|
2081 1492 | .unwrap();
|
2082 1493 | #[allow(unused_mut)]
|
2083 1494 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2084 1495 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2085 1496 | let service = crate::service::RpcV2Protocol::builder::<
|
2086 1497 | ::aws_smithy_http_server::body::BoxBody,
|
2087 1498 | _,
|
2088 1499 | _,
|
2089 1500 | _,
|
2090 1501 | >(config)
|
2091 - | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
1502 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2092 1503 | let sender = sender.clone();
|
2093 1504 | async move {
|
2094 1505 | let result = {
|
2095 - | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2096 - | dense_struct_map: ::std::option::Option::Some({
|
2097 - | let mut ret = ::std::collections::HashMap::new();
|
2098 - | ret.insert(
|
2099 - | "foo".to_owned(),
|
2100 - | crate::model::GreetingStruct {
|
2101 - | hi: ::std::option::Option::Some("there".to_owned()),
|
2102 - | },
|
2103 - | );
|
2104 - | ret.insert(
|
2105 - | "baz".to_owned(),
|
2106 - | crate::model::GreetingStruct {
|
2107 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
2108 - | },
|
2109 - | );
|
2110 - | ret
|
2111 - | }),
|
2112 - | dense_number_map: ::std::option::Option::None,
|
2113 - | dense_boolean_map: ::std::option::Option::None,
|
2114 - | dense_string_map: ::std::option::Option::None,
|
2115 - | dense_set_map: ::std::option::Option::None,
|
1506 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1507 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1508 + | double_value: ::std::option::Option::Some(
|
1509 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1510 + | "-Infinity",
|
1511 + | )
|
1512 + | .expect("invalid string for number"),
|
1513 + | ),
|
1514 + | float_value: ::std::option::Option::Some(
|
1515 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
1516 + | "-Infinity",
|
1517 + | )
|
1518 + | .expect("invalid string for number"),
|
1519 + | ),
|
1520 + | true_boolean_value: ::std::option::Option::None,
|
1521 + | false_boolean_value: ::std::option::Option::None,
|
1522 + | byte_value: ::std::option::Option::None,
|
1523 + | integer_value: ::std::option::Option::None,
|
1524 + | long_value: ::std::option::Option::None,
|
1525 + | short_value: ::std::option::Option::None,
|
1526 + | string_value: ::std::option::Option::None,
|
1527 + | blob_value: ::std::option::Option::None,
|
2116 1528 | };
|
2117 - | ::pretty_assertions::assert_eq!(input, expected);
|
2118 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2119 - | dense_struct_map: ::std::option::Option::None,
|
2120 - | dense_number_map: ::std::option::Option::None,
|
2121 - | dense_boolean_map: ::std::option::Option::None,
|
2122 - | dense_string_map: ::std::option::Option::None,
|
2123 - | dense_set_map: ::std::option::Option::None,
|
1529 + | ::pretty_assertions::assert_eq!(
|
1530 + | input.true_boolean_value,
|
1531 + | expected.true_boolean_value,
|
1532 + | "Unexpected value for `true_boolean_value`"
|
1533 + | );
|
1534 + | ::pretty_assertions::assert_eq!(
|
1535 + | input.false_boolean_value,
|
1536 + | expected.false_boolean_value,
|
1537 + | "Unexpected value for `false_boolean_value`"
|
1538 + | );
|
1539 + | ::pretty_assertions::assert_eq!(
|
1540 + | input.byte_value,
|
1541 + | expected.byte_value,
|
1542 + | "Unexpected value for `byte_value`"
|
1543 + | );
|
1544 + | assert!(
|
1545 + | input.double_value.float_equals(&expected.double_value),
|
1546 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1547 + | expected.double_value,
|
1548 + | input.double_value
|
1549 + | );
|
1550 + | assert!(
|
1551 + | input.float_value.float_equals(&expected.float_value),
|
1552 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1553 + | expected.float_value,
|
1554 + | input.float_value
|
1555 + | );
|
1556 + | ::pretty_assertions::assert_eq!(
|
1557 + | input.integer_value,
|
1558 + | expected.integer_value,
|
1559 + | "Unexpected value for `integer_value`"
|
1560 + | );
|
1561 + | ::pretty_assertions::assert_eq!(
|
1562 + | input.long_value,
|
1563 + | expected.long_value,
|
1564 + | "Unexpected value for `long_value`"
|
1565 + | );
|
1566 + | ::pretty_assertions::assert_eq!(
|
1567 + | input.short_value,
|
1568 + | expected.short_value,
|
1569 + | "Unexpected value for `short_value`"
|
1570 + | );
|
1571 + | ::pretty_assertions::assert_eq!(
|
1572 + | input.string_value,
|
1573 + | expected.string_value,
|
1574 + | "Unexpected value for `string_value`"
|
1575 + | );
|
1576 + | ::pretty_assertions::assert_eq!(
|
1577 + | input.blob_value,
|
1578 + | expected.blob_value,
|
1579 + | "Unexpected value for `blob_value`"
|
1580 + | );
|
1581 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1582 + | true_boolean_value: ::std::option::Option::None,
|
1583 + | false_boolean_value: ::std::option::Option::None,
|
1584 + | byte_value: ::std::option::Option::None,
|
1585 + | double_value: ::std::option::Option::None,
|
1586 + | float_value: ::std::option::Option::None,
|
1587 + | integer_value: ::std::option::Option::None,
|
1588 + | long_value: ::std::option::Option::None,
|
1589 + | short_value: ::std::option::Option::None,
|
1590 + | string_value: ::std::option::Option::None,
|
1591 + | blob_value: ::std::option::Option::None,
|
2124 1592 | };
|
2125 - | Ok(output)
|
1593 + | output
|
2126 1594 | };
|
2127 1595 | sender.send(()).await.expect("receiver dropped early");
|
2128 1596 | result
|
2129 1597 | }
|
2130 1598 | })
|
2131 1599 | .build_unchecked();
|
2132 1600 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2133 1601 | .await
|
2134 1602 | .expect("unable to make an HTTP request");
|
2135 1603 | assert!(
|
2136 1604 | receiver.recv().await.is_some(),
|
2137 1605 | "we expected operation handler to be invoked but it was not entered"
|
2138 1606 | );
|
2139 1607 | }
|
2140 1608 |
|
2141 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
2142 - | /// Test ID: RpcV2CborSerializesZeroValuesInMaps
|
1609 + | /// The server should be capable of deserializing indefinite length text strings.
|
1610 + | /// Test ID: RpcV2CborIndefiniteLengthStringsCanBeDeserialized
|
2143 1611 | #[::tokio::test]
|
2144 1612 | #[::tracing_test::traced_test]
|
2145 - | async fn rpc_v2_cbor_serializes_zero_values_in_maps_request() {
|
1613 + | async fn rpc_v2_cbor_indefinite_length_strings_can_be_deserialized_request() {
|
2146 1614 | #[allow(unused_mut)]
|
2147 - | let mut http_request = ::http_1x::Request::builder()
|
2148 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2149 - | .method("POST")
|
2150 - | .header("Accept", "application/cbor")
|
2151 - | .header("Content-Type", "application/cbor")
|
2152 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2153 - | .body(::aws_smithy_http_server::body::boxed(
|
2154 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2155 - | &::aws_smithy_protocol_test::decode_body_data(
|
2156 - | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==".as_bytes(),
|
2157 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2158 - | ),
|
2159 - | )),
|
2160 - | ))
|
2161 - | .unwrap();
|
1615 + | let mut http_request = ::http_1x::Request::builder()
|
1616 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1617 + | .method("POST")
|
1618 + | .header("Accept", "application/cbor")
|
1619 + | .header("Content-Type", "application/cbor")
|
1620 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1621 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1622 + | ::bytes::Bytes::copy_from_slice(
|
1623 + | &::aws_smithy_protocol_test::decode_body_data("oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1624 + | )
|
1625 + | ))).unwrap();
|
2162 1626 | #[allow(unused_mut)]
|
2163 1627 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2164 1628 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2165 1629 | let service = crate::service::RpcV2Protocol::builder::<
|
2166 1630 | ::aws_smithy_http_server::body::BoxBody,
|
2167 1631 | _,
|
2168 1632 | _,
|
2169 1633 | _,
|
2170 1634 | >(config)
|
2171 - | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
1635 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2172 1636 | let sender = sender.clone();
|
2173 1637 | async move {
|
2174 1638 | let result = {
|
2175 - | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2176 - | dense_number_map: ::std::option::Option::Some({
|
2177 - | let mut ret = ::std::collections::HashMap::new();
|
2178 - | ret.insert("x".to_owned(), 0);
|
2179 - | ret
|
2180 - | }),
|
2181 - | dense_boolean_map: ::std::option::Option::Some({
|
2182 - | let mut ret = ::std::collections::HashMap::new();
|
2183 - | ret.insert("x".to_owned(), false);
|
2184 - | ret
|
2185 - | }),
|
2186 - | dense_struct_map: ::std::option::Option::None,
|
2187 - | dense_string_map: ::std::option::Option::None,
|
2188 - | dense_set_map: ::std::option::Option::None,
|
1639 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1640 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1641 + | string_value: ::std::option::Option::Some(
|
1642 + | "An example indefinite string, chunked on comma".to_owned(),
|
1643 + | ),
|
1644 + | true_boolean_value: ::std::option::Option::None,
|
1645 + | false_boolean_value: ::std::option::Option::None,
|
1646 + | byte_value: ::std::option::Option::None,
|
1647 + | double_value: ::std::option::Option::None,
|
1648 + | float_value: ::std::option::Option::None,
|
1649 + | integer_value: ::std::option::Option::None,
|
1650 + | long_value: ::std::option::Option::None,
|
1651 + | short_value: ::std::option::Option::None,
|
1652 + | blob_value: ::std::option::Option::None,
|
2189 1653 | };
|
2190 - | ::pretty_assertions::assert_eq!(input, expected);
|
2191 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2192 - | dense_struct_map: ::std::option::Option::None,
|
2193 - | dense_number_map: ::std::option::Option::None,
|
2194 - | dense_boolean_map: ::std::option::Option::None,
|
2195 - | dense_string_map: ::std::option::Option::None,
|
2196 - | dense_set_map: ::std::option::Option::None,
|
1654 + | ::pretty_assertions::assert_eq!(
|
1655 + | input.true_boolean_value,
|
1656 + | expected.true_boolean_value,
|
1657 + | "Unexpected value for `true_boolean_value`"
|
1658 + | );
|
1659 + | ::pretty_assertions::assert_eq!(
|
1660 + | input.false_boolean_value,
|
1661 + | expected.false_boolean_value,
|
1662 + | "Unexpected value for `false_boolean_value`"
|
1663 + | );
|
1664 + | ::pretty_assertions::assert_eq!(
|
1665 + | input.byte_value,
|
1666 + | expected.byte_value,
|
1667 + | "Unexpected value for `byte_value`"
|
1668 + | );
|
1669 + | assert!(
|
1670 + | input.double_value.float_equals(&expected.double_value),
|
1671 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1672 + | expected.double_value,
|
1673 + | input.double_value
|
1674 + | );
|
1675 + | assert!(
|
1676 + | input.float_value.float_equals(&expected.float_value),
|
1677 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1678 + | expected.float_value,
|
1679 + | input.float_value
|
1680 + | );
|
1681 + | ::pretty_assertions::assert_eq!(
|
1682 + | input.integer_value,
|
1683 + | expected.integer_value,
|
1684 + | "Unexpected value for `integer_value`"
|
1685 + | );
|
1686 + | ::pretty_assertions::assert_eq!(
|
1687 + | input.long_value,
|
1688 + | expected.long_value,
|
1689 + | "Unexpected value for `long_value`"
|
1690 + | );
|
1691 + | ::pretty_assertions::assert_eq!(
|
1692 + | input.short_value,
|
1693 + | expected.short_value,
|
1694 + | "Unexpected value for `short_value`"
|
1695 + | );
|
1696 + | ::pretty_assertions::assert_eq!(
|
1697 + | input.string_value,
|
1698 + | expected.string_value,
|
1699 + | "Unexpected value for `string_value`"
|
1700 + | );
|
1701 + | ::pretty_assertions::assert_eq!(
|
1702 + | input.blob_value,
|
1703 + | expected.blob_value,
|
1704 + | "Unexpected value for `blob_value`"
|
1705 + | );
|
1706 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1707 + | true_boolean_value: ::std::option::Option::None,
|
1708 + | false_boolean_value: ::std::option::Option::None,
|
1709 + | byte_value: ::std::option::Option::None,
|
1710 + | double_value: ::std::option::Option::None,
|
1711 + | float_value: ::std::option::Option::None,
|
1712 + | integer_value: ::std::option::Option::None,
|
1713 + | long_value: ::std::option::Option::None,
|
1714 + | short_value: ::std::option::Option::None,
|
1715 + | string_value: ::std::option::Option::None,
|
1716 + | blob_value: ::std::option::Option::None,
|
2197 1717 | };
|
2198 - | Ok(output)
|
1718 + | output
|
2199 1719 | };
|
2200 1720 | sender.send(()).await.expect("receiver dropped early");
|
2201 1721 | result
|
2202 1722 | }
|
2203 1723 | })
|
2204 1724 | .build_unchecked();
|
2205 1725 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2206 1726 | .await
|
2207 1727 | .expect("unable to make an HTTP request");
|
2208 1728 | assert!(
|
2209 1729 | receiver.recv().await.is_some(),
|
2210 1730 | "we expected operation handler to be invoked but it was not entered"
|
2211 1731 | );
|
2212 1732 | }
|
2213 1733 |
|
2214 - | /// A request that contains a dense map of sets.
|
2215 - | /// Test ID: RpcV2CborSerializesDenseSetMap
|
1734 + | /// The server should be capable of deserializing indefinite length byte strings.
|
1735 + | /// Test ID: RpcV2CborIndefiniteLengthByteStringsCanBeDeserialized
|
2216 1736 | #[::tokio::test]
|
2217 1737 | #[::tracing_test::traced_test]
|
2218 - | async fn rpc_v2_cbor_serializes_dense_set_map_request() {
|
1738 + | async fn rpc_v2_cbor_indefinite_length_byte_strings_can_be_deserialized_request() {
|
2219 1739 | #[allow(unused_mut)]
|
2220 - | let mut http_request = ::http_1x::Request::builder()
|
2221 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2222 - | .method("POST")
|
2223 - | .header("Accept", "application/cbor")
|
2224 - | .header("Content-Type", "application/cbor")
|
2225 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2226 - | .body(::aws_smithy_http_server::body::boxed(
|
2227 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2228 - | &::aws_smithy_protocol_test::decode_body_data(
|
2229 - | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi".as_bytes(),
|
2230 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2231 - | ),
|
2232 - | )),
|
2233 - | ))
|
2234 - | .unwrap();
|
1740 + | let mut http_request = ::http_1x::Request::builder()
|
1741 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1742 + | .method("POST")
|
1743 + | .header("Accept", "application/cbor")
|
1744 + | .header("Content-Type", "application/cbor")
|
1745 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1746 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1747 + | ::bytes::Bytes::copy_from_slice(
|
1748 + | &::aws_smithy_protocol_test::decode_body_data("oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1749 + | )
|
1750 + | ))).unwrap();
|
2235 1751 | #[allow(unused_mut)]
|
2236 1752 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2237 1753 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2238 1754 | let service = crate::service::RpcV2Protocol::builder::<
|
2239 1755 | ::aws_smithy_http_server::body::BoxBody,
|
2240 1756 | _,
|
2241 1757 | _,
|
2242 1758 | _,
|
2243 1759 | >(config)
|
2244 - | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
1760 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2245 1761 | let sender = sender.clone();
|
2246 1762 | async move {
|
2247 1763 | let result = {
|
2248 - | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2249 - | dense_set_map: ::std::option::Option::Some({
|
2250 - | let mut ret = ::std::collections::HashMap::new();
|
2251 - | ret.insert(
|
2252 - | "x".to_owned(),
|
2253 - | vec![].try_into().expect("this is only used in tests"),
|
2254 - | );
|
2255 - | ret.insert(
|
2256 - | "y".to_owned(),
|
2257 - | vec!["a".to_owned(), "b".to_owned()]
|
2258 - | .try_into()
|
2259 - | .expect("this is only used in tests"),
|
2260 - | );
|
2261 - | ret
|
2262 - | }),
|
2263 - | dense_struct_map: ::std::option::Option::None,
|
2264 - | dense_number_map: ::std::option::Option::None,
|
2265 - | dense_boolean_map: ::std::option::Option::None,
|
2266 - | dense_string_map: ::std::option::Option::None,
|
1764 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1765 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1766 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
1767 + | "An example indefinite-byte string, chunked on comma",
|
1768 + | )),
|
1769 + | true_boolean_value: ::std::option::Option::None,
|
1770 + | false_boolean_value: ::std::option::Option::None,
|
1771 + | byte_value: ::std::option::Option::None,
|
1772 + | double_value: ::std::option::Option::None,
|
1773 + | float_value: ::std::option::Option::None,
|
1774 + | integer_value: ::std::option::Option::None,
|
1775 + | long_value: ::std::option::Option::None,
|
1776 + | short_value: ::std::option::Option::None,
|
1777 + | string_value: ::std::option::Option::None,
|
2267 1778 | };
|
2268 - | ::pretty_assertions::assert_eq!(input, expected);
|
2269 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2270 - | dense_struct_map: ::std::option::Option::None,
|
2271 - | dense_number_map: ::std::option::Option::None,
|
2272 - | dense_boolean_map: ::std::option::Option::None,
|
2273 - | dense_string_map: ::std::option::Option::None,
|
2274 - | dense_set_map: ::std::option::Option::None,
|
1779 + | ::pretty_assertions::assert_eq!(
|
1780 + | input.true_boolean_value,
|
1781 + | expected.true_boolean_value,
|
1782 + | "Unexpected value for `true_boolean_value`"
|
1783 + | );
|
1784 + | ::pretty_assertions::assert_eq!(
|
1785 + | input.false_boolean_value,
|
1786 + | expected.false_boolean_value,
|
1787 + | "Unexpected value for `false_boolean_value`"
|
1788 + | );
|
1789 + | ::pretty_assertions::assert_eq!(
|
1790 + | input.byte_value,
|
1791 + | expected.byte_value,
|
1792 + | "Unexpected value for `byte_value`"
|
1793 + | );
|
1794 + | assert!(
|
1795 + | input.double_value.float_equals(&expected.double_value),
|
1796 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1797 + | expected.double_value,
|
1798 + | input.double_value
|
1799 + | );
|
1800 + | assert!(
|
1801 + | input.float_value.float_equals(&expected.float_value),
|
1802 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1803 + | expected.float_value,
|
1804 + | input.float_value
|
1805 + | );
|
1806 + | ::pretty_assertions::assert_eq!(
|
1807 + | input.integer_value,
|
1808 + | expected.integer_value,
|
1809 + | "Unexpected value for `integer_value`"
|
1810 + | );
|
1811 + | ::pretty_assertions::assert_eq!(
|
1812 + | input.long_value,
|
1813 + | expected.long_value,
|
1814 + | "Unexpected value for `long_value`"
|
1815 + | );
|
1816 + | ::pretty_assertions::assert_eq!(
|
1817 + | input.short_value,
|
1818 + | expected.short_value,
|
1819 + | "Unexpected value for `short_value`"
|
1820 + | );
|
1821 + | ::pretty_assertions::assert_eq!(
|
1822 + | input.string_value,
|
1823 + | expected.string_value,
|
1824 + | "Unexpected value for `string_value`"
|
1825 + | );
|
1826 + | ::pretty_assertions::assert_eq!(
|
1827 + | input.blob_value,
|
1828 + | expected.blob_value,
|
1829 + | "Unexpected value for `blob_value`"
|
1830 + | );
|
1831 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1832 + | true_boolean_value: ::std::option::Option::None,
|
1833 + | false_boolean_value: ::std::option::Option::None,
|
1834 + | byte_value: ::std::option::Option::None,
|
1835 + | double_value: ::std::option::Option::None,
|
1836 + | float_value: ::std::option::Option::None,
|
1837 + | integer_value: ::std::option::Option::None,
|
1838 + | long_value: ::std::option::Option::None,
|
1839 + | short_value: ::std::option::Option::None,
|
1840 + | string_value: ::std::option::Option::None,
|
1841 + | blob_value: ::std::option::Option::None,
|
2275 1842 | };
|
2276 - | Ok(output)
|
1843 + | output
|
2277 1844 | };
|
2278 1845 | sender.send(()).await.expect("receiver dropped early");
|
2279 1846 | result
|
2280 1847 | }
|
2281 1848 | })
|
2282 1849 | .build_unchecked();
|
2283 1850 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2284 1851 | .await
|
2285 1852 | .expect("unable to make an HTTP request");
|
2286 1853 | assert!(
|
2287 1854 | receiver.recv().await.is_some(),
|
2288 1855 | "we expected operation handler to be invoked but it was not entered"
|
2289 1856 | );
|
2290 1857 | }
|
2291 1858 |
|
2292 - | /// Deserializes maps
|
2293 - | /// Test ID: RpcV2CborMaps
|
2294 - | #[::tokio::test]
|
2295 - | #[::tracing_test::traced_test]
|
2296 - | async fn rpc_v2_cbor_maps_response() {
|
2297 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2298 - | dense_struct_map: ::std::option::Option::Some({
|
2299 - | let mut ret = ::std::collections::HashMap::new();
|
2300 - | ret.insert(
|
2301 - | "foo".to_owned(),
|
2302 - | crate::model::GreetingStruct {
|
2303 - | hi: ::std::option::Option::Some("there".to_owned()),
|
2304 - | },
|
2305 - | );
|
2306 - | ret.insert(
|
2307 - | "baz".to_owned(),
|
2308 - | crate::model::GreetingStruct {
|
2309 - | hi: ::std::option::Option::Some("bye".to_owned()),
|
2310 - | },
|
2311 - | );
|
2312 - | ret
|
2313 - | }),
|
2314 - | dense_number_map: ::std::option::Option::None,
|
2315 - | dense_boolean_map: ::std::option::Option::None,
|
2316 - | dense_string_map: ::std::option::Option::None,
|
2317 - | dense_set_map: ::std::option::Option::None,
|
2318 - | };
|
2319 - | use ::aws_smithy_http_server::response::IntoResponse;
|
2320 - | let http_response = output.into_response();
|
2321 - | ::pretty_assertions::assert_eq!(
|
2322 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2323 - | http_response.status()
|
2324 - | );
|
2325 - | let expected_headers = [
|
2326 - | ("Content-Type", "application/cbor"),
|
2327 - | ("smithy-protocol", "rpc-v2-cbor"),
|
2328 - | ];
|
2329 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2330 - | http_response.headers(),
|
2331 - | expected_headers,
|
2332 - | ));
|
2333 - | use ::http_body_util::BodyExt;
|
2334 - | let body = http_response
|
2335 - | .into_body()
|
2336 - | .collect()
|
2337 - | .await
|
2338 - | .expect("unable to collect body")
|
2339 - | .to_bytes();
|
2340 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2341 - | &body,
|
2342 - | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==",
|
2343 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2344 - | ));
|
2345 - | }
|
2346 - |
|
2347 - | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
2348 - | /// Test ID: RpcV2CborDeserializesZeroValuesInMaps
|
2349 - | #[::tokio::test]
|
2350 - | #[::tracing_test::traced_test]
|
2351 - | async fn rpc_v2_cbor_deserializes_zero_values_in_maps_response() {
|
2352 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2353 - | dense_number_map: ::std::option::Option::Some({
|
2354 - | let mut ret = ::std::collections::HashMap::new();
|
2355 - | ret.insert("x".to_owned(), 0);
|
2356 - | ret
|
2357 - | }),
|
2358 - | dense_boolean_map: ::std::option::Option::Some({
|
2359 - | let mut ret = ::std::collections::HashMap::new();
|
2360 - | ret.insert("x".to_owned(), false);
|
2361 - | ret
|
2362 - | }),
|
2363 - | dense_struct_map: ::std::option::Option::None,
|
2364 - | dense_string_map: ::std::option::Option::None,
|
2365 - | dense_set_map: ::std::option::Option::None,
|
2366 - | };
|
2367 - | use ::aws_smithy_http_server::response::IntoResponse;
|
2368 - | let http_response = output.into_response();
|
2369 - | ::pretty_assertions::assert_eq!(
|
2370 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2371 - | http_response.status()
|
2372 - | );
|
2373 - | let expected_headers = [
|
2374 - | ("Content-Type", "application/cbor"),
|
2375 - | ("smithy-protocol", "rpc-v2-cbor"),
|
2376 - | ];
|
2377 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2378 - | http_response.headers(),
|
2379 - | expected_headers,
|
2380 - | ));
|
2381 - | use ::http_body_util::BodyExt;
|
2382 - | let body = http_response
|
2383 - | .into_body()
|
2384 - | .collect()
|
2385 - | .await
|
2386 - | .expect("unable to collect body")
|
2387 - | .to_bytes();
|
2388 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2389 - | &body,
|
2390 - | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==",
|
2391 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2392 - | ));
|
2393 - | }
|
2394 - |
|
2395 - | /// A response that contains a dense map of sets
|
2396 - | /// Test ID: RpcV2CborDeserializesDenseSetMap
|
1859 + | /// Supports upcasting from a smaller byte representation of the same data type.
|
1860 + | /// Test ID: RpcV2CborSupportsUpcastingData
|
2397 1861 | #[::tokio::test]
|
2398 1862 | #[::tracing_test::traced_test]
|
2399 - | async fn rpc_v2_cbor_deserializes_dense_set_map_response() {
|
2400 - | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2401 - | dense_set_map: ::std::option::Option::Some({
|
2402 - | let mut ret = ::std::collections::HashMap::new();
|
2403 - | ret.insert(
|
2404 - | "x".to_owned(),
|
2405 - | vec![].try_into().expect("this is only used in tests"),
|
2406 - | );
|
2407 - | ret.insert(
|
2408 - | "y".to_owned(),
|
2409 - | vec!["a".to_owned(), "b".to_owned()]
|
2410 - | .try_into()
|
2411 - | .expect("this is only used in tests"),
|
2412 - | );
|
2413 - | ret
|
2414 - | }),
|
2415 - | dense_struct_map: ::std::option::Option::None,
|
2416 - | dense_number_map: ::std::option::Option::None,
|
2417 - | dense_boolean_map: ::std::option::Option::None,
|
2418 - | dense_string_map: ::std::option::Option::None,
|
2419 - | };
|
2420 - | use ::aws_smithy_http_server::response::IntoResponse;
|
2421 - | let http_response = output.into_response();
|
2422 - | ::pretty_assertions::assert_eq!(
|
2423 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2424 - | http_response.status()
|
2425 - | );
|
2426 - | let expected_headers = [
|
2427 - | ("Content-Type", "application/cbor"),
|
2428 - | ("smithy-protocol", "rpc-v2-cbor"),
|
2429 - | ];
|
2430 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2431 - | http_response.headers(),
|
2432 - | expected_headers,
|
2433 - | ));
|
2434 - | use ::http_body_util::BodyExt;
|
2435 - | let body = http_response
|
2436 - | .into_body()
|
2437 - | .collect()
|
2438 - | .await
|
2439 - | .expect("unable to collect body")
|
2440 - | .to_bytes();
|
2441 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2442 - | &body,
|
2443 - | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi",
|
2444 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2445 - | ));
|
2446 - | }
|
2447 - | }
|
2448 - |
|
2449 - | ::pin_project_lite::pin_project! {
|
2450 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2451 - | /// [`RpcV2CborListsInput`](crate::input::RpcV2CborListsInput) using modelled bindings.
|
2452 - | pub struct RpcV2CborListsInputFuture {
|
2453 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborListsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2454 - | }
|
2455 - | }
|
2456 - |
|
2457 - | impl std::future::Future for RpcV2CborListsInputFuture {
|
2458 - | type Output = Result<
|
2459 - | crate::input::RpcV2CborListsInput,
|
2460 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
2461 - | >;
|
2462 - |
|
2463 - | fn poll(
|
2464 - | self: std::pin::Pin<&mut Self>,
|
2465 - | cx: &mut std::task::Context<'_>,
|
2466 - | ) -> std::task::Poll<Self::Output> {
|
2467 - | let this = self.project();
|
2468 - | this.inner.as_mut().poll(cx)
|
2469 - | }
|
2470 - | }
|
2471 - |
|
2472 - | impl<B>
|
2473 - | ::aws_smithy_http_server::request::FromRequest<
|
2474 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2475 - | B,
|
2476 - | > for crate::input::RpcV2CborListsInput
|
2477 - | where
|
2478 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
2479 - | B: 'static,
|
2480 - |
|
2481 - | B::Data: Send,
|
2482 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
2483 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
2484 - | {
|
2485 - | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
2486 - | type Future = RpcV2CborListsInputFuture;
|
2487 - |
|
2488 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
2489 - | let fut = async move {
|
2490 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
2491 - | request.headers(),
|
2492 - | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
2493 - | ) {
|
2494 - | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
2495 - | }
|
2496 - | crate::protocol_serde::shape_rpc_v2_cbor_lists::de_rpc_v2_cbor_lists_http_request(
|
2497 - | request,
|
2498 - | )
|
2499 - | .await
|
2500 - | };
|
2501 - | use ::futures_util::future::TryFutureExt;
|
2502 - | let fut = fut.map_err(
|
2503 - | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
2504 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2505 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
2506 - | e,
|
2507 - | )
|
2508 - | },
|
2509 - | );
|
2510 - | RpcV2CborListsInputFuture {
|
2511 - | inner: Box::pin(fut),
|
2512 - | }
|
2513 - | }
|
2514 - | }
|
2515 - | impl
|
2516 - | ::aws_smithy_http_server::response::IntoResponse<
|
2517 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2518 - | > for crate::output::RpcV2CborListsOutput
|
2519 - | {
|
2520 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2521 - | match crate::protocol_serde::shape_rpc_v2_cbor_lists::ser_rpc_v2_cbor_lists_http_response(
|
2522 - | self,
|
2523 - | ) {
|
2524 - | Ok(response) => response,
|
2525 - | Err(e) => {
|
2526 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2527 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2528 - | }
|
2529 - | }
|
2530 - | }
|
2531 - | }
|
2532 - | impl
|
2533 - | ::aws_smithy_http_server::response::IntoResponse<
|
2534 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2535 - | > for crate::error::RpcV2CborListsError
|
2536 - | {
|
2537 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2538 - | match crate::protocol_serde::shape_rpc_v2_cbor_lists::ser_rpc_v2_cbor_lists_http_error(
|
2539 - | &self,
|
2540 - | ) {
|
2541 - | Ok(mut response) => {
|
2542 - | response.extensions_mut().insert(
|
2543 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
2544 - | );
|
2545 - | response
|
2546 - | }
|
2547 - | Err(e) => {
|
2548 - | ::tracing::error!(error = %e, "failed to serialize response");
|
2549 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2550 - | }
|
2551 - | }
|
2552 - | }
|
2553 - | }
|
2554 - |
|
2555 - | #[allow(unreachable_code, unused_variables)]
|
2556 - | #[cfg(test)]
|
2557 - | mod rpc_v2_cbor_lists_test {
|
2558 - |
|
2559 - | /// Serializes RpcV2 Cbor lists
|
2560 - | /// Test ID: RpcV2CborLists
|
2561 - | #[::tokio::test]
|
2562 - | #[::tracing_test::traced_test]
|
2563 - | async fn rpc_v2_cbor_lists_request() {
|
1863 + | async fn rpc_v2_cbor_supports_upcasting_data_request() {
|
2564 1864 | #[allow(unused_mut)]
|
2565 1865 | let mut http_request = ::http_1x::Request::builder()
|
2566 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
1866 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
2567 1867 | .method("POST")
|
2568 1868 | .header("Accept", "application/cbor")
|
2569 1869 | .header("Content-Type", "application/cbor")
|
2570 1870 | .header("smithy-protocol", "rpc-v2-cbor")
|
2571 1871 | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2572 1872 | ::bytes::Bytes::copy_from_slice(
|
2573 - | &::aws_smithy_protocol_test::decode_body_data("v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1873 + | &::aws_smithy_protocol_test::decode_body_data("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2574 1874 | )
|
2575 1875 | ))).unwrap();
|
2576 1876 | #[allow(unused_mut)]
|
2577 1877 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2578 1878 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2579 1879 | let service = crate::service::RpcV2Protocol::builder::<
|
2580 1880 | ::aws_smithy_http_server::body::BoxBody,
|
2581 1881 | _,
|
2582 1882 | _,
|
2583 1883 | _,
|
2584 1884 | >(config)
|
2585 - | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
1885 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2586 1886 | let sender = sender.clone();
|
2587 1887 | async move {
|
2588 1888 | let result = {
|
2589 - | let expected = crate::input::RpcV2CborListsInput {
|
2590 - | string_list: ::std::option::Option::Some(vec![
|
2591 - | "foo".to_owned(),
|
2592 - | "bar".to_owned(),
|
2593 - | ]),
|
2594 - | string_set: ::std::option::Option::Some(
|
2595 - | vec!["foo".to_owned(), "bar".to_owned()]
|
2596 - | .try_into()
|
2597 - | .expect("this is only used in tests"),
|
2598 - | ),
|
2599 - | integer_list: ::std::option::Option::Some(vec![1, 2]),
|
2600 - | boolean_list: ::std::option::Option::Some(vec![true, false]),
|
2601 - | timestamp_list: ::std::option::Option::Some(vec![
|
2602 - | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2603 - | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2604 - | ]),
|
2605 - | enum_list: ::std::option::Option::Some(vec![
|
2606 - | "Foo"
|
2607 - | .parse::<crate::model::FooEnum>()
|
2608 - | .expect("static value validated to member"),
|
2609 - | "0".parse::<crate::model::FooEnum>()
|
2610 - | .expect("static value validated to member"),
|
2611 - | ]),
|
2612 - | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
2613 - | nested_string_list: ::std::option::Option::Some(vec![
|
2614 - | vec!["foo".to_owned(), "bar".to_owned()],
|
2615 - | vec!["baz".to_owned(), "qux".to_owned()],
|
2616 - | ]),
|
2617 - | structure_list: ::std::option::Option::Some(vec![
|
2618 - | crate::model::StructureListMember {
|
2619 - | a: ::std::option::Option::Some("1".to_owned()),
|
2620 - | b: ::std::option::Option::Some("2".to_owned()),
|
2621 - | },
|
2622 - | crate::model::StructureListMember {
|
2623 - | a: ::std::option::Option::Some("3".to_owned()),
|
2624 - | b: ::std::option::Option::Some("4".to_owned()),
|
2625 - | },
|
2626 - | ]),
|
2627 - | blob_list: ::std::option::Option::Some(vec![
|
2628 - | ::aws_smithy_types::Blob::new("foo"),
|
2629 - | ::aws_smithy_types::Blob::new("bar"),
|
2630 - | ]),
|
2631 - | };
|
2632 - | ::pretty_assertions::assert_eq!(input, expected);
|
2633 - | let output = crate::output::RpcV2CborListsOutput {
|
2634 - | string_list: ::std::option::Option::None,
|
2635 - | string_set: ::std::option::Option::None,
|
2636 - | integer_list: ::std::option::Option::None,
|
2637 - | boolean_list: ::std::option::Option::None,
|
2638 - | timestamp_list: ::std::option::Option::None,
|
2639 - | enum_list: ::std::option::Option::None,
|
2640 - | int_enum_list: ::std::option::Option::None,
|
2641 - | nested_string_list: ::std::option::Option::None,
|
2642 - | structure_list: ::std::option::Option::None,
|
2643 - | blob_list: ::std::option::Option::None,
|
1889 + | use ::aws_smithy_protocol_test::FloatEquals;
|
1890 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
1891 + | double_value: ::std::option::Option::Some(1.5_f64),
|
1892 + | float_value: ::std::option::Option::Some(7.625_f32),
|
1893 + | integer_value: ::std::option::Option::Some(56),
|
1894 + | long_value: ::std::option::Option::Some(256),
|
1895 + | short_value: ::std::option::Option::Some(10),
|
1896 + | true_boolean_value: ::std::option::Option::None,
|
1897 + | false_boolean_value: ::std::option::Option::None,
|
1898 + | byte_value: ::std::option::Option::None,
|
1899 + | string_value: ::std::option::Option::None,
|
1900 + | blob_value: ::std::option::Option::None,
|
2644 1901 | };
|
2645 - | Ok(output)
|
2646 - | };
|
2647 - | sender.send(()).await.expect("receiver dropped early");
|
2648 - | result
|
2649 - | }
|
2650 - | })
|
2651 - | .build_unchecked();
|
2652 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2653 - | .await
|
2654 - | .expect("unable to make an HTTP request");
|
2655 - | assert!(
|
2656 - | receiver.recv().await.is_some(),
|
2657 - | "we expected operation handler to be invoked but it was not entered"
|
2658 - | );
|
2659 - | }
|
2660 - |
|
2661 - | /// Serializes empty JSON lists
|
2662 - | /// Test ID: RpcV2CborListsEmpty
|
2663 - | #[::tokio::test]
|
2664 - | #[::tracing_test::traced_test]
|
2665 - | async fn rpc_v2_cbor_lists_empty_request() {
|
2666 - | #[allow(unused_mut)]
|
2667 - | let mut http_request = ::http_1x::Request::builder()
|
2668 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2669 - | .method("POST")
|
2670 - | .header("Accept", "application/cbor")
|
2671 - | .header("Content-Type", "application/cbor")
|
2672 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2673 - | .body(::aws_smithy_http_server::body::boxed(
|
2674 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2675 - | &::aws_smithy_protocol_test::decode_body_data(
|
2676 - | "v2pzdHJpbmdMaXN0n///".as_bytes(),
|
2677 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2678 - | ),
|
2679 - | )),
|
2680 - | ))
|
2681 - | .unwrap();
|
2682 - | #[allow(unused_mut)]
|
2683 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2684 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2685 - | let service = crate::service::RpcV2Protocol::builder::<
|
2686 - | ::aws_smithy_http_server::body::BoxBody,
|
2687 - | _,
|
2688 - | _,
|
2689 - | _,
|
2690 - | >(config)
|
2691 - | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2692 - | let sender = sender.clone();
|
2693 - | async move {
|
2694 - | let result = {
|
2695 - | let expected = crate::input::RpcV2CborListsInput {
|
2696 - | string_list: ::std::option::Option::Some(vec![]),
|
2697 - | string_set: ::std::option::Option::None,
|
2698 - | integer_list: ::std::option::Option::None,
|
2699 - | boolean_list: ::std::option::Option::None,
|
2700 - | timestamp_list: ::std::option::Option::None,
|
2701 - | enum_list: ::std::option::Option::None,
|
2702 - | int_enum_list: ::std::option::Option::None,
|
2703 - | nested_string_list: ::std::option::Option::None,
|
2704 - | structure_list: ::std::option::Option::None,
|
2705 - | blob_list: ::std::option::Option::None,
|
2706 - | };
|
2707 - | ::pretty_assertions::assert_eq!(input, expected);
|
2708 - | let output = crate::output::RpcV2CborListsOutput {
|
2709 - | string_list: ::std::option::Option::None,
|
2710 - | string_set: ::std::option::Option::None,
|
2711 - | integer_list: ::std::option::Option::None,
|
2712 - | boolean_list: ::std::option::Option::None,
|
2713 - | timestamp_list: ::std::option::Option::None,
|
2714 - | enum_list: ::std::option::Option::None,
|
2715 - | int_enum_list: ::std::option::Option::None,
|
2716 - | nested_string_list: ::std::option::Option::None,
|
2717 - | structure_list: ::std::option::Option::None,
|
2718 - | blob_list: ::std::option::Option::None,
|
1902 + | ::pretty_assertions::assert_eq!(
|
1903 + | input.true_boolean_value,
|
1904 + | expected.true_boolean_value,
|
1905 + | "Unexpected value for `true_boolean_value`"
|
1906 + | );
|
1907 + | ::pretty_assertions::assert_eq!(
|
1908 + | input.false_boolean_value,
|
1909 + | expected.false_boolean_value,
|
1910 + | "Unexpected value for `false_boolean_value`"
|
1911 + | );
|
1912 + | ::pretty_assertions::assert_eq!(
|
1913 + | input.byte_value,
|
1914 + | expected.byte_value,
|
1915 + | "Unexpected value for `byte_value`"
|
1916 + | );
|
1917 + | assert!(
|
1918 + | input.double_value.float_equals(&expected.double_value),
|
1919 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
1920 + | expected.double_value,
|
1921 + | input.double_value
|
1922 + | );
|
1923 + | assert!(
|
1924 + | input.float_value.float_equals(&expected.float_value),
|
1925 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
1926 + | expected.float_value,
|
1927 + | input.float_value
|
1928 + | );
|
1929 + | ::pretty_assertions::assert_eq!(
|
1930 + | input.integer_value,
|
1931 + | expected.integer_value,
|
1932 + | "Unexpected value for `integer_value`"
|
1933 + | );
|
1934 + | ::pretty_assertions::assert_eq!(
|
1935 + | input.long_value,
|
1936 + | expected.long_value,
|
1937 + | "Unexpected value for `long_value`"
|
1938 + | );
|
1939 + | ::pretty_assertions::assert_eq!(
|
1940 + | input.short_value,
|
1941 + | expected.short_value,
|
1942 + | "Unexpected value for `short_value`"
|
1943 + | );
|
1944 + | ::pretty_assertions::assert_eq!(
|
1945 + | input.string_value,
|
1946 + | expected.string_value,
|
1947 + | "Unexpected value for `string_value`"
|
1948 + | );
|
1949 + | ::pretty_assertions::assert_eq!(
|
1950 + | input.blob_value,
|
1951 + | expected.blob_value,
|
1952 + | "Unexpected value for `blob_value`"
|
1953 + | );
|
1954 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
1955 + | true_boolean_value: ::std::option::Option::None,
|
1956 + | false_boolean_value: ::std::option::Option::None,
|
1957 + | byte_value: ::std::option::Option::None,
|
1958 + | double_value: ::std::option::Option::None,
|
1959 + | float_value: ::std::option::Option::None,
|
1960 + | integer_value: ::std::option::Option::None,
|
1961 + | long_value: ::std::option::Option::None,
|
1962 + | short_value: ::std::option::Option::None,
|
1963 + | string_value: ::std::option::Option::None,
|
1964 + | blob_value: ::std::option::Option::None,
|
2719 1965 | };
|
2720 - | Ok(output)
|
1966 + | output
|
2721 1967 | };
|
2722 1968 | sender.send(()).await.expect("receiver dropped early");
|
2723 1969 | result
|
2724 1970 | }
|
2725 1971 | })
|
2726 1972 | .build_unchecked();
|
2727 1973 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2728 1974 | .await
|
2729 1975 | .expect("unable to make an HTTP request");
|
2730 1976 | assert!(
|
2731 1977 | receiver.recv().await.is_some(),
|
2732 1978 | "we expected operation handler to be invoked but it was not entered"
|
2733 1979 | );
|
2734 1980 | }
|
2735 1981 |
|
2736 - | /// Serializes empty JSON definite length lists
|
2737 - | /// Test ID: RpcV2CborListsEmptyUsingDefiniteLength
|
1982 + | /// The server should skip over additional fields that are not part of the structure. This allows a
|
1983 + | /// client generated against a newer Smithy model to be able to communicate with a server that is
|
1984 + | /// generated against an older Smithy model.
|
1985 + | /// Test ID: RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByServers
|
2738 1986 | #[::tokio::test]
|
2739 1987 | #[::tracing_test::traced_test]
|
2740 - | async fn rpc_v2_cbor_lists_empty_using_definite_length_request() {
|
1988 + | async fn rpc_v2_cbor_extra_fields_in_the_body_should_be_skipped_by_servers_request() {
|
2741 1989 | #[allow(unused_mut)]
|
2742 - | let mut http_request = ::http_1x::Request::builder()
|
2743 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2744 - | .method("POST")
|
2745 - | .header("Accept", "application/cbor")
|
2746 - | .header("Content-Type", "application/cbor")
|
2747 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2748 - | .body(::aws_smithy_http_server::body::boxed(
|
2749 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2750 - | &::aws_smithy_protocol_test::decode_body_data(
|
2751 - | "oWpzdHJpbmdMaXN0gA==".as_bytes(),
|
2752 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2753 - | ),
|
2754 - | )),
|
2755 - | ))
|
2756 - | .unwrap();
|
1990 + | let mut http_request = ::http_1x::Request::builder()
|
1991 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
1992 + | .method("POST")
|
1993 + | .header("Accept", "application/cbor")
|
1994 + | .header("Content-Type", "application/cbor")
|
1995 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1996 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1997 + | ::bytes::Bytes::copy_from_slice(
|
1998 + | &::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"))
|
1999 + | )
|
2000 + | ))).unwrap();
|
2757 2001 | #[allow(unused_mut)]
|
2758 2002 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2759 2003 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2760 2004 | let service = crate::service::RpcV2Protocol::builder::<
|
2761 2005 | ::aws_smithy_http_server::body::BoxBody,
|
2762 2006 | _,
|
2763 2007 | _,
|
2764 2008 | _,
|
2765 2009 | >(config)
|
2766 - | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2010 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2767 2011 | let sender = sender.clone();
|
2768 2012 | async move {
|
2769 2013 | let result = {
|
2770 - | let expected = crate::input::RpcV2CborListsInput {
|
2771 - | string_list: ::std::option::Option::Some(vec![]),
|
2772 - | string_set: ::std::option::Option::None,
|
2773 - | integer_list: ::std::option::Option::None,
|
2774 - | boolean_list: ::std::option::Option::None,
|
2775 - | timestamp_list: ::std::option::Option::None,
|
2776 - | enum_list: ::std::option::Option::None,
|
2777 - | int_enum_list: ::std::option::Option::None,
|
2778 - | nested_string_list: ::std::option::Option::None,
|
2779 - | structure_list: ::std::option::Option::None,
|
2780 - | blob_list: ::std::option::Option::None,
|
2014 + | use ::aws_smithy_protocol_test::FloatEquals;
|
2015 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
2016 + | byte_value: ::std::option::Option::Some(5),
|
2017 + | double_value: ::std::option::Option::Some(1.889_f64),
|
2018 + | false_boolean_value: ::std::option::Option::Some(false),
|
2019 + | float_value: ::std::option::Option::Some(7.625_f32),
|
2020 + | integer_value: ::std::option::Option::Some(256),
|
2021 + | long_value: ::std::option::Option::Some(9873),
|
2022 + | short_value: ::std::option::Option::Some(9898),
|
2023 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
2024 + | true_boolean_value: ::std::option::Option::Some(true),
|
2025 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
2026 + | "foo",
|
2027 + | )),
|
2781 2028 | };
|
2782 - | ::pretty_assertions::assert_eq!(input, expected);
|
2783 - | let output = crate::output::RpcV2CborListsOutput {
|
2784 - | string_list: ::std::option::Option::None,
|
2785 - | string_set: ::std::option::Option::None,
|
2786 - | integer_list: ::std::option::Option::None,
|
2787 - | boolean_list: ::std::option::Option::None,
|
2788 - | timestamp_list: ::std::option::Option::None,
|
2789 - | enum_list: ::std::option::Option::None,
|
2790 - | int_enum_list: ::std::option::Option::None,
|
2791 - | nested_string_list: ::std::option::Option::None,
|
2792 - | structure_list: ::std::option::Option::None,
|
2793 - | blob_list: ::std::option::Option::None,
|
2029 + | ::pretty_assertions::assert_eq!(
|
2030 + | input.true_boolean_value,
|
2031 + | expected.true_boolean_value,
|
2032 + | "Unexpected value for `true_boolean_value`"
|
2033 + | );
|
2034 + | ::pretty_assertions::assert_eq!(
|
2035 + | input.false_boolean_value,
|
2036 + | expected.false_boolean_value,
|
2037 + | "Unexpected value for `false_boolean_value`"
|
2038 + | );
|
2039 + | ::pretty_assertions::assert_eq!(
|
2040 + | input.byte_value,
|
2041 + | expected.byte_value,
|
2042 + | "Unexpected value for `byte_value`"
|
2043 + | );
|
2044 + | assert!(
|
2045 + | input.double_value.float_equals(&expected.double_value),
|
2046 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
2047 + | expected.double_value,
|
2048 + | input.double_value
|
2049 + | );
|
2050 + | assert!(
|
2051 + | input.float_value.float_equals(&expected.float_value),
|
2052 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
2053 + | expected.float_value,
|
2054 + | input.float_value
|
2055 + | );
|
2056 + | ::pretty_assertions::assert_eq!(
|
2057 + | input.integer_value,
|
2058 + | expected.integer_value,
|
2059 + | "Unexpected value for `integer_value`"
|
2060 + | );
|
2061 + | ::pretty_assertions::assert_eq!(
|
2062 + | input.long_value,
|
2063 + | expected.long_value,
|
2064 + | "Unexpected value for `long_value`"
|
2065 + | );
|
2066 + | ::pretty_assertions::assert_eq!(
|
2067 + | input.short_value,
|
2068 + | expected.short_value,
|
2069 + | "Unexpected value for `short_value`"
|
2070 + | );
|
2071 + | ::pretty_assertions::assert_eq!(
|
2072 + | input.string_value,
|
2073 + | expected.string_value,
|
2074 + | "Unexpected value for `string_value`"
|
2075 + | );
|
2076 + | ::pretty_assertions::assert_eq!(
|
2077 + | input.blob_value,
|
2078 + | expected.blob_value,
|
2079 + | "Unexpected value for `blob_value`"
|
2080 + | );
|
2081 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2082 + | true_boolean_value: ::std::option::Option::None,
|
2083 + | false_boolean_value: ::std::option::Option::None,
|
2084 + | byte_value: ::std::option::Option::None,
|
2085 + | double_value: ::std::option::Option::None,
|
2086 + | float_value: ::std::option::Option::None,
|
2087 + | integer_value: ::std::option::Option::None,
|
2088 + | long_value: ::std::option::Option::None,
|
2089 + | short_value: ::std::option::Option::None,
|
2090 + | string_value: ::std::option::Option::None,
|
2091 + | blob_value: ::std::option::Option::None,
|
2794 2092 | };
|
2795 - | Ok(output)
|
2093 + | output
|
2796 2094 | };
|
2797 2095 | sender.send(()).await.expect("receiver dropped early");
|
2798 2096 | result
|
2799 2097 | }
|
2800 2098 | })
|
2801 2099 | .build_unchecked();
|
2802 2100 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2803 2101 | .await
|
2804 2102 | .expect("unable to make an HTTP request");
|
2805 2103 | assert!(
|
2806 2104 | receiver.recv().await.is_some(),
|
2807 2105 | "we expected operation handler to be invoked but it was not entered"
|
2808 2106 | );
|
2809 2107 | }
|
2810 2108 |
|
2811 - | /// Can deserialize indefinite length text strings inside an indefinite length list
|
2812 - | /// Test ID: RpcV2CborIndefiniteStringInsideIndefiniteList
|
2109 + | /// Servers should tolerate requests without an Accept header set.
|
2110 + | /// Test ID: RpcV2CborServersShouldHandleNoAcceptHeader
|
2813 2111 | #[::tokio::test]
|
2814 2112 | #[::tracing_test::traced_test]
|
2815 - | async fn rpc_v2_cbor_indefinite_string_inside_indefinite_list_request() {
|
2113 + | async fn rpc_v2_cbor_servers_should_handle_no_accept_header_request() {
|
2816 2114 | #[allow(unused_mut)]
|
2817 2115 | let mut http_request = ::http_1x::Request::builder()
|
2818 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2116 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
2819 2117 | .method("POST")
|
2820 - | .header("Accept", "application/cbor")
|
2821 2118 | .header("Content-Type", "application/cbor")
|
2822 2119 | .header("smithy-protocol", "rpc-v2-cbor")
|
2823 2120 | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2824 2121 | ::bytes::Bytes::copy_from_slice(
|
2825 - | &::aws_smithy_protocol_test::decode_body_data("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2122 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2826 2123 | )
|
2827 2124 | ))).unwrap();
|
2828 2125 | #[allow(unused_mut)]
|
2829 2126 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2830 2127 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2831 2128 | let service = crate::service::RpcV2Protocol::builder::<
|
2832 2129 | ::aws_smithy_http_server::body::BoxBody,
|
2833 2130 | _,
|
2834 2131 | _,
|
2835 2132 | _,
|
2836 2133 | >(config)
|
2837 - | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2134 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2838 2135 | let sender = sender.clone();
|
2839 2136 | async move {
|
2840 2137 | let result = {
|
2841 - | let expected = crate::input::RpcV2CborListsInput {
|
2842 - | string_list: ::std::option::Option::Some(vec![
|
2843 - | "An example indefinite string, which will be chunked, on each comma"
|
2844 - | .to_owned(),
|
2845 - | "Another example indefinite string with only one chunk".to_owned(),
|
2846 - | "This is a plain string".to_owned(),
|
2847 - | ]),
|
2848 - | string_set: ::std::option::Option::None,
|
2849 - | integer_list: ::std::option::Option::None,
|
2850 - | boolean_list: ::std::option::Option::None,
|
2851 - | timestamp_list: ::std::option::Option::None,
|
2852 - | enum_list: ::std::option::Option::None,
|
2853 - | int_enum_list: ::std::option::Option::None,
|
2854 - | nested_string_list: ::std::option::Option::None,
|
2855 - | structure_list: ::std::option::Option::None,
|
2856 - | blob_list: ::std::option::Option::None,
|
2857 - | };
|
2858 - | ::pretty_assertions::assert_eq!(input, expected);
|
2859 - | let output = crate::output::RpcV2CborListsOutput {
|
2860 - | string_list: ::std::option::Option::None,
|
2861 - | string_set: ::std::option::Option::None,
|
2862 - | integer_list: ::std::option::Option::None,
|
2863 - | boolean_list: ::std::option::Option::None,
|
2864 - | timestamp_list: ::std::option::Option::None,
|
2865 - | enum_list: ::std::option::Option::None,
|
2866 - | int_enum_list: ::std::option::Option::None,
|
2867 - | nested_string_list: ::std::option::Option::None,
|
2868 - | structure_list: ::std::option::Option::None,
|
2869 - | blob_list: ::std::option::Option::None,
|
2870 - | };
|
2871 - | Ok(output)
|
2872 - | };
|
2873 - | sender.send(()).await.expect("receiver dropped early");
|
2874 - | result
|
2875 - | }
|
2876 - | })
|
2877 - | .build_unchecked();
|
2878 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2879 - | .await
|
2880 - | .expect("unable to make an HTTP request");
|
2881 - | assert!(
|
2882 - | receiver.recv().await.is_some(),
|
2883 - | "we expected operation handler to be invoked but it was not entered"
|
2884 - | );
|
2885 - | }
|
2886 - |
|
2887 - | /// Can deserialize indefinite length text strings inside a definite length list
|
2888 - | /// Test ID: RpcV2CborIndefiniteStringInsideDefiniteList
|
2889 - | #[::tokio::test]
|
2890 - | #[::tracing_test::traced_test]
|
2891 - | async fn rpc_v2_cbor_indefinite_string_inside_definite_list_request() {
|
2892 - | #[allow(unused_mut)]
|
2893 - | let mut http_request = ::http_1x::Request::builder()
|
2894 - | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2895 - | .method("POST")
|
2896 - | .header("Accept", "application/cbor")
|
2897 - | .header("Content-Type", "application/cbor")
|
2898 - | .header("smithy-protocol", "rpc-v2-cbor")
|
2899 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2900 - | ::bytes::Bytes::copy_from_slice(
|
2901 - | &::aws_smithy_protocol_test::decode_body_data("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2902 - | )
|
2903 - | ))).unwrap();
|
2904 - | #[allow(unused_mut)]
|
2905 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2906 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2907 - | let service = crate::service::RpcV2Protocol::builder::<
|
2908 - | ::aws_smithy_http_server::body::BoxBody,
|
2909 - | _,
|
2910 - | _,
|
2911 - | _,
|
2912 - | >(config)
|
2913 - | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2914 - | let sender = sender.clone();
|
2915 - | async move {
|
2916 - | let result = {
|
2917 - | let expected = crate::input::RpcV2CborListsInput {
|
2918 - | string_list: ::std::option::Option::Some(vec![
|
2919 - | "An example indefinite string, which will be chunked, on each comma"
|
2920 - | .to_owned(),
|
2921 - | "Another example indefinite string with only one chunk".to_owned(),
|
2922 - | "This is a plain string".to_owned(),
|
2923 - | ]),
|
2924 - | string_set: ::std::option::Option::None,
|
2925 - | integer_list: ::std::option::Option::None,
|
2926 - | boolean_list: ::std::option::Option::None,
|
2927 - | timestamp_list: ::std::option::Option::None,
|
2928 - | enum_list: ::std::option::Option::None,
|
2929 - | int_enum_list: ::std::option::Option::None,
|
2930 - | nested_string_list: ::std::option::Option::None,
|
2931 - | structure_list: ::std::option::Option::None,
|
2932 - | blob_list: ::std::option::Option::None,
|
2138 + | use ::aws_smithy_protocol_test::FloatEquals;
|
2139 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
2140 + | byte_value: ::std::option::Option::Some(5),
|
2141 + | double_value: ::std::option::Option::Some(1.889_f64),
|
2142 + | false_boolean_value: ::std::option::Option::Some(false),
|
2143 + | float_value: ::std::option::Option::Some(7.625_f32),
|
2144 + | integer_value: ::std::option::Option::Some(256),
|
2145 + | long_value: ::std::option::Option::Some(9873),
|
2146 + | short_value: ::std::option::Option::Some(9898),
|
2147 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
2148 + | true_boolean_value: ::std::option::Option::Some(true),
|
2149 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
2150 + | "foo",
|
2151 + | )),
|
2933 2152 | };
|
2934 - | ::pretty_assertions::assert_eq!(input, expected);
|
2935 - | let output = crate::output::RpcV2CborListsOutput {
|
2936 - | string_list: ::std::option::Option::None,
|
2937 - | string_set: ::std::option::Option::None,
|
2938 - | integer_list: ::std::option::Option::None,
|
2939 - | boolean_list: ::std::option::Option::None,
|
2940 - | timestamp_list: ::std::option::Option::None,
|
2941 - | enum_list: ::std::option::Option::None,
|
2942 - | int_enum_list: ::std::option::Option::None,
|
2943 - | nested_string_list: ::std::option::Option::None,
|
2944 - | structure_list: ::std::option::Option::None,
|
2945 - | blob_list: ::std::option::Option::None,
|
2153 + | ::pretty_assertions::assert_eq!(
|
2154 + | input.true_boolean_value,
|
2155 + | expected.true_boolean_value,
|
2156 + | "Unexpected value for `true_boolean_value`"
|
2157 + | );
|
2158 + | ::pretty_assertions::assert_eq!(
|
2159 + | input.false_boolean_value,
|
2160 + | expected.false_boolean_value,
|
2161 + | "Unexpected value for `false_boolean_value`"
|
2162 + | );
|
2163 + | ::pretty_assertions::assert_eq!(
|
2164 + | input.byte_value,
|
2165 + | expected.byte_value,
|
2166 + | "Unexpected value for `byte_value`"
|
2167 + | );
|
2168 + | assert!(
|
2169 + | input.double_value.float_equals(&expected.double_value),
|
2170 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
2171 + | expected.double_value,
|
2172 + | input.double_value
|
2173 + | );
|
2174 + | assert!(
|
2175 + | input.float_value.float_equals(&expected.float_value),
|
2176 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
2177 + | expected.float_value,
|
2178 + | input.float_value
|
2179 + | );
|
2180 + | ::pretty_assertions::assert_eq!(
|
2181 + | input.integer_value,
|
2182 + | expected.integer_value,
|
2183 + | "Unexpected value for `integer_value`"
|
2184 + | );
|
2185 + | ::pretty_assertions::assert_eq!(
|
2186 + | input.long_value,
|
2187 + | expected.long_value,
|
2188 + | "Unexpected value for `long_value`"
|
2189 + | );
|
2190 + | ::pretty_assertions::assert_eq!(
|
2191 + | input.short_value,
|
2192 + | expected.short_value,
|
2193 + | "Unexpected value for `short_value`"
|
2194 + | );
|
2195 + | ::pretty_assertions::assert_eq!(
|
2196 + | input.string_value,
|
2197 + | expected.string_value,
|
2198 + | "Unexpected value for `string_value`"
|
2199 + | );
|
2200 + | ::pretty_assertions::assert_eq!(
|
2201 + | input.blob_value,
|
2202 + | expected.blob_value,
|
2203 + | "Unexpected value for `blob_value`"
|
2204 + | );
|
2205 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2206 + | true_boolean_value: ::std::option::Option::None,
|
2207 + | false_boolean_value: ::std::option::Option::None,
|
2208 + | byte_value: ::std::option::Option::None,
|
2209 + | double_value: ::std::option::Option::None,
|
2210 + | float_value: ::std::option::Option::None,
|
2211 + | integer_value: ::std::option::Option::None,
|
2212 + | long_value: ::std::option::Option::None,
|
2213 + | short_value: ::std::option::Option::None,
|
2214 + | string_value: ::std::option::Option::None,
|
2215 + | blob_value: ::std::option::Option::None,
|
2946 2216 | };
|
2947 - | Ok(output)
|
2217 + | output
|
2948 2218 | };
|
2949 2219 | sender.send(()).await.expect("receiver dropped early");
|
2950 2220 | result
|
2951 2221 | }
|
2952 2222 | })
|
2953 2223 | .build_unchecked();
|
2954 2224 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2955 2225 | .await
|
2956 2226 | .expect("unable to make an HTTP request");
|
2957 2227 | assert!(
|
2958 2228 | receiver.recv().await.is_some(),
|
2959 2229 | "we expected operation handler to be invoked but it was not entered"
|
2960 2230 | );
|
2961 2231 | }
|
2962 2232 |
|
2963 - | /// Serializes RpcV2 Cbor lists
|
2964 - | /// Test ID: RpcV2CborLists
|
2233 + | /// Serializes simple scalar properties
|
2234 + | /// Test ID: RpcV2CborSimpleScalarProperties
|
2965 2235 | #[::tokio::test]
|
2966 2236 | #[::tracing_test::traced_test]
|
2967 - | async fn rpc_v2_cbor_lists_response() {
|
2968 - | let output = crate::output::RpcV2CborListsOutput {
|
2969 - | string_list: ::std::option::Option::Some(vec!["foo".to_owned(), "bar".to_owned()]),
|
2970 - | string_set: ::std::option::Option::Some(
|
2971 - | vec!["foo".to_owned(), "bar".to_owned()]
|
2972 - | .try_into()
|
2973 - | .expect("this is only used in tests"),
|
2974 - | ),
|
2975 - | integer_list: ::std::option::Option::Some(vec![1, 2]),
|
2976 - | boolean_list: ::std::option::Option::Some(vec![true, false]),
|
2977 - | timestamp_list: ::std::option::Option::Some(vec![
|
2978 - | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2979 - | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2980 - | ]),
|
2981 - | enum_list: ::std::option::Option::Some(vec![
|
2982 - | "Foo"
|
2983 - | .parse::<crate::model::FooEnum>()
|
2984 - | .expect("static value validated to member"),
|
2985 - | "0".parse::<crate::model::FooEnum>()
|
2986 - | .expect("static value validated to member"),
|
2987 - | ]),
|
2988 - | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
2989 - | nested_string_list: ::std::option::Option::Some(vec![
|
2990 - | vec!["foo".to_owned(), "bar".to_owned()],
|
2991 - | vec!["baz".to_owned(), "qux".to_owned()],
|
2992 - | ]),
|
2993 - | structure_list: ::std::option::Option::Some(vec![
|
2994 - | crate::model::StructureListMember {
|
2995 - | a: ::std::option::Option::Some("1".to_owned()),
|
2996 - | b: ::std::option::Option::Some("2".to_owned()),
|
2997 - | },
|
2998 - | crate::model::StructureListMember {
|
2999 - | a: ::std::option::Option::Some("3".to_owned()),
|
3000 - | b: ::std::option::Option::Some("4".to_owned()),
|
3001 - | },
|
3002 - | ]),
|
3003 - | blob_list: ::std::option::Option::Some(vec![
|
3004 - | ::aws_smithy_types::Blob::new("foo"),
|
3005 - | ::aws_smithy_types::Blob::new("bar"),
|
3006 - | ]),
|
2237 + | async fn rpc_v2_cbor_simple_scalar_properties_response() {
|
2238 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2239 + | true_boolean_value: ::std::option::Option::Some(true),
|
2240 + | false_boolean_value: ::std::option::Option::Some(false),
|
2241 + | byte_value: ::std::option::Option::Some(5),
|
2242 + | double_value: ::std::option::Option::Some(1.889_f64),
|
2243 + | float_value: ::std::option::Option::Some(7.625_f32),
|
2244 + | integer_value: ::std::option::Option::Some(256),
|
2245 + | short_value: ::std::option::Option::Some(9898),
|
2246 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
2247 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new("foo")),
|
2248 + | long_value: ::std::option::Option::None,
|
3007 2249 | };
|
3008 2250 | use ::aws_smithy_http_server::response::IntoResponse;
|
3009 2251 | let http_response = output.into_response();
|
3010 2252 | ::pretty_assertions::assert_eq!(
|
3011 2253 | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3012 2254 | http_response.status()
|
3013 2255 | );
|
3014 2256 | let expected_headers = [
|
3015 2257 | ("Content-Type", "application/cbor"),
|
3016 2258 | ("smithy-protocol", "rpc-v2-cbor"),
|
3017 2259 | ];
|
3018 2260 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3019 2261 | http_response.headers(),
|
3020 2262 | expected_headers,
|
3021 2263 | ));
|
3022 2264 | use ::http_body_util::BodyExt;
|
3023 2265 | let body = http_response
|
3024 2266 | .into_body()
|
3025 2267 | .collect()
|
3026 2268 | .await
|
3027 2269 | .expect("unable to collect body")
|
3028 2270 | .to_bytes();
|
3029 2271 | ::aws_smithy_protocol_test::assert_ok(
|
3030 - | ::aws_smithy_protocol_test::validate_body(&body, "v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2272 + | ::aws_smithy_protocol_test::validate_body(&body, "v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3031 2273 | );
|
3032 2274 | }
|
3033 2275 |
|
3034 - | /// Serializes empty RpcV2 Cbor lists
|
3035 - | /// Test ID: RpcV2CborListsEmpty
|
2276 + | /// RpcV2 Cbor should not serialize null structure values
|
2277 + | /// Test ID: RpcV2CborServerDoesntSerializeNullStructureValues
|
3036 2278 | #[::tokio::test]
|
3037 2279 | #[::tracing_test::traced_test]
|
3038 - | async fn rpc_v2_cbor_lists_empty_response() {
|
3039 - | let output = crate::output::RpcV2CborListsOutput {
|
3040 - | string_list: ::std::option::Option::Some(vec![]),
|
3041 - | string_set: ::std::option::Option::None,
|
3042 - | integer_list: ::std::option::Option::None,
|
3043 - | boolean_list: ::std::option::Option::None,
|
3044 - | timestamp_list: ::std::option::Option::None,
|
3045 - | enum_list: ::std::option::Option::None,
|
3046 - | int_enum_list: ::std::option::Option::None,
|
3047 - | nested_string_list: ::std::option::Option::None,
|
3048 - | structure_list: ::std::option::Option::None,
|
3049 - | blob_list: ::std::option::Option::None,
|
3050 - | };
|
3051 - | use ::aws_smithy_http_server::response::IntoResponse;
|
3052 - | let http_response = output.into_response();
|
3053 - | ::pretty_assertions::assert_eq!(
|
3054 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3055 - | http_response.status()
|
2280 + | async fn rpc_v2_cbor_server_doesnt_serialize_null_structure_values_response() {
|
2281 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2282 + | string_value: ::std::option::Option::None,
|
2283 + | true_boolean_value: ::std::option::Option::None,
|
2284 + | false_boolean_value: ::std::option::Option::None,
|
2285 + | byte_value: ::std::option::Option::None,
|
2286 + | double_value: ::std::option::Option::None,
|
2287 + | float_value: ::std::option::Option::None,
|
2288 + | integer_value: ::std::option::Option::None,
|
2289 + | long_value: ::std::option::Option::None,
|
2290 + | short_value: ::std::option::Option::None,
|
2291 + | blob_value: ::std::option::Option::None,
|
2292 + | };
|
2293 + | use ::aws_smithy_http_server::response::IntoResponse;
|
2294 + | let http_response = output.into_response();
|
2295 + | ::pretty_assertions::assert_eq!(
|
2296 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2297 + | http_response.status()
|
3056 2298 | );
|
3057 2299 | let expected_headers = [
|
3058 2300 | ("Content-Type", "application/cbor"),
|
3059 2301 | ("smithy-protocol", "rpc-v2-cbor"),
|
3060 2302 | ];
|
3061 2303 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3062 2304 | http_response.headers(),
|
3063 2305 | expected_headers,
|
3064 2306 | ));
|
3065 2307 | use ::http_body_util::BodyExt;
|
3066 2308 | let body = http_response
|
3067 2309 | .into_body()
|
3068 2310 | .collect()
|
3069 2311 | .await
|
3070 2312 | .expect("unable to collect body")
|
3071 2313 | .to_bytes();
|
3072 2314 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3073 2315 | &body,
|
3074 - | "v2pzdHJpbmdMaXN0n///",
|
2316 + | "v/8=",
|
2317 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2318 + | ));
|
2319 + | }
|
2320 + |
|
2321 + | /// Supports handling NaN float values.
|
2322 + | /// Test ID: RpcV2CborSupportsNaNFloatOutputs
|
2323 + | #[::tokio::test]
|
2324 + | #[::tracing_test::traced_test]
|
2325 + | async fn rpc_v2_cbor_supports_na_n_float_outputs_response() {
|
2326 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2327 + | double_value: ::std::option::Option::Some(
|
2328 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
2329 + | .expect("invalid string for number"),
|
2330 + | ),
|
2331 + | float_value: ::std::option::Option::Some(
|
2332 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
2333 + | .expect("invalid string for number"),
|
2334 + | ),
|
2335 + | true_boolean_value: ::std::option::Option::None,
|
2336 + | false_boolean_value: ::std::option::Option::None,
|
2337 + | byte_value: ::std::option::Option::None,
|
2338 + | integer_value: ::std::option::Option::None,
|
2339 + | long_value: ::std::option::Option::None,
|
2340 + | short_value: ::std::option::Option::None,
|
2341 + | string_value: ::std::option::Option::None,
|
2342 + | blob_value: ::std::option::Option::None,
|
2343 + | };
|
2344 + | use ::aws_smithy_http_server::response::IntoResponse;
|
2345 + | let http_response = output.into_response();
|
2346 + | ::pretty_assertions::assert_eq!(
|
2347 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2348 + | http_response.status()
|
2349 + | );
|
2350 + | let expected_headers = [
|
2351 + | ("Content-Type", "application/cbor"),
|
2352 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2353 + | ];
|
2354 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2355 + | http_response.headers(),
|
2356 + | expected_headers,
|
2357 + | ));
|
2358 + | use ::http_body_util::BodyExt;
|
2359 + | let body = http_response
|
2360 + | .into_body()
|
2361 + | .collect()
|
2362 + | .await
|
2363 + | .expect("unable to collect body")
|
2364 + | .to_bytes();
|
2365 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2366 + | &body,
|
2367 + | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/",
|
2368 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2369 + | ));
|
2370 + | }
|
2371 + |
|
2372 + | /// Supports handling Infinity float values.
|
2373 + | /// Test ID: RpcV2CborSupportsInfinityFloatOutputs
|
2374 + | #[::tokio::test]
|
2375 + | #[::tracing_test::traced_test]
|
2376 + | async fn rpc_v2_cbor_supports_infinity_float_outputs_response() {
|
2377 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2378 + | double_value: ::std::option::Option::Some(
|
2379 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
2380 + | .expect("invalid string for number"),
|
2381 + | ),
|
2382 + | float_value: ::std::option::Option::Some(
|
2383 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
2384 + | .expect("invalid string for number"),
|
2385 + | ),
|
2386 + | true_boolean_value: ::std::option::Option::None,
|
2387 + | false_boolean_value: ::std::option::Option::None,
|
2388 + | byte_value: ::std::option::Option::None,
|
2389 + | integer_value: ::std::option::Option::None,
|
2390 + | long_value: ::std::option::Option::None,
|
2391 + | short_value: ::std::option::Option::None,
|
2392 + | string_value: ::std::option::Option::None,
|
2393 + | blob_value: ::std::option::Option::None,
|
2394 + | };
|
2395 + | use ::aws_smithy_http_server::response::IntoResponse;
|
2396 + | let http_response = output.into_response();
|
2397 + | ::pretty_assertions::assert_eq!(
|
2398 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2399 + | http_response.status()
|
2400 + | );
|
2401 + | let expected_headers = [
|
2402 + | ("Content-Type", "application/cbor"),
|
2403 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2404 + | ];
|
2405 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2406 + | http_response.headers(),
|
2407 + | expected_headers,
|
2408 + | ));
|
2409 + | use ::http_body_util::BodyExt;
|
2410 + | let body = http_response
|
2411 + | .into_body()
|
2412 + | .collect()
|
2413 + | .await
|
2414 + | .expect("unable to collect body")
|
2415 + | .to_bytes();
|
2416 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2417 + | &body,
|
2418 + | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/",
|
2419 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2420 + | ));
|
2421 + | }
|
2422 + |
|
2423 + | /// Supports handling Negative Infinity float values.
|
2424 + | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatOutputs
|
2425 + | #[::tokio::test]
|
2426 + | #[::tracing_test::traced_test]
|
2427 + | async fn rpc_v2_cbor_supports_negative_infinity_float_outputs_response() {
|
2428 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
2429 + | double_value: ::std::option::Option::Some(
|
2430 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
2431 + | .expect("invalid string for number"),
|
2432 + | ),
|
2433 + | float_value: ::std::option::Option::Some(
|
2434 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
2435 + | .expect("invalid string for number"),
|
2436 + | ),
|
2437 + | true_boolean_value: ::std::option::Option::None,
|
2438 + | false_boolean_value: ::std::option::Option::None,
|
2439 + | byte_value: ::std::option::Option::None,
|
2440 + | integer_value: ::std::option::Option::None,
|
2441 + | long_value: ::std::option::Option::None,
|
2442 + | short_value: ::std::option::Option::None,
|
2443 + | string_value: ::std::option::Option::None,
|
2444 + | blob_value: ::std::option::Option::None,
|
2445 + | };
|
2446 + | use ::aws_smithy_http_server::response::IntoResponse;
|
2447 + | let http_response = output.into_response();
|
2448 + | ::pretty_assertions::assert_eq!(
|
2449 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2450 + | http_response.status()
|
2451 + | );
|
2452 + | let expected_headers = [
|
2453 + | ("Content-Type", "application/cbor"),
|
2454 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2455 + | ];
|
2456 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2457 + | http_response.headers(),
|
2458 + | expected_headers,
|
2459 + | ));
|
2460 + | use ::http_body_util::BodyExt;
|
2461 + | let body = http_response
|
2462 + | .into_body()
|
2463 + | .collect()
|
2464 + | .await
|
2465 + | .expect("unable to collect body")
|
2466 + | .to_bytes();
|
2467 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2468 + | &body,
|
2469 + | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/",
|
3075 2470 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3076 2471 | ));
|
3077 2472 | }
|
3078 2473 | }
|
3079 2474 |
|
3080 2475 | ::pin_project_lite::pin_project! {
|
3081 2476 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3082 - | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
3083 - | pub struct SimpleScalarPropertiesInputFuture {
|
3084 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2477 + | /// [`RpcV2CborListsInput`](crate::input::RpcV2CborListsInput) using modelled bindings.
|
2478 + | pub struct RpcV2CborListsInputFuture {
|
2479 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborListsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
3085 2480 | }
|
3086 2481 | }
|
3087 2482 |
|
3088 - | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
2483 + | impl std::future::Future for RpcV2CborListsInputFuture {
|
3089 2484 | type Output = Result<
|
3090 - | crate::input::SimpleScalarPropertiesInput,
|
2485 + | crate::input::RpcV2CborListsInput,
|
3091 2486 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
3092 2487 | >;
|
3093 2488 |
|
3094 2489 | fn poll(
|
3095 2490 | self: std::pin::Pin<&mut Self>,
|
3096 2491 | cx: &mut std::task::Context<'_>,
|
3097 2492 | ) -> std::task::Poll<Self::Output> {
|
3098 2493 | let this = self.project();
|
3099 2494 | this.inner.as_mut().poll(cx)
|
3100 2495 | }
|
3101 2496 | }
|
3102 2497 |
|
3103 2498 | impl<B>
|
3104 2499 | ::aws_smithy_http_server::request::FromRequest<
|
3105 2500 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3106 2501 | B,
|
3107 - | > for crate::input::SimpleScalarPropertiesInput
|
2502 + | > for crate::input::RpcV2CborListsInput
|
3108 2503 | where
|
3109 2504 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
3110 2505 | B: 'static,
|
3111 2506 |
|
3112 2507 | B::Data: Send,
|
3113 2508 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
3114 2509 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
3115 2510 | {
|
3116 2511 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
3117 - | type Future = SimpleScalarPropertiesInputFuture;
|
2512 + | type Future = RpcV2CborListsInputFuture;
|
3118 2513 |
|
3119 2514 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
3120 2515 | let fut = async move {
|
3121 2516 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
3122 2517 | request.headers(),
|
3123 2518 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
3124 2519 | ) {
|
3125 2520 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
3126 2521 | }
|
3127 - | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
3128 - | .await
|
2522 + | crate::protocol_serde::shape_rpc_v2_cbor_lists::de_rpc_v2_cbor_lists_http_request(
|
2523 + | request,
|
2524 + | )
|
2525 + | .await
|
3129 2526 | };
|
3130 2527 | use ::futures_util::future::TryFutureExt;
|
3131 2528 | let fut = fut.map_err(
|
3132 2529 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
3133 2530 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3134 2531 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
3135 2532 | e,
|
3136 2533 | )
|
3137 2534 | },
|
3138 2535 | );
|
3139 - | SimpleScalarPropertiesInputFuture {
|
2536 + | RpcV2CborListsInputFuture {
|
3140 2537 | inner: Box::pin(fut),
|
3141 2538 | }
|
3142 2539 | }
|
3143 2540 | }
|
3144 2541 | impl
|
3145 2542 | ::aws_smithy_http_server::response::IntoResponse<
|
3146 2543 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3147 - | > for crate::output::SimpleScalarPropertiesOutput
|
2544 + | > for crate::output::RpcV2CborListsOutput
|
3148 2545 | {
|
3149 2546 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3150 - | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
3151 - | Ok(response) => response,
|
3152 - | Err(e) => {
|
3153 - | ::tracing::error!(error = %e, "failed to serialize response");
|
3154 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3155 - | }
|
3156 - | }
|
2547 + | match crate::protocol_serde::shape_rpc_v2_cbor_lists::ser_rpc_v2_cbor_lists_http_response(
|
2548 + | self,
|
2549 + | ) {
|
2550 + | Ok(response) => response,
|
2551 + | Err(e) => {
|
2552 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2553 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2554 + | }
|
2555 + | }
|
2556 + | }
|
2557 + | }
|
2558 + | impl
|
2559 + | ::aws_smithy_http_server::response::IntoResponse<
|
2560 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2561 + | > for crate::error::RpcV2CborListsError
|
2562 + | {
|
2563 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2564 + | match crate::protocol_serde::shape_rpc_v2_cbor_lists::ser_rpc_v2_cbor_lists_http_error(
|
2565 + | &self,
|
2566 + | ) {
|
2567 + | Ok(mut response) => {
|
2568 + | response.extensions_mut().insert(
|
2569 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
2570 + | );
|
2571 + | response
|
2572 + | }
|
2573 + | Err(e) => {
|
2574 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2575 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2576 + | }
|
2577 + | }
|
3157 2578 | }
|
3158 2579 | }
|
3159 2580 |
|
3160 2581 | #[allow(unreachable_code, unused_variables)]
|
3161 2582 | #[cfg(test)]
|
3162 - | mod simple_scalar_properties_test {
|
2583 + | mod rpc_v2_cbor_lists_test {
|
3163 2584 |
|
3164 - | /// Serializes simple scalar properties
|
3165 - | /// Test ID: RpcV2CborSimpleScalarProperties
|
2585 + | /// Serializes RpcV2 Cbor lists
|
2586 + | /// Test ID: RpcV2CborLists
|
3166 2587 | #[::tokio::test]
|
3167 2588 | #[::tracing_test::traced_test]
|
3168 - | async fn rpc_v2_cbor_simple_scalar_properties_request() {
|
2589 + | async fn rpc_v2_cbor_lists_request() {
|
3169 2590 | #[allow(unused_mut)]
|
3170 2591 | let mut http_request = ::http_1x::Request::builder()
|
3171 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
2592 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
3172 2593 | .method("POST")
|
3173 2594 | .header("Accept", "application/cbor")
|
3174 2595 | .header("Content-Type", "application/cbor")
|
3175 2596 | .header("smithy-protocol", "rpc-v2-cbor")
|
3176 2597 | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
3177 2598 | ::bytes::Bytes::copy_from_slice(
|
3178 - | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2599 + | &::aws_smithy_protocol_test::decode_body_data("v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3179 2600 | )
|
3180 2601 | ))).unwrap();
|
3181 2602 | #[allow(unused_mut)]
|
3182 2603 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3183 2604 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3184 2605 | let service = crate::service::RpcV2Protocol::builder::<
|
3185 2606 | ::aws_smithy_http_server::body::BoxBody,
|
3186 2607 | _,
|
3187 2608 | _,
|
3188 2609 | _,
|
3189 2610 | >(config)
|
3190 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2611 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
3191 2612 | let sender = sender.clone();
|
3192 2613 | async move {
|
3193 2614 | let result = {
|
3194 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3195 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3196 - | byte_value: ::std::option::Option::Some(5),
|
3197 - | double_value: ::std::option::Option::Some(1.889_f64),
|
3198 - | false_boolean_value: ::std::option::Option::Some(false),
|
3199 - | float_value: ::std::option::Option::Some(7.625_f32),
|
3200 - | integer_value: ::std::option::Option::Some(256),
|
3201 - | long_value: ::std::option::Option::Some(9873),
|
3202 - | short_value: ::std::option::Option::Some(9898),
|
3203 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
3204 - | true_boolean_value: ::std::option::Option::Some(true),
|
3205 - | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
3206 - | "foo",
|
3207 - | )),
|
2615 + | let expected = crate::input::RpcV2CborListsInput {
|
2616 + | string_list: ::std::option::Option::Some(vec![
|
2617 + | "foo".to_owned(),
|
2618 + | "bar".to_owned(),
|
2619 + | ]),
|
2620 + | string_set: ::std::option::Option::Some(
|
2621 + | vec!["foo".to_owned(), "bar".to_owned()]
|
2622 + | .try_into()
|
2623 + | .expect("this is only used in tests"),
|
2624 + | ),
|
2625 + | integer_list: ::std::option::Option::Some(vec![1, 2]),
|
2626 + | boolean_list: ::std::option::Option::Some(vec![true, false]),
|
2627 + | timestamp_list: ::std::option::Option::Some(vec![
|
2628 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2629 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2630 + | ]),
|
2631 + | enum_list: ::std::option::Option::Some(vec![
|
2632 + | "Foo"
|
2633 + | .parse::<crate::model::FooEnum>()
|
2634 + | .expect("static value validated to member"),
|
2635 + | "0".parse::<crate::model::FooEnum>()
|
2636 + | .expect("static value validated to member"),
|
2637 + | ]),
|
2638 + | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
2639 + | nested_string_list: ::std::option::Option::Some(vec![
|
2640 + | vec!["foo".to_owned(), "bar".to_owned()],
|
2641 + | vec!["baz".to_owned(), "qux".to_owned()],
|
2642 + | ]),
|
2643 + | structure_list: ::std::option::Option::Some(vec![
|
2644 + | crate::model::StructureListMember {
|
2645 + | a: ::std::option::Option::Some("1".to_owned()),
|
2646 + | b: ::std::option::Option::Some("2".to_owned()),
|
2647 + | },
|
2648 + | crate::model::StructureListMember {
|
2649 + | a: ::std::option::Option::Some("3".to_owned()),
|
2650 + | b: ::std::option::Option::Some("4".to_owned()),
|
2651 + | },
|
2652 + | ]),
|
2653 + | blob_list: ::std::option::Option::Some(vec![
|
2654 + | ::aws_smithy_types::Blob::new("foo"),
|
2655 + | ::aws_smithy_types::Blob::new("bar"),
|
2656 + | ]),
|
3208 2657 | };
|
3209 - | ::pretty_assertions::assert_eq!(
|
3210 - | input.true_boolean_value,
|
3211 - | expected.true_boolean_value,
|
3212 - | "Unexpected value for `true_boolean_value`"
|
3213 - | );
|
3214 - | ::pretty_assertions::assert_eq!(
|
3215 - | input.false_boolean_value,
|
3216 - | expected.false_boolean_value,
|
3217 - | "Unexpected value for `false_boolean_value`"
|
3218 - | );
|
3219 - | ::pretty_assertions::assert_eq!(
|
3220 - | input.byte_value,
|
3221 - | expected.byte_value,
|
3222 - | "Unexpected value for `byte_value`"
|
3223 - | );
|
3224 - | assert!(
|
3225 - | input.double_value.float_equals(&expected.double_value),
|
3226 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3227 - | expected.double_value,
|
3228 - | input.double_value
|
3229 - | );
|
3230 - | assert!(
|
3231 - | input.float_value.float_equals(&expected.float_value),
|
3232 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3233 - | expected.float_value,
|
3234 - | input.float_value
|
3235 - | );
|
3236 - | ::pretty_assertions::assert_eq!(
|
3237 - | input.integer_value,
|
3238 - | expected.integer_value,
|
3239 - | "Unexpected value for `integer_value`"
|
3240 - | );
|
3241 - | ::pretty_assertions::assert_eq!(
|
3242 - | input.long_value,
|
3243 - | expected.long_value,
|
3244 - | "Unexpected value for `long_value`"
|
3245 - | );
|
3246 - | ::pretty_assertions::assert_eq!(
|
3247 - | input.short_value,
|
3248 - | expected.short_value,
|
3249 - | "Unexpected value for `short_value`"
|
3250 - | );
|
3251 - | ::pretty_assertions::assert_eq!(
|
3252 - | input.string_value,
|
3253 - | expected.string_value,
|
3254 - | "Unexpected value for `string_value`"
|
3255 - | );
|
3256 - | ::pretty_assertions::assert_eq!(
|
3257 - | input.blob_value,
|
3258 - | expected.blob_value,
|
3259 - | "Unexpected value for `blob_value`"
|
3260 - | );
|
3261 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3262 - | true_boolean_value: ::std::option::Option::None,
|
3263 - | false_boolean_value: ::std::option::Option::None,
|
3264 - | byte_value: ::std::option::Option::None,
|
3265 - | double_value: ::std::option::Option::None,
|
3266 - | float_value: ::std::option::Option::None,
|
3267 - | integer_value: ::std::option::Option::None,
|
3268 - | long_value: ::std::option::Option::None,
|
3269 - | short_value: ::std::option::Option::None,
|
3270 - | string_value: ::std::option::Option::None,
|
3271 - | blob_value: ::std::option::Option::None,
|
2658 + | ::pretty_assertions::assert_eq!(input, expected);
|
2659 + | let output = crate::output::RpcV2CborListsOutput {
|
2660 + | string_list: ::std::option::Option::None,
|
2661 + | string_set: ::std::option::Option::None,
|
2662 + | integer_list: ::std::option::Option::None,
|
2663 + | boolean_list: ::std::option::Option::None,
|
2664 + | timestamp_list: ::std::option::Option::None,
|
2665 + | enum_list: ::std::option::Option::None,
|
2666 + | int_enum_list: ::std::option::Option::None,
|
2667 + | nested_string_list: ::std::option::Option::None,
|
2668 + | structure_list: ::std::option::Option::None,
|
2669 + | blob_list: ::std::option::Option::None,
|
3272 2670 | };
|
3273 - | output
|
2671 + | Ok(output)
|
3274 2672 | };
|
3275 2673 | sender.send(()).await.expect("receiver dropped early");
|
3276 2674 | result
|
3277 2675 | }
|
3278 2676 | })
|
3279 2677 | .build_unchecked();
|
3280 2678 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3281 2679 | .await
|
3282 2680 | .expect("unable to make an HTTP request");
|
3283 2681 | assert!(
|
3284 2682 | receiver.recv().await.is_some(),
|
3285 2683 | "we expected operation handler to be invoked but it was not entered"
|
3286 2684 | );
|
3287 2685 | }
|
3288 2686 |
|
3289 - | /// The server should be capable of deserializing simple scalar properties
|
3290 - | /// encoded using a map with a definite length. The server should also be able to parse
|
3291 - | /// a key encoded using an indefinite length string.
|
3292 - | /// Test ID: RpcV2CborSimpleScalarPropertiesUsingIndefiniteLength
|
2687 + | /// Serializes empty JSON lists
|
2688 + | /// Test ID: RpcV2CborListsEmpty
|
3293 2689 | #[::tokio::test]
|
3294 2690 | #[::tracing_test::traced_test]
|
3295 - | async fn rpc_v2_cbor_simple_scalar_properties_using_indefinite_length_request() {
|
2691 + | async fn rpc_v2_cbor_lists_empty_request() {
|
3296 2692 | #[allow(unused_mut)]
|
3297 - | let mut http_request = ::http_1x::Request::builder()
|
3298 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3299 - | .method("POST")
|
3300 - | .header("Accept", "application/cbor")
|
3301 - | .header("Content-Type", "application/cbor")
|
3302 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3303 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
3304 - | ::bytes::Bytes::copy_from_slice(
|
3305 - | &::aws_smithy_protocol_test::decode_body_data("qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA9AAAbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3306 - | )
|
3307 - | ))).unwrap();
|
2693 + | let mut http_request = ::http_1x::Request::builder()
|
2694 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2695 + | .method("POST")
|
2696 + | .header("Accept", "application/cbor")
|
2697 + | .header("Content-Type", "application/cbor")
|
2698 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2699 + | .body(::aws_smithy_http_server::body::boxed(
|
2700 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2701 + | &::aws_smithy_protocol_test::decode_body_data(
|
2702 + | "v2pzdHJpbmdMaXN0n///".as_bytes(),
|
2703 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2704 + | ),
|
2705 + | )),
|
2706 + | ))
|
2707 + | .unwrap();
|
3308 2708 | #[allow(unused_mut)]
|
3309 2709 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3310 2710 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3311 2711 | let service = crate::service::RpcV2Protocol::builder::<
|
3312 2712 | ::aws_smithy_http_server::body::BoxBody,
|
3313 2713 | _,
|
3314 2714 | _,
|
3315 2715 | _,
|
3316 2716 | >(config)
|
3317 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2717 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
3318 2718 | let sender = sender.clone();
|
3319 2719 | async move {
|
3320 2720 | let result = {
|
3321 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3322 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3323 - | byte_value: ::std::option::Option::Some(5),
|
3324 - | double_value: ::std::option::Option::Some(1.889_f64),
|
3325 - | false_boolean_value: ::std::option::Option::Some(false),
|
3326 - | float_value: ::std::option::Option::Some(7.625_f32),
|
3327 - | integer_value: ::std::option::Option::Some(256),
|
3328 - | long_value: ::std::option::Option::Some(9873),
|
3329 - | short_value: ::std::option::Option::Some(9898),
|
3330 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
3331 - | true_boolean_value: ::std::option::Option::Some(true),
|
3332 - | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
3333 - | "foo",
|
3334 - | )),
|
3335 - | };
|
3336 - | ::pretty_assertions::assert_eq!(
|
3337 - | input.true_boolean_value,
|
3338 - | expected.true_boolean_value,
|
3339 - | "Unexpected value for `true_boolean_value`"
|
3340 - | );
|
3341 - | ::pretty_assertions::assert_eq!(
|
3342 - | input.false_boolean_value,
|
3343 - | expected.false_boolean_value,
|
3344 - | "Unexpected value for `false_boolean_value`"
|
3345 - | );
|
3346 - | ::pretty_assertions::assert_eq!(
|
3347 - | input.byte_value,
|
3348 - | expected.byte_value,
|
3349 - | "Unexpected value for `byte_value`"
|
3350 - | );
|
3351 - | assert!(
|
3352 - | input.double_value.float_equals(&expected.double_value),
|
3353 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3354 - | expected.double_value,
|
3355 - | input.double_value
|
3356 - | );
|
3357 - | assert!(
|
3358 - | input.float_value.float_equals(&expected.float_value),
|
3359 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3360 - | expected.float_value,
|
3361 - | input.float_value
|
3362 - | );
|
3363 - | ::pretty_assertions::assert_eq!(
|
3364 - | input.integer_value,
|
3365 - | expected.integer_value,
|
3366 - | "Unexpected value for `integer_value`"
|
3367 - | );
|
3368 - | ::pretty_assertions::assert_eq!(
|
3369 - | input.long_value,
|
3370 - | expected.long_value,
|
3371 - | "Unexpected value for `long_value`"
|
3372 - | );
|
3373 - | ::pretty_assertions::assert_eq!(
|
3374 - | input.short_value,
|
3375 - | expected.short_value,
|
3376 - | "Unexpected value for `short_value`"
|
3377 - | );
|
3378 - | ::pretty_assertions::assert_eq!(
|
3379 - | input.string_value,
|
3380 - | expected.string_value,
|
3381 - | "Unexpected value for `string_value`"
|
3382 - | );
|
3383 - | ::pretty_assertions::assert_eq!(
|
3384 - | input.blob_value,
|
3385 - | expected.blob_value,
|
3386 - | "Unexpected value for `blob_value`"
|
3387 - | );
|
3388 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3389 - | true_boolean_value: ::std::option::Option::None,
|
3390 - | false_boolean_value: ::std::option::Option::None,
|
3391 - | byte_value: ::std::option::Option::None,
|
3392 - | double_value: ::std::option::Option::None,
|
3393 - | float_value: ::std::option::Option::None,
|
3394 - | integer_value: ::std::option::Option::None,
|
3395 - | long_value: ::std::option::Option::None,
|
3396 - | short_value: ::std::option::Option::None,
|
3397 - | string_value: ::std::option::Option::None,
|
3398 - | blob_value: ::std::option::Option::None,
|
2721 + | let expected = crate::input::RpcV2CborListsInput {
|
2722 + | string_list: ::std::option::Option::Some(vec![]),
|
2723 + | string_set: ::std::option::Option::None,
|
2724 + | integer_list: ::std::option::Option::None,
|
2725 + | boolean_list: ::std::option::Option::None,
|
2726 + | timestamp_list: ::std::option::Option::None,
|
2727 + | enum_list: ::std::option::Option::None,
|
2728 + | int_enum_list: ::std::option::Option::None,
|
2729 + | nested_string_list: ::std::option::Option::None,
|
2730 + | structure_list: ::std::option::Option::None,
|
2731 + | blob_list: ::std::option::Option::None,
|
3399 2732 | };
|
3400 - | output
|
3401 - | };
|
3402 - | sender.send(()).await.expect("receiver dropped early");
|
3403 - | result
|
3404 - | }
|
2733 + | ::pretty_assertions::assert_eq!(input, expected);
|
2734 + | let output = crate::output::RpcV2CborListsOutput {
|
2735 + | string_list: ::std::option::Option::None,
|
2736 + | string_set: ::std::option::Option::None,
|
2737 + | integer_list: ::std::option::Option::None,
|
2738 + | boolean_list: ::std::option::Option::None,
|
2739 + | timestamp_list: ::std::option::Option::None,
|
2740 + | enum_list: ::std::option::Option::None,
|
2741 + | int_enum_list: ::std::option::Option::None,
|
2742 + | nested_string_list: ::std::option::Option::None,
|
2743 + | structure_list: ::std::option::Option::None,
|
2744 + | blob_list: ::std::option::Option::None,
|
2745 + | };
|
2746 + | Ok(output)
|
2747 + | };
|
2748 + | sender.send(()).await.expect("receiver dropped early");
|
2749 + | result
|
2750 + | }
|
3405 2751 | })
|
3406 2752 | .build_unchecked();
|
3407 2753 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3408 2754 | .await
|
3409 2755 | .expect("unable to make an HTTP request");
|
3410 2756 | assert!(
|
3411 2757 | receiver.recv().await.is_some(),
|
3412 2758 | "we expected operation handler to be invoked but it was not entered"
|
3413 2759 | );
|
3414 2760 | }
|
3415 2761 |
|
3416 - | /// RpcV2 Cbor should not deserialize null structure values
|
3417 - | /// Test ID: RpcV2CborServerDoesntDeSerializeNullStructureValues
|
2762 + | /// Serializes empty JSON definite length lists
|
2763 + | /// Test ID: RpcV2CborListsEmptyUsingDefiniteLength
|
3418 2764 | #[::tokio::test]
|
3419 2765 | #[::tracing_test::traced_test]
|
3420 - | async fn rpc_v2_cbor_server_doesnt_de_serialize_null_structure_values_request() {
|
2766 + | async fn rpc_v2_cbor_lists_empty_using_definite_length_request() {
|
3421 2767 | #[allow(unused_mut)]
|
3422 2768 | let mut http_request = ::http_1x::Request::builder()
|
3423 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
2769 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
3424 2770 | .method("POST")
|
3425 2771 | .header("Accept", "application/cbor")
|
3426 2772 | .header("Content-Type", "application/cbor")
|
3427 2773 | .header("smithy-protocol", "rpc-v2-cbor")
|
3428 2774 | .body(::aws_smithy_http_server::body::boxed(
|
3429 2775 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3430 2776 | &::aws_smithy_protocol_test::decode_body_data(
|
3431 - | "v2tzdHJpbmdWYWx1Zfb/".as_bytes(),
|
2777 + | "oWpzdHJpbmdMaXN0gA==".as_bytes(),
|
3432 2778 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3433 2779 | ),
|
3434 2780 | )),
|
3435 2781 | ))
|
3436 2782 | .unwrap();
|
3437 2783 | #[allow(unused_mut)]
|
3438 2784 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3439 2785 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3440 2786 | let service = crate::service::RpcV2Protocol::builder::<
|
3441 2787 | ::aws_smithy_http_server::body::BoxBody,
|
3442 2788 | _,
|
3443 2789 | _,
|
3444 2790 | _,
|
3445 2791 | >(config)
|
3446 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2792 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
3447 2793 | let sender = sender.clone();
|
3448 2794 | async move {
|
3449 2795 | let result = {
|
3450 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3451 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3452 - | true_boolean_value: ::std::option::Option::None,
|
3453 - | false_boolean_value: ::std::option::Option::None,
|
3454 - | byte_value: ::std::option::Option::None,
|
3455 - | double_value: ::std::option::Option::None,
|
3456 - | float_value: ::std::option::Option::None,
|
3457 - | integer_value: ::std::option::Option::None,
|
3458 - | long_value: ::std::option::Option::None,
|
3459 - | short_value: ::std::option::Option::None,
|
3460 - | string_value: ::std::option::Option::None,
|
3461 - | blob_value: ::std::option::Option::None,
|
2796 + | let expected = crate::input::RpcV2CborListsInput {
|
2797 + | string_list: ::std::option::Option::Some(vec![]),
|
2798 + | string_set: ::std::option::Option::None,
|
2799 + | integer_list: ::std::option::Option::None,
|
2800 + | boolean_list: ::std::option::Option::None,
|
2801 + | timestamp_list: ::std::option::Option::None,
|
2802 + | enum_list: ::std::option::Option::None,
|
2803 + | int_enum_list: ::std::option::Option::None,
|
2804 + | nested_string_list: ::std::option::Option::None,
|
2805 + | structure_list: ::std::option::Option::None,
|
2806 + | blob_list: ::std::option::Option::None,
|
3462 2807 | };
|
3463 - | ::pretty_assertions::assert_eq!(
|
3464 - | input.true_boolean_value,
|
3465 - | expected.true_boolean_value,
|
3466 - | "Unexpected value for `true_boolean_value`"
|
3467 - | );
|
3468 - | ::pretty_assertions::assert_eq!(
|
3469 - | input.false_boolean_value,
|
3470 - | expected.false_boolean_value,
|
3471 - | "Unexpected value for `false_boolean_value`"
|
3472 - | );
|
3473 - | ::pretty_assertions::assert_eq!(
|
3474 - | input.byte_value,
|
3475 - | expected.byte_value,
|
3476 - | "Unexpected value for `byte_value`"
|
3477 - | );
|
3478 - | assert!(
|
3479 - | input.double_value.float_equals(&expected.double_value),
|
3480 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3481 - | expected.double_value,
|
3482 - | input.double_value
|
3483 - | );
|
3484 - | assert!(
|
3485 - | input.float_value.float_equals(&expected.float_value),
|
3486 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3487 - | expected.float_value,
|
3488 - | input.float_value
|
3489 - | );
|
3490 - | ::pretty_assertions::assert_eq!(
|
3491 - | input.integer_value,
|
3492 - | expected.integer_value,
|
3493 - | "Unexpected value for `integer_value`"
|
3494 - | );
|
3495 - | ::pretty_assertions::assert_eq!(
|
3496 - | input.long_value,
|
3497 - | expected.long_value,
|
3498 - | "Unexpected value for `long_value`"
|
3499 - | );
|
3500 - | ::pretty_assertions::assert_eq!(
|
3501 - | input.short_value,
|
3502 - | expected.short_value,
|
3503 - | "Unexpected value for `short_value`"
|
3504 - | );
|
3505 - | ::pretty_assertions::assert_eq!(
|
3506 - | input.string_value,
|
3507 - | expected.string_value,
|
3508 - | "Unexpected value for `string_value`"
|
3509 - | );
|
3510 - | ::pretty_assertions::assert_eq!(
|
3511 - | input.blob_value,
|
3512 - | expected.blob_value,
|
3513 - | "Unexpected value for `blob_value`"
|
3514 - | );
|
3515 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3516 - | true_boolean_value: ::std::option::Option::None,
|
3517 - | false_boolean_value: ::std::option::Option::None,
|
3518 - | byte_value: ::std::option::Option::None,
|
3519 - | double_value: ::std::option::Option::None,
|
3520 - | float_value: ::std::option::Option::None,
|
3521 - | integer_value: ::std::option::Option::None,
|
3522 - | long_value: ::std::option::Option::None,
|
3523 - | short_value: ::std::option::Option::None,
|
3524 - | string_value: ::std::option::Option::None,
|
3525 - | blob_value: ::std::option::Option::None,
|
2808 + | ::pretty_assertions::assert_eq!(input, expected);
|
2809 + | let output = crate::output::RpcV2CborListsOutput {
|
2810 + | string_list: ::std::option::Option::None,
|
2811 + | string_set: ::std::option::Option::None,
|
2812 + | integer_list: ::std::option::Option::None,
|
2813 + | boolean_list: ::std::option::Option::None,
|
2814 + | timestamp_list: ::std::option::Option::None,
|
2815 + | enum_list: ::std::option::Option::None,
|
2816 + | int_enum_list: ::std::option::Option::None,
|
2817 + | nested_string_list: ::std::option::Option::None,
|
2818 + | structure_list: ::std::option::Option::None,
|
2819 + | blob_list: ::std::option::Option::None,
|
3526 2820 | };
|
3527 - | output
|
2821 + | Ok(output)
|
3528 2822 | };
|
3529 2823 | sender.send(()).await.expect("receiver dropped early");
|
3530 2824 | result
|
3531 2825 | }
|
3532 2826 | })
|
3533 2827 | .build_unchecked();
|
3534 2828 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3535 2829 | .await
|
3536 2830 | .expect("unable to make an HTTP request");
|
3537 2831 | assert!(
|
3538 2832 | receiver.recv().await.is_some(),
|
3539 2833 | "we expected operation handler to be invoked but it was not entered"
|
3540 2834 | );
|
3541 2835 | }
|
3542 2836 |
|
3543 - | /// Supports handling NaN float values.
|
3544 - | /// Test ID: RpcV2CborSupportsNaNFloatInputs
|
2837 + | /// Can deserialize indefinite length text strings inside an indefinite length list
|
2838 + | /// Test ID: RpcV2CborIndefiniteStringInsideIndefiniteList
|
3545 2839 | #[::tokio::test]
|
3546 2840 | #[::tracing_test::traced_test]
|
3547 - | async fn rpc_v2_cbor_supports_na_n_float_inputs_request() {
|
2841 + | async fn rpc_v2_cbor_indefinite_string_inside_indefinite_list_request() {
|
3548 2842 | #[allow(unused_mut)]
|
3549 - | let mut http_request = ::http_1x::Request::builder()
|
3550 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3551 - | .method("POST")
|
3552 - | .header("Accept", "application/cbor")
|
3553 - | .header("Content-Type", "application/cbor")
|
3554 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3555 - | .body(::aws_smithy_http_server::body::boxed(
|
3556 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3557 - | &::aws_smithy_protocol_test::decode_body_data(
|
3558 - | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/".as_bytes(),
|
3559 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3560 - | ),
|
3561 - | )),
|
3562 - | ))
|
3563 - | .unwrap();
|
2843 + | let mut http_request = ::http_1x::Request::builder()
|
2844 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2845 + | .method("POST")
|
2846 + | .header("Accept", "application/cbor")
|
2847 + | .header("Content-Type", "application/cbor")
|
2848 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2849 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2850 + | ::bytes::Bytes::copy_from_slice(
|
2851 + | &::aws_smithy_protocol_test::decode_body_data("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2852 + | )
|
2853 + | ))).unwrap();
|
3564 2854 | #[allow(unused_mut)]
|
3565 2855 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3566 2856 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3567 2857 | let service = crate::service::RpcV2Protocol::builder::<
|
3568 2858 | ::aws_smithy_http_server::body::BoxBody,
|
3569 2859 | _,
|
3570 2860 | _,
|
3571 2861 | _,
|
3572 2862 | >(config)
|
3573 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2863 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
3574 2864 | let sender = sender.clone();
|
3575 2865 | async move {
|
3576 2866 | let result = {
|
3577 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3578 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3579 - | double_value: ::std::option::Option::Some(
|
3580 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3581 - | "NaN",
|
3582 - | )
|
3583 - | .expect("invalid string for number"),
|
3584 - | ),
|
3585 - | float_value: ::std::option::Option::Some(
|
3586 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3587 - | "NaN",
|
3588 - | )
|
3589 - | .expect("invalid string for number"),
|
3590 - | ),
|
3591 - | true_boolean_value: ::std::option::Option::None,
|
3592 - | false_boolean_value: ::std::option::Option::None,
|
3593 - | byte_value: ::std::option::Option::None,
|
3594 - | integer_value: ::std::option::Option::None,
|
3595 - | long_value: ::std::option::Option::None,
|
3596 - | short_value: ::std::option::Option::None,
|
3597 - | string_value: ::std::option::Option::None,
|
3598 - | blob_value: ::std::option::Option::None,
|
2867 + | let expected = crate::input::RpcV2CborListsInput {
|
2868 + | string_list: ::std::option::Option::Some(vec![
|
2869 + | "An example indefinite string, which will be chunked, on each comma"
|
2870 + | .to_owned(),
|
2871 + | "Another example indefinite string with only one chunk".to_owned(),
|
2872 + | "This is a plain string".to_owned(),
|
2873 + | ]),
|
2874 + | string_set: ::std::option::Option::None,
|
2875 + | integer_list: ::std::option::Option::None,
|
2876 + | boolean_list: ::std::option::Option::None,
|
2877 + | timestamp_list: ::std::option::Option::None,
|
2878 + | enum_list: ::std::option::Option::None,
|
2879 + | int_enum_list: ::std::option::Option::None,
|
2880 + | nested_string_list: ::std::option::Option::None,
|
2881 + | structure_list: ::std::option::Option::None,
|
2882 + | blob_list: ::std::option::Option::None,
|
3599 2883 | };
|
3600 - | ::pretty_assertions::assert_eq!(
|
3601 - | input.true_boolean_value,
|
3602 - | expected.true_boolean_value,
|
3603 - | "Unexpected value for `true_boolean_value`"
|
3604 - | );
|
3605 - | ::pretty_assertions::assert_eq!(
|
3606 - | input.false_boolean_value,
|
3607 - | expected.false_boolean_value,
|
3608 - | "Unexpected value for `false_boolean_value`"
|
3609 - | );
|
3610 - | ::pretty_assertions::assert_eq!(
|
3611 - | input.byte_value,
|
3612 - | expected.byte_value,
|
3613 - | "Unexpected value for `byte_value`"
|
3614 - | );
|
3615 - | assert!(
|
3616 - | input.double_value.float_equals(&expected.double_value),
|
3617 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3618 - | expected.double_value,
|
3619 - | input.double_value
|
3620 - | );
|
3621 - | assert!(
|
3622 - | input.float_value.float_equals(&expected.float_value),
|
3623 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3624 - | expected.float_value,
|
3625 - | input.float_value
|
3626 - | );
|
3627 - | ::pretty_assertions::assert_eq!(
|
3628 - | input.integer_value,
|
3629 - | expected.integer_value,
|
3630 - | "Unexpected value for `integer_value`"
|
3631 - | );
|
3632 - | ::pretty_assertions::assert_eq!(
|
3633 - | input.long_value,
|
3634 - | expected.long_value,
|
3635 - | "Unexpected value for `long_value`"
|
3636 - | );
|
3637 - | ::pretty_assertions::assert_eq!(
|
3638 - | input.short_value,
|
3639 - | expected.short_value,
|
3640 - | "Unexpected value for `short_value`"
|
3641 - | );
|
3642 - | ::pretty_assertions::assert_eq!(
|
3643 - | input.string_value,
|
3644 - | expected.string_value,
|
3645 - | "Unexpected value for `string_value`"
|
3646 - | );
|
3647 - | ::pretty_assertions::assert_eq!(
|
3648 - | input.blob_value,
|
3649 - | expected.blob_value,
|
3650 - | "Unexpected value for `blob_value`"
|
3651 - | );
|
3652 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3653 - | true_boolean_value: ::std::option::Option::None,
|
3654 - | false_boolean_value: ::std::option::Option::None,
|
3655 - | byte_value: ::std::option::Option::None,
|
3656 - | double_value: ::std::option::Option::None,
|
3657 - | float_value: ::std::option::Option::None,
|
3658 - | integer_value: ::std::option::Option::None,
|
3659 - | long_value: ::std::option::Option::None,
|
3660 - | short_value: ::std::option::Option::None,
|
3661 - | string_value: ::std::option::Option::None,
|
3662 - | blob_value: ::std::option::Option::None,
|
2884 + | ::pretty_assertions::assert_eq!(input, expected);
|
2885 + | let output = crate::output::RpcV2CborListsOutput {
|
2886 + | string_list: ::std::option::Option::None,
|
2887 + | string_set: ::std::option::Option::None,
|
2888 + | integer_list: ::std::option::Option::None,
|
2889 + | boolean_list: ::std::option::Option::None,
|
2890 + | timestamp_list: ::std::option::Option::None,
|
2891 + | enum_list: ::std::option::Option::None,
|
2892 + | int_enum_list: ::std::option::Option::None,
|
2893 + | nested_string_list: ::std::option::Option::None,
|
2894 + | structure_list: ::std::option::Option::None,
|
2895 + | blob_list: ::std::option::Option::None,
|
3663 2896 | };
|
3664 - | output
|
2897 + | Ok(output)
|
3665 2898 | };
|
3666 2899 | sender.send(()).await.expect("receiver dropped early");
|
3667 2900 | result
|
3668 2901 | }
|
3669 2902 | })
|
3670 2903 | .build_unchecked();
|
3671 2904 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3672 2905 | .await
|
3673 2906 | .expect("unable to make an HTTP request");
|
3674 2907 | assert!(
|
3675 2908 | receiver.recv().await.is_some(),
|
3676 2909 | "we expected operation handler to be invoked but it was not entered"
|
3677 2910 | );
|
3678 2911 | }
|
3679 2912 |
|
3680 - | /// Supports handling Infinity float values.
|
3681 - | /// Test ID: RpcV2CborSupportsInfinityFloatInputs
|
2913 + | /// Can deserialize indefinite length text strings inside a definite length list
|
2914 + | /// Test ID: RpcV2CborIndefiniteStringInsideDefiniteList
|
3682 2915 | #[::tokio::test]
|
3683 2916 | #[::tracing_test::traced_test]
|
3684 - | async fn rpc_v2_cbor_supports_infinity_float_inputs_request() {
|
2917 + | async fn rpc_v2_cbor_indefinite_string_inside_definite_list_request() {
|
3685 2918 | #[allow(unused_mut)]
|
3686 - | let mut http_request = ::http_1x::Request::builder()
|
3687 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3688 - | .method("POST")
|
3689 - | .header("Accept", "application/cbor")
|
3690 - | .header("Content-Type", "application/cbor")
|
3691 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3692 - | .body(::aws_smithy_http_server::body::boxed(
|
3693 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3694 - | &::aws_smithy_protocol_test::decode_body_data(
|
3695 - | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/".as_bytes(),
|
3696 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3697 - | ),
|
3698 - | )),
|
3699 - | ))
|
3700 - | .unwrap();
|
2919 + | let mut http_request = ::http_1x::Request::builder()
|
2920 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2921 + | .method("POST")
|
2922 + | .header("Accept", "application/cbor")
|
2923 + | .header("Content-Type", "application/cbor")
|
2924 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2925 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2926 + | ::bytes::Bytes::copy_from_slice(
|
2927 + | &::aws_smithy_protocol_test::decode_body_data("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2928 + | )
|
2929 + | ))).unwrap();
|
3701 2930 | #[allow(unused_mut)]
|
3702 2931 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3703 2932 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3704 2933 | let service = crate::service::RpcV2Protocol::builder::<
|
3705 2934 | ::aws_smithy_http_server::body::BoxBody,
|
3706 2935 | _,
|
3707 2936 | _,
|
3708 2937 | _,
|
3709 2938 | >(config)
|
3710 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
2939 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
3711 2940 | let sender = sender.clone();
|
3712 2941 | async move {
|
3713 2942 | let result = {
|
3714 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3715 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3716 - | double_value: ::std::option::Option::Some(
|
3717 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3718 - | "Infinity",
|
3719 - | )
|
3720 - | .expect("invalid string for number"),
|
3721 - | ),
|
3722 - | float_value: ::std::option::Option::Some(
|
3723 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3724 - | "Infinity",
|
3725 - | )
|
3726 - | .expect("invalid string for number"),
|
3727 - | ),
|
3728 - | true_boolean_value: ::std::option::Option::None,
|
3729 - | false_boolean_value: ::std::option::Option::None,
|
3730 - | byte_value: ::std::option::Option::None,
|
3731 - | integer_value: ::std::option::Option::None,
|
3732 - | long_value: ::std::option::Option::None,
|
3733 - | short_value: ::std::option::Option::None,
|
3734 - | string_value: ::std::option::Option::None,
|
3735 - | blob_value: ::std::option::Option::None,
|
2943 + | let expected = crate::input::RpcV2CborListsInput {
|
2944 + | string_list: ::std::option::Option::Some(vec![
|
2945 + | "An example indefinite string, which will be chunked, on each comma"
|
2946 + | .to_owned(),
|
2947 + | "Another example indefinite string with only one chunk".to_owned(),
|
2948 + | "This is a plain string".to_owned(),
|
2949 + | ]),
|
2950 + | string_set: ::std::option::Option::None,
|
2951 + | integer_list: ::std::option::Option::None,
|
2952 + | boolean_list: ::std::option::Option::None,
|
2953 + | timestamp_list: ::std::option::Option::None,
|
2954 + | enum_list: ::std::option::Option::None,
|
2955 + | int_enum_list: ::std::option::Option::None,
|
2956 + | nested_string_list: ::std::option::Option::None,
|
2957 + | structure_list: ::std::option::Option::None,
|
2958 + | blob_list: ::std::option::Option::None,
|
3736 2959 | };
|
3737 - | ::pretty_assertions::assert_eq!(
|
3738 - | input.true_boolean_value,
|
3739 - | expected.true_boolean_value,
|
3740 - | "Unexpected value for `true_boolean_value`"
|
3741 - | );
|
3742 - | ::pretty_assertions::assert_eq!(
|
3743 - | input.false_boolean_value,
|
3744 - | expected.false_boolean_value,
|
3745 - | "Unexpected value for `false_boolean_value`"
|
3746 - | );
|
3747 - | ::pretty_assertions::assert_eq!(
|
3748 - | input.byte_value,
|
3749 - | expected.byte_value,
|
3750 - | "Unexpected value for `byte_value`"
|
3751 - | );
|
3752 - | assert!(
|
3753 - | input.double_value.float_equals(&expected.double_value),
|
3754 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3755 - | expected.double_value,
|
3756 - | input.double_value
|
3757 - | );
|
3758 - | assert!(
|
3759 - | input.float_value.float_equals(&expected.float_value),
|
3760 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3761 - | expected.float_value,
|
3762 - | input.float_value
|
3763 - | );
|
3764 - | ::pretty_assertions::assert_eq!(
|
3765 - | input.integer_value,
|
3766 - | expected.integer_value,
|
3767 - | "Unexpected value for `integer_value`"
|
3768 - | );
|
3769 - | ::pretty_assertions::assert_eq!(
|
3770 - | input.long_value,
|
3771 - | expected.long_value,
|
3772 - | "Unexpected value for `long_value`"
|
3773 - | );
|
3774 - | ::pretty_assertions::assert_eq!(
|
3775 - | input.short_value,
|
3776 - | expected.short_value,
|
3777 - | "Unexpected value for `short_value`"
|
3778 - | );
|
3779 - | ::pretty_assertions::assert_eq!(
|
3780 - | input.string_value,
|
3781 - | expected.string_value,
|
3782 - | "Unexpected value for `string_value`"
|
3783 - | );
|
3784 - | ::pretty_assertions::assert_eq!(
|
3785 - | input.blob_value,
|
3786 - | expected.blob_value,
|
3787 - | "Unexpected value for `blob_value`"
|
3788 - | );
|
3789 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3790 - | true_boolean_value: ::std::option::Option::None,
|
3791 - | false_boolean_value: ::std::option::Option::None,
|
3792 - | byte_value: ::std::option::Option::None,
|
3793 - | double_value: ::std::option::Option::None,
|
3794 - | float_value: ::std::option::Option::None,
|
3795 - | integer_value: ::std::option::Option::None,
|
3796 - | long_value: ::std::option::Option::None,
|
3797 - | short_value: ::std::option::Option::None,
|
3798 - | string_value: ::std::option::Option::None,
|
3799 - | blob_value: ::std::option::Option::None,
|
2960 + | ::pretty_assertions::assert_eq!(input, expected);
|
2961 + | let output = crate::output::RpcV2CborListsOutput {
|
2962 + | string_list: ::std::option::Option::None,
|
2963 + | string_set: ::std::option::Option::None,
|
2964 + | integer_list: ::std::option::Option::None,
|
2965 + | boolean_list: ::std::option::Option::None,
|
2966 + | timestamp_list: ::std::option::Option::None,
|
2967 + | enum_list: ::std::option::Option::None,
|
2968 + | int_enum_list: ::std::option::Option::None,
|
2969 + | nested_string_list: ::std::option::Option::None,
|
2970 + | structure_list: ::std::option::Option::None,
|
2971 + | blob_list: ::std::option::Option::None,
|
3800 2972 | };
|
3801 - | output
|
2973 + | Ok(output)
|
3802 2974 | };
|
3803 2975 | sender.send(()).await.expect("receiver dropped early");
|
3804 2976 | result
|
3805 2977 | }
|
3806 2978 | })
|
3807 2979 | .build_unchecked();
|
3808 2980 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3809 2981 | .await
|
3810 2982 | .expect("unable to make an HTTP request");
|
3811 2983 | assert!(
|
3812 2984 | receiver.recv().await.is_some(),
|
3813 2985 | "we expected operation handler to be invoked but it was not entered"
|
3814 2986 | );
|
3815 2987 | }
|
3816 2988 |
|
3817 - | /// Supports handling Infinity float values.
|
3818 - | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatInputs
|
2989 + | /// Serializes RpcV2 Cbor lists
|
2990 + | /// Test ID: RpcV2CborLists
|
3819 2991 | #[::tokio::test]
|
3820 2992 | #[::tracing_test::traced_test]
|
3821 - | async fn rpc_v2_cbor_supports_negative_infinity_float_inputs_request() {
|
3822 - | #[allow(unused_mut)]
|
3823 - | let mut http_request = ::http_1x::Request::builder()
|
3824 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3825 - | .method("POST")
|
3826 - | .header("Accept", "application/cbor")
|
3827 - | .header("Content-Type", "application/cbor")
|
3828 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3829 - | .body(::aws_smithy_http_server::body::boxed(
|
3830 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3831 - | &::aws_smithy_protocol_test::decode_body_data(
|
3832 - | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/".as_bytes(),
|
3833 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3834 - | ),
|
3835 - | )),
|
3836 - | ))
|
3837 - | .unwrap();
|
3838 - | #[allow(unused_mut)]
|
3839 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3840 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3841 - | let service = crate::service::RpcV2Protocol::builder::<
|
3842 - | ::aws_smithy_http_server::body::BoxBody,
|
3843 - | _,
|
3844 - | _,
|
3845 - | _,
|
3846 - | >(config)
|
3847 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3848 - | let sender = sender.clone();
|
3849 - | async move {
|
3850 - | let result = {
|
3851 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3852 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3853 - | double_value: ::std::option::Option::Some(
|
3854 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3855 - | "-Infinity",
|
3856 - | )
|
3857 - | .expect("invalid string for number"),
|
3858 - | ),
|
3859 - | float_value: ::std::option::Option::Some(
|
3860 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3861 - | "-Infinity",
|
3862 - | )
|
3863 - | .expect("invalid string for number"),
|
3864 - | ),
|
3865 - | true_boolean_value: ::std::option::Option::None,
|
3866 - | false_boolean_value: ::std::option::Option::None,
|
3867 - | byte_value: ::std::option::Option::None,
|
3868 - | integer_value: ::std::option::Option::None,
|
3869 - | long_value: ::std::option::Option::None,
|
3870 - | short_value: ::std::option::Option::None,
|
3871 - | string_value: ::std::option::Option::None,
|
3872 - | blob_value: ::std::option::Option::None,
|
3873 - | };
|
3874 - | ::pretty_assertions::assert_eq!(
|
3875 - | input.true_boolean_value,
|
3876 - | expected.true_boolean_value,
|
3877 - | "Unexpected value for `true_boolean_value`"
|
3878 - | );
|
3879 - | ::pretty_assertions::assert_eq!(
|
3880 - | input.false_boolean_value,
|
3881 - | expected.false_boolean_value,
|
3882 - | "Unexpected value for `false_boolean_value`"
|
3883 - | );
|
3884 - | ::pretty_assertions::assert_eq!(
|
3885 - | input.byte_value,
|
3886 - | expected.byte_value,
|
3887 - | "Unexpected value for `byte_value`"
|
3888 - | );
|
3889 - | assert!(
|
3890 - | input.double_value.float_equals(&expected.double_value),
|
3891 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3892 - | expected.double_value,
|
3893 - | input.double_value
|
3894 - | );
|
3895 - | assert!(
|
3896 - | input.float_value.float_equals(&expected.float_value),
|
3897 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3898 - | expected.float_value,
|
3899 - | input.float_value
|
3900 - | );
|
3901 - | ::pretty_assertions::assert_eq!(
|
3902 - | input.integer_value,
|
3903 - | expected.integer_value,
|
3904 - | "Unexpected value for `integer_value`"
|
3905 - | );
|
3906 - | ::pretty_assertions::assert_eq!(
|
3907 - | input.long_value,
|
3908 - | expected.long_value,
|
3909 - | "Unexpected value for `long_value`"
|
3910 - | );
|
3911 - | ::pretty_assertions::assert_eq!(
|
3912 - | input.short_value,
|
3913 - | expected.short_value,
|
3914 - | "Unexpected value for `short_value`"
|
3915 - | );
|
3916 - | ::pretty_assertions::assert_eq!(
|
3917 - | input.string_value,
|
3918 - | expected.string_value,
|
3919 - | "Unexpected value for `string_value`"
|
3920 - | );
|
3921 - | ::pretty_assertions::assert_eq!(
|
3922 - | input.blob_value,
|
3923 - | expected.blob_value,
|
3924 - | "Unexpected value for `blob_value`"
|
3925 - | );
|
3926 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
3927 - | true_boolean_value: ::std::option::Option::None,
|
3928 - | false_boolean_value: ::std::option::Option::None,
|
3929 - | byte_value: ::std::option::Option::None,
|
3930 - | double_value: ::std::option::Option::None,
|
3931 - | float_value: ::std::option::Option::None,
|
3932 - | integer_value: ::std::option::Option::None,
|
3933 - | long_value: ::std::option::Option::None,
|
3934 - | short_value: ::std::option::Option::None,
|
3935 - | string_value: ::std::option::Option::None,
|
3936 - | blob_value: ::std::option::Option::None,
|
3937 - | };
|
3938 - | output
|
3939 - | };
|
3940 - | sender.send(()).await.expect("receiver dropped early");
|
3941 - | result
|
3942 - | }
|
3943 - | })
|
3944 - | .build_unchecked();
|
3945 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3946 - | .await
|
3947 - | .expect("unable to make an HTTP request");
|
3948 - | assert!(
|
3949 - | receiver.recv().await.is_some(),
|
3950 - | "we expected operation handler to be invoked but it was not entered"
|
2993 + | async fn rpc_v2_cbor_lists_response() {
|
2994 + | let output = crate::output::RpcV2CborListsOutput {
|
2995 + | string_list: ::std::option::Option::Some(vec!["foo".to_owned(), "bar".to_owned()]),
|
2996 + | string_set: ::std::option::Option::Some(
|
2997 + | vec!["foo".to_owned(), "bar".to_owned()]
|
2998 + | .try_into()
|
2999 + | .expect("this is only used in tests"),
|
3000 + | ),
|
3001 + | integer_list: ::std::option::Option::Some(vec![1, 2]),
|
3002 + | boolean_list: ::std::option::Option::Some(vec![true, false]),
|
3003 + | timestamp_list: ::std::option::Option::Some(vec![
|
3004 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
3005 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
3006 + | ]),
|
3007 + | enum_list: ::std::option::Option::Some(vec![
|
3008 + | "Foo"
|
3009 + | .parse::<crate::model::FooEnum>()
|
3010 + | .expect("static value validated to member"),
|
3011 + | "0".parse::<crate::model::FooEnum>()
|
3012 + | .expect("static value validated to member"),
|
3013 + | ]),
|
3014 + | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
3015 + | nested_string_list: ::std::option::Option::Some(vec![
|
3016 + | vec!["foo".to_owned(), "bar".to_owned()],
|
3017 + | vec!["baz".to_owned(), "qux".to_owned()],
|
3018 + | ]),
|
3019 + | structure_list: ::std::option::Option::Some(vec![
|
3020 + | crate::model::StructureListMember {
|
3021 + | a: ::std::option::Option::Some("1".to_owned()),
|
3022 + | b: ::std::option::Option::Some("2".to_owned()),
|
3023 + | },
|
3024 + | crate::model::StructureListMember {
|
3025 + | a: ::std::option::Option::Some("3".to_owned()),
|
3026 + | b: ::std::option::Option::Some("4".to_owned()),
|
3027 + | },
|
3028 + | ]),
|
3029 + | blob_list: ::std::option::Option::Some(vec![
|
3030 + | ::aws_smithy_types::Blob::new("foo"),
|
3031 + | ::aws_smithy_types::Blob::new("bar"),
|
3032 + | ]),
|
3033 + | };
|
3034 + | use ::aws_smithy_http_server::response::IntoResponse;
|
3035 + | let http_response = output.into_response();
|
3036 + | ::pretty_assertions::assert_eq!(
|
3037 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3038 + | http_response.status()
|
3951 3039 | );
|
3952 - | }
|
3953 - |
|
3954 - | /// The server should be capable of deserializing indefinite length text strings.
|
3955 - | /// Test ID: RpcV2CborIndefiniteLengthStringsCanBeDeserialized
|
3956 - | #[::tokio::test]
|
3957 - | #[::tracing_test::traced_test]
|
3958 - | async fn rpc_v2_cbor_indefinite_length_strings_can_be_deserialized_request() {
|
3959 - | #[allow(unused_mut)]
|
3960 - | let mut http_request = ::http_1x::Request::builder()
|
3961 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3962 - | .method("POST")
|
3963 - | .header("Accept", "application/cbor")
|
3964 - | .header("Content-Type", "application/cbor")
|
3965 - | .header("smithy-protocol", "rpc-v2-cbor")
|
3966 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
3967 - | ::bytes::Bytes::copy_from_slice(
|
3968 - | &::aws_smithy_protocol_test::decode_body_data("oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3969 - | )
|
3970 - | ))).unwrap();
|
3971 - | #[allow(unused_mut)]
|
3972 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3973 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3974 - | let service = crate::service::RpcV2Protocol::builder::<
|
3975 - | ::aws_smithy_http_server::body::BoxBody,
|
3976 - | _,
|
3977 - | _,
|
3978 - | _,
|
3979 - | >(config)
|
3980 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3981 - | let sender = sender.clone();
|
3982 - | async move {
|
3983 - | let result = {
|
3984 - | use ::aws_smithy_protocol_test::FloatEquals;
|
3985 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
3986 - | string_value: ::std::option::Option::Some(
|
3987 - | "An example indefinite string, chunked on comma".to_owned(),
|
3988 - | ),
|
3989 - | true_boolean_value: ::std::option::Option::None,
|
3990 - | false_boolean_value: ::std::option::Option::None,
|
3991 - | byte_value: ::std::option::Option::None,
|
3992 - | double_value: ::std::option::Option::None,
|
3993 - | float_value: ::std::option::Option::None,
|
3994 - | integer_value: ::std::option::Option::None,
|
3995 - | long_value: ::std::option::Option::None,
|
3996 - | short_value: ::std::option::Option::None,
|
3997 - | blob_value: ::std::option::Option::None,
|
3998 - | };
|
3999 - | ::pretty_assertions::assert_eq!(
|
4000 - | input.true_boolean_value,
|
4001 - | expected.true_boolean_value,
|
4002 - | "Unexpected value for `true_boolean_value`"
|
4003 - | );
|
4004 - | ::pretty_assertions::assert_eq!(
|
4005 - | input.false_boolean_value,
|
4006 - | expected.false_boolean_value,
|
4007 - | "Unexpected value for `false_boolean_value`"
|
4008 - | );
|
4009 - | ::pretty_assertions::assert_eq!(
|
4010 - | input.byte_value,
|
4011 - | expected.byte_value,
|
4012 - | "Unexpected value for `byte_value`"
|
4013 - | );
|
4014 - | assert!(
|
4015 - | input.double_value.float_equals(&expected.double_value),
|
4016 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4017 - | expected.double_value,
|
4018 - | input.double_value
|
4019 - | );
|
4020 - | assert!(
|
4021 - | input.float_value.float_equals(&expected.float_value),
|
4022 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4023 - | expected.float_value,
|
4024 - | input.float_value
|
4025 - | );
|
4026 - | ::pretty_assertions::assert_eq!(
|
4027 - | input.integer_value,
|
4028 - | expected.integer_value,
|
4029 - | "Unexpected value for `integer_value`"
|
4030 - | );
|
4031 - | ::pretty_assertions::assert_eq!(
|
4032 - | input.long_value,
|
4033 - | expected.long_value,
|
4034 - | "Unexpected value for `long_value`"
|
4035 - | );
|
4036 - | ::pretty_assertions::assert_eq!(
|
4037 - | input.short_value,
|
4038 - | expected.short_value,
|
4039 - | "Unexpected value for `short_value`"
|
4040 - | );
|
4041 - | ::pretty_assertions::assert_eq!(
|
4042 - | input.string_value,
|
4043 - | expected.string_value,
|
4044 - | "Unexpected value for `string_value`"
|
4045 - | );
|
4046 - | ::pretty_assertions::assert_eq!(
|
4047 - | input.blob_value,
|
4048 - | expected.blob_value,
|
4049 - | "Unexpected value for `blob_value`"
|
4050 - | );
|
4051 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4052 - | true_boolean_value: ::std::option::Option::None,
|
4053 - | false_boolean_value: ::std::option::Option::None,
|
4054 - | byte_value: ::std::option::Option::None,
|
4055 - | double_value: ::std::option::Option::None,
|
4056 - | float_value: ::std::option::Option::None,
|
4057 - | integer_value: ::std::option::Option::None,
|
4058 - | long_value: ::std::option::Option::None,
|
4059 - | short_value: ::std::option::Option::None,
|
4060 - | string_value: ::std::option::Option::None,
|
4061 - | blob_value: ::std::option::Option::None,
|
4062 - | };
|
4063 - | output
|
4064 - | };
|
4065 - | sender.send(()).await.expect("receiver dropped early");
|
4066 - | result
|
4067 - | }
|
4068 - | })
|
4069 - | .build_unchecked();
|
4070 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3040 + | let expected_headers = [
|
3041 + | ("Content-Type", "application/cbor"),
|
3042 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3043 + | ];
|
3044 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3045 + | http_response.headers(),
|
3046 + | expected_headers,
|
3047 + | ));
|
3048 + | use ::http_body_util::BodyExt;
|
3049 + | let body = http_response
|
3050 + | .into_body()
|
3051 + | .collect()
|
4071 3052 | .await
|
4072 - | .expect("unable to make an HTTP request");
|
4073 - | assert!(
|
4074 - | receiver.recv().await.is_some(),
|
4075 - | "we expected operation handler to be invoked but it was not entered"
|
3053 + | .expect("unable to collect body")
|
3054 + | .to_bytes();
|
3055 + | ::aws_smithy_protocol_test::assert_ok(
|
3056 + | ::aws_smithy_protocol_test::validate_body(&body, "v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w==", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4076 3057 | );
|
4077 3058 | }
|
4078 3059 |
|
4079 - | /// The server should be capable of deserializing indefinite length byte strings.
|
4080 - | /// Test ID: RpcV2CborIndefiniteLengthByteStringsCanBeDeserialized
|
3060 + | /// Serializes empty RpcV2 Cbor lists
|
3061 + | /// Test ID: RpcV2CborListsEmpty
|
4081 3062 | #[::tokio::test]
|
4082 3063 | #[::tracing_test::traced_test]
|
4083 - | async fn rpc_v2_cbor_indefinite_length_byte_strings_can_be_deserialized_request() {
|
4084 - | #[allow(unused_mut)]
|
4085 - | let mut http_request = ::http_1x::Request::builder()
|
4086 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4087 - | .method("POST")
|
4088 - | .header("Accept", "application/cbor")
|
4089 - | .header("Content-Type", "application/cbor")
|
4090 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4091 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
4092 - | ::bytes::Bytes::copy_from_slice(
|
4093 - | &::aws_smithy_protocol_test::decode_body_data("oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4094 - | )
|
4095 - | ))).unwrap();
|
4096 - | #[allow(unused_mut)]
|
4097 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4098 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4099 - | let service = crate::service::RpcV2Protocol::builder::<
|
3064 + | async fn rpc_v2_cbor_lists_empty_response() {
|
3065 + | let output = crate::output::RpcV2CborListsOutput {
|
3066 + | string_list: ::std::option::Option::Some(vec![]),
|
3067 + | string_set: ::std::option::Option::None,
|
3068 + | integer_list: ::std::option::Option::None,
|
3069 + | boolean_list: ::std::option::Option::None,
|
3070 + | timestamp_list: ::std::option::Option::None,
|
3071 + | enum_list: ::std::option::Option::None,
|
3072 + | int_enum_list: ::std::option::Option::None,
|
3073 + | nested_string_list: ::std::option::Option::None,
|
3074 + | structure_list: ::std::option::Option::None,
|
3075 + | blob_list: ::std::option::Option::None,
|
3076 + | };
|
3077 + | use ::aws_smithy_http_server::response::IntoResponse;
|
3078 + | let http_response = output.into_response();
|
3079 + | ::pretty_assertions::assert_eq!(
|
3080 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3081 + | http_response.status()
|
3082 + | );
|
3083 + | let expected_headers = [
|
3084 + | ("Content-Type", "application/cbor"),
|
3085 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3086 + | ];
|
3087 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3088 + | http_response.headers(),
|
3089 + | expected_headers,
|
3090 + | ));
|
3091 + | use ::http_body_util::BodyExt;
|
3092 + | let body = http_response
|
3093 + | .into_body()
|
3094 + | .collect()
|
3095 + | .await
|
3096 + | .expect("unable to collect body")
|
3097 + | .to_bytes();
|
3098 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3099 + | &body,
|
3100 + | "v2pzdHJpbmdMaXN0n///",
|
3101 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3102 + | ));
|
3103 + | }
|
3104 + | }
|
3105 + |
|
3106 + | ::pin_project_lite::pin_project! {
|
3107 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3108 + | /// [`RpcV2CborDenseMapsInput`](crate::input::RpcV2CborDenseMapsInput) using modelled bindings.
|
3109 + | pub struct RpcV2CborDenseMapsInputFuture {
|
3110 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborDenseMapsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
3111 + | }
|
3112 + | }
|
3113 + |
|
3114 + | impl std::future::Future for RpcV2CborDenseMapsInputFuture {
|
3115 + | type Output = Result<
|
3116 + | crate::input::RpcV2CborDenseMapsInput,
|
3117 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
3118 + | >;
|
3119 + |
|
3120 + | fn poll(
|
3121 + | self: std::pin::Pin<&mut Self>,
|
3122 + | cx: &mut std::task::Context<'_>,
|
3123 + | ) -> std::task::Poll<Self::Output> {
|
3124 + | let this = self.project();
|
3125 + | this.inner.as_mut().poll(cx)
|
3126 + | }
|
3127 + | }
|
3128 + |
|
3129 + | impl<B>
|
3130 + | ::aws_smithy_http_server::request::FromRequest<
|
3131 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3132 + | B,
|
3133 + | > for crate::input::RpcV2CborDenseMapsInput
|
3134 + | where
|
3135 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
3136 + | B: 'static,
|
3137 + |
|
3138 + | B::Data: Send,
|
3139 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
3140 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
3141 + | {
|
3142 + | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
3143 + | type Future = RpcV2CborDenseMapsInputFuture;
|
3144 + |
|
3145 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
3146 + | let fut = async move {
|
3147 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
3148 + | request.headers(),
|
3149 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
3150 + | ) {
|
3151 + | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
3152 + | }
|
3153 + | crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::de_rpc_v2_cbor_dense_maps_http_request(request)
|
3154 + | .await
|
3155 + | };
|
3156 + | use ::futures_util::future::TryFutureExt;
|
3157 + | let fut = fut.map_err(
|
3158 + | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
3159 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3160 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
3161 + | e,
|
3162 + | )
|
3163 + | },
|
3164 + | );
|
3165 + | RpcV2CborDenseMapsInputFuture {
|
3166 + | inner: Box::pin(fut),
|
3167 + | }
|
3168 + | }
|
3169 + | }
|
3170 + | impl
|
3171 + | ::aws_smithy_http_server::response::IntoResponse<
|
3172 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3173 + | > for crate::output::RpcV2CborDenseMapsOutput
|
3174 + | {
|
3175 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3176 + | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_response(self) {
|
3177 + | Ok(response) => response,
|
3178 + | Err(e) => {
|
3179 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3180 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3181 + | }
|
3182 + | }
|
3183 + | }
|
3184 + | }
|
3185 + | impl
|
3186 + | ::aws_smithy_http_server::response::IntoResponse<
|
3187 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3188 + | > for crate::error::RpcV2CborDenseMapsError
|
3189 + | {
|
3190 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3191 + | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_error(&self) {
|
3192 + | Ok(mut response) => {
|
3193 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
3194 + | response
|
3195 + | },
|
3196 + | Err(e) => {
|
3197 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3198 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3199 + | }
|
3200 + | }
|
3201 + | }
|
3202 + | }
|
3203 + |
|
3204 + | #[allow(unreachable_code, unused_variables)]
|
3205 + | #[cfg(test)]
|
3206 + | mod rpc_v2_cbor_dense_maps_test {
|
3207 + |
|
3208 + | /// Serializes maps
|
3209 + | /// Test ID: RpcV2CborMaps
|
3210 + | #[::tokio::test]
|
3211 + | #[::tracing_test::traced_test]
|
3212 + | async fn rpc_v2_cbor_maps_request() {
|
3213 + | #[allow(unused_mut)]
|
3214 + | let mut http_request = ::http_1x::Request::builder()
|
3215 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
3216 + | .method("POST")
|
3217 + | .header("Accept", "application/cbor")
|
3218 + | .header("Content-Type", "application/cbor")
|
3219 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3220 + | .body(::aws_smithy_http_server::body::boxed(
|
3221 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3222 + | &::aws_smithy_protocol_test::decode_body_data(
|
3223 + | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==".as_bytes(),
|
3224 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3225 + | ),
|
3226 + | )),
|
3227 + | ))
|
3228 + | .unwrap();
|
3229 + | #[allow(unused_mut)]
|
3230 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3231 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3232 + | let service = crate::service::RpcV2Protocol::builder::<
|
4100 3233 | ::aws_smithy_http_server::body::BoxBody,
|
4101 3234 | _,
|
4102 3235 | _,
|
4103 3236 | _,
|
4104 3237 | >(config)
|
4105 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3238 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
4106 3239 | let sender = sender.clone();
|
4107 3240 | async move {
|
4108 3241 | let result = {
|
4109 - | use ::aws_smithy_protocol_test::FloatEquals;
|
4110 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
4111 - | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
4112 - | "An example indefinite-byte string, chunked on comma",
|
4113 - | )),
|
4114 - | true_boolean_value: ::std::option::Option::None,
|
4115 - | false_boolean_value: ::std::option::Option::None,
|
4116 - | byte_value: ::std::option::Option::None,
|
4117 - | double_value: ::std::option::Option::None,
|
4118 - | float_value: ::std::option::Option::None,
|
4119 - | integer_value: ::std::option::Option::None,
|
4120 - | long_value: ::std::option::Option::None,
|
4121 - | short_value: ::std::option::Option::None,
|
4122 - | string_value: ::std::option::Option::None,
|
3242 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
3243 + | dense_struct_map: ::std::option::Option::Some({
|
3244 + | let mut ret = ::std::collections::HashMap::new();
|
3245 + | ret.insert(
|
3246 + | "foo".to_owned(),
|
3247 + | crate::model::GreetingStruct {
|
3248 + | hi: ::std::option::Option::Some("there".to_owned()),
|
3249 + | },
|
3250 + | );
|
3251 + | ret.insert(
|
3252 + | "baz".to_owned(),
|
3253 + | crate::model::GreetingStruct {
|
3254 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
3255 + | },
|
3256 + | );
|
3257 + | ret
|
3258 + | }),
|
3259 + | dense_number_map: ::std::option::Option::None,
|
3260 + | dense_boolean_map: ::std::option::Option::None,
|
3261 + | dense_string_map: ::std::option::Option::None,
|
3262 + | dense_set_map: ::std::option::Option::None,
|
4123 3263 | };
|
4124 - | ::pretty_assertions::assert_eq!(
|
4125 - | input.true_boolean_value,
|
4126 - | expected.true_boolean_value,
|
4127 - | "Unexpected value for `true_boolean_value`"
|
4128 - | );
|
4129 - | ::pretty_assertions::assert_eq!(
|
4130 - | input.false_boolean_value,
|
4131 - | expected.false_boolean_value,
|
4132 - | "Unexpected value for `false_boolean_value`"
|
4133 - | );
|
4134 - | ::pretty_assertions::assert_eq!(
|
4135 - | input.byte_value,
|
4136 - | expected.byte_value,
|
4137 - | "Unexpected value for `byte_value`"
|
4138 - | );
|
4139 - | assert!(
|
4140 - | input.double_value.float_equals(&expected.double_value),
|
4141 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4142 - | expected.double_value,
|
4143 - | input.double_value
|
4144 - | );
|
4145 - | assert!(
|
4146 - | input.float_value.float_equals(&expected.float_value),
|
4147 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4148 - | expected.float_value,
|
4149 - | input.float_value
|
4150 - | );
|
4151 - | ::pretty_assertions::assert_eq!(
|
4152 - | input.integer_value,
|
4153 - | expected.integer_value,
|
4154 - | "Unexpected value for `integer_value`"
|
4155 - | );
|
4156 - | ::pretty_assertions::assert_eq!(
|
4157 - | input.long_value,
|
4158 - | expected.long_value,
|
4159 - | "Unexpected value for `long_value`"
|
4160 - | );
|
4161 - | ::pretty_assertions::assert_eq!(
|
4162 - | input.short_value,
|
4163 - | expected.short_value,
|
4164 - | "Unexpected value for `short_value`"
|
4165 - | );
|
4166 - | ::pretty_assertions::assert_eq!(
|
4167 - | input.string_value,
|
4168 - | expected.string_value,
|
4169 - | "Unexpected value for `string_value`"
|
4170 - | );
|
4171 - | ::pretty_assertions::assert_eq!(
|
4172 - | input.blob_value,
|
4173 - | expected.blob_value,
|
4174 - | "Unexpected value for `blob_value`"
|
4175 - | );
|
4176 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4177 - | true_boolean_value: ::std::option::Option::None,
|
4178 - | false_boolean_value: ::std::option::Option::None,
|
4179 - | byte_value: ::std::option::Option::None,
|
4180 - | double_value: ::std::option::Option::None,
|
4181 - | float_value: ::std::option::Option::None,
|
4182 - | integer_value: ::std::option::Option::None,
|
4183 - | long_value: ::std::option::Option::None,
|
4184 - | short_value: ::std::option::Option::None,
|
4185 - | string_value: ::std::option::Option::None,
|
4186 - | blob_value: ::std::option::Option::None,
|
3264 + | ::pretty_assertions::assert_eq!(input, expected);
|
3265 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3266 + | dense_struct_map: ::std::option::Option::None,
|
3267 + | dense_number_map: ::std::option::Option::None,
|
3268 + | dense_boolean_map: ::std::option::Option::None,
|
3269 + | dense_string_map: ::std::option::Option::None,
|
3270 + | dense_set_map: ::std::option::Option::None,
|
4187 3271 | };
|
4188 - | output
|
3272 + | Ok(output)
|
4189 3273 | };
|
4190 3274 | sender.send(()).await.expect("receiver dropped early");
|
4191 3275 | result
|
4192 3276 | }
|
4193 3277 | })
|
4194 3278 | .build_unchecked();
|
4195 3279 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4196 3280 | .await
|
4197 3281 | .expect("unable to make an HTTP request");
|
4198 3282 | assert!(
|
4199 3283 | receiver.recv().await.is_some(),
|
4200 3284 | "we expected operation handler to be invoked but it was not entered"
|
4201 3285 | );
|
4202 3286 | }
|
4203 3287 |
|
4204 - | /// Supports upcasting from a smaller byte representation of the same data type.
|
4205 - | /// Test ID: RpcV2CborSupportsUpcastingData
|
3288 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
3289 + | /// Test ID: RpcV2CborSerializesZeroValuesInMaps
|
4206 3290 | #[::tokio::test]
|
4207 3291 | #[::tracing_test::traced_test]
|
4208 - | async fn rpc_v2_cbor_supports_upcasting_data_request() {
|
3292 + | async fn rpc_v2_cbor_serializes_zero_values_in_maps_request() {
|
4209 3293 | #[allow(unused_mut)]
|
4210 - | let mut http_request = ::http_1x::Request::builder()
|
4211 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4212 - | .method("POST")
|
4213 - | .header("Accept", "application/cbor")
|
4214 - | .header("Content-Type", "application/cbor")
|
4215 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4216 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
4217 - | ::bytes::Bytes::copy_from_slice(
|
4218 - | &::aws_smithy_protocol_test::decode_body_data("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4219 - | )
|
4220 - | ))).unwrap();
|
3294 + | let mut http_request = ::http_1x::Request::builder()
|
3295 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
3296 + | .method("POST")
|
3297 + | .header("Accept", "application/cbor")
|
3298 + | .header("Content-Type", "application/cbor")
|
3299 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3300 + | .body(::aws_smithy_http_server::body::boxed(
|
3301 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3302 + | &::aws_smithy_protocol_test::decode_body_data(
|
3303 + | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==".as_bytes(),
|
3304 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3305 + | ),
|
3306 + | )),
|
3307 + | ))
|
3308 + | .unwrap();
|
4221 3309 | #[allow(unused_mut)]
|
4222 3310 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4223 3311 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4224 3312 | let service = crate::service::RpcV2Protocol::builder::<
|
4225 3313 | ::aws_smithy_http_server::body::BoxBody,
|
4226 3314 | _,
|
4227 3315 | _,
|
4228 3316 | _,
|
4229 3317 | >(config)
|
4230 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3318 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
4231 3319 | let sender = sender.clone();
|
4232 3320 | async move {
|
4233 3321 | let result = {
|
4234 - | use ::aws_smithy_protocol_test::FloatEquals;
|
4235 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
4236 - | double_value: ::std::option::Option::Some(1.5_f64),
|
4237 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4238 - | integer_value: ::std::option::Option::Some(56),
|
4239 - | long_value: ::std::option::Option::Some(256),
|
4240 - | short_value: ::std::option::Option::Some(10),
|
4241 - | true_boolean_value: ::std::option::Option::None,
|
4242 - | false_boolean_value: ::std::option::Option::None,
|
4243 - | byte_value: ::std::option::Option::None,
|
4244 - | string_value: ::std::option::Option::None,
|
4245 - | blob_value: ::std::option::Option::None,
|
3322 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
3323 + | dense_number_map: ::std::option::Option::Some({
|
3324 + | let mut ret = ::std::collections::HashMap::new();
|
3325 + | ret.insert("x".to_owned(), 0);
|
3326 + | ret
|
3327 + | }),
|
3328 + | dense_boolean_map: ::std::option::Option::Some({
|
3329 + | let mut ret = ::std::collections::HashMap::new();
|
3330 + | ret.insert("x".to_owned(), false);
|
3331 + | ret
|
3332 + | }),
|
3333 + | dense_struct_map: ::std::option::Option::None,
|
3334 + | dense_string_map: ::std::option::Option::None,
|
3335 + | dense_set_map: ::std::option::Option::None,
|
4246 3336 | };
|
4247 - | ::pretty_assertions::assert_eq!(
|
4248 - | input.true_boolean_value,
|
4249 - | expected.true_boolean_value,
|
4250 - | "Unexpected value for `true_boolean_value`"
|
4251 - | );
|
4252 - | ::pretty_assertions::assert_eq!(
|
4253 - | input.false_boolean_value,
|
4254 - | expected.false_boolean_value,
|
4255 - | "Unexpected value for `false_boolean_value`"
|
4256 - | );
|
4257 - | ::pretty_assertions::assert_eq!(
|
4258 - | input.byte_value,
|
4259 - | expected.byte_value,
|
4260 - | "Unexpected value for `byte_value`"
|
4261 - | );
|
4262 - | assert!(
|
4263 - | input.double_value.float_equals(&expected.double_value),
|
4264 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4265 - | expected.double_value,
|
4266 - | input.double_value
|
4267 - | );
|
4268 - | assert!(
|
4269 - | input.float_value.float_equals(&expected.float_value),
|
4270 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4271 - | expected.float_value,
|
4272 - | input.float_value
|
4273 - | );
|
4274 - | ::pretty_assertions::assert_eq!(
|
4275 - | input.integer_value,
|
4276 - | expected.integer_value,
|
4277 - | "Unexpected value for `integer_value`"
|
4278 - | );
|
4279 - | ::pretty_assertions::assert_eq!(
|
4280 - | input.long_value,
|
4281 - | expected.long_value,
|
4282 - | "Unexpected value for `long_value`"
|
4283 - | );
|
4284 - | ::pretty_assertions::assert_eq!(
|
4285 - | input.short_value,
|
4286 - | expected.short_value,
|
4287 - | "Unexpected value for `short_value`"
|
4288 - | );
|
4289 - | ::pretty_assertions::assert_eq!(
|
4290 - | input.string_value,
|
4291 - | expected.string_value,
|
4292 - | "Unexpected value for `string_value`"
|
4293 - | );
|
4294 - | ::pretty_assertions::assert_eq!(
|
4295 - | input.blob_value,
|
4296 - | expected.blob_value,
|
4297 - | "Unexpected value for `blob_value`"
|
4298 - | );
|
4299 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4300 - | true_boolean_value: ::std::option::Option::None,
|
4301 - | false_boolean_value: ::std::option::Option::None,
|
4302 - | byte_value: ::std::option::Option::None,
|
4303 - | double_value: ::std::option::Option::None,
|
4304 - | float_value: ::std::option::Option::None,
|
4305 - | integer_value: ::std::option::Option::None,
|
4306 - | long_value: ::std::option::Option::None,
|
4307 - | short_value: ::std::option::Option::None,
|
4308 - | string_value: ::std::option::Option::None,
|
4309 - | blob_value: ::std::option::Option::None,
|
3337 + | ::pretty_assertions::assert_eq!(input, expected);
|
3338 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3339 + | dense_struct_map: ::std::option::Option::None,
|
3340 + | dense_number_map: ::std::option::Option::None,
|
3341 + | dense_boolean_map: ::std::option::Option::None,
|
3342 + | dense_string_map: ::std::option::Option::None,
|
3343 + | dense_set_map: ::std::option::Option::None,
|
4310 3344 | };
|
4311 - | output
|
3345 + | Ok(output)
|
4312 3346 | };
|
4313 3347 | sender.send(()).await.expect("receiver dropped early");
|
4314 3348 | result
|
4315 3349 | }
|
4316 3350 | })
|
4317 3351 | .build_unchecked();
|
4318 3352 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4319 3353 | .await
|
4320 3354 | .expect("unable to make an HTTP request");
|
4321 3355 | assert!(
|
4322 3356 | receiver.recv().await.is_some(),
|
4323 3357 | "we expected operation handler to be invoked but it was not entered"
|
4324 3358 | );
|
4325 3359 | }
|
4326 3360 |
|
4327 - | /// The server should skip over additional fields that are not part of the structure. This allows a
|
4328 - | /// client generated against a newer Smithy model to be able to communicate with a server that is
|
4329 - | /// generated against an older Smithy model.
|
4330 - | /// Test ID: RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByServers
|
3361 + | /// A request that contains a dense map of sets.
|
3362 + | /// Test ID: RpcV2CborSerializesDenseSetMap
|
4331 3363 | #[::tokio::test]
|
4332 3364 | #[::tracing_test::traced_test]
|
4333 - | async fn rpc_v2_cbor_extra_fields_in_the_body_should_be_skipped_by_servers_request() {
|
3365 + | async fn rpc_v2_cbor_serializes_dense_set_map_request() {
|
4334 3366 | #[allow(unused_mut)]
|
4335 - | let mut http_request = ::http_1x::Request::builder()
|
4336 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4337 - | .method("POST")
|
4338 - | .header("Accept", "application/cbor")
|
4339 - | .header("Content-Type", "application/cbor")
|
4340 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4341 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
4342 - | ::bytes::Bytes::copy_from_slice(
|
4343 - | &::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"))
|
4344 - | )
|
4345 - | ))).unwrap();
|
3367 + | let mut http_request = ::http_1x::Request::builder()
|
3368 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
3369 + | .method("POST")
|
3370 + | .header("Accept", "application/cbor")
|
3371 + | .header("Content-Type", "application/cbor")
|
3372 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3373 + | .body(::aws_smithy_http_server::body::boxed(
|
3374 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3375 + | &::aws_smithy_protocol_test::decode_body_data(
|
3376 + | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi".as_bytes(),
|
3377 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3378 + | ),
|
3379 + | )),
|
3380 + | ))
|
3381 + | .unwrap();
|
4346 3382 | #[allow(unused_mut)]
|
4347 3383 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4348 3384 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4349 3385 | let service = crate::service::RpcV2Protocol::builder::<
|
4350 3386 | ::aws_smithy_http_server::body::BoxBody,
|
4351 3387 | _,
|
4352 3388 | _,
|
4353 3389 | _,
|
4354 3390 | >(config)
|
4355 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3391 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
4356 3392 | let sender = sender.clone();
|
4357 3393 | async move {
|
4358 3394 | let result = {
|
4359 - | use ::aws_smithy_protocol_test::FloatEquals;
|
4360 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
4361 - | byte_value: ::std::option::Option::Some(5),
|
4362 - | double_value: ::std::option::Option::Some(1.889_f64),
|
4363 - | false_boolean_value: ::std::option::Option::Some(false),
|
4364 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4365 - | integer_value: ::std::option::Option::Some(256),
|
4366 - | long_value: ::std::option::Option::Some(9873),
|
4367 - | short_value: ::std::option::Option::Some(9898),
|
4368 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4369 - | true_boolean_value: ::std::option::Option::Some(true),
|
4370 - | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
4371 - | "foo",
|
4372 - | )),
|
3395 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
3396 + | dense_set_map: ::std::option::Option::Some({
|
3397 + | let mut ret = ::std::collections::HashMap::new();
|
3398 + | ret.insert(
|
3399 + | "x".to_owned(),
|
3400 + | vec![].try_into().expect("this is only used in tests"),
|
3401 + | );
|
3402 + | ret.insert(
|
3403 + | "y".to_owned(),
|
3404 + | vec!["a".to_owned(), "b".to_owned()]
|
3405 + | .try_into()
|
3406 + | .expect("this is only used in tests"),
|
3407 + | );
|
3408 + | ret
|
3409 + | }),
|
3410 + | dense_struct_map: ::std::option::Option::None,
|
3411 + | dense_number_map: ::std::option::Option::None,
|
3412 + | dense_boolean_map: ::std::option::Option::None,
|
3413 + | dense_string_map: ::std::option::Option::None,
|
4373 3414 | };
|
4374 - | ::pretty_assertions::assert_eq!(
|
4375 - | input.true_boolean_value,
|
4376 - | expected.true_boolean_value,
|
4377 - | "Unexpected value for `true_boolean_value`"
|
4378 - | );
|
4379 - | ::pretty_assertions::assert_eq!(
|
4380 - | input.false_boolean_value,
|
4381 - | expected.false_boolean_value,
|
4382 - | "Unexpected value for `false_boolean_value`"
|
4383 - | );
|
4384 - | ::pretty_assertions::assert_eq!(
|
4385 - | input.byte_value,
|
4386 - | expected.byte_value,
|
4387 - | "Unexpected value for `byte_value`"
|
4388 - | );
|
4389 - | assert!(
|
4390 - | input.double_value.float_equals(&expected.double_value),
|
4391 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4392 - | expected.double_value,
|
4393 - | input.double_value
|
4394 - | );
|
4395 - | assert!(
|
4396 - | input.float_value.float_equals(&expected.float_value),
|
4397 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4398 - | expected.float_value,
|
4399 - | input.float_value
|
4400 - | );
|
4401 - | ::pretty_assertions::assert_eq!(
|
4402 - | input.integer_value,
|
4403 - | expected.integer_value,
|
4404 - | "Unexpected value for `integer_value`"
|
4405 - | );
|
4406 - | ::pretty_assertions::assert_eq!(
|
4407 - | input.long_value,
|
4408 - | expected.long_value,
|
4409 - | "Unexpected value for `long_value`"
|
4410 - | );
|
4411 - | ::pretty_assertions::assert_eq!(
|
4412 - | input.short_value,
|
4413 - | expected.short_value,
|
4414 - | "Unexpected value for `short_value`"
|
4415 - | );
|
4416 - | ::pretty_assertions::assert_eq!(
|
4417 - | input.string_value,
|
4418 - | expected.string_value,
|
4419 - | "Unexpected value for `string_value`"
|
4420 - | );
|
4421 - | ::pretty_assertions::assert_eq!(
|
4422 - | input.blob_value,
|
4423 - | expected.blob_value,
|
4424 - | "Unexpected value for `blob_value`"
|
4425 - | );
|
4426 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4427 - | true_boolean_value: ::std::option::Option::None,
|
4428 - | false_boolean_value: ::std::option::Option::None,
|
4429 - | byte_value: ::std::option::Option::None,
|
4430 - | double_value: ::std::option::Option::None,
|
4431 - | float_value: ::std::option::Option::None,
|
4432 - | integer_value: ::std::option::Option::None,
|
4433 - | long_value: ::std::option::Option::None,
|
4434 - | short_value: ::std::option::Option::None,
|
4435 - | string_value: ::std::option::Option::None,
|
4436 - | blob_value: ::std::option::Option::None,
|
3415 + | ::pretty_assertions::assert_eq!(input, expected);
|
3416 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3417 + | dense_struct_map: ::std::option::Option::None,
|
3418 + | dense_number_map: ::std::option::Option::None,
|
3419 + | dense_boolean_map: ::std::option::Option::None,
|
3420 + | dense_string_map: ::std::option::Option::None,
|
3421 + | dense_set_map: ::std::option::Option::None,
|
4437 3422 | };
|
4438 - | output
|
3423 + | Ok(output)
|
4439 3424 | };
|
4440 3425 | sender.send(()).await.expect("receiver dropped early");
|
4441 3426 | result
|
4442 3427 | }
|
4443 - | })
|
4444 - | .build_unchecked();
|
4445 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4446 - | .await
|
4447 - | .expect("unable to make an HTTP request");
|
4448 - | assert!(
|
4449 - | receiver.recv().await.is_some(),
|
4450 - | "we expected operation handler to be invoked but it was not entered"
|
3428 + | })
|
3429 + | .build_unchecked();
|
3430 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3431 + | .await
|
3432 + | .expect("unable to make an HTTP request");
|
3433 + | assert!(
|
3434 + | receiver.recv().await.is_some(),
|
3435 + | "we expected operation handler to be invoked but it was not entered"
|
3436 + | );
|
3437 + | }
|
3438 + |
|
3439 + | /// Deserializes maps
|
3440 + | /// Test ID: RpcV2CborMaps
|
3441 + | #[::tokio::test]
|
3442 + | #[::tracing_test::traced_test]
|
3443 + | async fn rpc_v2_cbor_maps_response() {
|
3444 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3445 + | dense_struct_map: ::std::option::Option::Some({
|
3446 + | let mut ret = ::std::collections::HashMap::new();
|
3447 + | ret.insert(
|
3448 + | "foo".to_owned(),
|
3449 + | crate::model::GreetingStruct {
|
3450 + | hi: ::std::option::Option::Some("there".to_owned()),
|
3451 + | },
|
3452 + | );
|
3453 + | ret.insert(
|
3454 + | "baz".to_owned(),
|
3455 + | crate::model::GreetingStruct {
|
3456 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
3457 + | },
|
3458 + | );
|
3459 + | ret
|
3460 + | }),
|
3461 + | dense_number_map: ::std::option::Option::None,
|
3462 + | dense_boolean_map: ::std::option::Option::None,
|
3463 + | dense_string_map: ::std::option::Option::None,
|
3464 + | dense_set_map: ::std::option::Option::None,
|
3465 + | };
|
3466 + | use ::aws_smithy_http_server::response::IntoResponse;
|
3467 + | let http_response = output.into_response();
|
3468 + | ::pretty_assertions::assert_eq!(
|
3469 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3470 + | http_response.status()
|
3471 + | );
|
3472 + | let expected_headers = [
|
3473 + | ("Content-Type", "application/cbor"),
|
3474 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3475 + | ];
|
3476 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3477 + | http_response.headers(),
|
3478 + | expected_headers,
|
3479 + | ));
|
3480 + | use ::http_body_util::BodyExt;
|
3481 + | let body = http_response
|
3482 + | .into_body()
|
3483 + | .collect()
|
3484 + | .await
|
3485 + | .expect("unable to collect body")
|
3486 + | .to_bytes();
|
3487 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3488 + | &body,
|
3489 + | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==",
|
3490 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3491 + | ));
|
3492 + | }
|
3493 + |
|
3494 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
3495 + | /// Test ID: RpcV2CborDeserializesZeroValuesInMaps
|
3496 + | #[::tokio::test]
|
3497 + | #[::tracing_test::traced_test]
|
3498 + | async fn rpc_v2_cbor_deserializes_zero_values_in_maps_response() {
|
3499 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3500 + | dense_number_map: ::std::option::Option::Some({
|
3501 + | let mut ret = ::std::collections::HashMap::new();
|
3502 + | ret.insert("x".to_owned(), 0);
|
3503 + | ret
|
3504 + | }),
|
3505 + | dense_boolean_map: ::std::option::Option::Some({
|
3506 + | let mut ret = ::std::collections::HashMap::new();
|
3507 + | ret.insert("x".to_owned(), false);
|
3508 + | ret
|
3509 + | }),
|
3510 + | dense_struct_map: ::std::option::Option::None,
|
3511 + | dense_string_map: ::std::option::Option::None,
|
3512 + | dense_set_map: ::std::option::Option::None,
|
3513 + | };
|
3514 + | use ::aws_smithy_http_server::response::IntoResponse;
|
3515 + | let http_response = output.into_response();
|
3516 + | ::pretty_assertions::assert_eq!(
|
3517 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3518 + | http_response.status()
|
3519 + | );
|
3520 + | let expected_headers = [
|
3521 + | ("Content-Type", "application/cbor"),
|
3522 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3523 + | ];
|
3524 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3525 + | http_response.headers(),
|
3526 + | expected_headers,
|
3527 + | ));
|
3528 + | use ::http_body_util::BodyExt;
|
3529 + | let body = http_response
|
3530 + | .into_body()
|
3531 + | .collect()
|
3532 + | .await
|
3533 + | .expect("unable to collect body")
|
3534 + | .to_bytes();
|
3535 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3536 + | &body,
|
3537 + | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==",
|
3538 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3539 + | ));
|
3540 + | }
|
3541 + |
|
3542 + | /// A response that contains a dense map of sets
|
3543 + | /// Test ID: RpcV2CborDeserializesDenseSetMap
|
3544 + | #[::tokio::test]
|
3545 + | #[::tracing_test::traced_test]
|
3546 + | async fn rpc_v2_cbor_deserializes_dense_set_map_response() {
|
3547 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
3548 + | dense_set_map: ::std::option::Option::Some({
|
3549 + | let mut ret = ::std::collections::HashMap::new();
|
3550 + | ret.insert(
|
3551 + | "x".to_owned(),
|
3552 + | vec![].try_into().expect("this is only used in tests"),
|
3553 + | );
|
3554 + | ret.insert(
|
3555 + | "y".to_owned(),
|
3556 + | vec!["a".to_owned(), "b".to_owned()]
|
3557 + | .try_into()
|
3558 + | .expect("this is only used in tests"),
|
3559 + | );
|
3560 + | ret
|
3561 + | }),
|
3562 + | dense_struct_map: ::std::option::Option::None,
|
3563 + | dense_number_map: ::std::option::Option::None,
|
3564 + | dense_boolean_map: ::std::option::Option::None,
|
3565 + | dense_string_map: ::std::option::Option::None,
|
3566 + | };
|
3567 + | use ::aws_smithy_http_server::response::IntoResponse;
|
3568 + | let http_response = output.into_response();
|
3569 + | ::pretty_assertions::assert_eq!(
|
3570 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
3571 + | http_response.status()
|
3572 + | );
|
3573 + | let expected_headers = [
|
3574 + | ("Content-Type", "application/cbor"),
|
3575 + | ("smithy-protocol", "rpc-v2-cbor"),
|
3576 + | ];
|
3577 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3578 + | http_response.headers(),
|
3579 + | expected_headers,
|
3580 + | ));
|
3581 + | use ::http_body_util::BodyExt;
|
3582 + | let body = http_response
|
3583 + | .into_body()
|
3584 + | .collect()
|
3585 + | .await
|
3586 + | .expect("unable to collect body")
|
3587 + | .to_bytes();
|
3588 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
3589 + | &body,
|
3590 + | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi",
|
3591 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3592 + | ));
|
3593 + | }
|
3594 + | }
|
3595 + |
|
3596 + | ::pin_project_lite::pin_project! {
|
3597 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3598 + | /// [`RpcV2CborSparseMapsInput`](crate::input::RpcV2CborSparseMapsInput) using modelled bindings.
|
3599 + | pub struct RpcV2CborSparseMapsInputFuture {
|
3600 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborSparseMapsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
3601 + | }
|
3602 + | }
|
3603 + |
|
3604 + | impl std::future::Future for RpcV2CborSparseMapsInputFuture {
|
3605 + | type Output = Result<
|
3606 + | crate::input::RpcV2CborSparseMapsInput,
|
3607 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
3608 + | >;
|
3609 + |
|
3610 + | fn poll(
|
3611 + | self: std::pin::Pin<&mut Self>,
|
3612 + | cx: &mut std::task::Context<'_>,
|
3613 + | ) -> std::task::Poll<Self::Output> {
|
3614 + | let this = self.project();
|
3615 + | this.inner.as_mut().poll(cx)
|
3616 + | }
|
3617 + | }
|
3618 + |
|
3619 + | impl<B>
|
3620 + | ::aws_smithy_http_server::request::FromRequest<
|
3621 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3622 + | B,
|
3623 + | > for crate::input::RpcV2CborSparseMapsInput
|
3624 + | where
|
3625 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
3626 + | B: 'static,
|
3627 + |
|
3628 + | B::Data: Send,
|
3629 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
3630 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
3631 + | {
|
3632 + | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
3633 + | type Future = RpcV2CborSparseMapsInputFuture;
|
3634 + |
|
3635 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
3636 + | let fut = async move {
|
3637 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
3638 + | request.headers(),
|
3639 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
3640 + | ) {
|
3641 + | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
3642 + | }
|
3643 + | crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::de_rpc_v2_cbor_sparse_maps_http_request(request)
|
3644 + | .await
|
3645 + | };
|
3646 + | use ::futures_util::future::TryFutureExt;
|
3647 + | let fut = fut.map_err(
|
3648 + | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
3649 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3650 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
3651 + | e,
|
3652 + | )
|
3653 + | },
|
3654 + | );
|
3655 + | RpcV2CborSparseMapsInputFuture {
|
3656 + | inner: Box::pin(fut),
|
3657 + | }
|
3658 + | }
|
3659 + | }
|
3660 + | impl
|
3661 + | ::aws_smithy_http_server::response::IntoResponse<
|
3662 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3663 + | > for crate::output::RpcV2CborSparseMapsOutput
|
3664 + | {
|
3665 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3666 + | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_response(self) {
|
3667 + | Ok(response) => response,
|
3668 + | Err(e) => {
|
3669 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3670 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3671 + | }
|
3672 + | }
|
3673 + | }
|
3674 + | }
|
3675 + | impl
|
3676 + | ::aws_smithy_http_server::response::IntoResponse<
|
3677 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
3678 + | > for crate::error::RpcV2CborSparseMapsError
|
3679 + | {
|
3680 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3681 + | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_error(&self) {
|
3682 + | Ok(mut response) => {
|
3683 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
3684 + | response
|
3685 + | },
|
3686 + | Err(e) => {
|
3687 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3688 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
3689 + | }
|
3690 + | }
|
3691 + | }
|
3692 + | }
|
3693 + |
|
3694 + | #[allow(unreachable_code, unused_variables)]
|
3695 + | #[cfg(test)]
|
3696 + | mod rpc_v2_cbor_sparse_maps_test {
|
3697 + |
|
3698 + | /// Serializes sparse maps
|
3699 + | /// Test ID: RpcV2CborSparseMaps
|
3700 + | #[::tokio::test]
|
3701 + | #[::tracing_test::traced_test]
|
3702 + | async fn rpc_v2_cbor_sparse_maps_request() {
|
3703 + | #[allow(unused_mut)]
|
3704 + | let mut http_request = ::http_1x::Request::builder()
|
3705 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3706 + | .method("POST")
|
3707 + | .header("Accept", "application/cbor")
|
3708 + | .header("Content-Type", "application/cbor")
|
3709 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3710 + | .body(::aws_smithy_http_server::body::boxed(
|
3711 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3712 + | &::aws_smithy_protocol_test::decode_body_data(
|
3713 + | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////"
|
3714 + | .as_bytes(),
|
3715 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3716 + | ),
|
3717 + | )),
|
3718 + | ))
|
3719 + | .unwrap();
|
3720 + | #[allow(unused_mut)]
|
3721 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3722 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3723 + | let service = crate::service::RpcV2Protocol::builder::<
|
3724 + | ::aws_smithy_http_server::body::BoxBody,
|
3725 + | _,
|
3726 + | _,
|
3727 + | _,
|
3728 + | >(config)
|
3729 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3730 + | let sender = sender.clone();
|
3731 + | async move {
|
3732 + | let result = {
|
3733 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3734 + | sparse_struct_map: ::std::option::Option::Some({
|
3735 + | let mut ret = ::std::collections::HashMap::new();
|
3736 + | ret.insert(
|
3737 + | "foo".to_owned(),
|
3738 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
3739 + | hi: ::std::option::Option::Some("there".to_owned()),
|
3740 + | }),
|
3741 + | );
|
3742 + | ret.insert(
|
3743 + | "baz".to_owned(),
|
3744 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
3745 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
3746 + | }),
|
3747 + | );
|
3748 + | ret
|
3749 + | }),
|
3750 + | sparse_number_map: ::std::option::Option::None,
|
3751 + | sparse_boolean_map: ::std::option::Option::None,
|
3752 + | sparse_string_map: ::std::option::Option::None,
|
3753 + | sparse_set_map: ::std::option::Option::None,
|
3754 + | };
|
3755 + | ::pretty_assertions::assert_eq!(input, expected);
|
3756 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3757 + | sparse_struct_map: ::std::option::Option::None,
|
3758 + | sparse_number_map: ::std::option::Option::None,
|
3759 + | sparse_boolean_map: ::std::option::Option::None,
|
3760 + | sparse_string_map: ::std::option::Option::None,
|
3761 + | sparse_set_map: ::std::option::Option::None,
|
3762 + | };
|
3763 + | Ok(output)
|
3764 + | };
|
3765 + | sender.send(()).await.expect("receiver dropped early");
|
3766 + | result
|
3767 + | }
|
3768 + | })
|
3769 + | .build_unchecked();
|
3770 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3771 + | .await
|
3772 + | .expect("unable to make an HTTP request");
|
3773 + | assert!(
|
3774 + | receiver.recv().await.is_some(),
|
3775 + | "we expected operation handler to be invoked but it was not entered"
|
3776 + | );
|
3777 + | }
|
3778 + |
|
3779 + | /// Serializes null map values in sparse maps
|
3780 + | /// Test ID: RpcV2CborSerializesNullMapValues
|
3781 + | #[::tokio::test]
|
3782 + | #[::tracing_test::traced_test]
|
3783 + | async fn rpc_v2_cbor_serializes_null_map_values_request() {
|
3784 + | #[allow(unused_mut)]
|
3785 + | let mut http_request = ::http_1x::Request::builder()
|
3786 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3787 + | .method("POST")
|
3788 + | .header("Accept", "application/cbor")
|
3789 + | .header("Content-Type", "application/cbor")
|
3790 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3791 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
3792 + | ::bytes::Bytes::copy_from_slice(
|
3793 + | &::aws_smithy_protocol_test::decode_body_data("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3794 + | )
|
3795 + | ))).unwrap();
|
3796 + | #[allow(unused_mut)]
|
3797 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3798 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3799 + | let service = crate::service::RpcV2Protocol::builder::<
|
3800 + | ::aws_smithy_http_server::body::BoxBody,
|
3801 + | _,
|
3802 + | _,
|
3803 + | _,
|
3804 + | >(config)
|
3805 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3806 + | let sender = sender.clone();
|
3807 + | async move {
|
3808 + | let result = {
|
3809 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3810 + | sparse_boolean_map: ::std::option::Option::Some({
|
3811 + | let mut ret = ::std::collections::HashMap::new();
|
3812 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3813 + | ret
|
3814 + | }),
|
3815 + | sparse_number_map: ::std::option::Option::Some({
|
3816 + | let mut ret = ::std::collections::HashMap::new();
|
3817 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3818 + | ret
|
3819 + | }),
|
3820 + | sparse_string_map: ::std::option::Option::Some({
|
3821 + | let mut ret = ::std::collections::HashMap::new();
|
3822 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3823 + | ret
|
3824 + | }),
|
3825 + | sparse_struct_map: ::std::option::Option::Some({
|
3826 + | let mut ret = ::std::collections::HashMap::new();
|
3827 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
3828 + | ret
|
3829 + | }),
|
3830 + | sparse_set_map: ::std::option::Option::None,
|
3831 + | };
|
3832 + | ::pretty_assertions::assert_eq!(input, expected);
|
3833 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3834 + | sparse_struct_map: ::std::option::Option::None,
|
3835 + | sparse_number_map: ::std::option::Option::None,
|
3836 + | sparse_boolean_map: ::std::option::Option::None,
|
3837 + | sparse_string_map: ::std::option::Option::None,
|
3838 + | sparse_set_map: ::std::option::Option::None,
|
3839 + | };
|
3840 + | Ok(output)
|
3841 + | };
|
3842 + | sender.send(()).await.expect("receiver dropped early");
|
3843 + | result
|
3844 + | }
|
3845 + | })
|
3846 + | .build_unchecked();
|
3847 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3848 + | .await
|
3849 + | .expect("unable to make an HTTP request");
|
3850 + | assert!(
|
3851 + | receiver.recv().await.is_some(),
|
3852 + | "we expected operation handler to be invoked but it was not entered"
|
3853 + | );
|
3854 + | }
|
3855 + |
|
3856 + | /// A request that contains a sparse map of sets
|
3857 + | /// Test ID: RpcV2CborSerializesSparseSetMap
|
3858 + | #[::tokio::test]
|
3859 + | #[::tracing_test::traced_test]
|
3860 + | async fn rpc_v2_cbor_serializes_sparse_set_map_request() {
|
3861 + | #[allow(unused_mut)]
|
3862 + | let mut http_request = ::http_1x::Request::builder()
|
3863 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3864 + | .method("POST")
|
3865 + | .header("Accept", "application/cbor")
|
3866 + | .header("Content-Type", "application/cbor")
|
3867 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3868 + | .body(::aws_smithy_http_server::body::boxed(
|
3869 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3870 + | &::aws_smithy_protocol_test::decode_body_data(
|
3871 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=".as_bytes(),
|
3872 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3873 + | ),
|
3874 + | )),
|
3875 + | ))
|
3876 + | .unwrap();
|
3877 + | #[allow(unused_mut)]
|
3878 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3879 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3880 + | let service = crate::service::RpcV2Protocol::builder::<
|
3881 + | ::aws_smithy_http_server::body::BoxBody,
|
3882 + | _,
|
3883 + | _,
|
3884 + | _,
|
3885 + | >(config)
|
3886 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3887 + | let sender = sender.clone();
|
3888 + | async move {
|
3889 + | let result = {
|
3890 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3891 + | sparse_set_map: ::std::option::Option::Some({
|
3892 + | let mut ret = ::std::collections::HashMap::new();
|
3893 + | ret.insert(
|
3894 + | "x".to_owned(),
|
3895 + | ::std::option::Option::Some(
|
3896 + | vec![].try_into().expect("this is only used in tests"),
|
3897 + | ),
|
3898 + | );
|
3899 + | ret.insert(
|
3900 + | "y".to_owned(),
|
3901 + | ::std::option::Option::Some(
|
3902 + | vec!["a".to_owned(), "b".to_owned()]
|
3903 + | .try_into()
|
3904 + | .expect("this is only used in tests"),
|
3905 + | ),
|
3906 + | );
|
3907 + | ret
|
3908 + | }),
|
3909 + | sparse_struct_map: ::std::option::Option::None,
|
3910 + | sparse_number_map: ::std::option::Option::None,
|
3911 + | sparse_boolean_map: ::std::option::Option::None,
|
3912 + | sparse_string_map: ::std::option::Option::None,
|
3913 + | };
|
3914 + | ::pretty_assertions::assert_eq!(input, expected);
|
3915 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3916 + | sparse_struct_map: ::std::option::Option::None,
|
3917 + | sparse_number_map: ::std::option::Option::None,
|
3918 + | sparse_boolean_map: ::std::option::Option::None,
|
3919 + | sparse_string_map: ::std::option::Option::None,
|
3920 + | sparse_set_map: ::std::option::Option::None,
|
3921 + | };
|
3922 + | Ok(output)
|
3923 + | };
|
3924 + | sender.send(()).await.expect("receiver dropped early");
|
3925 + | result
|
3926 + | }
|
3927 + | })
|
3928 + | .build_unchecked();
|
3929 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3930 + | .await
|
3931 + | .expect("unable to make an HTTP request");
|
3932 + | assert!(
|
3933 + | receiver.recv().await.is_some(),
|
3934 + | "we expected operation handler to be invoked but it was not entered"
|
3935 + | );
|
3936 + | }
|
3937 + |
|
3938 + | /// A request that contains a sparse map of sets.
|
3939 + | /// Test ID: RpcV2CborSerializesSparseSetMapAndRetainsNull
|
3940 + | #[::tokio::test]
|
3941 + | #[::tracing_test::traced_test]
|
3942 + | async fn rpc_v2_cbor_serializes_sparse_set_map_and_retains_null_request() {
|
3943 + | #[allow(unused_mut)]
|
3944 + | let mut http_request = ::http_1x::Request::builder()
|
3945 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
3946 + | .method("POST")
|
3947 + | .header("Accept", "application/cbor")
|
3948 + | .header("Content-Type", "application/cbor")
|
3949 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3950 + | .body(::aws_smithy_http_server::body::boxed(
|
3951 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3952 + | &::aws_smithy_protocol_test::decode_body_data(
|
3953 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=".as_bytes(),
|
3954 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3955 + | ),
|
3956 + | )),
|
3957 + | ))
|
3958 + | .unwrap();
|
3959 + | #[allow(unused_mut)]
|
3960 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3961 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3962 + | let service = crate::service::RpcV2Protocol::builder::<
|
3963 + | ::aws_smithy_http_server::body::BoxBody,
|
3964 + | _,
|
3965 + | _,
|
3966 + | _,
|
3967 + | >(config)
|
3968 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
3969 + | let sender = sender.clone();
|
3970 + | async move {
|
3971 + | let result = {
|
3972 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
3973 + | sparse_set_map: ::std::option::Option::Some({
|
3974 + | let mut ret = ::std::collections::HashMap::new();
|
3975 + | ret.insert(
|
3976 + | "x".to_owned(),
|
3977 + | ::std::option::Option::Some(
|
3978 + | vec![].try_into().expect("this is only used in tests"),
|
3979 + | ),
|
3980 + | );
|
3981 + | ret.insert(
|
3982 + | "y".to_owned(),
|
3983 + | ::std::option::Option::Some(
|
3984 + | vec!["a".to_owned(), "b".to_owned()]
|
3985 + | .try_into()
|
3986 + | .expect("this is only used in tests"),
|
3987 + | ),
|
3988 + | );
|
3989 + | ret.insert("z".to_owned(), ::std::option::Option::None);
|
3990 + | ret
|
3991 + | }),
|
3992 + | sparse_struct_map: ::std::option::Option::None,
|
3993 + | sparse_number_map: ::std::option::Option::None,
|
3994 + | sparse_boolean_map: ::std::option::Option::None,
|
3995 + | sparse_string_map: ::std::option::Option::None,
|
3996 + | };
|
3997 + | ::pretty_assertions::assert_eq!(input, expected);
|
3998 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
3999 + | sparse_struct_map: ::std::option::Option::None,
|
4000 + | sparse_number_map: ::std::option::Option::None,
|
4001 + | sparse_boolean_map: ::std::option::Option::None,
|
4002 + | sparse_string_map: ::std::option::Option::None,
|
4003 + | sparse_set_map: ::std::option::Option::None,
|
4004 + | };
|
4005 + | Ok(output)
|
4006 + | };
|
4007 + | sender.send(()).await.expect("receiver dropped early");
|
4008 + | result
|
4009 + | }
|
4010 + | })
|
4011 + | .build_unchecked();
|
4012 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4013 + | .await
|
4014 + | .expect("unable to make an HTTP request");
|
4015 + | assert!(
|
4016 + | receiver.recv().await.is_some(),
|
4017 + | "we expected operation handler to be invoked but it was not entered"
|
4018 + | );
|
4019 + | }
|
4020 + |
|
4021 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
4022 + | /// Test ID: RpcV2CborSerializesZeroValuesInSparseMaps
|
4023 + | #[::tokio::test]
|
4024 + | #[::tracing_test::traced_test]
|
4025 + | async fn rpc_v2_cbor_serializes_zero_values_in_sparse_maps_request() {
|
4026 + | #[allow(unused_mut)]
|
4027 + | let mut http_request = ::http_1x::Request::builder()
|
4028 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
4029 + | .method("POST")
|
4030 + | .header("Accept", "application/cbor")
|
4031 + | .header("Content-Type", "application/cbor")
|
4032 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4033 + | .body(::aws_smithy_http_server::body::boxed(
|
4034 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4035 + | &::aws_smithy_protocol_test::decode_body_data(
|
4036 + | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//".as_bytes(),
|
4037 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4038 + | ),
|
4039 + | )),
|
4040 + | ))
|
4041 + | .unwrap();
|
4042 + | #[allow(unused_mut)]
|
4043 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4044 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4045 + | let service = crate::service::RpcV2Protocol::builder::<
|
4046 + | ::aws_smithy_http_server::body::BoxBody,
|
4047 + | _,
|
4048 + | _,
|
4049 + | _,
|
4050 + | >(config)
|
4051 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
4052 + | let sender = sender.clone();
|
4053 + | async move {
|
4054 + | let result = {
|
4055 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
4056 + | sparse_number_map: ::std::option::Option::Some({
|
4057 + | let mut ret = ::std::collections::HashMap::new();
|
4058 + | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
4059 + | ret
|
4060 + | }),
|
4061 + | sparse_boolean_map: ::std::option::Option::Some({
|
4062 + | let mut ret = ::std::collections::HashMap::new();
|
4063 + | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
4064 + | ret
|
4065 + | }),
|
4066 + | sparse_struct_map: ::std::option::Option::None,
|
4067 + | sparse_string_map: ::std::option::Option::None,
|
4068 + | sparse_set_map: ::std::option::Option::None,
|
4069 + | };
|
4070 + | ::pretty_assertions::assert_eq!(input, expected);
|
4071 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4072 + | sparse_struct_map: ::std::option::Option::None,
|
4073 + | sparse_number_map: ::std::option::Option::None,
|
4074 + | sparse_boolean_map: ::std::option::Option::None,
|
4075 + | sparse_string_map: ::std::option::Option::None,
|
4076 + | sparse_set_map: ::std::option::Option::None,
|
4077 + | };
|
4078 + | Ok(output)
|
4079 + | };
|
4080 + | sender.send(()).await.expect("receiver dropped early");
|
4081 + | result
|
4082 + | }
|
4083 + | })
|
4084 + | .build_unchecked();
|
4085 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4086 + | .await
|
4087 + | .expect("unable to make an HTTP request");
|
4088 + | assert!(
|
4089 + | receiver.recv().await.is_some(),
|
4090 + | "we expected operation handler to be invoked but it was not entered"
|
4091 + | );
|
4092 + | }
|
4093 + |
|
4094 + | /// Deserializes sparse maps
|
4095 + | /// Test ID: RpcV2CborSparseJsonMaps
|
4096 + | #[::tokio::test]
|
4097 + | #[::tracing_test::traced_test]
|
4098 + | async fn rpc_v2_cbor_sparse_json_maps_response() {
|
4099 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4100 + | sparse_struct_map: ::std::option::Option::Some({
|
4101 + | let mut ret = ::std::collections::HashMap::new();
|
4102 + | ret.insert(
|
4103 + | "foo".to_owned(),
|
4104 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
4105 + | hi: ::std::option::Option::Some("there".to_owned()),
|
4106 + | }),
|
4107 + | );
|
4108 + | ret.insert(
|
4109 + | "baz".to_owned(),
|
4110 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
4111 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
4112 + | }),
|
4113 + | );
|
4114 + | ret
|
4115 + | }),
|
4116 + | sparse_number_map: ::std::option::Option::None,
|
4117 + | sparse_boolean_map: ::std::option::Option::None,
|
4118 + | sparse_string_map: ::std::option::Option::None,
|
4119 + | sparse_set_map: ::std::option::Option::None,
|
4120 + | };
|
4121 + | use ::aws_smithy_http_server::response::IntoResponse;
|
4122 + | let http_response = output.into_response();
|
4123 + | ::pretty_assertions::assert_eq!(
|
4124 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4125 + | http_response.status()
|
4126 + | );
|
4127 + | let expected_headers = [
|
4128 + | ("Content-Type", "application/cbor"),
|
4129 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4130 + | ];
|
4131 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4132 + | http_response.headers(),
|
4133 + | expected_headers,
|
4134 + | ));
|
4135 + | use ::http_body_util::BodyExt;
|
4136 + | let body = http_response
|
4137 + | .into_body()
|
4138 + | .collect()
|
4139 + | .await
|
4140 + | .expect("unable to collect body")
|
4141 + | .to_bytes();
|
4142 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4143 + | &body,
|
4144 + | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////",
|
4145 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4146 + | ));
|
4147 + | }
|
4148 + |
|
4149 + | /// Deserializes null map values
|
4150 + | /// Test ID: RpcV2CborDeserializesNullMapValues
|
4151 + | #[::tokio::test]
|
4152 + | #[::tracing_test::traced_test]
|
4153 + | async fn rpc_v2_cbor_deserializes_null_map_values_response() {
|
4154 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4155 + | sparse_boolean_map: ::std::option::Option::Some({
|
4156 + | let mut ret = ::std::collections::HashMap::new();
|
4157 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
4158 + | ret
|
4159 + | }),
|
4160 + | sparse_number_map: ::std::option::Option::Some({
|
4161 + | let mut ret = ::std::collections::HashMap::new();
|
4162 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
4163 + | ret
|
4164 + | }),
|
4165 + | sparse_string_map: ::std::option::Option::Some({
|
4166 + | let mut ret = ::std::collections::HashMap::new();
|
4167 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
4168 + | ret
|
4169 + | }),
|
4170 + | sparse_struct_map: ::std::option::Option::Some({
|
4171 + | let mut ret = ::std::collections::HashMap::new();
|
4172 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
4173 + | ret
|
4174 + | }),
|
4175 + | sparse_set_map: ::std::option::Option::None,
|
4176 + | };
|
4177 + | use ::aws_smithy_http_server::response::IntoResponse;
|
4178 + | let http_response = output.into_response();
|
4179 + | ::pretty_assertions::assert_eq!(
|
4180 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4181 + | http_response.status()
|
4182 + | );
|
4183 + | let expected_headers = [
|
4184 + | ("Content-Type", "application/cbor"),
|
4185 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4186 + | ];
|
4187 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4188 + | http_response.headers(),
|
4189 + | expected_headers,
|
4190 + | ));
|
4191 + | use ::http_body_util::BodyExt;
|
4192 + | let body = http_response
|
4193 + | .into_body()
|
4194 + | .collect()
|
4195 + | .await
|
4196 + | .expect("unable to collect body")
|
4197 + | .to_bytes();
|
4198 + | ::aws_smithy_protocol_test::assert_ok(
|
4199 + | ::aws_smithy_protocol_test::validate_body(&body, "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4200 + | );
|
4201 + | }
|
4202 + |
|
4203 + | /// A response that contains a sparse map of sets
|
4204 + | /// Test ID: RpcV2CborDeserializesSparseSetMap
|
4205 + | #[::tokio::test]
|
4206 + | #[::tracing_test::traced_test]
|
4207 + | async fn rpc_v2_cbor_deserializes_sparse_set_map_response() {
|
4208 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4209 + | sparse_set_map: ::std::option::Option::Some({
|
4210 + | let mut ret = ::std::collections::HashMap::new();
|
4211 + | ret.insert(
|
4212 + | "x".to_owned(),
|
4213 + | ::std::option::Option::Some(
|
4214 + | vec![].try_into().expect("this is only used in tests"),
|
4215 + | ),
|
4216 + | );
|
4217 + | ret.insert(
|
4218 + | "y".to_owned(),
|
4219 + | ::std::option::Option::Some(
|
4220 + | vec!["a".to_owned(), "b".to_owned()]
|
4221 + | .try_into()
|
4222 + | .expect("this is only used in tests"),
|
4223 + | ),
|
4224 + | );
|
4225 + | ret
|
4226 + | }),
|
4227 + | sparse_struct_map: ::std::option::Option::None,
|
4228 + | sparse_number_map: ::std::option::Option::None,
|
4229 + | sparse_boolean_map: ::std::option::Option::None,
|
4230 + | sparse_string_map: ::std::option::Option::None,
|
4231 + | };
|
4232 + | use ::aws_smithy_http_server::response::IntoResponse;
|
4233 + | let http_response = output.into_response();
|
4234 + | ::pretty_assertions::assert_eq!(
|
4235 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4236 + | http_response.status()
|
4237 + | );
|
4238 + | let expected_headers = [
|
4239 + | ("Content-Type", "application/cbor"),
|
4240 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4241 + | ];
|
4242 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4243 + | http_response.headers(),
|
4244 + | expected_headers,
|
4245 + | ));
|
4246 + | use ::http_body_util::BodyExt;
|
4247 + | let body = http_response
|
4248 + | .into_body()
|
4249 + | .collect()
|
4250 + | .await
|
4251 + | .expect("unable to collect body")
|
4252 + | .to_bytes();
|
4253 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4254 + | &body,
|
4255 + | "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=",
|
4256 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4257 + | ));
|
4258 + | }
|
4259 + |
|
4260 + | /// A response that contains a sparse map of sets with a null
|
4261 + | /// Test ID: RpcV2CborDeserializesSparseSetMapAndRetainsNull
|
4262 + | #[::tokio::test]
|
4263 + | #[::tracing_test::traced_test]
|
4264 + | async fn rpc_v2_cbor_deserializes_sparse_set_map_and_retains_null_response() {
|
4265 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4266 + | sparse_set_map: ::std::option::Option::Some({
|
4267 + | let mut ret = ::std::collections::HashMap::new();
|
4268 + | ret.insert(
|
4269 + | "x".to_owned(),
|
4270 + | ::std::option::Option::Some(
|
4271 + | vec![].try_into().expect("this is only used in tests"),
|
4272 + | ),
|
4273 + | );
|
4274 + | ret.insert(
|
4275 + | "y".to_owned(),
|
4276 + | ::std::option::Option::Some(
|
4277 + | vec!["a".to_owned(), "b".to_owned()]
|
4278 + | .try_into()
|
4279 + | .expect("this is only used in tests"),
|
4280 + | ),
|
4281 + | );
|
4282 + | ret.insert("z".to_owned(), ::std::option::Option::None);
|
4283 + | ret
|
4284 + | }),
|
4285 + | sparse_struct_map: ::std::option::Option::None,
|
4286 + | sparse_number_map: ::std::option::Option::None,
|
4287 + | sparse_boolean_map: ::std::option::Option::None,
|
4288 + | sparse_string_map: ::std::option::Option::None,
|
4289 + | };
|
4290 + | use ::aws_smithy_http_server::response::IntoResponse;
|
4291 + | let http_response = output.into_response();
|
4292 + | ::pretty_assertions::assert_eq!(
|
4293 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4294 + | http_response.status()
|
4295 + | );
|
4296 + | let expected_headers = [
|
4297 + | ("Content-Type", "application/cbor"),
|
4298 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4299 + | ];
|
4300 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4301 + | http_response.headers(),
|
4302 + | expected_headers,
|
4303 + | ));
|
4304 + | use ::http_body_util::BodyExt;
|
4305 + | let body = http_response
|
4306 + | .into_body()
|
4307 + | .collect()
|
4308 + | .await
|
4309 + | .expect("unable to collect body")
|
4310 + | .to_bytes();
|
4311 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4312 + | &body,
|
4313 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=",
|
4314 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4315 + | ));
|
4316 + | }
|
4317 + |
|
4318 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
4319 + | /// Test ID: RpcV2CborDeserializesZeroValuesInSparseMaps
|
4320 + | #[::tokio::test]
|
4321 + | #[::tracing_test::traced_test]
|
4322 + | async fn rpc_v2_cbor_deserializes_zero_values_in_sparse_maps_response() {
|
4323 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
4324 + | sparse_number_map: ::std::option::Option::Some({
|
4325 + | let mut ret = ::std::collections::HashMap::new();
|
4326 + | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
4327 + | ret
|
4328 + | }),
|
4329 + | sparse_boolean_map: ::std::option::Option::Some({
|
4330 + | let mut ret = ::std::collections::HashMap::new();
|
4331 + | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
4332 + | ret
|
4333 + | }),
|
4334 + | sparse_struct_map: ::std::option::Option::None,
|
4335 + | sparse_string_map: ::std::option::Option::None,
|
4336 + | sparse_set_map: ::std::option::Option::None,
|
4337 + | };
|
4338 + | use ::aws_smithy_http_server::response::IntoResponse;
|
4339 + | let http_response = output.into_response();
|
4340 + | ::pretty_assertions::assert_eq!(
|
4341 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4342 + | http_response.status()
|
4343 + | );
|
4344 + | let expected_headers = [
|
4345 + | ("Content-Type", "application/cbor"),
|
4346 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4347 + | ];
|
4348 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4349 + | http_response.headers(),
|
4350 + | expected_headers,
|
4351 + | ));
|
4352 + | use ::http_body_util::BodyExt;
|
4353 + | let body = http_response
|
4354 + | .into_body()
|
4355 + | .collect()
|
4356 + | .await
|
4357 + | .expect("unable to collect body")
|
4358 + | .to_bytes();
|
4359 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4360 + | &body,
|
4361 + | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//",
|
4362 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4363 + | ));
|
4364 + | }
|
4365 + | }
|
4366 + |
|
4367 + | ::pin_project_lite::pin_project! {
|
4368 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4369 + | /// [`RecursiveShapesInput`](crate::input::RecursiveShapesInput) using modelled bindings.
|
4370 + | pub struct RecursiveShapesInputFuture {
|
4371 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveShapesInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4372 + | }
|
4373 + | }
|
4374 + |
|
4375 + | impl std::future::Future for RecursiveShapesInputFuture {
|
4376 + | type Output = Result<
|
4377 + | crate::input::RecursiveShapesInput,
|
4378 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4379 + | >;
|
4380 + |
|
4381 + | fn poll(
|
4382 + | self: std::pin::Pin<&mut Self>,
|
4383 + | cx: &mut std::task::Context<'_>,
|
4384 + | ) -> std::task::Poll<Self::Output> {
|
4385 + | let this = self.project();
|
4386 + | this.inner.as_mut().poll(cx)
|
4387 + | }
|
4388 + | }
|
4389 + |
|
4390 + | impl<B>
|
4391 + | ::aws_smithy_http_server::request::FromRequest<
|
4392 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4393 + | B,
|
4394 + | > for crate::input::RecursiveShapesInput
|
4395 + | where
|
4396 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
4397 + | B: 'static,
|
4398 + |
|
4399 + | B::Data: Send,
|
4400 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4401 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
4402 + | {
|
4403 + | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4404 + | type Future = RecursiveShapesInputFuture;
|
4405 + |
|
4406 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
4407 + | let fut = async move {
|
4408 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
4409 + | request.headers(),
|
4410 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4411 + | ) {
|
4412 + | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4413 + | }
|
4414 + | crate::protocol_serde::shape_recursive_shapes::de_recursive_shapes_http_request(request)
|
4415 + | .await
|
4416 + | };
|
4417 + | use ::futures_util::future::TryFutureExt;
|
4418 + | let fut = fut.map_err(
|
4419 + | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4420 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4421 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
4422 + | e,
|
4423 + | )
|
4424 + | },
|
4451 4425 | );
|
4426 + | RecursiveShapesInputFuture {
|
4427 + | inner: Box::pin(fut),
|
4428 + | }
|
4429 + | }
|
4430 + | }
|
4431 + | impl
|
4432 + | ::aws_smithy_http_server::response::IntoResponse<
|
4433 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4434 + | > for crate::output::RecursiveShapesOutput
|
4435 + | {
|
4436 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4437 + | match crate::protocol_serde::shape_recursive_shapes::ser_recursive_shapes_http_response(
|
4438 + | self,
|
4439 + | ) {
|
4440 + | Ok(response) => response,
|
4441 + | Err(e) => {
|
4442 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4443 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4444 + | }
|
4445 + | }
|
4452 4446 | }
|
4447 + | }
|
4453 4448 |
|
4454 - | /// Servers should tolerate requests without an Accept header set.
|
4455 - | /// Test ID: RpcV2CborServersShouldHandleNoAcceptHeader
|
4449 + | #[allow(unreachable_code, unused_variables)]
|
4450 + | #[cfg(test)]
|
4451 + | mod recursive_shapes_test {
|
4452 + |
|
4453 + | /// Serializes recursive structures
|
4454 + | /// Test ID: RpcV2CborRecursiveShapes
|
4456 4455 | #[::tokio::test]
|
4457 4456 | #[::tracing_test::traced_test]
|
4458 - | async fn rpc_v2_cbor_servers_should_handle_no_accept_header_request() {
|
4457 + | async fn rpc_v2_cbor_recursive_shapes_request() {
|
4459 4458 | #[allow(unused_mut)]
|
4460 4459 | let mut http_request = ::http_1x::Request::builder()
|
4461 - | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4460 + | .uri("/service/RpcV2Protocol/operation/RecursiveShapes")
|
4462 4461 | .method("POST")
|
4462 + | .header("Accept", "application/cbor")
|
4463 4463 | .header("Content-Type", "application/cbor")
|
4464 4464 | .header("smithy-protocol", "rpc-v2-cbor")
|
4465 4465 | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
4466 4466 | ::bytes::Bytes::copy_from_slice(
|
4467 - | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4467 + | &::aws_smithy_protocol_test::decode_body_data("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4468 4468 | )
|
4469 4469 | ))).unwrap();
|
4470 4470 | #[allow(unused_mut)]
|
4471 4471 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4472 4472 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4473 - | let service = crate::service::RpcV2Protocol::builder::<
|
4474 - | ::aws_smithy_http_server::body::BoxBody,
|
4475 - | _,
|
4476 - | _,
|
4477 - | _,
|
4478 - | >(config)
|
4479 - | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
4480 - | let sender = sender.clone();
|
4481 - | async move {
|
4482 - | let result = {
|
4483 - | use ::aws_smithy_protocol_test::FloatEquals;
|
4484 - | let expected = crate::input::SimpleScalarPropertiesInput {
|
4485 - | byte_value: ::std::option::Option::Some(5),
|
4486 - | double_value: ::std::option::Option::Some(1.889_f64),
|
4487 - | false_boolean_value: ::std::option::Option::Some(false),
|
4488 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4489 - | integer_value: ::std::option::Option::Some(256),
|
4490 - | long_value: ::std::option::Option::Some(9873),
|
4491 - | short_value: ::std::option::Option::Some(9898),
|
4492 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4493 - | true_boolean_value: ::std::option::Option::Some(true),
|
4494 - | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new(
|
4495 - | "foo",
|
4496 - | )),
|
4497 - | };
|
4498 - | ::pretty_assertions::assert_eq!(
|
4499 - | input.true_boolean_value,
|
4500 - | expected.true_boolean_value,
|
4501 - | "Unexpected value for `true_boolean_value`"
|
4502 - | );
|
4503 - | ::pretty_assertions::assert_eq!(
|
4504 - | input.false_boolean_value,
|
4505 - | expected.false_boolean_value,
|
4506 - | "Unexpected value for `false_boolean_value`"
|
4507 - | );
|
4508 - | ::pretty_assertions::assert_eq!(
|
4509 - | input.byte_value,
|
4510 - | expected.byte_value,
|
4511 - | "Unexpected value for `byte_value`"
|
4512 - | );
|
4513 - | assert!(
|
4514 - | input.double_value.float_equals(&expected.double_value),
|
4515 - | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4516 - | expected.double_value,
|
4517 - | input.double_value
|
4518 - | );
|
4519 - | assert!(
|
4520 - | input.float_value.float_equals(&expected.float_value),
|
4521 - | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4522 - | expected.float_value,
|
4523 - | input.float_value
|
4524 - | );
|
4525 - | ::pretty_assertions::assert_eq!(
|
4526 - | input.integer_value,
|
4527 - | expected.integer_value,
|
4528 - | "Unexpected value for `integer_value`"
|
4529 - | );
|
4530 - | ::pretty_assertions::assert_eq!(
|
4531 - | input.long_value,
|
4532 - | expected.long_value,
|
4533 - | "Unexpected value for `long_value`"
|
4534 - | );
|
4535 - | ::pretty_assertions::assert_eq!(
|
4536 - | input.short_value,
|
4537 - | expected.short_value,
|
4538 - | "Unexpected value for `short_value`"
|
4539 - | );
|
4540 - | ::pretty_assertions::assert_eq!(
|
4541 - | input.string_value,
|
4542 - | expected.string_value,
|
4543 - | "Unexpected value for `string_value`"
|
4544 - | );
|
4545 - | ::pretty_assertions::assert_eq!(
|
4546 - | input.blob_value,
|
4547 - | expected.blob_value,
|
4548 - | "Unexpected value for `blob_value`"
|
4549 - | );
|
4550 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4551 - | true_boolean_value: ::std::option::Option::None,
|
4552 - | false_boolean_value: ::std::option::Option::None,
|
4553 - | byte_value: ::std::option::Option::None,
|
4554 - | double_value: ::std::option::Option::None,
|
4555 - | float_value: ::std::option::Option::None,
|
4556 - | integer_value: ::std::option::Option::None,
|
4557 - | long_value: ::std::option::Option::None,
|
4558 - | short_value: ::std::option::Option::None,
|
4559 - | string_value: ::std::option::Option::None,
|
4560 - | blob_value: ::std::option::Option::None,
|
4561 - | };
|
4562 - | output
|
4563 - | };
|
4564 - | sender.send(()).await.expect("receiver dropped early");
|
4565 - | result
|
4473 + | let service = crate::service::RpcV2Protocol::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4474 + | .recursive_shapes(move |input: crate::input::RecursiveShapesInput| {
|
4475 + | let sender = sender.clone();
|
4476 + | async move {
|
4477 + | let result = { let expected =
|
4478 + | crate::input::RecursiveShapesInput {
|
4479 + | nested:
|
4480 + | ::std::option::Option::Some(
|
4481 + | crate::model::RecursiveShapesInputOutputNested1 {
|
4482 + | foo:
|
4483 + | ::std::option::Option::Some(
|
4484 + | "Foo1".to_owned()
|
4485 + | )
|
4486 + | ,
|
4487 + | nested:
|
4488 + | ::std::option::Option::Some(
|
4489 + | ::std::boxed::Box::new(
|
4490 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4491 + | bar:
|
4492 + | ::std::option::Option::Some(
|
4493 + | "Bar1".to_owned()
|
4494 + | )
|
4495 + | ,
|
4496 + | recursive_member:
|
4497 + | ::std::option::Option::Some(
|
4498 + | crate::model::RecursiveShapesInputOutputNested1 {
|
4499 + | foo:
|
4500 + | ::std::option::Option::Some(
|
4501 + | "Foo2".to_owned()
|
4502 + | )
|
4503 + | ,
|
4504 + | nested:
|
4505 + | ::std::option::Option::Some(
|
4506 + | ::std::boxed::Box::new(
|
4507 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4508 + | bar:
|
4509 + | ::std::option::Option::Some(
|
4510 + | "Bar2".to_owned()
|
4511 + | )
|
4512 + | ,
|
4513 + | recursive_member:
|
4514 + | ::std::option::Option::None
|
4515 + | ,
|
4516 + | }
|
4517 + | )
|
4518 + | )
|
4519 + | ,
|
4520 + | }
|
4521 + | )
|
4522 + | ,
|
4523 + | }
|
4524 + | )
|
4525 + | )
|
4526 + | ,
|
4527 + | }
|
4528 + | )
|
4529 + | ,
|
4566 4530 | }
|
4567 - | })
|
4568 - | .build_unchecked();
|
4531 + | ;
|
4532 + | ::pretty_assertions::assert_eq!(input, expected);
|
4533 + | let output =
|
4534 + | crate::output::RecursiveShapesOutput {
|
4535 + | nested:
|
4536 + | ::std::option::Option::None
|
4537 + | ,
|
4538 + | }
|
4539 + | ;
|
4540 + | output };
|
4541 + | sender.send(()).await.expect("receiver dropped early");
|
4542 + | result
|
4543 + | }
|
4544 + | })
|
4545 + | .build_unchecked();
|
4569 4546 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4570 4547 | .await
|
4571 4548 | .expect("unable to make an HTTP request");
|
4572 4549 | assert!(
|
4573 4550 | receiver.recv().await.is_some(),
|
4574 4551 | "we expected operation handler to be invoked but it was not entered"
|
4575 4552 | );
|
4576 4553 | }
|
4577 4554 |
|
4578 - | /// Serializes simple scalar properties
|
4579 - | /// Test ID: RpcV2CborSimpleScalarProperties
|
4555 + | /// Serializes recursive structures
|
4556 + | /// Test ID: RpcV2CborRecursiveShapes
|
4580 4557 | #[::tokio::test]
|
4581 4558 | #[::tracing_test::traced_test]
|
4582 - | async fn rpc_v2_cbor_simple_scalar_properties_response() {
|
4583 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4584 - | true_boolean_value: ::std::option::Option::Some(true),
|
4585 - | false_boolean_value: ::std::option::Option::Some(false),
|
4586 - | byte_value: ::std::option::Option::Some(5),
|
4587 - | double_value: ::std::option::Option::Some(1.889_f64),
|
4588 - | float_value: ::std::option::Option::Some(7.625_f32),
|
4589 - | integer_value: ::std::option::Option::Some(256),
|
4590 - | short_value: ::std::option::Option::Some(9898),
|
4591 - | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4592 - | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new("foo")),
|
4593 - | long_value: ::std::option::Option::None,
|
4559 + | async fn rpc_v2_cbor_recursive_shapes_response() {
|
4560 + | let output = crate::output::RecursiveShapesOutput {
|
4561 + | nested: ::std::option::Option::Some(crate::model::RecursiveShapesInputOutputNested1 {
|
4562 + | foo: ::std::option::Option::Some("Foo1".to_owned()),
|
4563 + | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
4564 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4565 + | bar: ::std::option::Option::Some("Bar1".to_owned()),
|
4566 + | recursive_member: ::std::option::Option::Some(
|
4567 + | crate::model::RecursiveShapesInputOutputNested1 {
|
4568 + | foo: ::std::option::Option::Some("Foo2".to_owned()),
|
4569 + | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
4570 + | crate::model::RecursiveShapesInputOutputNested2 {
|
4571 + | bar: ::std::option::Option::Some("Bar2".to_owned()),
|
4572 + | recursive_member: ::std::option::Option::None,
|
4573 + | },
|
4574 + | )),
|
4575 + | },
|
4576 + | ),
|
4577 + | },
|
4578 + | )),
|
4579 + | }),
|
4594 4580 | };
|
4595 4581 | use ::aws_smithy_http_server::response::IntoResponse;
|
4596 4582 | let http_response = output.into_response();
|
4597 4583 | ::pretty_assertions::assert_eq!(
|
4598 4584 | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4599 4585 | http_response.status()
|
4600 4586 | );
|
4601 4587 | let expected_headers = [
|
4602 4588 | ("Content-Type", "application/cbor"),
|
4603 4589 | ("smithy-protocol", "rpc-v2-cbor"),
|
4604 4590 | ];
|
4605 4591 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4606 4592 | http_response.headers(),
|
4607 4593 | expected_headers,
|
4608 4594 | ));
|
4609 4595 | use ::http_body_util::BodyExt;
|
4610 4596 | let body = http_response
|
4611 4597 | .into_body()
|
4612 4598 | .collect()
|
4613 4599 | .await
|
4614 4600 | .expect("unable to collect body")
|
4615 4601 | .to_bytes();
|
4616 4602 | ::aws_smithy_protocol_test::assert_ok(
|
4617 - | ::aws_smithy_protocol_test::validate_body(&body, "v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4603 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4618 4604 | );
|
4619 4605 | }
|
4606 + | }
|
4620 4607 |
|
4621 - | /// RpcV2 Cbor should not serialize null structure values
|
4622 - | /// Test ID: RpcV2CborServerDoesntSerializeNullStructureValues
|
4623 - | #[::tokio::test]
|
4624 - | #[::tracing_test::traced_test]
|
4625 - | async fn rpc_v2_cbor_server_doesnt_serialize_null_structure_values_response() {
|
4626 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4627 - | string_value: ::std::option::Option::None,
|
4628 - | true_boolean_value: ::std::option::Option::None,
|
4629 - | false_boolean_value: ::std::option::Option::None,
|
4630 - | byte_value: ::std::option::Option::None,
|
4631 - | double_value: ::std::option::Option::None,
|
4632 - | float_value: ::std::option::Option::None,
|
4633 - | integer_value: ::std::option::Option::None,
|
4634 - | long_value: ::std::option::Option::None,
|
4635 - | short_value: ::std::option::Option::None,
|
4636 - | blob_value: ::std::option::Option::None,
|
4608 + | ::pin_project_lite::pin_project! {
|
4609 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4610 + | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
4611 + | pub struct GreetingWithErrorsInputFuture {
|
4612 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GreetingWithErrorsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4613 + | }
|
4614 + | }
|
4615 + |
|
4616 + | impl std::future::Future for GreetingWithErrorsInputFuture {
|
4617 + | type Output = Result<
|
4618 + | crate::input::GreetingWithErrorsInput,
|
4619 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4620 + | >;
|
4621 + |
|
4622 + | fn poll(
|
4623 + | self: std::pin::Pin<&mut Self>,
|
4624 + | cx: &mut std::task::Context<'_>,
|
4625 + | ) -> std::task::Poll<Self::Output> {
|
4626 + | let this = self.project();
|
4627 + | this.inner.as_mut().poll(cx)
|
4628 + | }
|
4629 + | }
|
4630 + |
|
4631 + | impl<B>
|
4632 + | ::aws_smithy_http_server::request::FromRequest<
|
4633 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4634 + | B,
|
4635 + | > for crate::input::GreetingWithErrorsInput
|
4636 + | where
|
4637 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
4638 + | B: 'static,
|
4639 + |
|
4640 + | B::Data: Send,
|
4641 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4642 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
4643 + | {
|
4644 + | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4645 + | type Future = GreetingWithErrorsInputFuture;
|
4646 + |
|
4647 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
4648 + | let fut = async move {
|
4649 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
4650 + | request.headers(),
|
4651 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4652 + | ) {
|
4653 + | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4654 + | }
|
4655 + | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
4656 + | request,
|
4657 + | )
|
4658 + | .await
|
4637 4659 | };
|
4638 - | use ::aws_smithy_http_server::response::IntoResponse;
|
4639 - | let http_response = output.into_response();
|
4640 - | ::pretty_assertions::assert_eq!(
|
4641 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4642 - | http_response.status()
|
4660 + | use ::futures_util::future::TryFutureExt;
|
4661 + | let fut = fut.map_err(
|
4662 + | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4663 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4664 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
4665 + | e,
|
4666 + | )
|
4667 + | },
|
4643 4668 | );
|
4644 - | let expected_headers = [
|
4645 - | ("Content-Type", "application/cbor"),
|
4646 - | ("smithy-protocol", "rpc-v2-cbor"),
|
4647 - | ];
|
4648 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4649 - | http_response.headers(),
|
4650 - | expected_headers,
|
4651 - | ));
|
4652 - | use ::http_body_util::BodyExt;
|
4653 - | let body = http_response
|
4654 - | .into_body()
|
4655 - | .collect()
|
4656 - | .await
|
4657 - | .expect("unable to collect body")
|
4658 - | .to_bytes();
|
4659 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4660 - | &body,
|
4661 - | "v/8=",
|
4662 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4663 - | ));
|
4669 + | GreetingWithErrorsInputFuture {
|
4670 + | inner: Box::pin(fut),
|
4671 + | }
|
4672 + | }
|
4673 + | }
|
4674 + | impl
|
4675 + | ::aws_smithy_http_server::response::IntoResponse<
|
4676 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4677 + | > for crate::output::GreetingWithErrorsOutput
|
4678 + | {
|
4679 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4680 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
4681 + | Ok(response) => response,
|
4682 + | Err(e) => {
|
4683 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4684 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4685 + | }
|
4686 + | }
|
4687 + | }
|
4688 + | }
|
4689 + | impl
|
4690 + | ::aws_smithy_http_server::response::IntoResponse<
|
4691 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4692 + | > for crate::error::GreetingWithErrorsError
|
4693 + | {
|
4694 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4695 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
4696 + | &self,
|
4697 + | ) {
|
4698 + | Ok(mut response) => {
|
4699 + | response.extensions_mut().insert(
|
4700 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
4701 + | );
|
4702 + | response
|
4703 + | }
|
4704 + | Err(e) => {
|
4705 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4706 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4707 + | }
|
4708 + | }
|
4664 4709 | }
|
4710 + | }
|
4665 4711 |
|
4666 - | /// Supports handling NaN float values.
|
4667 - | /// Test ID: RpcV2CborSupportsNaNFloatOutputs
|
4712 + | #[allow(unreachable_code, unused_variables)]
|
4713 + | #[cfg(test)]
|
4714 + | mod greeting_with_errors_test {
|
4715 + |
|
4716 + | /// Parses simple RpcV2 Cbor errors
|
4717 + | /// Test ID: RpcV2CborInvalidGreetingError
|
4668 4718 | #[::tokio::test]
|
4669 4719 | #[::tracing_test::traced_test]
|
4670 - | async fn rpc_v2_cbor_supports_na_n_float_outputs_response() {
|
4671 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4672 - | double_value: ::std::option::Option::Some(
|
4673 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4674 - | .expect("invalid string for number"),
|
4675 - | ),
|
4676 - | float_value: ::std::option::Option::Some(
|
4677 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4678 - | .expect("invalid string for number"),
|
4679 - | ),
|
4680 - | true_boolean_value: ::std::option::Option::None,
|
4681 - | false_boolean_value: ::std::option::Option::None,
|
4682 - | byte_value: ::std::option::Option::None,
|
4683 - | integer_value: ::std::option::Option::None,
|
4684 - | long_value: ::std::option::Option::None,
|
4685 - | short_value: ::std::option::Option::None,
|
4686 - | string_value: ::std::option::Option::None,
|
4687 - | blob_value: ::std::option::Option::None,
|
4720 + | async fn rpc_v2_cbor_invalid_greeting_error_response() {
|
4721 + | let output = crate::error::InvalidGreeting {
|
4722 + | message: ::std::option::Option::Some("Hi".to_owned()),
|
4688 4723 | };
|
4724 + | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
4689 4725 | use ::aws_smithy_http_server::response::IntoResponse;
|
4690 4726 | let http_response = output.into_response();
|
4691 4727 | ::pretty_assertions::assert_eq!(
|
4692 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4728 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4693 4729 | http_response.status()
|
4694 4730 | );
|
4695 4731 | let expected_headers = [
|
4696 4732 | ("Content-Type", "application/cbor"),
|
4697 4733 | ("smithy-protocol", "rpc-v2-cbor"),
|
4698 4734 | ];
|
4699 4735 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4700 4736 | http_response.headers(),
|
4701 4737 | expected_headers,
|
4702 4738 | ));
|
4703 4739 | use ::http_body_util::BodyExt;
|
4704 4740 | let body = http_response
|
4705 4741 | .into_body()
|
4706 4742 | .collect()
|
4707 4743 | .await
|
4708 4744 | .expect("unable to collect body")
|
4709 4745 | .to_bytes();
|
4710 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4711 - | &body,
|
4712 - | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/",
|
4713 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4714 - | ));
|
4746 + | ::aws_smithy_protocol_test::assert_ok(
|
4747 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4748 + | );
|
4715 4749 | }
|
4716 4750 |
|
4717 - | /// Supports handling Infinity float values.
|
4718 - | /// Test ID: RpcV2CborSupportsInfinityFloatOutputs
|
4751 + | /// Parses a complex error with no message member
|
4752 + | /// Test ID: RpcV2CborComplexError
|
4719 4753 | #[::tokio::test]
|
4720 4754 | #[::tracing_test::traced_test]
|
4721 - | async fn rpc_v2_cbor_supports_infinity_float_outputs_response() {
|
4722 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4723 - | double_value: ::std::option::Option::Some(
|
4724 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4725 - | .expect("invalid string for number"),
|
4726 - | ),
|
4727 - | float_value: ::std::option::Option::Some(
|
4728 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4729 - | .expect("invalid string for number"),
|
4730 - | ),
|
4731 - | true_boolean_value: ::std::option::Option::None,
|
4732 - | false_boolean_value: ::std::option::Option::None,
|
4733 - | byte_value: ::std::option::Option::None,
|
4734 - | integer_value: ::std::option::Option::None,
|
4735 - | long_value: ::std::option::Option::None,
|
4736 - | short_value: ::std::option::Option::None,
|
4737 - | string_value: ::std::option::Option::None,
|
4738 - | blob_value: ::std::option::Option::None,
|
4755 + | async fn rpc_v2_cbor_complex_error_response() {
|
4756 + | let output = crate::error::ComplexError {
|
4757 + | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
4758 + | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
4759 + | foo: ::std::option::Option::Some("bar".to_owned()),
|
4760 + | }),
|
4739 4761 | };
|
4762 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
4740 4763 | use ::aws_smithy_http_server::response::IntoResponse;
|
4741 4764 | let http_response = output.into_response();
|
4742 4765 | ::pretty_assertions::assert_eq!(
|
4743 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4766 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4744 4767 | http_response.status()
|
4745 4768 | );
|
4746 4769 | let expected_headers = [
|
4747 4770 | ("Content-Type", "application/cbor"),
|
4748 4771 | ("smithy-protocol", "rpc-v2-cbor"),
|
4749 4772 | ];
|
4750 4773 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4751 4774 | http_response.headers(),
|
4752 4775 | expected_headers,
|
4753 4776 | ));
|
4754 4777 | use ::http_body_util::BodyExt;
|
4755 4778 | let body = http_response
|
4756 4779 | .into_body()
|
4757 4780 | .collect()
|
4758 4781 | .await
|
4759 4782 | .expect("unable to collect body")
|
4760 4783 | .to_bytes();
|
4761 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4762 - | &body,
|
4763 - | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/",
|
4764 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4765 - | ));
|
4766 - | }
|
4767 - |
|
4768 - | /// Supports handling Negative Infinity float values.
|
4769 - | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatOutputs
|
4770 - | #[::tokio::test]
|
4771 - | #[::tracing_test::traced_test]
|
4772 - | async fn rpc_v2_cbor_supports_negative_infinity_float_outputs_response() {
|
4773 - | let output = crate::output::SimpleScalarPropertiesOutput {
|
4774 - | double_value: ::std::option::Option::Some(
|
4775 - | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4776 - | .expect("invalid string for number"),
|
4777 - | ),
|
4778 - | float_value: ::std::option::Option::Some(
|
4779 - | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4780 - | .expect("invalid string for number"),
|
4781 - | ),
|
4782 - | true_boolean_value: ::std::option::Option::None,
|
4783 - | false_boolean_value: ::std::option::Option::None,
|
4784 - | byte_value: ::std::option::Option::None,
|
4785 - | integer_value: ::std::option::Option::None,
|
4786 - | long_value: ::std::option::Option::None,
|
4787 - | short_value: ::std::option::Option::None,
|
4788 - | string_value: ::std::option::Option::None,
|
4789 - | blob_value: ::std::option::Option::None,
|
4784 + | ::aws_smithy_protocol_test::assert_ok(
|
4785 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4786 + | );
|
4787 + | }
|
4788 + | /// Test ID: RpcV2CborEmptyComplexError
|
4789 + | #[::tokio::test]
|
4790 + | #[::tracing_test::traced_test]
|
4791 + | async fn rpc_v2_cbor_empty_complex_error_response() {
|
4792 + | let output = crate::error::ComplexError {
|
4793 + | top_level: ::std::option::Option::None,
|
4794 + | nested: ::std::option::Option::None,
|
4790 4795 | };
|
4796 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
4791 4797 | use ::aws_smithy_http_server::response::IntoResponse;
|
4792 4798 | let http_response = output.into_response();
|
4793 4799 | ::pretty_assertions::assert_eq!(
|
4794 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4800 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4795 4801 | http_response.status()
|
4796 4802 | );
|
4797 4803 | let expected_headers = [
|
4798 4804 | ("Content-Type", "application/cbor"),
|
4799 4805 | ("smithy-protocol", "rpc-v2-cbor"),
|
4800 4806 | ];
|
4801 4807 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4802 4808 | http_response.headers(),
|
4803 4809 | expected_headers,
|
4804 4810 | ));
|
4805 4811 | use ::http_body_util::BodyExt;
|
4806 4812 | let body = http_response
|
4807 4813 | .into_body()
|
4808 4814 | .collect()
|
4809 4815 | .await
|
4810 4816 | .expect("unable to collect body")
|
4811 4817 | .to_bytes();
|
4812 4818 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4813 4819 | &body,
|
4814 - | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/",
|
4820 + | "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/",
|
4815 4821 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4816 4822 | ));
|
4817 4823 | }
|
4818 4824 | }
|
4819 4825 |
|
4820 4826 | ::pin_project_lite::pin_project! {
|
4821 4827 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4822 - | /// [`OptionalInputOutputInput`](crate::input::OptionalInputOutputInput) using modelled bindings.
|
4823 - | pub struct OptionalInputOutputInputFuture {
|
4824 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OptionalInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4828 + | /// [`FractionalSecondsInput`](crate::input::FractionalSecondsInput) using modelled bindings.
|
4829 + | pub struct FractionalSecondsInputFuture {
|
4830 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::FractionalSecondsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4825 4831 | }
|
4826 4832 | }
|
4827 4833 |
|
4828 - | impl std::future::Future for OptionalInputOutputInputFuture {
|
4834 + | impl std::future::Future for FractionalSecondsInputFuture {
|
4829 4835 | type Output = Result<
|
4830 - | crate::input::OptionalInputOutputInput,
|
4836 + | crate::input::FractionalSecondsInput,
|
4831 4837 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4832 4838 | >;
|
4833 4839 |
|
4834 4840 | fn poll(
|
4835 4841 | self: std::pin::Pin<&mut Self>,
|
4836 4842 | cx: &mut std::task::Context<'_>,
|
4837 4843 | ) -> std::task::Poll<Self::Output> {
|
4838 4844 | let this = self.project();
|
4839 4845 | this.inner.as_mut().poll(cx)
|
4840 4846 | }
|
4841 4847 | }
|
4842 4848 |
|
4843 4849 | impl<B>
|
4844 4850 | ::aws_smithy_http_server::request::FromRequest<
|
4845 4851 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4846 4852 | B,
|
4847 - | > for crate::input::OptionalInputOutputInput
|
4853 + | > for crate::input::FractionalSecondsInput
|
4848 4854 | where
|
4849 4855 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
4850 4856 | B: 'static,
|
4851 4857 |
|
4852 4858 | B::Data: Send,
|
4853 4859 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4854 4860 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
4855 4861 | {
|
4856 4862 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4857 - | type Future = OptionalInputOutputInputFuture;
|
4863 + | type Future = FractionalSecondsInputFuture;
|
4858 4864 |
|
4859 4865 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
4860 4866 | let fut = async move {
|
4861 4867 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
4862 4868 | request.headers(),
|
4863 4869 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4864 4870 | ) {
|
4865 4871 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4866 4872 | }
|
4867 - | crate::protocol_serde::shape_optional_input_output::de_optional_input_output_http_request(request)
|
4868 - | .await
|
4873 + | crate::protocol_serde::shape_fractional_seconds::de_fractional_seconds_http_request(
|
4874 + | request,
|
4875 + | )
|
4876 + | .await
|
4869 4877 | };
|
4870 4878 | use ::futures_util::future::TryFutureExt;
|
4871 4879 | let fut = fut.map_err(
|
4872 4880 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4873 4881 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4874 4882 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
4875 4883 | e,
|
4876 4884 | )
|
4877 4885 | },
|
4878 4886 | );
|
4879 - | OptionalInputOutputInputFuture {
|
4887 + | FractionalSecondsInputFuture {
|
4880 4888 | inner: Box::pin(fut),
|
4881 4889 | }
|
4882 4890 | }
|
4883 4891 | }
|
4884 4892 | impl
|
4885 4893 | ::aws_smithy_http_server::response::IntoResponse<
|
4886 4894 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4887 - | > for crate::output::OptionalInputOutputOutput
|
4895 + | > for crate::output::FractionalSecondsOutput
|
4888 4896 | {
|
4889 4897 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4890 - | match crate::protocol_serde::shape_optional_input_output::ser_optional_input_output_http_response(self) {
|
4891 - | Ok(response) => response,
|
4892 - | Err(e) => {
|
4893 - | ::tracing::error!(error = %e, "failed to serialize response");
|
4894 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4895 - | }
|
4896 - | }
|
4897 - | }
|
4898 - | }
|
4899 - |
|
4900 - | #[allow(unreachable_code, unused_variables)]
|
4901 - | #[cfg(test)]
|
4902 - | mod optional_input_output_test {
|
4903 - |
|
4904 - | /// When input is empty we write CBOR equivalent of {}
|
4905 - | /// Test ID: optional_input
|
4906 - | #[::tokio::test]
|
4907 - | #[::tracing_test::traced_test]
|
4908 - | async fn optional_input_request() {
|
4909 - | #[allow(unused_mut)]
|
4910 - | let mut http_request = ::http_1x::Request::builder()
|
4911 - | .uri("/service/RpcV2Protocol/operation/OptionalInputOutput")
|
4912 - | .method("POST")
|
4913 - | .header("Accept", "application/cbor")
|
4914 - | .header("Content-Type", "application/cbor")
|
4915 - | .header("smithy-protocol", "rpc-v2-cbor")
|
4916 - | .body(::aws_smithy_http_server::body::boxed(
|
4917 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4918 - | &::aws_smithy_protocol_test::decode_body_data(
|
4919 - | "v/8=".as_bytes(),
|
4920 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4921 - | ),
|
4922 - | )),
|
4923 - | ))
|
4924 - | .unwrap();
|
4925 - | #[allow(unused_mut)]
|
4926 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4927 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4928 - | let service = crate::service::RpcV2Protocol::builder::<
|
4929 - | ::aws_smithy_http_server::body::BoxBody,
|
4930 - | _,
|
4931 - | _,
|
4932 - | _,
|
4933 - | >(config)
|
4934 - | .optional_input_output(move |input: crate::input::OptionalInputOutputInput| {
|
4935 - | let sender = sender.clone();
|
4936 - | async move {
|
4937 - | let result = {
|
4938 - | let expected = crate::input::OptionalInputOutputInput {
|
4939 - | value: ::std::option::Option::None,
|
4940 - | };
|
4941 - | ::pretty_assertions::assert_eq!(input, expected);
|
4942 - | let output = crate::output::OptionalInputOutputOutput {
|
4943 - | value: ::std::option::Option::None,
|
4944 - | };
|
4945 - | output
|
4946 - | };
|
4947 - | sender.send(()).await.expect("receiver dropped early");
|
4948 - | result
|
4898 + | match crate::protocol_serde::shape_fractional_seconds::ser_fractional_seconds_http_response(
|
4899 + | self,
|
4900 + | ) {
|
4901 + | Ok(response) => response,
|
4902 + | Err(e) => {
|
4903 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4904 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4949 4905 | }
|
4950 - | })
|
4951 - | .build_unchecked();
|
4952 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4953 - | .await
|
4954 - | .expect("unable to make an HTTP request");
|
4955 - | assert!(
|
4956 - | receiver.recv().await.is_some(),
|
4957 - | "we expected operation handler to be invoked but it was not entered"
|
4958 - | );
|
4959 - | }
|
4960 - |
|
4961 - | /// When output is empty we write CBOR equivalent of {}
|
4962 - | /// Test ID: optional_output
|
4963 - | #[::tokio::test]
|
4964 - | #[::tracing_test::traced_test]
|
4965 - | async fn optional_output_response() {
|
4966 - | let output = crate::output::OptionalInputOutputOutput {
|
4967 - | value: ::std::option::Option::None,
|
4968 - | };
|
4969 - | use ::aws_smithy_http_server::response::IntoResponse;
|
4970 - | let http_response = output.into_response();
|
4971 - | ::pretty_assertions::assert_eq!(
|
4972 - | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4973 - | http_response.status()
|
4974 - | );
|
4975 - | let expected_headers = [
|
4976 - | ("Content-Type", "application/cbor"),
|
4977 - | ("smithy-protocol", "rpc-v2-cbor"),
|
4978 - | ];
|
4979 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4980 - | http_response.headers(),
|
4981 - | expected_headers,
|
4982 - | ));
|
4983 - | use ::http_body_util::BodyExt;
|
4984 - | let body = http_response
|
4985 - | .into_body()
|
4986 - | .collect()
|
4987 - | .await
|
4988 - | .expect("unable to collect body")
|
4989 - | .to_bytes();
|
4990 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4991 - | &body,
|
4992 - | "v/8=",
|
4993 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4994 - | ));
|
4906 + | }
|
4995 4907 | }
|
4996 4908 | }
|
4997 4909 |
|
4998 4910 | ::pin_project_lite::pin_project! {
|
4999 4911 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5000 - | /// [`EmptyInputOutputInput`](crate::input::EmptyInputOutputInput) using modelled bindings.
|
5001 - | pub struct EmptyInputOutputInputFuture {
|
5002 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4912 + | /// [`OperationWithDefaultsInput`](crate::input::OperationWithDefaultsInput) using modelled bindings.
|
4913 + | pub struct OperationWithDefaultsInputFuture {
|
4914 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithDefaultsInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5003 4915 | }
|
5004 4916 | }
|
5005 4917 |
|
5006 - | impl std::future::Future for EmptyInputOutputInputFuture {
|
4918 + | impl std::future::Future for OperationWithDefaultsInputFuture {
|
5007 4919 | type Output = Result<
|
5008 - | crate::input::EmptyInputOutputInput,
|
4920 + | crate::input::OperationWithDefaultsInput,
|
5009 4921 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
5010 4922 | >;
|
5011 4923 |
|
5012 4924 | fn poll(
|
5013 4925 | self: std::pin::Pin<&mut Self>,
|
5014 4926 | cx: &mut std::task::Context<'_>,
|
5015 4927 | ) -> std::task::Poll<Self::Output> {
|
5016 4928 | let this = self.project();
|
5017 4929 | this.inner.as_mut().poll(cx)
|
5018 4930 | }
|
5019 4931 | }
|
5020 4932 |
|
5021 4933 | impl<B>
|
5022 4934 | ::aws_smithy_http_server::request::FromRequest<
|
5023 4935 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5024 4936 | B,
|
5025 - | > for crate::input::EmptyInputOutputInput
|
4937 + | > for crate::input::OperationWithDefaultsInput
|
5026 4938 | where
|
5027 4939 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5028 4940 | B: 'static,
|
5029 4941 |
|
5030 4942 | B::Data: Send,
|
5031 4943 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
5032 4944 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5033 4945 | {
|
5034 4946 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
5035 - | type Future = EmptyInputOutputInputFuture;
|
4947 + | type Future = OperationWithDefaultsInputFuture;
|
5036 4948 |
|
5037 4949 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5038 4950 | let fut = async move {
|
5039 4951 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5040 4952 | request.headers(),
|
5041 4953 | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
5042 4954 | ) {
|
5043 4955 | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
5044 4956 | }
|
5045 - | crate::protocol_serde::shape_empty_input_output::de_empty_input_output_http_request(
|
5046 - | request,
|
5047 - | )
|
5048 - | .await
|
4957 + | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_request(request)
|
4958 + | .await
|
5049 4959 | };
|
5050 4960 | use ::futures_util::future::TryFutureExt;
|
5051 4961 | let fut = fut.map_err(
|
5052 - | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
5053 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5054 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
5055 - | e,
|
5056 - | )
|
5057 - | },
|
5058 - | );
|
5059 - | EmptyInputOutputInputFuture {
|
5060 - | inner: Box::pin(fut),
|
5061 - | }
|
5062 - | }
|
5063 - | }
|
5064 - | impl
|
5065 - | ::aws_smithy_http_server::response::IntoResponse<
|
5066 - | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5067 - | > for crate::output::EmptyInputOutputOutput
|
5068 - | {
|
5069 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5070 - | match crate::protocol_serde::shape_empty_input_output::ser_empty_input_output_http_response(
|
5071 - | self,
|
5072 - | ) {
|
5073 - | Ok(response) => response,
|
5074 - | Err(e) => {
|
5075 - | ::tracing::error!(error = %e, "failed to serialize response");
|
5076 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5077 - | }
|
5078 - | }
|
5079 - | }
|
5080 - | }
|
5081 - |
|
5082 - | #[allow(unreachable_code, unused_variables)]
|
5083 - | #[cfg(test)]
|
5084 - | mod empty_input_output_test {
|
5085 - |
|
5086 - | /// When Input structure is empty we write CBOR equivalent of {}
|
5087 - | /// Test ID: empty_input
|
5088 - | #[::tokio::test]
|
5089 - | #[::tracing_test::traced_test]
|
5090 - | async fn empty_input_request() {
|
5091 - | #[allow(unused_mut)]
|
5092 - | let mut http_request = ::http_1x::Request::builder()
|
5093 - | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
5094 - | .method("POST")
|
5095 - | .header("Accept", "application/cbor")
|
5096 - | .header("Content-Type", "application/cbor")
|
5097 - | .header("smithy-protocol", "rpc-v2-cbor")
|
5098 - | .body(::aws_smithy_http_server::body::boxed(
|
5099 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5100 - | &::aws_smithy_protocol_test::decode_body_data(
|
5101 - | "v/8=".as_bytes(),
|
5102 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5103 - | ),
|
5104 - | )),
|
5105 - | ))
|
5106 - | .unwrap();
|
5107 - | #[allow(unused_mut)]
|
5108 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5109 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5110 - | let service = crate::service::RpcV2Protocol::builder::<
|
5111 - | ::aws_smithy_http_server::body::BoxBody,
|
5112 - | _,
|
5113 - | _,
|
5114 - | _,
|
5115 - | >(config)
|
5116 - | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
5117 - | let sender = sender.clone();
|
5118 - | async move {
|
5119 - | let result = {
|
5120 - | let expected = crate::input::EmptyInputOutputInput {};
|
5121 - | ::pretty_assertions::assert_eq!(input, expected);
|
5122 - | let output = crate::output::EmptyInputOutputOutput {};
|
5123 - | output
|
5124 - | };
|
5125 - | sender.send(()).await.expect("receiver dropped early");
|
5126 - | result
|
5127 - | }
|
5128 - | })
|
5129 - | .build_unchecked();
|
5130 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5131 - | .await
|
5132 - | .expect("unable to make an HTTP request");
|
5133 - | assert!(
|
5134 - | receiver.recv().await.is_some(),
|
5135 - | "we expected operation handler to be invoked but it was not entered"
|
4962 + | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4963 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4964 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
4965 + | e,
|
4966 + | )
|
4967 + | },
|
5136 4968 | );
|
4969 + | OperationWithDefaultsInputFuture {
|
4970 + | inner: Box::pin(fut),
|
4971 + | }
|
5137 4972 | }
|
5138 - |
|
5139 - | /// When Input structure is empty the server should accept an empty body
|
5140 - | /// Test ID: empty_input_no_body
|
5141 - | #[::tokio::test]
|
5142 - | #[::tracing_test::traced_test]
|
5143 - | async fn empty_input_no_body_request() {
|
5144 - | #[allow(unused_mut)]
|
5145 - | let mut http_request = ::http_1x::Request::builder()
|
5146 - | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
5147 - | .method("POST")
|
5148 - | .header("Accept", "application/cbor")
|
5149 - | .header("Content-Type", "application/cbor")
|
5150 - | .header("smithy-protocol", "rpc-v2-cbor")
|
5151 - | .body(::aws_smithy_http_server::body::boxed(
|
5152 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5153 - | &::aws_smithy_protocol_test::decode_body_data(
|
5154 - | "".as_bytes(),
|
5155 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5156 - | ),
|
5157 - | )),
|
5158 - | ))
|
5159 - | .unwrap();
|
5160 - | #[allow(unused_mut)]
|
5161 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5162 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5163 - | let service = crate::service::RpcV2Protocol::builder::<
|
5164 - | ::aws_smithy_http_server::body::BoxBody,
|
5165 - | _,
|
5166 - | _,
|
5167 - | _,
|
5168 - | >(config)
|
5169 - | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
5170 - | let sender = sender.clone();
|
5171 - | async move {
|
5172 - | let result = {
|
5173 - | let expected = crate::input::EmptyInputOutputInput {};
|
5174 - | ::pretty_assertions::assert_eq!(input, expected);
|
5175 - | let output = crate::output::EmptyInputOutputOutput {};
|
5176 - | output
|
5177 - | };
|
5178 - | sender.send(()).await.expect("receiver dropped early");
|
5179 - | result
|
4973 + | }
|
4974 + | impl
|
4975 + | ::aws_smithy_http_server::response::IntoResponse<
|
4976 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4977 + | > for crate::output::OperationWithDefaultsOutput
|
4978 + | {
|
4979 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4980 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_response(self) {
|
4981 + | Ok(response) => response,
|
4982 + | Err(e) => {
|
4983 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4984 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4985 + | }
|
4986 + | }
|
4987 + | }
|
4988 + | }
|
4989 + | impl
|
4990 + | ::aws_smithy_http_server::response::IntoResponse<
|
4991 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4992 + | > for crate::error::OperationWithDefaultsError
|
4993 + | {
|
4994 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4995 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_error(&self) {
|
4996 + | Ok(mut response) => {
|
4997 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
4998 + | response
|
4999 + | },
|
5000 + | Err(e) => {
|
5001 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5002 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5180 5003 | }
|
5181 - | })
|
5182 - | .build_unchecked();
|
5183 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5184 - | .await
|
5185 - | .expect("unable to make an HTTP request");
|
5186 - | assert!(
|
5187 - | receiver.recv().await.is_some(),
|
5188 - | "we expected operation handler to be invoked but it was not entered"
|
5189 - | );
|
5004 + | }
|
5190 5005 | }
|
5006 + | }
|
5191 5007 |
|
5192 - | /// When input structure, is empty the server should accept an empty body
|
5193 - | /// even if the Accept header is set.
|
5194 - | /// Test ID: empty_input_no_body_has_accept
|
5008 + | #[allow(unreachable_code, unused_variables)]
|
5009 + | #[cfg(test)]
|
5010 + | mod operation_with_defaults_test {
|
5011 + |
|
5012 + | /// Server populates default values when missing in request body.
|
5013 + | /// Test ID: RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody
|
5195 5014 | #[::tokio::test]
|
5196 5015 | #[::tracing_test::traced_test]
|
5197 - | async fn empty_input_no_body_has_accept_request() {
|
5016 + | #[should_panic]
|
5017 + | async fn rpc_v2_cbor_server_populates_defaults_when_missing_in_request_body_request() {
|
5198 5018 | #[allow(unused_mut)]
|
5199 5019 | let mut http_request = ::http_1x::Request::builder()
|
5200 - | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
5020 + | .uri("/service/RpcV2Protocol/operation/OperationWithDefaults")
|
5201 5021 | .method("POST")
|
5202 5022 | .header("Accept", "application/cbor")
|
5203 5023 | .header("Content-Type", "application/cbor")
|
5204 5024 | .header("smithy-protocol", "rpc-v2-cbor")
|
5205 5025 | .body(::aws_smithy_http_server::body::boxed(
|
5206 5026 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5207 5027 | &::aws_smithy_protocol_test::decode_body_data(
|
5208 - | "".as_bytes(),
|
5028 + | "v2hkZWZhdWx0c6D/".as_bytes(),
|
5209 5029 | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5210 5030 | ),
|
5211 5031 | )),
|
5212 5032 | ))
|
5213 5033 | .unwrap();
|
5214 5034 | #[allow(unused_mut)]
|
5215 5035 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5216 5036 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5217 5037 | let service = crate::service::RpcV2Protocol::builder::<
|
5218 5038 | ::aws_smithy_http_server::body::BoxBody,
|
5219 5039 | _,
|
5220 5040 | _,
|
5221 5041 | _,
|
5222 5042 | >(config)
|
5223 - | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
5043 + | .operation_with_defaults(move |input: crate::input::OperationWithDefaultsInput| {
|
5224 5044 | let sender = sender.clone();
|
5225 5045 | async move {
|
5226 5046 | let result = {
|
5227 - | let expected = crate::input::EmptyInputOutputInput {};
|
5047 + | let expected = crate::input::OperationWithDefaultsInput {
|
5048 + | defaults: ::std::option::Option::Some(crate::model::Defaults {
|
5049 + | default_string: "hi".to_owned(),
|
5050 + | default_boolean: true,
|
5051 + | default_list: vec![],
|
5052 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
5053 + | 0, 0_f64,
|
5054 + | ),
|
5055 + | default_blob: ::aws_smithy_types::Blob::new("abc"),
|
5056 + | default_byte: 1,
|
5057 + | default_short: 1,
|
5058 + | default_integer: 10,
|
5059 + | default_long: 100,
|
5060 + | default_float: 1.0_f32,
|
5061 + | default_double: 1.0_f64,
|
5062 + | default_map: ::std::collections::HashMap::new(),
|
5063 + | default_enum: "FOO"
|
5064 + | .parse::<crate::model::TestEnum>()
|
5065 + | .expect("static value validated to member"),
|
5066 + | default_int_enum: 1,
|
5067 + | empty_string: "".to_owned(),
|
5068 + | false_boolean: false,
|
5069 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
5070 + | zero_byte: 0,
|
5071 + | zero_short: 0,
|
5072 + | zero_integer: 0,
|
5073 + | zero_long: 0,
|
5074 + | zero_float: 0.0_f32,
|
5075 + | zero_double: 0.0_f64,
|
5076 + | }),
|
5077 + | top_level_default: "hi".to_owned(),
|
5078 + | other_top_level_default: 0,
|
5079 + | client_optional_defaults: ::std::option::Option::None,
|
5080 + | };
|
5228 5081 | ::pretty_assertions::assert_eq!(input, expected);
|
5229 - | let output = crate::output::EmptyInputOutputOutput {};
|
5230 - | output
|
5082 + | let output = crate::output::OperationWithDefaultsOutput {
|
5083 + | default_string: "".to_owned(),
|
5084 + | default_boolean: false,
|
5085 + | default_list: vec![],
|
5086 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
5087 + | 0, 0_f64,
|
5088 + | ),
|
5089 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
5090 + | default_byte: 0,
|
5091 + | default_short: 0,
|
5092 + | default_integer: 0,
|
5093 + | default_long: 0,
|
5094 + | default_float: 0_f32,
|
5095 + | default_double: 0_f64,
|
5096 + | default_map: ::std::collections::HashMap::new(),
|
5097 + | default_enum: ""
|
5098 + | .parse::<crate::model::TestEnum>()
|
5099 + | .expect("static value validated to member"),
|
5100 + | default_int_enum: 0,
|
5101 + | empty_string: "".to_owned(),
|
5102 + | false_boolean: false,
|
5103 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
5104 + | zero_byte: 0,
|
5105 + | zero_short: 0,
|
5106 + | zero_integer: 0,
|
5107 + | zero_long: 0,
|
5108 + | zero_float: 0_f32,
|
5109 + | zero_double: 0_f64,
|
5110 + | };
|
5111 + | Ok(output)
|
5231 5112 | };
|
5232 5113 | sender.send(()).await.expect("receiver dropped early");
|
5233 5114 | result
|
5234 5115 | }
|
5235 5116 | })
|
5236 5117 | .build_unchecked();
|
5237 5118 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5238 5119 | .await
|
5239 5120 | .expect("unable to make an HTTP request");
|
5240 5121 | assert!(
|
5241 5122 | receiver.recv().await.is_some(),
|
5242 5123 | "we expected operation handler to be invoked but it was not entered"
|
5243 5124 | );
|
5244 5125 | }
|
5245 5126 |
|
5246 - | /// When output structure is empty we write CBOR equivalent of {}
|
5247 - | /// Test ID: empty_output
|
5127 + | /// Server populates default values in response when missing in params.
|
5128 + | /// Test ID: RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams
|
5248 5129 | #[::tokio::test]
|
5249 5130 | #[::tracing_test::traced_test]
|
5250 - | async fn empty_output_response() {
|
5251 - | let output = crate::output::EmptyInputOutputOutput {};
|
5131 + | #[should_panic]
|
5132 + | async fn rpc_v2_cbor_server_populates_defaults_in_response_when_missing_in_params_response() {
|
5133 + | let output = crate::output::OperationWithDefaultsOutput {
|
5134 + | default_string: "".to_owned(),
|
5135 + | default_boolean: false,
|
5136 + | default_list: vec![],
|
5137 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64),
|
5138 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
5139 + | default_byte: 0,
|
5140 + | default_short: 0,
|
5141 + | default_integer: 0,
|
5142 + | default_long: 0,
|
5143 + | default_float: 0_f32,
|
5144 + | default_double: 0_f64,
|
5145 + | default_map: ::std::collections::HashMap::new(),
|
5146 + | default_enum: ""
|
5147 + | .parse::<crate::model::TestEnum>()
|
5148 + | .expect("static value validated to member"),
|
5149 + | default_int_enum: 0,
|
5150 + | empty_string: "".to_owned(),
|
5151 + | false_boolean: false,
|
5152 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
5153 + | zero_byte: 0,
|
5154 + | zero_short: 0,
|
5155 + | zero_integer: 0,
|
5156 + | zero_long: 0,
|
5157 + | zero_float: 0_f32,
|
5158 + | zero_double: 0_f64,
|
5159 + | };
|
5252 5160 | use ::aws_smithy_http_server::response::IntoResponse;
|
5253 5161 | let http_response = output.into_response();
|
5254 5162 | ::pretty_assertions::assert_eq!(
|
5255 5163 | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5256 5164 | http_response.status()
|
5257 5165 | );
|
5258 5166 | let expected_headers = [
|
5259 5167 | ("Content-Type", "application/cbor"),
|
5260 5168 | ("smithy-protocol", "rpc-v2-cbor"),
|
5261 5169 | ];
|
5262 5170 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5263 5171 | http_response.headers(),
|
5264 5172 | expected_headers,
|
5265 5173 | ));
|
5266 5174 | use ::http_body_util::BodyExt;
|
5267 5175 | let body = http_response
|
5268 5176 | .into_body()
|
5269 5177 | .collect()
|
5270 5178 | .await
|
5271 5179 | .expect("unable to collect body")
|
5272 5180 | .to_bytes();
|
5273 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5274 - | &body,
|
5275 - | "v/8=",
|
5276 - | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5277 - | ));
|
5181 + | ::aws_smithy_protocol_test::assert_ok(
|
5182 + | ::aws_smithy_protocol_test::validate_body(&body, "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
5183 + | );
|
5278 5184 | }
|
5279 5185 | }
|
5280 5186 |
|
5281 5187 | ::pin_project_lite::pin_project! {
|
5282 5188 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5283 - | /// [`NoInputOutputInput`](crate::input::NoInputOutputInput) using modelled bindings.
|
5284 - | pub struct NoInputOutputInputFuture {
|
5285 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NoInputOutputInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5189 + | /// [`SparseNullsOperationInput`](crate::input::SparseNullsOperationInput) using modelled bindings.
|
5190 + | pub struct SparseNullsOperationInputFuture {
|
5191 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SparseNullsOperationInput, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5286 5192 | }
|
5287 5193 | }
|
5288 5194 |
|
5289 - | impl std::future::Future for NoInputOutputInputFuture {
|
5195 + | impl std::future::Future for SparseNullsOperationInputFuture {
|
5290 5196 | type Output = Result<
|
5291 - | crate::input::NoInputOutputInput,
|
5197 + | crate::input::SparseNullsOperationInput,
|
5292 5198 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
5293 5199 | >;
|
5294 5200 |
|
5295 5201 | fn poll(
|
5296 5202 | self: std::pin::Pin<&mut Self>,
|
5297 5203 | cx: &mut std::task::Context<'_>,
|
5298 5204 | ) -> std::task::Poll<Self::Output> {
|
5299 5205 | let this = self.project();
|
5300 5206 | this.inner.as_mut().poll(cx)
|
5301 5207 | }
|
5302 5208 | }
|
5303 5209 |
|
5304 5210 | impl<B>
|
5305 5211 | ::aws_smithy_http_server::request::FromRequest<
|
5306 5212 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5307 5213 | B,
|
5308 - | > for crate::input::NoInputOutputInput
|
5214 + | > for crate::input::SparseNullsOperationInput
|
5309 5215 | where
|
5310 5216 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5311 5217 | B: 'static,
|
5312 5218 |
|
5313 5219 | B::Data: Send,
|
5314 5220 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
5315 5221 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5316 5222 | {
|
5317 5223 | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
5318 - | type Future = NoInputOutputInputFuture;
|
5224 + | type Future = SparseNullsOperationInputFuture;
|
5319 5225 |
|
5320 5226 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5321 5227 | let fut = async move {
|
5322 - | crate::protocol_serde::shape_no_input_output::de_no_input_output_http_request(request)
|
5323 - | .await
|
5228 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5229 + | request.headers(),
|
5230 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
5231 + | ) {
|
5232 + | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
5233 + | }
|
5234 + | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
5235 + | .await
|
5324 5236 | };
|
5325 5237 | use ::futures_util::future::TryFutureExt;
|
5326 5238 | let fut = fut.map_err(
|
5327 5239 | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
5328 5240 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5329 5241 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
5330 5242 | e,
|
5331 5243 | )
|
5332 5244 | },
|
5333 5245 | );
|
5334 - | NoInputOutputInputFuture {
|
5246 + | SparseNullsOperationInputFuture {
|
5335 5247 | inner: Box::pin(fut),
|
5336 5248 | }
|
5337 5249 | }
|
5338 5250 | }
|
5339 5251 | impl
|
5340 5252 | ::aws_smithy_http_server::response::IntoResponse<
|
5341 5253 | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5342 - | > for crate::output::NoInputOutputOutput
|
5254 + | > for crate::output::SparseNullsOperationOutput
|
5343 5255 | {
|
5344 5256 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5345 - | match crate::protocol_serde::shape_no_input_output::ser_no_input_output_http_response(self)
|
5346 - | {
|
5347 - | Ok(response) => response,
|
5348 - | Err(e) => {
|
5349 - | ::tracing::error!(error = %e, "failed to serialize response");
|
5350 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5351 - | }
|
5352 - | }
|
5257 + | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
5258 + | Ok(response) => response,
|
5259 + | Err(e) => {
|
5260 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5261 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5262 + | }
|
5263 + | }
|
5353 5264 | }
|
5354 5265 | }
|
5355 5266 |
|
5356 5267 | #[allow(unreachable_code, unused_variables)]
|
5357 5268 | #[cfg(test)]
|
5358 - | mod no_input_output_test {
|
5269 + | mod sparse_nulls_operation_test {
|
5359 5270 |
|
5360 - | /// Body is empty and no Content-Type header if no input
|
5361 - | /// Test ID: no_input
|
5271 + | /// Serializes null values in maps
|
5272 + | /// Test ID: RpcV2CborSparseMapsSerializeNullValues
|
5362 5273 | #[::tokio::test]
|
5363 5274 | #[::tracing_test::traced_test]
|
5364 - | async fn no_input_request() {
|
5275 + | async fn rpc_v2_cbor_sparse_maps_serialize_null_values_request() {
|
5365 5276 | #[allow(unused_mut)]
|
5366 5277 | let mut http_request = ::http_1x::Request::builder()
|
5367 - | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5278 + | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
5368 5279 | .method("POST")
|
5369 5280 | .header("Accept", "application/cbor")
|
5281 + | .header("Content-Type", "application/cbor")
|
5370 5282 | .header("smithy-protocol", "rpc-v2-cbor")
|
5371 5283 | .body(::aws_smithy_http_server::body::boxed(
|
5372 5284 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5373 5285 | &::aws_smithy_protocol_test::decode_body_data(
|
5374 - | "".as_bytes(),
|
5375 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5286 + | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==".as_bytes(),
|
5287 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5376 5288 | ),
|
5377 5289 | )),
|
5378 5290 | ))
|
5379 5291 | .unwrap();
|
5380 5292 | #[allow(unused_mut)]
|
5381 5293 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5382 5294 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5383 5295 | let service = crate::service::RpcV2Protocol::builder::<
|
5384 5296 | ::aws_smithy_http_server::body::BoxBody,
|
5385 5297 | _,
|
5386 5298 | _,
|
5387 5299 | _,
|
5388 5300 | >(config)
|
5389 - | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5301 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
5390 5302 | let sender = sender.clone();
|
5391 5303 | async move {
|
5392 5304 | let result = {
|
5393 - | let expected = crate::input::NoInputOutputInput {};
|
5305 + | let expected = crate::input::SparseNullsOperationInput {
|
5306 + | sparse_string_map: ::std::option::Option::Some({
|
5307 + | let mut ret = ::std::collections::HashMap::new();
|
5308 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
5309 + | ret
|
5310 + | }),
|
5311 + | sparse_string_list: ::std::option::Option::None,
|
5312 + | };
|
5394 5313 | ::pretty_assertions::assert_eq!(input, expected);
|
5395 - | let output = crate::output::NoInputOutputOutput {};
|
5314 + | let output = crate::output::SparseNullsOperationOutput {
|
5315 + | sparse_string_list: ::std::option::Option::None,
|
5316 + | sparse_string_map: ::std::option::Option::None,
|
5317 + | };
|
5396 5318 | output
|
5397 5319 | };
|
5398 5320 | sender.send(()).await.expect("receiver dropped early");
|
5399 5321 | result
|
5400 5322 | }
|
5401 5323 | })
|
5402 5324 | .build_unchecked();
|
5403 5325 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5404 5326 | .await
|
5405 5327 | .expect("unable to make an HTTP request");
|
5406 5328 | assert!(
|
5407 5329 | receiver.recv().await.is_some(),
|
5408 5330 | "we expected operation handler to be invoked but it was not entered"
|
5409 5331 | );
|
5410 5332 | }
|
5411 5333 |
|
5412 - | /// Servers should accept CBOR empty struct if no input.
|
5413 - | /// Test ID: NoInputServerAllowsEmptyCbor
|
5334 + | /// Serializes null values in lists
|
5335 + | /// Test ID: RpcV2CborSparseListsSerializeNull
|
5414 5336 | #[::tokio::test]
|
5415 5337 | #[::tracing_test::traced_test]
|
5416 - | async fn no_input_server_allows_empty_cbor_request() {
|
5338 + | async fn rpc_v2_cbor_sparse_lists_serialize_null_request() {
|
5417 5339 | #[allow(unused_mut)]
|
5418 5340 | let mut http_request = ::http_1x::Request::builder()
|
5419 - | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5341 + | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
5420 5342 | .method("POST")
|
5421 5343 | .header("Accept", "application/cbor")
|
5422 5344 | .header("Content-Type", "application/cbor")
|
5423 5345 | .header("smithy-protocol", "rpc-v2-cbor")
|
5424 5346 | .body(::aws_smithy_http_server::body::boxed(
|
5425 5347 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5426 5348 | &::aws_smithy_protocol_test::decode_body_data(
|
5427 - | "v/8=".as_bytes(),
|
5428 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5349 + | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==".as_bytes(),
|
5350 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5429 5351 | ),
|
5430 5352 | )),
|
5431 5353 | ))
|
5432 5354 | .unwrap();
|
5433 5355 | #[allow(unused_mut)]
|
5434 5356 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5435 5357 | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5436 5358 | let service = crate::service::RpcV2Protocol::builder::<
|
5437 5359 | ::aws_smithy_http_server::body::BoxBody,
|
5438 5360 | _,
|
5439 5361 | _,
|
5440 5362 | _,
|
5441 5363 | >(config)
|
5442 - | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5364 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
5443 5365 | let sender = sender.clone();
|
5444 5366 | async move {
|
5445 5367 | let result = {
|
5446 - | let expected = crate::input::NoInputOutputInput {};
|
5368 + | let expected = crate::input::SparseNullsOperationInput {
|
5369 + | sparse_string_list: ::std::option::Option::Some(vec![
|
5370 + | ::std::option::Option::None,
|
5371 + | ]),
|
5372 + | sparse_string_map: ::std::option::Option::None,
|
5373 + | };
|
5447 5374 | ::pretty_assertions::assert_eq!(input, expected);
|
5448 - | let output = crate::output::NoInputOutputOutput {};
|
5375 + | let output = crate::output::SparseNullsOperationOutput {
|
5376 + | sparse_string_list: ::std::option::Option::None,
|
5377 + | sparse_string_map: ::std::option::Option::None,
|
5378 + | };
|
5449 5379 | output
|
5450 5380 | };
|
5451 5381 | sender.send(()).await.expect("receiver dropped early");
|
5452 5382 | result
|
5453 5383 | }
|
5454 5384 | })
|
5455 5385 | .build_unchecked();
|
5456 5386 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5457 5387 | .await
|
5458 5388 | .expect("unable to make an HTTP request");
|
5459 5389 | assert!(
|
5460 5390 | receiver.recv().await.is_some(),
|
5461 5391 | "we expected operation handler to be invoked but it was not entered"
|
5462 5392 | );
|
5463 5393 | }
|
5464 5394 |
|
5465 - | /// Servers should accept an empty body if there is no input. Additionally,
|
5466 - | /// they should not raise an error if the `Accept` header is set.
|
5467 - | /// Test ID: NoInputServerAllowsEmptyBody
|
5395 + | /// Deserializes null values in maps
|
5396 + | /// Test ID: RpcV2CborSparseMapsDeserializeNullValues
|
5468 5397 | #[::tokio::test]
|
5469 5398 | #[::tracing_test::traced_test]
|
5470 - | async fn no_input_server_allows_empty_body_request() {
|
5471 - | #[allow(unused_mut)]
|
5472 - | let mut http_request = ::http_1x::Request::builder()
|
5473 - | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5474 - | .method("POST")
|
5475 - | .header("Accept", "application/cbor")
|
5476 - | .header("Content-Type", "application/cbor")
|
5477 - | .header("smithy-protocol", "rpc-v2-cbor")
|
5478 - | .body(::aws_smithy_http_server::body::boxed(
|
5479 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5480 - | &::aws_smithy_protocol_test::decode_body_data(
|
5481 - | "".as_bytes(),
|
5482 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5483 - | ),
|
5484 - | )),
|
5485 - | ))
|
5486 - | .unwrap();
|
5487 - | #[allow(unused_mut)]
|
5488 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5489 - | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5490 - | let service = crate::service::RpcV2Protocol::builder::<
|
5491 - | ::aws_smithy_http_server::body::BoxBody,
|
5492 - | _,
|
5493 - | _,
|
5494 - | _,
|
5495 - | >(config)
|
5496 - | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5497 - | let sender = sender.clone();
|
5498 - | async move {
|
5499 - | let result = {
|
5500 - | let expected = crate::input::NoInputOutputInput {};
|
5501 - | ::pretty_assertions::assert_eq!(input, expected);
|
5502 - | let output = crate::output::NoInputOutputOutput {};
|
5503 - | output
|
5504 - | };
|
5505 - | sender.send(()).await.expect("receiver dropped early");
|
5506 - | result
|
5507 - | }
|
5508 - | })
|
5509 - | .build_unchecked();
|
5510 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5511 - | .await
|
5512 - | .expect("unable to make an HTTP request");
|
5513 - | assert!(
|
5514 - | receiver.recv().await.is_some(),
|
5515 - | "we expected operation handler to be invoked but it was not entered"
|
5399 + | async fn rpc_v2_cbor_sparse_maps_deserialize_null_values_response() {
|
5400 + | let output = crate::output::SparseNullsOperationOutput {
|
5401 + | sparse_string_map: ::std::option::Option::Some({
|
5402 + | let mut ret = ::std::collections::HashMap::new();
|
5403 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
5404 + | ret
|
5405 + | }),
|
5406 + | sparse_string_list: ::std::option::Option::None,
|
5407 + | };
|
5408 + | use ::aws_smithy_http_server::response::IntoResponse;
|
5409 + | let http_response = output.into_response();
|
5410 + | ::pretty_assertions::assert_eq!(
|
5411 + | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5412 + | http_response.status()
|
5516 5413 | );
|
5414 + | let expected_headers = [
|
5415 + | ("Content-Type", "application/cbor"),
|
5416 + | ("smithy-protocol", "rpc-v2-cbor"),
|
5417 + | ];
|
5418 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5419 + | http_response.headers(),
|
5420 + | expected_headers,
|
5421 + | ));
|
5422 + | use ::http_body_util::BodyExt;
|
5423 + | let body = http_response
|
5424 + | .into_body()
|
5425 + | .collect()
|
5426 + | .await
|
5427 + | .expect("unable to collect body")
|
5428 + | .to_bytes();
|
5429 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5430 + | &body,
|
5431 + | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==",
|
5432 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5433 + | ));
|
5517 5434 | }
|
5518 5435 |
|
5519 - | /// A `Content-Type` header should not be set if the response body is empty.
|
5520 - | /// Test ID: no_output
|
5436 + | /// Deserializes null values in lists
|
5437 + | /// Test ID: RpcV2CborSparseListsDeserializeNull
|
5521 5438 | #[::tokio::test]
|
5522 5439 | #[::tracing_test::traced_test]
|
5523 - | async fn no_output_response() {
|
5524 - | let output = crate::output::NoInputOutputOutput {};
|
5440 + | async fn rpc_v2_cbor_sparse_lists_deserialize_null_response() {
|
5441 + | let output = crate::output::SparseNullsOperationOutput {
|
5442 + | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
5443 + | sparse_string_map: ::std::option::Option::None,
|
5444 + | };
|
5525 5445 | use ::aws_smithy_http_server::response::IntoResponse;
|
5526 5446 | let http_response = output.into_response();
|
5527 5447 | ::pretty_assertions::assert_eq!(
|
5528 5448 | ::http_1x::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5529 5449 | http_response.status()
|
5530 5450 | );
|
5531 - | let expected_headers = [("smithy-protocol", "rpc-v2-cbor")];
|
5451 + | let expected_headers = [
|
5452 + | ("Content-Type", "application/cbor"),
|
5453 + | ("smithy-protocol", "rpc-v2-cbor"),
|
5454 + | ];
|
5532 5455 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5533 5456 | http_response.headers(),
|
5534 5457 | expected_headers,
|
5535 5458 | ));
|
5536 - | let forbidden_headers = &["Content-Type"];
|
5537 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::forbid_headers(
|
5538 - | http_response.headers(),
|
5539 - | forbidden_headers,
|
5540 - | ));
|
5541 5459 | use ::http_body_util::BodyExt;
|
5542 5460 | let body = http_response
|
5543 5461 | .into_body()
|
5544 5462 | .collect()
|
5545 5463 | .await
|
5546 5464 | .expect("unable to collect body")
|
5547 5465 | .to_bytes();
|
5548 - | // No body.
|
5549 - | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
5466 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5467 + | &body,
|
5468 + | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==",
|
5469 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5470 + | ));
|
5471 + | }
|
5472 + | }
|
5473 + |
|
5474 + | ::pin_project_lite::pin_project! {
|
5475 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5476 + | /// [`Float16Input`](crate::input::Float16Input) using modelled bindings.
|
5477 + | pub struct Float16InputFuture {
|
5478 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::Float16Input, ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5479 + | }
|
5480 + | }
|
5481 + |
|
5482 + | impl std::future::Future for Float16InputFuture {
|
5483 + | type Output = Result<
|
5484 + | crate::input::Float16Input,
|
5485 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
5486 + | >;
|
5487 + |
|
5488 + | fn poll(
|
5489 + | self: std::pin::Pin<&mut Self>,
|
5490 + | cx: &mut std::task::Context<'_>,
|
5491 + | ) -> std::task::Poll<Self::Output> {
|
5492 + | let this = self.project();
|
5493 + | this.inner.as_mut().poll(cx)
|
5494 + | }
|
5495 + | }
|
5496 + |
|
5497 + | impl<B>
|
5498 + | ::aws_smithy_http_server::request::FromRequest<
|
5499 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5500 + | B,
|
5501 + | > for crate::input::Float16Input
|
5502 + | where
|
5503 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5504 + | B: 'static,
|
5505 + |
|
5506 + | B::Data: Send,
|
5507 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
5508 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5509 + | {
|
5510 + | type Rejection = ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
5511 + | type Future = Float16InputFuture;
|
5512 + |
|
5513 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5514 + | let fut = async move {
|
5515 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5516 + | request.headers(),
|
5517 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
5518 + | ) {
|
5519 + | return Err(::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
5520 + | }
|
5521 + | crate::protocol_serde::shape_float16::de_float16_http_request(request).await
|
5522 + | };
|
5523 + | use ::futures_util::future::TryFutureExt;
|
5524 + | let fut = fut.map_err(
|
5525 + | |e: ::aws_smithy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
5526 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5527 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(
|
5528 + | e,
|
5529 + | )
|
5530 + | },
|
5531 + | );
|
5532 + | Float16InputFuture {
|
5533 + | inner: Box::pin(fut),
|
5534 + | }
|
5535 + | }
|
5536 + | }
|
5537 + | impl
|
5538 + | ::aws_smithy_http_server::response::IntoResponse<
|
5539 + | ::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5540 + | > for crate::output::Float16Output
|
5541 + | {
|
5542 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5543 + | match crate::protocol_serde::shape_float16::ser_float16_http_response(self) {
|
5544 + | Ok(response) => response,
|
5545 + | Err(e) => {
|
5546 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5547 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5548 + | }
|
5549 + | }
|
5550 5550 | }
|
5551 5551 | }
|