1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | ::pin_project_lite::pin_project! {
|
3 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4 + | /// [`Float16Input`](crate::input::Float16Input) using modelled bindings.
|
5 + | pub struct Float16InputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::Float16Input, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
7 + | }
|
8 + | }
|
9 + |
|
10 + | impl std::future::Future for Float16InputFuture {
|
11 + | type Output = Result<
|
12 + | crate::input::Float16Input,
|
13 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
14 + | >;
|
15 + |
|
16 + | fn poll(
|
17 + | self: std::pin::Pin<&mut Self>,
|
18 + | cx: &mut std::task::Context<'_>,
|
19 + | ) -> std::task::Poll<Self::Output> {
|
20 + | let this = self.project();
|
21 + | this.inner.as_mut().poll(cx)
|
22 + | }
|
23 + | }
|
24 + |
|
25 + | impl<B>
|
26 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
27 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
28 + | B,
|
29 + | > for crate::input::Float16Input
|
30 + | where
|
31 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
32 + | B: 'static,
|
33 + |
|
34 + | B::Data: Send,
|
35 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
36 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
37 + | {
|
38 + | type Rejection =
|
39 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
40 + | type Future = Float16InputFuture;
|
41 + |
|
42 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
43 + | let fut = async move {
|
44 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
45 + | request.headers(),
|
46 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
47 + | ) {
|
48 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
49 + | }
|
50 + | crate::protocol_serde::shape_float16::de_float16_http_request(request).await
|
51 + | };
|
52 + | use ::futures_util::future::TryFutureExt;
|
53 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
54 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
55 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
56 + | });
|
57 + | Float16InputFuture {
|
58 + | inner: Box::pin(fut),
|
59 + | }
|
60 + | }
|
61 + | }
|
62 + | impl
|
63 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
64 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
65 + | > for crate::output::Float16Output
|
66 + | {
|
67 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
68 + | match crate::protocol_serde::shape_float16::ser_float16_http_response(self) {
|
69 + | Ok(response) => response,
|
70 + | Err(e) => {
|
71 + | ::tracing::error!(error = %e, "failed to serialize response");
|
72 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
73 + | }
|
74 + | }
|
75 + | }
|
76 + | }
|
77 + |
|
78 + | ::pin_project_lite::pin_project! {
|
79 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
80 + | /// [`SparseNullsOperationInput`](crate::input::SparseNullsOperationInput) using modelled bindings.
|
81 + | pub struct SparseNullsOperationInputFuture {
|
82 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SparseNullsOperationInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
83 + | }
|
84 + | }
|
85 + |
|
86 + | impl std::future::Future for SparseNullsOperationInputFuture {
|
87 + | type Output = Result<
|
88 + | crate::input::SparseNullsOperationInput,
|
89 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
90 + | >;
|
91 + |
|
92 + | fn poll(
|
93 + | self: std::pin::Pin<&mut Self>,
|
94 + | cx: &mut std::task::Context<'_>,
|
95 + | ) -> std::task::Poll<Self::Output> {
|
96 + | let this = self.project();
|
97 + | this.inner.as_mut().poll(cx)
|
98 + | }
|
99 + | }
|
100 + |
|
101 + | impl<B>
|
102 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
103 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
104 + | B,
|
105 + | > for crate::input::SparseNullsOperationInput
|
106 + | where
|
107 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
108 + | B: 'static,
|
109 + |
|
110 + | B::Data: Send,
|
111 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
112 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
113 + | {
|
114 + | type Rejection =
|
115 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
116 + | type Future = SparseNullsOperationInputFuture;
|
117 + |
|
118 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
119 + | let fut = async move {
|
120 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
121 + | request.headers(),
|
122 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
123 + | ) {
|
124 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
125 + | }
|
126 + | crate::protocol_serde::shape_sparse_nulls_operation::de_sparse_nulls_operation_http_request(request)
|
127 + | .await
|
128 + | };
|
129 + | use ::futures_util::future::TryFutureExt;
|
130 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
131 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
132 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
133 + | });
|
134 + | SparseNullsOperationInputFuture {
|
135 + | inner: Box::pin(fut),
|
136 + | }
|
137 + | }
|
138 + | }
|
139 + | impl
|
140 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
141 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
142 + | > for crate::output::SparseNullsOperationOutput
|
143 + | {
|
144 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
145 + | match crate::protocol_serde::shape_sparse_nulls_operation::ser_sparse_nulls_operation_http_response(self) {
|
146 + | Ok(response) => response,
|
147 + | Err(e) => {
|
148 + | ::tracing::error!(error = %e, "failed to serialize response");
|
149 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
150 + | }
|
151 + | }
|
152 + | }
|
153 + | }
|
154 + |
|
155 + | #[allow(unreachable_code, unused_variables)]
|
156 + | #[cfg(test)]
|
157 + | mod sparse_nulls_operation_test {
|
158 + |
|
159 + | /// Serializes null values in maps
|
160 + | /// Test ID: RpcV2CborSparseMapsSerializeNullValues
|
161 + | #[::tokio::test]
|
162 + | #[::tracing_test::traced_test]
|
163 + | async fn rpc_v2_cbor_sparse_maps_serialize_null_values_request() {
|
164 + | #[allow(unused_mut)]
|
165 + | let mut http_request = ::http::Request::builder()
|
166 + | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
167 + | .method("POST")
|
168 + | .header("Accept", "application/cbor")
|
169 + | .header("Content-Type", "application/cbor")
|
170 + | .header("smithy-protocol", "rpc-v2-cbor")
|
171 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
172 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
173 + | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==".as_bytes(),
|
174 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
175 + | )),
|
176 + | ))
|
177 + | .unwrap();
|
178 + | #[allow(unused_mut)]
|
179 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
180 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
181 + | let service =
|
182 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
183 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
184 + | let sender = sender.clone();
|
185 + | async move {
|
186 + | let result = {
|
187 + | let expected = crate::input::SparseNullsOperationInput {
|
188 + | sparse_string_map: ::std::option::Option::Some({
|
189 + | let mut ret = ::std::collections::HashMap::new();
|
190 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
191 + | ret
|
192 + | }),
|
193 + | sparse_string_list: ::std::option::Option::None,
|
194 + | };
|
195 + | ::pretty_assertions::assert_eq!(input, expected);
|
196 + | let output = crate::output::SparseNullsOperationOutput {
|
197 + | sparse_string_list: ::std::option::Option::None,
|
198 + | sparse_string_map: ::std::option::Option::None,
|
199 + | };
|
200 + | output
|
201 + | };
|
202 + | sender.send(()).await.expect("receiver dropped early");
|
203 + | result
|
204 + | }
|
205 + | })
|
206 + | .build_unchecked();
|
207 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
208 + | .await
|
209 + | .expect("unable to make an HTTP request");
|
210 + | assert!(
|
211 + | receiver.recv().await.is_some(),
|
212 + | "we expected operation handler to be invoked but it was not entered"
|
213 + | );
|
214 + | }
|
215 + |
|
216 + | /// Serializes null values in lists
|
217 + | /// Test ID: RpcV2CborSparseListsSerializeNull
|
218 + | #[::tokio::test]
|
219 + | #[::tracing_test::traced_test]
|
220 + | async fn rpc_v2_cbor_sparse_lists_serialize_null_request() {
|
221 + | #[allow(unused_mut)]
|
222 + | let mut http_request = ::http::Request::builder()
|
223 + | .uri("/service/RpcV2Protocol/operation/SparseNullsOperation")
|
224 + | .method("POST")
|
225 + | .header("Accept", "application/cbor")
|
226 + | .header("Content-Type", "application/cbor")
|
227 + | .header("smithy-protocol", "rpc-v2-cbor")
|
228 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
229 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
230 + | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==".as_bytes(),
|
231 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
232 + | )),
|
233 + | ))
|
234 + | .unwrap();
|
235 + | #[allow(unused_mut)]
|
236 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
237 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
238 + | let service =
|
239 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
240 + | .sparse_nulls_operation(move |input: crate::input::SparseNullsOperationInput| {
|
241 + | let sender = sender.clone();
|
242 + | async move {
|
243 + | let result = {
|
244 + | let expected = crate::input::SparseNullsOperationInput {
|
245 + | sparse_string_list: ::std::option::Option::Some(vec![
|
246 + | ::std::option::Option::None,
|
247 + | ]),
|
248 + | sparse_string_map: ::std::option::Option::None,
|
249 + | };
|
250 + | ::pretty_assertions::assert_eq!(input, expected);
|
251 + | let output = crate::output::SparseNullsOperationOutput {
|
252 + | sparse_string_list: ::std::option::Option::None,
|
253 + | sparse_string_map: ::std::option::Option::None,
|
254 + | };
|
255 + | output
|
256 + | };
|
257 + | sender.send(()).await.expect("receiver dropped early");
|
258 + | result
|
259 + | }
|
260 + | })
|
261 + | .build_unchecked();
|
262 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
263 + | .await
|
264 + | .expect("unable to make an HTTP request");
|
265 + | assert!(
|
266 + | receiver.recv().await.is_some(),
|
267 + | "we expected operation handler to be invoked but it was not entered"
|
268 + | );
|
269 + | }
|
270 + |
|
271 + | /// Deserializes null values in maps
|
272 + | /// Test ID: RpcV2CborSparseMapsDeserializeNullValues
|
273 + | #[::tokio::test]
|
274 + | #[::tracing_test::traced_test]
|
275 + | async fn rpc_v2_cbor_sparse_maps_deserialize_null_values_response() {
|
276 + | let output = crate::output::SparseNullsOperationOutput {
|
277 + | sparse_string_map: ::std::option::Option::Some({
|
278 + | let mut ret = ::std::collections::HashMap::new();
|
279 + | ret.insert("foo".to_owned(), ::std::option::Option::None);
|
280 + | ret
|
281 + | }),
|
282 + | sparse_string_list: ::std::option::Option::None,
|
283 + | };
|
284 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
285 + | let http_response = output.into_response();
|
286 + | ::pretty_assertions::assert_eq!(
|
287 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
288 + | http_response.status()
|
289 + | );
|
290 + | let expected_headers = [
|
291 + | ("Content-Type", "application/cbor"),
|
292 + | ("smithy-protocol", "rpc-v2-cbor"),
|
293 + | ];
|
294 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
295 + | http_response.headers(),
|
296 + | expected_headers,
|
297 + | ));
|
298 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
299 + | .await
|
300 + | .expect("unable to extract body to bytes");
|
301 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
302 + | &body,
|
303 + | "v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==",
|
304 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
305 + | ));
|
306 + | }
|
307 + |
|
308 + | /// Deserializes null values in lists
|
309 + | /// Test ID: RpcV2CborSparseListsDeserializeNull
|
310 + | #[::tokio::test]
|
311 + | #[::tracing_test::traced_test]
|
312 + | async fn rpc_v2_cbor_sparse_lists_deserialize_null_response() {
|
313 + | let output = crate::output::SparseNullsOperationOutput {
|
314 + | sparse_string_list: ::std::option::Option::Some(vec![::std::option::Option::None]),
|
315 + | sparse_string_map: ::std::option::Option::None,
|
316 + | };
|
317 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
318 + | let http_response = output.into_response();
|
319 + | ::pretty_assertions::assert_eq!(
|
320 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
321 + | http_response.status()
|
322 + | );
|
323 + | let expected_headers = [
|
324 + | ("Content-Type", "application/cbor"),
|
325 + | ("smithy-protocol", "rpc-v2-cbor"),
|
326 + | ];
|
327 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
328 + | http_response.headers(),
|
329 + | expected_headers,
|
330 + | ));
|
331 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
332 + | .await
|
333 + | .expect("unable to extract body to bytes");
|
334 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
335 + | &body,
|
336 + | "v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==",
|
337 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
338 + | ));
|
339 + | }
|
340 + | }
|
341 + |
|
342 + | ::pin_project_lite::pin_project! {
|
343 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
344 + | /// [`OperationWithDefaultsInput`](crate::input::OperationWithDefaultsInput) using modelled bindings.
|
345 + | pub struct OperationWithDefaultsInputFuture {
|
346 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationWithDefaultsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
347 + | }
|
348 + | }
|
349 + |
|
350 + | impl std::future::Future for OperationWithDefaultsInputFuture {
|
351 + | type Output = Result<
|
352 + | crate::input::OperationWithDefaultsInput,
|
353 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
354 + | >;
|
355 + |
|
356 + | fn poll(
|
357 + | self: std::pin::Pin<&mut Self>,
|
358 + | cx: &mut std::task::Context<'_>,
|
359 + | ) -> std::task::Poll<Self::Output> {
|
360 + | let this = self.project();
|
361 + | this.inner.as_mut().poll(cx)
|
362 + | }
|
363 + | }
|
364 + |
|
365 + | impl<B>
|
366 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
367 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
368 + | B,
|
369 + | > for crate::input::OperationWithDefaultsInput
|
370 + | where
|
371 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
372 + | B: 'static,
|
373 + |
|
374 + | B::Data: Send,
|
375 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
376 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
377 + | {
|
378 + | type Rejection =
|
379 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
380 + | type Future = OperationWithDefaultsInputFuture;
|
381 + |
|
382 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
383 + | let fut = async move {
|
384 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
385 + | request.headers(),
|
386 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
387 + | ) {
|
388 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
389 + | }
|
390 + | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults_http_request(request)
|
391 + | .await
|
392 + | };
|
393 + | use ::futures_util::future::TryFutureExt;
|
394 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
395 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
396 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
397 + | });
|
398 + | OperationWithDefaultsInputFuture {
|
399 + | inner: Box::pin(fut),
|
400 + | }
|
401 + | }
|
402 + | }
|
403 + | impl
|
404 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
405 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
406 + | > for crate::output::OperationWithDefaultsOutput
|
407 + | {
|
408 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
409 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_response(self) {
|
410 + | Ok(response) => response,
|
411 + | Err(e) => {
|
412 + | ::tracing::error!(error = %e, "failed to serialize response");
|
413 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
414 + | }
|
415 + | }
|
416 + | }
|
417 + | }
|
418 + | impl
|
419 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
420 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
421 + | > for crate::error::OperationWithDefaultsError
|
422 + | {
|
423 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
424 + | match crate::protocol_serde::shape_operation_with_defaults::ser_operation_with_defaults_http_error(&self) {
|
425 + | Ok(mut response) => {
|
426 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
427 + | response
|
428 + | },
|
429 + | Err(e) => {
|
430 + | ::tracing::error!(error = %e, "failed to serialize response");
|
431 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
432 + | }
|
433 + | }
|
434 + | }
|
435 + | }
|
436 + |
|
437 + | #[allow(unreachable_code, unused_variables)]
|
438 + | #[cfg(test)]
|
439 + | mod operation_with_defaults_test {
|
440 + |
|
441 + | /// Server populates default values when missing in request body.
|
442 + | /// Test ID: RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody
|
443 + | #[::tokio::test]
|
444 + | #[::tracing_test::traced_test]
|
445 + | #[should_panic]
|
446 + | async fn rpc_v2_cbor_server_populates_defaults_when_missing_in_request_body_request() {
|
447 + | #[allow(unused_mut)]
|
448 + | let mut http_request = ::http::Request::builder()
|
449 + | .uri("/service/RpcV2Protocol/operation/OperationWithDefaults")
|
450 + | .method("POST")
|
451 + | .header("Accept", "application/cbor")
|
452 + | .header("Content-Type", "application/cbor")
|
453 + | .header("smithy-protocol", "rpc-v2-cbor")
|
454 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
455 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
456 + | "v2hkZWZhdWx0c6D/".as_bytes(),
|
457 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
458 + | )),
|
459 + | ))
|
460 + | .unwrap();
|
461 + | #[allow(unused_mut)]
|
462 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
463 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
464 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
465 + | config,
|
466 + | )
|
467 + | .operation_with_defaults(move |input: crate::input::OperationWithDefaultsInput| {
|
468 + | let sender = sender.clone();
|
469 + | async move {
|
470 + | let result = {
|
471 + | let expected = crate::input::OperationWithDefaultsInput {
|
472 + | defaults: ::std::option::Option::Some(crate::model::Defaults {
|
473 + | default_string: "hi".to_owned(),
|
474 + | default_boolean: true,
|
475 + | default_list: vec![],
|
476 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
477 + | 0, 0_f64,
|
478 + | ),
|
479 + | default_blob: ::aws_smithy_types::Blob::new("abc"),
|
480 + | default_byte: 1,
|
481 + | default_short: 1,
|
482 + | default_integer: 10,
|
483 + | default_long: 100,
|
484 + | default_float: 1.0_f32,
|
485 + | default_double: 1.0_f64,
|
486 + | default_map: ::std::collections::HashMap::new(),
|
487 + | default_enum: "FOO"
|
488 + | .parse::<crate::model::TestEnum>()
|
489 + | .expect("static value validated to member"),
|
490 + | default_int_enum: 1,
|
491 + | empty_string: "".to_owned(),
|
492 + | false_boolean: false,
|
493 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
494 + | zero_byte: 0,
|
495 + | zero_short: 0,
|
496 + | zero_integer: 0,
|
497 + | zero_long: 0,
|
498 + | zero_float: 0.0_f32,
|
499 + | zero_double: 0.0_f64,
|
500 + | }),
|
501 + | top_level_default: "hi".to_owned(),
|
502 + | other_top_level_default: 0,
|
503 + | client_optional_defaults: ::std::option::Option::None,
|
504 + | };
|
505 + | ::pretty_assertions::assert_eq!(input, expected);
|
506 + | let output = crate::output::OperationWithDefaultsOutput {
|
507 + | default_string: "".to_owned(),
|
508 + | default_boolean: false,
|
509 + | default_list: vec![],
|
510 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(
|
511 + | 0, 0_f64,
|
512 + | ),
|
513 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
514 + | default_byte: 0,
|
515 + | default_short: 0,
|
516 + | default_integer: 0,
|
517 + | default_long: 0,
|
518 + | default_float: 0_f32,
|
519 + | default_double: 0_f64,
|
520 + | default_map: ::std::collections::HashMap::new(),
|
521 + | default_enum: ""
|
522 + | .parse::<crate::model::TestEnum>()
|
523 + | .expect("static value validated to member"),
|
524 + | default_int_enum: 0,
|
525 + | empty_string: "".to_owned(),
|
526 + | false_boolean: false,
|
527 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
528 + | zero_byte: 0,
|
529 + | zero_short: 0,
|
530 + | zero_integer: 0,
|
531 + | zero_long: 0,
|
532 + | zero_float: 0_f32,
|
533 + | zero_double: 0_f64,
|
534 + | };
|
535 + | Ok(output)
|
536 + | };
|
537 + | sender.send(()).await.expect("receiver dropped early");
|
538 + | result
|
539 + | }
|
540 + | })
|
541 + | .build_unchecked();
|
542 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
543 + | .await
|
544 + | .expect("unable to make an HTTP request");
|
545 + | assert!(
|
546 + | receiver.recv().await.is_some(),
|
547 + | "we expected operation handler to be invoked but it was not entered"
|
548 + | );
|
549 + | }
|
550 + |
|
551 + | /// Server populates default values in response when missing in params.
|
552 + | /// Test ID: RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams
|
553 + | #[::tokio::test]
|
554 + | #[::tracing_test::traced_test]
|
555 + | #[should_panic]
|
556 + | async fn rpc_v2_cbor_server_populates_defaults_in_response_when_missing_in_params_response() {
|
557 + | let output = crate::output::OperationWithDefaultsOutput {
|
558 + | default_string: "".to_owned(),
|
559 + | default_boolean: false,
|
560 + | default_list: vec![],
|
561 + | default_timestamp: ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64),
|
562 + | default_blob: ::aws_smithy_types::Blob::new(""),
|
563 + | default_byte: 0,
|
564 + | default_short: 0,
|
565 + | default_integer: 0,
|
566 + | default_long: 0,
|
567 + | default_float: 0_f32,
|
568 + | default_double: 0_f64,
|
569 + | default_map: ::std::collections::HashMap::new(),
|
570 + | default_enum: ""
|
571 + | .parse::<crate::model::TestEnum>()
|
572 + | .expect("static value validated to member"),
|
573 + | default_int_enum: 0,
|
574 + | empty_string: "".to_owned(),
|
575 + | false_boolean: false,
|
576 + | empty_blob: ::aws_smithy_types::Blob::new(""),
|
577 + | zero_byte: 0,
|
578 + | zero_short: 0,
|
579 + | zero_integer: 0,
|
580 + | zero_long: 0,
|
581 + | zero_float: 0_f32,
|
582 + | zero_double: 0_f64,
|
583 + | };
|
584 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
585 + | let http_response = output.into_response();
|
586 + | ::pretty_assertions::assert_eq!(
|
587 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
588 + | http_response.status()
|
589 + | );
|
590 + | let expected_headers = [
|
591 + | ("Content-Type", "application/cbor"),
|
592 + | ("smithy-protocol", "rpc-v2-cbor"),
|
593 + | ];
|
594 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
595 + | http_response.headers(),
|
596 + | expected_headers,
|
597 + | ));
|
598 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
599 + | .await
|
600 + | .expect("unable to extract body to bytes");
|
601 + | ::aws_smithy_protocol_test::assert_ok(
|
602 + | ::aws_smithy_protocol_test::validate_body(&body, "v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
603 + | );
|
604 + | }
|
605 + | }
|
606 + |
|
607 + | ::pin_project_lite::pin_project! {
|
608 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
609 + | /// [`FractionalSecondsInput`](crate::input::FractionalSecondsInput) using modelled bindings.
|
610 + | pub struct FractionalSecondsInputFuture {
|
611 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::FractionalSecondsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
612 + | }
|
613 + | }
|
614 + |
|
615 + | impl std::future::Future for FractionalSecondsInputFuture {
|
616 + | type Output = Result<
|
617 + | crate::input::FractionalSecondsInput,
|
618 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
619 + | >;
|
620 + |
|
621 + | fn poll(
|
622 + | self: std::pin::Pin<&mut Self>,
|
623 + | cx: &mut std::task::Context<'_>,
|
624 + | ) -> std::task::Poll<Self::Output> {
|
625 + | let this = self.project();
|
626 + | this.inner.as_mut().poll(cx)
|
627 + | }
|
628 + | }
|
629 + |
|
630 + | impl<B>
|
631 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
632 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
633 + | B,
|
634 + | > for crate::input::FractionalSecondsInput
|
635 + | where
|
636 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
637 + | B: 'static,
|
638 + |
|
639 + | B::Data: Send,
|
640 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
641 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
642 + | {
|
643 + | type Rejection =
|
644 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
645 + | type Future = FractionalSecondsInputFuture;
|
646 + |
|
647 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
648 + | let fut = async move {
|
649 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
650 + | request.headers(),
|
651 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
652 + | ) {
|
653 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
654 + | }
|
655 + | crate::protocol_serde::shape_fractional_seconds::de_fractional_seconds_http_request(
|
656 + | request,
|
657 + | )
|
658 + | .await
|
659 + | };
|
660 + | use ::futures_util::future::TryFutureExt;
|
661 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
662 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
663 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
664 + | });
|
665 + | FractionalSecondsInputFuture {
|
666 + | inner: Box::pin(fut),
|
667 + | }
|
668 + | }
|
669 + | }
|
670 + | impl
|
671 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
672 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
673 + | > for crate::output::FractionalSecondsOutput
|
674 + | {
|
675 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
676 + | match crate::protocol_serde::shape_fractional_seconds::ser_fractional_seconds_http_response(
|
677 + | self,
|
678 + | ) {
|
679 + | Ok(response) => response,
|
680 + | Err(e) => {
|
681 + | ::tracing::error!(error = %e, "failed to serialize response");
|
682 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
683 + | }
|
684 + | }
|
685 + | }
|
686 + | }
|
687 + |
|
688 + | ::pin_project_lite::pin_project! {
|
689 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
690 + | /// [`GreetingWithErrorsInput`](crate::input::GreetingWithErrorsInput) using modelled bindings.
|
691 + | pub struct GreetingWithErrorsInputFuture {
|
692 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GreetingWithErrorsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
693 + | }
|
694 + | }
|
695 + |
|
696 + | impl std::future::Future for GreetingWithErrorsInputFuture {
|
697 + | type Output = Result<
|
698 + | crate::input::GreetingWithErrorsInput,
|
699 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
700 + | >;
|
701 + |
|
702 + | fn poll(
|
703 + | self: std::pin::Pin<&mut Self>,
|
704 + | cx: &mut std::task::Context<'_>,
|
705 + | ) -> std::task::Poll<Self::Output> {
|
706 + | let this = self.project();
|
707 + | this.inner.as_mut().poll(cx)
|
708 + | }
|
709 + | }
|
710 + |
|
711 + | impl<B>
|
712 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
713 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
714 + | B,
|
715 + | > for crate::input::GreetingWithErrorsInput
|
716 + | where
|
717 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
718 + | B: 'static,
|
719 + |
|
720 + | B::Data: Send,
|
721 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
722 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
723 + | {
|
724 + | type Rejection =
|
725 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
726 + | type Future = GreetingWithErrorsInputFuture;
|
727 + |
|
728 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
729 + | let fut = async move {
|
730 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
731 + | request.headers(),
|
732 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
733 + | ) {
|
734 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
735 + | }
|
736 + | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_request(
|
737 + | request,
|
738 + | )
|
739 + | .await
|
740 + | };
|
741 + | use ::futures_util::future::TryFutureExt;
|
742 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
743 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
744 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
745 + | });
|
746 + | GreetingWithErrorsInputFuture {
|
747 + | inner: Box::pin(fut),
|
748 + | }
|
749 + | }
|
750 + | }
|
751 + | impl
|
752 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
753 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
754 + | > for crate::output::GreetingWithErrorsOutput
|
755 + | {
|
756 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
757 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_response(self) {
|
758 + | Ok(response) => response,
|
759 + | Err(e) => {
|
760 + | ::tracing::error!(error = %e, "failed to serialize response");
|
761 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
762 + | }
|
763 + | }
|
764 + | }
|
765 + | }
|
766 + | impl
|
767 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
768 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
769 + | > for crate::error::GreetingWithErrorsError
|
770 + | {
|
771 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
772 + | match crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_http_error(
|
773 + | &self,
|
774 + | ) {
|
775 + | Ok(mut response) => {
|
776 + | response.extensions_mut().insert(
|
777 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
778 + | self.name(),
|
779 + | ),
|
780 + | );
|
781 + | response
|
782 + | }
|
783 + | Err(e) => {
|
784 + | ::tracing::error!(error = %e, "failed to serialize response");
|
785 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
786 + | }
|
787 + | }
|
788 + | }
|
789 + | }
|
790 + |
|
791 + | #[allow(unreachable_code, unused_variables)]
|
792 + | #[cfg(test)]
|
793 + | mod greeting_with_errors_test {
|
794 + |
|
795 + | /// Parses simple RpcV2 Cbor errors
|
796 + | /// Test ID: RpcV2CborInvalidGreetingError
|
797 + | #[::tokio::test]
|
798 + | #[::tracing_test::traced_test]
|
799 + | async fn rpc_v2_cbor_invalid_greeting_error_response() {
|
800 + | let output = crate::error::InvalidGreeting {
|
801 + | message: ::std::option::Option::Some("Hi".to_owned()),
|
802 + | };
|
803 + | let output = crate::error::GreetingWithErrorsError::InvalidGreeting(output);
|
804 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
805 + | let http_response = output.into_response();
|
806 + | ::pretty_assertions::assert_eq!(
|
807 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
808 + | http_response.status()
|
809 + | );
|
810 + | let expected_headers = [
|
811 + | ("Content-Type", "application/cbor"),
|
812 + | ("smithy-protocol", "rpc-v2-cbor"),
|
813 + | ];
|
814 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
815 + | http_response.headers(),
|
816 + | expected_headers,
|
817 + | ));
|
818 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
819 + | .await
|
820 + | .expect("unable to extract body to bytes");
|
821 + | ::aws_smithy_protocol_test::assert_ok(
|
822 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
823 + | );
|
824 + | }
|
825 + |
|
826 + | /// Parses a complex error with no message member
|
827 + | /// Test ID: RpcV2CborComplexError
|
828 + | #[::tokio::test]
|
829 + | #[::tracing_test::traced_test]
|
830 + | async fn rpc_v2_cbor_complex_error_response() {
|
831 + | let output = crate::error::ComplexError {
|
832 + | top_level: ::std::option::Option::Some("Top level".to_owned()),
|
833 + | nested: ::std::option::Option::Some(crate::model::ComplexNestedErrorData {
|
834 + | foo: ::std::option::Option::Some("bar".to_owned()),
|
835 + | }),
|
836 + | };
|
837 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
838 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
839 + | let http_response = output.into_response();
|
840 + | ::pretty_assertions::assert_eq!(
|
841 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
842 + | http_response.status()
|
843 + | );
|
844 + | let expected_headers = [
|
845 + | ("Content-Type", "application/cbor"),
|
846 + | ("smithy-protocol", "rpc-v2-cbor"),
|
847 + | ];
|
848 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
849 + | http_response.headers(),
|
850 + | expected_headers,
|
851 + | ));
|
852 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
853 + | .await
|
854 + | .expect("unable to extract body to bytes");
|
855 + | ::aws_smithy_protocol_test::assert_ok(
|
856 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
857 + | );
|
858 + | }
|
859 + | /// Test ID: RpcV2CborEmptyComplexError
|
860 + | #[::tokio::test]
|
861 + | #[::tracing_test::traced_test]
|
862 + | async fn rpc_v2_cbor_empty_complex_error_response() {
|
863 + | let output = crate::error::ComplexError {
|
864 + | top_level: ::std::option::Option::None,
|
865 + | nested: ::std::option::Option::None,
|
866 + | };
|
867 + | let output = crate::error::GreetingWithErrorsError::ComplexError(output);
|
868 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
869 + | let http_response = output.into_response();
|
870 + | ::pretty_assertions::assert_eq!(
|
871 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
872 + | http_response.status()
|
873 + | );
|
874 + | let expected_headers = [
|
875 + | ("Content-Type", "application/cbor"),
|
876 + | ("smithy-protocol", "rpc-v2-cbor"),
|
877 + | ];
|
878 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
879 + | http_response.headers(),
|
880 + | expected_headers,
|
881 + | ));
|
882 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
883 + | .await
|
884 + | .expect("unable to extract body to bytes");
|
885 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
886 + | &body,
|
887 + | "v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/",
|
888 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
889 + | ));
|
890 + | }
|
891 + | }
|
892 + |
|
893 + | ::pin_project_lite::pin_project! {
|
894 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
895 + | /// [`RecursiveShapesInput`](crate::input::RecursiveShapesInput) using modelled bindings.
|
896 + | pub struct RecursiveShapesInputFuture {
|
897 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveShapesInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
898 + | }
|
899 + | }
|
900 + |
|
901 + | impl std::future::Future for RecursiveShapesInputFuture {
|
902 + | type Output = Result<
|
903 + | crate::input::RecursiveShapesInput,
|
904 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
905 + | >;
|
906 + |
|
907 + | fn poll(
|
908 + | self: std::pin::Pin<&mut Self>,
|
909 + | cx: &mut std::task::Context<'_>,
|
910 + | ) -> std::task::Poll<Self::Output> {
|
911 + | let this = self.project();
|
912 + | this.inner.as_mut().poll(cx)
|
913 + | }
|
914 + | }
|
915 + |
|
916 + | impl<B>
|
917 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
918 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
919 + | B,
|
920 + | > for crate::input::RecursiveShapesInput
|
921 + | where
|
922 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
923 + | B: 'static,
|
924 + |
|
925 + | B::Data: Send,
|
926 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
927 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
928 + | {
|
929 + | type Rejection =
|
930 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
931 + | type Future = RecursiveShapesInputFuture;
|
932 + |
|
933 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
934 + | let fut = async move {
|
935 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
936 + | request.headers(),
|
937 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
938 + | ) {
|
939 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
940 + | }
|
941 + | crate::protocol_serde::shape_recursive_shapes::de_recursive_shapes_http_request(request)
|
942 + | .await
|
943 + | };
|
944 + | use ::futures_util::future::TryFutureExt;
|
945 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
946 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
947 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
948 + | });
|
949 + | RecursiveShapesInputFuture {
|
950 + | inner: Box::pin(fut),
|
951 + | }
|
952 + | }
|
953 + | }
|
954 + | impl
|
955 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
956 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
957 + | > for crate::output::RecursiveShapesOutput
|
958 + | {
|
959 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
960 + | match crate::protocol_serde::shape_recursive_shapes::ser_recursive_shapes_http_response(
|
961 + | self,
|
962 + | ) {
|
963 + | Ok(response) => response,
|
964 + | Err(e) => {
|
965 + | ::tracing::error!(error = %e, "failed to serialize response");
|
966 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
967 + | }
|
968 + | }
|
969 + | }
|
970 + | }
|
971 + |
|
972 + | #[allow(unreachable_code, unused_variables)]
|
973 + | #[cfg(test)]
|
974 + | mod recursive_shapes_test {
|
975 + |
|
976 + | /// Serializes recursive structures
|
977 + | /// Test ID: RpcV2CborRecursiveShapes
|
978 + | #[::tokio::test]
|
979 + | #[::tracing_test::traced_test]
|
980 + | async fn rpc_v2_cbor_recursive_shapes_request() {
|
981 + | #[allow(unused_mut)]
|
982 + | let mut http_request = ::http::Request::builder()
|
983 + | .uri("/service/RpcV2Protocol/operation/RecursiveShapes")
|
984 + | .method("POST")
|
985 + | .header("Accept", "application/cbor")
|
986 + | .header("Content-Type", "application/cbor")
|
987 + | .header("smithy-protocol", "rpc-v2-cbor")
|
988 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
989 + | ::bytes::Bytes::copy_from_slice(
|
990 + | &::aws_smithy_protocol_test::decode_body_data("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
991 + | )
|
992 + | )).unwrap();
|
993 + | #[allow(unused_mut)]
|
994 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
995 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
996 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
997 + | .recursive_shapes(move |input: crate::input::RecursiveShapesInput| {
|
998 + | let sender = sender.clone();
|
999 + | async move {
|
1000 + | let result = { let expected =
|
1001 + | crate::input::RecursiveShapesInput {
|
1002 + | nested:
|
1003 + | ::std::option::Option::Some(
|
1004 + | crate::model::RecursiveShapesInputOutputNested1 {
|
1005 + | foo:
|
1006 + | ::std::option::Option::Some(
|
1007 + | "Foo1".to_owned()
|
1008 + | )
|
1009 + | ,
|
1010 + | nested:
|
1011 + | ::std::option::Option::Some(
|
1012 + | ::std::boxed::Box::new(
|
1013 + | crate::model::RecursiveShapesInputOutputNested2 {
|
1014 + | bar:
|
1015 + | ::std::option::Option::Some(
|
1016 + | "Bar1".to_owned()
|
1017 + | )
|
1018 + | ,
|
1019 + | recursive_member:
|
1020 + | ::std::option::Option::Some(
|
1021 + | crate::model::RecursiveShapesInputOutputNested1 {
|
1022 + | foo:
|
1023 + | ::std::option::Option::Some(
|
1024 + | "Foo2".to_owned()
|
1025 + | )
|
1026 + | ,
|
1027 + | nested:
|
1028 + | ::std::option::Option::Some(
|
1029 + | ::std::boxed::Box::new(
|
1030 + | crate::model::RecursiveShapesInputOutputNested2 {
|
1031 + | bar:
|
1032 + | ::std::option::Option::Some(
|
1033 + | "Bar2".to_owned()
|
1034 + | )
|
1035 + | ,
|
1036 + | recursive_member:
|
1037 + | ::std::option::Option::None
|
1038 + | ,
|
1039 + | }
|
1040 + | )
|
1041 + | )
|
1042 + | ,
|
1043 + | }
|
1044 + | )
|
1045 + | ,
|
1046 + | }
|
1047 + | )
|
1048 + | )
|
1049 + | ,
|
1050 + | }
|
1051 + | )
|
1052 + | ,
|
1053 + | }
|
1054 + | ;
|
1055 + | ::pretty_assertions::assert_eq!(input, expected);
|
1056 + | let output =
|
1057 + | crate::output::RecursiveShapesOutput {
|
1058 + | nested:
|
1059 + | ::std::option::Option::None
|
1060 + | ,
|
1061 + | }
|
1062 + | ;
|
1063 + | output };
|
1064 + | sender.send(()).await.expect("receiver dropped early");
|
1065 + | result
|
1066 + | }
|
1067 + | })
|
1068 + | .build_unchecked();
|
1069 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1070 + | .await
|
1071 + | .expect("unable to make an HTTP request");
|
1072 + | assert!(
|
1073 + | receiver.recv().await.is_some(),
|
1074 + | "we expected operation handler to be invoked but it was not entered"
|
1075 + | );
|
1076 + | }
|
1077 + |
|
1078 + | /// Serializes recursive structures
|
1079 + | /// Test ID: RpcV2CborRecursiveShapes
|
1080 + | #[::tokio::test]
|
1081 + | #[::tracing_test::traced_test]
|
1082 + | async fn rpc_v2_cbor_recursive_shapes_response() {
|
1083 + | let output = crate::output::RecursiveShapesOutput {
|
1084 + | nested: ::std::option::Option::Some(crate::model::RecursiveShapesInputOutputNested1 {
|
1085 + | foo: ::std::option::Option::Some("Foo1".to_owned()),
|
1086 + | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
1087 + | crate::model::RecursiveShapesInputOutputNested2 {
|
1088 + | bar: ::std::option::Option::Some("Bar1".to_owned()),
|
1089 + | recursive_member: ::std::option::Option::Some(
|
1090 + | crate::model::RecursiveShapesInputOutputNested1 {
|
1091 + | foo: ::std::option::Option::Some("Foo2".to_owned()),
|
1092 + | nested: ::std::option::Option::Some(::std::boxed::Box::new(
|
1093 + | crate::model::RecursiveShapesInputOutputNested2 {
|
1094 + | bar: ::std::option::Option::Some("Bar2".to_owned()),
|
1095 + | recursive_member: ::std::option::Option::None,
|
1096 + | },
|
1097 + | )),
|
1098 + | },
|
1099 + | ),
|
1100 + | },
|
1101 + | )),
|
1102 + | }),
|
1103 + | };
|
1104 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1105 + | let http_response = output.into_response();
|
1106 + | ::pretty_assertions::assert_eq!(
|
1107 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1108 + | http_response.status()
|
1109 + | );
|
1110 + | let expected_headers = [
|
1111 + | ("Content-Type", "application/cbor"),
|
1112 + | ("smithy-protocol", "rpc-v2-cbor"),
|
1113 + | ];
|
1114 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1115 + | http_response.headers(),
|
1116 + | expected_headers,
|
1117 + | ));
|
1118 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1119 + | .await
|
1120 + | .expect("unable to extract body to bytes");
|
1121 + | ::aws_smithy_protocol_test::assert_ok(
|
1122 + | ::aws_smithy_protocol_test::validate_body(&body, "v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1123 + | );
|
1124 + | }
|
1125 + | }
|
1126 + |
|
1127 + | ::pin_project_lite::pin_project! {
|
1128 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1129 + | /// [`RpcV2CborSparseMapsInput`](crate::input::RpcV2CborSparseMapsInput) using modelled bindings.
|
1130 + | pub struct RpcV2CborSparseMapsInputFuture {
|
1131 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborSparseMapsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1132 + | }
|
1133 + | }
|
1134 + |
|
1135 + | impl std::future::Future for RpcV2CborSparseMapsInputFuture {
|
1136 + | type Output = Result<
|
1137 + | crate::input::RpcV2CborSparseMapsInput,
|
1138 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1139 + | >;
|
1140 + |
|
1141 + | fn poll(
|
1142 + | self: std::pin::Pin<&mut Self>,
|
1143 + | cx: &mut std::task::Context<'_>,
|
1144 + | ) -> std::task::Poll<Self::Output> {
|
1145 + | let this = self.project();
|
1146 + | this.inner.as_mut().poll(cx)
|
1147 + | }
|
1148 + | }
|
1149 + |
|
1150 + | impl<B>
|
1151 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1152 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1153 + | B,
|
1154 + | > for crate::input::RpcV2CborSparseMapsInput
|
1155 + | where
|
1156 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1157 + | B: 'static,
|
1158 + |
|
1159 + | B::Data: Send,
|
1160 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1161 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1162 + | {
|
1163 + | type Rejection =
|
1164 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1165 + | type Future = RpcV2CborSparseMapsInputFuture;
|
1166 + |
|
1167 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1168 + | let fut = async move {
|
1169 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1170 + | request.headers(),
|
1171 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1172 + | ) {
|
1173 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1174 + | }
|
1175 + | crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::de_rpc_v2_cbor_sparse_maps_http_request(request)
|
1176 + | .await
|
1177 + | };
|
1178 + | use ::futures_util::future::TryFutureExt;
|
1179 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1180 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1181 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
1182 + | });
|
1183 + | RpcV2CborSparseMapsInputFuture {
|
1184 + | inner: Box::pin(fut),
|
1185 + | }
|
1186 + | }
|
1187 + | }
|
1188 + | impl
|
1189 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1190 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1191 + | > for crate::output::RpcV2CborSparseMapsOutput
|
1192 + | {
|
1193 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1194 + | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_response(self) {
|
1195 + | Ok(response) => response,
|
1196 + | Err(e) => {
|
1197 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1198 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1199 + | }
|
1200 + | }
|
1201 + | }
|
1202 + | }
|
1203 + | impl
|
1204 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1205 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1206 + | > for crate::error::RpcV2CborSparseMapsError
|
1207 + | {
|
1208 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1209 + | match crate::protocol_serde::shape_rpc_v2_cbor_sparse_maps::ser_rpc_v2_cbor_sparse_maps_http_error(&self) {
|
1210 + | Ok(mut response) => {
|
1211 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1212 + | response
|
1213 + | },
|
1214 + | Err(e) => {
|
1215 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1216 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1217 + | }
|
1218 + | }
|
1219 + | }
|
1220 + | }
|
1221 + |
|
1222 + | #[allow(unreachable_code, unused_variables)]
|
1223 + | #[cfg(test)]
|
1224 + | mod rpc_v2_cbor_sparse_maps_test {
|
1225 + |
|
1226 + | /// Serializes sparse maps
|
1227 + | /// Test ID: RpcV2CborSparseMaps
|
1228 + | #[::tokio::test]
|
1229 + | #[::tracing_test::traced_test]
|
1230 + | async fn rpc_v2_cbor_sparse_maps_request() {
|
1231 + | #[allow(unused_mut)]
|
1232 + | let mut http_request = ::http::Request::builder()
|
1233 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1234 + | .method("POST")
|
1235 + | .header("Accept", "application/cbor")
|
1236 + | .header("Content-Type", "application/cbor")
|
1237 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1238 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1239 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1240 + | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////".as_bytes(),
|
1241 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1242 + | )),
|
1243 + | ))
|
1244 + | .unwrap();
|
1245 + | #[allow(unused_mut)]
|
1246 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1247 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1248 + | let service =
|
1249 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1250 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1251 + | let sender = sender.clone();
|
1252 + | async move {
|
1253 + | let result = {
|
1254 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1255 + | sparse_struct_map: ::std::option::Option::Some({
|
1256 + | let mut ret = ::std::collections::HashMap::new();
|
1257 + | ret.insert(
|
1258 + | "foo".to_owned(),
|
1259 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1260 + | hi: ::std::option::Option::Some("there".to_owned()),
|
1261 + | }),
|
1262 + | );
|
1263 + | ret.insert(
|
1264 + | "baz".to_owned(),
|
1265 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1266 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
1267 + | }),
|
1268 + | );
|
1269 + | ret
|
1270 + | }),
|
1271 + | sparse_number_map: ::std::option::Option::None,
|
1272 + | sparse_boolean_map: ::std::option::Option::None,
|
1273 + | sparse_string_map: ::std::option::Option::None,
|
1274 + | sparse_set_map: ::std::option::Option::None,
|
1275 + | };
|
1276 + | ::pretty_assertions::assert_eq!(input, expected);
|
1277 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1278 + | sparse_struct_map: ::std::option::Option::None,
|
1279 + | sparse_number_map: ::std::option::Option::None,
|
1280 + | sparse_boolean_map: ::std::option::Option::None,
|
1281 + | sparse_string_map: ::std::option::Option::None,
|
1282 + | sparse_set_map: ::std::option::Option::None,
|
1283 + | };
|
1284 + | Ok(output)
|
1285 + | };
|
1286 + | sender.send(()).await.expect("receiver dropped early");
|
1287 + | result
|
1288 + | }
|
1289 + | })
|
1290 + | .build_unchecked();
|
1291 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1292 + | .await
|
1293 + | .expect("unable to make an HTTP request");
|
1294 + | assert!(
|
1295 + | receiver.recv().await.is_some(),
|
1296 + | "we expected operation handler to be invoked but it was not entered"
|
1297 + | );
|
1298 + | }
|
1299 + |
|
1300 + | /// Serializes null map values in sparse maps
|
1301 + | /// Test ID: RpcV2CborSerializesNullMapValues
|
1302 + | #[::tokio::test]
|
1303 + | #[::tracing_test::traced_test]
|
1304 + | async fn rpc_v2_cbor_serializes_null_map_values_request() {
|
1305 + | #[allow(unused_mut)]
|
1306 + | let mut http_request = ::http::Request::builder()
|
1307 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1308 + | .method("POST")
|
1309 + | .header("Accept", "application/cbor")
|
1310 + | .header("Content-Type", "application/cbor")
|
1311 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1312 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1313 + | ::bytes::Bytes::copy_from_slice(
|
1314 + | &::aws_smithy_protocol_test::decode_body_data("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1315 + | )
|
1316 + | )).unwrap();
|
1317 + | #[allow(unused_mut)]
|
1318 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1319 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1320 + | let service =
|
1321 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1322 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1323 + | let sender = sender.clone();
|
1324 + | async move {
|
1325 + | let result = {
|
1326 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1327 + | sparse_boolean_map: ::std::option::Option::Some({
|
1328 + | let mut ret = ::std::collections::HashMap::new();
|
1329 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1330 + | ret
|
1331 + | }),
|
1332 + | sparse_number_map: ::std::option::Option::Some({
|
1333 + | let mut ret = ::std::collections::HashMap::new();
|
1334 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1335 + | ret
|
1336 + | }),
|
1337 + | sparse_string_map: ::std::option::Option::Some({
|
1338 + | let mut ret = ::std::collections::HashMap::new();
|
1339 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1340 + | ret
|
1341 + | }),
|
1342 + | sparse_struct_map: ::std::option::Option::Some({
|
1343 + | let mut ret = ::std::collections::HashMap::new();
|
1344 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1345 + | ret
|
1346 + | }),
|
1347 + | sparse_set_map: ::std::option::Option::None,
|
1348 + | };
|
1349 + | ::pretty_assertions::assert_eq!(input, expected);
|
1350 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1351 + | sparse_struct_map: ::std::option::Option::None,
|
1352 + | sparse_number_map: ::std::option::Option::None,
|
1353 + | sparse_boolean_map: ::std::option::Option::None,
|
1354 + | sparse_string_map: ::std::option::Option::None,
|
1355 + | sparse_set_map: ::std::option::Option::None,
|
1356 + | };
|
1357 + | Ok(output)
|
1358 + | };
|
1359 + | sender.send(()).await.expect("receiver dropped early");
|
1360 + | result
|
1361 + | }
|
1362 + | })
|
1363 + | .build_unchecked();
|
1364 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1365 + | .await
|
1366 + | .expect("unable to make an HTTP request");
|
1367 + | assert!(
|
1368 + | receiver.recv().await.is_some(),
|
1369 + | "we expected operation handler to be invoked but it was not entered"
|
1370 + | );
|
1371 + | }
|
1372 + |
|
1373 + | /// A request that contains a sparse map of sets
|
1374 + | /// Test ID: RpcV2CborSerializesSparseSetMap
|
1375 + | #[::tokio::test]
|
1376 + | #[::tracing_test::traced_test]
|
1377 + | async fn rpc_v2_cbor_serializes_sparse_set_map_request() {
|
1378 + | #[allow(unused_mut)]
|
1379 + | let mut http_request = ::http::Request::builder()
|
1380 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1381 + | .method("POST")
|
1382 + | .header("Accept", "application/cbor")
|
1383 + | .header("Content-Type", "application/cbor")
|
1384 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1385 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1386 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1387 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=".as_bytes(),
|
1388 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1389 + | )),
|
1390 + | ))
|
1391 + | .unwrap();
|
1392 + | #[allow(unused_mut)]
|
1393 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1394 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1395 + | let service =
|
1396 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1397 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1398 + | let sender = sender.clone();
|
1399 + | async move {
|
1400 + | let result = {
|
1401 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1402 + | sparse_set_map: ::std::option::Option::Some({
|
1403 + | let mut ret = ::std::collections::HashMap::new();
|
1404 + | ret.insert(
|
1405 + | "x".to_owned(),
|
1406 + | ::std::option::Option::Some(
|
1407 + | vec![].try_into().expect("this is only used in tests"),
|
1408 + | ),
|
1409 + | );
|
1410 + | ret.insert(
|
1411 + | "y".to_owned(),
|
1412 + | ::std::option::Option::Some(
|
1413 + | vec!["a".to_owned(), "b".to_owned()]
|
1414 + | .try_into()
|
1415 + | .expect("this is only used in tests"),
|
1416 + | ),
|
1417 + | );
|
1418 + | ret
|
1419 + | }),
|
1420 + | sparse_struct_map: ::std::option::Option::None,
|
1421 + | sparse_number_map: ::std::option::Option::None,
|
1422 + | sparse_boolean_map: ::std::option::Option::None,
|
1423 + | sparse_string_map: ::std::option::Option::None,
|
1424 + | };
|
1425 + | ::pretty_assertions::assert_eq!(input, expected);
|
1426 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1427 + | sparse_struct_map: ::std::option::Option::None,
|
1428 + | sparse_number_map: ::std::option::Option::None,
|
1429 + | sparse_boolean_map: ::std::option::Option::None,
|
1430 + | sparse_string_map: ::std::option::Option::None,
|
1431 + | sparse_set_map: ::std::option::Option::None,
|
1432 + | };
|
1433 + | Ok(output)
|
1434 + | };
|
1435 + | sender.send(()).await.expect("receiver dropped early");
|
1436 + | result
|
1437 + | }
|
1438 + | })
|
1439 + | .build_unchecked();
|
1440 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1441 + | .await
|
1442 + | .expect("unable to make an HTTP request");
|
1443 + | assert!(
|
1444 + | receiver.recv().await.is_some(),
|
1445 + | "we expected operation handler to be invoked but it was not entered"
|
1446 + | );
|
1447 + | }
|
1448 + |
|
1449 + | /// A request that contains a sparse map of sets.
|
1450 + | /// Test ID: RpcV2CborSerializesSparseSetMapAndRetainsNull
|
1451 + | #[::tokio::test]
|
1452 + | #[::tracing_test::traced_test]
|
1453 + | async fn rpc_v2_cbor_serializes_sparse_set_map_and_retains_null_request() {
|
1454 + | #[allow(unused_mut)]
|
1455 + | let mut http_request = ::http::Request::builder()
|
1456 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1457 + | .method("POST")
|
1458 + | .header("Accept", "application/cbor")
|
1459 + | .header("Content-Type", "application/cbor")
|
1460 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1461 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1462 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1463 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=".as_bytes(),
|
1464 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1465 + | )),
|
1466 + | ))
|
1467 + | .unwrap();
|
1468 + | #[allow(unused_mut)]
|
1469 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1470 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1471 + | let service =
|
1472 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1473 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1474 + | let sender = sender.clone();
|
1475 + | async move {
|
1476 + | let result = {
|
1477 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1478 + | sparse_set_map: ::std::option::Option::Some({
|
1479 + | let mut ret = ::std::collections::HashMap::new();
|
1480 + | ret.insert(
|
1481 + | "x".to_owned(),
|
1482 + | ::std::option::Option::Some(
|
1483 + | vec![].try_into().expect("this is only used in tests"),
|
1484 + | ),
|
1485 + | );
|
1486 + | ret.insert(
|
1487 + | "y".to_owned(),
|
1488 + | ::std::option::Option::Some(
|
1489 + | vec!["a".to_owned(), "b".to_owned()]
|
1490 + | .try_into()
|
1491 + | .expect("this is only used in tests"),
|
1492 + | ),
|
1493 + | );
|
1494 + | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1495 + | ret
|
1496 + | }),
|
1497 + | sparse_struct_map: ::std::option::Option::None,
|
1498 + | sparse_number_map: ::std::option::Option::None,
|
1499 + | sparse_boolean_map: ::std::option::Option::None,
|
1500 + | sparse_string_map: ::std::option::Option::None,
|
1501 + | };
|
1502 + | ::pretty_assertions::assert_eq!(input, expected);
|
1503 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1504 + | sparse_struct_map: ::std::option::Option::None,
|
1505 + | sparse_number_map: ::std::option::Option::None,
|
1506 + | sparse_boolean_map: ::std::option::Option::None,
|
1507 + | sparse_string_map: ::std::option::Option::None,
|
1508 + | sparse_set_map: ::std::option::Option::None,
|
1509 + | };
|
1510 + | Ok(output)
|
1511 + | };
|
1512 + | sender.send(()).await.expect("receiver dropped early");
|
1513 + | result
|
1514 + | }
|
1515 + | })
|
1516 + | .build_unchecked();
|
1517 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1518 + | .await
|
1519 + | .expect("unable to make an HTTP request");
|
1520 + | assert!(
|
1521 + | receiver.recv().await.is_some(),
|
1522 + | "we expected operation handler to be invoked but it was not entered"
|
1523 + | );
|
1524 + | }
|
1525 + |
|
1526 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1527 + | /// Test ID: RpcV2CborSerializesZeroValuesInSparseMaps
|
1528 + | #[::tokio::test]
|
1529 + | #[::tracing_test::traced_test]
|
1530 + | async fn rpc_v2_cbor_serializes_zero_values_in_sparse_maps_request() {
|
1531 + | #[allow(unused_mut)]
|
1532 + | let mut http_request = ::http::Request::builder()
|
1533 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborSparseMaps")
|
1534 + | .method("POST")
|
1535 + | .header("Accept", "application/cbor")
|
1536 + | .header("Content-Type", "application/cbor")
|
1537 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1538 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1539 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1540 + | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//".as_bytes(),
|
1541 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1542 + | )),
|
1543 + | ))
|
1544 + | .unwrap();
|
1545 + | #[allow(unused_mut)]
|
1546 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1547 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1548 + | let service =
|
1549 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1550 + | .rpc_v2_cbor_sparse_maps(move |input: crate::input::RpcV2CborSparseMapsInput| {
|
1551 + | let sender = sender.clone();
|
1552 + | async move {
|
1553 + | let result = {
|
1554 + | let expected = crate::input::RpcV2CborSparseMapsInput {
|
1555 + | sparse_number_map: ::std::option::Option::Some({
|
1556 + | let mut ret = ::std::collections::HashMap::new();
|
1557 + | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1558 + | ret
|
1559 + | }),
|
1560 + | sparse_boolean_map: ::std::option::Option::Some({
|
1561 + | let mut ret = ::std::collections::HashMap::new();
|
1562 + | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
1563 + | ret
|
1564 + | }),
|
1565 + | sparse_struct_map: ::std::option::Option::None,
|
1566 + | sparse_string_map: ::std::option::Option::None,
|
1567 + | sparse_set_map: ::std::option::Option::None,
|
1568 + | };
|
1569 + | ::pretty_assertions::assert_eq!(input, expected);
|
1570 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1571 + | sparse_struct_map: ::std::option::Option::None,
|
1572 + | sparse_number_map: ::std::option::Option::None,
|
1573 + | sparse_boolean_map: ::std::option::Option::None,
|
1574 + | sparse_string_map: ::std::option::Option::None,
|
1575 + | sparse_set_map: ::std::option::Option::None,
|
1576 + | };
|
1577 + | Ok(output)
|
1578 + | };
|
1579 + | sender.send(()).await.expect("receiver dropped early");
|
1580 + | result
|
1581 + | }
|
1582 + | })
|
1583 + | .build_unchecked();
|
1584 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1585 + | .await
|
1586 + | .expect("unable to make an HTTP request");
|
1587 + | assert!(
|
1588 + | receiver.recv().await.is_some(),
|
1589 + | "we expected operation handler to be invoked but it was not entered"
|
1590 + | );
|
1591 + | }
|
1592 + |
|
1593 + | /// Deserializes sparse maps
|
1594 + | /// Test ID: RpcV2CborSparseJsonMaps
|
1595 + | #[::tokio::test]
|
1596 + | #[::tracing_test::traced_test]
|
1597 + | async fn rpc_v2_cbor_sparse_json_maps_response() {
|
1598 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1599 + | sparse_struct_map: ::std::option::Option::Some({
|
1600 + | let mut ret = ::std::collections::HashMap::new();
|
1601 + | ret.insert(
|
1602 + | "foo".to_owned(),
|
1603 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1604 + | hi: ::std::option::Option::Some("there".to_owned()),
|
1605 + | }),
|
1606 + | );
|
1607 + | ret.insert(
|
1608 + | "baz".to_owned(),
|
1609 + | ::std::option::Option::Some(crate::model::GreetingStruct {
|
1610 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
1611 + | }),
|
1612 + | );
|
1613 + | ret
|
1614 + | }),
|
1615 + | sparse_number_map: ::std::option::Option::None,
|
1616 + | sparse_boolean_map: ::std::option::Option::None,
|
1617 + | sparse_string_map: ::std::option::Option::None,
|
1618 + | sparse_set_map: ::std::option::Option::None,
|
1619 + | };
|
1620 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1621 + | let http_response = output.into_response();
|
1622 + | ::pretty_assertions::assert_eq!(
|
1623 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1624 + | http_response.status()
|
1625 + | );
|
1626 + | let expected_headers = [
|
1627 + | ("Content-Type", "application/cbor"),
|
1628 + | ("smithy-protocol", "rpc-v2-cbor"),
|
1629 + | ];
|
1630 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1631 + | http_response.headers(),
|
1632 + | expected_headers,
|
1633 + | ));
|
1634 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1635 + | .await
|
1636 + | .expect("unable to extract body to bytes");
|
1637 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1638 + | &body,
|
1639 + | "v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////",
|
1640 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1641 + | ));
|
1642 + | }
|
1643 + |
|
1644 + | /// Deserializes null map values
|
1645 + | /// Test ID: RpcV2CborDeserializesNullMapValues
|
1646 + | #[::tokio::test]
|
1647 + | #[::tracing_test::traced_test]
|
1648 + | async fn rpc_v2_cbor_deserializes_null_map_values_response() {
|
1649 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1650 + | sparse_boolean_map: ::std::option::Option::Some({
|
1651 + | let mut ret = ::std::collections::HashMap::new();
|
1652 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1653 + | ret
|
1654 + | }),
|
1655 + | sparse_number_map: ::std::option::Option::Some({
|
1656 + | let mut ret = ::std::collections::HashMap::new();
|
1657 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1658 + | ret
|
1659 + | }),
|
1660 + | sparse_string_map: ::std::option::Option::Some({
|
1661 + | let mut ret = ::std::collections::HashMap::new();
|
1662 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1663 + | ret
|
1664 + | }),
|
1665 + | sparse_struct_map: ::std::option::Option::Some({
|
1666 + | let mut ret = ::std::collections::HashMap::new();
|
1667 + | ret.insert("x".to_owned(), ::std::option::Option::None);
|
1668 + | ret
|
1669 + | }),
|
1670 + | sparse_set_map: ::std::option::Option::None,
|
1671 + | };
|
1672 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1673 + | let http_response = output.into_response();
|
1674 + | ::pretty_assertions::assert_eq!(
|
1675 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1676 + | http_response.status()
|
1677 + | );
|
1678 + | let expected_headers = [
|
1679 + | ("Content-Type", "application/cbor"),
|
1680 + | ("smithy-protocol", "rpc-v2-cbor"),
|
1681 + | ];
|
1682 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1683 + | http_response.headers(),
|
1684 + | expected_headers,
|
1685 + | ));
|
1686 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1687 + | .await
|
1688 + | .expect("unable to extract body to bytes");
|
1689 + | ::aws_smithy_protocol_test::assert_ok(
|
1690 + | ::aws_smithy_protocol_test::validate_body(&body, "v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
1691 + | );
|
1692 + | }
|
1693 + |
|
1694 + | /// A response that contains a sparse map of sets
|
1695 + | /// Test ID: RpcV2CborDeserializesSparseSetMap
|
1696 + | #[::tokio::test]
|
1697 + | #[::tracing_test::traced_test]
|
1698 + | async fn rpc_v2_cbor_deserializes_sparse_set_map_response() {
|
1699 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1700 + | sparse_set_map: ::std::option::Option::Some({
|
1701 + | let mut ret = ::std::collections::HashMap::new();
|
1702 + | ret.insert(
|
1703 + | "x".to_owned(),
|
1704 + | ::std::option::Option::Some(
|
1705 + | vec![].try_into().expect("this is only used in tests"),
|
1706 + | ),
|
1707 + | );
|
1708 + | ret.insert(
|
1709 + | "y".to_owned(),
|
1710 + | ::std::option::Option::Some(
|
1711 + | vec!["a".to_owned(), "b".to_owned()]
|
1712 + | .try_into()
|
1713 + | .expect("this is only used in tests"),
|
1714 + | ),
|
1715 + | );
|
1716 + | ret
|
1717 + | }),
|
1718 + | sparse_struct_map: ::std::option::Option::None,
|
1719 + | sparse_number_map: ::std::option::Option::None,
|
1720 + | sparse_boolean_map: ::std::option::Option::None,
|
1721 + | sparse_string_map: ::std::option::Option::None,
|
1722 + | };
|
1723 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1724 + | let http_response = output.into_response();
|
1725 + | ::pretty_assertions::assert_eq!(
|
1726 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1727 + | http_response.status()
|
1728 + | );
|
1729 + | let expected_headers = [
|
1730 + | ("Content-Type", "application/cbor"),
|
1731 + | ("smithy-protocol", "rpc-v2-cbor"),
|
1732 + | ];
|
1733 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1734 + | http_response.headers(),
|
1735 + | expected_headers,
|
1736 + | ));
|
1737 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1738 + | .await
|
1739 + | .expect("unable to extract body to bytes");
|
1740 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1741 + | &body,
|
1742 + | "v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=",
|
1743 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1744 + | ));
|
1745 + | }
|
1746 + |
|
1747 + | /// A response that contains a sparse map of sets with a null
|
1748 + | /// Test ID: RpcV2CborDeserializesSparseSetMapAndRetainsNull
|
1749 + | #[::tokio::test]
|
1750 + | #[::tracing_test::traced_test]
|
1751 + | async fn rpc_v2_cbor_deserializes_sparse_set_map_and_retains_null_response() {
|
1752 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1753 + | sparse_set_map: ::std::option::Option::Some({
|
1754 + | let mut ret = ::std::collections::HashMap::new();
|
1755 + | ret.insert(
|
1756 + | "x".to_owned(),
|
1757 + | ::std::option::Option::Some(
|
1758 + | vec![].try_into().expect("this is only used in tests"),
|
1759 + | ),
|
1760 + | );
|
1761 + | ret.insert(
|
1762 + | "y".to_owned(),
|
1763 + | ::std::option::Option::Some(
|
1764 + | vec!["a".to_owned(), "b".to_owned()]
|
1765 + | .try_into()
|
1766 + | .expect("this is only used in tests"),
|
1767 + | ),
|
1768 + | );
|
1769 + | ret.insert("z".to_owned(), ::std::option::Option::None);
|
1770 + | ret
|
1771 + | }),
|
1772 + | sparse_struct_map: ::std::option::Option::None,
|
1773 + | sparse_number_map: ::std::option::Option::None,
|
1774 + | sparse_boolean_map: ::std::option::Option::None,
|
1775 + | sparse_string_map: ::std::option::Option::None,
|
1776 + | };
|
1777 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1778 + | let http_response = output.into_response();
|
1779 + | ::pretty_assertions::assert_eq!(
|
1780 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1781 + | http_response.status()
|
1782 + | );
|
1783 + | let expected_headers = [
|
1784 + | ("Content-Type", "application/cbor"),
|
1785 + | ("smithy-protocol", "rpc-v2-cbor"),
|
1786 + | ];
|
1787 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1788 + | http_response.headers(),
|
1789 + | expected_headers,
|
1790 + | ));
|
1791 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1792 + | .await
|
1793 + | .expect("unable to extract body to bytes");
|
1794 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1795 + | &body,
|
1796 + | "v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=",
|
1797 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1798 + | ));
|
1799 + | }
|
1800 + |
|
1801 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
1802 + | /// Test ID: RpcV2CborDeserializesZeroValuesInSparseMaps
|
1803 + | #[::tokio::test]
|
1804 + | #[::tracing_test::traced_test]
|
1805 + | async fn rpc_v2_cbor_deserializes_zero_values_in_sparse_maps_response() {
|
1806 + | let output = crate::output::RpcV2CborSparseMapsOutput {
|
1807 + | sparse_number_map: ::std::option::Option::Some({
|
1808 + | let mut ret = ::std::collections::HashMap::new();
|
1809 + | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
1810 + | ret
|
1811 + | }),
|
1812 + | sparse_boolean_map: ::std::option::Option::Some({
|
1813 + | let mut ret = ::std::collections::HashMap::new();
|
1814 + | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
1815 + | ret
|
1816 + | }),
|
1817 + | sparse_struct_map: ::std::option::Option::None,
|
1818 + | sparse_string_map: ::std::option::Option::None,
|
1819 + | sparse_set_map: ::std::option::Option::None,
|
1820 + | };
|
1821 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
1822 + | let http_response = output.into_response();
|
1823 + | ::pretty_assertions::assert_eq!(
|
1824 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
1825 + | http_response.status()
|
1826 + | );
|
1827 + | let expected_headers = [
|
1828 + | ("Content-Type", "application/cbor"),
|
1829 + | ("smithy-protocol", "rpc-v2-cbor"),
|
1830 + | ];
|
1831 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1832 + | http_response.headers(),
|
1833 + | expected_headers,
|
1834 + | ));
|
1835 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1836 + | .await
|
1837 + | .expect("unable to extract body to bytes");
|
1838 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
1839 + | &body,
|
1840 + | "v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//",
|
1841 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1842 + | ));
|
1843 + | }
|
1844 + | }
|
1845 + |
|
1846 + | ::pin_project_lite::pin_project! {
|
1847 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1848 + | /// [`RpcV2CborDenseMapsInput`](crate::input::RpcV2CborDenseMapsInput) using modelled bindings.
|
1849 + | pub struct RpcV2CborDenseMapsInputFuture {
|
1850 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborDenseMapsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
1851 + | }
|
1852 + | }
|
1853 + |
|
1854 + | impl std::future::Future for RpcV2CborDenseMapsInputFuture {
|
1855 + | type Output = Result<
|
1856 + | crate::input::RpcV2CborDenseMapsInput,
|
1857 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
1858 + | >;
|
1859 + |
|
1860 + | fn poll(
|
1861 + | self: std::pin::Pin<&mut Self>,
|
1862 + | cx: &mut std::task::Context<'_>,
|
1863 + | ) -> std::task::Poll<Self::Output> {
|
1864 + | let this = self.project();
|
1865 + | this.inner.as_mut().poll(cx)
|
1866 + | }
|
1867 + | }
|
1868 + |
|
1869 + | impl<B>
|
1870 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1871 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1872 + | B,
|
1873 + | > for crate::input::RpcV2CborDenseMapsInput
|
1874 + | where
|
1875 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1876 + | B: 'static,
|
1877 + |
|
1878 + | B::Data: Send,
|
1879 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
1880 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1881 + | {
|
1882 + | type Rejection =
|
1883 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
1884 + | type Future = RpcV2CborDenseMapsInputFuture;
|
1885 + |
|
1886 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1887 + | let fut = async move {
|
1888 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1889 + | request.headers(),
|
1890 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
1891 + | ) {
|
1892 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
1893 + | }
|
1894 + | crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::de_rpc_v2_cbor_dense_maps_http_request(request)
|
1895 + | .await
|
1896 + | };
|
1897 + | use ::futures_util::future::TryFutureExt;
|
1898 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
1899 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1900 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
1901 + | });
|
1902 + | RpcV2CborDenseMapsInputFuture {
|
1903 + | inner: Box::pin(fut),
|
1904 + | }
|
1905 + | }
|
1906 + | }
|
1907 + | impl
|
1908 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1909 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1910 + | > for crate::output::RpcV2CborDenseMapsOutput
|
1911 + | {
|
1912 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1913 + | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_response(self) {
|
1914 + | Ok(response) => response,
|
1915 + | Err(e) => {
|
1916 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1917 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1918 + | }
|
1919 + | }
|
1920 + | }
|
1921 + | }
|
1922 + | impl
|
1923 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1924 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
1925 + | > for crate::error::RpcV2CborDenseMapsError
|
1926 + | {
|
1927 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1928 + | match crate::protocol_serde::shape_rpc_v2_cbor_dense_maps::ser_rpc_v2_cbor_dense_maps_http_error(&self) {
|
1929 + | Ok(mut response) => {
|
1930 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1931 + | response
|
1932 + | },
|
1933 + | Err(e) => {
|
1934 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1935 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
1936 + | }
|
1937 + | }
|
1938 + | }
|
1939 + | }
|
1940 + |
|
1941 + | #[allow(unreachable_code, unused_variables)]
|
1942 + | #[cfg(test)]
|
1943 + | mod rpc_v2_cbor_dense_maps_test {
|
1944 + |
|
1945 + | /// Serializes maps
|
1946 + | /// Test ID: RpcV2CborMaps
|
1947 + | #[::tokio::test]
|
1948 + | #[::tracing_test::traced_test]
|
1949 + | async fn rpc_v2_cbor_maps_request() {
|
1950 + | #[allow(unused_mut)]
|
1951 + | let mut http_request = ::http::Request::builder()
|
1952 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
1953 + | .method("POST")
|
1954 + | .header("Accept", "application/cbor")
|
1955 + | .header("Content-Type", "application/cbor")
|
1956 + | .header("smithy-protocol", "rpc-v2-cbor")
|
1957 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1958 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1959 + | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==".as_bytes(),
|
1960 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
1961 + | )),
|
1962 + | ))
|
1963 + | .unwrap();
|
1964 + | #[allow(unused_mut)]
|
1965 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1966 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
1967 + | let service =
|
1968 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
1969 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
1970 + | let sender = sender.clone();
|
1971 + | async move {
|
1972 + | let result = {
|
1973 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
1974 + | dense_struct_map: ::std::option::Option::Some({
|
1975 + | let mut ret = ::std::collections::HashMap::new();
|
1976 + | ret.insert(
|
1977 + | "foo".to_owned(),
|
1978 + | crate::model::GreetingStruct {
|
1979 + | hi: ::std::option::Option::Some("there".to_owned()),
|
1980 + | },
|
1981 + | );
|
1982 + | ret.insert(
|
1983 + | "baz".to_owned(),
|
1984 + | crate::model::GreetingStruct {
|
1985 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
1986 + | },
|
1987 + | );
|
1988 + | ret
|
1989 + | }),
|
1990 + | dense_number_map: ::std::option::Option::None,
|
1991 + | dense_boolean_map: ::std::option::Option::None,
|
1992 + | dense_string_map: ::std::option::Option::None,
|
1993 + | dense_set_map: ::std::option::Option::None,
|
1994 + | };
|
1995 + | ::pretty_assertions::assert_eq!(input, expected);
|
1996 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
1997 + | dense_struct_map: ::std::option::Option::None,
|
1998 + | dense_number_map: ::std::option::Option::None,
|
1999 + | dense_boolean_map: ::std::option::Option::None,
|
2000 + | dense_string_map: ::std::option::Option::None,
|
2001 + | dense_set_map: ::std::option::Option::None,
|
2002 + | };
|
2003 + | Ok(output)
|
2004 + | };
|
2005 + | sender.send(()).await.expect("receiver dropped early");
|
2006 + | result
|
2007 + | }
|
2008 + | })
|
2009 + | .build_unchecked();
|
2010 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2011 + | .await
|
2012 + | .expect("unable to make an HTTP request");
|
2013 + | assert!(
|
2014 + | receiver.recv().await.is_some(),
|
2015 + | "we expected operation handler to be invoked but it was not entered"
|
2016 + | );
|
2017 + | }
|
2018 + |
|
2019 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
2020 + | /// Test ID: RpcV2CborSerializesZeroValuesInMaps
|
2021 + | #[::tokio::test]
|
2022 + | #[::tracing_test::traced_test]
|
2023 + | async fn rpc_v2_cbor_serializes_zero_values_in_maps_request() {
|
2024 + | #[allow(unused_mut)]
|
2025 + | let mut http_request = ::http::Request::builder()
|
2026 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2027 + | .method("POST")
|
2028 + | .header("Accept", "application/cbor")
|
2029 + | .header("Content-Type", "application/cbor")
|
2030 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2031 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2032 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2033 + | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==".as_bytes(),
|
2034 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2035 + | )),
|
2036 + | ))
|
2037 + | .unwrap();
|
2038 + | #[allow(unused_mut)]
|
2039 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2040 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2041 + | let service =
|
2042 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2043 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
2044 + | let sender = sender.clone();
|
2045 + | async move {
|
2046 + | let result = {
|
2047 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2048 + | dense_number_map: ::std::option::Option::Some({
|
2049 + | let mut ret = ::std::collections::HashMap::new();
|
2050 + | ret.insert("x".to_owned(), 0);
|
2051 + | ret
|
2052 + | }),
|
2053 + | dense_boolean_map: ::std::option::Option::Some({
|
2054 + | let mut ret = ::std::collections::HashMap::new();
|
2055 + | ret.insert("x".to_owned(), false);
|
2056 + | ret
|
2057 + | }),
|
2058 + | dense_struct_map: ::std::option::Option::None,
|
2059 + | dense_string_map: ::std::option::Option::None,
|
2060 + | dense_set_map: ::std::option::Option::None,
|
2061 + | };
|
2062 + | ::pretty_assertions::assert_eq!(input, expected);
|
2063 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2064 + | dense_struct_map: ::std::option::Option::None,
|
2065 + | dense_number_map: ::std::option::Option::None,
|
2066 + | dense_boolean_map: ::std::option::Option::None,
|
2067 + | dense_string_map: ::std::option::Option::None,
|
2068 + | dense_set_map: ::std::option::Option::None,
|
2069 + | };
|
2070 + | Ok(output)
|
2071 + | };
|
2072 + | sender.send(()).await.expect("receiver dropped early");
|
2073 + | result
|
2074 + | }
|
2075 + | })
|
2076 + | .build_unchecked();
|
2077 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2078 + | .await
|
2079 + | .expect("unable to make an HTTP request");
|
2080 + | assert!(
|
2081 + | receiver.recv().await.is_some(),
|
2082 + | "we expected operation handler to be invoked but it was not entered"
|
2083 + | );
|
2084 + | }
|
2085 + |
|
2086 + | /// A request that contains a dense map of sets.
|
2087 + | /// Test ID: RpcV2CborSerializesDenseSetMap
|
2088 + | #[::tokio::test]
|
2089 + | #[::tracing_test::traced_test]
|
2090 + | async fn rpc_v2_cbor_serializes_dense_set_map_request() {
|
2091 + | #[allow(unused_mut)]
|
2092 + | let mut http_request = ::http::Request::builder()
|
2093 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborDenseMaps")
|
2094 + | .method("POST")
|
2095 + | .header("Accept", "application/cbor")
|
2096 + | .header("Content-Type", "application/cbor")
|
2097 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2098 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2099 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2100 + | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi".as_bytes(),
|
2101 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2102 + | )),
|
2103 + | ))
|
2104 + | .unwrap();
|
2105 + | #[allow(unused_mut)]
|
2106 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2107 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2108 + | let service =
|
2109 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2110 + | .rpc_v2_cbor_dense_maps(move |input: crate::input::RpcV2CborDenseMapsInput| {
|
2111 + | let sender = sender.clone();
|
2112 + | async move {
|
2113 + | let result = {
|
2114 + | let expected = crate::input::RpcV2CborDenseMapsInput {
|
2115 + | dense_set_map: ::std::option::Option::Some({
|
2116 + | let mut ret = ::std::collections::HashMap::new();
|
2117 + | ret.insert(
|
2118 + | "x".to_owned(),
|
2119 + | vec![].try_into().expect("this is only used in tests"),
|
2120 + | );
|
2121 + | ret.insert(
|
2122 + | "y".to_owned(),
|
2123 + | vec!["a".to_owned(), "b".to_owned()]
|
2124 + | .try_into()
|
2125 + | .expect("this is only used in tests"),
|
2126 + | );
|
2127 + | ret
|
2128 + | }),
|
2129 + | dense_struct_map: ::std::option::Option::None,
|
2130 + | dense_number_map: ::std::option::Option::None,
|
2131 + | dense_boolean_map: ::std::option::Option::None,
|
2132 + | dense_string_map: ::std::option::Option::None,
|
2133 + | };
|
2134 + | ::pretty_assertions::assert_eq!(input, expected);
|
2135 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2136 + | dense_struct_map: ::std::option::Option::None,
|
2137 + | dense_number_map: ::std::option::Option::None,
|
2138 + | dense_boolean_map: ::std::option::Option::None,
|
2139 + | dense_string_map: ::std::option::Option::None,
|
2140 + | dense_set_map: ::std::option::Option::None,
|
2141 + | };
|
2142 + | Ok(output)
|
2143 + | };
|
2144 + | sender.send(()).await.expect("receiver dropped early");
|
2145 + | result
|
2146 + | }
|
2147 + | })
|
2148 + | .build_unchecked();
|
2149 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2150 + | .await
|
2151 + | .expect("unable to make an HTTP request");
|
2152 + | assert!(
|
2153 + | receiver.recv().await.is_some(),
|
2154 + | "we expected operation handler to be invoked but it was not entered"
|
2155 + | );
|
2156 + | }
|
2157 + |
|
2158 + | /// Deserializes maps
|
2159 + | /// Test ID: RpcV2CborMaps
|
2160 + | #[::tokio::test]
|
2161 + | #[::tracing_test::traced_test]
|
2162 + | async fn rpc_v2_cbor_maps_response() {
|
2163 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2164 + | dense_struct_map: ::std::option::Option::Some({
|
2165 + | let mut ret = ::std::collections::HashMap::new();
|
2166 + | ret.insert(
|
2167 + | "foo".to_owned(),
|
2168 + | crate::model::GreetingStruct {
|
2169 + | hi: ::std::option::Option::Some("there".to_owned()),
|
2170 + | },
|
2171 + | );
|
2172 + | ret.insert(
|
2173 + | "baz".to_owned(),
|
2174 + | crate::model::GreetingStruct {
|
2175 + | hi: ::std::option::Option::Some("bye".to_owned()),
|
2176 + | },
|
2177 + | );
|
2178 + | ret
|
2179 + | }),
|
2180 + | dense_number_map: ::std::option::Option::None,
|
2181 + | dense_boolean_map: ::std::option::Option::None,
|
2182 + | dense_string_map: ::std::option::Option::None,
|
2183 + | dense_set_map: ::std::option::Option::None,
|
2184 + | };
|
2185 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2186 + | let http_response = output.into_response();
|
2187 + | ::pretty_assertions::assert_eq!(
|
2188 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2189 + | http_response.status()
|
2190 + | );
|
2191 + | let expected_headers = [
|
2192 + | ("Content-Type", "application/cbor"),
|
2193 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2194 + | ];
|
2195 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2196 + | http_response.headers(),
|
2197 + | expected_headers,
|
2198 + | ));
|
2199 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2200 + | .await
|
2201 + | .expect("unable to extract body to bytes");
|
2202 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2203 + | &body,
|
2204 + | "oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==",
|
2205 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2206 + | ));
|
2207 + | }
|
2208 + |
|
2209 + | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
2210 + | /// Test ID: RpcV2CborDeserializesZeroValuesInMaps
|
2211 + | #[::tokio::test]
|
2212 + | #[::tracing_test::traced_test]
|
2213 + | async fn rpc_v2_cbor_deserializes_zero_values_in_maps_response() {
|
2214 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2215 + | dense_number_map: ::std::option::Option::Some({
|
2216 + | let mut ret = ::std::collections::HashMap::new();
|
2217 + | ret.insert("x".to_owned(), 0);
|
2218 + | ret
|
2219 + | }),
|
2220 + | dense_boolean_map: ::std::option::Option::Some({
|
2221 + | let mut ret = ::std::collections::HashMap::new();
|
2222 + | ret.insert("x".to_owned(), false);
|
2223 + | ret
|
2224 + | }),
|
2225 + | dense_struct_map: ::std::option::Option::None,
|
2226 + | dense_string_map: ::std::option::Option::None,
|
2227 + | dense_set_map: ::std::option::Option::None,
|
2228 + | };
|
2229 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2230 + | let http_response = output.into_response();
|
2231 + | ::pretty_assertions::assert_eq!(
|
2232 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2233 + | http_response.status()
|
2234 + | );
|
2235 + | let expected_headers = [
|
2236 + | ("Content-Type", "application/cbor"),
|
2237 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2238 + | ];
|
2239 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2240 + | http_response.headers(),
|
2241 + | expected_headers,
|
2242 + | ));
|
2243 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2244 + | .await
|
2245 + | .expect("unable to extract body to bytes");
|
2246 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2247 + | &body,
|
2248 + | "om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==",
|
2249 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2250 + | ));
|
2251 + | }
|
2252 + |
|
2253 + | /// A response that contains a dense map of sets
|
2254 + | /// Test ID: RpcV2CborDeserializesDenseSetMap
|
2255 + | #[::tokio::test]
|
2256 + | #[::tracing_test::traced_test]
|
2257 + | async fn rpc_v2_cbor_deserializes_dense_set_map_response() {
|
2258 + | let output = crate::output::RpcV2CborDenseMapsOutput {
|
2259 + | dense_set_map: ::std::option::Option::Some({
|
2260 + | let mut ret = ::std::collections::HashMap::new();
|
2261 + | ret.insert(
|
2262 + | "x".to_owned(),
|
2263 + | vec![].try_into().expect("this is only used in tests"),
|
2264 + | );
|
2265 + | ret.insert(
|
2266 + | "y".to_owned(),
|
2267 + | vec!["a".to_owned(), "b".to_owned()]
|
2268 + | .try_into()
|
2269 + | .expect("this is only used in tests"),
|
2270 + | );
|
2271 + | ret
|
2272 + | }),
|
2273 + | dense_struct_map: ::std::option::Option::None,
|
2274 + | dense_number_map: ::std::option::Option::None,
|
2275 + | dense_boolean_map: ::std::option::Option::None,
|
2276 + | dense_string_map: ::std::option::Option::None,
|
2277 + | };
|
2278 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2279 + | let http_response = output.into_response();
|
2280 + | ::pretty_assertions::assert_eq!(
|
2281 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2282 + | http_response.status()
|
2283 + | );
|
2284 + | let expected_headers = [
|
2285 + | ("Content-Type", "application/cbor"),
|
2286 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2287 + | ];
|
2288 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2289 + | http_response.headers(),
|
2290 + | expected_headers,
|
2291 + | ));
|
2292 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2293 + | .await
|
2294 + | .expect("unable to extract body to bytes");
|
2295 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2296 + | &body,
|
2297 + | "oWtkZW5zZVNldE1hcKJheIBheYJhYWFi",
|
2298 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2299 + | ));
|
2300 + | }
|
2301 + | }
|
2302 + |
|
2303 + | ::pin_project_lite::pin_project! {
|
2304 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2305 + | /// [`RpcV2CborListsInput`](crate::input::RpcV2CborListsInput) using modelled bindings.
|
2306 + | pub struct RpcV2CborListsInputFuture {
|
2307 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RpcV2CborListsInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2308 + | }
|
2309 + | }
|
2310 + |
|
2311 + | impl std::future::Future for RpcV2CborListsInputFuture {
|
2312 + | type Output = Result<
|
2313 + | crate::input::RpcV2CborListsInput,
|
2314 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
2315 + | >;
|
2316 + |
|
2317 + | fn poll(
|
2318 + | self: std::pin::Pin<&mut Self>,
|
2319 + | cx: &mut std::task::Context<'_>,
|
2320 + | ) -> std::task::Poll<Self::Output> {
|
2321 + | let this = self.project();
|
2322 + | this.inner.as_mut().poll(cx)
|
2323 + | }
|
2324 + | }
|
2325 + |
|
2326 + | impl<B>
|
2327 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2328 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2329 + | B,
|
2330 + | > for crate::input::RpcV2CborListsInput
|
2331 + | where
|
2332 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2333 + | B: 'static,
|
2334 + |
|
2335 + | B::Data: Send,
|
2336 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
2337 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2338 + | {
|
2339 + | type Rejection =
|
2340 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
2341 + | type Future = RpcV2CborListsInputFuture;
|
2342 + |
|
2343 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2344 + | let fut = async move {
|
2345 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2346 + | request.headers(),
|
2347 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
2348 + | ) {
|
2349 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
2350 + | }
|
2351 + | crate::protocol_serde::shape_rpc_v2_cbor_lists::de_rpc_v2_cbor_lists_http_request(
|
2352 + | request,
|
2353 + | )
|
2354 + | .await
|
2355 + | };
|
2356 + | use ::futures_util::future::TryFutureExt;
|
2357 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
2358 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2359 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
2360 + | });
|
2361 + | RpcV2CborListsInputFuture {
|
2362 + | inner: Box::pin(fut),
|
2363 + | }
|
2364 + | }
|
2365 + | }
|
2366 + | impl
|
2367 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2368 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2369 + | > for crate::output::RpcV2CborListsOutput
|
2370 + | {
|
2371 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2372 + | match crate::protocol_serde::shape_rpc_v2_cbor_lists::ser_rpc_v2_cbor_lists_http_response(
|
2373 + | self,
|
2374 + | ) {
|
2375 + | Ok(response) => response,
|
2376 + | Err(e) => {
|
2377 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2378 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2379 + | }
|
2380 + | }
|
2381 + | }
|
2382 + | }
|
2383 + | impl
|
2384 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2385 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2386 + | > for crate::error::RpcV2CborListsError
|
2387 + | {
|
2388 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2389 + | match crate::protocol_serde::shape_rpc_v2_cbor_lists::ser_rpc_v2_cbor_lists_http_error(
|
2390 + | &self,
|
2391 + | ) {
|
2392 + | Ok(mut response) => {
|
2393 + | response.extensions_mut().insert(
|
2394 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
2395 + | self.name(),
|
2396 + | ),
|
2397 + | );
|
2398 + | response
|
2399 + | }
|
2400 + | Err(e) => {
|
2401 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2402 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2403 + | }
|
2404 + | }
|
2405 + | }
|
2406 + | }
|
2407 + |
|
2408 + | #[allow(unreachable_code, unused_variables)]
|
2409 + | #[cfg(test)]
|
2410 + | mod rpc_v2_cbor_lists_test {
|
2411 + |
|
2412 + | /// Serializes RpcV2 Cbor lists
|
2413 + | /// Test ID: RpcV2CborLists
|
2414 + | #[::tokio::test]
|
2415 + | #[::tracing_test::traced_test]
|
2416 + | async fn rpc_v2_cbor_lists_request() {
|
2417 + | #[allow(unused_mut)]
|
2418 + | let mut http_request = ::http::Request::builder()
|
2419 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2420 + | .method("POST")
|
2421 + | .header("Accept", "application/cbor")
|
2422 + | .header("Content-Type", "application/cbor")
|
2423 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2424 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2425 + | ::bytes::Bytes::copy_from_slice(
|
2426 + | &::aws_smithy_protocol_test::decode_body_data("v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2427 + | )
|
2428 + | )).unwrap();
|
2429 + | #[allow(unused_mut)]
|
2430 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2431 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2432 + | let service =
|
2433 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2434 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2435 + | let sender = sender.clone();
|
2436 + | async move {
|
2437 + | let result = {
|
2438 + | let expected = crate::input::RpcV2CborListsInput {
|
2439 + | string_list: ::std::option::Option::Some(vec![
|
2440 + | "foo".to_owned(),
|
2441 + | "bar".to_owned(),
|
2442 + | ]),
|
2443 + | string_set: ::std::option::Option::Some(
|
2444 + | vec!["foo".to_owned(), "bar".to_owned()]
|
2445 + | .try_into()
|
2446 + | .expect("this is only used in tests"),
|
2447 + | ),
|
2448 + | integer_list: ::std::option::Option::Some(vec![1, 2]),
|
2449 + | boolean_list: ::std::option::Option::Some(vec![true, false]),
|
2450 + | timestamp_list: ::std::option::Option::Some(vec![
|
2451 + | ::aws_smithy_types::DateTime::from_fractional_secs(
|
2452 + | 1398796238, 0_f64,
|
2453 + | ),
|
2454 + | ::aws_smithy_types::DateTime::from_fractional_secs(
|
2455 + | 1398796238, 0_f64,
|
2456 + | ),
|
2457 + | ]),
|
2458 + | enum_list: ::std::option::Option::Some(vec![
|
2459 + | "Foo"
|
2460 + | .parse::<crate::model::FooEnum>()
|
2461 + | .expect("static value validated to member"),
|
2462 + | "0".parse::<crate::model::FooEnum>()
|
2463 + | .expect("static value validated to member"),
|
2464 + | ]),
|
2465 + | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
2466 + | nested_string_list: ::std::option::Option::Some(vec![
|
2467 + | vec!["foo".to_owned(), "bar".to_owned()],
|
2468 + | vec!["baz".to_owned(), "qux".to_owned()],
|
2469 + | ]),
|
2470 + | structure_list: ::std::option::Option::Some(vec![
|
2471 + | crate::model::StructureListMember {
|
2472 + | a: ::std::option::Option::Some("1".to_owned()),
|
2473 + | b: ::std::option::Option::Some("2".to_owned()),
|
2474 + | },
|
2475 + | crate::model::StructureListMember {
|
2476 + | a: ::std::option::Option::Some("3".to_owned()),
|
2477 + | b: ::std::option::Option::Some("4".to_owned()),
|
2478 + | },
|
2479 + | ]),
|
2480 + | blob_list: ::std::option::Option::Some(vec![
|
2481 + | ::aws_smithy_types::Blob::new("foo"),
|
2482 + | ::aws_smithy_types::Blob::new("bar"),
|
2483 + | ]),
|
2484 + | };
|
2485 + | ::pretty_assertions::assert_eq!(input, expected);
|
2486 + | let output = crate::output::RpcV2CborListsOutput {
|
2487 + | string_list: ::std::option::Option::None,
|
2488 + | string_set: ::std::option::Option::None,
|
2489 + | integer_list: ::std::option::Option::None,
|
2490 + | boolean_list: ::std::option::Option::None,
|
2491 + | timestamp_list: ::std::option::Option::None,
|
2492 + | enum_list: ::std::option::Option::None,
|
2493 + | int_enum_list: ::std::option::Option::None,
|
2494 + | nested_string_list: ::std::option::Option::None,
|
2495 + | structure_list: ::std::option::Option::None,
|
2496 + | blob_list: ::std::option::Option::None,
|
2497 + | };
|
2498 + | Ok(output)
|
2499 + | };
|
2500 + | sender.send(()).await.expect("receiver dropped early");
|
2501 + | result
|
2502 + | }
|
2503 + | })
|
2504 + | .build_unchecked();
|
2505 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2506 + | .await
|
2507 + | .expect("unable to make an HTTP request");
|
2508 + | assert!(
|
2509 + | receiver.recv().await.is_some(),
|
2510 + | "we expected operation handler to be invoked but it was not entered"
|
2511 + | );
|
2512 + | }
|
2513 + |
|
2514 + | /// Serializes empty JSON lists
|
2515 + | /// Test ID: RpcV2CborListsEmpty
|
2516 + | #[::tokio::test]
|
2517 + | #[::tracing_test::traced_test]
|
2518 + | async fn rpc_v2_cbor_lists_empty_request() {
|
2519 + | #[allow(unused_mut)]
|
2520 + | let mut http_request = ::http::Request::builder()
|
2521 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2522 + | .method("POST")
|
2523 + | .header("Accept", "application/cbor")
|
2524 + | .header("Content-Type", "application/cbor")
|
2525 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2526 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2527 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2528 + | "v2pzdHJpbmdMaXN0n///".as_bytes(),
|
2529 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2530 + | )),
|
2531 + | ))
|
2532 + | .unwrap();
|
2533 + | #[allow(unused_mut)]
|
2534 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2535 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2536 + | let service =
|
2537 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2538 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2539 + | let sender = sender.clone();
|
2540 + | async move {
|
2541 + | let result = {
|
2542 + | let expected = crate::input::RpcV2CborListsInput {
|
2543 + | string_list: ::std::option::Option::Some(vec![]),
|
2544 + | string_set: ::std::option::Option::None,
|
2545 + | integer_list: ::std::option::Option::None,
|
2546 + | boolean_list: ::std::option::Option::None,
|
2547 + | timestamp_list: ::std::option::Option::None,
|
2548 + | enum_list: ::std::option::Option::None,
|
2549 + | int_enum_list: ::std::option::Option::None,
|
2550 + | nested_string_list: ::std::option::Option::None,
|
2551 + | structure_list: ::std::option::Option::None,
|
2552 + | blob_list: ::std::option::Option::None,
|
2553 + | };
|
2554 + | ::pretty_assertions::assert_eq!(input, expected);
|
2555 + | let output = crate::output::RpcV2CborListsOutput {
|
2556 + | string_list: ::std::option::Option::None,
|
2557 + | string_set: ::std::option::Option::None,
|
2558 + | integer_list: ::std::option::Option::None,
|
2559 + | boolean_list: ::std::option::Option::None,
|
2560 + | timestamp_list: ::std::option::Option::None,
|
2561 + | enum_list: ::std::option::Option::None,
|
2562 + | int_enum_list: ::std::option::Option::None,
|
2563 + | nested_string_list: ::std::option::Option::None,
|
2564 + | structure_list: ::std::option::Option::None,
|
2565 + | blob_list: ::std::option::Option::None,
|
2566 + | };
|
2567 + | Ok(output)
|
2568 + | };
|
2569 + | sender.send(()).await.expect("receiver dropped early");
|
2570 + | result
|
2571 + | }
|
2572 + | })
|
2573 + | .build_unchecked();
|
2574 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2575 + | .await
|
2576 + | .expect("unable to make an HTTP request");
|
2577 + | assert!(
|
2578 + | receiver.recv().await.is_some(),
|
2579 + | "we expected operation handler to be invoked but it was not entered"
|
2580 + | );
|
2581 + | }
|
2582 + |
|
2583 + | /// Serializes empty JSON definite length lists
|
2584 + | /// Test ID: RpcV2CborListsEmptyUsingDefiniteLength
|
2585 + | #[::tokio::test]
|
2586 + | #[::tracing_test::traced_test]
|
2587 + | async fn rpc_v2_cbor_lists_empty_using_definite_length_request() {
|
2588 + | #[allow(unused_mut)]
|
2589 + | let mut http_request = ::http::Request::builder()
|
2590 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2591 + | .method("POST")
|
2592 + | .header("Accept", "application/cbor")
|
2593 + | .header("Content-Type", "application/cbor")
|
2594 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2595 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2596 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2597 + | "oWpzdHJpbmdMaXN0gA==".as_bytes(),
|
2598 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2599 + | )),
|
2600 + | ))
|
2601 + | .unwrap();
|
2602 + | #[allow(unused_mut)]
|
2603 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2604 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2605 + | let service =
|
2606 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
2607 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2608 + | let sender = sender.clone();
|
2609 + | async move {
|
2610 + | let result = {
|
2611 + | let expected = crate::input::RpcV2CborListsInput {
|
2612 + | string_list: ::std::option::Option::Some(vec![]),
|
2613 + | string_set: ::std::option::Option::None,
|
2614 + | integer_list: ::std::option::Option::None,
|
2615 + | boolean_list: ::std::option::Option::None,
|
2616 + | timestamp_list: ::std::option::Option::None,
|
2617 + | enum_list: ::std::option::Option::None,
|
2618 + | int_enum_list: ::std::option::Option::None,
|
2619 + | nested_string_list: ::std::option::Option::None,
|
2620 + | structure_list: ::std::option::Option::None,
|
2621 + | blob_list: ::std::option::Option::None,
|
2622 + | };
|
2623 + | ::pretty_assertions::assert_eq!(input, expected);
|
2624 + | let output = crate::output::RpcV2CborListsOutput {
|
2625 + | string_list: ::std::option::Option::None,
|
2626 + | string_set: ::std::option::Option::None,
|
2627 + | integer_list: ::std::option::Option::None,
|
2628 + | boolean_list: ::std::option::Option::None,
|
2629 + | timestamp_list: ::std::option::Option::None,
|
2630 + | enum_list: ::std::option::Option::None,
|
2631 + | int_enum_list: ::std::option::Option::None,
|
2632 + | nested_string_list: ::std::option::Option::None,
|
2633 + | structure_list: ::std::option::Option::None,
|
2634 + | blob_list: ::std::option::Option::None,
|
2635 + | };
|
2636 + | Ok(output)
|
2637 + | };
|
2638 + | sender.send(()).await.expect("receiver dropped early");
|
2639 + | result
|
2640 + | }
|
2641 + | })
|
2642 + | .build_unchecked();
|
2643 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2644 + | .await
|
2645 + | .expect("unable to make an HTTP request");
|
2646 + | assert!(
|
2647 + | receiver.recv().await.is_some(),
|
2648 + | "we expected operation handler to be invoked but it was not entered"
|
2649 + | );
|
2650 + | }
|
2651 + |
|
2652 + | /// Can deserialize indefinite length text strings inside an indefinite length list
|
2653 + | /// Test ID: RpcV2CborIndefiniteStringInsideIndefiniteList
|
2654 + | #[::tokio::test]
|
2655 + | #[::tracing_test::traced_test]
|
2656 + | async fn rpc_v2_cbor_indefinite_string_inside_indefinite_list_request() {
|
2657 + | #[allow(unused_mut)]
|
2658 + | let mut http_request = ::http::Request::builder()
|
2659 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2660 + | .method("POST")
|
2661 + | .header("Accept", "application/cbor")
|
2662 + | .header("Content-Type", "application/cbor")
|
2663 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2664 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2665 + | ::bytes::Bytes::copy_from_slice(
|
2666 + | &::aws_smithy_protocol_test::decode_body_data("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2667 + | )
|
2668 + | )).unwrap();
|
2669 + | #[allow(unused_mut)]
|
2670 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2671 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2672 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
2673 + | config,
|
2674 + | )
|
2675 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2676 + | let sender = sender.clone();
|
2677 + | async move {
|
2678 + | let result = {
|
2679 + | let expected = crate::input::RpcV2CborListsInput {
|
2680 + | string_list: ::std::option::Option::Some(vec![
|
2681 + | "An example indefinite string, which will be chunked, on each comma"
|
2682 + | .to_owned(),
|
2683 + | "Another example indefinite string with only one chunk".to_owned(),
|
2684 + | "This is a plain string".to_owned(),
|
2685 + | ]),
|
2686 + | string_set: ::std::option::Option::None,
|
2687 + | integer_list: ::std::option::Option::None,
|
2688 + | boolean_list: ::std::option::Option::None,
|
2689 + | timestamp_list: ::std::option::Option::None,
|
2690 + | enum_list: ::std::option::Option::None,
|
2691 + | int_enum_list: ::std::option::Option::None,
|
2692 + | nested_string_list: ::std::option::Option::None,
|
2693 + | structure_list: ::std::option::Option::None,
|
2694 + | blob_list: ::std::option::Option::None,
|
2695 + | };
|
2696 + | ::pretty_assertions::assert_eq!(input, expected);
|
2697 + | let output = crate::output::RpcV2CborListsOutput {
|
2698 + | string_list: ::std::option::Option::None,
|
2699 + | string_set: ::std::option::Option::None,
|
2700 + | integer_list: ::std::option::Option::None,
|
2701 + | boolean_list: ::std::option::Option::None,
|
2702 + | timestamp_list: ::std::option::Option::None,
|
2703 + | enum_list: ::std::option::Option::None,
|
2704 + | int_enum_list: ::std::option::Option::None,
|
2705 + | nested_string_list: ::std::option::Option::None,
|
2706 + | structure_list: ::std::option::Option::None,
|
2707 + | blob_list: ::std::option::Option::None,
|
2708 + | };
|
2709 + | Ok(output)
|
2710 + | };
|
2711 + | sender.send(()).await.expect("receiver dropped early");
|
2712 + | result
|
2713 + | }
|
2714 + | })
|
2715 + | .build_unchecked();
|
2716 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2717 + | .await
|
2718 + | .expect("unable to make an HTTP request");
|
2719 + | assert!(
|
2720 + | receiver.recv().await.is_some(),
|
2721 + | "we expected operation handler to be invoked but it was not entered"
|
2722 + | );
|
2723 + | }
|
2724 + |
|
2725 + | /// Can deserialize indefinite length text strings inside a definite length list
|
2726 + | /// Test ID: RpcV2CborIndefiniteStringInsideDefiniteList
|
2727 + | #[::tokio::test]
|
2728 + | #[::tracing_test::traced_test]
|
2729 + | async fn rpc_v2_cbor_indefinite_string_inside_definite_list_request() {
|
2730 + | #[allow(unused_mut)]
|
2731 + | let mut http_request = ::http::Request::builder()
|
2732 + | .uri("/service/RpcV2Protocol/operation/RpcV2CborLists")
|
2733 + | .method("POST")
|
2734 + | .header("Accept", "application/cbor")
|
2735 + | .header("Content-Type", "application/cbor")
|
2736 + | .header("smithy-protocol", "rpc-v2-cbor")
|
2737 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2738 + | ::bytes::Bytes::copy_from_slice(
|
2739 + | &::aws_smithy_protocol_test::decode_body_data("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
2740 + | )
|
2741 + | )).unwrap();
|
2742 + | #[allow(unused_mut)]
|
2743 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2744 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
2745 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
2746 + | config,
|
2747 + | )
|
2748 + | .rpc_v2_cbor_lists(move |input: crate::input::RpcV2CborListsInput| {
|
2749 + | let sender = sender.clone();
|
2750 + | async move {
|
2751 + | let result = {
|
2752 + | let expected = crate::input::RpcV2CborListsInput {
|
2753 + | string_list: ::std::option::Option::Some(vec![
|
2754 + | "An example indefinite string, which will be chunked, on each comma"
|
2755 + | .to_owned(),
|
2756 + | "Another example indefinite string with only one chunk".to_owned(),
|
2757 + | "This is a plain string".to_owned(),
|
2758 + | ]),
|
2759 + | string_set: ::std::option::Option::None,
|
2760 + | integer_list: ::std::option::Option::None,
|
2761 + | boolean_list: ::std::option::Option::None,
|
2762 + | timestamp_list: ::std::option::Option::None,
|
2763 + | enum_list: ::std::option::Option::None,
|
2764 + | int_enum_list: ::std::option::Option::None,
|
2765 + | nested_string_list: ::std::option::Option::None,
|
2766 + | structure_list: ::std::option::Option::None,
|
2767 + | blob_list: ::std::option::Option::None,
|
2768 + | };
|
2769 + | ::pretty_assertions::assert_eq!(input, expected);
|
2770 + | let output = crate::output::RpcV2CborListsOutput {
|
2771 + | string_list: ::std::option::Option::None,
|
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,
|
2781 + | };
|
2782 + | Ok(output)
|
2783 + | };
|
2784 + | sender.send(()).await.expect("receiver dropped early");
|
2785 + | result
|
2786 + | }
|
2787 + | })
|
2788 + | .build_unchecked();
|
2789 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2790 + | .await
|
2791 + | .expect("unable to make an HTTP request");
|
2792 + | assert!(
|
2793 + | receiver.recv().await.is_some(),
|
2794 + | "we expected operation handler to be invoked but it was not entered"
|
2795 + | );
|
2796 + | }
|
2797 + |
|
2798 + | /// Serializes RpcV2 Cbor lists
|
2799 + | /// Test ID: RpcV2CborLists
|
2800 + | #[::tokio::test]
|
2801 + | #[::tracing_test::traced_test]
|
2802 + | async fn rpc_v2_cbor_lists_response() {
|
2803 + | let output = crate::output::RpcV2CborListsOutput {
|
2804 + | string_list: ::std::option::Option::Some(vec!["foo".to_owned(), "bar".to_owned()]),
|
2805 + | string_set: ::std::option::Option::Some(
|
2806 + | vec!["foo".to_owned(), "bar".to_owned()]
|
2807 + | .try_into()
|
2808 + | .expect("this is only used in tests"),
|
2809 + | ),
|
2810 + | integer_list: ::std::option::Option::Some(vec![1, 2]),
|
2811 + | boolean_list: ::std::option::Option::Some(vec![true, false]),
|
2812 + | timestamp_list: ::std::option::Option::Some(vec![
|
2813 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2814 + | ::aws_smithy_types::DateTime::from_fractional_secs(1398796238, 0_f64),
|
2815 + | ]),
|
2816 + | enum_list: ::std::option::Option::Some(vec![
|
2817 + | "Foo"
|
2818 + | .parse::<crate::model::FooEnum>()
|
2819 + | .expect("static value validated to member"),
|
2820 + | "0".parse::<crate::model::FooEnum>()
|
2821 + | .expect("static value validated to member"),
|
2822 + | ]),
|
2823 + | int_enum_list: ::std::option::Option::Some(vec![1, 2]),
|
2824 + | nested_string_list: ::std::option::Option::Some(vec![
|
2825 + | vec!["foo".to_owned(), "bar".to_owned()],
|
2826 + | vec!["baz".to_owned(), "qux".to_owned()],
|
2827 + | ]),
|
2828 + | structure_list: ::std::option::Option::Some(vec![
|
2829 + | crate::model::StructureListMember {
|
2830 + | a: ::std::option::Option::Some("1".to_owned()),
|
2831 + | b: ::std::option::Option::Some("2".to_owned()),
|
2832 + | },
|
2833 + | crate::model::StructureListMember {
|
2834 + | a: ::std::option::Option::Some("3".to_owned()),
|
2835 + | b: ::std::option::Option::Some("4".to_owned()),
|
2836 + | },
|
2837 + | ]),
|
2838 + | blob_list: ::std::option::Option::Some(vec![
|
2839 + | ::aws_smithy_types::Blob::new("foo"),
|
2840 + | ::aws_smithy_types::Blob::new("bar"),
|
2841 + | ]),
|
2842 + | };
|
2843 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2844 + | let http_response = output.into_response();
|
2845 + | ::pretty_assertions::assert_eq!(
|
2846 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2847 + | http_response.status()
|
2848 + | );
|
2849 + | let expected_headers = [
|
2850 + | ("Content-Type", "application/cbor"),
|
2851 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2852 + | ];
|
2853 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2854 + | http_response.headers(),
|
2855 + | expected_headers,
|
2856 + | ));
|
2857 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2858 + | .await
|
2859 + | .expect("unable to extract body to bytes");
|
2860 + | ::aws_smithy_protocol_test::assert_ok(
|
2861 + | ::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"))
|
2862 + | );
|
2863 + | }
|
2864 + |
|
2865 + | /// Serializes empty RpcV2 Cbor lists
|
2866 + | /// Test ID: RpcV2CborListsEmpty
|
2867 + | #[::tokio::test]
|
2868 + | #[::tracing_test::traced_test]
|
2869 + | async fn rpc_v2_cbor_lists_empty_response() {
|
2870 + | let output = crate::output::RpcV2CborListsOutput {
|
2871 + | string_list: ::std::option::Option::Some(vec![]),
|
2872 + | string_set: ::std::option::Option::None,
|
2873 + | integer_list: ::std::option::Option::None,
|
2874 + | boolean_list: ::std::option::Option::None,
|
2875 + | timestamp_list: ::std::option::Option::None,
|
2876 + | enum_list: ::std::option::Option::None,
|
2877 + | int_enum_list: ::std::option::Option::None,
|
2878 + | nested_string_list: ::std::option::Option::None,
|
2879 + | structure_list: ::std::option::Option::None,
|
2880 + | blob_list: ::std::option::Option::None,
|
2881 + | };
|
2882 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
2883 + | let http_response = output.into_response();
|
2884 + | ::pretty_assertions::assert_eq!(
|
2885 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
2886 + | http_response.status()
|
2887 + | );
|
2888 + | let expected_headers = [
|
2889 + | ("Content-Type", "application/cbor"),
|
2890 + | ("smithy-protocol", "rpc-v2-cbor"),
|
2891 + | ];
|
2892 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2893 + | http_response.headers(),
|
2894 + | expected_headers,
|
2895 + | ));
|
2896 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2897 + | .await
|
2898 + | .expect("unable to extract body to bytes");
|
2899 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
2900 + | &body,
|
2901 + | "v2pzdHJpbmdMaXN0n///",
|
2902 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
2903 + | ));
|
2904 + | }
|
2905 + | }
|
2906 + |
|
2907 + | ::pin_project_lite::pin_project! {
|
2908 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2909 + | /// [`SimpleScalarPropertiesInput`](crate::input::SimpleScalarPropertiesInput) using modelled bindings.
|
2910 + | pub struct SimpleScalarPropertiesInputFuture {
|
2911 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SimpleScalarPropertiesInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
2912 + | }
|
2913 + | }
|
2914 + |
|
2915 + | impl std::future::Future for SimpleScalarPropertiesInputFuture {
|
2916 + | type Output = Result<
|
2917 + | crate::input::SimpleScalarPropertiesInput,
|
2918 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
2919 + | >;
|
2920 + |
|
2921 + | fn poll(
|
2922 + | self: std::pin::Pin<&mut Self>,
|
2923 + | cx: &mut std::task::Context<'_>,
|
2924 + | ) -> std::task::Poll<Self::Output> {
|
2925 + | let this = self.project();
|
2926 + | this.inner.as_mut().poll(cx)
|
2927 + | }
|
2928 + | }
|
2929 + |
|
2930 + | impl<B>
|
2931 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2932 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2933 + | B,
|
2934 + | > for crate::input::SimpleScalarPropertiesInput
|
2935 + | where
|
2936 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2937 + | B: 'static,
|
2938 + |
|
2939 + | B::Data: Send,
|
2940 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
2941 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2942 + | {
|
2943 + | type Rejection =
|
2944 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
2945 + | type Future = SimpleScalarPropertiesInputFuture;
|
2946 + |
|
2947 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2948 + | let fut = async move {
|
2949 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2950 + | request.headers(),
|
2951 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
2952 + | ) {
|
2953 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
2954 + | }
|
2955 + | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties_http_request(request)
|
2956 + | .await
|
2957 + | };
|
2958 + | use ::futures_util::future::TryFutureExt;
|
2959 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
2960 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2961 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
2962 + | });
|
2963 + | SimpleScalarPropertiesInputFuture {
|
2964 + | inner: Box::pin(fut),
|
2965 + | }
|
2966 + | }
|
2967 + | }
|
2968 + | impl
|
2969 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2970 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
2971 + | > for crate::output::SimpleScalarPropertiesOutput
|
2972 + | {
|
2973 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2974 + | match crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_http_response(self) {
|
2975 + | Ok(response) => response,
|
2976 + | Err(e) => {
|
2977 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2978 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
2979 + | }
|
2980 + | }
|
2981 + | }
|
2982 + | }
|
2983 + |
|
2984 + | #[allow(unreachable_code, unused_variables)]
|
2985 + | #[cfg(test)]
|
2986 + | mod simple_scalar_properties_test {
|
2987 + |
|
2988 + | /// Serializes simple scalar properties
|
2989 + | /// Test ID: RpcV2CborSimpleScalarProperties
|
2990 + | #[::tokio::test]
|
2991 + | #[::tracing_test::traced_test]
|
2992 + | async fn rpc_v2_cbor_simple_scalar_properties_request() {
|
2993 + | #[allow(unused_mut)]
|
2994 + | let mut http_request = ::http::Request::builder()
|
2995 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
2996 + | .method("POST")
|
2997 + | .header("Accept", "application/cbor")
|
2998 + | .header("Content-Type", "application/cbor")
|
2999 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3000 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3001 + | ::bytes::Bytes::copy_from_slice(
|
3002 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3003 + | )
|
3004 + | )).unwrap();
|
3005 + | #[allow(unused_mut)]
|
3006 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3007 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3008 + | let service =
|
3009 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3010 + | .simple_scalar_properties(
|
3011 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3012 + | let sender = sender.clone();
|
3013 + | async move {
|
3014 + | let result = {
|
3015 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3016 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3017 + | byte_value: ::std::option::Option::Some(5),
|
3018 + | double_value: ::std::option::Option::Some(1.889_f64),
|
3019 + | false_boolean_value: ::std::option::Option::Some(false),
|
3020 + | float_value: ::std::option::Option::Some(7.625_f32),
|
3021 + | integer_value: ::std::option::Option::Some(256),
|
3022 + | long_value: ::std::option::Option::Some(9873),
|
3023 + | short_value: ::std::option::Option::Some(9898),
|
3024 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
3025 + | true_boolean_value: ::std::option::Option::Some(true),
|
3026 + | blob_value: ::std::option::Option::Some(
|
3027 + | ::aws_smithy_types::Blob::new("foo"),
|
3028 + | ),
|
3029 + | };
|
3030 + | ::pretty_assertions::assert_eq!(
|
3031 + | input.true_boolean_value,
|
3032 + | expected.true_boolean_value,
|
3033 + | "Unexpected value for `true_boolean_value`"
|
3034 + | );
|
3035 + | ::pretty_assertions::assert_eq!(
|
3036 + | input.false_boolean_value,
|
3037 + | expected.false_boolean_value,
|
3038 + | "Unexpected value for `false_boolean_value`"
|
3039 + | );
|
3040 + | ::pretty_assertions::assert_eq!(
|
3041 + | input.byte_value,
|
3042 + | expected.byte_value,
|
3043 + | "Unexpected value for `byte_value`"
|
3044 + | );
|
3045 + | assert!(
|
3046 + | input.double_value.float_equals(&expected.double_value),
|
3047 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3048 + | expected.double_value,
|
3049 + | input.double_value
|
3050 + | );
|
3051 + | assert!(
|
3052 + | input.float_value.float_equals(&expected.float_value),
|
3053 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3054 + | expected.float_value,
|
3055 + | input.float_value
|
3056 + | );
|
3057 + | ::pretty_assertions::assert_eq!(
|
3058 + | input.integer_value,
|
3059 + | expected.integer_value,
|
3060 + | "Unexpected value for `integer_value`"
|
3061 + | );
|
3062 + | ::pretty_assertions::assert_eq!(
|
3063 + | input.long_value,
|
3064 + | expected.long_value,
|
3065 + | "Unexpected value for `long_value`"
|
3066 + | );
|
3067 + | ::pretty_assertions::assert_eq!(
|
3068 + | input.short_value,
|
3069 + | expected.short_value,
|
3070 + | "Unexpected value for `short_value`"
|
3071 + | );
|
3072 + | ::pretty_assertions::assert_eq!(
|
3073 + | input.string_value,
|
3074 + | expected.string_value,
|
3075 + | "Unexpected value for `string_value`"
|
3076 + | );
|
3077 + | ::pretty_assertions::assert_eq!(
|
3078 + | input.blob_value,
|
3079 + | expected.blob_value,
|
3080 + | "Unexpected value for `blob_value`"
|
3081 + | );
|
3082 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3083 + | true_boolean_value: ::std::option::Option::None,
|
3084 + | false_boolean_value: ::std::option::Option::None,
|
3085 + | byte_value: ::std::option::Option::None,
|
3086 + | double_value: ::std::option::Option::None,
|
3087 + | float_value: ::std::option::Option::None,
|
3088 + | integer_value: ::std::option::Option::None,
|
3089 + | long_value: ::std::option::Option::None,
|
3090 + | short_value: ::std::option::Option::None,
|
3091 + | string_value: ::std::option::Option::None,
|
3092 + | blob_value: ::std::option::Option::None,
|
3093 + | };
|
3094 + | output
|
3095 + | };
|
3096 + | sender.send(()).await.expect("receiver dropped early");
|
3097 + | result
|
3098 + | }
|
3099 + | },
|
3100 + | )
|
3101 + | .build_unchecked();
|
3102 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3103 + | .await
|
3104 + | .expect("unable to make an HTTP request");
|
3105 + | assert!(
|
3106 + | receiver.recv().await.is_some(),
|
3107 + | "we expected operation handler to be invoked but it was not entered"
|
3108 + | );
|
3109 + | }
|
3110 + |
|
3111 + | /// The server should be capable of deserializing simple scalar properties
|
3112 + | /// encoded using a map with a definite length. The server should also be able to parse
|
3113 + | /// a key encoded using an indefinite length string.
|
3114 + | /// Test ID: RpcV2CborSimpleScalarPropertiesUsingIndefiniteLength
|
3115 + | #[::tokio::test]
|
3116 + | #[::tracing_test::traced_test]
|
3117 + | async fn rpc_v2_cbor_simple_scalar_properties_using_indefinite_length_request() {
|
3118 + | #[allow(unused_mut)]
|
3119 + | let mut http_request = ::http::Request::builder()
|
3120 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3121 + | .method("POST")
|
3122 + | .header("Accept", "application/cbor")
|
3123 + | .header("Content-Type", "application/cbor")
|
3124 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3125 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3126 + | ::bytes::Bytes::copy_from_slice(
|
3127 + | &::aws_smithy_protocol_test::decode_body_data("qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA9AAAbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3128 + | )
|
3129 + | )).unwrap();
|
3130 + | #[allow(unused_mut)]
|
3131 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3132 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3133 + | let service =
|
3134 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3135 + | .simple_scalar_properties(
|
3136 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3137 + | let sender = sender.clone();
|
3138 + | async move {
|
3139 + | let result = {
|
3140 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3141 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3142 + | byte_value: ::std::option::Option::Some(5),
|
3143 + | double_value: ::std::option::Option::Some(1.889_f64),
|
3144 + | false_boolean_value: ::std::option::Option::Some(false),
|
3145 + | float_value: ::std::option::Option::Some(7.625_f32),
|
3146 + | integer_value: ::std::option::Option::Some(256),
|
3147 + | long_value: ::std::option::Option::Some(9873),
|
3148 + | short_value: ::std::option::Option::Some(9898),
|
3149 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
3150 + | true_boolean_value: ::std::option::Option::Some(true),
|
3151 + | blob_value: ::std::option::Option::Some(
|
3152 + | ::aws_smithy_types::Blob::new("foo"),
|
3153 + | ),
|
3154 + | };
|
3155 + | ::pretty_assertions::assert_eq!(
|
3156 + | input.true_boolean_value,
|
3157 + | expected.true_boolean_value,
|
3158 + | "Unexpected value for `true_boolean_value`"
|
3159 + | );
|
3160 + | ::pretty_assertions::assert_eq!(
|
3161 + | input.false_boolean_value,
|
3162 + | expected.false_boolean_value,
|
3163 + | "Unexpected value for `false_boolean_value`"
|
3164 + | );
|
3165 + | ::pretty_assertions::assert_eq!(
|
3166 + | input.byte_value,
|
3167 + | expected.byte_value,
|
3168 + | "Unexpected value for `byte_value`"
|
3169 + | );
|
3170 + | assert!(
|
3171 + | input.double_value.float_equals(&expected.double_value),
|
3172 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3173 + | expected.double_value,
|
3174 + | input.double_value
|
3175 + | );
|
3176 + | assert!(
|
3177 + | input.float_value.float_equals(&expected.float_value),
|
3178 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3179 + | expected.float_value,
|
3180 + | input.float_value
|
3181 + | );
|
3182 + | ::pretty_assertions::assert_eq!(
|
3183 + | input.integer_value,
|
3184 + | expected.integer_value,
|
3185 + | "Unexpected value for `integer_value`"
|
3186 + | );
|
3187 + | ::pretty_assertions::assert_eq!(
|
3188 + | input.long_value,
|
3189 + | expected.long_value,
|
3190 + | "Unexpected value for `long_value`"
|
3191 + | );
|
3192 + | ::pretty_assertions::assert_eq!(
|
3193 + | input.short_value,
|
3194 + | expected.short_value,
|
3195 + | "Unexpected value for `short_value`"
|
3196 + | );
|
3197 + | ::pretty_assertions::assert_eq!(
|
3198 + | input.string_value,
|
3199 + | expected.string_value,
|
3200 + | "Unexpected value for `string_value`"
|
3201 + | );
|
3202 + | ::pretty_assertions::assert_eq!(
|
3203 + | input.blob_value,
|
3204 + | expected.blob_value,
|
3205 + | "Unexpected value for `blob_value`"
|
3206 + | );
|
3207 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3208 + | true_boolean_value: ::std::option::Option::None,
|
3209 + | false_boolean_value: ::std::option::Option::None,
|
3210 + | byte_value: ::std::option::Option::None,
|
3211 + | double_value: ::std::option::Option::None,
|
3212 + | float_value: ::std::option::Option::None,
|
3213 + | integer_value: ::std::option::Option::None,
|
3214 + | long_value: ::std::option::Option::None,
|
3215 + | short_value: ::std::option::Option::None,
|
3216 + | string_value: ::std::option::Option::None,
|
3217 + | blob_value: ::std::option::Option::None,
|
3218 + | };
|
3219 + | output
|
3220 + | };
|
3221 + | sender.send(()).await.expect("receiver dropped early");
|
3222 + | result
|
3223 + | }
|
3224 + | },
|
3225 + | )
|
3226 + | .build_unchecked();
|
3227 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3228 + | .await
|
3229 + | .expect("unable to make an HTTP request");
|
3230 + | assert!(
|
3231 + | receiver.recv().await.is_some(),
|
3232 + | "we expected operation handler to be invoked but it was not entered"
|
3233 + | );
|
3234 + | }
|
3235 + |
|
3236 + | /// RpcV2 Cbor should not deserialize null structure values
|
3237 + | /// Test ID: RpcV2CborServerDoesntDeSerializeNullStructureValues
|
3238 + | #[::tokio::test]
|
3239 + | #[::tracing_test::traced_test]
|
3240 + | async fn rpc_v2_cbor_server_doesnt_de_serialize_null_structure_values_request() {
|
3241 + | #[allow(unused_mut)]
|
3242 + | let mut http_request = ::http::Request::builder()
|
3243 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3244 + | .method("POST")
|
3245 + | .header("Accept", "application/cbor")
|
3246 + | .header("Content-Type", "application/cbor")
|
3247 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3248 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3249 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3250 + | "v2tzdHJpbmdWYWx1Zfb/".as_bytes(),
|
3251 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3252 + | )),
|
3253 + | ))
|
3254 + | .unwrap();
|
3255 + | #[allow(unused_mut)]
|
3256 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3257 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3258 + | let service =
|
3259 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3260 + | .simple_scalar_properties(
|
3261 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3262 + | let sender = sender.clone();
|
3263 + | async move {
|
3264 + | let result = {
|
3265 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3266 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3267 + | true_boolean_value: ::std::option::Option::None,
|
3268 + | false_boolean_value: ::std::option::Option::None,
|
3269 + | byte_value: ::std::option::Option::None,
|
3270 + | double_value: ::std::option::Option::None,
|
3271 + | float_value: ::std::option::Option::None,
|
3272 + | integer_value: ::std::option::Option::None,
|
3273 + | long_value: ::std::option::Option::None,
|
3274 + | short_value: ::std::option::Option::None,
|
3275 + | string_value: ::std::option::Option::None,
|
3276 + | blob_value: ::std::option::Option::None,
|
3277 + | };
|
3278 + | ::pretty_assertions::assert_eq!(
|
3279 + | input.true_boolean_value,
|
3280 + | expected.true_boolean_value,
|
3281 + | "Unexpected value for `true_boolean_value`"
|
3282 + | );
|
3283 + | ::pretty_assertions::assert_eq!(
|
3284 + | input.false_boolean_value,
|
3285 + | expected.false_boolean_value,
|
3286 + | "Unexpected value for `false_boolean_value`"
|
3287 + | );
|
3288 + | ::pretty_assertions::assert_eq!(
|
3289 + | input.byte_value,
|
3290 + | expected.byte_value,
|
3291 + | "Unexpected value for `byte_value`"
|
3292 + | );
|
3293 + | assert!(
|
3294 + | input.double_value.float_equals(&expected.double_value),
|
3295 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3296 + | expected.double_value,
|
3297 + | input.double_value
|
3298 + | );
|
3299 + | assert!(
|
3300 + | input.float_value.float_equals(&expected.float_value),
|
3301 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3302 + | expected.float_value,
|
3303 + | input.float_value
|
3304 + | );
|
3305 + | ::pretty_assertions::assert_eq!(
|
3306 + | input.integer_value,
|
3307 + | expected.integer_value,
|
3308 + | "Unexpected value for `integer_value`"
|
3309 + | );
|
3310 + | ::pretty_assertions::assert_eq!(
|
3311 + | input.long_value,
|
3312 + | expected.long_value,
|
3313 + | "Unexpected value for `long_value`"
|
3314 + | );
|
3315 + | ::pretty_assertions::assert_eq!(
|
3316 + | input.short_value,
|
3317 + | expected.short_value,
|
3318 + | "Unexpected value for `short_value`"
|
3319 + | );
|
3320 + | ::pretty_assertions::assert_eq!(
|
3321 + | input.string_value,
|
3322 + | expected.string_value,
|
3323 + | "Unexpected value for `string_value`"
|
3324 + | );
|
3325 + | ::pretty_assertions::assert_eq!(
|
3326 + | input.blob_value,
|
3327 + | expected.blob_value,
|
3328 + | "Unexpected value for `blob_value`"
|
3329 + | );
|
3330 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3331 + | true_boolean_value: ::std::option::Option::None,
|
3332 + | false_boolean_value: ::std::option::Option::None,
|
3333 + | byte_value: ::std::option::Option::None,
|
3334 + | double_value: ::std::option::Option::None,
|
3335 + | float_value: ::std::option::Option::None,
|
3336 + | integer_value: ::std::option::Option::None,
|
3337 + | long_value: ::std::option::Option::None,
|
3338 + | short_value: ::std::option::Option::None,
|
3339 + | string_value: ::std::option::Option::None,
|
3340 + | blob_value: ::std::option::Option::None,
|
3341 + | };
|
3342 + | output
|
3343 + | };
|
3344 + | sender.send(()).await.expect("receiver dropped early");
|
3345 + | result
|
3346 + | }
|
3347 + | },
|
3348 + | )
|
3349 + | .build_unchecked();
|
3350 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3351 + | .await
|
3352 + | .expect("unable to make an HTTP request");
|
3353 + | assert!(
|
3354 + | receiver.recv().await.is_some(),
|
3355 + | "we expected operation handler to be invoked but it was not entered"
|
3356 + | );
|
3357 + | }
|
3358 + |
|
3359 + | /// Supports handling NaN float values.
|
3360 + | /// Test ID: RpcV2CborSupportsNaNFloatInputs
|
3361 + | #[::tokio::test]
|
3362 + | #[::tracing_test::traced_test]
|
3363 + | async fn rpc_v2_cbor_supports_na_n_float_inputs_request() {
|
3364 + | #[allow(unused_mut)]
|
3365 + | let mut http_request = ::http::Request::builder()
|
3366 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3367 + | .method("POST")
|
3368 + | .header("Accept", "application/cbor")
|
3369 + | .header("Content-Type", "application/cbor")
|
3370 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3371 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3372 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3373 + | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/".as_bytes(),
|
3374 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3375 + | )),
|
3376 + | ))
|
3377 + | .unwrap();
|
3378 + | #[allow(unused_mut)]
|
3379 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3380 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3381 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
3382 + | config,
|
3383 + | )
|
3384 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3385 + | let sender = sender.clone();
|
3386 + | async move {
|
3387 + | let result = {
|
3388 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3389 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3390 + | double_value: ::std::option::Option::Some(
|
3391 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3392 + | "NaN",
|
3393 + | )
|
3394 + | .expect("invalid string for number"),
|
3395 + | ),
|
3396 + | float_value: ::std::option::Option::Some(
|
3397 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3398 + | "NaN",
|
3399 + | )
|
3400 + | .expect("invalid string for number"),
|
3401 + | ),
|
3402 + | true_boolean_value: ::std::option::Option::None,
|
3403 + | false_boolean_value: ::std::option::Option::None,
|
3404 + | byte_value: ::std::option::Option::None,
|
3405 + | integer_value: ::std::option::Option::None,
|
3406 + | long_value: ::std::option::Option::None,
|
3407 + | short_value: ::std::option::Option::None,
|
3408 + | string_value: ::std::option::Option::None,
|
3409 + | blob_value: ::std::option::Option::None,
|
3410 + | };
|
3411 + | ::pretty_assertions::assert_eq!(
|
3412 + | input.true_boolean_value,
|
3413 + | expected.true_boolean_value,
|
3414 + | "Unexpected value for `true_boolean_value`"
|
3415 + | );
|
3416 + | ::pretty_assertions::assert_eq!(
|
3417 + | input.false_boolean_value,
|
3418 + | expected.false_boolean_value,
|
3419 + | "Unexpected value for `false_boolean_value`"
|
3420 + | );
|
3421 + | ::pretty_assertions::assert_eq!(
|
3422 + | input.byte_value,
|
3423 + | expected.byte_value,
|
3424 + | "Unexpected value for `byte_value`"
|
3425 + | );
|
3426 + | assert!(
|
3427 + | input.double_value.float_equals(&expected.double_value),
|
3428 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3429 + | expected.double_value,
|
3430 + | input.double_value
|
3431 + | );
|
3432 + | assert!(
|
3433 + | input.float_value.float_equals(&expected.float_value),
|
3434 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3435 + | expected.float_value,
|
3436 + | input.float_value
|
3437 + | );
|
3438 + | ::pretty_assertions::assert_eq!(
|
3439 + | input.integer_value,
|
3440 + | expected.integer_value,
|
3441 + | "Unexpected value for `integer_value`"
|
3442 + | );
|
3443 + | ::pretty_assertions::assert_eq!(
|
3444 + | input.long_value,
|
3445 + | expected.long_value,
|
3446 + | "Unexpected value for `long_value`"
|
3447 + | );
|
3448 + | ::pretty_assertions::assert_eq!(
|
3449 + | input.short_value,
|
3450 + | expected.short_value,
|
3451 + | "Unexpected value for `short_value`"
|
3452 + | );
|
3453 + | ::pretty_assertions::assert_eq!(
|
3454 + | input.string_value,
|
3455 + | expected.string_value,
|
3456 + | "Unexpected value for `string_value`"
|
3457 + | );
|
3458 + | ::pretty_assertions::assert_eq!(
|
3459 + | input.blob_value,
|
3460 + | expected.blob_value,
|
3461 + | "Unexpected value for `blob_value`"
|
3462 + | );
|
3463 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3464 + | true_boolean_value: ::std::option::Option::None,
|
3465 + | false_boolean_value: ::std::option::Option::None,
|
3466 + | byte_value: ::std::option::Option::None,
|
3467 + | double_value: ::std::option::Option::None,
|
3468 + | float_value: ::std::option::Option::None,
|
3469 + | integer_value: ::std::option::Option::None,
|
3470 + | long_value: ::std::option::Option::None,
|
3471 + | short_value: ::std::option::Option::None,
|
3472 + | string_value: ::std::option::Option::None,
|
3473 + | blob_value: ::std::option::Option::None,
|
3474 + | };
|
3475 + | output
|
3476 + | };
|
3477 + | sender.send(()).await.expect("receiver dropped early");
|
3478 + | result
|
3479 + | }
|
3480 + | })
|
3481 + | .build_unchecked();
|
3482 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3483 + | .await
|
3484 + | .expect("unable to make an HTTP request");
|
3485 + | assert!(
|
3486 + | receiver.recv().await.is_some(),
|
3487 + | "we expected operation handler to be invoked but it was not entered"
|
3488 + | );
|
3489 + | }
|
3490 + |
|
3491 + | /// Supports handling Infinity float values.
|
3492 + | /// Test ID: RpcV2CborSupportsInfinityFloatInputs
|
3493 + | #[::tokio::test]
|
3494 + | #[::tracing_test::traced_test]
|
3495 + | async fn rpc_v2_cbor_supports_infinity_float_inputs_request() {
|
3496 + | #[allow(unused_mut)]
|
3497 + | let mut http_request = ::http::Request::builder()
|
3498 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3499 + | .method("POST")
|
3500 + | .header("Accept", "application/cbor")
|
3501 + | .header("Content-Type", "application/cbor")
|
3502 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3503 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3504 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3505 + | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/".as_bytes(),
|
3506 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3507 + | )),
|
3508 + | ))
|
3509 + | .unwrap();
|
3510 + | #[allow(unused_mut)]
|
3511 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3512 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3513 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
3514 + | config,
|
3515 + | )
|
3516 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3517 + | let sender = sender.clone();
|
3518 + | async move {
|
3519 + | let result = {
|
3520 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3521 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3522 + | double_value: ::std::option::Option::Some(
|
3523 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3524 + | "Infinity",
|
3525 + | )
|
3526 + | .expect("invalid string for number"),
|
3527 + | ),
|
3528 + | float_value: ::std::option::Option::Some(
|
3529 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3530 + | "Infinity",
|
3531 + | )
|
3532 + | .expect("invalid string for number"),
|
3533 + | ),
|
3534 + | true_boolean_value: ::std::option::Option::None,
|
3535 + | false_boolean_value: ::std::option::Option::None,
|
3536 + | byte_value: ::std::option::Option::None,
|
3537 + | integer_value: ::std::option::Option::None,
|
3538 + | long_value: ::std::option::Option::None,
|
3539 + | short_value: ::std::option::Option::None,
|
3540 + | string_value: ::std::option::Option::None,
|
3541 + | blob_value: ::std::option::Option::None,
|
3542 + | };
|
3543 + | ::pretty_assertions::assert_eq!(
|
3544 + | input.true_boolean_value,
|
3545 + | expected.true_boolean_value,
|
3546 + | "Unexpected value for `true_boolean_value`"
|
3547 + | );
|
3548 + | ::pretty_assertions::assert_eq!(
|
3549 + | input.false_boolean_value,
|
3550 + | expected.false_boolean_value,
|
3551 + | "Unexpected value for `false_boolean_value`"
|
3552 + | );
|
3553 + | ::pretty_assertions::assert_eq!(
|
3554 + | input.byte_value,
|
3555 + | expected.byte_value,
|
3556 + | "Unexpected value for `byte_value`"
|
3557 + | );
|
3558 + | assert!(
|
3559 + | input.double_value.float_equals(&expected.double_value),
|
3560 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3561 + | expected.double_value,
|
3562 + | input.double_value
|
3563 + | );
|
3564 + | assert!(
|
3565 + | input.float_value.float_equals(&expected.float_value),
|
3566 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3567 + | expected.float_value,
|
3568 + | input.float_value
|
3569 + | );
|
3570 + | ::pretty_assertions::assert_eq!(
|
3571 + | input.integer_value,
|
3572 + | expected.integer_value,
|
3573 + | "Unexpected value for `integer_value`"
|
3574 + | );
|
3575 + | ::pretty_assertions::assert_eq!(
|
3576 + | input.long_value,
|
3577 + | expected.long_value,
|
3578 + | "Unexpected value for `long_value`"
|
3579 + | );
|
3580 + | ::pretty_assertions::assert_eq!(
|
3581 + | input.short_value,
|
3582 + | expected.short_value,
|
3583 + | "Unexpected value for `short_value`"
|
3584 + | );
|
3585 + | ::pretty_assertions::assert_eq!(
|
3586 + | input.string_value,
|
3587 + | expected.string_value,
|
3588 + | "Unexpected value for `string_value`"
|
3589 + | );
|
3590 + | ::pretty_assertions::assert_eq!(
|
3591 + | input.blob_value,
|
3592 + | expected.blob_value,
|
3593 + | "Unexpected value for `blob_value`"
|
3594 + | );
|
3595 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3596 + | true_boolean_value: ::std::option::Option::None,
|
3597 + | false_boolean_value: ::std::option::Option::None,
|
3598 + | byte_value: ::std::option::Option::None,
|
3599 + | double_value: ::std::option::Option::None,
|
3600 + | float_value: ::std::option::Option::None,
|
3601 + | integer_value: ::std::option::Option::None,
|
3602 + | long_value: ::std::option::Option::None,
|
3603 + | short_value: ::std::option::Option::None,
|
3604 + | string_value: ::std::option::Option::None,
|
3605 + | blob_value: ::std::option::Option::None,
|
3606 + | };
|
3607 + | output
|
3608 + | };
|
3609 + | sender.send(()).await.expect("receiver dropped early");
|
3610 + | result
|
3611 + | }
|
3612 + | })
|
3613 + | .build_unchecked();
|
3614 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3615 + | .await
|
3616 + | .expect("unable to make an HTTP request");
|
3617 + | assert!(
|
3618 + | receiver.recv().await.is_some(),
|
3619 + | "we expected operation handler to be invoked but it was not entered"
|
3620 + | );
|
3621 + | }
|
3622 + |
|
3623 + | /// Supports handling Infinity float values.
|
3624 + | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatInputs
|
3625 + | #[::tokio::test]
|
3626 + | #[::tracing_test::traced_test]
|
3627 + | async fn rpc_v2_cbor_supports_negative_infinity_float_inputs_request() {
|
3628 + | #[allow(unused_mut)]
|
3629 + | let mut http_request = ::http::Request::builder()
|
3630 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3631 + | .method("POST")
|
3632 + | .header("Accept", "application/cbor")
|
3633 + | .header("Content-Type", "application/cbor")
|
3634 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3635 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3636 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3637 + | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/".as_bytes(),
|
3638 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
3639 + | )),
|
3640 + | ))
|
3641 + | .unwrap();
|
3642 + | #[allow(unused_mut)]
|
3643 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3644 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3645 + | let service = crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(
|
3646 + | config,
|
3647 + | )
|
3648 + | .simple_scalar_properties(move |input: crate::input::SimpleScalarPropertiesInput| {
|
3649 + | let sender = sender.clone();
|
3650 + | async move {
|
3651 + | let result = {
|
3652 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3653 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3654 + | double_value: ::std::option::Option::Some(
|
3655 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3656 + | "-Infinity",
|
3657 + | )
|
3658 + | .expect("invalid string for number"),
|
3659 + | ),
|
3660 + | float_value: ::std::option::Option::Some(
|
3661 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
|
3662 + | "-Infinity",
|
3663 + | )
|
3664 + | .expect("invalid string for number"),
|
3665 + | ),
|
3666 + | true_boolean_value: ::std::option::Option::None,
|
3667 + | false_boolean_value: ::std::option::Option::None,
|
3668 + | byte_value: ::std::option::Option::None,
|
3669 + | integer_value: ::std::option::Option::None,
|
3670 + | long_value: ::std::option::Option::None,
|
3671 + | short_value: ::std::option::Option::None,
|
3672 + | string_value: ::std::option::Option::None,
|
3673 + | blob_value: ::std::option::Option::None,
|
3674 + | };
|
3675 + | ::pretty_assertions::assert_eq!(
|
3676 + | input.true_boolean_value,
|
3677 + | expected.true_boolean_value,
|
3678 + | "Unexpected value for `true_boolean_value`"
|
3679 + | );
|
3680 + | ::pretty_assertions::assert_eq!(
|
3681 + | input.false_boolean_value,
|
3682 + | expected.false_boolean_value,
|
3683 + | "Unexpected value for `false_boolean_value`"
|
3684 + | );
|
3685 + | ::pretty_assertions::assert_eq!(
|
3686 + | input.byte_value,
|
3687 + | expected.byte_value,
|
3688 + | "Unexpected value for `byte_value`"
|
3689 + | );
|
3690 + | assert!(
|
3691 + | input.double_value.float_equals(&expected.double_value),
|
3692 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3693 + | expected.double_value,
|
3694 + | input.double_value
|
3695 + | );
|
3696 + | assert!(
|
3697 + | input.float_value.float_equals(&expected.float_value),
|
3698 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3699 + | expected.float_value,
|
3700 + | input.float_value
|
3701 + | );
|
3702 + | ::pretty_assertions::assert_eq!(
|
3703 + | input.integer_value,
|
3704 + | expected.integer_value,
|
3705 + | "Unexpected value for `integer_value`"
|
3706 + | );
|
3707 + | ::pretty_assertions::assert_eq!(
|
3708 + | input.long_value,
|
3709 + | expected.long_value,
|
3710 + | "Unexpected value for `long_value`"
|
3711 + | );
|
3712 + | ::pretty_assertions::assert_eq!(
|
3713 + | input.short_value,
|
3714 + | expected.short_value,
|
3715 + | "Unexpected value for `short_value`"
|
3716 + | );
|
3717 + | ::pretty_assertions::assert_eq!(
|
3718 + | input.string_value,
|
3719 + | expected.string_value,
|
3720 + | "Unexpected value for `string_value`"
|
3721 + | );
|
3722 + | ::pretty_assertions::assert_eq!(
|
3723 + | input.blob_value,
|
3724 + | expected.blob_value,
|
3725 + | "Unexpected value for `blob_value`"
|
3726 + | );
|
3727 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3728 + | true_boolean_value: ::std::option::Option::None,
|
3729 + | false_boolean_value: ::std::option::Option::None,
|
3730 + | byte_value: ::std::option::Option::None,
|
3731 + | double_value: ::std::option::Option::None,
|
3732 + | float_value: ::std::option::Option::None,
|
3733 + | integer_value: ::std::option::Option::None,
|
3734 + | long_value: ::std::option::Option::None,
|
3735 + | short_value: ::std::option::Option::None,
|
3736 + | string_value: ::std::option::Option::None,
|
3737 + | blob_value: ::std::option::Option::None,
|
3738 + | };
|
3739 + | output
|
3740 + | };
|
3741 + | sender.send(()).await.expect("receiver dropped early");
|
3742 + | result
|
3743 + | }
|
3744 + | })
|
3745 + | .build_unchecked();
|
3746 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3747 + | .await
|
3748 + | .expect("unable to make an HTTP request");
|
3749 + | assert!(
|
3750 + | receiver.recv().await.is_some(),
|
3751 + | "we expected operation handler to be invoked but it was not entered"
|
3752 + | );
|
3753 + | }
|
3754 + |
|
3755 + | /// The server should be capable of deserializing indefinite length text strings.
|
3756 + | /// Test ID: RpcV2CborIndefiniteLengthStringsCanBeDeserialized
|
3757 + | #[::tokio::test]
|
3758 + | #[::tracing_test::traced_test]
|
3759 + | async fn rpc_v2_cbor_indefinite_length_strings_can_be_deserialized_request() {
|
3760 + | #[allow(unused_mut)]
|
3761 + | let mut http_request = ::http::Request::builder()
|
3762 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3763 + | .method("POST")
|
3764 + | .header("Accept", "application/cbor")
|
3765 + | .header("Content-Type", "application/cbor")
|
3766 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3767 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3768 + | ::bytes::Bytes::copy_from_slice(
|
3769 + | &::aws_smithy_protocol_test::decode_body_data("oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3770 + | )
|
3771 + | )).unwrap();
|
3772 + | #[allow(unused_mut)]
|
3773 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3774 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3775 + | let service =
|
3776 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3777 + | .simple_scalar_properties(
|
3778 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3779 + | let sender = sender.clone();
|
3780 + | async move {
|
3781 + | let result = {
|
3782 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3783 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3784 + | string_value: ::std::option::Option::Some(
|
3785 + | "An example indefinite string, chunked on comma".to_owned(),
|
3786 + | ),
|
3787 + | true_boolean_value: ::std::option::Option::None,
|
3788 + | false_boolean_value: ::std::option::Option::None,
|
3789 + | byte_value: ::std::option::Option::None,
|
3790 + | double_value: ::std::option::Option::None,
|
3791 + | float_value: ::std::option::Option::None,
|
3792 + | integer_value: ::std::option::Option::None,
|
3793 + | long_value: ::std::option::Option::None,
|
3794 + | short_value: ::std::option::Option::None,
|
3795 + | blob_value: ::std::option::Option::None,
|
3796 + | };
|
3797 + | ::pretty_assertions::assert_eq!(
|
3798 + | input.true_boolean_value,
|
3799 + | expected.true_boolean_value,
|
3800 + | "Unexpected value for `true_boolean_value`"
|
3801 + | );
|
3802 + | ::pretty_assertions::assert_eq!(
|
3803 + | input.false_boolean_value,
|
3804 + | expected.false_boolean_value,
|
3805 + | "Unexpected value for `false_boolean_value`"
|
3806 + | );
|
3807 + | ::pretty_assertions::assert_eq!(
|
3808 + | input.byte_value,
|
3809 + | expected.byte_value,
|
3810 + | "Unexpected value for `byte_value`"
|
3811 + | );
|
3812 + | assert!(
|
3813 + | input.double_value.float_equals(&expected.double_value),
|
3814 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3815 + | expected.double_value,
|
3816 + | input.double_value
|
3817 + | );
|
3818 + | assert!(
|
3819 + | input.float_value.float_equals(&expected.float_value),
|
3820 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3821 + | expected.float_value,
|
3822 + | input.float_value
|
3823 + | );
|
3824 + | ::pretty_assertions::assert_eq!(
|
3825 + | input.integer_value,
|
3826 + | expected.integer_value,
|
3827 + | "Unexpected value for `integer_value`"
|
3828 + | );
|
3829 + | ::pretty_assertions::assert_eq!(
|
3830 + | input.long_value,
|
3831 + | expected.long_value,
|
3832 + | "Unexpected value for `long_value`"
|
3833 + | );
|
3834 + | ::pretty_assertions::assert_eq!(
|
3835 + | input.short_value,
|
3836 + | expected.short_value,
|
3837 + | "Unexpected value for `short_value`"
|
3838 + | );
|
3839 + | ::pretty_assertions::assert_eq!(
|
3840 + | input.string_value,
|
3841 + | expected.string_value,
|
3842 + | "Unexpected value for `string_value`"
|
3843 + | );
|
3844 + | ::pretty_assertions::assert_eq!(
|
3845 + | input.blob_value,
|
3846 + | expected.blob_value,
|
3847 + | "Unexpected value for `blob_value`"
|
3848 + | );
|
3849 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3850 + | true_boolean_value: ::std::option::Option::None,
|
3851 + | false_boolean_value: ::std::option::Option::None,
|
3852 + | byte_value: ::std::option::Option::None,
|
3853 + | double_value: ::std::option::Option::None,
|
3854 + | float_value: ::std::option::Option::None,
|
3855 + | integer_value: ::std::option::Option::None,
|
3856 + | long_value: ::std::option::Option::None,
|
3857 + | short_value: ::std::option::Option::None,
|
3858 + | string_value: ::std::option::Option::None,
|
3859 + | blob_value: ::std::option::Option::None,
|
3860 + | };
|
3861 + | output
|
3862 + | };
|
3863 + | sender.send(()).await.expect("receiver dropped early");
|
3864 + | result
|
3865 + | }
|
3866 + | },
|
3867 + | )
|
3868 + | .build_unchecked();
|
3869 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3870 + | .await
|
3871 + | .expect("unable to make an HTTP request");
|
3872 + | assert!(
|
3873 + | receiver.recv().await.is_some(),
|
3874 + | "we expected operation handler to be invoked but it was not entered"
|
3875 + | );
|
3876 + | }
|
3877 + |
|
3878 + | /// The server should be capable of deserializing indefinite length byte strings.
|
3879 + | /// Test ID: RpcV2CborIndefiniteLengthByteStringsCanBeDeserialized
|
3880 + | #[::tokio::test]
|
3881 + | #[::tracing_test::traced_test]
|
3882 + | async fn rpc_v2_cbor_indefinite_length_byte_strings_can_be_deserialized_request() {
|
3883 + | #[allow(unused_mut)]
|
3884 + | let mut http_request = ::http::Request::builder()
|
3885 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
3886 + | .method("POST")
|
3887 + | .header("Accept", "application/cbor")
|
3888 + | .header("Content-Type", "application/cbor")
|
3889 + | .header("smithy-protocol", "rpc-v2-cbor")
|
3890 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3891 + | ::bytes::Bytes::copy_from_slice(
|
3892 + | &::aws_smithy_protocol_test::decode_body_data("oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
3893 + | )
|
3894 + | )).unwrap();
|
3895 + | #[allow(unused_mut)]
|
3896 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3897 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
3898 + | let service =
|
3899 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
3900 + | .simple_scalar_properties(
|
3901 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
3902 + | let sender = sender.clone();
|
3903 + | async move {
|
3904 + | let result = {
|
3905 + | use ::aws_smithy_protocol_test::FloatEquals;
|
3906 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
3907 + | blob_value: ::std::option::Option::Some(
|
3908 + | ::aws_smithy_types::Blob::new(
|
3909 + | "An example indefinite-byte string, chunked on comma",
|
3910 + | ),
|
3911 + | ),
|
3912 + | true_boolean_value: ::std::option::Option::None,
|
3913 + | false_boolean_value: ::std::option::Option::None,
|
3914 + | byte_value: ::std::option::Option::None,
|
3915 + | double_value: ::std::option::Option::None,
|
3916 + | float_value: ::std::option::Option::None,
|
3917 + | integer_value: ::std::option::Option::None,
|
3918 + | long_value: ::std::option::Option::None,
|
3919 + | short_value: ::std::option::Option::None,
|
3920 + | string_value: ::std::option::Option::None,
|
3921 + | };
|
3922 + | ::pretty_assertions::assert_eq!(
|
3923 + | input.true_boolean_value,
|
3924 + | expected.true_boolean_value,
|
3925 + | "Unexpected value for `true_boolean_value`"
|
3926 + | );
|
3927 + | ::pretty_assertions::assert_eq!(
|
3928 + | input.false_boolean_value,
|
3929 + | expected.false_boolean_value,
|
3930 + | "Unexpected value for `false_boolean_value`"
|
3931 + | );
|
3932 + | ::pretty_assertions::assert_eq!(
|
3933 + | input.byte_value,
|
3934 + | expected.byte_value,
|
3935 + | "Unexpected value for `byte_value`"
|
3936 + | );
|
3937 + | assert!(
|
3938 + | input.double_value.float_equals(&expected.double_value),
|
3939 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
3940 + | expected.double_value,
|
3941 + | input.double_value
|
3942 + | );
|
3943 + | assert!(
|
3944 + | input.float_value.float_equals(&expected.float_value),
|
3945 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
3946 + | expected.float_value,
|
3947 + | input.float_value
|
3948 + | );
|
3949 + | ::pretty_assertions::assert_eq!(
|
3950 + | input.integer_value,
|
3951 + | expected.integer_value,
|
3952 + | "Unexpected value for `integer_value`"
|
3953 + | );
|
3954 + | ::pretty_assertions::assert_eq!(
|
3955 + | input.long_value,
|
3956 + | expected.long_value,
|
3957 + | "Unexpected value for `long_value`"
|
3958 + | );
|
3959 + | ::pretty_assertions::assert_eq!(
|
3960 + | input.short_value,
|
3961 + | expected.short_value,
|
3962 + | "Unexpected value for `short_value`"
|
3963 + | );
|
3964 + | ::pretty_assertions::assert_eq!(
|
3965 + | input.string_value,
|
3966 + | expected.string_value,
|
3967 + | "Unexpected value for `string_value`"
|
3968 + | );
|
3969 + | ::pretty_assertions::assert_eq!(
|
3970 + | input.blob_value,
|
3971 + | expected.blob_value,
|
3972 + | "Unexpected value for `blob_value`"
|
3973 + | );
|
3974 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
3975 + | true_boolean_value: ::std::option::Option::None,
|
3976 + | false_boolean_value: ::std::option::Option::None,
|
3977 + | byte_value: ::std::option::Option::None,
|
3978 + | double_value: ::std::option::Option::None,
|
3979 + | float_value: ::std::option::Option::None,
|
3980 + | integer_value: ::std::option::Option::None,
|
3981 + | long_value: ::std::option::Option::None,
|
3982 + | short_value: ::std::option::Option::None,
|
3983 + | string_value: ::std::option::Option::None,
|
3984 + | blob_value: ::std::option::Option::None,
|
3985 + | };
|
3986 + | output
|
3987 + | };
|
3988 + | sender.send(()).await.expect("receiver dropped early");
|
3989 + | result
|
3990 + | }
|
3991 + | },
|
3992 + | )
|
3993 + | .build_unchecked();
|
3994 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3995 + | .await
|
3996 + | .expect("unable to make an HTTP request");
|
3997 + | assert!(
|
3998 + | receiver.recv().await.is_some(),
|
3999 + | "we expected operation handler to be invoked but it was not entered"
|
4000 + | );
|
4001 + | }
|
4002 + |
|
4003 + | /// Supports upcasting from a smaller byte representation of the same data type.
|
4004 + | /// Test ID: RpcV2CborSupportsUpcastingData
|
4005 + | #[::tokio::test]
|
4006 + | #[::tracing_test::traced_test]
|
4007 + | async fn rpc_v2_cbor_supports_upcasting_data_request() {
|
4008 + | #[allow(unused_mut)]
|
4009 + | let mut http_request = ::http::Request::builder()
|
4010 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4011 + | .method("POST")
|
4012 + | .header("Accept", "application/cbor")
|
4013 + | .header("Content-Type", "application/cbor")
|
4014 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4015 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4016 + | ::bytes::Bytes::copy_from_slice(
|
4017 + | &::aws_smithy_protocol_test::decode_body_data("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8=".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4018 + | )
|
4019 + | )).unwrap();
|
4020 + | #[allow(unused_mut)]
|
4021 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4022 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4023 + | let service =
|
4024 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4025 + | .simple_scalar_properties(
|
4026 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
4027 + | let sender = sender.clone();
|
4028 + | async move {
|
4029 + | let result = {
|
4030 + | use ::aws_smithy_protocol_test::FloatEquals;
|
4031 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
4032 + | double_value: ::std::option::Option::Some(1.5_f64),
|
4033 + | float_value: ::std::option::Option::Some(7.625_f32),
|
4034 + | integer_value: ::std::option::Option::Some(56),
|
4035 + | long_value: ::std::option::Option::Some(256),
|
4036 + | short_value: ::std::option::Option::Some(10),
|
4037 + | true_boolean_value: ::std::option::Option::None,
|
4038 + | false_boolean_value: ::std::option::Option::None,
|
4039 + | byte_value: ::std::option::Option::None,
|
4040 + | string_value: ::std::option::Option::None,
|
4041 + | blob_value: ::std::option::Option::None,
|
4042 + | };
|
4043 + | ::pretty_assertions::assert_eq!(
|
4044 + | input.true_boolean_value,
|
4045 + | expected.true_boolean_value,
|
4046 + | "Unexpected value for `true_boolean_value`"
|
4047 + | );
|
4048 + | ::pretty_assertions::assert_eq!(
|
4049 + | input.false_boolean_value,
|
4050 + | expected.false_boolean_value,
|
4051 + | "Unexpected value for `false_boolean_value`"
|
4052 + | );
|
4053 + | ::pretty_assertions::assert_eq!(
|
4054 + | input.byte_value,
|
4055 + | expected.byte_value,
|
4056 + | "Unexpected value for `byte_value`"
|
4057 + | );
|
4058 + | assert!(
|
4059 + | input.double_value.float_equals(&expected.double_value),
|
4060 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4061 + | expected.double_value,
|
4062 + | input.double_value
|
4063 + | );
|
4064 + | assert!(
|
4065 + | input.float_value.float_equals(&expected.float_value),
|
4066 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4067 + | expected.float_value,
|
4068 + | input.float_value
|
4069 + | );
|
4070 + | ::pretty_assertions::assert_eq!(
|
4071 + | input.integer_value,
|
4072 + | expected.integer_value,
|
4073 + | "Unexpected value for `integer_value`"
|
4074 + | );
|
4075 + | ::pretty_assertions::assert_eq!(
|
4076 + | input.long_value,
|
4077 + | expected.long_value,
|
4078 + | "Unexpected value for `long_value`"
|
4079 + | );
|
4080 + | ::pretty_assertions::assert_eq!(
|
4081 + | input.short_value,
|
4082 + | expected.short_value,
|
4083 + | "Unexpected value for `short_value`"
|
4084 + | );
|
4085 + | ::pretty_assertions::assert_eq!(
|
4086 + | input.string_value,
|
4087 + | expected.string_value,
|
4088 + | "Unexpected value for `string_value`"
|
4089 + | );
|
4090 + | ::pretty_assertions::assert_eq!(
|
4091 + | input.blob_value,
|
4092 + | expected.blob_value,
|
4093 + | "Unexpected value for `blob_value`"
|
4094 + | );
|
4095 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4096 + | true_boolean_value: ::std::option::Option::None,
|
4097 + | false_boolean_value: ::std::option::Option::None,
|
4098 + | byte_value: ::std::option::Option::None,
|
4099 + | double_value: ::std::option::Option::None,
|
4100 + | float_value: ::std::option::Option::None,
|
4101 + | integer_value: ::std::option::Option::None,
|
4102 + | long_value: ::std::option::Option::None,
|
4103 + | short_value: ::std::option::Option::None,
|
4104 + | string_value: ::std::option::Option::None,
|
4105 + | blob_value: ::std::option::Option::None,
|
4106 + | };
|
4107 + | output
|
4108 + | };
|
4109 + | sender.send(()).await.expect("receiver dropped early");
|
4110 + | result
|
4111 + | }
|
4112 + | },
|
4113 + | )
|
4114 + | .build_unchecked();
|
4115 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4116 + | .await
|
4117 + | .expect("unable to make an HTTP request");
|
4118 + | assert!(
|
4119 + | receiver.recv().await.is_some(),
|
4120 + | "we expected operation handler to be invoked but it was not entered"
|
4121 + | );
|
4122 + | }
|
4123 + |
|
4124 + | /// The server should skip over additional fields that are not part of the structure. This allows a
|
4125 + | /// client generated against a newer Smithy model to be able to communicate with a server that is
|
4126 + | /// generated against an older Smithy model.
|
4127 + | /// Test ID: RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByServers
|
4128 + | #[::tokio::test]
|
4129 + | #[::tracing_test::traced_test]
|
4130 + | async fn rpc_v2_cbor_extra_fields_in_the_body_should_be_skipped_by_servers_request() {
|
4131 + | #[allow(unused_mut)]
|
4132 + | let mut http_request = ::http::Request::builder()
|
4133 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4134 + | .method("POST")
|
4135 + | .header("Accept", "application/cbor")
|
4136 + | .header("Content-Type", "application/cbor")
|
4137 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4138 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4139 + | ::bytes::Bytes::copy_from_slice(
|
4140 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABrZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4141 + | )
|
4142 + | )).unwrap();
|
4143 + | #[allow(unused_mut)]
|
4144 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4145 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4146 + | let service =
|
4147 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4148 + | .simple_scalar_properties(
|
4149 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
4150 + | let sender = sender.clone();
|
4151 + | async move {
|
4152 + | let result = {
|
4153 + | use ::aws_smithy_protocol_test::FloatEquals;
|
4154 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
4155 + | byte_value: ::std::option::Option::Some(5),
|
4156 + | double_value: ::std::option::Option::Some(1.889_f64),
|
4157 + | false_boolean_value: ::std::option::Option::Some(false),
|
4158 + | float_value: ::std::option::Option::Some(7.625_f32),
|
4159 + | integer_value: ::std::option::Option::Some(256),
|
4160 + | long_value: ::std::option::Option::Some(9873),
|
4161 + | short_value: ::std::option::Option::Some(9898),
|
4162 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4163 + | true_boolean_value: ::std::option::Option::Some(true),
|
4164 + | blob_value: ::std::option::Option::Some(
|
4165 + | ::aws_smithy_types::Blob::new("foo"),
|
4166 + | ),
|
4167 + | };
|
4168 + | ::pretty_assertions::assert_eq!(
|
4169 + | input.true_boolean_value,
|
4170 + | expected.true_boolean_value,
|
4171 + | "Unexpected value for `true_boolean_value`"
|
4172 + | );
|
4173 + | ::pretty_assertions::assert_eq!(
|
4174 + | input.false_boolean_value,
|
4175 + | expected.false_boolean_value,
|
4176 + | "Unexpected value for `false_boolean_value`"
|
4177 + | );
|
4178 + | ::pretty_assertions::assert_eq!(
|
4179 + | input.byte_value,
|
4180 + | expected.byte_value,
|
4181 + | "Unexpected value for `byte_value`"
|
4182 + | );
|
4183 + | assert!(
|
4184 + | input.double_value.float_equals(&expected.double_value),
|
4185 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4186 + | expected.double_value,
|
4187 + | input.double_value
|
4188 + | );
|
4189 + | assert!(
|
4190 + | input.float_value.float_equals(&expected.float_value),
|
4191 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4192 + | expected.float_value,
|
4193 + | input.float_value
|
4194 + | );
|
4195 + | ::pretty_assertions::assert_eq!(
|
4196 + | input.integer_value,
|
4197 + | expected.integer_value,
|
4198 + | "Unexpected value for `integer_value`"
|
4199 + | );
|
4200 + | ::pretty_assertions::assert_eq!(
|
4201 + | input.long_value,
|
4202 + | expected.long_value,
|
4203 + | "Unexpected value for `long_value`"
|
4204 + | );
|
4205 + | ::pretty_assertions::assert_eq!(
|
4206 + | input.short_value,
|
4207 + | expected.short_value,
|
4208 + | "Unexpected value for `short_value`"
|
4209 + | );
|
4210 + | ::pretty_assertions::assert_eq!(
|
4211 + | input.string_value,
|
4212 + | expected.string_value,
|
4213 + | "Unexpected value for `string_value`"
|
4214 + | );
|
4215 + | ::pretty_assertions::assert_eq!(
|
4216 + | input.blob_value,
|
4217 + | expected.blob_value,
|
4218 + | "Unexpected value for `blob_value`"
|
4219 + | );
|
4220 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4221 + | true_boolean_value: ::std::option::Option::None,
|
4222 + | false_boolean_value: ::std::option::Option::None,
|
4223 + | byte_value: ::std::option::Option::None,
|
4224 + | double_value: ::std::option::Option::None,
|
4225 + | float_value: ::std::option::Option::None,
|
4226 + | integer_value: ::std::option::Option::None,
|
4227 + | long_value: ::std::option::Option::None,
|
4228 + | short_value: ::std::option::Option::None,
|
4229 + | string_value: ::std::option::Option::None,
|
4230 + | blob_value: ::std::option::Option::None,
|
4231 + | };
|
4232 + | output
|
4233 + | };
|
4234 + | sender.send(()).await.expect("receiver dropped early");
|
4235 + | result
|
4236 + | }
|
4237 + | },
|
4238 + | )
|
4239 + | .build_unchecked();
|
4240 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4241 + | .await
|
4242 + | .expect("unable to make an HTTP request");
|
4243 + | assert!(
|
4244 + | receiver.recv().await.is_some(),
|
4245 + | "we expected operation handler to be invoked but it was not entered"
|
4246 + | );
|
4247 + | }
|
4248 + |
|
4249 + | /// Servers should tolerate requests without an Accept header set.
|
4250 + | /// Test ID: RpcV2CborServersShouldHandleNoAcceptHeader
|
4251 + | #[::tokio::test]
|
4252 + | #[::tracing_test::traced_test]
|
4253 + | async fn rpc_v2_cbor_servers_should_handle_no_accept_header_request() {
|
4254 + | #[allow(unused_mut)]
|
4255 + | let mut http_request = ::http::Request::builder()
|
4256 + | .uri("/service/RpcV2Protocol/operation/SimpleScalarProperties")
|
4257 + | .method("POST")
|
4258 + | .header("Content-Type", "application/cbor")
|
4259 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4260 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4261 + | ::bytes::Bytes::copy_from_slice(
|
4262 + | &::aws_smithy_protocol_test::decode_body_data("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4263 + | )
|
4264 + | )).unwrap();
|
4265 + | #[allow(unused_mut)]
|
4266 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4267 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4268 + | let service =
|
4269 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4270 + | .simple_scalar_properties(
|
4271 + | move |input: crate::input::SimpleScalarPropertiesInput| {
|
4272 + | let sender = sender.clone();
|
4273 + | async move {
|
4274 + | let result = {
|
4275 + | use ::aws_smithy_protocol_test::FloatEquals;
|
4276 + | let expected = crate::input::SimpleScalarPropertiesInput {
|
4277 + | byte_value: ::std::option::Option::Some(5),
|
4278 + | double_value: ::std::option::Option::Some(1.889_f64),
|
4279 + | false_boolean_value: ::std::option::Option::Some(false),
|
4280 + | float_value: ::std::option::Option::Some(7.625_f32),
|
4281 + | integer_value: ::std::option::Option::Some(256),
|
4282 + | long_value: ::std::option::Option::Some(9873),
|
4283 + | short_value: ::std::option::Option::Some(9898),
|
4284 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4285 + | true_boolean_value: ::std::option::Option::Some(true),
|
4286 + | blob_value: ::std::option::Option::Some(
|
4287 + | ::aws_smithy_types::Blob::new("foo"),
|
4288 + | ),
|
4289 + | };
|
4290 + | ::pretty_assertions::assert_eq!(
|
4291 + | input.true_boolean_value,
|
4292 + | expected.true_boolean_value,
|
4293 + | "Unexpected value for `true_boolean_value`"
|
4294 + | );
|
4295 + | ::pretty_assertions::assert_eq!(
|
4296 + | input.false_boolean_value,
|
4297 + | expected.false_boolean_value,
|
4298 + | "Unexpected value for `false_boolean_value`"
|
4299 + | );
|
4300 + | ::pretty_assertions::assert_eq!(
|
4301 + | input.byte_value,
|
4302 + | expected.byte_value,
|
4303 + | "Unexpected value for `byte_value`"
|
4304 + | );
|
4305 + | assert!(
|
4306 + | input.double_value.float_equals(&expected.double_value),
|
4307 + | "Unexpected value for `double_value` {:?} vs. {:?}",
|
4308 + | expected.double_value,
|
4309 + | input.double_value
|
4310 + | );
|
4311 + | assert!(
|
4312 + | input.float_value.float_equals(&expected.float_value),
|
4313 + | "Unexpected value for `float_value` {:?} vs. {:?}",
|
4314 + | expected.float_value,
|
4315 + | input.float_value
|
4316 + | );
|
4317 + | ::pretty_assertions::assert_eq!(
|
4318 + | input.integer_value,
|
4319 + | expected.integer_value,
|
4320 + | "Unexpected value for `integer_value`"
|
4321 + | );
|
4322 + | ::pretty_assertions::assert_eq!(
|
4323 + | input.long_value,
|
4324 + | expected.long_value,
|
4325 + | "Unexpected value for `long_value`"
|
4326 + | );
|
4327 + | ::pretty_assertions::assert_eq!(
|
4328 + | input.short_value,
|
4329 + | expected.short_value,
|
4330 + | "Unexpected value for `short_value`"
|
4331 + | );
|
4332 + | ::pretty_assertions::assert_eq!(
|
4333 + | input.string_value,
|
4334 + | expected.string_value,
|
4335 + | "Unexpected value for `string_value`"
|
4336 + | );
|
4337 + | ::pretty_assertions::assert_eq!(
|
4338 + | input.blob_value,
|
4339 + | expected.blob_value,
|
4340 + | "Unexpected value for `blob_value`"
|
4341 + | );
|
4342 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4343 + | true_boolean_value: ::std::option::Option::None,
|
4344 + | false_boolean_value: ::std::option::Option::None,
|
4345 + | byte_value: ::std::option::Option::None,
|
4346 + | double_value: ::std::option::Option::None,
|
4347 + | float_value: ::std::option::Option::None,
|
4348 + | integer_value: ::std::option::Option::None,
|
4349 + | long_value: ::std::option::Option::None,
|
4350 + | short_value: ::std::option::Option::None,
|
4351 + | string_value: ::std::option::Option::None,
|
4352 + | blob_value: ::std::option::Option::None,
|
4353 + | };
|
4354 + | output
|
4355 + | };
|
4356 + | sender.send(()).await.expect("receiver dropped early");
|
4357 + | result
|
4358 + | }
|
4359 + | },
|
4360 + | )
|
4361 + | .build_unchecked();
|
4362 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4363 + | .await
|
4364 + | .expect("unable to make an HTTP request");
|
4365 + | assert!(
|
4366 + | receiver.recv().await.is_some(),
|
4367 + | "we expected operation handler to be invoked but it was not entered"
|
4368 + | );
|
4369 + | }
|
4370 + |
|
4371 + | /// Serializes simple scalar properties
|
4372 + | /// Test ID: RpcV2CborSimpleScalarProperties
|
4373 + | #[::tokio::test]
|
4374 + | #[::tracing_test::traced_test]
|
4375 + | async fn rpc_v2_cbor_simple_scalar_properties_response() {
|
4376 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4377 + | true_boolean_value: ::std::option::Option::Some(true),
|
4378 + | false_boolean_value: ::std::option::Option::Some(false),
|
4379 + | byte_value: ::std::option::Option::Some(5),
|
4380 + | double_value: ::std::option::Option::Some(1.889_f64),
|
4381 + | float_value: ::std::option::Option::Some(7.625_f32),
|
4382 + | integer_value: ::std::option::Option::Some(256),
|
4383 + | short_value: ::std::option::Option::Some(9898),
|
4384 + | string_value: ::std::option::Option::Some("simple".to_owned()),
|
4385 + | blob_value: ::std::option::Option::Some(::aws_smithy_types::Blob::new("foo")),
|
4386 + | long_value: ::std::option::Option::None,
|
4387 + | };
|
4388 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4389 + | let http_response = output.into_response();
|
4390 + | ::pretty_assertions::assert_eq!(
|
4391 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4392 + | http_response.status()
|
4393 + | );
|
4394 + | let expected_headers = [
|
4395 + | ("Content-Type", "application/cbor"),
|
4396 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4397 + | ];
|
4398 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4399 + | http_response.headers(),
|
4400 + | expected_headers,
|
4401 + | ));
|
4402 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4403 + | .await
|
4404 + | .expect("unable to extract body to bytes");
|
4405 + | ::aws_smithy_protocol_test::assert_ok(
|
4406 + | ::aws_smithy_protocol_test::validate_body(&body, "v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", ::aws_smithy_protocol_test::MediaType::from("application/cbor"))
|
4407 + | );
|
4408 + | }
|
4409 + |
|
4410 + | /// RpcV2 Cbor should not serialize null structure values
|
4411 + | /// Test ID: RpcV2CborServerDoesntSerializeNullStructureValues
|
4412 + | #[::tokio::test]
|
4413 + | #[::tracing_test::traced_test]
|
4414 + | async fn rpc_v2_cbor_server_doesnt_serialize_null_structure_values_response() {
|
4415 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4416 + | string_value: ::std::option::Option::None,
|
4417 + | true_boolean_value: ::std::option::Option::None,
|
4418 + | false_boolean_value: ::std::option::Option::None,
|
4419 + | byte_value: ::std::option::Option::None,
|
4420 + | double_value: ::std::option::Option::None,
|
4421 + | float_value: ::std::option::Option::None,
|
4422 + | integer_value: ::std::option::Option::None,
|
4423 + | long_value: ::std::option::Option::None,
|
4424 + | short_value: ::std::option::Option::None,
|
4425 + | blob_value: ::std::option::Option::None,
|
4426 + | };
|
4427 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4428 + | let http_response = output.into_response();
|
4429 + | ::pretty_assertions::assert_eq!(
|
4430 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4431 + | http_response.status()
|
4432 + | );
|
4433 + | let expected_headers = [
|
4434 + | ("Content-Type", "application/cbor"),
|
4435 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4436 + | ];
|
4437 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4438 + | http_response.headers(),
|
4439 + | expected_headers,
|
4440 + | ));
|
4441 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4442 + | .await
|
4443 + | .expect("unable to extract body to bytes");
|
4444 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4445 + | &body,
|
4446 + | "v/8=",
|
4447 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4448 + | ));
|
4449 + | }
|
4450 + |
|
4451 + | /// Supports handling NaN float values.
|
4452 + | /// Test ID: RpcV2CborSupportsNaNFloatOutputs
|
4453 + | #[::tokio::test]
|
4454 + | #[::tracing_test::traced_test]
|
4455 + | async fn rpc_v2_cbor_supports_na_n_float_outputs_response() {
|
4456 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4457 + | double_value: ::std::option::Option::Some(
|
4458 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4459 + | .expect("invalid string for number"),
|
4460 + | ),
|
4461 + | float_value: ::std::option::Option::Some(
|
4462 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("NaN")
|
4463 + | .expect("invalid string for number"),
|
4464 + | ),
|
4465 + | true_boolean_value: ::std::option::Option::None,
|
4466 + | false_boolean_value: ::std::option::Option::None,
|
4467 + | byte_value: ::std::option::Option::None,
|
4468 + | integer_value: ::std::option::Option::None,
|
4469 + | long_value: ::std::option::Option::None,
|
4470 + | short_value: ::std::option::Option::None,
|
4471 + | string_value: ::std::option::Option::None,
|
4472 + | blob_value: ::std::option::Option::None,
|
4473 + | };
|
4474 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4475 + | let http_response = output.into_response();
|
4476 + | ::pretty_assertions::assert_eq!(
|
4477 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4478 + | http_response.status()
|
4479 + | );
|
4480 + | let expected_headers = [
|
4481 + | ("Content-Type", "application/cbor"),
|
4482 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4483 + | ];
|
4484 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4485 + | http_response.headers(),
|
4486 + | expected_headers,
|
4487 + | ));
|
4488 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4489 + | .await
|
4490 + | .expect("unable to extract body to bytes");
|
4491 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4492 + | &body,
|
4493 + | "v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/",
|
4494 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4495 + | ));
|
4496 + | }
|
4497 + |
|
4498 + | /// Supports handling Infinity float values.
|
4499 + | /// Test ID: RpcV2CborSupportsInfinityFloatOutputs
|
4500 + | #[::tokio::test]
|
4501 + | #[::tracing_test::traced_test]
|
4502 + | async fn rpc_v2_cbor_supports_infinity_float_outputs_response() {
|
4503 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4504 + | double_value: ::std::option::Option::Some(
|
4505 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4506 + | .expect("invalid string for number"),
|
4507 + | ),
|
4508 + | float_value: ::std::option::Option::Some(
|
4509 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("Infinity")
|
4510 + | .expect("invalid string for number"),
|
4511 + | ),
|
4512 + | true_boolean_value: ::std::option::Option::None,
|
4513 + | false_boolean_value: ::std::option::Option::None,
|
4514 + | byte_value: ::std::option::Option::None,
|
4515 + | integer_value: ::std::option::Option::None,
|
4516 + | long_value: ::std::option::Option::None,
|
4517 + | short_value: ::std::option::Option::None,
|
4518 + | string_value: ::std::option::Option::None,
|
4519 + | blob_value: ::std::option::Option::None,
|
4520 + | };
|
4521 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4522 + | let http_response = output.into_response();
|
4523 + | ::pretty_assertions::assert_eq!(
|
4524 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4525 + | http_response.status()
|
4526 + | );
|
4527 + | let expected_headers = [
|
4528 + | ("Content-Type", "application/cbor"),
|
4529 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4530 + | ];
|
4531 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4532 + | http_response.headers(),
|
4533 + | expected_headers,
|
4534 + | ));
|
4535 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4536 + | .await
|
4537 + | .expect("unable to extract body to bytes");
|
4538 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4539 + | &body,
|
4540 + | "v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/",
|
4541 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4542 + | ));
|
4543 + | }
|
4544 + |
|
4545 + | /// Supports handling Negative Infinity float values.
|
4546 + | /// Test ID: RpcV2CborSupportsNegativeInfinityFloatOutputs
|
4547 + | #[::tokio::test]
|
4548 + | #[::tracing_test::traced_test]
|
4549 + | async fn rpc_v2_cbor_supports_negative_infinity_float_outputs_response() {
|
4550 + | let output = crate::output::SimpleScalarPropertiesOutput {
|
4551 + | double_value: ::std::option::Option::Some(
|
4552 + | <f64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4553 + | .expect("invalid string for number"),
|
4554 + | ),
|
4555 + | float_value: ::std::option::Option::Some(
|
4556 + | <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive("-Infinity")
|
4557 + | .expect("invalid string for number"),
|
4558 + | ),
|
4559 + | true_boolean_value: ::std::option::Option::None,
|
4560 + | false_boolean_value: ::std::option::Option::None,
|
4561 + | byte_value: ::std::option::Option::None,
|
4562 + | integer_value: ::std::option::Option::None,
|
4563 + | long_value: ::std::option::Option::None,
|
4564 + | short_value: ::std::option::Option::None,
|
4565 + | string_value: ::std::option::Option::None,
|
4566 + | blob_value: ::std::option::Option::None,
|
4567 + | };
|
4568 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4569 + | let http_response = output.into_response();
|
4570 + | ::pretty_assertions::assert_eq!(
|
4571 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4572 + | http_response.status()
|
4573 + | );
|
4574 + | let expected_headers = [
|
4575 + | ("Content-Type", "application/cbor"),
|
4576 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4577 + | ];
|
4578 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4579 + | http_response.headers(),
|
4580 + | expected_headers,
|
4581 + | ));
|
4582 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4583 + | .await
|
4584 + | .expect("unable to extract body to bytes");
|
4585 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4586 + | &body,
|
4587 + | "v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/",
|
4588 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4589 + | ));
|
4590 + | }
|
4591 + | }
|
4592 + |
|
4593 + | ::pin_project_lite::pin_project! {
|
4594 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4595 + | /// [`OptionalInputOutputInput`](crate::input::OptionalInputOutputInput) using modelled bindings.
|
4596 + | pub struct OptionalInputOutputInputFuture {
|
4597 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OptionalInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4598 + | }
|
4599 + | }
|
4600 + |
|
4601 + | impl std::future::Future for OptionalInputOutputInputFuture {
|
4602 + | type Output = Result<
|
4603 + | crate::input::OptionalInputOutputInput,
|
4604 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4605 + | >;
|
4606 + |
|
4607 + | fn poll(
|
4608 + | self: std::pin::Pin<&mut Self>,
|
4609 + | cx: &mut std::task::Context<'_>,
|
4610 + | ) -> std::task::Poll<Self::Output> {
|
4611 + | let this = self.project();
|
4612 + | this.inner.as_mut().poll(cx)
|
4613 + | }
|
4614 + | }
|
4615 + |
|
4616 + | impl<B>
|
4617 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4618 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4619 + | B,
|
4620 + | > for crate::input::OptionalInputOutputInput
|
4621 + | where
|
4622 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4623 + | B: 'static,
|
4624 + |
|
4625 + | B::Data: Send,
|
4626 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4627 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4628 + | {
|
4629 + | type Rejection =
|
4630 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4631 + | type Future = OptionalInputOutputInputFuture;
|
4632 + |
|
4633 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4634 + | let fut = async move {
|
4635 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4636 + | request.headers(),
|
4637 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4638 + | ) {
|
4639 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4640 + | }
|
4641 + | crate::protocol_serde::shape_optional_input_output::de_optional_input_output_http_request(request)
|
4642 + | .await
|
4643 + | };
|
4644 + | use ::futures_util::future::TryFutureExt;
|
4645 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4646 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4647 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
4648 + | });
|
4649 + | OptionalInputOutputInputFuture {
|
4650 + | inner: Box::pin(fut),
|
4651 + | }
|
4652 + | }
|
4653 + | }
|
4654 + | impl
|
4655 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4656 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4657 + | > for crate::output::OptionalInputOutputOutput
|
4658 + | {
|
4659 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4660 + | match crate::protocol_serde::shape_optional_input_output::ser_optional_input_output_http_response(self) {
|
4661 + | Ok(response) => response,
|
4662 + | Err(e) => {
|
4663 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4664 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4665 + | }
|
4666 + | }
|
4667 + | }
|
4668 + | }
|
4669 + |
|
4670 + | #[allow(unreachable_code, unused_variables)]
|
4671 + | #[cfg(test)]
|
4672 + | mod optional_input_output_test {
|
4673 + |
|
4674 + | /// When input is empty we write CBOR equivalent of {}
|
4675 + | /// Test ID: optional_input
|
4676 + | #[::tokio::test]
|
4677 + | #[::tracing_test::traced_test]
|
4678 + | async fn optional_input_request() {
|
4679 + | #[allow(unused_mut)]
|
4680 + | let mut http_request = ::http::Request::builder()
|
4681 + | .uri("/service/RpcV2Protocol/operation/OptionalInputOutput")
|
4682 + | .method("POST")
|
4683 + | .header("Accept", "application/cbor")
|
4684 + | .header("Content-Type", "application/cbor")
|
4685 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4686 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4687 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4688 + | "v/8=".as_bytes(),
|
4689 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4690 + | )),
|
4691 + | ))
|
4692 + | .unwrap();
|
4693 + | #[allow(unused_mut)]
|
4694 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4695 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4696 + | let service =
|
4697 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4698 + | .optional_input_output(move |input: crate::input::OptionalInputOutputInput| {
|
4699 + | let sender = sender.clone();
|
4700 + | async move {
|
4701 + | let result = {
|
4702 + | let expected = crate::input::OptionalInputOutputInput {
|
4703 + | value: ::std::option::Option::None,
|
4704 + | };
|
4705 + | ::pretty_assertions::assert_eq!(input, expected);
|
4706 + | let output = crate::output::OptionalInputOutputOutput {
|
4707 + | value: ::std::option::Option::None,
|
4708 + | };
|
4709 + | output
|
4710 + | };
|
4711 + | sender.send(()).await.expect("receiver dropped early");
|
4712 + | result
|
4713 + | }
|
4714 + | })
|
4715 + | .build_unchecked();
|
4716 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4717 + | .await
|
4718 + | .expect("unable to make an HTTP request");
|
4719 + | assert!(
|
4720 + | receiver.recv().await.is_some(),
|
4721 + | "we expected operation handler to be invoked but it was not entered"
|
4722 + | );
|
4723 + | }
|
4724 + |
|
4725 + | /// When output is empty we write CBOR equivalent of {}
|
4726 + | /// Test ID: optional_output
|
4727 + | #[::tokio::test]
|
4728 + | #[::tracing_test::traced_test]
|
4729 + | async fn optional_output_response() {
|
4730 + | let output = crate::output::OptionalInputOutputOutput {
|
4731 + | value: ::std::option::Option::None,
|
4732 + | };
|
4733 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4734 + | let http_response = output.into_response();
|
4735 + | ::pretty_assertions::assert_eq!(
|
4736 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4737 + | http_response.status()
|
4738 + | );
|
4739 + | let expected_headers = [
|
4740 + | ("Content-Type", "application/cbor"),
|
4741 + | ("smithy-protocol", "rpc-v2-cbor"),
|
4742 + | ];
|
4743 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4744 + | http_response.headers(),
|
4745 + | expected_headers,
|
4746 + | ));
|
4747 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4748 + | .await
|
4749 + | .expect("unable to extract body to bytes");
|
4750 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
4751 + | &body,
|
4752 + | "v/8=",
|
4753 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4754 + | ));
|
4755 + | }
|
4756 + | }
|
4757 + |
|
4758 + | ::pin_project_lite::pin_project! {
|
4759 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4760 + | /// [`EmptyInputOutputInput`](crate::input::EmptyInputOutputInput) using modelled bindings.
|
4761 + | pub struct EmptyInputOutputInputFuture {
|
4762 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::EmptyInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
4763 + | }
|
4764 + | }
|
4765 + |
|
4766 + | impl std::future::Future for EmptyInputOutputInputFuture {
|
4767 + | type Output = Result<
|
4768 + | crate::input::EmptyInputOutputInput,
|
4769 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
4770 + | >;
|
4771 + |
|
4772 + | fn poll(
|
4773 + | self: std::pin::Pin<&mut Self>,
|
4774 + | cx: &mut std::task::Context<'_>,
|
4775 + | ) -> std::task::Poll<Self::Output> {
|
4776 + | let this = self.project();
|
4777 + | this.inner.as_mut().poll(cx)
|
4778 + | }
|
4779 + | }
|
4780 + |
|
4781 + | impl<B>
|
4782 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4783 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4784 + | B,
|
4785 + | > for crate::input::EmptyInputOutputInput
|
4786 + | where
|
4787 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4788 + | B: 'static,
|
4789 + |
|
4790 + | B::Data: Send,
|
4791 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
4792 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4793 + | {
|
4794 + | type Rejection =
|
4795 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
4796 + | type Future = EmptyInputOutputInputFuture;
|
4797 + |
|
4798 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4799 + | let fut = async move {
|
4800 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4801 + | request.headers(),
|
4802 + | &crate::mimes::CONTENT_TYPE_APPLICATION_CBOR,
|
4803 + | ) {
|
4804 + | return Err(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection::NotAcceptable);
|
4805 + | }
|
4806 + | crate::protocol_serde::shape_empty_input_output::de_empty_input_output_http_request(
|
4807 + | request,
|
4808 + | )
|
4809 + | .await
|
4810 + | };
|
4811 + | use ::futures_util::future::TryFutureExt;
|
4812 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
4813 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4814 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
4815 + | });
|
4816 + | EmptyInputOutputInputFuture {
|
4817 + | inner: Box::pin(fut),
|
4818 + | }
|
4819 + | }
|
4820 + | }
|
4821 + | impl
|
4822 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4823 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
4824 + | > for crate::output::EmptyInputOutputOutput
|
4825 + | {
|
4826 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4827 + | match crate::protocol_serde::shape_empty_input_output::ser_empty_input_output_http_response(
|
4828 + | self,
|
4829 + | ) {
|
4830 + | Ok(response) => response,
|
4831 + | Err(e) => {
|
4832 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4833 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
4834 + | }
|
4835 + | }
|
4836 + | }
|
4837 + | }
|
4838 + |
|
4839 + | #[allow(unreachable_code, unused_variables)]
|
4840 + | #[cfg(test)]
|
4841 + | mod empty_input_output_test {
|
4842 + |
|
4843 + | /// When Input structure is empty we write CBOR equivalent of {}
|
4844 + | /// Test ID: empty_input
|
4845 + | #[::tokio::test]
|
4846 + | #[::tracing_test::traced_test]
|
4847 + | async fn empty_input_request() {
|
4848 + | #[allow(unused_mut)]
|
4849 + | let mut http_request = ::http::Request::builder()
|
4850 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4851 + | .method("POST")
|
4852 + | .header("Accept", "application/cbor")
|
4853 + | .header("Content-Type", "application/cbor")
|
4854 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4855 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4856 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4857 + | "v/8=".as_bytes(),
|
4858 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4859 + | )),
|
4860 + | ))
|
4861 + | .unwrap();
|
4862 + | #[allow(unused_mut)]
|
4863 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4864 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4865 + | let service =
|
4866 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4867 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4868 + | let sender = sender.clone();
|
4869 + | async move {
|
4870 + | let result = {
|
4871 + | let expected = crate::input::EmptyInputOutputInput {};
|
4872 + | ::pretty_assertions::assert_eq!(input, expected);
|
4873 + | let output = crate::output::EmptyInputOutputOutput {};
|
4874 + | output
|
4875 + | };
|
4876 + | sender.send(()).await.expect("receiver dropped early");
|
4877 + | result
|
4878 + | }
|
4879 + | })
|
4880 + | .build_unchecked();
|
4881 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4882 + | .await
|
4883 + | .expect("unable to make an HTTP request");
|
4884 + | assert!(
|
4885 + | receiver.recv().await.is_some(),
|
4886 + | "we expected operation handler to be invoked but it was not entered"
|
4887 + | );
|
4888 + | }
|
4889 + |
|
4890 + | /// When Input structure is empty the server should accept an empty body
|
4891 + | /// Test ID: empty_input_no_body
|
4892 + | #[::tokio::test]
|
4893 + | #[::tracing_test::traced_test]
|
4894 + | async fn empty_input_no_body_request() {
|
4895 + | #[allow(unused_mut)]
|
4896 + | let mut http_request = ::http::Request::builder()
|
4897 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4898 + | .method("POST")
|
4899 + | .header("Accept", "application/cbor")
|
4900 + | .header("Content-Type", "application/cbor")
|
4901 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4902 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4903 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4904 + | "".as_bytes(),
|
4905 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4906 + | )),
|
4907 + | ))
|
4908 + | .unwrap();
|
4909 + | #[allow(unused_mut)]
|
4910 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4911 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4912 + | let service =
|
4913 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4914 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4915 + | let sender = sender.clone();
|
4916 + | async move {
|
4917 + | let result = {
|
4918 + | let expected = crate::input::EmptyInputOutputInput {};
|
4919 + | ::pretty_assertions::assert_eq!(input, expected);
|
4920 + | let output = crate::output::EmptyInputOutputOutput {};
|
4921 + | output
|
4922 + | };
|
4923 + | sender.send(()).await.expect("receiver dropped early");
|
4924 + | result
|
4925 + | }
|
4926 + | })
|
4927 + | .build_unchecked();
|
4928 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4929 + | .await
|
4930 + | .expect("unable to make an HTTP request");
|
4931 + | assert!(
|
4932 + | receiver.recv().await.is_some(),
|
4933 + | "we expected operation handler to be invoked but it was not entered"
|
4934 + | );
|
4935 + | }
|
4936 + |
|
4937 + | /// When input structure, is empty the server should accept an empty body
|
4938 + | /// even if the Accept header is set.
|
4939 + | /// Test ID: empty_input_no_body_has_accept
|
4940 + | #[::tokio::test]
|
4941 + | #[::tracing_test::traced_test]
|
4942 + | async fn empty_input_no_body_has_accept_request() {
|
4943 + | #[allow(unused_mut)]
|
4944 + | let mut http_request = ::http::Request::builder()
|
4945 + | .uri("/service/RpcV2Protocol/operation/EmptyInputOutput")
|
4946 + | .method("POST")
|
4947 + | .header("Accept", "application/cbor")
|
4948 + | .header("Content-Type", "application/cbor")
|
4949 + | .header("smithy-protocol", "rpc-v2-cbor")
|
4950 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4951 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4952 + | "".as_bytes(),
|
4953 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
4954 + | )),
|
4955 + | ))
|
4956 + | .unwrap();
|
4957 + | #[allow(unused_mut)]
|
4958 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4959 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
4960 + | let service =
|
4961 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
4962 + | .empty_input_output(move |input: crate::input::EmptyInputOutputInput| {
|
4963 + | let sender = sender.clone();
|
4964 + | async move {
|
4965 + | let result = {
|
4966 + | let expected = crate::input::EmptyInputOutputInput {};
|
4967 + | ::pretty_assertions::assert_eq!(input, expected);
|
4968 + | let output = crate::output::EmptyInputOutputOutput {};
|
4969 + | output
|
4970 + | };
|
4971 + | sender.send(()).await.expect("receiver dropped early");
|
4972 + | result
|
4973 + | }
|
4974 + | })
|
4975 + | .build_unchecked();
|
4976 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4977 + | .await
|
4978 + | .expect("unable to make an HTTP request");
|
4979 + | assert!(
|
4980 + | receiver.recv().await.is_some(),
|
4981 + | "we expected operation handler to be invoked but it was not entered"
|
4982 + | );
|
4983 + | }
|
4984 + |
|
4985 + | /// When output structure is empty we write CBOR equivalent of {}
|
4986 + | /// Test ID: empty_output
|
4987 + | #[::tokio::test]
|
4988 + | #[::tracing_test::traced_test]
|
4989 + | async fn empty_output_response() {
|
4990 + | let output = crate::output::EmptyInputOutputOutput {};
|
4991 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
4992 + | let http_response = output.into_response();
|
4993 + | ::pretty_assertions::assert_eq!(
|
4994 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
4995 + | http_response.status()
|
4996 + | );
|
4997 + | let expected_headers = [
|
4998 + | ("Content-Type", "application/cbor"),
|
4999 + | ("smithy-protocol", "rpc-v2-cbor"),
|
5000 + | ];
|
5001 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5002 + | http_response.headers(),
|
5003 + | expected_headers,
|
5004 + | ));
|
5005 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5006 + | .await
|
5007 + | .expect("unable to extract body to bytes");
|
5008 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
5009 + | &body,
|
5010 + | "v/8=",
|
5011 + | ::aws_smithy_protocol_test::MediaType::from("application/cbor"),
|
5012 + | ));
|
5013 + | }
|
5014 + | }
|
5015 + |
|
5016 + | ::pin_project_lite::pin_project! {
|
5017 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5018 + | /// [`NoInputOutputInput`](crate::input::NoInputOutputInput) using modelled bindings.
|
5019 + | pub struct NoInputOutputInputFuture {
|
5020 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::NoInputOutputInput, ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError>> + Send>>
|
5021 + | }
|
5022 + | }
|
5023 + |
|
5024 + | impl std::future::Future for NoInputOutputInputFuture {
|
5025 + | type Output = Result<
|
5026 + | crate::input::NoInputOutputInput,
|
5027 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError,
|
5028 + | >;
|
5029 + |
|
5030 + | fn poll(
|
5031 + | self: std::pin::Pin<&mut Self>,
|
5032 + | cx: &mut std::task::Context<'_>,
|
5033 + | ) -> std::task::Poll<Self::Output> {
|
5034 + | let this = self.project();
|
5035 + | this.inner.as_mut().poll(cx)
|
5036 + | }
|
5037 + | }
|
5038 + |
|
5039 + | impl<B>
|
5040 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
5041 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5042 + | B,
|
5043 + | > for crate::input::NoInputOutputInput
|
5044 + | where
|
5045 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
5046 + | B: 'static,
|
5047 + |
|
5048 + | B::Data: Send,
|
5049 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
5050 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
5051 + | {
|
5052 + | type Rejection =
|
5053 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError;
|
5054 + | type Future = NoInputOutputInputFuture;
|
5055 + |
|
5056 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5057 + | let fut = async move {
|
5058 + | crate::protocol_serde::shape_no_input_output::de_no_input_output_http_request(request)
|
5059 + | .await
|
5060 + | };
|
5061 + | use ::futures_util::future::TryFutureExt;
|
5062 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection| {
|
5063 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5064 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e)
|
5065 + | });
|
5066 + | NoInputOutputInputFuture {
|
5067 + | inner: Box::pin(fut),
|
5068 + | }
|
5069 + | }
|
5070 + | }
|
5071 + | impl
|
5072 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
5073 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor,
|
5074 + | > for crate::output::NoInputOutputOutput
|
5075 + | {
|
5076 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
5077 + | match crate::protocol_serde::shape_no_input_output::ser_no_input_output_http_response(self)
|
5078 + | {
|
5079 + | Ok(response) => response,
|
5080 + | Err(e) => {
|
5081 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5082 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::RpcV2Cbor>::into_response(::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::runtime_error::RuntimeError::from(e))
|
5083 + | }
|
5084 + | }
|
5085 + | }
|
5086 + | }
|
5087 + |
|
5088 + | #[allow(unreachable_code, unused_variables)]
|
5089 + | #[cfg(test)]
|
5090 + | mod no_input_output_test {
|
5091 + |
|
5092 + | /// Body is empty and no Content-Type header if no input
|
5093 + | /// Test ID: no_input
|
5094 + | #[::tokio::test]
|
5095 + | #[::tracing_test::traced_test]
|
5096 + | async fn no_input_request() {
|
5097 + | #[allow(unused_mut)]
|
5098 + | let mut http_request = ::http::Request::builder()
|
5099 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5100 + | .method("POST")
|
5101 + | .header("Accept", "application/cbor")
|
5102 + | .header("smithy-protocol", "rpc-v2-cbor")
|
5103 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5104 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5105 + | "".as_bytes(),
|
5106 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5107 + | )),
|
5108 + | ))
|
5109 + | .unwrap();
|
5110 + | #[allow(unused_mut)]
|
5111 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5112 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5113 + | let service =
|
5114 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5115 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5116 + | let sender = sender.clone();
|
5117 + | async move {
|
5118 + | let result = {
|
5119 + | let expected = crate::input::NoInputOutputInput {};
|
5120 + | ::pretty_assertions::assert_eq!(input, expected);
|
5121 + | let output = crate::output::NoInputOutputOutput {};
|
5122 + | output
|
5123 + | };
|
5124 + | sender.send(()).await.expect("receiver dropped early");
|
5125 + | result
|
5126 + | }
|
5127 + | })
|
5128 + | .build_unchecked();
|
5129 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5130 + | .await
|
5131 + | .expect("unable to make an HTTP request");
|
5132 + | assert!(
|
5133 + | receiver.recv().await.is_some(),
|
5134 + | "we expected operation handler to be invoked but it was not entered"
|
5135 + | );
|
5136 + | }
|
5137 + |
|
5138 + | /// Servers should accept CBOR empty struct if no input.
|
5139 + | /// Test ID: NoInputServerAllowsEmptyCbor
|
5140 + | #[::tokio::test]
|
5141 + | #[::tracing_test::traced_test]
|
5142 + | async fn no_input_server_allows_empty_cbor_request() {
|
5143 + | #[allow(unused_mut)]
|
5144 + | let mut http_request = ::http::Request::builder()
|
5145 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5146 + | .method("POST")
|
5147 + | .header("Accept", "application/cbor")
|
5148 + | .header("Content-Type", "application/cbor")
|
5149 + | .header("smithy-protocol", "rpc-v2-cbor")
|
5150 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5151 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5152 + | "v/8=".as_bytes(),
|
5153 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5154 + | )),
|
5155 + | ))
|
5156 + | .unwrap();
|
5157 + | #[allow(unused_mut)]
|
5158 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5159 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5160 + | let service =
|
5161 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5162 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5163 + | let sender = sender.clone();
|
5164 + | async move {
|
5165 + | let result = {
|
5166 + | let expected = crate::input::NoInputOutputInput {};
|
5167 + | ::pretty_assertions::assert_eq!(input, expected);
|
5168 + | let output = crate::output::NoInputOutputOutput {};
|
5169 + | output
|
5170 + | };
|
5171 + | sender.send(()).await.expect("receiver dropped early");
|
5172 + | result
|
5173 + | }
|
5174 + | })
|
5175 + | .build_unchecked();
|
5176 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5177 + | .await
|
5178 + | .expect("unable to make an HTTP request");
|
5179 + | assert!(
|
5180 + | receiver.recv().await.is_some(),
|
5181 + | "we expected operation handler to be invoked but it was not entered"
|
5182 + | );
|
5183 + | }
|
5184 + |
|
5185 + | /// Servers should accept an empty body if there is no input. Additionally,
|
5186 + | /// they should not raise an error if the `Accept` header is set.
|
5187 + | /// Test ID: NoInputServerAllowsEmptyBody
|
5188 + | #[::tokio::test]
|
5189 + | #[::tracing_test::traced_test]
|
5190 + | async fn no_input_server_allows_empty_body_request() {
|
5191 + | #[allow(unused_mut)]
|
5192 + | let mut http_request = ::http::Request::builder()
|
5193 + | .uri("/service/RpcV2Protocol/operation/NoInputOutput")
|
5194 + | .method("POST")
|
5195 + | .header("Accept", "application/cbor")
|
5196 + | .header("Content-Type", "application/cbor")
|
5197 + | .header("smithy-protocol", "rpc-v2-cbor")
|
5198 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5199 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5200 + | "".as_bytes(),
|
5201 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5202 + | )),
|
5203 + | ))
|
5204 + | .unwrap();
|
5205 + | #[allow(unused_mut)]
|
5206 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5207 + | let config = crate::service::RpcV2ProtocolConfig::builder().build();
|
5208 + | let service =
|
5209 + | crate::service::RpcV2Protocol::builder::<::hyper::body::Body, _, _, _>(config)
|
5210 + | .no_input_output(move |input: crate::input::NoInputOutputInput| {
|
5211 + | let sender = sender.clone();
|
5212 + | async move {
|
5213 + | let result = {
|
5214 + | let expected = crate::input::NoInputOutputInput {};
|
5215 + | ::pretty_assertions::assert_eq!(input, expected);
|
5216 + | let output = crate::output::NoInputOutputOutput {};
|
5217 + | output
|
5218 + | };
|
5219 + | sender.send(()).await.expect("receiver dropped early");
|
5220 + | result
|
5221 + | }
|
5222 + | })
|
5223 + | .build_unchecked();
|
5224 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5225 + | .await
|
5226 + | .expect("unable to make an HTTP request");
|
5227 + | assert!(
|
5228 + | receiver.recv().await.is_some(),
|
5229 + | "we expected operation handler to be invoked but it was not entered"
|
5230 + | );
|
5231 + | }
|
5232 + |
|
5233 + | /// A `Content-Type` header should not be set if the response body is empty.
|
5234 + | /// Test ID: no_output
|
5235 + | #[::tokio::test]
|
5236 + | #[::tracing_test::traced_test]
|
5237 + | async fn no_output_response() {
|
5238 + | let output = crate::output::NoInputOutputOutput {};
|
5239 + | use ::aws_smithy_legacy_http_server::response::IntoResponse;
|
5240 + | let http_response = output.into_response();
|
5241 + | ::pretty_assertions::assert_eq!(
|
5242 + | ::http::StatusCode::from_u16(200).expect("invalid expected HTTP status code"),
|
5243 + | http_response.status()
|
5244 + | );
|
5245 + | let expected_headers = [("smithy-protocol", "rpc-v2-cbor")];
|
5246 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5247 + | http_response.headers(),
|
5248 + | expected_headers,
|
5249 + | ));
|
5250 + | let forbidden_headers = &["Content-Type"];
|
5251 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::forbid_headers(
|
5252 + | http_response.headers(),
|
5253 + | forbidden_headers,
|
5254 + | ));
|
5255 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5256 + | .await
|
5257 + | .expect("unable to extract body to bytes");
|
5258 + | // No body.
|
5259 + | ::pretty_assertions::assert_eq!(&body, &bytes::Bytes::new());
|
5260 + | }
|
5261 + | }
|