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 + | /// [`SensitiveValidationInput`](crate::input::SensitiveValidationInput) using modelled bindings.
|
5 + | pub struct SensitiveValidationInputFuture {
|
6 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SensitiveValidationInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7 + | }
|
8 + | }
|
9 + |
|
10 + | impl std::future::Future for SensitiveValidationInputFuture {
|
11 + | type Output = Result<
|
12 + | crate::input::SensitiveValidationInput,
|
13 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::RestJson1,
|
28 + | B,
|
29 + | > for crate::input::SensitiveValidationInput
|
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::rest_json_1::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::rest_json_1::runtime_error::RuntimeError;
|
40 + | type Future = SensitiveValidationInputFuture;
|
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_JSON,
|
47 + | ) {
|
48 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
49 + | }
|
50 + | crate::protocol_serde::shape_sensitive_validation::de_sensitive_validation_http_request(
|
51 + | request,
|
52 + | )
|
53 + | .await
|
54 + | };
|
55 + | use ::futures_util::future::TryFutureExt;
|
56 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
57 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
58 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
59 + | });
|
60 + | SensitiveValidationInputFuture {
|
61 + | inner: Box::pin(fut),
|
62 + | }
|
63 + | }
|
64 + | }
|
65 + | impl
|
66 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
67 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
68 + | > for crate::output::SensitiveValidationOutput
|
69 + | {
|
70 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
71 + | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_response(self) {
|
72 + | Ok(response) => response,
|
73 + | Err(e) => {
|
74 + | ::tracing::error!(error = %e, "failed to serialize response");
|
75 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
76 + | }
|
77 + | }
|
78 + | }
|
79 + | }
|
80 + | impl
|
81 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
82 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
83 + | > for crate::error::SensitiveValidationError
|
84 + | {
|
85 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
86 + | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_error(
|
87 + | &self,
|
88 + | ) {
|
89 + | Ok(mut response) => {
|
90 + | response.extensions_mut().insert(
|
91 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
92 + | self.name(),
|
93 + | ),
|
94 + | );
|
95 + | response
|
96 + | }
|
97 + | Err(e) => {
|
98 + | ::tracing::error!(error = %e, "failed to serialize response");
|
99 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
100 + | }
|
101 + | }
|
102 + | }
|
103 + | }
|
104 + |
|
105 + | #[allow(unreachable_code, unused_variables)]
|
106 + | #[cfg(test)]
|
107 + | mod sensitive_validation_test {
|
108 + |
|
109 + | /// When a sensitive member fails validation, the resultant
|
110 + | /// ValidationException will omit the value of the input.
|
111 + | /// Test ID: RestJsonMalformedPatternSensitiveString
|
112 + | #[::tokio::test]
|
113 + | #[::tracing_test::traced_test]
|
114 + | async fn rest_json_malformed_pattern_sensitive_string_malformed_request() {
|
115 + | {
|
116 + | #[allow(unused_mut)]
|
117 + | let mut http_request = ::http::Request::builder()
|
118 + | .uri("/SensitiveValidation")
|
119 + | .method("POST")
|
120 + | .header("content-type", "application/json")
|
121 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
122 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
123 + | "{ \"string\" : \"ABC\" }".as_bytes(),
|
124 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
125 + | )),
|
126 + | ))
|
127 + | .unwrap();
|
128 + | #[allow(unused_mut)]
|
129 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
130 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
131 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
132 + | .sensitive_validation(move |input: crate::input::SensitiveValidationInput| {
|
133 + | let sender = sender.clone();
|
134 + | async move {
|
135 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::SensitiveValidationOutput, crate::error::SensitiveValidationError> };
|
136 + | sender.send(()).await.expect("receiver dropped early");
|
137 + | result
|
138 + | }
|
139 + | })
|
140 + | .build_unchecked();
|
141 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
142 + | .await
|
143 + | .expect("unable to make an HTTP request");
|
144 + | ::pretty_assertions::assert_eq!(
|
145 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
146 + | http_response.status()
|
147 + | );
|
148 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
149 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
150 + | http_response.headers(),
|
151 + | expected_headers,
|
152 + | ));
|
153 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
154 + | .await
|
155 + | .expect("unable to extract body to bytes");
|
156 + | ::aws_smithy_protocol_test::assert_ok(
|
157 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
158 + | );
|
159 + | }
|
160 + | }
|
161 + | }
|
162 + |
|
163 + | ::pin_project_lite::pin_project! {
|
164 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
165 + | /// [`RecursiveStructuresInput`](crate::input::RecursiveStructuresInput) using modelled bindings.
|
166 + | pub struct RecursiveStructuresInputFuture {
|
167 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveStructuresInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
168 + | }
|
169 + | }
|
170 + |
|
171 + | impl std::future::Future for RecursiveStructuresInputFuture {
|
172 + | type Output = Result<
|
173 + | crate::input::RecursiveStructuresInput,
|
174 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
175 + | >;
|
176 + |
|
177 + | fn poll(
|
178 + | self: std::pin::Pin<&mut Self>,
|
179 + | cx: &mut std::task::Context<'_>,
|
180 + | ) -> std::task::Poll<Self::Output> {
|
181 + | let this = self.project();
|
182 + | this.inner.as_mut().poll(cx)
|
183 + | }
|
184 + | }
|
185 + |
|
186 + | impl<B>
|
187 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
188 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
189 + | B,
|
190 + | > for crate::input::RecursiveStructuresInput
|
191 + | where
|
192 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
193 + | B: 'static,
|
194 + |
|
195 + | B::Data: Send,
|
196 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
197 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
198 + | {
|
199 + | type Rejection =
|
200 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
201 + | type Future = RecursiveStructuresInputFuture;
|
202 + |
|
203 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
204 + | let fut = async move {
|
205 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
206 + | request.headers(),
|
207 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
208 + | ) {
|
209 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
210 + | }
|
211 + | crate::protocol_serde::shape_recursive_structures::de_recursive_structures_http_request(
|
212 + | request,
|
213 + | )
|
214 + | .await
|
215 + | };
|
216 + | use ::futures_util::future::TryFutureExt;
|
217 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
218 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
219 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
220 + | });
|
221 + | RecursiveStructuresInputFuture {
|
222 + | inner: Box::pin(fut),
|
223 + | }
|
224 + | }
|
225 + | }
|
226 + | impl
|
227 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
228 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
229 + | > for crate::output::RecursiveStructuresOutput
|
230 + | {
|
231 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
232 + | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_response(self) {
|
233 + | Ok(response) => response,
|
234 + | Err(e) => {
|
235 + | ::tracing::error!(error = %e, "failed to serialize response");
|
236 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
237 + | }
|
238 + | }
|
239 + | }
|
240 + | }
|
241 + | impl
|
242 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
243 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
244 + | > for crate::error::RecursiveStructuresError
|
245 + | {
|
246 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
247 + | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_error(
|
248 + | &self,
|
249 + | ) {
|
250 + | Ok(mut response) => {
|
251 + | response.extensions_mut().insert(
|
252 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
253 + | self.name(),
|
254 + | ),
|
255 + | );
|
256 + | response
|
257 + | }
|
258 + | Err(e) => {
|
259 + | ::tracing::error!(error = %e, "failed to serialize response");
|
260 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
261 + | }
|
262 + | }
|
263 + | }
|
264 + | }
|
265 + |
|
266 + | #[allow(unreachable_code, unused_variables)]
|
267 + | #[cfg(test)]
|
268 + | mod recursive_structures_test {
|
269 + |
|
270 + | /// Validation should work with recursive structures.
|
271 + | /// Test ID: RestJsonRecursiveStructuresValidate
|
272 + | #[::tokio::test]
|
273 + | #[::tracing_test::traced_test]
|
274 + | async fn rest_json_recursive_structures_validate_request() {
|
275 + | #[allow(unused_mut)]
|
276 + | let mut http_request = ::http::Request::builder()
|
277 + | .uri("/RecursiveStructures")
|
278 + | .method("POST")
|
279 + | .header("content-type", "application/json")
|
280 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
281 + | ::bytes::Bytes::copy_from_slice(
|
282 + | &::aws_smithy_protocol_test::decode_body_data("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"abc\" }\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
283 + | )
|
284 + | )).unwrap();
|
285 + | #[allow(unused_mut)]
|
286 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
287 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
288 + | let service =
|
289 + | crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
290 + | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
291 + | let sender = sender.clone();
|
292 + | async move {
|
293 + | let result = {
|
294 + | let expected = crate::input::RecursiveStructuresInput {
|
295 + | union: ::std::option::Option::Some(
|
296 + | crate::model::RecursiveUnionOne::Union(::std::boxed::Box::new(
|
297 + | crate::model::RecursiveUnionTwo::Union(
|
298 + | crate::model::RecursiveUnionOne::String(
|
299 + | "abc"
|
300 + | .parse::<crate::model::RecursiveEnumString>()
|
301 + | .expect("static value validated to member"),
|
302 + | ),
|
303 + | ),
|
304 + | )),
|
305 + | ),
|
306 + | };
|
307 + | ::pretty_assertions::assert_eq!(input, expected);
|
308 + | let output = crate::output::RecursiveStructuresOutput {};
|
309 + | Ok(output)
|
310 + | };
|
311 + | sender.send(()).await.expect("receiver dropped early");
|
312 + | result
|
313 + | }
|
314 + | })
|
315 + | .build_unchecked();
|
316 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
317 + | .await
|
318 + | .expect("unable to make an HTTP request");
|
319 + | assert!(
|
320 + | receiver.recv().await.is_some(),
|
321 + | "we expected operation handler to be invoked but it was not entered"
|
322 + | );
|
323 + | }
|
324 + |
|
325 + | /// When a value deeply nested in a recursive structure does not meet constraints,
|
326 + | /// a 400 ValidationException is returned.
|
327 + | /// Test ID: RestJsonMalformedRecursiveStructures
|
328 + | #[::tokio::test]
|
329 + | #[::tracing_test::traced_test]
|
330 + | async fn rest_json_malformed_recursive_structures_malformed_request() {
|
331 + | {
|
332 + | #[allow(unused_mut)]
|
333 + | let mut http_request = ::http::Request::builder()
|
334 + | .uri("/RecursiveStructures")
|
335 + | .method("POST")
|
336 + | .header("content-type", "application/json")
|
337 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
338 + | ::bytes::Bytes::copy_from_slice(
|
339 + | &::aws_smithy_protocol_test::decode_body_data("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"XYZ\" }\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
340 + | )
|
341 + | )).unwrap();
|
342 + | #[allow(unused_mut)]
|
343 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
344 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
345 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
346 + | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
347 + | let sender = sender.clone();
|
348 + | async move {
|
349 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::RecursiveStructuresOutput, crate::error::RecursiveStructuresError> };
|
350 + | sender.send(()).await.expect("receiver dropped early");
|
351 + | result
|
352 + | }
|
353 + | })
|
354 + | .build_unchecked();
|
355 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
356 + | .await
|
357 + | .expect("unable to make an HTTP request");
|
358 + | ::pretty_assertions::assert_eq!(
|
359 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
360 + | http_response.status()
|
361 + | );
|
362 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
363 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
364 + | http_response.headers(),
|
365 + | expected_headers,
|
366 + | ));
|
367 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
368 + | .await
|
369 + | .expect("unable to extract body to bytes");
|
370 + | ::aws_smithy_protocol_test::assert_ok(
|
371 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/union/union/union/string' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]\",\n \"fieldList\" : [{\"message\": \"Value at '/union/union/union/string' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]\", \"path\": \"/union/union/union/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
372 + | );
|
373 + | }
|
374 + | }
|
375 + | }
|
376 + |
|
377 + | ::pin_project_lite::pin_project! {
|
378 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
379 + | /// [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) using modelled bindings.
|
380 + | pub struct MalformedUniqueItemsInputFuture {
|
381 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedUniqueItemsInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
382 + | }
|
383 + | }
|
384 + |
|
385 + | impl std::future::Future for MalformedUniqueItemsInputFuture {
|
386 + | type Output = Result<
|
387 + | crate::input::MalformedUniqueItemsInput,
|
388 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
389 + | >;
|
390 + |
|
391 + | fn poll(
|
392 + | self: std::pin::Pin<&mut Self>,
|
393 + | cx: &mut std::task::Context<'_>,
|
394 + | ) -> std::task::Poll<Self::Output> {
|
395 + | let this = self.project();
|
396 + | this.inner.as_mut().poll(cx)
|
397 + | }
|
398 + | }
|
399 + |
|
400 + | impl<B>
|
401 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
402 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
403 + | B,
|
404 + | > for crate::input::MalformedUniqueItemsInput
|
405 + | where
|
406 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
407 + | B: 'static,
|
408 + |
|
409 + | B::Data: Send,
|
410 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
411 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
412 + | {
|
413 + | type Rejection =
|
414 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
415 + | type Future = MalformedUniqueItemsInputFuture;
|
416 + |
|
417 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
418 + | let fut = async move {
|
419 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
420 + | request.headers(),
|
421 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
422 + | ) {
|
423 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
424 + | }
|
425 + | crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items_http_request(request)
|
426 + | .await
|
427 + | };
|
428 + | use ::futures_util::future::TryFutureExt;
|
429 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
430 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
431 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
432 + | });
|
433 + | MalformedUniqueItemsInputFuture {
|
434 + | inner: Box::pin(fut),
|
435 + | }
|
436 + | }
|
437 + | }
|
438 + | impl
|
439 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
440 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
441 + | > for crate::output::MalformedUniqueItemsOutput
|
442 + | {
|
443 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
444 + | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_response(self) {
|
445 + | Ok(response) => response,
|
446 + | Err(e) => {
|
447 + | ::tracing::error!(error = %e, "failed to serialize response");
|
448 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
449 + | }
|
450 + | }
|
451 + | }
|
452 + | }
|
453 + | impl
|
454 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
455 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
456 + | > for crate::error::MalformedUniqueItemsError
|
457 + | {
|
458 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
459 + | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_error(&self) {
|
460 + | Ok(mut response) => {
|
461 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
462 + | response
|
463 + | },
|
464 + | Err(e) => {
|
465 + | ::tracing::error!(error = %e, "failed to serialize response");
|
466 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
467 + | }
|
468 + | }
|
469 + | }
|
470 + | }
|
471 + |
|
472 + | #[allow(unreachable_code, unused_variables)]
|
473 + | #[cfg(test)]
|
474 + | mod malformed_unique_items_test {
|
475 + |
|
476 + | /// When a blob list contains non-unique values,
|
477 + | /// the response should be a 400 ValidationException.
|
478 + | /// Test ID: RestJsonMalformedUniqueItemsBlobList
|
479 + | #[::tokio::test]
|
480 + | #[::tracing_test::traced_test]
|
481 + | #[should_panic]
|
482 + | async fn rest_json_malformed_unique_items_blob_list_malformed_request() {
|
483 + | {
|
484 + | #[allow(unused_mut)]
|
485 + | let mut http_request = ::http::Request::builder()
|
486 + | .uri("/MalformedUniqueItems")
|
487 + | .method("POST")
|
488 + | .header("content-type", "application/json")
|
489 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
490 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
491 + | "{ \"blobList\" : [\"YQ==\", \"YQ==\"] }".as_bytes(),
|
492 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
493 + | )),
|
494 + | ))
|
495 + | .unwrap();
|
496 + | #[allow(unused_mut)]
|
497 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
498 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
499 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
500 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
501 + | let sender = sender.clone();
|
502 + | async move {
|
503 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
504 + | sender.send(()).await.expect("receiver dropped early");
|
505 + | result
|
506 + | }
|
507 + | })
|
508 + | .build_unchecked();
|
509 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
510 + | .await
|
511 + | .expect("unable to make an HTTP request");
|
512 + | ::pretty_assertions::assert_eq!(
|
513 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
514 + | http_response.status()
|
515 + | );
|
516 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
517 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
518 + | http_response.headers(),
|
519 + | expected_headers,
|
520 + | ));
|
521 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
522 + | .await
|
523 + | .expect("unable to extract body to bytes");
|
524 + | ::aws_smithy_protocol_test::assert_ok(
|
525 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/blobList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/blobList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/blobList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
526 + | );
|
527 + | }
|
528 + | }
|
529 + |
|
530 + | /// When a boolean list contains non-unique values,
|
531 + | /// the response should be a 400 ValidationException.
|
532 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case0
|
533 + | #[::tokio::test]
|
534 + | #[::tracing_test::traced_test]
|
535 + | #[should_panic]
|
536 + | async fn rest_json_malformed_unique_items_boolean_list_case0_malformed_request() {
|
537 + | {
|
538 + | #[allow(unused_mut)]
|
539 + | let mut http_request = ::http::Request::builder()
|
540 + | .uri("/MalformedUniqueItems")
|
541 + | .method("POST")
|
542 + | .header("content-type", "application/json")
|
543 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
544 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
545 + | "{ \"booleanList\" : [true, true] }".as_bytes(),
|
546 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
547 + | )),
|
548 + | ))
|
549 + | .unwrap();
|
550 + | #[allow(unused_mut)]
|
551 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
552 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
553 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
554 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
555 + | let sender = sender.clone();
|
556 + | async move {
|
557 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
558 + | sender.send(()).await.expect("receiver dropped early");
|
559 + | result
|
560 + | }
|
561 + | })
|
562 + | .build_unchecked();
|
563 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
564 + | .await
|
565 + | .expect("unable to make an HTTP request");
|
566 + | ::pretty_assertions::assert_eq!(
|
567 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
568 + | http_response.status()
|
569 + | );
|
570 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
571 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
572 + | http_response.headers(),
|
573 + | expected_headers,
|
574 + | ));
|
575 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
576 + | .await
|
577 + | .expect("unable to extract body to bytes");
|
578 + | ::aws_smithy_protocol_test::assert_ok(
|
579 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/booleanList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/booleanList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/booleanList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
580 + | );
|
581 + | }
|
582 + | }
|
583 + |
|
584 + | /// When a boolean list contains non-unique values,
|
585 + | /// the response should be a 400 ValidationException.
|
586 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case1
|
587 + | #[::tokio::test]
|
588 + | #[::tracing_test::traced_test]
|
589 + | #[should_panic]
|
590 + | async fn rest_json_malformed_unique_items_boolean_list_case1_malformed_request() {
|
591 + | {
|
592 + | #[allow(unused_mut)]
|
593 + | let mut http_request = ::http::Request::builder()
|
594 + | .uri("/MalformedUniqueItems")
|
595 + | .method("POST")
|
596 + | .header("content-type", "application/json")
|
597 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
598 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
599 + | "{ \"booleanList\" : [false, false] }".as_bytes(),
|
600 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
601 + | )),
|
602 + | ))
|
603 + | .unwrap();
|
604 + | #[allow(unused_mut)]
|
605 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
606 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
607 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
608 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
609 + | let sender = sender.clone();
|
610 + | async move {
|
611 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
612 + | sender.send(()).await.expect("receiver dropped early");
|
613 + | result
|
614 + | }
|
615 + | })
|
616 + | .build_unchecked();
|
617 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
618 + | .await
|
619 + | .expect("unable to make an HTTP request");
|
620 + | ::pretty_assertions::assert_eq!(
|
621 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
622 + | http_response.status()
|
623 + | );
|
624 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
625 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
626 + | http_response.headers(),
|
627 + | expected_headers,
|
628 + | ));
|
629 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
630 + | .await
|
631 + | .expect("unable to extract body to bytes");
|
632 + | ::aws_smithy_protocol_test::assert_ok(
|
633 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/booleanList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/booleanList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/booleanList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
634 + | );
|
635 + | }
|
636 + | }
|
637 + |
|
638 + | /// When a string list contains non-unique values,
|
639 + | /// the response should be a 400 ValidationException.
|
640 + | /// Test ID: RestJsonMalformedUniqueItemsStringList
|
641 + | #[::tokio::test]
|
642 + | #[::tracing_test::traced_test]
|
643 + | #[should_panic]
|
644 + | async fn rest_json_malformed_unique_items_string_list_malformed_request() {
|
645 + | {
|
646 + | #[allow(unused_mut)]
|
647 + | let mut http_request = ::http::Request::builder()
|
648 + | .uri("/MalformedUniqueItems")
|
649 + | .method("POST")
|
650 + | .header("content-type", "application/json")
|
651 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
652 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
653 + | "{ \"stringList\" : [\"abc\", \"abc\"] }".as_bytes(),
|
654 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
655 + | )),
|
656 + | ))
|
657 + | .unwrap();
|
658 + | #[allow(unused_mut)]
|
659 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
660 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
661 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
662 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
663 + | let sender = sender.clone();
|
664 + | async move {
|
665 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
666 + | sender.send(()).await.expect("receiver dropped early");
|
667 + | result
|
668 + | }
|
669 + | })
|
670 + | .build_unchecked();
|
671 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
672 + | .await
|
673 + | .expect("unable to make an HTTP request");
|
674 + | ::pretty_assertions::assert_eq!(
|
675 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
676 + | http_response.status()
|
677 + | );
|
678 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
679 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
680 + | http_response.headers(),
|
681 + | expected_headers,
|
682 + | ));
|
683 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
684 + | .await
|
685 + | .expect("unable to extract body to bytes");
|
686 + | ::aws_smithy_protocol_test::assert_ok(
|
687 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/stringList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/stringList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/stringList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
688 + | );
|
689 + | }
|
690 + | }
|
691 + |
|
692 + | /// When a byte list contains non-unique values,
|
693 + | /// the response should be a 400 ValidationException.
|
694 + | /// Test ID: RestJsonMalformedUniqueItemsByteList
|
695 + | #[::tokio::test]
|
696 + | #[::tracing_test::traced_test]
|
697 + | #[should_panic]
|
698 + | async fn rest_json_malformed_unique_items_byte_list_malformed_request() {
|
699 + | {
|
700 + | #[allow(unused_mut)]
|
701 + | let mut http_request = ::http::Request::builder()
|
702 + | .uri("/MalformedUniqueItems")
|
703 + | .method("POST")
|
704 + | .header("content-type", "application/json")
|
705 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
706 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
707 + | "{ \"byteList\" : [1, 1] }".as_bytes(),
|
708 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
709 + | )),
|
710 + | ))
|
711 + | .unwrap();
|
712 + | #[allow(unused_mut)]
|
713 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
714 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
715 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
716 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
717 + | let sender = sender.clone();
|
718 + | async move {
|
719 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
720 + | sender.send(()).await.expect("receiver dropped early");
|
721 + | result
|
722 + | }
|
723 + | })
|
724 + | .build_unchecked();
|
725 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
726 + | .await
|
727 + | .expect("unable to make an HTTP request");
|
728 + | ::pretty_assertions::assert_eq!(
|
729 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
730 + | http_response.status()
|
731 + | );
|
732 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
733 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
734 + | http_response.headers(),
|
735 + | expected_headers,
|
736 + | ));
|
737 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
738 + | .await
|
739 + | .expect("unable to extract body to bytes");
|
740 + | ::aws_smithy_protocol_test::assert_ok(
|
741 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/byteList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/byteList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/byteList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
742 + | );
|
743 + | }
|
744 + | }
|
745 + |
|
746 + | /// When a short list contains non-unique values,
|
747 + | /// the response should be a 400 ValidationException.
|
748 + | /// Test ID: RestJsonMalformedUniqueItemsShortList
|
749 + | #[::tokio::test]
|
750 + | #[::tracing_test::traced_test]
|
751 + | #[should_panic]
|
752 + | async fn rest_json_malformed_unique_items_short_list_malformed_request() {
|
753 + | {
|
754 + | #[allow(unused_mut)]
|
755 + | let mut http_request = ::http::Request::builder()
|
756 + | .uri("/MalformedUniqueItems")
|
757 + | .method("POST")
|
758 + | .header("content-type", "application/json")
|
759 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
760 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
761 + | "{ \"shortList\" : [2, 2] }".as_bytes(),
|
762 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
763 + | )),
|
764 + | ))
|
765 + | .unwrap();
|
766 + | #[allow(unused_mut)]
|
767 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
768 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
769 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
770 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
771 + | let sender = sender.clone();
|
772 + | async move {
|
773 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
774 + | sender.send(()).await.expect("receiver dropped early");
|
775 + | result
|
776 + | }
|
777 + | })
|
778 + | .build_unchecked();
|
779 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
780 + | .await
|
781 + | .expect("unable to make an HTTP request");
|
782 + | ::pretty_assertions::assert_eq!(
|
783 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
784 + | http_response.status()
|
785 + | );
|
786 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
787 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
788 + | http_response.headers(),
|
789 + | expected_headers,
|
790 + | ));
|
791 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
792 + | .await
|
793 + | .expect("unable to extract body to bytes");
|
794 + | ::aws_smithy_protocol_test::assert_ok(
|
795 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/shortList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/shortList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/shortList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
796 + | );
|
797 + | }
|
798 + | }
|
799 + |
|
800 + | /// When an integer list contains non-unique values,
|
801 + | /// the response should be a 400 ValidationException.
|
802 + | /// Test ID: RestJsonMalformedUniqueItemsIntegerList
|
803 + | #[::tokio::test]
|
804 + | #[::tracing_test::traced_test]
|
805 + | #[should_panic]
|
806 + | async fn rest_json_malformed_unique_items_integer_list_malformed_request() {
|
807 + | {
|
808 + | #[allow(unused_mut)]
|
809 + | let mut http_request = ::http::Request::builder()
|
810 + | .uri("/MalformedUniqueItems")
|
811 + | .method("POST")
|
812 + | .header("content-type", "application/json")
|
813 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
814 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
815 + | "{ \"integerList\" : [3, 3] }".as_bytes(),
|
816 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
817 + | )),
|
818 + | ))
|
819 + | .unwrap();
|
820 + | #[allow(unused_mut)]
|
821 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
822 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
823 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
824 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
825 + | let sender = sender.clone();
|
826 + | async move {
|
827 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
828 + | sender.send(()).await.expect("receiver dropped early");
|
829 + | result
|
830 + | }
|
831 + | })
|
832 + | .build_unchecked();
|
833 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
834 + | .await
|
835 + | .expect("unable to make an HTTP request");
|
836 + | ::pretty_assertions::assert_eq!(
|
837 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
838 + | http_response.status()
|
839 + | );
|
840 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
841 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
842 + | http_response.headers(),
|
843 + | expected_headers,
|
844 + | ));
|
845 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
846 + | .await
|
847 + | .expect("unable to extract body to bytes");
|
848 + | ::aws_smithy_protocol_test::assert_ok(
|
849 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/integerList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/integerList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/integerList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
850 + | );
|
851 + | }
|
852 + | }
|
853 + |
|
854 + | /// When an integer list contains non-unique values,
|
855 + | /// the response should be a 400 ValidationException.
|
856 + | /// Test ID: RestJsonMalformedUniqueItemsLongList
|
857 + | #[::tokio::test]
|
858 + | #[::tracing_test::traced_test]
|
859 + | #[should_panic]
|
860 + | async fn rest_json_malformed_unique_items_long_list_malformed_request() {
|
861 + | {
|
862 + | #[allow(unused_mut)]
|
863 + | let mut http_request = ::http::Request::builder()
|
864 + | .uri("/MalformedUniqueItems")
|
865 + | .method("POST")
|
866 + | .header("content-type", "application/json")
|
867 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
868 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
869 + | "{ \"longList\" : [4, 4] }".as_bytes(),
|
870 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
871 + | )),
|
872 + | ))
|
873 + | .unwrap();
|
874 + | #[allow(unused_mut)]
|
875 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
876 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
877 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
878 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
879 + | let sender = sender.clone();
|
880 + | async move {
|
881 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
882 + | sender.send(()).await.expect("receiver dropped early");
|
883 + | result
|
884 + | }
|
885 + | })
|
886 + | .build_unchecked();
|
887 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
888 + | .await
|
889 + | .expect("unable to make an HTTP request");
|
890 + | ::pretty_assertions::assert_eq!(
|
891 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
892 + | http_response.status()
|
893 + | );
|
894 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
895 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
896 + | http_response.headers(),
|
897 + | expected_headers,
|
898 + | ));
|
899 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
900 + | .await
|
901 + | .expect("unable to extract body to bytes");
|
902 + | ::aws_smithy_protocol_test::assert_ok(
|
903 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/longList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/longList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/longList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
904 + | );
|
905 + | }
|
906 + | }
|
907 + |
|
908 + | /// When a timestamp list contains non-unique values,
|
909 + | /// the response should be a 400 ValidationException.
|
910 + | /// Test ID: RestJsonMalformedUniqueItemsTimestampList
|
911 + | #[::tokio::test]
|
912 + | #[::tracing_test::traced_test]
|
913 + | #[should_panic]
|
914 + | async fn rest_json_malformed_unique_items_timestamp_list_malformed_request() {
|
915 + | {
|
916 + | #[allow(unused_mut)]
|
917 + | let mut http_request = ::http::Request::builder()
|
918 + | .uri("/MalformedUniqueItems")
|
919 + | .method("POST")
|
920 + | .header("content-type", "application/json")
|
921 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
922 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
923 + | "{ \"timestampList\" : [1676660607, 1676660607] }".as_bytes(),
|
924 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
925 + | )),
|
926 + | ))
|
927 + | .unwrap();
|
928 + | #[allow(unused_mut)]
|
929 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
930 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
931 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
932 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
933 + | let sender = sender.clone();
|
934 + | async move {
|
935 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
936 + | sender.send(()).await.expect("receiver dropped early");
|
937 + | result
|
938 + | }
|
939 + | })
|
940 + | .build_unchecked();
|
941 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
942 + | .await
|
943 + | .expect("unable to make an HTTP request");
|
944 + | ::pretty_assertions::assert_eq!(
|
945 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
946 + | http_response.status()
|
947 + | );
|
948 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
949 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
950 + | http_response.headers(),
|
951 + | expected_headers,
|
952 + | ));
|
953 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
954 + | .await
|
955 + | .expect("unable to extract body to bytes");
|
956 + | ::aws_smithy_protocol_test::assert_ok(
|
957 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/timestampList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/timestampList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/timestampList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
958 + | );
|
959 + | }
|
960 + | }
|
961 + |
|
962 + | /// When a date-time timestamp list contains non-unique values,
|
963 + | /// the response should be a 400 ValidationException.
|
964 + | /// Test ID: RestJsonMalformedUniqueItemsDateTimeList
|
965 + | #[::tokio::test]
|
966 + | #[::tracing_test::traced_test]
|
967 + | #[should_panic]
|
968 + | async fn rest_json_malformed_unique_items_date_time_list_malformed_request() {
|
969 + | {
|
970 + | #[allow(unused_mut)]
|
971 + | let mut http_request = ::http::Request::builder()
|
972 + | .uri("/MalformedUniqueItems")
|
973 + | .method("POST")
|
974 + | .header("content-type", "application/json")
|
975 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
976 + | ::bytes::Bytes::copy_from_slice(
|
977 + | &::aws_smithy_protocol_test::decode_body_data("{ \"dateTimeList\" : [\"1985-04-12T23:20:50.52Z\", \"1985-04-12T23:20:50.52Z\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
978 + | )
|
979 + | )).unwrap();
|
980 + | #[allow(unused_mut)]
|
981 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
982 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
983 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
984 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
985 + | let sender = sender.clone();
|
986 + | async move {
|
987 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
988 + | sender.send(()).await.expect("receiver dropped early");
|
989 + | result
|
990 + | }
|
991 + | })
|
992 + | .build_unchecked();
|
993 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
994 + | .await
|
995 + | .expect("unable to make an HTTP request");
|
996 + | ::pretty_assertions::assert_eq!(
|
997 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
998 + | http_response.status()
|
999 + | );
|
1000 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1001 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1002 + | http_response.headers(),
|
1003 + | expected_headers,
|
1004 + | ));
|
1005 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1006 + | .await
|
1007 + | .expect("unable to extract body to bytes");
|
1008 + | ::aws_smithy_protocol_test::assert_ok(
|
1009 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/dateTimeList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/dateTimeList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/dateTimeList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1010 + | );
|
1011 + | }
|
1012 + | }
|
1013 + |
|
1014 + | /// When a http-date timestamp list contains non-unique values,
|
1015 + | /// the response should be a 400 ValidationException.
|
1016 + | /// Test ID: RestJsonMalformedUniqueItemsHttpDateList_case0
|
1017 + | #[::tokio::test]
|
1018 + | #[::tracing_test::traced_test]
|
1019 + | #[should_panic]
|
1020 + | async fn rest_json_malformed_unique_items_http_date_list_case0_malformed_request() {
|
1021 + | {
|
1022 + | #[allow(unused_mut)]
|
1023 + | let mut http_request = ::http::Request::builder()
|
1024 + | .uri("/MalformedUniqueItems")
|
1025 + | .method("POST")
|
1026 + | .header("content-type", "application/json")
|
1027 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1028 + | ::bytes::Bytes::copy_from_slice(
|
1029 + | &::aws_smithy_protocol_test::decode_body_data("{ \"httpDateList\" : [\"Tue, 29 Apr 2014 18:30:38 GMT\", \"Tue, 29 Apr 2014 18:30:38 GMT\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1030 + | )
|
1031 + | )).unwrap();
|
1032 + | #[allow(unused_mut)]
|
1033 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1034 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1035 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1036 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1037 + | let sender = sender.clone();
|
1038 + | async move {
|
1039 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1040 + | sender.send(()).await.expect("receiver dropped early");
|
1041 + | result
|
1042 + | }
|
1043 + | })
|
1044 + | .build_unchecked();
|
1045 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1046 + | .await
|
1047 + | .expect("unable to make an HTTP request");
|
1048 + | ::pretty_assertions::assert_eq!(
|
1049 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1050 + | http_response.status()
|
1051 + | );
|
1052 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1053 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1054 + | http_response.headers(),
|
1055 + | expected_headers,
|
1056 + | ));
|
1057 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1058 + | .await
|
1059 + | .expect("unable to extract body to bytes");
|
1060 + | ::aws_smithy_protocol_test::assert_ok(
|
1061 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/httpDateList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/httpDateList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/httpDateList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1062 + | );
|
1063 + | }
|
1064 + | }
|
1065 + |
|
1066 + | /// When an enum list contains non-unique values,
|
1067 + | /// the response should be a 400 ValidationException.
|
1068 + | /// Test ID: RestJsonMalformedUniqueItemsEnumList
|
1069 + | #[::tokio::test]
|
1070 + | #[::tracing_test::traced_test]
|
1071 + | #[should_panic]
|
1072 + | async fn rest_json_malformed_unique_items_enum_list_malformed_request() {
|
1073 + | {
|
1074 + | #[allow(unused_mut)]
|
1075 + | let mut http_request = ::http::Request::builder()
|
1076 + | .uri("/MalformedUniqueItems")
|
1077 + | .method("POST")
|
1078 + | .header("content-type", "application/json")
|
1079 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1080 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1081 + | "{ \"enumList\" : [\"Foo\", \"Foo\"] }".as_bytes(),
|
1082 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1083 + | )),
|
1084 + | ))
|
1085 + | .unwrap();
|
1086 + | #[allow(unused_mut)]
|
1087 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1088 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1089 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1090 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1091 + | let sender = sender.clone();
|
1092 + | async move {
|
1093 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1094 + | sender.send(()).await.expect("receiver dropped early");
|
1095 + | result
|
1096 + | }
|
1097 + | })
|
1098 + | .build_unchecked();
|
1099 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1100 + | .await
|
1101 + | .expect("unable to make an HTTP request");
|
1102 + | ::pretty_assertions::assert_eq!(
|
1103 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1104 + | http_response.status()
|
1105 + | );
|
1106 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1107 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1108 + | http_response.headers(),
|
1109 + | expected_headers,
|
1110 + | ));
|
1111 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1112 + | .await
|
1113 + | .expect("unable to extract body to bytes");
|
1114 + | ::aws_smithy_protocol_test::assert_ok(
|
1115 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/enumList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/enumList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/enumList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1116 + | );
|
1117 + | }
|
1118 + | }
|
1119 + |
|
1120 + | /// When an intEnum list contains non-unique values,
|
1121 + | /// the response should be a 400 ValidationException.
|
1122 + | /// Test ID: RestJsonMalformedUniqueItemsIntEnumList
|
1123 + | #[::tokio::test]
|
1124 + | #[::tracing_test::traced_test]
|
1125 + | #[should_panic]
|
1126 + | async fn rest_json_malformed_unique_items_int_enum_list_malformed_request() {
|
1127 + | {
|
1128 + | #[allow(unused_mut)]
|
1129 + | let mut http_request = ::http::Request::builder()
|
1130 + | .uri("/MalformedUniqueItems")
|
1131 + | .method("POST")
|
1132 + | .header("content-type", "application/json")
|
1133 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1134 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1135 + | "{ \"intEnumList\" : [3, 3] }".as_bytes(),
|
1136 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1137 + | )),
|
1138 + | ))
|
1139 + | .unwrap();
|
1140 + | #[allow(unused_mut)]
|
1141 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1142 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1143 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1144 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1145 + | let sender = sender.clone();
|
1146 + | async move {
|
1147 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1148 + | sender.send(()).await.expect("receiver dropped early");
|
1149 + | result
|
1150 + | }
|
1151 + | })
|
1152 + | .build_unchecked();
|
1153 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1154 + | .await
|
1155 + | .expect("unable to make an HTTP request");
|
1156 + | ::pretty_assertions::assert_eq!(
|
1157 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1158 + | http_response.status()
|
1159 + | );
|
1160 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1161 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1162 + | http_response.headers(),
|
1163 + | expected_headers,
|
1164 + | ));
|
1165 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1166 + | .await
|
1167 + | .expect("unable to extract body to bytes");
|
1168 + | ::aws_smithy_protocol_test::assert_ok(
|
1169 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/intEnumList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/intEnumList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/intEnumList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1170 + | );
|
1171 + | }
|
1172 + | }
|
1173 + |
|
1174 + | /// When an list of lists contains non-unique values,
|
1175 + | /// the response should be a 400 ValidationException.
|
1176 + | /// Test ID: RestJsonMalformedUniqueItemsListList
|
1177 + | #[::tokio::test]
|
1178 + | #[::tracing_test::traced_test]
|
1179 + | #[should_panic]
|
1180 + | async fn rest_json_malformed_unique_items_list_list_malformed_request() {
|
1181 + | {
|
1182 + | #[allow(unused_mut)]
|
1183 + | let mut http_request = ::http::Request::builder()
|
1184 + | .uri("/MalformedUniqueItems")
|
1185 + | .method("POST")
|
1186 + | .header("content-type", "application/json")
|
1187 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1188 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1189 + | "{ \"listList\" : [[\"foo\",\"bar\"], [\"foo\",\"bar\"]] }".as_bytes(),
|
1190 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1191 + | )),
|
1192 + | ))
|
1193 + | .unwrap();
|
1194 + | #[allow(unused_mut)]
|
1195 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1196 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1197 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1198 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1199 + | let sender = sender.clone();
|
1200 + | async move {
|
1201 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1202 + | sender.send(()).await.expect("receiver dropped early");
|
1203 + | result
|
1204 + | }
|
1205 + | })
|
1206 + | .build_unchecked();
|
1207 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1208 + | .await
|
1209 + | .expect("unable to make an HTTP request");
|
1210 + | ::pretty_assertions::assert_eq!(
|
1211 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1212 + | http_response.status()
|
1213 + | );
|
1214 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1215 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1216 + | http_response.headers(),
|
1217 + | expected_headers,
|
1218 + | ));
|
1219 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1220 + | .await
|
1221 + | .expect("unable to extract body to bytes");
|
1222 + | ::aws_smithy_protocol_test::assert_ok(
|
1223 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/listList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/listList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/listList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1224 + | );
|
1225 + | }
|
1226 + | }
|
1227 + |
|
1228 + | /// When an list of structures contains non-unique values,
|
1229 + | /// the response should be a 400 ValidationException.
|
1230 + | /// Test ID: RestJsonMalformedUniqueItemsStructureList
|
1231 + | #[::tokio::test]
|
1232 + | #[::tracing_test::traced_test]
|
1233 + | #[should_panic]
|
1234 + | async fn rest_json_malformed_unique_items_structure_list_malformed_request() {
|
1235 + | {
|
1236 + | #[allow(unused_mut)]
|
1237 + | let mut http_request = ::http::Request::builder()
|
1238 + | .uri("/MalformedUniqueItems")
|
1239 + | .method("POST")
|
1240 + | .header("content-type", "application/json")
|
1241 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1242 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1243 + | "{ \"structureList\" : [{\"hi\": \"hello\"}, {\"hi\": \"hello\"}] }"
|
1244 + | .as_bytes(),
|
1245 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1246 + | )),
|
1247 + | ))
|
1248 + | .unwrap();
|
1249 + | #[allow(unused_mut)]
|
1250 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1251 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1252 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1253 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1254 + | let sender = sender.clone();
|
1255 + | async move {
|
1256 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1257 + | sender.send(()).await.expect("receiver dropped early");
|
1258 + | result
|
1259 + | }
|
1260 + | })
|
1261 + | .build_unchecked();
|
1262 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1263 + | .await
|
1264 + | .expect("unable to make an HTTP request");
|
1265 + | ::pretty_assertions::assert_eq!(
|
1266 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1267 + | http_response.status()
|
1268 + | );
|
1269 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1270 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1271 + | http_response.headers(),
|
1272 + | expected_headers,
|
1273 + | ));
|
1274 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1275 + | .await
|
1276 + | .expect("unable to extract body to bytes");
|
1277 + | ::aws_smithy_protocol_test::assert_ok(
|
1278 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/structureList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/structureList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/structureList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1279 + | );
|
1280 + | }
|
1281 + | }
|
1282 + |
|
1283 + | /// When a list of structures does not contain required keys,
|
1284 + | /// the response should be a 400 ValidationException and not
|
1285 + | /// a 500 error.
|
1286 + | /// Test ID: RestJsonMalformedUniqueItemsStructureMissingKeyList
|
1287 + | #[::tokio::test]
|
1288 + | #[::tracing_test::traced_test]
|
1289 + | async fn rest_json_malformed_unique_items_structure_missing_key_list_malformed_request() {
|
1290 + | {
|
1291 + | #[allow(unused_mut)]
|
1292 + | let mut http_request = ::http::Request::builder()
|
1293 + | .uri("/MalformedUniqueItems")
|
1294 + | .method("POST")
|
1295 + | .header("content-type", "application/json")
|
1296 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1297 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1298 + | "{ \"structureListWithNoKey\" : [{\"hi2\": \"bar\"}] }".as_bytes(),
|
1299 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1300 + | )),
|
1301 + | ))
|
1302 + | .unwrap();
|
1303 + | #[allow(unused_mut)]
|
1304 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1305 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1306 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1307 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1308 + | let sender = sender.clone();
|
1309 + | async move {
|
1310 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1311 + | sender.send(()).await.expect("receiver dropped early");
|
1312 + | result
|
1313 + | }
|
1314 + | })
|
1315 + | .build_unchecked();
|
1316 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1317 + | .await
|
1318 + | .expect("unable to make an HTTP request");
|
1319 + | ::pretty_assertions::assert_eq!(
|
1320 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1321 + | http_response.status()
|
1322 + | );
|
1323 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1324 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1325 + | http_response.headers(),
|
1326 + | expected_headers,
|
1327 + | ));
|
1328 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1329 + | .await
|
1330 + | .expect("unable to extract body to bytes");
|
1331 + | ::aws_smithy_protocol_test::assert_ok(
|
1332 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/structureListWithNoKey/0/hi' failed to satisfy constraint: Member must not be null\",\n \"fieldList\" : [{\"message\": \"Value at '/structureListWithNoKey/0/hi' failed to satisfy constraint: Member must not be null\", \"path\": \"/structureListWithNoKey/0/hi\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1333 + | );
|
1334 + | }
|
1335 + | }
|
1336 + |
|
1337 + | /// When an list of unions contains non-unique values,
|
1338 + | /// the response should be a 400 ValidationException.
|
1339 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case0
|
1340 + | #[::tokio::test]
|
1341 + | #[::tracing_test::traced_test]
|
1342 + | #[should_panic]
|
1343 + | async fn rest_json_malformed_unique_items_union_list_case0_malformed_request() {
|
1344 + | {
|
1345 + | #[allow(unused_mut)]
|
1346 + | let mut http_request = ::http::Request::builder()
|
1347 + | .uri("/MalformedUniqueItems")
|
1348 + | .method("POST")
|
1349 + | .header("content-type", "application/json")
|
1350 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1351 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1352 + | "{ \"unionList\" : [{\"string\": \"foo\"}, {\"string\": \"foo\"}] }"
|
1353 + | .as_bytes(),
|
1354 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1355 + | )),
|
1356 + | ))
|
1357 + | .unwrap();
|
1358 + | #[allow(unused_mut)]
|
1359 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1360 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1361 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1362 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1363 + | let sender = sender.clone();
|
1364 + | async move {
|
1365 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1366 + | sender.send(()).await.expect("receiver dropped early");
|
1367 + | result
|
1368 + | }
|
1369 + | })
|
1370 + | .build_unchecked();
|
1371 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1372 + | .await
|
1373 + | .expect("unable to make an HTTP request");
|
1374 + | ::pretty_assertions::assert_eq!(
|
1375 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1376 + | http_response.status()
|
1377 + | );
|
1378 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1379 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1380 + | http_response.headers(),
|
1381 + | expected_headers,
|
1382 + | ));
|
1383 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1384 + | .await
|
1385 + | .expect("unable to extract body to bytes");
|
1386 + | ::aws_smithy_protocol_test::assert_ok(
|
1387 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/unionList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/unionList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/unionList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1388 + | );
|
1389 + | }
|
1390 + | }
|
1391 + |
|
1392 + | /// When an list of unions contains non-unique values,
|
1393 + | /// the response should be a 400 ValidationException.
|
1394 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case1
|
1395 + | #[::tokio::test]
|
1396 + | #[::tracing_test::traced_test]
|
1397 + | #[should_panic]
|
1398 + | async fn rest_json_malformed_unique_items_union_list_case1_malformed_request() {
|
1399 + | {
|
1400 + | #[allow(unused_mut)]
|
1401 + | let mut http_request = ::http::Request::builder()
|
1402 + | .uri("/MalformedUniqueItems")
|
1403 + | .method("POST")
|
1404 + | .header("content-type", "application/json")
|
1405 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1406 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1407 + | "{ \"unionList\" : [{\"integer\": 1}, {\"integer\": 1}] }".as_bytes(),
|
1408 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1409 + | )),
|
1410 + | ))
|
1411 + | .unwrap();
|
1412 + | #[allow(unused_mut)]
|
1413 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1414 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1415 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1416 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1417 + | let sender = sender.clone();
|
1418 + | async move {
|
1419 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
1420 + | sender.send(()).await.expect("receiver dropped early");
|
1421 + | result
|
1422 + | }
|
1423 + | })
|
1424 + | .build_unchecked();
|
1425 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1426 + | .await
|
1427 + | .expect("unable to make an HTTP request");
|
1428 + | ::pretty_assertions::assert_eq!(
|
1429 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1430 + | http_response.status()
|
1431 + | );
|
1432 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1433 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1434 + | http_response.headers(),
|
1435 + | expected_headers,
|
1436 + | ));
|
1437 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1438 + | .await
|
1439 + | .expect("unable to extract body to bytes");
|
1440 + | ::aws_smithy_protocol_test::assert_ok(
|
1441 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/unionList' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value at '/unionList' failed to satisfy constraint: Member must have unique values\", \"path\": \"/unionList\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1442 + | );
|
1443 + | }
|
1444 + | }
|
1445 + | }
|
1446 + |
|
1447 + | ::pin_project_lite::pin_project! {
|
1448 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1449 + | /// [`MalformedRequiredInput`](crate::input::MalformedRequiredInput) using modelled bindings.
|
1450 + | pub struct MalformedRequiredInputFuture {
|
1451 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRequiredInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1452 + | }
|
1453 + | }
|
1454 + |
|
1455 + | impl std::future::Future for MalformedRequiredInputFuture {
|
1456 + | type Output = Result<
|
1457 + | crate::input::MalformedRequiredInput,
|
1458 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1459 + | >;
|
1460 + |
|
1461 + | fn poll(
|
1462 + | self: std::pin::Pin<&mut Self>,
|
1463 + | cx: &mut std::task::Context<'_>,
|
1464 + | ) -> std::task::Poll<Self::Output> {
|
1465 + | let this = self.project();
|
1466 + | this.inner.as_mut().poll(cx)
|
1467 + | }
|
1468 + | }
|
1469 + |
|
1470 + | impl<B>
|
1471 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1472 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1473 + | B,
|
1474 + | > for crate::input::MalformedRequiredInput
|
1475 + | where
|
1476 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1477 + | B: 'static,
|
1478 + |
|
1479 + | B::Data: Send,
|
1480 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1481 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1482 + | {
|
1483 + | type Rejection =
|
1484 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1485 + | type Future = MalformedRequiredInputFuture;
|
1486 + |
|
1487 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1488 + | let fut = async move {
|
1489 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1490 + | request.headers(),
|
1491 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1492 + | ) {
|
1493 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1494 + | }
|
1495 + | crate::protocol_serde::shape_malformed_required::de_malformed_required_http_request(
|
1496 + | request,
|
1497 + | )
|
1498 + | .await
|
1499 + | };
|
1500 + | use ::futures_util::future::TryFutureExt;
|
1501 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1502 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1503 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1504 + | });
|
1505 + | MalformedRequiredInputFuture {
|
1506 + | inner: Box::pin(fut),
|
1507 + | }
|
1508 + | }
|
1509 + | }
|
1510 + | impl
|
1511 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1512 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1513 + | > for crate::output::MalformedRequiredOutput
|
1514 + | {
|
1515 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1516 + | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_response(
|
1517 + | self,
|
1518 + | ) {
|
1519 + | Ok(response) => response,
|
1520 + | Err(e) => {
|
1521 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1522 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1523 + | }
|
1524 + | }
|
1525 + | }
|
1526 + | }
|
1527 + | impl
|
1528 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1529 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1530 + | > for crate::error::MalformedRequiredError
|
1531 + | {
|
1532 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1533 + | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_error(
|
1534 + | &self,
|
1535 + | ) {
|
1536 + | Ok(mut response) => {
|
1537 + | response.extensions_mut().insert(
|
1538 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
1539 + | self.name(),
|
1540 + | ),
|
1541 + | );
|
1542 + | response
|
1543 + | }
|
1544 + | Err(e) => {
|
1545 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1546 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1547 + | }
|
1548 + | }
|
1549 + | }
|
1550 + | }
|
1551 + |
|
1552 + | #[allow(unreachable_code, unused_variables)]
|
1553 + | #[cfg(test)]
|
1554 + | mod malformed_required_test {
|
1555 + |
|
1556 + | /// When a required member is not set in the message body,
|
1557 + | /// the response should be a 400 ValidationException.
|
1558 + | /// Test ID: RestJsonMalformedRequiredBodyUnset
|
1559 + | #[::tokio::test]
|
1560 + | #[::tracing_test::traced_test]
|
1561 + | async fn rest_json_malformed_required_body_unset_malformed_request() {
|
1562 + | {
|
1563 + | #[allow(unused_mut)]
|
1564 + | let mut http_request = ::http::Request::builder()
|
1565 + | .uri("/MalformedRequired")
|
1566 + | .method("POST")
|
1567 + | .header("content-type", "application/json")
|
1568 + | .header("string-in-headers", "abc")
|
1569 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1570 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1571 + | "{ }".as_bytes(),
|
1572 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1573 + | )),
|
1574 + | ))
|
1575 + | .unwrap();
|
1576 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1577 + | #[allow(unused_mut)]
|
1578 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1579 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1580 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1581 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1582 + | let sender = sender.clone();
|
1583 + | async move {
|
1584 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRequiredOutput, crate::error::MalformedRequiredError> };
|
1585 + | sender.send(()).await.expect("receiver dropped early");
|
1586 + | result
|
1587 + | }
|
1588 + | })
|
1589 + | .build_unchecked();
|
1590 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1591 + | .await
|
1592 + | .expect("unable to make an HTTP request");
|
1593 + | ::pretty_assertions::assert_eq!(
|
1594 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1595 + | http_response.status()
|
1596 + | );
|
1597 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1598 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1599 + | http_response.headers(),
|
1600 + | expected_headers,
|
1601 + | ));
|
1602 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1603 + | .await
|
1604 + | .expect("unable to extract body to bytes");
|
1605 + | ::aws_smithy_protocol_test::assert_ok(
|
1606 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must not be null\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must not be null\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1607 + | );
|
1608 + | }
|
1609 + | }
|
1610 + |
|
1611 + | /// When a required member is set to null in the message body,
|
1612 + | /// the response should be a 400 ValidationException.
|
1613 + | /// Test ID: RestJsonMalformedRequiredBodyExplicitNull
|
1614 + | #[::tokio::test]
|
1615 + | #[::tracing_test::traced_test]
|
1616 + | async fn rest_json_malformed_required_body_explicit_null_malformed_request() {
|
1617 + | {
|
1618 + | #[allow(unused_mut)]
|
1619 + | let mut http_request = ::http::Request::builder()
|
1620 + | .uri("/MalformedRequired")
|
1621 + | .method("POST")
|
1622 + | .header("content-type", "application/json")
|
1623 + | .header("string-in-headers", "abc")
|
1624 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1625 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1626 + | "{ \"string\": null }".as_bytes(),
|
1627 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1628 + | )),
|
1629 + | ))
|
1630 + | .unwrap();
|
1631 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1632 + | #[allow(unused_mut)]
|
1633 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1634 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1635 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1636 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1637 + | let sender = sender.clone();
|
1638 + | async move {
|
1639 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRequiredOutput, crate::error::MalformedRequiredError> };
|
1640 + | sender.send(()).await.expect("receiver dropped early");
|
1641 + | result
|
1642 + | }
|
1643 + | })
|
1644 + | .build_unchecked();
|
1645 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1646 + | .await
|
1647 + | .expect("unable to make an HTTP request");
|
1648 + | ::pretty_assertions::assert_eq!(
|
1649 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1650 + | http_response.status()
|
1651 + | );
|
1652 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1653 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1654 + | http_response.headers(),
|
1655 + | expected_headers,
|
1656 + | ));
|
1657 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1658 + | .await
|
1659 + | .expect("unable to extract body to bytes");
|
1660 + | ::aws_smithy_protocol_test::assert_ok(
|
1661 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must not be null\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must not be null\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1662 + | );
|
1663 + | }
|
1664 + | }
|
1665 + |
|
1666 + | /// When a required member is not set in headers,
|
1667 + | /// the response should be a 400 ValidationException.
|
1668 + | /// Test ID: RestJsonMalformedRequiredHeaderUnset
|
1669 + | #[::tokio::test]
|
1670 + | #[::tracing_test::traced_test]
|
1671 + | async fn rest_json_malformed_required_header_unset_malformed_request() {
|
1672 + | {
|
1673 + | #[allow(unused_mut)]
|
1674 + | let mut http_request = ::http::Request::builder()
|
1675 + | .uri("/MalformedRequired")
|
1676 + | .method("POST")
|
1677 + | .header("content-type", "application/json")
|
1678 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1679 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1680 + | "{ \"string\": \"abc\" }".as_bytes(),
|
1681 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1682 + | )),
|
1683 + | ))
|
1684 + | .unwrap();
|
1685 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1686 + | #[allow(unused_mut)]
|
1687 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1688 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1689 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1690 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1691 + | let sender = sender.clone();
|
1692 + | async move {
|
1693 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRequiredOutput, crate::error::MalformedRequiredError> };
|
1694 + | sender.send(()).await.expect("receiver dropped early");
|
1695 + | result
|
1696 + | }
|
1697 + | })
|
1698 + | .build_unchecked();
|
1699 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1700 + | .await
|
1701 + | .expect("unable to make an HTTP request");
|
1702 + | ::pretty_assertions::assert_eq!(
|
1703 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1704 + | http_response.status()
|
1705 + | );
|
1706 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1707 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1708 + | http_response.headers(),
|
1709 + | expected_headers,
|
1710 + | ));
|
1711 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1712 + | .await
|
1713 + | .expect("unable to extract body to bytes");
|
1714 + | ::aws_smithy_protocol_test::assert_ok(
|
1715 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/stringInHeader' failed to satisfy constraint: Member must not be null\",\n \"fieldList\" : [{\"message\": \"Value at '/stringInHeader' failed to satisfy constraint: Member must not be null\", \"path\": \"/stringInHeader\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1716 + | );
|
1717 + | }
|
1718 + | }
|
1719 + | }
|
1720 + |
|
1721 + | ::pin_project_lite::pin_project! {
|
1722 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1723 + | /// [`MalformedRangeOverrideInput`](crate::input::MalformedRangeOverrideInput) using modelled bindings.
|
1724 + | pub struct MalformedRangeOverrideInputFuture {
|
1725 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRangeOverrideInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1726 + | }
|
1727 + | }
|
1728 + |
|
1729 + | impl std::future::Future for MalformedRangeOverrideInputFuture {
|
1730 + | type Output = Result<
|
1731 + | crate::input::MalformedRangeOverrideInput,
|
1732 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1733 + | >;
|
1734 + |
|
1735 + | fn poll(
|
1736 + | self: std::pin::Pin<&mut Self>,
|
1737 + | cx: &mut std::task::Context<'_>,
|
1738 + | ) -> std::task::Poll<Self::Output> {
|
1739 + | let this = self.project();
|
1740 + | this.inner.as_mut().poll(cx)
|
1741 + | }
|
1742 + | }
|
1743 + |
|
1744 + | impl<B>
|
1745 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
1746 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1747 + | B,
|
1748 + | > for crate::input::MalformedRangeOverrideInput
|
1749 + | where
|
1750 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
1751 + | B: 'static,
|
1752 + |
|
1753 + | B::Data: Send,
|
1754 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1755 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
1756 + | {
|
1757 + | type Rejection =
|
1758 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1759 + | type Future = MalformedRangeOverrideInputFuture;
|
1760 + |
|
1761 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1762 + | let fut = async move {
|
1763 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
1764 + | request.headers(),
|
1765 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1766 + | ) {
|
1767 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1768 + | }
|
1769 + | crate::protocol_serde::shape_malformed_range_override::de_malformed_range_override_http_request(request)
|
1770 + | .await
|
1771 + | };
|
1772 + | use ::futures_util::future::TryFutureExt;
|
1773 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1774 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1775 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
1776 + | });
|
1777 + | MalformedRangeOverrideInputFuture {
|
1778 + | inner: Box::pin(fut),
|
1779 + | }
|
1780 + | }
|
1781 + | }
|
1782 + | impl
|
1783 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1784 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1785 + | > for crate::output::MalformedRangeOverrideOutput
|
1786 + | {
|
1787 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1788 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_response(self) {
|
1789 + | Ok(response) => response,
|
1790 + | Err(e) => {
|
1791 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1792 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1793 + | }
|
1794 + | }
|
1795 + | }
|
1796 + | }
|
1797 + | impl
|
1798 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
1799 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
1800 + | > for crate::error::MalformedRangeOverrideError
|
1801 + | {
|
1802 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
1803 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_error(&self) {
|
1804 + | Ok(mut response) => {
|
1805 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1806 + | response
|
1807 + | },
|
1808 + | Err(e) => {
|
1809 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1810 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1811 + | }
|
1812 + | }
|
1813 + | }
|
1814 + | }
|
1815 + |
|
1816 + | #[allow(unreachable_code, unused_variables)]
|
1817 + | #[cfg(test)]
|
1818 + | mod malformed_range_override_test {
|
1819 + |
|
1820 + | /// When a byte member does not fit within range bounds,
|
1821 + | /// the response should be a 400 ValidationException.
|
1822 + | /// Test ID: RestJsonMalformedRangeByteOverride_case0
|
1823 + | #[::tokio::test]
|
1824 + | #[::tracing_test::traced_test]
|
1825 + | async fn rest_json_malformed_range_byte_override_case0_malformed_request() {
|
1826 + | {
|
1827 + | #[allow(unused_mut)]
|
1828 + | let mut http_request = ::http::Request::builder()
|
1829 + | .uri("/MalformedRangeOverride")
|
1830 + | .method("POST")
|
1831 + | .header("content-type", "application/json")
|
1832 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1833 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1834 + | "{ \"byte\" : 3 }".as_bytes(),
|
1835 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1836 + | )),
|
1837 + | ))
|
1838 + | .unwrap();
|
1839 + | #[allow(unused_mut)]
|
1840 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1841 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1842 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1843 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1844 + | let sender = sender.clone();
|
1845 + | async move {
|
1846 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
1847 + | sender.send(()).await.expect("receiver dropped early");
|
1848 + | result
|
1849 + | }
|
1850 + | })
|
1851 + | .build_unchecked();
|
1852 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1853 + | .await
|
1854 + | .expect("unable to make an HTTP request");
|
1855 + | ::pretty_assertions::assert_eq!(
|
1856 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1857 + | http_response.status()
|
1858 + | );
|
1859 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1860 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1861 + | http_response.headers(),
|
1862 + | expected_headers,
|
1863 + | ));
|
1864 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1865 + | .await
|
1866 + | .expect("unable to extract body to bytes");
|
1867 + | ::aws_smithy_protocol_test::assert_ok(
|
1868 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/byte' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/byte' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/byte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1869 + | );
|
1870 + | }
|
1871 + | }
|
1872 + |
|
1873 + | /// When a byte member does not fit within range bounds,
|
1874 + | /// the response should be a 400 ValidationException.
|
1875 + | /// Test ID: RestJsonMalformedRangeByteOverride_case1
|
1876 + | #[::tokio::test]
|
1877 + | #[::tracing_test::traced_test]
|
1878 + | async fn rest_json_malformed_range_byte_override_case1_malformed_request() {
|
1879 + | {
|
1880 + | #[allow(unused_mut)]
|
1881 + | let mut http_request = ::http::Request::builder()
|
1882 + | .uri("/MalformedRangeOverride")
|
1883 + | .method("POST")
|
1884 + | .header("content-type", "application/json")
|
1885 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1886 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1887 + | "{ \"byte\" : 7 }".as_bytes(),
|
1888 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1889 + | )),
|
1890 + | ))
|
1891 + | .unwrap();
|
1892 + | #[allow(unused_mut)]
|
1893 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1894 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1895 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1896 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1897 + | let sender = sender.clone();
|
1898 + | async move {
|
1899 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
1900 + | sender.send(()).await.expect("receiver dropped early");
|
1901 + | result
|
1902 + | }
|
1903 + | })
|
1904 + | .build_unchecked();
|
1905 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1906 + | .await
|
1907 + | .expect("unable to make an HTTP request");
|
1908 + | ::pretty_assertions::assert_eq!(
|
1909 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1910 + | http_response.status()
|
1911 + | );
|
1912 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1913 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1914 + | http_response.headers(),
|
1915 + | expected_headers,
|
1916 + | ));
|
1917 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1918 + | .await
|
1919 + | .expect("unable to extract body to bytes");
|
1920 + | ::aws_smithy_protocol_test::assert_ok(
|
1921 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/byte' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/byte' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/byte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1922 + | );
|
1923 + | }
|
1924 + | }
|
1925 + |
|
1926 + | /// When a byte member does not fit within range bounds,
|
1927 + | /// the response should be a 400 ValidationException.
|
1928 + | /// Test ID: RestJsonMalformedRangeMinByteOverride
|
1929 + | #[::tokio::test]
|
1930 + | #[::tracing_test::traced_test]
|
1931 + | async fn rest_json_malformed_range_min_byte_override_malformed_request() {
|
1932 + | {
|
1933 + | #[allow(unused_mut)]
|
1934 + | let mut http_request = ::http::Request::builder()
|
1935 + | .uri("/MalformedRangeOverride")
|
1936 + | .method("POST")
|
1937 + | .header("content-type", "application/json")
|
1938 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1939 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1940 + | "{ \"minByte\" : 3 }".as_bytes(),
|
1941 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1942 + | )),
|
1943 + | ))
|
1944 + | .unwrap();
|
1945 + | #[allow(unused_mut)]
|
1946 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1947 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1948 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1949 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1950 + | let sender = sender.clone();
|
1951 + | async move {
|
1952 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
1953 + | sender.send(()).await.expect("receiver dropped early");
|
1954 + | result
|
1955 + | }
|
1956 + | })
|
1957 + | .build_unchecked();
|
1958 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1959 + | .await
|
1960 + | .expect("unable to make an HTTP request");
|
1961 + | ::pretty_assertions::assert_eq!(
|
1962 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1963 + | http_response.status()
|
1964 + | );
|
1965 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1966 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1967 + | http_response.headers(),
|
1968 + | expected_headers,
|
1969 + | ));
|
1970 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1971 + | .await
|
1972 + | .expect("unable to extract body to bytes");
|
1973 + | ::aws_smithy_protocol_test::assert_ok(
|
1974 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minByte' failed to satisfy constraint: Member must be greater than or equal to 4\",\n \"fieldList\" : [{\"message\": \"Value at '/minByte' failed to satisfy constraint: Member must be greater than or equal to 4\", \"path\": \"/minByte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
1975 + | );
|
1976 + | }
|
1977 + | }
|
1978 + |
|
1979 + | /// When a byte member does not fit within range bounds,
|
1980 + | /// the response should be a 400 ValidationException.
|
1981 + | /// Test ID: RestJsonMalformedRangeMaxByteOverride
|
1982 + | #[::tokio::test]
|
1983 + | #[::tracing_test::traced_test]
|
1984 + | async fn rest_json_malformed_range_max_byte_override_malformed_request() {
|
1985 + | {
|
1986 + | #[allow(unused_mut)]
|
1987 + | let mut http_request = ::http::Request::builder()
|
1988 + | .uri("/MalformedRangeOverride")
|
1989 + | .method("POST")
|
1990 + | .header("content-type", "application/json")
|
1991 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
1992 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
1993 + | "{ \"maxByte\" : 7 }".as_bytes(),
|
1994 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1995 + | )),
|
1996 + | ))
|
1997 + | .unwrap();
|
1998 + | #[allow(unused_mut)]
|
1999 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2000 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2001 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2002 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2003 + | let sender = sender.clone();
|
2004 + | async move {
|
2005 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2006 + | sender.send(()).await.expect("receiver dropped early");
|
2007 + | result
|
2008 + | }
|
2009 + | })
|
2010 + | .build_unchecked();
|
2011 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2012 + | .await
|
2013 + | .expect("unable to make an HTTP request");
|
2014 + | ::pretty_assertions::assert_eq!(
|
2015 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2016 + | http_response.status()
|
2017 + | );
|
2018 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2019 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2020 + | http_response.headers(),
|
2021 + | expected_headers,
|
2022 + | ));
|
2023 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2024 + | .await
|
2025 + | .expect("unable to extract body to bytes");
|
2026 + | ::aws_smithy_protocol_test::assert_ok(
|
2027 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxByte' failed to satisfy constraint: Member must be less than or equal to 6\",\n \"fieldList\" : [{\"message\": \"Value at '/maxByte' failed to satisfy constraint: Member must be less than or equal to 6\", \"path\": \"/maxByte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2028 + | );
|
2029 + | }
|
2030 + | }
|
2031 + |
|
2032 + | /// When a float member does not fit within range bounds,
|
2033 + | /// the response should be a 400 ValidationException.
|
2034 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case0
|
2035 + | #[::tokio::test]
|
2036 + | #[::tracing_test::traced_test]
|
2037 + | #[should_panic]
|
2038 + | async fn rest_json_malformed_range_float_override_case0_malformed_request() {
|
2039 + | {
|
2040 + | #[allow(unused_mut)]
|
2041 + | let mut http_request = ::http::Request::builder()
|
2042 + | .uri("/MalformedRangeOverride")
|
2043 + | .method("POST")
|
2044 + | .header("content-type", "application/json")
|
2045 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2046 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2047 + | "{ \"float\" : 4.3 }".as_bytes(),
|
2048 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2049 + | )),
|
2050 + | ))
|
2051 + | .unwrap();
|
2052 + | #[allow(unused_mut)]
|
2053 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2054 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2055 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2056 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2057 + | let sender = sender.clone();
|
2058 + | async move {
|
2059 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2060 + | sender.send(()).await.expect("receiver dropped early");
|
2061 + | result
|
2062 + | }
|
2063 + | })
|
2064 + | .build_unchecked();
|
2065 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2066 + | .await
|
2067 + | .expect("unable to make an HTTP request");
|
2068 + | ::pretty_assertions::assert_eq!(
|
2069 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2070 + | http_response.status()
|
2071 + | );
|
2072 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2073 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2074 + | http_response.headers(),
|
2075 + | expected_headers,
|
2076 + | ));
|
2077 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2078 + | .await
|
2079 + | .expect("unable to extract body to bytes");
|
2080 + | ::aws_smithy_protocol_test::assert_ok(
|
2081 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/float' failed to satisfy constraint: Member must be between 4.4 and 6.6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/float' failed to satisfy constraint: Member must be between 4.4 and 6.6, inclusive\", \"path\": \"/float\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2082 + | );
|
2083 + | }
|
2084 + | }
|
2085 + |
|
2086 + | /// When a float member does not fit within range bounds,
|
2087 + | /// the response should be a 400 ValidationException.
|
2088 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case1
|
2089 + | #[::tokio::test]
|
2090 + | #[::tracing_test::traced_test]
|
2091 + | #[should_panic]
|
2092 + | async fn rest_json_malformed_range_float_override_case1_malformed_request() {
|
2093 + | {
|
2094 + | #[allow(unused_mut)]
|
2095 + | let mut http_request = ::http::Request::builder()
|
2096 + | .uri("/MalformedRangeOverride")
|
2097 + | .method("POST")
|
2098 + | .header("content-type", "application/json")
|
2099 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2100 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2101 + | "{ \"float\" : 6.7 }".as_bytes(),
|
2102 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2103 + | )),
|
2104 + | ))
|
2105 + | .unwrap();
|
2106 + | #[allow(unused_mut)]
|
2107 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2108 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2109 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2110 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2111 + | let sender = sender.clone();
|
2112 + | async move {
|
2113 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2114 + | sender.send(()).await.expect("receiver dropped early");
|
2115 + | result
|
2116 + | }
|
2117 + | })
|
2118 + | .build_unchecked();
|
2119 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2120 + | .await
|
2121 + | .expect("unable to make an HTTP request");
|
2122 + | ::pretty_assertions::assert_eq!(
|
2123 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2124 + | http_response.status()
|
2125 + | );
|
2126 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2127 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2128 + | http_response.headers(),
|
2129 + | expected_headers,
|
2130 + | ));
|
2131 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2132 + | .await
|
2133 + | .expect("unable to extract body to bytes");
|
2134 + | ::aws_smithy_protocol_test::assert_ok(
|
2135 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/float' failed to satisfy constraint: Member must be between 4.4 and 6.6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/float' failed to satisfy constraint: Member must be between 4.4 and 6.6, inclusive\", \"path\": \"/float\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2136 + | );
|
2137 + | }
|
2138 + | }
|
2139 + |
|
2140 + | /// When a float member does not fit within range bounds,
|
2141 + | /// the response should be a 400 ValidationException.
|
2142 + | /// Test ID: RestJsonMalformedRangeMinFloatOverride
|
2143 + | #[::tokio::test]
|
2144 + | #[::tracing_test::traced_test]
|
2145 + | #[should_panic]
|
2146 + | async fn rest_json_malformed_range_min_float_override_malformed_request() {
|
2147 + | {
|
2148 + | #[allow(unused_mut)]
|
2149 + | let mut http_request = ::http::Request::builder()
|
2150 + | .uri("/MalformedRangeOverride")
|
2151 + | .method("POST")
|
2152 + | .header("content-type", "application/json")
|
2153 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2154 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2155 + | "{ \"minFloat\" : 4.3 }".as_bytes(),
|
2156 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2157 + | )),
|
2158 + | ))
|
2159 + | .unwrap();
|
2160 + | #[allow(unused_mut)]
|
2161 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2162 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2163 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2164 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2165 + | let sender = sender.clone();
|
2166 + | async move {
|
2167 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2168 + | sender.send(()).await.expect("receiver dropped early");
|
2169 + | result
|
2170 + | }
|
2171 + | })
|
2172 + | .build_unchecked();
|
2173 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2174 + | .await
|
2175 + | .expect("unable to make an HTTP request");
|
2176 + | ::pretty_assertions::assert_eq!(
|
2177 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2178 + | http_response.status()
|
2179 + | );
|
2180 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2181 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2182 + | http_response.headers(),
|
2183 + | expected_headers,
|
2184 + | ));
|
2185 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2186 + | .await
|
2187 + | .expect("unable to extract body to bytes");
|
2188 + | ::aws_smithy_protocol_test::assert_ok(
|
2189 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minFloat' failed to satisfy constraint: Member must be greater than or equal to 4.4\",\n \"fieldList\" : [{\"message\": \"Value at '/minFloat' failed to satisfy constraint: Member must be greater than or equal to 4.4\", \"path\": \"/minFloat\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2190 + | );
|
2191 + | }
|
2192 + | }
|
2193 + |
|
2194 + | /// When a float member does not fit within range bounds,
|
2195 + | /// the response should be a 400 ValidationException.
|
2196 + | /// Test ID: RestJsonMalformedRangeMaxFloatOverride
|
2197 + | #[::tokio::test]
|
2198 + | #[::tracing_test::traced_test]
|
2199 + | #[should_panic]
|
2200 + | async fn rest_json_malformed_range_max_float_override_malformed_request() {
|
2201 + | {
|
2202 + | #[allow(unused_mut)]
|
2203 + | let mut http_request = ::http::Request::builder()
|
2204 + | .uri("/MalformedRangeOverride")
|
2205 + | .method("POST")
|
2206 + | .header("content-type", "application/json")
|
2207 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2208 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2209 + | "{ \"maxFloat\" : 6.7 }".as_bytes(),
|
2210 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2211 + | )),
|
2212 + | ))
|
2213 + | .unwrap();
|
2214 + | #[allow(unused_mut)]
|
2215 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2216 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2217 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2218 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2219 + | let sender = sender.clone();
|
2220 + | async move {
|
2221 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2222 + | sender.send(()).await.expect("receiver dropped early");
|
2223 + | result
|
2224 + | }
|
2225 + | })
|
2226 + | .build_unchecked();
|
2227 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2228 + | .await
|
2229 + | .expect("unable to make an HTTP request");
|
2230 + | ::pretty_assertions::assert_eq!(
|
2231 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2232 + | http_response.status()
|
2233 + | );
|
2234 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2235 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2236 + | http_response.headers(),
|
2237 + | expected_headers,
|
2238 + | ));
|
2239 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2240 + | .await
|
2241 + | .expect("unable to extract body to bytes");
|
2242 + | ::aws_smithy_protocol_test::assert_ok(
|
2243 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxFloat' failed to satisfy constraint: Member must be less than or equal to 6.6\",\n \"fieldList\" : [{\"message\": \"Value at '/maxFloat' failed to satisfy constraint: Member must be less than or equal to 6.6\", \"path\": \"/maxFloat\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2244 + | );
|
2245 + | }
|
2246 + | }
|
2247 + |
|
2248 + | /// When a short member does not fit within range bounds,
|
2249 + | /// the response should be a 400 ValidationException.
|
2250 + | /// Test ID: RestJsonMalformedRangeShortOverride_case0
|
2251 + | #[::tokio::test]
|
2252 + | #[::tracing_test::traced_test]
|
2253 + | async fn rest_json_malformed_range_short_override_case0_malformed_request() {
|
2254 + | {
|
2255 + | #[allow(unused_mut)]
|
2256 + | let mut http_request = ::http::Request::builder()
|
2257 + | .uri("/MalformedRangeOverride")
|
2258 + | .method("POST")
|
2259 + | .header("content-type", "application/json")
|
2260 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2261 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2262 + | "{ \"short\" : 3 }".as_bytes(),
|
2263 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2264 + | )),
|
2265 + | ))
|
2266 + | .unwrap();
|
2267 + | #[allow(unused_mut)]
|
2268 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2269 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2270 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2271 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2272 + | let sender = sender.clone();
|
2273 + | async move {
|
2274 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2275 + | sender.send(()).await.expect("receiver dropped early");
|
2276 + | result
|
2277 + | }
|
2278 + | })
|
2279 + | .build_unchecked();
|
2280 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2281 + | .await
|
2282 + | .expect("unable to make an HTTP request");
|
2283 + | ::pretty_assertions::assert_eq!(
|
2284 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2285 + | http_response.status()
|
2286 + | );
|
2287 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
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(
|
2296 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/short' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/short' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/short\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2297 + | );
|
2298 + | }
|
2299 + | }
|
2300 + |
|
2301 + | /// When a short member does not fit within range bounds,
|
2302 + | /// the response should be a 400 ValidationException.
|
2303 + | /// Test ID: RestJsonMalformedRangeShortOverride_case1
|
2304 + | #[::tokio::test]
|
2305 + | #[::tracing_test::traced_test]
|
2306 + | async fn rest_json_malformed_range_short_override_case1_malformed_request() {
|
2307 + | {
|
2308 + | #[allow(unused_mut)]
|
2309 + | let mut http_request = ::http::Request::builder()
|
2310 + | .uri("/MalformedRangeOverride")
|
2311 + | .method("POST")
|
2312 + | .header("content-type", "application/json")
|
2313 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2314 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2315 + | "{ \"short\" : 7 }".as_bytes(),
|
2316 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2317 + | )),
|
2318 + | ))
|
2319 + | .unwrap();
|
2320 + | #[allow(unused_mut)]
|
2321 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2322 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2323 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2324 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2325 + | let sender = sender.clone();
|
2326 + | async move {
|
2327 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2328 + | sender.send(()).await.expect("receiver dropped early");
|
2329 + | result
|
2330 + | }
|
2331 + | })
|
2332 + | .build_unchecked();
|
2333 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2334 + | .await
|
2335 + | .expect("unable to make an HTTP request");
|
2336 + | ::pretty_assertions::assert_eq!(
|
2337 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2338 + | http_response.status()
|
2339 + | );
|
2340 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2341 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2342 + | http_response.headers(),
|
2343 + | expected_headers,
|
2344 + | ));
|
2345 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2346 + | .await
|
2347 + | .expect("unable to extract body to bytes");
|
2348 + | ::aws_smithy_protocol_test::assert_ok(
|
2349 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/short' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/short' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/short\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2350 + | );
|
2351 + | }
|
2352 + | }
|
2353 + |
|
2354 + | /// When a short member does not fit within range bounds,
|
2355 + | /// the response should be a 400 ValidationException.
|
2356 + | /// Test ID: RestJsonMalformedRangeMinShortOverride
|
2357 + | #[::tokio::test]
|
2358 + | #[::tracing_test::traced_test]
|
2359 + | async fn rest_json_malformed_range_min_short_override_malformed_request() {
|
2360 + | {
|
2361 + | #[allow(unused_mut)]
|
2362 + | let mut http_request = ::http::Request::builder()
|
2363 + | .uri("/MalformedRangeOverride")
|
2364 + | .method("POST")
|
2365 + | .header("content-type", "application/json")
|
2366 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2367 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2368 + | "{ \"minShort\" : 3 }".as_bytes(),
|
2369 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2370 + | )),
|
2371 + | ))
|
2372 + | .unwrap();
|
2373 + | #[allow(unused_mut)]
|
2374 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2375 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2376 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2377 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2378 + | let sender = sender.clone();
|
2379 + | async move {
|
2380 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2381 + | sender.send(()).await.expect("receiver dropped early");
|
2382 + | result
|
2383 + | }
|
2384 + | })
|
2385 + | .build_unchecked();
|
2386 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2387 + | .await
|
2388 + | .expect("unable to make an HTTP request");
|
2389 + | ::pretty_assertions::assert_eq!(
|
2390 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2391 + | http_response.status()
|
2392 + | );
|
2393 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2394 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2395 + | http_response.headers(),
|
2396 + | expected_headers,
|
2397 + | ));
|
2398 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2399 + | .await
|
2400 + | .expect("unable to extract body to bytes");
|
2401 + | ::aws_smithy_protocol_test::assert_ok(
|
2402 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minShort' failed to satisfy constraint: Member must be greater than or equal to 4\",\n \"fieldList\" : [{\"message\": \"Value at '/minShort' failed to satisfy constraint: Member must be greater than or equal to 4\", \"path\": \"/minShort\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2403 + | );
|
2404 + | }
|
2405 + | }
|
2406 + |
|
2407 + | /// When a short member does not fit within range bounds,
|
2408 + | /// the response should be a 400 ValidationException.
|
2409 + | /// Test ID: RestJsonMalformedRangeMaxShortOverride
|
2410 + | #[::tokio::test]
|
2411 + | #[::tracing_test::traced_test]
|
2412 + | async fn rest_json_malformed_range_max_short_override_malformed_request() {
|
2413 + | {
|
2414 + | #[allow(unused_mut)]
|
2415 + | let mut http_request = ::http::Request::builder()
|
2416 + | .uri("/MalformedRangeOverride")
|
2417 + | .method("POST")
|
2418 + | .header("content-type", "application/json")
|
2419 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2420 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2421 + | "{ \"maxShort\" : 7 }".as_bytes(),
|
2422 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2423 + | )),
|
2424 + | ))
|
2425 + | .unwrap();
|
2426 + | #[allow(unused_mut)]
|
2427 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2428 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2429 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2430 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2431 + | let sender = sender.clone();
|
2432 + | async move {
|
2433 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2434 + | sender.send(()).await.expect("receiver dropped early");
|
2435 + | result
|
2436 + | }
|
2437 + | })
|
2438 + | .build_unchecked();
|
2439 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2440 + | .await
|
2441 + | .expect("unable to make an HTTP request");
|
2442 + | ::pretty_assertions::assert_eq!(
|
2443 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2444 + | http_response.status()
|
2445 + | );
|
2446 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2447 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2448 + | http_response.headers(),
|
2449 + | expected_headers,
|
2450 + | ));
|
2451 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2452 + | .await
|
2453 + | .expect("unable to extract body to bytes");
|
2454 + | ::aws_smithy_protocol_test::assert_ok(
|
2455 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxShort' failed to satisfy constraint: Member must be less than or equal to 6\",\n \"fieldList\" : [{\"message\": \"Value at '/maxShort' failed to satisfy constraint: Member must be less than or equal to 6\", \"path\": \"/maxShort\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2456 + | );
|
2457 + | }
|
2458 + | }
|
2459 + |
|
2460 + | /// When a integer member does not fit within range bounds,
|
2461 + | /// the response should be a 400 ValidationException.
|
2462 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case0
|
2463 + | #[::tokio::test]
|
2464 + | #[::tracing_test::traced_test]
|
2465 + | async fn rest_json_malformed_range_integer_override_case0_malformed_request() {
|
2466 + | {
|
2467 + | #[allow(unused_mut)]
|
2468 + | let mut http_request = ::http::Request::builder()
|
2469 + | .uri("/MalformedRangeOverride")
|
2470 + | .method("POST")
|
2471 + | .header("content-type", "application/json")
|
2472 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2473 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2474 + | "{ \"integer\" : 3 }".as_bytes(),
|
2475 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2476 + | )),
|
2477 + | ))
|
2478 + | .unwrap();
|
2479 + | #[allow(unused_mut)]
|
2480 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2481 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2482 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2483 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2484 + | let sender = sender.clone();
|
2485 + | async move {
|
2486 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2487 + | sender.send(()).await.expect("receiver dropped early");
|
2488 + | result
|
2489 + | }
|
2490 + | })
|
2491 + | .build_unchecked();
|
2492 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2493 + | .await
|
2494 + | .expect("unable to make an HTTP request");
|
2495 + | ::pretty_assertions::assert_eq!(
|
2496 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2497 + | http_response.status()
|
2498 + | );
|
2499 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2500 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2501 + | http_response.headers(),
|
2502 + | expected_headers,
|
2503 + | ));
|
2504 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2505 + | .await
|
2506 + | .expect("unable to extract body to bytes");
|
2507 + | ::aws_smithy_protocol_test::assert_ok(
|
2508 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/integer' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/integer' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/integer\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2509 + | );
|
2510 + | }
|
2511 + | }
|
2512 + |
|
2513 + | /// When a integer member does not fit within range bounds,
|
2514 + | /// the response should be a 400 ValidationException.
|
2515 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case1
|
2516 + | #[::tokio::test]
|
2517 + | #[::tracing_test::traced_test]
|
2518 + | async fn rest_json_malformed_range_integer_override_case1_malformed_request() {
|
2519 + | {
|
2520 + | #[allow(unused_mut)]
|
2521 + | let mut http_request = ::http::Request::builder()
|
2522 + | .uri("/MalformedRangeOverride")
|
2523 + | .method("POST")
|
2524 + | .header("content-type", "application/json")
|
2525 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2526 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2527 + | "{ \"integer\" : 7 }".as_bytes(),
|
2528 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2529 + | )),
|
2530 + | ))
|
2531 + | .unwrap();
|
2532 + | #[allow(unused_mut)]
|
2533 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2534 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2535 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2536 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2537 + | let sender = sender.clone();
|
2538 + | async move {
|
2539 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2540 + | sender.send(()).await.expect("receiver dropped early");
|
2541 + | result
|
2542 + | }
|
2543 + | })
|
2544 + | .build_unchecked();
|
2545 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2546 + | .await
|
2547 + | .expect("unable to make an HTTP request");
|
2548 + | ::pretty_assertions::assert_eq!(
|
2549 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2550 + | http_response.status()
|
2551 + | );
|
2552 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2553 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2554 + | http_response.headers(),
|
2555 + | expected_headers,
|
2556 + | ));
|
2557 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2558 + | .await
|
2559 + | .expect("unable to extract body to bytes");
|
2560 + | ::aws_smithy_protocol_test::assert_ok(
|
2561 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/integer' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/integer' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/integer\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2562 + | );
|
2563 + | }
|
2564 + | }
|
2565 + |
|
2566 + | /// When a integer member does not fit within range bounds,
|
2567 + | /// the response should be a 400 ValidationException.
|
2568 + | /// Test ID: RestJsonMalformedRangeMinIntegerOverride
|
2569 + | #[::tokio::test]
|
2570 + | #[::tracing_test::traced_test]
|
2571 + | async fn rest_json_malformed_range_min_integer_override_malformed_request() {
|
2572 + | {
|
2573 + | #[allow(unused_mut)]
|
2574 + | let mut http_request = ::http::Request::builder()
|
2575 + | .uri("/MalformedRangeOverride")
|
2576 + | .method("POST")
|
2577 + | .header("content-type", "application/json")
|
2578 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2579 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2580 + | "{ \"minInteger\" : 3 }".as_bytes(),
|
2581 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2582 + | )),
|
2583 + | ))
|
2584 + | .unwrap();
|
2585 + | #[allow(unused_mut)]
|
2586 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2587 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2588 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2589 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2590 + | let sender = sender.clone();
|
2591 + | async move {
|
2592 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2593 + | sender.send(()).await.expect("receiver dropped early");
|
2594 + | result
|
2595 + | }
|
2596 + | })
|
2597 + | .build_unchecked();
|
2598 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2599 + | .await
|
2600 + | .expect("unable to make an HTTP request");
|
2601 + | ::pretty_assertions::assert_eq!(
|
2602 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2603 + | http_response.status()
|
2604 + | );
|
2605 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2606 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2607 + | http_response.headers(),
|
2608 + | expected_headers,
|
2609 + | ));
|
2610 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2611 + | .await
|
2612 + | .expect("unable to extract body to bytes");
|
2613 + | ::aws_smithy_protocol_test::assert_ok(
|
2614 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minInteger' failed to satisfy constraint: Member must be greater than or equal to 4\",\n \"fieldList\" : [{\"message\": \"Value at '/minInteger' failed to satisfy constraint: Member must be greater than or equal to 4\", \"path\": \"/minInteger\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2615 + | );
|
2616 + | }
|
2617 + | }
|
2618 + |
|
2619 + | /// When a integer member does not fit within range bounds,
|
2620 + | /// the response should be a 400 ValidationException.
|
2621 + | /// Test ID: RestJsonMalformedRangeMaxIntegerOverride
|
2622 + | #[::tokio::test]
|
2623 + | #[::tracing_test::traced_test]
|
2624 + | async fn rest_json_malformed_range_max_integer_override_malformed_request() {
|
2625 + | {
|
2626 + | #[allow(unused_mut)]
|
2627 + | let mut http_request = ::http::Request::builder()
|
2628 + | .uri("/MalformedRangeOverride")
|
2629 + | .method("POST")
|
2630 + | .header("content-type", "application/json")
|
2631 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2632 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2633 + | "{ \"maxInteger\" : 7 }".as_bytes(),
|
2634 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2635 + | )),
|
2636 + | ))
|
2637 + | .unwrap();
|
2638 + | #[allow(unused_mut)]
|
2639 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2640 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2641 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2642 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2643 + | let sender = sender.clone();
|
2644 + | async move {
|
2645 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2646 + | sender.send(()).await.expect("receiver dropped early");
|
2647 + | result
|
2648 + | }
|
2649 + | })
|
2650 + | .build_unchecked();
|
2651 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2652 + | .await
|
2653 + | .expect("unable to make an HTTP request");
|
2654 + | ::pretty_assertions::assert_eq!(
|
2655 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2656 + | http_response.status()
|
2657 + | );
|
2658 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2659 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2660 + | http_response.headers(),
|
2661 + | expected_headers,
|
2662 + | ));
|
2663 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2664 + | .await
|
2665 + | .expect("unable to extract body to bytes");
|
2666 + | ::aws_smithy_protocol_test::assert_ok(
|
2667 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxInteger' failed to satisfy constraint: Member must be less than or equal to 6\",\n \"fieldList\" : [{\"message\": \"Value at '/maxInteger' failed to satisfy constraint: Member must be less than or equal to 6\", \"path\": \"/maxInteger\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2668 + | );
|
2669 + | }
|
2670 + | }
|
2671 + |
|
2672 + | /// When a long member does not fit within range bounds,
|
2673 + | /// the response should be a 400 ValidationException.
|
2674 + | /// Test ID: RestJsonMalformedRangeLongOverride_case0
|
2675 + | #[::tokio::test]
|
2676 + | #[::tracing_test::traced_test]
|
2677 + | async fn rest_json_malformed_range_long_override_case0_malformed_request() {
|
2678 + | {
|
2679 + | #[allow(unused_mut)]
|
2680 + | let mut http_request = ::http::Request::builder()
|
2681 + | .uri("/MalformedRangeOverride")
|
2682 + | .method("POST")
|
2683 + | .header("content-type", "application/json")
|
2684 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2685 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2686 + | "{ \"long\" : 3 }".as_bytes(),
|
2687 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2688 + | )),
|
2689 + | ))
|
2690 + | .unwrap();
|
2691 + | #[allow(unused_mut)]
|
2692 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2693 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2694 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2695 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2696 + | let sender = sender.clone();
|
2697 + | async move {
|
2698 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2699 + | sender.send(()).await.expect("receiver dropped early");
|
2700 + | result
|
2701 + | }
|
2702 + | })
|
2703 + | .build_unchecked();
|
2704 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2705 + | .await
|
2706 + | .expect("unable to make an HTTP request");
|
2707 + | ::pretty_assertions::assert_eq!(
|
2708 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2709 + | http_response.status()
|
2710 + | );
|
2711 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2712 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2713 + | http_response.headers(),
|
2714 + | expected_headers,
|
2715 + | ));
|
2716 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2717 + | .await
|
2718 + | .expect("unable to extract body to bytes");
|
2719 + | ::aws_smithy_protocol_test::assert_ok(
|
2720 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/long' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/long' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/long\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2721 + | );
|
2722 + | }
|
2723 + | }
|
2724 + |
|
2725 + | /// When a long member does not fit within range bounds,
|
2726 + | /// the response should be a 400 ValidationException.
|
2727 + | /// Test ID: RestJsonMalformedRangeLongOverride_case1
|
2728 + | #[::tokio::test]
|
2729 + | #[::tracing_test::traced_test]
|
2730 + | async fn rest_json_malformed_range_long_override_case1_malformed_request() {
|
2731 + | {
|
2732 + | #[allow(unused_mut)]
|
2733 + | let mut http_request = ::http::Request::builder()
|
2734 + | .uri("/MalformedRangeOverride")
|
2735 + | .method("POST")
|
2736 + | .header("content-type", "application/json")
|
2737 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2738 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2739 + | "{ \"long\" : 7 }".as_bytes(),
|
2740 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2741 + | )),
|
2742 + | ))
|
2743 + | .unwrap();
|
2744 + | #[allow(unused_mut)]
|
2745 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2746 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2747 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2748 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2749 + | let sender = sender.clone();
|
2750 + | async move {
|
2751 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2752 + | sender.send(()).await.expect("receiver dropped early");
|
2753 + | result
|
2754 + | }
|
2755 + | })
|
2756 + | .build_unchecked();
|
2757 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2758 + | .await
|
2759 + | .expect("unable to make an HTTP request");
|
2760 + | ::pretty_assertions::assert_eq!(
|
2761 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2762 + | http_response.status()
|
2763 + | );
|
2764 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2765 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2766 + | http_response.headers(),
|
2767 + | expected_headers,
|
2768 + | ));
|
2769 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2770 + | .await
|
2771 + | .expect("unable to extract body to bytes");
|
2772 + | ::aws_smithy_protocol_test::assert_ok(
|
2773 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/long' failed to satisfy constraint: Member must be between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/long' failed to satisfy constraint: Member must be between 4 and 6, inclusive\", \"path\": \"/long\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2774 + | );
|
2775 + | }
|
2776 + | }
|
2777 + |
|
2778 + | /// When a long member does not fit within range bounds,
|
2779 + | /// the response should be a 400 ValidationException.
|
2780 + | /// Test ID: RestJsonMalformedRangeMinLongOverride
|
2781 + | #[::tokio::test]
|
2782 + | #[::tracing_test::traced_test]
|
2783 + | async fn rest_json_malformed_range_min_long_override_malformed_request() {
|
2784 + | {
|
2785 + | #[allow(unused_mut)]
|
2786 + | let mut http_request = ::http::Request::builder()
|
2787 + | .uri("/MalformedRangeOverride")
|
2788 + | .method("POST")
|
2789 + | .header("content-type", "application/json")
|
2790 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2791 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2792 + | "{ \"minLong\" : 3 }".as_bytes(),
|
2793 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2794 + | )),
|
2795 + | ))
|
2796 + | .unwrap();
|
2797 + | #[allow(unused_mut)]
|
2798 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2799 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2800 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2801 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2802 + | let sender = sender.clone();
|
2803 + | async move {
|
2804 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2805 + | sender.send(()).await.expect("receiver dropped early");
|
2806 + | result
|
2807 + | }
|
2808 + | })
|
2809 + | .build_unchecked();
|
2810 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2811 + | .await
|
2812 + | .expect("unable to make an HTTP request");
|
2813 + | ::pretty_assertions::assert_eq!(
|
2814 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2815 + | http_response.status()
|
2816 + | );
|
2817 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2818 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2819 + | http_response.headers(),
|
2820 + | expected_headers,
|
2821 + | ));
|
2822 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2823 + | .await
|
2824 + | .expect("unable to extract body to bytes");
|
2825 + | ::aws_smithy_protocol_test::assert_ok(
|
2826 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minLong' failed to satisfy constraint: Member must be greater than or equal to 4\",\n \"fieldList\" : [{\"message\": \"Value at '/minLong' failed to satisfy constraint: Member must be greater than or equal to 4\", \"path\": \"/minLong\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2827 + | );
|
2828 + | }
|
2829 + | }
|
2830 + |
|
2831 + | /// When a long member does not fit within range bounds,
|
2832 + | /// the response should be a 400 ValidationException.
|
2833 + | /// Test ID: RestJsonMalformedRangeMaxLongOverride
|
2834 + | #[::tokio::test]
|
2835 + | #[::tracing_test::traced_test]
|
2836 + | async fn rest_json_malformed_range_max_long_override_malformed_request() {
|
2837 + | {
|
2838 + | #[allow(unused_mut)]
|
2839 + | let mut http_request = ::http::Request::builder()
|
2840 + | .uri("/MalformedRangeOverride")
|
2841 + | .method("POST")
|
2842 + | .header("content-type", "application/json")
|
2843 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
2844 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
2845 + | "{ \"maxLong\" : 7 }".as_bytes(),
|
2846 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2847 + | )),
|
2848 + | ))
|
2849 + | .unwrap();
|
2850 + | #[allow(unused_mut)]
|
2851 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2852 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2853 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2854 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2855 + | let sender = sender.clone();
|
2856 + | async move {
|
2857 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOverrideOutput, crate::error::MalformedRangeOverrideError> };
|
2858 + | sender.send(()).await.expect("receiver dropped early");
|
2859 + | result
|
2860 + | }
|
2861 + | })
|
2862 + | .build_unchecked();
|
2863 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2864 + | .await
|
2865 + | .expect("unable to make an HTTP request");
|
2866 + | ::pretty_assertions::assert_eq!(
|
2867 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2868 + | http_response.status()
|
2869 + | );
|
2870 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2871 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2872 + | http_response.headers(),
|
2873 + | expected_headers,
|
2874 + | ));
|
2875 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2876 + | .await
|
2877 + | .expect("unable to extract body to bytes");
|
2878 + | ::aws_smithy_protocol_test::assert_ok(
|
2879 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxLong' failed to satisfy constraint: Member must be less than or equal to 6\",\n \"fieldList\" : [{\"message\": \"Value at '/maxLong' failed to satisfy constraint: Member must be less than or equal to 6\", \"path\": \"/maxLong\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2880 + | );
|
2881 + | }
|
2882 + | }
|
2883 + | }
|
2884 + |
|
2885 + | ::pin_project_lite::pin_project! {
|
2886 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2887 + | /// [`MalformedRangeInput`](crate::input::MalformedRangeInput) using modelled bindings.
|
2888 + | pub struct MalformedRangeInputFuture {
|
2889 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRangeInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
2890 + | }
|
2891 + | }
|
2892 + |
|
2893 + | impl std::future::Future for MalformedRangeInputFuture {
|
2894 + | type Output = Result<
|
2895 + | crate::input::MalformedRangeInput,
|
2896 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
2897 + | >;
|
2898 + |
|
2899 + | fn poll(
|
2900 + | self: std::pin::Pin<&mut Self>,
|
2901 + | cx: &mut std::task::Context<'_>,
|
2902 + | ) -> std::task::Poll<Self::Output> {
|
2903 + | let this = self.project();
|
2904 + | this.inner.as_mut().poll(cx)
|
2905 + | }
|
2906 + | }
|
2907 + |
|
2908 + | impl<B>
|
2909 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
2910 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
2911 + | B,
|
2912 + | > for crate::input::MalformedRangeInput
|
2913 + | where
|
2914 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
2915 + | B: 'static,
|
2916 + |
|
2917 + | B::Data: Send,
|
2918 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
2919 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
2920 + | {
|
2921 + | type Rejection =
|
2922 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
2923 + | type Future = MalformedRangeInputFuture;
|
2924 + |
|
2925 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2926 + | let fut = async move {
|
2927 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
2928 + | request.headers(),
|
2929 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
2930 + | ) {
|
2931 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
2932 + | }
|
2933 + | crate::protocol_serde::shape_malformed_range::de_malformed_range_http_request(request)
|
2934 + | .await
|
2935 + | };
|
2936 + | use ::futures_util::future::TryFutureExt;
|
2937 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
2938 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2939 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
2940 + | });
|
2941 + | MalformedRangeInputFuture {
|
2942 + | inner: Box::pin(fut),
|
2943 + | }
|
2944 + | }
|
2945 + | }
|
2946 + | impl
|
2947 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2948 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
2949 + | > for crate::output::MalformedRangeOutput
|
2950 + | {
|
2951 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2952 + | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_response(self)
|
2953 + | {
|
2954 + | Ok(response) => response,
|
2955 + | Err(e) => {
|
2956 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2957 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
2958 + | }
|
2959 + | }
|
2960 + | }
|
2961 + | }
|
2962 + | impl
|
2963 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
2964 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
2965 + | > for crate::error::MalformedRangeError
|
2966 + | {
|
2967 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
2968 + | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_error(&self) {
|
2969 + | Ok(mut response) => {
|
2970 + | response.extensions_mut().insert(
|
2971 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
2972 + | self.name(),
|
2973 + | ),
|
2974 + | );
|
2975 + | response
|
2976 + | }
|
2977 + | Err(e) => {
|
2978 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2979 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
2980 + | }
|
2981 + | }
|
2982 + | }
|
2983 + | }
|
2984 + |
|
2985 + | #[allow(unreachable_code, unused_variables)]
|
2986 + | #[cfg(test)]
|
2987 + | mod malformed_range_test {
|
2988 + |
|
2989 + | /// When a byte member does not fit within range bounds,
|
2990 + | /// the response should be a 400 ValidationException.
|
2991 + | /// Test ID: RestJsonMalformedRangeByte_case0
|
2992 + | #[::tokio::test]
|
2993 + | #[::tracing_test::traced_test]
|
2994 + | async fn rest_json_malformed_range_byte_case0_malformed_request() {
|
2995 + | {
|
2996 + | #[allow(unused_mut)]
|
2997 + | let mut http_request = ::http::Request::builder()
|
2998 + | .uri("/MalformedRange")
|
2999 + | .method("POST")
|
3000 + | .header("content-type", "application/json")
|
3001 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3002 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3003 + | "{ \"byte\" : 1 }".as_bytes(),
|
3004 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3005 + | )),
|
3006 + | ))
|
3007 + | .unwrap();
|
3008 + | #[allow(unused_mut)]
|
3009 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3010 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3011 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3012 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3013 + | let sender = sender.clone();
|
3014 + | async move {
|
3015 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3016 + | sender.send(()).await.expect("receiver dropped early");
|
3017 + | result
|
3018 + | }
|
3019 + | })
|
3020 + | .build_unchecked();
|
3021 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3022 + | .await
|
3023 + | .expect("unable to make an HTTP request");
|
3024 + | ::pretty_assertions::assert_eq!(
|
3025 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3026 + | http_response.status()
|
3027 + | );
|
3028 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3029 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3030 + | http_response.headers(),
|
3031 + | expected_headers,
|
3032 + | ));
|
3033 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3034 + | .await
|
3035 + | .expect("unable to extract body to bytes");
|
3036 + | ::aws_smithy_protocol_test::assert_ok(
|
3037 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/byte' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/byte' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/byte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3038 + | );
|
3039 + | }
|
3040 + | }
|
3041 + |
|
3042 + | /// When a byte member does not fit within range bounds,
|
3043 + | /// the response should be a 400 ValidationException.
|
3044 + | /// Test ID: RestJsonMalformedRangeByte_case1
|
3045 + | #[::tokio::test]
|
3046 + | #[::tracing_test::traced_test]
|
3047 + | async fn rest_json_malformed_range_byte_case1_malformed_request() {
|
3048 + | {
|
3049 + | #[allow(unused_mut)]
|
3050 + | let mut http_request = ::http::Request::builder()
|
3051 + | .uri("/MalformedRange")
|
3052 + | .method("POST")
|
3053 + | .header("content-type", "application/json")
|
3054 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3055 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3056 + | "{ \"byte\" : 9 }".as_bytes(),
|
3057 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3058 + | )),
|
3059 + | ))
|
3060 + | .unwrap();
|
3061 + | #[allow(unused_mut)]
|
3062 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3063 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3064 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3065 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3066 + | let sender = sender.clone();
|
3067 + | async move {
|
3068 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3069 + | sender.send(()).await.expect("receiver dropped early");
|
3070 + | result
|
3071 + | }
|
3072 + | })
|
3073 + | .build_unchecked();
|
3074 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3075 + | .await
|
3076 + | .expect("unable to make an HTTP request");
|
3077 + | ::pretty_assertions::assert_eq!(
|
3078 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3079 + | http_response.status()
|
3080 + | );
|
3081 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3082 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3083 + | http_response.headers(),
|
3084 + | expected_headers,
|
3085 + | ));
|
3086 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3087 + | .await
|
3088 + | .expect("unable to extract body to bytes");
|
3089 + | ::aws_smithy_protocol_test::assert_ok(
|
3090 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/byte' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/byte' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/byte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3091 + | );
|
3092 + | }
|
3093 + | }
|
3094 + |
|
3095 + | /// When a byte member does not fit within range bounds,
|
3096 + | /// the response should be a 400 ValidationException.
|
3097 + | /// Test ID: RestJsonMalformedRangeMinByte
|
3098 + | #[::tokio::test]
|
3099 + | #[::tracing_test::traced_test]
|
3100 + | async fn rest_json_malformed_range_min_byte_malformed_request() {
|
3101 + | {
|
3102 + | #[allow(unused_mut)]
|
3103 + | let mut http_request = ::http::Request::builder()
|
3104 + | .uri("/MalformedRange")
|
3105 + | .method("POST")
|
3106 + | .header("content-type", "application/json")
|
3107 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3108 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3109 + | "{ \"minByte\" : 1 }".as_bytes(),
|
3110 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3111 + | )),
|
3112 + | ))
|
3113 + | .unwrap();
|
3114 + | #[allow(unused_mut)]
|
3115 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3116 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3117 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3118 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3119 + | let sender = sender.clone();
|
3120 + | async move {
|
3121 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3122 + | sender.send(()).await.expect("receiver dropped early");
|
3123 + | result
|
3124 + | }
|
3125 + | })
|
3126 + | .build_unchecked();
|
3127 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3128 + | .await
|
3129 + | .expect("unable to make an HTTP request");
|
3130 + | ::pretty_assertions::assert_eq!(
|
3131 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3132 + | http_response.status()
|
3133 + | );
|
3134 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3135 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3136 + | http_response.headers(),
|
3137 + | expected_headers,
|
3138 + | ));
|
3139 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3140 + | .await
|
3141 + | .expect("unable to extract body to bytes");
|
3142 + | ::aws_smithy_protocol_test::assert_ok(
|
3143 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minByte' failed to satisfy constraint: Member must be greater than or equal to 2\",\n \"fieldList\" : [{\"message\": \"Value at '/minByte' failed to satisfy constraint: Member must be greater than or equal to 2\", \"path\": \"/minByte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3144 + | );
|
3145 + | }
|
3146 + | }
|
3147 + |
|
3148 + | /// When a byte member does not fit within range bounds,
|
3149 + | /// the response should be a 400 ValidationException.
|
3150 + | /// Test ID: RestJsonMalformedRangeMaxByte
|
3151 + | #[::tokio::test]
|
3152 + | #[::tracing_test::traced_test]
|
3153 + | async fn rest_json_malformed_range_max_byte_malformed_request() {
|
3154 + | {
|
3155 + | #[allow(unused_mut)]
|
3156 + | let mut http_request = ::http::Request::builder()
|
3157 + | .uri("/MalformedRange")
|
3158 + | .method("POST")
|
3159 + | .header("content-type", "application/json")
|
3160 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3161 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3162 + | "{ \"maxByte\" : 9 }".as_bytes(),
|
3163 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3164 + | )),
|
3165 + | ))
|
3166 + | .unwrap();
|
3167 + | #[allow(unused_mut)]
|
3168 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3169 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3170 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3171 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3172 + | let sender = sender.clone();
|
3173 + | async move {
|
3174 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3175 + | sender.send(()).await.expect("receiver dropped early");
|
3176 + | result
|
3177 + | }
|
3178 + | })
|
3179 + | .build_unchecked();
|
3180 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3181 + | .await
|
3182 + | .expect("unable to make an HTTP request");
|
3183 + | ::pretty_assertions::assert_eq!(
|
3184 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3185 + | http_response.status()
|
3186 + | );
|
3187 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3188 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3189 + | http_response.headers(),
|
3190 + | expected_headers,
|
3191 + | ));
|
3192 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3193 + | .await
|
3194 + | .expect("unable to extract body to bytes");
|
3195 + | ::aws_smithy_protocol_test::assert_ok(
|
3196 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxByte' failed to satisfy constraint: Member must be less than or equal to 8\",\n \"fieldList\" : [{\"message\": \"Value at '/maxByte' failed to satisfy constraint: Member must be less than or equal to 8\", \"path\": \"/maxByte\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3197 + | );
|
3198 + | }
|
3199 + | }
|
3200 + |
|
3201 + | /// When a float member does not fit within range bounds,
|
3202 + | /// the response should be a 400 ValidationException.
|
3203 + | /// Test ID: RestJsonMalformedRangeFloat_case0
|
3204 + | #[::tokio::test]
|
3205 + | #[::tracing_test::traced_test]
|
3206 + | #[should_panic]
|
3207 + | async fn rest_json_malformed_range_float_case0_malformed_request() {
|
3208 + | {
|
3209 + | #[allow(unused_mut)]
|
3210 + | let mut http_request = ::http::Request::builder()
|
3211 + | .uri("/MalformedRange")
|
3212 + | .method("POST")
|
3213 + | .header("content-type", "application/json")
|
3214 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3215 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3216 + | "{ \"float\" : 2.1 }".as_bytes(),
|
3217 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3218 + | )),
|
3219 + | ))
|
3220 + | .unwrap();
|
3221 + | #[allow(unused_mut)]
|
3222 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3223 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3224 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3225 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3226 + | let sender = sender.clone();
|
3227 + | async move {
|
3228 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3229 + | sender.send(()).await.expect("receiver dropped early");
|
3230 + | result
|
3231 + | }
|
3232 + | })
|
3233 + | .build_unchecked();
|
3234 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3235 + | .await
|
3236 + | .expect("unable to make an HTTP request");
|
3237 + | ::pretty_assertions::assert_eq!(
|
3238 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3239 + | http_response.status()
|
3240 + | );
|
3241 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3242 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3243 + | http_response.headers(),
|
3244 + | expected_headers,
|
3245 + | ));
|
3246 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3247 + | .await
|
3248 + | .expect("unable to extract body to bytes");
|
3249 + | ::aws_smithy_protocol_test::assert_ok(
|
3250 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/float' failed to satisfy constraint: Member must be between 2.2 and 8.8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/float' failed to satisfy constraint: Member must be between 2.2 and 8.8, inclusive\", \"path\": \"/float\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3251 + | );
|
3252 + | }
|
3253 + | }
|
3254 + |
|
3255 + | /// When a float member does not fit within range bounds,
|
3256 + | /// the response should be a 400 ValidationException.
|
3257 + | /// Test ID: RestJsonMalformedRangeFloat_case1
|
3258 + | #[::tokio::test]
|
3259 + | #[::tracing_test::traced_test]
|
3260 + | #[should_panic]
|
3261 + | async fn rest_json_malformed_range_float_case1_malformed_request() {
|
3262 + | {
|
3263 + | #[allow(unused_mut)]
|
3264 + | let mut http_request = ::http::Request::builder()
|
3265 + | .uri("/MalformedRange")
|
3266 + | .method("POST")
|
3267 + | .header("content-type", "application/json")
|
3268 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3269 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3270 + | "{ \"float\" : 8.9 }".as_bytes(),
|
3271 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3272 + | )),
|
3273 + | ))
|
3274 + | .unwrap();
|
3275 + | #[allow(unused_mut)]
|
3276 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3277 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3278 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3279 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3280 + | let sender = sender.clone();
|
3281 + | async move {
|
3282 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3283 + | sender.send(()).await.expect("receiver dropped early");
|
3284 + | result
|
3285 + | }
|
3286 + | })
|
3287 + | .build_unchecked();
|
3288 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3289 + | .await
|
3290 + | .expect("unable to make an HTTP request");
|
3291 + | ::pretty_assertions::assert_eq!(
|
3292 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3293 + | http_response.status()
|
3294 + | );
|
3295 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3296 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3297 + | http_response.headers(),
|
3298 + | expected_headers,
|
3299 + | ));
|
3300 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3301 + | .await
|
3302 + | .expect("unable to extract body to bytes");
|
3303 + | ::aws_smithy_protocol_test::assert_ok(
|
3304 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/float' failed to satisfy constraint: Member must be between 2.2 and 8.8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/float' failed to satisfy constraint: Member must be between 2.2 and 8.8, inclusive\", \"path\": \"/float\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3305 + | );
|
3306 + | }
|
3307 + | }
|
3308 + |
|
3309 + | /// When a float member does not fit within range bounds,
|
3310 + | /// the response should be a 400 ValidationException.
|
3311 + | /// Test ID: RestJsonMalformedRangeMinFloat
|
3312 + | #[::tokio::test]
|
3313 + | #[::tracing_test::traced_test]
|
3314 + | #[should_panic]
|
3315 + | async fn rest_json_malformed_range_min_float_malformed_request() {
|
3316 + | {
|
3317 + | #[allow(unused_mut)]
|
3318 + | let mut http_request = ::http::Request::builder()
|
3319 + | .uri("/MalformedRange")
|
3320 + | .method("POST")
|
3321 + | .header("content-type", "application/json")
|
3322 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3323 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3324 + | "{ \"minFloat\" : 2.1 }".as_bytes(),
|
3325 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3326 + | )),
|
3327 + | ))
|
3328 + | .unwrap();
|
3329 + | #[allow(unused_mut)]
|
3330 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3331 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3332 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3333 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3334 + | let sender = sender.clone();
|
3335 + | async move {
|
3336 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3337 + | sender.send(()).await.expect("receiver dropped early");
|
3338 + | result
|
3339 + | }
|
3340 + | })
|
3341 + | .build_unchecked();
|
3342 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3343 + | .await
|
3344 + | .expect("unable to make an HTTP request");
|
3345 + | ::pretty_assertions::assert_eq!(
|
3346 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3347 + | http_response.status()
|
3348 + | );
|
3349 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3350 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3351 + | http_response.headers(),
|
3352 + | expected_headers,
|
3353 + | ));
|
3354 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3355 + | .await
|
3356 + | .expect("unable to extract body to bytes");
|
3357 + | ::aws_smithy_protocol_test::assert_ok(
|
3358 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minFloat' failed to satisfy constraint: Member must be greater than or equal to 2.2\",\n \"fieldList\" : [{\"message\": \"Value at '/minFloat' failed to satisfy constraint: Member must be greater than or equal to 2.2\", \"path\": \"/minFloat\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3359 + | );
|
3360 + | }
|
3361 + | }
|
3362 + |
|
3363 + | /// When a float member does not fit within range bounds,
|
3364 + | /// the response should be a 400 ValidationException.
|
3365 + | /// Test ID: RestJsonMalformedRangeMaxFloat
|
3366 + | #[::tokio::test]
|
3367 + | #[::tracing_test::traced_test]
|
3368 + | #[should_panic]
|
3369 + | async fn rest_json_malformed_range_max_float_malformed_request() {
|
3370 + | {
|
3371 + | #[allow(unused_mut)]
|
3372 + | let mut http_request = ::http::Request::builder()
|
3373 + | .uri("/MalformedRange")
|
3374 + | .method("POST")
|
3375 + | .header("content-type", "application/json")
|
3376 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3377 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3378 + | "{ \"maxFloat\" : 8.9 }".as_bytes(),
|
3379 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3380 + | )),
|
3381 + | ))
|
3382 + | .unwrap();
|
3383 + | #[allow(unused_mut)]
|
3384 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3385 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3386 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3387 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3388 + | let sender = sender.clone();
|
3389 + | async move {
|
3390 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3391 + | sender.send(()).await.expect("receiver dropped early");
|
3392 + | result
|
3393 + | }
|
3394 + | })
|
3395 + | .build_unchecked();
|
3396 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3397 + | .await
|
3398 + | .expect("unable to make an HTTP request");
|
3399 + | ::pretty_assertions::assert_eq!(
|
3400 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3401 + | http_response.status()
|
3402 + | );
|
3403 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3404 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3405 + | http_response.headers(),
|
3406 + | expected_headers,
|
3407 + | ));
|
3408 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3409 + | .await
|
3410 + | .expect("unable to extract body to bytes");
|
3411 + | ::aws_smithy_protocol_test::assert_ok(
|
3412 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxFloat' failed to satisfy constraint: Member must be less than or equal to 8.8\",\n \"fieldList\" : [{\"message\": \"Value at '/maxFloat' failed to satisfy constraint: Member must be less than or equal to 8.8\", \"path\": \"/maxFloat\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3413 + | );
|
3414 + | }
|
3415 + | }
|
3416 + |
|
3417 + | /// When a short member does not fit within range bounds,
|
3418 + | /// the response should be a 400 ValidationException.
|
3419 + | /// Test ID: RestJsonMalformedRangeShort_case0
|
3420 + | #[::tokio::test]
|
3421 + | #[::tracing_test::traced_test]
|
3422 + | async fn rest_json_malformed_range_short_case0_malformed_request() {
|
3423 + | {
|
3424 + | #[allow(unused_mut)]
|
3425 + | let mut http_request = ::http::Request::builder()
|
3426 + | .uri("/MalformedRange")
|
3427 + | .method("POST")
|
3428 + | .header("content-type", "application/json")
|
3429 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3430 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3431 + | "{ \"short\" : 1 }".as_bytes(),
|
3432 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3433 + | )),
|
3434 + | ))
|
3435 + | .unwrap();
|
3436 + | #[allow(unused_mut)]
|
3437 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3438 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3439 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3440 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3441 + | let sender = sender.clone();
|
3442 + | async move {
|
3443 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3444 + | sender.send(()).await.expect("receiver dropped early");
|
3445 + | result
|
3446 + | }
|
3447 + | })
|
3448 + | .build_unchecked();
|
3449 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3450 + | .await
|
3451 + | .expect("unable to make an HTTP request");
|
3452 + | ::pretty_assertions::assert_eq!(
|
3453 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3454 + | http_response.status()
|
3455 + | );
|
3456 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3457 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3458 + | http_response.headers(),
|
3459 + | expected_headers,
|
3460 + | ));
|
3461 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3462 + | .await
|
3463 + | .expect("unable to extract body to bytes");
|
3464 + | ::aws_smithy_protocol_test::assert_ok(
|
3465 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/short' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/short' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/short\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3466 + | );
|
3467 + | }
|
3468 + | }
|
3469 + |
|
3470 + | /// When a short member does not fit within range bounds,
|
3471 + | /// the response should be a 400 ValidationException.
|
3472 + | /// Test ID: RestJsonMalformedRangeShort_case1
|
3473 + | #[::tokio::test]
|
3474 + | #[::tracing_test::traced_test]
|
3475 + | async fn rest_json_malformed_range_short_case1_malformed_request() {
|
3476 + | {
|
3477 + | #[allow(unused_mut)]
|
3478 + | let mut http_request = ::http::Request::builder()
|
3479 + | .uri("/MalformedRange")
|
3480 + | .method("POST")
|
3481 + | .header("content-type", "application/json")
|
3482 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3483 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3484 + | "{ \"short\" : 9 }".as_bytes(),
|
3485 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3486 + | )),
|
3487 + | ))
|
3488 + | .unwrap();
|
3489 + | #[allow(unused_mut)]
|
3490 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3491 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3492 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3493 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3494 + | let sender = sender.clone();
|
3495 + | async move {
|
3496 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3497 + | sender.send(()).await.expect("receiver dropped early");
|
3498 + | result
|
3499 + | }
|
3500 + | })
|
3501 + | .build_unchecked();
|
3502 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3503 + | .await
|
3504 + | .expect("unable to make an HTTP request");
|
3505 + | ::pretty_assertions::assert_eq!(
|
3506 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3507 + | http_response.status()
|
3508 + | );
|
3509 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3510 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3511 + | http_response.headers(),
|
3512 + | expected_headers,
|
3513 + | ));
|
3514 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3515 + | .await
|
3516 + | .expect("unable to extract body to bytes");
|
3517 + | ::aws_smithy_protocol_test::assert_ok(
|
3518 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/short' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/short' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/short\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3519 + | );
|
3520 + | }
|
3521 + | }
|
3522 + |
|
3523 + | /// When a short member does not fit within range bounds,
|
3524 + | /// the response should be a 400 ValidationException.
|
3525 + | /// Test ID: RestJsonMalformedRangeMinShort
|
3526 + | #[::tokio::test]
|
3527 + | #[::tracing_test::traced_test]
|
3528 + | async fn rest_json_malformed_range_min_short_malformed_request() {
|
3529 + | {
|
3530 + | #[allow(unused_mut)]
|
3531 + | let mut http_request = ::http::Request::builder()
|
3532 + | .uri("/MalformedRange")
|
3533 + | .method("POST")
|
3534 + | .header("content-type", "application/json")
|
3535 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3536 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3537 + | "{ \"minShort\" : 1 }".as_bytes(),
|
3538 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3539 + | )),
|
3540 + | ))
|
3541 + | .unwrap();
|
3542 + | #[allow(unused_mut)]
|
3543 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3544 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3545 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3546 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3547 + | let sender = sender.clone();
|
3548 + | async move {
|
3549 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3550 + | sender.send(()).await.expect("receiver dropped early");
|
3551 + | result
|
3552 + | }
|
3553 + | })
|
3554 + | .build_unchecked();
|
3555 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3556 + | .await
|
3557 + | .expect("unable to make an HTTP request");
|
3558 + | ::pretty_assertions::assert_eq!(
|
3559 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3560 + | http_response.status()
|
3561 + | );
|
3562 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3563 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3564 + | http_response.headers(),
|
3565 + | expected_headers,
|
3566 + | ));
|
3567 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3568 + | .await
|
3569 + | .expect("unable to extract body to bytes");
|
3570 + | ::aws_smithy_protocol_test::assert_ok(
|
3571 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minShort' failed to satisfy constraint: Member must be greater than or equal to 2\",\n \"fieldList\" : [{\"message\": \"Value at '/minShort' failed to satisfy constraint: Member must be greater than or equal to 2\", \"path\": \"/minShort\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3572 + | );
|
3573 + | }
|
3574 + | }
|
3575 + |
|
3576 + | /// When a short member does not fit within range bounds,
|
3577 + | /// the response should be a 400 ValidationException.
|
3578 + | /// Test ID: RestJsonMalformedRangeMaxShort
|
3579 + | #[::tokio::test]
|
3580 + | #[::tracing_test::traced_test]
|
3581 + | async fn rest_json_malformed_range_max_short_malformed_request() {
|
3582 + | {
|
3583 + | #[allow(unused_mut)]
|
3584 + | let mut http_request = ::http::Request::builder()
|
3585 + | .uri("/MalformedRange")
|
3586 + | .method("POST")
|
3587 + | .header("content-type", "application/json")
|
3588 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3589 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3590 + | "{ \"maxShort\" : 9 }".as_bytes(),
|
3591 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3592 + | )),
|
3593 + | ))
|
3594 + | .unwrap();
|
3595 + | #[allow(unused_mut)]
|
3596 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3597 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3598 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3599 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3600 + | let sender = sender.clone();
|
3601 + | async move {
|
3602 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3603 + | sender.send(()).await.expect("receiver dropped early");
|
3604 + | result
|
3605 + | }
|
3606 + | })
|
3607 + | .build_unchecked();
|
3608 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3609 + | .await
|
3610 + | .expect("unable to make an HTTP request");
|
3611 + | ::pretty_assertions::assert_eq!(
|
3612 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3613 + | http_response.status()
|
3614 + | );
|
3615 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3616 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3617 + | http_response.headers(),
|
3618 + | expected_headers,
|
3619 + | ));
|
3620 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3621 + | .await
|
3622 + | .expect("unable to extract body to bytes");
|
3623 + | ::aws_smithy_protocol_test::assert_ok(
|
3624 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxShort' failed to satisfy constraint: Member must be less than or equal to 8\",\n \"fieldList\" : [{\"message\": \"Value at '/maxShort' failed to satisfy constraint: Member must be less than or equal to 8\", \"path\": \"/maxShort\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3625 + | );
|
3626 + | }
|
3627 + | }
|
3628 + |
|
3629 + | /// When a integer member does not fit within range bounds,
|
3630 + | /// the response should be a 400 ValidationException.
|
3631 + | /// Test ID: RestJsonMalformedRangeInteger_case0
|
3632 + | #[::tokio::test]
|
3633 + | #[::tracing_test::traced_test]
|
3634 + | async fn rest_json_malformed_range_integer_case0_malformed_request() {
|
3635 + | {
|
3636 + | #[allow(unused_mut)]
|
3637 + | let mut http_request = ::http::Request::builder()
|
3638 + | .uri("/MalformedRange")
|
3639 + | .method("POST")
|
3640 + | .header("content-type", "application/json")
|
3641 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3642 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3643 + | "{ \"integer\" : 1 }".as_bytes(),
|
3644 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3645 + | )),
|
3646 + | ))
|
3647 + | .unwrap();
|
3648 + | #[allow(unused_mut)]
|
3649 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3650 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3651 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3652 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3653 + | let sender = sender.clone();
|
3654 + | async move {
|
3655 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3656 + | sender.send(()).await.expect("receiver dropped early");
|
3657 + | result
|
3658 + | }
|
3659 + | })
|
3660 + | .build_unchecked();
|
3661 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3662 + | .await
|
3663 + | .expect("unable to make an HTTP request");
|
3664 + | ::pretty_assertions::assert_eq!(
|
3665 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3666 + | http_response.status()
|
3667 + | );
|
3668 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3669 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3670 + | http_response.headers(),
|
3671 + | expected_headers,
|
3672 + | ));
|
3673 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3674 + | .await
|
3675 + | .expect("unable to extract body to bytes");
|
3676 + | ::aws_smithy_protocol_test::assert_ok(
|
3677 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/integer' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/integer' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/integer\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3678 + | );
|
3679 + | }
|
3680 + | }
|
3681 + |
|
3682 + | /// When a integer member does not fit within range bounds,
|
3683 + | /// the response should be a 400 ValidationException.
|
3684 + | /// Test ID: RestJsonMalformedRangeInteger_case1
|
3685 + | #[::tokio::test]
|
3686 + | #[::tracing_test::traced_test]
|
3687 + | async fn rest_json_malformed_range_integer_case1_malformed_request() {
|
3688 + | {
|
3689 + | #[allow(unused_mut)]
|
3690 + | let mut http_request = ::http::Request::builder()
|
3691 + | .uri("/MalformedRange")
|
3692 + | .method("POST")
|
3693 + | .header("content-type", "application/json")
|
3694 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3695 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3696 + | "{ \"integer\" : 9 }".as_bytes(),
|
3697 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3698 + | )),
|
3699 + | ))
|
3700 + | .unwrap();
|
3701 + | #[allow(unused_mut)]
|
3702 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3703 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3704 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3705 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3706 + | let sender = sender.clone();
|
3707 + | async move {
|
3708 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3709 + | sender.send(()).await.expect("receiver dropped early");
|
3710 + | result
|
3711 + | }
|
3712 + | })
|
3713 + | .build_unchecked();
|
3714 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3715 + | .await
|
3716 + | .expect("unable to make an HTTP request");
|
3717 + | ::pretty_assertions::assert_eq!(
|
3718 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3719 + | http_response.status()
|
3720 + | );
|
3721 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3722 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3723 + | http_response.headers(),
|
3724 + | expected_headers,
|
3725 + | ));
|
3726 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3727 + | .await
|
3728 + | .expect("unable to extract body to bytes");
|
3729 + | ::aws_smithy_protocol_test::assert_ok(
|
3730 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/integer' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/integer' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/integer\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3731 + | );
|
3732 + | }
|
3733 + | }
|
3734 + |
|
3735 + | /// When a integer member does not fit within range bounds,
|
3736 + | /// the response should be a 400 ValidationException.
|
3737 + | /// Test ID: RestJsonMalformedRangeMinInteger
|
3738 + | #[::tokio::test]
|
3739 + | #[::tracing_test::traced_test]
|
3740 + | async fn rest_json_malformed_range_min_integer_malformed_request() {
|
3741 + | {
|
3742 + | #[allow(unused_mut)]
|
3743 + | let mut http_request = ::http::Request::builder()
|
3744 + | .uri("/MalformedRange")
|
3745 + | .method("POST")
|
3746 + | .header("content-type", "application/json")
|
3747 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3748 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3749 + | "{ \"minInteger\" : 1 }".as_bytes(),
|
3750 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3751 + | )),
|
3752 + | ))
|
3753 + | .unwrap();
|
3754 + | #[allow(unused_mut)]
|
3755 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3756 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3757 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3758 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3759 + | let sender = sender.clone();
|
3760 + | async move {
|
3761 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3762 + | sender.send(()).await.expect("receiver dropped early");
|
3763 + | result
|
3764 + | }
|
3765 + | })
|
3766 + | .build_unchecked();
|
3767 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3768 + | .await
|
3769 + | .expect("unable to make an HTTP request");
|
3770 + | ::pretty_assertions::assert_eq!(
|
3771 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3772 + | http_response.status()
|
3773 + | );
|
3774 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3775 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3776 + | http_response.headers(),
|
3777 + | expected_headers,
|
3778 + | ));
|
3779 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3780 + | .await
|
3781 + | .expect("unable to extract body to bytes");
|
3782 + | ::aws_smithy_protocol_test::assert_ok(
|
3783 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minInteger' failed to satisfy constraint: Member must be greater than or equal to 2\",\n \"fieldList\" : [{\"message\": \"Value at '/minInteger' failed to satisfy constraint: Member must be greater than or equal to 2\", \"path\": \"/minInteger\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3784 + | );
|
3785 + | }
|
3786 + | }
|
3787 + |
|
3788 + | /// When a integer member does not fit within range bounds,
|
3789 + | /// the response should be a 400 ValidationException.
|
3790 + | /// Test ID: RestJsonMalformedRangeMaxInteger
|
3791 + | #[::tokio::test]
|
3792 + | #[::tracing_test::traced_test]
|
3793 + | async fn rest_json_malformed_range_max_integer_malformed_request() {
|
3794 + | {
|
3795 + | #[allow(unused_mut)]
|
3796 + | let mut http_request = ::http::Request::builder()
|
3797 + | .uri("/MalformedRange")
|
3798 + | .method("POST")
|
3799 + | .header("content-type", "application/json")
|
3800 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3801 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3802 + | "{ \"maxInteger\" : 9 }".as_bytes(),
|
3803 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3804 + | )),
|
3805 + | ))
|
3806 + | .unwrap();
|
3807 + | #[allow(unused_mut)]
|
3808 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3809 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3810 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3811 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3812 + | let sender = sender.clone();
|
3813 + | async move {
|
3814 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3815 + | sender.send(()).await.expect("receiver dropped early");
|
3816 + | result
|
3817 + | }
|
3818 + | })
|
3819 + | .build_unchecked();
|
3820 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3821 + | .await
|
3822 + | .expect("unable to make an HTTP request");
|
3823 + | ::pretty_assertions::assert_eq!(
|
3824 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3825 + | http_response.status()
|
3826 + | );
|
3827 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3828 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3829 + | http_response.headers(),
|
3830 + | expected_headers,
|
3831 + | ));
|
3832 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3833 + | .await
|
3834 + | .expect("unable to extract body to bytes");
|
3835 + | ::aws_smithy_protocol_test::assert_ok(
|
3836 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxInteger' failed to satisfy constraint: Member must be less than or equal to 8\",\n \"fieldList\" : [{\"message\": \"Value at '/maxInteger' failed to satisfy constraint: Member must be less than or equal to 8\", \"path\": \"/maxInteger\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3837 + | );
|
3838 + | }
|
3839 + | }
|
3840 + |
|
3841 + | /// When a long member does not fit within range bounds,
|
3842 + | /// the response should be a 400 ValidationException.
|
3843 + | /// Test ID: RestJsonMalformedRangeLong_case0
|
3844 + | #[::tokio::test]
|
3845 + | #[::tracing_test::traced_test]
|
3846 + | async fn rest_json_malformed_range_long_case0_malformed_request() {
|
3847 + | {
|
3848 + | #[allow(unused_mut)]
|
3849 + | let mut http_request = ::http::Request::builder()
|
3850 + | .uri("/MalformedRange")
|
3851 + | .method("POST")
|
3852 + | .header("content-type", "application/json")
|
3853 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3854 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3855 + | "{ \"long\" : 1 }".as_bytes(),
|
3856 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3857 + | )),
|
3858 + | ))
|
3859 + | .unwrap();
|
3860 + | #[allow(unused_mut)]
|
3861 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3862 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3863 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3864 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3865 + | let sender = sender.clone();
|
3866 + | async move {
|
3867 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3868 + | sender.send(()).await.expect("receiver dropped early");
|
3869 + | result
|
3870 + | }
|
3871 + | })
|
3872 + | .build_unchecked();
|
3873 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3874 + | .await
|
3875 + | .expect("unable to make an HTTP request");
|
3876 + | ::pretty_assertions::assert_eq!(
|
3877 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3878 + | http_response.status()
|
3879 + | );
|
3880 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3881 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3882 + | http_response.headers(),
|
3883 + | expected_headers,
|
3884 + | ));
|
3885 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3886 + | .await
|
3887 + | .expect("unable to extract body to bytes");
|
3888 + | ::aws_smithy_protocol_test::assert_ok(
|
3889 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/long' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/long' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/long\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3890 + | );
|
3891 + | }
|
3892 + | }
|
3893 + |
|
3894 + | /// When a long member does not fit within range bounds,
|
3895 + | /// the response should be a 400 ValidationException.
|
3896 + | /// Test ID: RestJsonMalformedRangeLong_case1
|
3897 + | #[::tokio::test]
|
3898 + | #[::tracing_test::traced_test]
|
3899 + | async fn rest_json_malformed_range_long_case1_malformed_request() {
|
3900 + | {
|
3901 + | #[allow(unused_mut)]
|
3902 + | let mut http_request = ::http::Request::builder()
|
3903 + | .uri("/MalformedRange")
|
3904 + | .method("POST")
|
3905 + | .header("content-type", "application/json")
|
3906 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3907 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3908 + | "{ \"long\" : 9 }".as_bytes(),
|
3909 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3910 + | )),
|
3911 + | ))
|
3912 + | .unwrap();
|
3913 + | #[allow(unused_mut)]
|
3914 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3915 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3916 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3917 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3918 + | let sender = sender.clone();
|
3919 + | async move {
|
3920 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3921 + | sender.send(()).await.expect("receiver dropped early");
|
3922 + | result
|
3923 + | }
|
3924 + | })
|
3925 + | .build_unchecked();
|
3926 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3927 + | .await
|
3928 + | .expect("unable to make an HTTP request");
|
3929 + | ::pretty_assertions::assert_eq!(
|
3930 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3931 + | http_response.status()
|
3932 + | );
|
3933 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3934 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3935 + | http_response.headers(),
|
3936 + | expected_headers,
|
3937 + | ));
|
3938 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3939 + | .await
|
3940 + | .expect("unable to extract body to bytes");
|
3941 + | ::aws_smithy_protocol_test::assert_ok(
|
3942 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/long' failed to satisfy constraint: Member must be between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/long' failed to satisfy constraint: Member must be between 2 and 8, inclusive\", \"path\": \"/long\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3943 + | );
|
3944 + | }
|
3945 + | }
|
3946 + |
|
3947 + | /// When a long member does not fit within range bounds,
|
3948 + | /// the response should be a 400 ValidationException.
|
3949 + | /// Test ID: RestJsonMalformedRangeMinLong
|
3950 + | #[::tokio::test]
|
3951 + | #[::tracing_test::traced_test]
|
3952 + | async fn rest_json_malformed_range_min_long_malformed_request() {
|
3953 + | {
|
3954 + | #[allow(unused_mut)]
|
3955 + | let mut http_request = ::http::Request::builder()
|
3956 + | .uri("/MalformedRange")
|
3957 + | .method("POST")
|
3958 + | .header("content-type", "application/json")
|
3959 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
3960 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
3961 + | "{ \"minLong\" : 1 }".as_bytes(),
|
3962 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3963 + | )),
|
3964 + | ))
|
3965 + | .unwrap();
|
3966 + | #[allow(unused_mut)]
|
3967 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3968 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3969 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3970 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3971 + | let sender = sender.clone();
|
3972 + | async move {
|
3973 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
3974 + | sender.send(()).await.expect("receiver dropped early");
|
3975 + | result
|
3976 + | }
|
3977 + | })
|
3978 + | .build_unchecked();
|
3979 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3980 + | .await
|
3981 + | .expect("unable to make an HTTP request");
|
3982 + | ::pretty_assertions::assert_eq!(
|
3983 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3984 + | http_response.status()
|
3985 + | );
|
3986 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3987 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3988 + | http_response.headers(),
|
3989 + | expected_headers,
|
3990 + | ));
|
3991 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3992 + | .await
|
3993 + | .expect("unable to extract body to bytes");
|
3994 + | ::aws_smithy_protocol_test::assert_ok(
|
3995 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/minLong' failed to satisfy constraint: Member must be greater than or equal to 2\",\n \"fieldList\" : [{\"message\": \"Value at '/minLong' failed to satisfy constraint: Member must be greater than or equal to 2\", \"path\": \"/minLong\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3996 + | );
|
3997 + | }
|
3998 + | }
|
3999 + |
|
4000 + | /// When a long member does not fit within range bounds,
|
4001 + | /// the response should be a 400 ValidationException.
|
4002 + | /// Test ID: RestJsonMalformedRangeMaxLong
|
4003 + | #[::tokio::test]
|
4004 + | #[::tracing_test::traced_test]
|
4005 + | async fn rest_json_malformed_range_max_long_malformed_request() {
|
4006 + | {
|
4007 + | #[allow(unused_mut)]
|
4008 + | let mut http_request = ::http::Request::builder()
|
4009 + | .uri("/MalformedRange")
|
4010 + | .method("POST")
|
4011 + | .header("content-type", "application/json")
|
4012 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4013 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4014 + | "{ \"maxLong\" : 9 }".as_bytes(),
|
4015 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4016 + | )),
|
4017 + | ))
|
4018 + | .unwrap();
|
4019 + | #[allow(unused_mut)]
|
4020 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4021 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4022 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4023 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4024 + | let sender = sender.clone();
|
4025 + | async move {
|
4026 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedRangeOutput, crate::error::MalformedRangeError> };
|
4027 + | sender.send(()).await.expect("receiver dropped early");
|
4028 + | result
|
4029 + | }
|
4030 + | })
|
4031 + | .build_unchecked();
|
4032 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4033 + | .await
|
4034 + | .expect("unable to make an HTTP request");
|
4035 + | ::pretty_assertions::assert_eq!(
|
4036 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4037 + | http_response.status()
|
4038 + | );
|
4039 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4040 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4041 + | http_response.headers(),
|
4042 + | expected_headers,
|
4043 + | ));
|
4044 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4045 + | .await
|
4046 + | .expect("unable to extract body to bytes");
|
4047 + | ::aws_smithy_protocol_test::assert_ok(
|
4048 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/maxLong' failed to satisfy constraint: Member must be less than or equal to 8\",\n \"fieldList\" : [{\"message\": \"Value at '/maxLong' failed to satisfy constraint: Member must be less than or equal to 8\", \"path\": \"/maxLong\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4049 + | );
|
4050 + | }
|
4051 + | }
|
4052 + | }
|
4053 + |
|
4054 + | ::pin_project_lite::pin_project! {
|
4055 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4056 + | /// [`MalformedPatternOverrideInput`](crate::input::MalformedPatternOverrideInput) using modelled bindings.
|
4057 + | pub struct MalformedPatternOverrideInputFuture {
|
4058 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedPatternOverrideInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
4059 + | }
|
4060 + | }
|
4061 + |
|
4062 + | impl std::future::Future for MalformedPatternOverrideInputFuture {
|
4063 + | type Output = Result<
|
4064 + | crate::input::MalformedPatternOverrideInput,
|
4065 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
4066 + | >;
|
4067 + |
|
4068 + | fn poll(
|
4069 + | self: std::pin::Pin<&mut Self>,
|
4070 + | cx: &mut std::task::Context<'_>,
|
4071 + | ) -> std::task::Poll<Self::Output> {
|
4072 + | let this = self.project();
|
4073 + | this.inner.as_mut().poll(cx)
|
4074 + | }
|
4075 + | }
|
4076 + |
|
4077 + | impl<B>
|
4078 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4079 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
4080 + | B,
|
4081 + | > for crate::input::MalformedPatternOverrideInput
|
4082 + | where
|
4083 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4084 + | B: 'static,
|
4085 + |
|
4086 + | B::Data: Send,
|
4087 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
4088 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4089 + | {
|
4090 + | type Rejection =
|
4091 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
4092 + | type Future = MalformedPatternOverrideInputFuture;
|
4093 + |
|
4094 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4095 + | let fut = async move {
|
4096 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4097 + | request.headers(),
|
4098 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
4099 + | ) {
|
4100 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
4101 + | }
|
4102 + | crate::protocol_serde::shape_malformed_pattern_override::de_malformed_pattern_override_http_request(request)
|
4103 + | .await
|
4104 + | };
|
4105 + | use ::futures_util::future::TryFutureExt;
|
4106 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
4107 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4108 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
4109 + | });
|
4110 + | MalformedPatternOverrideInputFuture {
|
4111 + | inner: Box::pin(fut),
|
4112 + | }
|
4113 + | }
|
4114 + | }
|
4115 + | impl
|
4116 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4117 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
4118 + | > for crate::output::MalformedPatternOverrideOutput
|
4119 + | {
|
4120 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4121 + | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_response(self) {
|
4122 + | Ok(response) => response,
|
4123 + | Err(e) => {
|
4124 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4125 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
4126 + | }
|
4127 + | }
|
4128 + | }
|
4129 + | }
|
4130 + | impl
|
4131 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4132 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
4133 + | > for crate::error::MalformedPatternOverrideError
|
4134 + | {
|
4135 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4136 + | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_error(&self) {
|
4137 + | Ok(mut response) => {
|
4138 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
4139 + | response
|
4140 + | },
|
4141 + | Err(e) => {
|
4142 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4143 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
4144 + | }
|
4145 + | }
|
4146 + | }
|
4147 + | }
|
4148 + |
|
4149 + | #[allow(unreachable_code, unused_variables)]
|
4150 + | #[cfg(test)]
|
4151 + | mod malformed_pattern_override_test {
|
4152 + |
|
4153 + | /// When a string member does not match the specified pattern,
|
4154 + | /// the response should be a 400 ValidationException.
|
4155 + | /// Test ID: RestJsonMalformedPatternStringOverride_case0
|
4156 + | #[::tokio::test]
|
4157 + | #[::tracing_test::traced_test]
|
4158 + | async fn rest_json_malformed_pattern_string_override_case0_malformed_request() {
|
4159 + | {
|
4160 + | #[allow(unused_mut)]
|
4161 + | let mut http_request = ::http::Request::builder()
|
4162 + | .uri("/MalformedPatternOverride")
|
4163 + | .method("POST")
|
4164 + | .header("content-type", "application/json")
|
4165 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4166 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4167 + | "{ \"string\" : \"abc\" }".as_bytes(),
|
4168 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4169 + | )),
|
4170 + | ))
|
4171 + | .unwrap();
|
4172 + | #[allow(unused_mut)]
|
4173 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4174 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4175 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4176 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4177 + | let sender = sender.clone();
|
4178 + | async move {
|
4179 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4180 + | sender.send(()).await.expect("receiver dropped early");
|
4181 + | result
|
4182 + | }
|
4183 + | })
|
4184 + | .build_unchecked();
|
4185 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4186 + | .await
|
4187 + | .expect("unable to make an HTTP request");
|
4188 + | ::pretty_assertions::assert_eq!(
|
4189 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4190 + | http_response.status()
|
4191 + | );
|
4192 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4193 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4194 + | http_response.headers(),
|
4195 + | expected_headers,
|
4196 + | ));
|
4197 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4198 + | .await
|
4199 + | .expect("unable to extract body to bytes");
|
4200 + | ::aws_smithy_protocol_test::assert_ok(
|
4201 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4202 + | );
|
4203 + | }
|
4204 + | }
|
4205 + |
|
4206 + | /// When a string member does not match the specified pattern,
|
4207 + | /// the response should be a 400 ValidationException.
|
4208 + | /// Test ID: RestJsonMalformedPatternStringOverride_case1
|
4209 + | #[::tokio::test]
|
4210 + | #[::tracing_test::traced_test]
|
4211 + | async fn rest_json_malformed_pattern_string_override_case1_malformed_request() {
|
4212 + | {
|
4213 + | #[allow(unused_mut)]
|
4214 + | let mut http_request = ::http::Request::builder()
|
4215 + | .uri("/MalformedPatternOverride")
|
4216 + | .method("POST")
|
4217 + | .header("content-type", "application/json")
|
4218 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4219 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4220 + | "{ \"string\" : \"xyz\" }".as_bytes(),
|
4221 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4222 + | )),
|
4223 + | ))
|
4224 + | .unwrap();
|
4225 + | #[allow(unused_mut)]
|
4226 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4227 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4228 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4229 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4230 + | let sender = sender.clone();
|
4231 + | async move {
|
4232 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4233 + | sender.send(()).await.expect("receiver dropped early");
|
4234 + | result
|
4235 + | }
|
4236 + | })
|
4237 + | .build_unchecked();
|
4238 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4239 + | .await
|
4240 + | .expect("unable to make an HTTP request");
|
4241 + | ::pretty_assertions::assert_eq!(
|
4242 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4243 + | http_response.status()
|
4244 + | );
|
4245 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4246 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4247 + | http_response.headers(),
|
4248 + | expected_headers,
|
4249 + | ));
|
4250 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4251 + | .await
|
4252 + | .expect("unable to extract body to bytes");
|
4253 + | ::aws_smithy_protocol_test::assert_ok(
|
4254 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4255 + | );
|
4256 + | }
|
4257 + | }
|
4258 + |
|
4259 + | /// When a list member value does not match the specified pattern,
|
4260 + | /// the response should be a 400 ValidationException.
|
4261 + | /// Test ID: RestJsonMalformedPatternListOverride_case0
|
4262 + | #[::tokio::test]
|
4263 + | #[::tracing_test::traced_test]
|
4264 + | async fn rest_json_malformed_pattern_list_override_case0_malformed_request() {
|
4265 + | {
|
4266 + | #[allow(unused_mut)]
|
4267 + | let mut http_request = ::http::Request::builder()
|
4268 + | .uri("/MalformedPatternOverride")
|
4269 + | .method("POST")
|
4270 + | .header("content-type", "application/json")
|
4271 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4272 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4273 + | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
4274 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4275 + | )),
|
4276 + | ))
|
4277 + | .unwrap();
|
4278 + | #[allow(unused_mut)]
|
4279 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4280 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4281 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4282 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4283 + | let sender = sender.clone();
|
4284 + | async move {
|
4285 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4286 + | sender.send(()).await.expect("receiver dropped early");
|
4287 + | result
|
4288 + | }
|
4289 + | })
|
4290 + | .build_unchecked();
|
4291 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4292 + | .await
|
4293 + | .expect("unable to make an HTTP request");
|
4294 + | ::pretty_assertions::assert_eq!(
|
4295 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4296 + | http_response.status()
|
4297 + | );
|
4298 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4299 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4300 + | http_response.headers(),
|
4301 + | expected_headers,
|
4302 + | ));
|
4303 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4304 + | .await
|
4305 + | .expect("unable to extract body to bytes");
|
4306 + | ::aws_smithy_protocol_test::assert_ok(
|
4307 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4308 + | );
|
4309 + | }
|
4310 + | }
|
4311 + |
|
4312 + | /// When a list member value does not match the specified pattern,
|
4313 + | /// the response should be a 400 ValidationException.
|
4314 + | /// Test ID: RestJsonMalformedPatternListOverride_case1
|
4315 + | #[::tokio::test]
|
4316 + | #[::tracing_test::traced_test]
|
4317 + | async fn rest_json_malformed_pattern_list_override_case1_malformed_request() {
|
4318 + | {
|
4319 + | #[allow(unused_mut)]
|
4320 + | let mut http_request = ::http::Request::builder()
|
4321 + | .uri("/MalformedPatternOverride")
|
4322 + | .method("POST")
|
4323 + | .header("content-type", "application/json")
|
4324 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4325 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4326 + | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
4327 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4328 + | )),
|
4329 + | ))
|
4330 + | .unwrap();
|
4331 + | #[allow(unused_mut)]
|
4332 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4333 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4334 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4335 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4336 + | let sender = sender.clone();
|
4337 + | async move {
|
4338 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4339 + | sender.send(()).await.expect("receiver dropped early");
|
4340 + | result
|
4341 + | }
|
4342 + | })
|
4343 + | .build_unchecked();
|
4344 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4345 + | .await
|
4346 + | .expect("unable to make an HTTP request");
|
4347 + | ::pretty_assertions::assert_eq!(
|
4348 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4349 + | http_response.status()
|
4350 + | );
|
4351 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4352 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4353 + | http_response.headers(),
|
4354 + | expected_headers,
|
4355 + | ));
|
4356 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4357 + | .await
|
4358 + | .expect("unable to extract body to bytes");
|
4359 + | ::aws_smithy_protocol_test::assert_ok(
|
4360 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4361 + | );
|
4362 + | }
|
4363 + | }
|
4364 + |
|
4365 + | /// When a map member's key does not match the specified pattern,
|
4366 + | /// the response should be a 400 ValidationException.
|
4367 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case0
|
4368 + | #[::tokio::test]
|
4369 + | #[::tracing_test::traced_test]
|
4370 + | async fn rest_json_malformed_pattern_map_key_override_case0_malformed_request() {
|
4371 + | {
|
4372 + | #[allow(unused_mut)]
|
4373 + | let mut http_request = ::http::Request::builder()
|
4374 + | .uri("/MalformedPatternOverride")
|
4375 + | .method("POST")
|
4376 + | .header("content-type", "application/json")
|
4377 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4378 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4379 + | "{ \"map\" : { \"abc\" : \"ghi\" } }".as_bytes(),
|
4380 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4381 + | )),
|
4382 + | ))
|
4383 + | .unwrap();
|
4384 + | #[allow(unused_mut)]
|
4385 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4386 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4387 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4388 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4389 + | let sender = sender.clone();
|
4390 + | async move {
|
4391 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4392 + | sender.send(()).await.expect("receiver dropped early");
|
4393 + | result
|
4394 + | }
|
4395 + | })
|
4396 + | .build_unchecked();
|
4397 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4398 + | .await
|
4399 + | .expect("unable to make an HTTP request");
|
4400 + | ::pretty_assertions::assert_eq!(
|
4401 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4402 + | http_response.status()
|
4403 + | );
|
4404 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4405 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4406 + | http_response.headers(),
|
4407 + | expected_headers,
|
4408 + | ));
|
4409 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4410 + | .await
|
4411 + | .expect("unable to extract body to bytes");
|
4412 + | ::aws_smithy_protocol_test::assert_ok(
|
4413 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4414 + | );
|
4415 + | }
|
4416 + | }
|
4417 + |
|
4418 + | /// When a map member's key does not match the specified pattern,
|
4419 + | /// the response should be a 400 ValidationException.
|
4420 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case1
|
4421 + | #[::tokio::test]
|
4422 + | #[::tracing_test::traced_test]
|
4423 + | async fn rest_json_malformed_pattern_map_key_override_case1_malformed_request() {
|
4424 + | {
|
4425 + | #[allow(unused_mut)]
|
4426 + | let mut http_request = ::http::Request::builder()
|
4427 + | .uri("/MalformedPatternOverride")
|
4428 + | .method("POST")
|
4429 + | .header("content-type", "application/json")
|
4430 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4431 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4432 + | "{ \"map\" : { \"xyz\" : \"ghi\" } }".as_bytes(),
|
4433 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4434 + | )),
|
4435 + | ))
|
4436 + | .unwrap();
|
4437 + | #[allow(unused_mut)]
|
4438 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4439 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4440 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4441 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4442 + | let sender = sender.clone();
|
4443 + | async move {
|
4444 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4445 + | sender.send(()).await.expect("receiver dropped early");
|
4446 + | result
|
4447 + | }
|
4448 + | })
|
4449 + | .build_unchecked();
|
4450 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4451 + | .await
|
4452 + | .expect("unable to make an HTTP request");
|
4453 + | ::pretty_assertions::assert_eq!(
|
4454 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4455 + | http_response.status()
|
4456 + | );
|
4457 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4458 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4459 + | http_response.headers(),
|
4460 + | expected_headers,
|
4461 + | ));
|
4462 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4463 + | .await
|
4464 + | .expect("unable to extract body to bytes");
|
4465 + | ::aws_smithy_protocol_test::assert_ok(
|
4466 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4467 + | );
|
4468 + | }
|
4469 + | }
|
4470 + |
|
4471 + | /// When a map member's value does not match the specified pattern,
|
4472 + | /// the response should be a 400 ValidationException.
|
4473 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case0
|
4474 + | #[::tokio::test]
|
4475 + | #[::tracing_test::traced_test]
|
4476 + | async fn rest_json_malformed_pattern_map_value_override_case0_malformed_request() {
|
4477 + | {
|
4478 + | #[allow(unused_mut)]
|
4479 + | let mut http_request = ::http::Request::builder()
|
4480 + | .uri("/MalformedPatternOverride")
|
4481 + | .method("POST")
|
4482 + | .header("content-type", "application/json")
|
4483 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4484 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4485 + | "{ \"map\" : { \"ghi\": \"abc\" } }".as_bytes(),
|
4486 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4487 + | )),
|
4488 + | ))
|
4489 + | .unwrap();
|
4490 + | #[allow(unused_mut)]
|
4491 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4492 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4493 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4494 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4495 + | let sender = sender.clone();
|
4496 + | async move {
|
4497 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4498 + | sender.send(()).await.expect("receiver dropped early");
|
4499 + | result
|
4500 + | }
|
4501 + | })
|
4502 + | .build_unchecked();
|
4503 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4504 + | .await
|
4505 + | .expect("unable to make an HTTP request");
|
4506 + | ::pretty_assertions::assert_eq!(
|
4507 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4508 + | http_response.status()
|
4509 + | );
|
4510 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4511 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4512 + | http_response.headers(),
|
4513 + | expected_headers,
|
4514 + | ));
|
4515 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4516 + | .await
|
4517 + | .expect("unable to extract body to bytes");
|
4518 + | ::aws_smithy_protocol_test::assert_ok(
|
4519 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map/ghi' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map/ghi' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/map/ghi\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4520 + | );
|
4521 + | }
|
4522 + | }
|
4523 + |
|
4524 + | /// When a map member's value does not match the specified pattern,
|
4525 + | /// the response should be a 400 ValidationException.
|
4526 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case1
|
4527 + | #[::tokio::test]
|
4528 + | #[::tracing_test::traced_test]
|
4529 + | async fn rest_json_malformed_pattern_map_value_override_case1_malformed_request() {
|
4530 + | {
|
4531 + | #[allow(unused_mut)]
|
4532 + | let mut http_request = ::http::Request::builder()
|
4533 + | .uri("/MalformedPatternOverride")
|
4534 + | .method("POST")
|
4535 + | .header("content-type", "application/json")
|
4536 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4537 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4538 + | "{ \"map\" : { \"ghi\": \"xyz\" } }".as_bytes(),
|
4539 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4540 + | )),
|
4541 + | ))
|
4542 + | .unwrap();
|
4543 + | #[allow(unused_mut)]
|
4544 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4545 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4546 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4547 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4548 + | let sender = sender.clone();
|
4549 + | async move {
|
4550 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4551 + | sender.send(()).await.expect("receiver dropped early");
|
4552 + | result
|
4553 + | }
|
4554 + | })
|
4555 + | .build_unchecked();
|
4556 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4557 + | .await
|
4558 + | .expect("unable to make an HTTP request");
|
4559 + | ::pretty_assertions::assert_eq!(
|
4560 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4561 + | http_response.status()
|
4562 + | );
|
4563 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4564 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4565 + | http_response.headers(),
|
4566 + | expected_headers,
|
4567 + | ));
|
4568 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4569 + | .await
|
4570 + | .expect("unable to extract body to bytes");
|
4571 + | ::aws_smithy_protocol_test::assert_ok(
|
4572 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map/ghi' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map/ghi' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/map/ghi\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4573 + | );
|
4574 + | }
|
4575 + | }
|
4576 + |
|
4577 + | /// When a union member's value does not match the specified pattern,
|
4578 + | /// the response should be a 400 ValidationException.
|
4579 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case0
|
4580 + | #[::tokio::test]
|
4581 + | #[::tracing_test::traced_test]
|
4582 + | async fn rest_json_malformed_pattern_union_override_case0_malformed_request() {
|
4583 + | {
|
4584 + | #[allow(unused_mut)]
|
4585 + | let mut http_request = ::http::Request::builder()
|
4586 + | .uri("/MalformedPatternOverride")
|
4587 + | .method("POST")
|
4588 + | .header("content-type", "application/json")
|
4589 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4590 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4591 + | "{ \"union\" : { \"first\": \"abc\" } }".as_bytes(),
|
4592 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4593 + | )),
|
4594 + | ))
|
4595 + | .unwrap();
|
4596 + | #[allow(unused_mut)]
|
4597 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4598 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4599 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4600 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4601 + | let sender = sender.clone();
|
4602 + | async move {
|
4603 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4604 + | sender.send(()).await.expect("receiver dropped early");
|
4605 + | result
|
4606 + | }
|
4607 + | })
|
4608 + | .build_unchecked();
|
4609 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4610 + | .await
|
4611 + | .expect("unable to make an HTTP request");
|
4612 + | ::pretty_assertions::assert_eq!(
|
4613 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4614 + | http_response.status()
|
4615 + | );
|
4616 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4617 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4618 + | http_response.headers(),
|
4619 + | expected_headers,
|
4620 + | ));
|
4621 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4622 + | .await
|
4623 + | .expect("unable to extract body to bytes");
|
4624 + | ::aws_smithy_protocol_test::assert_ok(
|
4625 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/union/first\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4626 + | );
|
4627 + | }
|
4628 + | }
|
4629 + |
|
4630 + | /// When a union member's value does not match the specified pattern,
|
4631 + | /// the response should be a 400 ValidationException.
|
4632 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case1
|
4633 + | #[::tokio::test]
|
4634 + | #[::tracing_test::traced_test]
|
4635 + | async fn rest_json_malformed_pattern_union_override_case1_malformed_request() {
|
4636 + | {
|
4637 + | #[allow(unused_mut)]
|
4638 + | let mut http_request = ::http::Request::builder()
|
4639 + | .uri("/MalformedPatternOverride")
|
4640 + | .method("POST")
|
4641 + | .header("content-type", "application/json")
|
4642 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4643 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4644 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
4645 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4646 + | )),
|
4647 + | ))
|
4648 + | .unwrap();
|
4649 + | #[allow(unused_mut)]
|
4650 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4651 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4652 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4653 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4654 + | let sender = sender.clone();
|
4655 + | async move {
|
4656 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOverrideOutput, crate::error::MalformedPatternOverrideError> };
|
4657 + | sender.send(()).await.expect("receiver dropped early");
|
4658 + | result
|
4659 + | }
|
4660 + | })
|
4661 + | .build_unchecked();
|
4662 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4663 + | .await
|
4664 + | .expect("unable to make an HTTP request");
|
4665 + | ::pretty_assertions::assert_eq!(
|
4666 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4667 + | http_response.status()
|
4668 + | );
|
4669 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4670 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4671 + | http_response.headers(),
|
4672 + | expected_headers,
|
4673 + | ));
|
4674 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4675 + | .await
|
4676 + | .expect("unable to extract body to bytes");
|
4677 + | ::aws_smithy_protocol_test::assert_ok(
|
4678 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[g-m]+$\", \"path\": \"/union/first\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4679 + | );
|
4680 + | }
|
4681 + | }
|
4682 + | }
|
4683 + |
|
4684 + | ::pin_project_lite::pin_project! {
|
4685 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4686 + | /// [`MalformedPatternInput`](crate::input::MalformedPatternInput) using modelled bindings.
|
4687 + | pub struct MalformedPatternInputFuture {
|
4688 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedPatternInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
4689 + | }
|
4690 + | }
|
4691 + |
|
4692 + | impl std::future::Future for MalformedPatternInputFuture {
|
4693 + | type Output = Result<
|
4694 + | crate::input::MalformedPatternInput,
|
4695 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
4696 + | >;
|
4697 + |
|
4698 + | fn poll(
|
4699 + | self: std::pin::Pin<&mut Self>,
|
4700 + | cx: &mut std::task::Context<'_>,
|
4701 + | ) -> std::task::Poll<Self::Output> {
|
4702 + | let this = self.project();
|
4703 + | this.inner.as_mut().poll(cx)
|
4704 + | }
|
4705 + | }
|
4706 + |
|
4707 + | impl<B>
|
4708 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
4709 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
4710 + | B,
|
4711 + | > for crate::input::MalformedPatternInput
|
4712 + | where
|
4713 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
4714 + | B: 'static,
|
4715 + |
|
4716 + | B::Data: Send,
|
4717 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
4718 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
4719 + | {
|
4720 + | type Rejection =
|
4721 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
4722 + | type Future = MalformedPatternInputFuture;
|
4723 + |
|
4724 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4725 + | let fut = async move {
|
4726 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
4727 + | request.headers(),
|
4728 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
4729 + | ) {
|
4730 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
4731 + | }
|
4732 + | crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern_http_request(
|
4733 + | request,
|
4734 + | )
|
4735 + | .await
|
4736 + | };
|
4737 + | use ::futures_util::future::TryFutureExt;
|
4738 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
4739 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4740 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
4741 + | });
|
4742 + | MalformedPatternInputFuture {
|
4743 + | inner: Box::pin(fut),
|
4744 + | }
|
4745 + | }
|
4746 + | }
|
4747 + | impl
|
4748 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4749 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
4750 + | > for crate::output::MalformedPatternOutput
|
4751 + | {
|
4752 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4753 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_response(
|
4754 + | self,
|
4755 + | ) {
|
4756 + | Ok(response) => response,
|
4757 + | Err(e) => {
|
4758 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4759 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
4760 + | }
|
4761 + | }
|
4762 + | }
|
4763 + | }
|
4764 + | impl
|
4765 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
4766 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
4767 + | > for crate::error::MalformedPatternError
|
4768 + | {
|
4769 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
4770 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_error(
|
4771 + | &self,
|
4772 + | ) {
|
4773 + | Ok(mut response) => {
|
4774 + | response.extensions_mut().insert(
|
4775 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
4776 + | self.name(),
|
4777 + | ),
|
4778 + | );
|
4779 + | response
|
4780 + | }
|
4781 + | Err(e) => {
|
4782 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4783 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
4784 + | }
|
4785 + | }
|
4786 + | }
|
4787 + | }
|
4788 + |
|
4789 + | #[allow(unreachable_code, unused_variables)]
|
4790 + | #[cfg(test)]
|
4791 + | mod malformed_pattern_test {
|
4792 + |
|
4793 + | /// When a string member does not match the specified pattern,
|
4794 + | /// the response should be a 400 ValidationException.
|
4795 + | /// Test ID: RestJsonMalformedPatternString_case0
|
4796 + | #[::tokio::test]
|
4797 + | #[::tracing_test::traced_test]
|
4798 + | async fn rest_json_malformed_pattern_string_case0_malformed_request() {
|
4799 + | {
|
4800 + | #[allow(unused_mut)]
|
4801 + | let mut http_request = ::http::Request::builder()
|
4802 + | .uri("/MalformedPattern")
|
4803 + | .method("POST")
|
4804 + | .header("content-type", "application/json")
|
4805 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4806 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4807 + | "{ \"string\" : \"ABC\" }".as_bytes(),
|
4808 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4809 + | )),
|
4810 + | ))
|
4811 + | .unwrap();
|
4812 + | #[allow(unused_mut)]
|
4813 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4814 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4815 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4816 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4817 + | let sender = sender.clone();
|
4818 + | async move {
|
4819 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
4820 + | sender.send(()).await.expect("receiver dropped early");
|
4821 + | result
|
4822 + | }
|
4823 + | })
|
4824 + | .build_unchecked();
|
4825 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4826 + | .await
|
4827 + | .expect("unable to make an HTTP request");
|
4828 + | ::pretty_assertions::assert_eq!(
|
4829 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4830 + | http_response.status()
|
4831 + | );
|
4832 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4833 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4834 + | http_response.headers(),
|
4835 + | expected_headers,
|
4836 + | ));
|
4837 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4838 + | .await
|
4839 + | .expect("unable to extract body to bytes");
|
4840 + | ::aws_smithy_protocol_test::assert_ok(
|
4841 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4842 + | );
|
4843 + | }
|
4844 + | }
|
4845 + |
|
4846 + | /// When a string member does not match the specified pattern,
|
4847 + | /// the response should be a 400 ValidationException.
|
4848 + | /// Test ID: RestJsonMalformedPatternString_case1
|
4849 + | #[::tokio::test]
|
4850 + | #[::tracing_test::traced_test]
|
4851 + | async fn rest_json_malformed_pattern_string_case1_malformed_request() {
|
4852 + | {
|
4853 + | #[allow(unused_mut)]
|
4854 + | let mut http_request = ::http::Request::builder()
|
4855 + | .uri("/MalformedPattern")
|
4856 + | .method("POST")
|
4857 + | .header("content-type", "application/json")
|
4858 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4859 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
4860 + | "{ \"string\" : \"xyz\" }".as_bytes(),
|
4861 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4862 + | )),
|
4863 + | ))
|
4864 + | .unwrap();
|
4865 + | #[allow(unused_mut)]
|
4866 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4867 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4868 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4869 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4870 + | let sender = sender.clone();
|
4871 + | async move {
|
4872 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
4873 + | sender.send(()).await.expect("receiver dropped early");
|
4874 + | result
|
4875 + | }
|
4876 + | })
|
4877 + | .build_unchecked();
|
4878 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4879 + | .await
|
4880 + | .expect("unable to make an HTTP request");
|
4881 + | ::pretty_assertions::assert_eq!(
|
4882 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4883 + | http_response.status()
|
4884 + | );
|
4885 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4886 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4887 + | http_response.headers(),
|
4888 + | expected_headers,
|
4889 + | ));
|
4890 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4891 + | .await
|
4892 + | .expect("unable to extract body to bytes");
|
4893 + | ::aws_smithy_protocol_test::assert_ok(
|
4894 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4895 + | );
|
4896 + | }
|
4897 + | }
|
4898 + |
|
4899 + | /// When the specified pattern is susceptible to ReDOS, the service will not
|
4900 + | /// hang indefinitely while evaluating the pattern
|
4901 + | /// Test ID: RestJsonMalformedPatternReDOSString
|
4902 + | #[::tokio::test]
|
4903 + | #[::tracing_test::traced_test]
|
4904 + | #[should_panic]
|
4905 + | async fn rest_json_malformed_pattern_re_dos_string_malformed_request() {
|
4906 + | {
|
4907 + | #[allow(unused_mut)]
|
4908 + | let mut http_request = ::http::Request::builder()
|
4909 + | .uri("/MalformedPattern")
|
4910 + | .method("POST")
|
4911 + | .header("content-type", "application/json")
|
4912 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4913 + | ::bytes::Bytes::copy_from_slice(
|
4914 + | &::aws_smithy_protocol_test::decode_body_data("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
4915 + | )
|
4916 + | )).unwrap();
|
4917 + | #[allow(unused_mut)]
|
4918 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4919 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4920 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4921 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4922 + | let sender = sender.clone();
|
4923 + | async move {
|
4924 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
4925 + | sender.send(()).await.expect("receiver dropped early");
|
4926 + | result
|
4927 + | }
|
4928 + | })
|
4929 + | .build_unchecked();
|
4930 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4931 + | .await
|
4932 + | .expect("unable to make an HTTP request");
|
4933 + | ::pretty_assertions::assert_eq!(
|
4934 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4935 + | http_response.status()
|
4936 + | );
|
4937 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4938 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4939 + | http_response.headers(),
|
4940 + | expected_headers,
|
4941 + | ));
|
4942 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4943 + | .await
|
4944 + | .expect("unable to extract body to bytes");
|
4945 + | ::aws_smithy_protocol_test::assert_ok(
|
4946 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$$\",\n \"fieldList\" : [{\"message\": \"Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$$\", \"path\": \"/evilString\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4947 + | );
|
4948 + | }
|
4949 + | }
|
4950 + |
|
4951 + | /// When the specified pattern is susceptible to ReDOS, the service will not
|
4952 + | /// hang indefinitely while evaluating the pattern
|
4953 + | /// Test ID: RestJsonMalformedPatternReDOSString_hotfixed
|
4954 + | #[::tokio::test]
|
4955 + | #[::tracing_test::traced_test]
|
4956 + | async fn rest_json_malformed_pattern_re_dos_string_hotfixed_malformed_request() {
|
4957 + | {
|
4958 + | #[allow(unused_mut)]
|
4959 + | let mut http_request = ::http::Request::builder()
|
4960 + | .uri("/MalformedPattern")
|
4961 + | .method("POST")
|
4962 + | .header("content-type", "application/json")
|
4963 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
4964 + | ::bytes::Bytes::copy_from_slice(
|
4965 + | &::aws_smithy_protocol_test::decode_body_data("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
4966 + | )
|
4967 + | )).unwrap();
|
4968 + | #[allow(unused_mut)]
|
4969 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4970 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4971 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4972 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4973 + | let sender = sender.clone();
|
4974 + | async move {
|
4975 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
4976 + | sender.send(()).await.expect("receiver dropped early");
|
4977 + | result
|
4978 + | }
|
4979 + | })
|
4980 + | .build_unchecked();
|
4981 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4982 + | .await
|
4983 + | .expect("unable to make an HTTP request");
|
4984 + | ::pretty_assertions::assert_eq!(
|
4985 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4986 + | http_response.status()
|
4987 + | );
|
4988 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4989 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4990 + | http_response.headers(),
|
4991 + | expected_headers,
|
4992 + | ));
|
4993 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4994 + | .await
|
4995 + | .expect("unable to extract body to bytes");
|
4996 + | ::aws_smithy_protocol_test::assert_ok(
|
4997 + | ::aws_smithy_protocol_test::validate_body(&body, "{\n \"message\" : \"1 validation error detected. Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$\",\n \"fieldList\" : [{\"message\": \"Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$\", \"path\": \"/evilString\"}]\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
4998 + | );
|
4999 + | }
|
5000 + | }
|
5001 + |
|
5002 + | /// When a list member value does not match the specified pattern,
|
5003 + | /// the response should be a 400 ValidationException.
|
5004 + | /// Test ID: RestJsonMalformedPatternList_case0
|
5005 + | #[::tokio::test]
|
5006 + | #[::tracing_test::traced_test]
|
5007 + | async fn rest_json_malformed_pattern_list_case0_malformed_request() {
|
5008 + | {
|
5009 + | #[allow(unused_mut)]
|
5010 + | let mut http_request = ::http::Request::builder()
|
5011 + | .uri("/MalformedPattern")
|
5012 + | .method("POST")
|
5013 + | .header("content-type", "application/json")
|
5014 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5015 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5016 + | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
5017 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5018 + | )),
|
5019 + | ))
|
5020 + | .unwrap();
|
5021 + | #[allow(unused_mut)]
|
5022 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5023 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5024 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5025 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5026 + | let sender = sender.clone();
|
5027 + | async move {
|
5028 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5029 + | sender.send(()).await.expect("receiver dropped early");
|
5030 + | result
|
5031 + | }
|
5032 + | })
|
5033 + | .build_unchecked();
|
5034 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5035 + | .await
|
5036 + | .expect("unable to make an HTTP request");
|
5037 + | ::pretty_assertions::assert_eq!(
|
5038 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5039 + | http_response.status()
|
5040 + | );
|
5041 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5042 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5043 + | http_response.headers(),
|
5044 + | expected_headers,
|
5045 + | ));
|
5046 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5047 + | .await
|
5048 + | .expect("unable to extract body to bytes");
|
5049 + | ::aws_smithy_protocol_test::assert_ok(
|
5050 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5051 + | );
|
5052 + | }
|
5053 + | }
|
5054 + |
|
5055 + | /// When a list member value does not match the specified pattern,
|
5056 + | /// the response should be a 400 ValidationException.
|
5057 + | /// Test ID: RestJsonMalformedPatternList_case1
|
5058 + | #[::tokio::test]
|
5059 + | #[::tracing_test::traced_test]
|
5060 + | async fn rest_json_malformed_pattern_list_case1_malformed_request() {
|
5061 + | {
|
5062 + | #[allow(unused_mut)]
|
5063 + | let mut http_request = ::http::Request::builder()
|
5064 + | .uri("/MalformedPattern")
|
5065 + | .method("POST")
|
5066 + | .header("content-type", "application/json")
|
5067 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5068 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5069 + | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
5070 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5071 + | )),
|
5072 + | ))
|
5073 + | .unwrap();
|
5074 + | #[allow(unused_mut)]
|
5075 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5076 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5077 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5078 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5079 + | let sender = sender.clone();
|
5080 + | async move {
|
5081 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5082 + | sender.send(()).await.expect("receiver dropped early");
|
5083 + | result
|
5084 + | }
|
5085 + | })
|
5086 + | .build_unchecked();
|
5087 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5088 + | .await
|
5089 + | .expect("unable to make an HTTP request");
|
5090 + | ::pretty_assertions::assert_eq!(
|
5091 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5092 + | http_response.status()
|
5093 + | );
|
5094 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5095 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5096 + | http_response.headers(),
|
5097 + | expected_headers,
|
5098 + | ));
|
5099 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5100 + | .await
|
5101 + | .expect("unable to extract body to bytes");
|
5102 + | ::aws_smithy_protocol_test::assert_ok(
|
5103 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/list/0' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5104 + | );
|
5105 + | }
|
5106 + | }
|
5107 + |
|
5108 + | /// When a map member's key does not match the specified pattern,
|
5109 + | /// the response should be a 400 ValidationException.
|
5110 + | /// Test ID: RestJsonMalformedPatternMapKey_case0
|
5111 + | #[::tokio::test]
|
5112 + | #[::tracing_test::traced_test]
|
5113 + | async fn rest_json_malformed_pattern_map_key_case0_malformed_request() {
|
5114 + | {
|
5115 + | #[allow(unused_mut)]
|
5116 + | let mut http_request = ::http::Request::builder()
|
5117 + | .uri("/MalformedPattern")
|
5118 + | .method("POST")
|
5119 + | .header("content-type", "application/json")
|
5120 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5121 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5122 + | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
5123 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5124 + | )),
|
5125 + | ))
|
5126 + | .unwrap();
|
5127 + | #[allow(unused_mut)]
|
5128 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5129 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5130 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5131 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5132 + | let sender = sender.clone();
|
5133 + | async move {
|
5134 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5135 + | sender.send(()).await.expect("receiver dropped early");
|
5136 + | result
|
5137 + | }
|
5138 + | })
|
5139 + | .build_unchecked();
|
5140 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5141 + | .await
|
5142 + | .expect("unable to make an HTTP request");
|
5143 + | ::pretty_assertions::assert_eq!(
|
5144 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5145 + | http_response.status()
|
5146 + | );
|
5147 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5148 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5149 + | http_response.headers(),
|
5150 + | expected_headers,
|
5151 + | ));
|
5152 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5153 + | .await
|
5154 + | .expect("unable to extract body to bytes");
|
5155 + | ::aws_smithy_protocol_test::assert_ok(
|
5156 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5157 + | );
|
5158 + | }
|
5159 + | }
|
5160 + |
|
5161 + | /// When a map member's key does not match the specified pattern,
|
5162 + | /// the response should be a 400 ValidationException.
|
5163 + | /// Test ID: RestJsonMalformedPatternMapKey_case1
|
5164 + | #[::tokio::test]
|
5165 + | #[::tracing_test::traced_test]
|
5166 + | async fn rest_json_malformed_pattern_map_key_case1_malformed_request() {
|
5167 + | {
|
5168 + | #[allow(unused_mut)]
|
5169 + | let mut http_request = ::http::Request::builder()
|
5170 + | .uri("/MalformedPattern")
|
5171 + | .method("POST")
|
5172 + | .header("content-type", "application/json")
|
5173 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5174 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5175 + | "{ \"map\" : { \"xyz\" : \"abc\" } }".as_bytes(),
|
5176 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5177 + | )),
|
5178 + | ))
|
5179 + | .unwrap();
|
5180 + | #[allow(unused_mut)]
|
5181 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5182 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5183 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5184 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5185 + | let sender = sender.clone();
|
5186 + | async move {
|
5187 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5188 + | sender.send(()).await.expect("receiver dropped early");
|
5189 + | result
|
5190 + | }
|
5191 + | })
|
5192 + | .build_unchecked();
|
5193 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5194 + | .await
|
5195 + | .expect("unable to make an HTTP request");
|
5196 + | ::pretty_assertions::assert_eq!(
|
5197 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5198 + | http_response.status()
|
5199 + | );
|
5200 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5201 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5202 + | http_response.headers(),
|
5203 + | expected_headers,
|
5204 + | ));
|
5205 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5206 + | .await
|
5207 + | .expect("unable to extract body to bytes");
|
5208 + | ::aws_smithy_protocol_test::assert_ok(
|
5209 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5210 + | );
|
5211 + | }
|
5212 + | }
|
5213 + |
|
5214 + | /// When a map member's value does not match the specified pattern,
|
5215 + | /// the response should be a 400 ValidationException.
|
5216 + | /// Test ID: RestJsonMalformedPatternMapValue_case0
|
5217 + | #[::tokio::test]
|
5218 + | #[::tracing_test::traced_test]
|
5219 + | async fn rest_json_malformed_pattern_map_value_case0_malformed_request() {
|
5220 + | {
|
5221 + | #[allow(unused_mut)]
|
5222 + | let mut http_request = ::http::Request::builder()
|
5223 + | .uri("/MalformedPattern")
|
5224 + | .method("POST")
|
5225 + | .header("content-type", "application/json")
|
5226 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5227 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5228 + | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
5229 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5230 + | )),
|
5231 + | ))
|
5232 + | .unwrap();
|
5233 + | #[allow(unused_mut)]
|
5234 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5235 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5236 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5237 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5238 + | let sender = sender.clone();
|
5239 + | async move {
|
5240 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5241 + | sender.send(()).await.expect("receiver dropped early");
|
5242 + | result
|
5243 + | }
|
5244 + | })
|
5245 + | .build_unchecked();
|
5246 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5247 + | .await
|
5248 + | .expect("unable to make an HTTP request");
|
5249 + | ::pretty_assertions::assert_eq!(
|
5250 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5251 + | http_response.status()
|
5252 + | );
|
5253 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5254 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5255 + | http_response.headers(),
|
5256 + | expected_headers,
|
5257 + | ));
|
5258 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5259 + | .await
|
5260 + | .expect("unable to extract body to bytes");
|
5261 + | ::aws_smithy_protocol_test::assert_ok(
|
5262 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map/abc' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map/abc' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/map/abc\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5263 + | );
|
5264 + | }
|
5265 + | }
|
5266 + |
|
5267 + | /// When a map member's value does not match the specified pattern,
|
5268 + | /// the response should be a 400 ValidationException.
|
5269 + | /// Test ID: RestJsonMalformedPatternMapValue_case1
|
5270 + | #[::tokio::test]
|
5271 + | #[::tracing_test::traced_test]
|
5272 + | async fn rest_json_malformed_pattern_map_value_case1_malformed_request() {
|
5273 + | {
|
5274 + | #[allow(unused_mut)]
|
5275 + | let mut http_request = ::http::Request::builder()
|
5276 + | .uri("/MalformedPattern")
|
5277 + | .method("POST")
|
5278 + | .header("content-type", "application/json")
|
5279 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5280 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5281 + | "{ \"map\" : { \"abc\": \"xyz\" } }".as_bytes(),
|
5282 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5283 + | )),
|
5284 + | ))
|
5285 + | .unwrap();
|
5286 + | #[allow(unused_mut)]
|
5287 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5288 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5289 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5290 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5291 + | let sender = sender.clone();
|
5292 + | async move {
|
5293 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5294 + | sender.send(()).await.expect("receiver dropped early");
|
5295 + | result
|
5296 + | }
|
5297 + | })
|
5298 + | .build_unchecked();
|
5299 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5300 + | .await
|
5301 + | .expect("unable to make an HTTP request");
|
5302 + | ::pretty_assertions::assert_eq!(
|
5303 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5304 + | http_response.status()
|
5305 + | );
|
5306 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5307 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5308 + | http_response.headers(),
|
5309 + | expected_headers,
|
5310 + | ));
|
5311 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5312 + | .await
|
5313 + | .expect("unable to extract body to bytes");
|
5314 + | ::aws_smithy_protocol_test::assert_ok(
|
5315 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map/abc' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/map/abc' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/map/abc\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5316 + | );
|
5317 + | }
|
5318 + | }
|
5319 + |
|
5320 + | /// When a union member's value does not match the specified pattern,
|
5321 + | /// the response should be a 400 ValidationException.
|
5322 + | /// Test ID: RestJsonMalformedPatternUnion_case0
|
5323 + | #[::tokio::test]
|
5324 + | #[::tracing_test::traced_test]
|
5325 + | async fn rest_json_malformed_pattern_union_case0_malformed_request() {
|
5326 + | {
|
5327 + | #[allow(unused_mut)]
|
5328 + | let mut http_request = ::http::Request::builder()
|
5329 + | .uri("/MalformedPattern")
|
5330 + | .method("POST")
|
5331 + | .header("content-type", "application/json")
|
5332 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5333 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5334 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
5335 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5336 + | )),
|
5337 + | ))
|
5338 + | .unwrap();
|
5339 + | #[allow(unused_mut)]
|
5340 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5341 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5342 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5343 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5344 + | let sender = sender.clone();
|
5345 + | async move {
|
5346 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5347 + | sender.send(()).await.expect("receiver dropped early");
|
5348 + | result
|
5349 + | }
|
5350 + | })
|
5351 + | .build_unchecked();
|
5352 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5353 + | .await
|
5354 + | .expect("unable to make an HTTP request");
|
5355 + | ::pretty_assertions::assert_eq!(
|
5356 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5357 + | http_response.status()
|
5358 + | );
|
5359 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5360 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5361 + | http_response.headers(),
|
5362 + | expected_headers,
|
5363 + | ));
|
5364 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5365 + | .await
|
5366 + | .expect("unable to extract body to bytes");
|
5367 + | ::aws_smithy_protocol_test::assert_ok(
|
5368 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/union/first\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5369 + | );
|
5370 + | }
|
5371 + | }
|
5372 + |
|
5373 + | /// When a union member's value does not match the specified pattern,
|
5374 + | /// the response should be a 400 ValidationException.
|
5375 + | /// Test ID: RestJsonMalformedPatternUnion_case1
|
5376 + | #[::tokio::test]
|
5377 + | #[::tracing_test::traced_test]
|
5378 + | async fn rest_json_malformed_pattern_union_case1_malformed_request() {
|
5379 + | {
|
5380 + | #[allow(unused_mut)]
|
5381 + | let mut http_request = ::http::Request::builder()
|
5382 + | .uri("/MalformedPattern")
|
5383 + | .method("POST")
|
5384 + | .header("content-type", "application/json")
|
5385 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5386 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5387 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
5388 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5389 + | )),
|
5390 + | ))
|
5391 + | .unwrap();
|
5392 + | #[allow(unused_mut)]
|
5393 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5394 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5395 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5396 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5397 + | let sender = sender.clone();
|
5398 + | async move {
|
5399 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedPatternOutput, crate::error::MalformedPatternError> };
|
5400 + | sender.send(()).await.expect("receiver dropped early");
|
5401 + | result
|
5402 + | }
|
5403 + | })
|
5404 + | .build_unchecked();
|
5405 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5406 + | .await
|
5407 + | .expect("unable to make an HTTP request");
|
5408 + | ::pretty_assertions::assert_eq!(
|
5409 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5410 + | http_response.status()
|
5411 + | );
|
5412 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5413 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5414 + | http_response.headers(),
|
5415 + | expected_headers,
|
5416 + | ));
|
5417 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5418 + | .await
|
5419 + | .expect("unable to extract body to bytes");
|
5420 + | ::aws_smithy_protocol_test::assert_ok(
|
5421 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\",\n \"fieldList\" : [{\"message\": \"Value at '/union/first' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-m]+$\", \"path\": \"/union/first\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5422 + | );
|
5423 + | }
|
5424 + | }
|
5425 + | }
|
5426 + |
|
5427 + | ::pin_project_lite::pin_project! {
|
5428 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5429 + | /// [`MalformedLengthQueryStringInput`](crate::input::MalformedLengthQueryStringInput) using modelled bindings.
|
5430 + | pub struct MalformedLengthQueryStringInputFuture {
|
5431 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthQueryStringInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
5432 + | }
|
5433 + | }
|
5434 + |
|
5435 + | impl std::future::Future for MalformedLengthQueryStringInputFuture {
|
5436 + | type Output = Result<
|
5437 + | crate::input::MalformedLengthQueryStringInput,
|
5438 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5439 + | >;
|
5440 + |
|
5441 + | fn poll(
|
5442 + | self: std::pin::Pin<&mut Self>,
|
5443 + | cx: &mut std::task::Context<'_>,
|
5444 + | ) -> std::task::Poll<Self::Output> {
|
5445 + | let this = self.project();
|
5446 + | this.inner.as_mut().poll(cx)
|
5447 + | }
|
5448 + | }
|
5449 + |
|
5450 + | impl<B>
|
5451 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
5452 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
5453 + | B,
|
5454 + | > for crate::input::MalformedLengthQueryStringInput
|
5455 + | where
|
5456 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
5457 + | B: 'static,
|
5458 + |
|
5459 + | B::Data: Send,
|
5460 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5461 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
5462 + | {
|
5463 + | type Rejection =
|
5464 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5465 + | type Future = MalformedLengthQueryStringInputFuture;
|
5466 + |
|
5467 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5468 + | let fut = async move {
|
5469 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
5470 + | request.headers(),
|
5471 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
5472 + | ) {
|
5473 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5474 + | }
|
5475 + | crate::protocol_serde::shape_malformed_length_query_string::de_malformed_length_query_string_http_request(request)
|
5476 + | .await
|
5477 + | };
|
5478 + | use ::futures_util::future::TryFutureExt;
|
5479 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5480 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5481 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
5482 + | });
|
5483 + | MalformedLengthQueryStringInputFuture {
|
5484 + | inner: Box::pin(fut),
|
5485 + | }
|
5486 + | }
|
5487 + | }
|
5488 + | impl
|
5489 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
5490 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
5491 + | > for crate::output::MalformedLengthQueryStringOutput
|
5492 + | {
|
5493 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
5494 + | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_response(self) {
|
5495 + | Ok(response) => response,
|
5496 + | Err(e) => {
|
5497 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5498 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5499 + | }
|
5500 + | }
|
5501 + | }
|
5502 + | }
|
5503 + | impl
|
5504 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
5505 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
5506 + | > for crate::error::MalformedLengthQueryStringError
|
5507 + | {
|
5508 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
5509 + | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_error(&self) {
|
5510 + | Ok(mut response) => {
|
5511 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
5512 + | response
|
5513 + | },
|
5514 + | Err(e) => {
|
5515 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5516 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5517 + | }
|
5518 + | }
|
5519 + | }
|
5520 + | }
|
5521 + |
|
5522 + | #[allow(unreachable_code, unused_variables)]
|
5523 + | #[cfg(test)]
|
5524 + | mod malformed_length_query_string_test {
|
5525 + |
|
5526 + | /// When a required member has no value in the query string,
|
5527 + | /// the response should be a 400 ValidationException.
|
5528 + | /// Test ID: RestJsonMalformedLengthQueryStringNoValue
|
5529 + | #[::tokio::test]
|
5530 + | #[::tracing_test::traced_test]
|
5531 + | async fn rest_json_malformed_length_query_string_no_value_malformed_request() {
|
5532 + | {
|
5533 + | #[allow(unused_mut)]
|
5534 + | let mut http_request = ::http::Request::builder()
|
5535 + | .uri("/MalformedLengthQueryString")
|
5536 + | .method("POST")
|
5537 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5538 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5539 + | "{}".as_bytes(),
|
5540 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5541 + | )),
|
5542 + | ))
|
5543 + | .unwrap();
|
5544 + | *http_request.uri_mut() = "/MalformedLengthQueryString?string".parse().unwrap();
|
5545 + | #[allow(unused_mut)]
|
5546 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5547 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5548 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5549 + | .malformed_length_query_string(move |input: crate::input::MalformedLengthQueryStringInput| {
|
5550 + | let sender = sender.clone();
|
5551 + | async move {
|
5552 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthQueryStringOutput, crate::error::MalformedLengthQueryStringError> };
|
5553 + | sender.send(()).await.expect("receiver dropped early");
|
5554 + | result
|
5555 + | }
|
5556 + | })
|
5557 + | .build_unchecked();
|
5558 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5559 + | .await
|
5560 + | .expect("unable to make an HTTP request");
|
5561 + | ::pretty_assertions::assert_eq!(
|
5562 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5563 + | http_response.status()
|
5564 + | );
|
5565 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5566 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5567 + | http_response.headers(),
|
5568 + | expected_headers,
|
5569 + | ));
|
5570 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5571 + | .await
|
5572 + | .expect("unable to extract body to bytes");
|
5573 + | ::aws_smithy_protocol_test::assert_ok(
|
5574 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 0 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 0 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5575 + | );
|
5576 + | }
|
5577 + | }
|
5578 + | }
|
5579 + |
|
5580 + | ::pin_project_lite::pin_project! {
|
5581 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5582 + | /// [`MalformedLengthOverrideInput`](crate::input::MalformedLengthOverrideInput) using modelled bindings.
|
5583 + | pub struct MalformedLengthOverrideInputFuture {
|
5584 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthOverrideInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
5585 + | }
|
5586 + | }
|
5587 + |
|
5588 + | impl std::future::Future for MalformedLengthOverrideInputFuture {
|
5589 + | type Output = Result<
|
5590 + | crate::input::MalformedLengthOverrideInput,
|
5591 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5592 + | >;
|
5593 + |
|
5594 + | fn poll(
|
5595 + | self: std::pin::Pin<&mut Self>,
|
5596 + | cx: &mut std::task::Context<'_>,
|
5597 + | ) -> std::task::Poll<Self::Output> {
|
5598 + | let this = self.project();
|
5599 + | this.inner.as_mut().poll(cx)
|
5600 + | }
|
5601 + | }
|
5602 + |
|
5603 + | impl<B>
|
5604 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
5605 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
5606 + | B,
|
5607 + | > for crate::input::MalformedLengthOverrideInput
|
5608 + | where
|
5609 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
5610 + | B: 'static,
|
5611 + |
|
5612 + | B::Data: Send,
|
5613 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5614 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
5615 + | {
|
5616 + | type Rejection =
|
5617 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5618 + | type Future = MalformedLengthOverrideInputFuture;
|
5619 + |
|
5620 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5621 + | let fut = async move {
|
5622 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
5623 + | request.headers(),
|
5624 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
5625 + | ) {
|
5626 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5627 + | }
|
5628 + | crate::protocol_serde::shape_malformed_length_override::de_malformed_length_override_http_request(request)
|
5629 + | .await
|
5630 + | };
|
5631 + | use ::futures_util::future::TryFutureExt;
|
5632 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5633 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5634 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
5635 + | });
|
5636 + | MalformedLengthOverrideInputFuture {
|
5637 + | inner: Box::pin(fut),
|
5638 + | }
|
5639 + | }
|
5640 + | }
|
5641 + | impl
|
5642 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
5643 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
5644 + | > for crate::output::MalformedLengthOverrideOutput
|
5645 + | {
|
5646 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
5647 + | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_response(self) {
|
5648 + | Ok(response) => response,
|
5649 + | Err(e) => {
|
5650 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5651 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5652 + | }
|
5653 + | }
|
5654 + | }
|
5655 + | }
|
5656 + | impl
|
5657 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
5658 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
5659 + | > for crate::error::MalformedLengthOverrideError
|
5660 + | {
|
5661 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
5662 + | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_error(&self) {
|
5663 + | Ok(mut response) => {
|
5664 + | response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
5665 + | response
|
5666 + | },
|
5667 + | Err(e) => {
|
5668 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5669 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5670 + | }
|
5671 + | }
|
5672 + | }
|
5673 + | }
|
5674 + |
|
5675 + | #[allow(unreachable_code, unused_variables)]
|
5676 + | #[cfg(test)]
|
5677 + | mod malformed_length_override_test {
|
5678 + |
|
5679 + | /// When a blob member does not fit within length bounds,
|
5680 + | /// the response should be a 400 ValidationException.
|
5681 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case0
|
5682 + | #[::tokio::test]
|
5683 + | #[::tracing_test::traced_test]
|
5684 + | async fn rest_json_malformed_length_blob_override_case0_malformed_request() {
|
5685 + | {
|
5686 + | #[allow(unused_mut)]
|
5687 + | let mut http_request = ::http::Request::builder()
|
5688 + | .uri("/MalformedLengthOverride")
|
5689 + | .method("POST")
|
5690 + | .header("content-type", "application/json")
|
5691 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5692 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5693 + | "{ \"blob\" : \"YWJj\" }".as_bytes(),
|
5694 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5695 + | )),
|
5696 + | ))
|
5697 + | .unwrap();
|
5698 + | #[allow(unused_mut)]
|
5699 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5700 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5701 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5702 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5703 + | let sender = sender.clone();
|
5704 + | async move {
|
5705 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
5706 + | sender.send(()).await.expect("receiver dropped early");
|
5707 + | result
|
5708 + | }
|
5709 + | })
|
5710 + | .build_unchecked();
|
5711 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5712 + | .await
|
5713 + | .expect("unable to make an HTTP request");
|
5714 + | ::pretty_assertions::assert_eq!(
|
5715 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5716 + | http_response.status()
|
5717 + | );
|
5718 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5719 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5720 + | http_response.headers(),
|
5721 + | expected_headers,
|
5722 + | ));
|
5723 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5724 + | .await
|
5725 + | .expect("unable to extract body to bytes");
|
5726 + | ::aws_smithy_protocol_test::assert_ok(
|
5727 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 3 at '/blob' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 3 at '/blob' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/blob\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5728 + | );
|
5729 + | }
|
5730 + | }
|
5731 + |
|
5732 + | /// When a blob member does not fit within length bounds,
|
5733 + | /// the response should be a 400 ValidationException.
|
5734 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case1
|
5735 + | #[::tokio::test]
|
5736 + | #[::tracing_test::traced_test]
|
5737 + | async fn rest_json_malformed_length_blob_override_case1_malformed_request() {
|
5738 + | {
|
5739 + | #[allow(unused_mut)]
|
5740 + | let mut http_request = ::http::Request::builder()
|
5741 + | .uri("/MalformedLengthOverride")
|
5742 + | .method("POST")
|
5743 + | .header("content-type", "application/json")
|
5744 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5745 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5746 + | "{ \"blob\" : \"YWJjZGVmZw==\" }".as_bytes(),
|
5747 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5748 + | )),
|
5749 + | ))
|
5750 + | .unwrap();
|
5751 + | #[allow(unused_mut)]
|
5752 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5753 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5754 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5755 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5756 + | let sender = sender.clone();
|
5757 + | async move {
|
5758 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
5759 + | sender.send(()).await.expect("receiver dropped early");
|
5760 + | result
|
5761 + | }
|
5762 + | })
|
5763 + | .build_unchecked();
|
5764 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5765 + | .await
|
5766 + | .expect("unable to make an HTTP request");
|
5767 + | ::pretty_assertions::assert_eq!(
|
5768 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5769 + | http_response.status()
|
5770 + | );
|
5771 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5772 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5773 + | http_response.headers(),
|
5774 + | expected_headers,
|
5775 + | ));
|
5776 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5777 + | .await
|
5778 + | .expect("unable to extract body to bytes");
|
5779 + | ::aws_smithy_protocol_test::assert_ok(
|
5780 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 7 at '/blob' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 7 at '/blob' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/blob\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5781 + | );
|
5782 + | }
|
5783 + | }
|
5784 + |
|
5785 + | /// When a string member does not fit within length bounds,
|
5786 + | /// the response should be a 400 ValidationException.
|
5787 + | /// Test ID: RestJsonMalformedLengthStringOverride_case0
|
5788 + | #[::tokio::test]
|
5789 + | #[::tracing_test::traced_test]
|
5790 + | async fn rest_json_malformed_length_string_override_case0_malformed_request() {
|
5791 + | {
|
5792 + | #[allow(unused_mut)]
|
5793 + | let mut http_request = ::http::Request::builder()
|
5794 + | .uri("/MalformedLengthOverride")
|
5795 + | .method("POST")
|
5796 + | .header("content-type", "application/json")
|
5797 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5798 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5799 + | "{ \"string\" : \"abc\" }".as_bytes(),
|
5800 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5801 + | )),
|
5802 + | ))
|
5803 + | .unwrap();
|
5804 + | #[allow(unused_mut)]
|
5805 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5806 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5807 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5808 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5809 + | let sender = sender.clone();
|
5810 + | async move {
|
5811 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
5812 + | sender.send(()).await.expect("receiver dropped early");
|
5813 + | result
|
5814 + | }
|
5815 + | })
|
5816 + | .build_unchecked();
|
5817 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5818 + | .await
|
5819 + | .expect("unable to make an HTTP request");
|
5820 + | ::pretty_assertions::assert_eq!(
|
5821 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5822 + | http_response.status()
|
5823 + | );
|
5824 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5825 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5826 + | http_response.headers(),
|
5827 + | expected_headers,
|
5828 + | ));
|
5829 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5830 + | .await
|
5831 + | .expect("unable to extract body to bytes");
|
5832 + | ::aws_smithy_protocol_test::assert_ok(
|
5833 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 3 at '/string' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 3 at '/string' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5834 + | );
|
5835 + | }
|
5836 + | }
|
5837 + |
|
5838 + | /// When a string member does not fit within length bounds,
|
5839 + | /// the response should be a 400 ValidationException.
|
5840 + | /// Test ID: RestJsonMalformedLengthStringOverride_case1
|
5841 + | #[::tokio::test]
|
5842 + | #[::tracing_test::traced_test]
|
5843 + | async fn rest_json_malformed_length_string_override_case1_malformed_request() {
|
5844 + | {
|
5845 + | #[allow(unused_mut)]
|
5846 + | let mut http_request = ::http::Request::builder()
|
5847 + | .uri("/MalformedLengthOverride")
|
5848 + | .method("POST")
|
5849 + | .header("content-type", "application/json")
|
5850 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5851 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5852 + | "{ \"string\" : \"abcdefg\" }".as_bytes(),
|
5853 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5854 + | )),
|
5855 + | ))
|
5856 + | .unwrap();
|
5857 + | #[allow(unused_mut)]
|
5858 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5859 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5860 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5861 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5862 + | let sender = sender.clone();
|
5863 + | async move {
|
5864 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
5865 + | sender.send(()).await.expect("receiver dropped early");
|
5866 + | result
|
5867 + | }
|
5868 + | })
|
5869 + | .build_unchecked();
|
5870 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5871 + | .await
|
5872 + | .expect("unable to make an HTTP request");
|
5873 + | ::pretty_assertions::assert_eq!(
|
5874 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5875 + | http_response.status()
|
5876 + | );
|
5877 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5878 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5879 + | http_response.headers(),
|
5880 + | expected_headers,
|
5881 + | ));
|
5882 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5883 + | .await
|
5884 + | .expect("unable to extract body to bytes");
|
5885 + | ::aws_smithy_protocol_test::assert_ok(
|
5886 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 7 at '/string' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 7 at '/string' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5887 + | );
|
5888 + | }
|
5889 + | }
|
5890 + |
|
5891 + | /// When a string member does not fit within length bounds,
|
5892 + | /// the response should be a 400 ValidationException.
|
5893 + | /// Test ID: RestJsonMalformedLengthStringOverride_case2
|
5894 + | #[::tokio::test]
|
5895 + | #[::tracing_test::traced_test]
|
5896 + | async fn rest_json_malformed_length_string_override_case2_malformed_request() {
|
5897 + | {
|
5898 + | #[allow(unused_mut)]
|
5899 + | let mut http_request = ::http::Request::builder()
|
5900 + | .uri("/MalformedLengthOverride")
|
5901 + | .method("POST")
|
5902 + | .header("content-type", "application/json")
|
5903 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5904 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5905 + | "{ \"string\" : \"👍👍👍\" }".as_bytes(),
|
5906 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5907 + | )),
|
5908 + | ))
|
5909 + | .unwrap();
|
5910 + | #[allow(unused_mut)]
|
5911 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5912 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5913 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5914 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5915 + | let sender = sender.clone();
|
5916 + | async move {
|
5917 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
5918 + | sender.send(()).await.expect("receiver dropped early");
|
5919 + | result
|
5920 + | }
|
5921 + | })
|
5922 + | .build_unchecked();
|
5923 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5924 + | .await
|
5925 + | .expect("unable to make an HTTP request");
|
5926 + | ::pretty_assertions::assert_eq!(
|
5927 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5928 + | http_response.status()
|
5929 + | );
|
5930 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5931 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5932 + | http_response.headers(),
|
5933 + | expected_headers,
|
5934 + | ));
|
5935 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5936 + | .await
|
5937 + | .expect("unable to extract body to bytes");
|
5938 + | ::aws_smithy_protocol_test::assert_ok(
|
5939 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 3 at '/string' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 3 at '/string' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5940 + | );
|
5941 + | }
|
5942 + | }
|
5943 + |
|
5944 + | /// When a string member does not fit within length bounds,
|
5945 + | /// the response should be a 400 ValidationException.
|
5946 + | /// Test ID: RestJsonMalformedLengthMinStringOverride
|
5947 + | #[::tokio::test]
|
5948 + | #[::tracing_test::traced_test]
|
5949 + | async fn rest_json_malformed_length_min_string_override_malformed_request() {
|
5950 + | {
|
5951 + | #[allow(unused_mut)]
|
5952 + | let mut http_request = ::http::Request::builder()
|
5953 + | .uri("/MalformedLengthOverride")
|
5954 + | .method("POST")
|
5955 + | .header("content-type", "application/json")
|
5956 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
5957 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
5958 + | "{ \"minString\" : \"abc\" }".as_bytes(),
|
5959 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5960 + | )),
|
5961 + | ))
|
5962 + | .unwrap();
|
5963 + | #[allow(unused_mut)]
|
5964 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5965 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5966 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5967 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5968 + | let sender = sender.clone();
|
5969 + | async move {
|
5970 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
5971 + | sender.send(()).await.expect("receiver dropped early");
|
5972 + | result
|
5973 + | }
|
5974 + | })
|
5975 + | .build_unchecked();
|
5976 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5977 + | .await
|
5978 + | .expect("unable to make an HTTP request");
|
5979 + | ::pretty_assertions::assert_eq!(
|
5980 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5981 + | http_response.status()
|
5982 + | );
|
5983 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5984 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5985 + | http_response.headers(),
|
5986 + | expected_headers,
|
5987 + | ));
|
5988 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5989 + | .await
|
5990 + | .expect("unable to extract body to bytes");
|
5991 + | ::aws_smithy_protocol_test::assert_ok(
|
5992 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 3 at '/minString' failed to satisfy constraint: Member must have length greater than or equal to 4\",\n \"fieldList\" : [{\"message\": \"Value with length 3 at '/minString' failed to satisfy constraint: Member must have length greater than or equal to 4\", \"path\": \"/minString\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5993 + | );
|
5994 + | }
|
5995 + | }
|
5996 + |
|
5997 + | /// When a string member does not fit within length bounds,
|
5998 + | /// the response should be a 400 ValidationException.
|
5999 + | /// Test ID: RestJsonMalformedLengthMaxStringOverride
|
6000 + | #[::tokio::test]
|
6001 + | #[::tracing_test::traced_test]
|
6002 + | async fn rest_json_malformed_length_max_string_override_malformed_request() {
|
6003 + | {
|
6004 + | #[allow(unused_mut)]
|
6005 + | let mut http_request = ::http::Request::builder()
|
6006 + | .uri("/MalformedLengthOverride")
|
6007 + | .method("POST")
|
6008 + | .header("content-type", "application/json")
|
6009 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6010 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6011 + | "{ \"maxString\" : \"abcdefg\" }".as_bytes(),
|
6012 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6013 + | )),
|
6014 + | ))
|
6015 + | .unwrap();
|
6016 + | #[allow(unused_mut)]
|
6017 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6018 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6019 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6020 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6021 + | let sender = sender.clone();
|
6022 + | async move {
|
6023 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
6024 + | sender.send(()).await.expect("receiver dropped early");
|
6025 + | result
|
6026 + | }
|
6027 + | })
|
6028 + | .build_unchecked();
|
6029 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6030 + | .await
|
6031 + | .expect("unable to make an HTTP request");
|
6032 + | ::pretty_assertions::assert_eq!(
|
6033 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6034 + | http_response.status()
|
6035 + | );
|
6036 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6037 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6038 + | http_response.headers(),
|
6039 + | expected_headers,
|
6040 + | ));
|
6041 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6042 + | .await
|
6043 + | .expect("unable to extract body to bytes");
|
6044 + | ::aws_smithy_protocol_test::assert_ok(
|
6045 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 7 at '/maxString' failed to satisfy constraint: Member must have length less than or equal to 6\",\n \"fieldList\" : [{\"message\": \"Value with length 7 at '/maxString' failed to satisfy constraint: Member must have length less than or equal to 6\", \"path\": \"/maxString\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6046 + | );
|
6047 + | }
|
6048 + | }
|
6049 + |
|
6050 + | /// When a list member does not fit within length bounds,
|
6051 + | /// the response should be a 400 ValidationException.
|
6052 + | /// Test ID: RestJsonMalformedLengthListOverride_case0
|
6053 + | #[::tokio::test]
|
6054 + | #[::tracing_test::traced_test]
|
6055 + | async fn rest_json_malformed_length_list_override_case0_malformed_request() {
|
6056 + | {
|
6057 + | #[allow(unused_mut)]
|
6058 + | let mut http_request = ::http::Request::builder()
|
6059 + | .uri("/MalformedLengthOverride")
|
6060 + | .method("POST")
|
6061 + | .header("content-type", "application/json")
|
6062 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6063 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6064 + | "{ \"list\" : [\"abc\", \"def\", \"ghi\"] }".as_bytes(),
|
6065 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6066 + | )),
|
6067 + | ))
|
6068 + | .unwrap();
|
6069 + | #[allow(unused_mut)]
|
6070 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6071 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6072 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6073 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6074 + | let sender = sender.clone();
|
6075 + | async move {
|
6076 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
6077 + | sender.send(()).await.expect("receiver dropped early");
|
6078 + | result
|
6079 + | }
|
6080 + | })
|
6081 + | .build_unchecked();
|
6082 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6083 + | .await
|
6084 + | .expect("unable to make an HTTP request");
|
6085 + | ::pretty_assertions::assert_eq!(
|
6086 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6087 + | http_response.status()
|
6088 + | );
|
6089 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6090 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6091 + | http_response.headers(),
|
6092 + | expected_headers,
|
6093 + | ));
|
6094 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6095 + | .await
|
6096 + | .expect("unable to extract body to bytes");
|
6097 + | ::aws_smithy_protocol_test::assert_ok(
|
6098 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 3 at '/list' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 3 at '/list' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/list\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6099 + | );
|
6100 + | }
|
6101 + | }
|
6102 + |
|
6103 + | /// When a list member does not fit within length bounds,
|
6104 + | /// the response should be a 400 ValidationException.
|
6105 + | /// Test ID: RestJsonMalformedLengthListOverride_case1
|
6106 + | #[::tokio::test]
|
6107 + | #[::tracing_test::traced_test]
|
6108 + | async fn rest_json_malformed_length_list_override_case1_malformed_request() {
|
6109 + | {
|
6110 + | #[allow(unused_mut)]
|
6111 + | let mut http_request = ::http::Request::builder()
|
6112 + | .uri("/MalformedLengthOverride")
|
6113 + | .method("POST")
|
6114 + | .header("content-type", "application/json")
|
6115 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6116 + | ::bytes::Bytes::copy_from_slice(
|
6117 + | &::aws_smithy_protocol_test::decode_body_data("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
6118 + | )
|
6119 + | )).unwrap();
|
6120 + | #[allow(unused_mut)]
|
6121 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6122 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6123 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6124 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6125 + | let sender = sender.clone();
|
6126 + | async move {
|
6127 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
6128 + | sender.send(()).await.expect("receiver dropped early");
|
6129 + | result
|
6130 + | }
|
6131 + | })
|
6132 + | .build_unchecked();
|
6133 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6134 + | .await
|
6135 + | .expect("unable to make an HTTP request");
|
6136 + | ::pretty_assertions::assert_eq!(
|
6137 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6138 + | http_response.status()
|
6139 + | );
|
6140 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6141 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6142 + | http_response.headers(),
|
6143 + | expected_headers,
|
6144 + | ));
|
6145 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6146 + | .await
|
6147 + | .expect("unable to extract body to bytes");
|
6148 + | ::aws_smithy_protocol_test::assert_ok(
|
6149 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 7 at '/list' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 7 at '/list' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/list\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6150 + | );
|
6151 + | }
|
6152 + | }
|
6153 + |
|
6154 + | /// When a map member does not fit within length bounds,
|
6155 + | /// the response should be a 400 ValidationException.
|
6156 + | /// Test ID: RestJsonMalformedLengthMapOverride_case0
|
6157 + | #[::tokio::test]
|
6158 + | #[::tracing_test::traced_test]
|
6159 + | async fn rest_json_malformed_length_map_override_case0_malformed_request() {
|
6160 + | {
|
6161 + | #[allow(unused_mut)]
|
6162 + | let mut http_request = ::http::Request::builder()
|
6163 + | .uri("/MalformedLengthOverride")
|
6164 + | .method("POST")
|
6165 + | .header("content-type", "application/json")
|
6166 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6167 + | ::bytes::Bytes::copy_from_slice(
|
6168 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
6169 + | )
|
6170 + | )).unwrap();
|
6171 + | #[allow(unused_mut)]
|
6172 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6173 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6174 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6175 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6176 + | let sender = sender.clone();
|
6177 + | async move {
|
6178 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
6179 + | sender.send(()).await.expect("receiver dropped early");
|
6180 + | result
|
6181 + | }
|
6182 + | })
|
6183 + | .build_unchecked();
|
6184 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6185 + | .await
|
6186 + | .expect("unable to make an HTTP request");
|
6187 + | ::pretty_assertions::assert_eq!(
|
6188 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6189 + | http_response.status()
|
6190 + | );
|
6191 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6192 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6193 + | http_response.headers(),
|
6194 + | expected_headers,
|
6195 + | ));
|
6196 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6197 + | .await
|
6198 + | .expect("unable to extract body to bytes");
|
6199 + | ::aws_smithy_protocol_test::assert_ok(
|
6200 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 3 at '/map' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 3 at '/map' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6201 + | );
|
6202 + | }
|
6203 + | }
|
6204 + |
|
6205 + | /// When a map member does not fit within length bounds,
|
6206 + | /// the response should be a 400 ValidationException.
|
6207 + | /// Test ID: RestJsonMalformedLengthMapOverride_case1
|
6208 + | #[::tokio::test]
|
6209 + | #[::tracing_test::traced_test]
|
6210 + | async fn rest_json_malformed_length_map_override_case1_malformed_request() {
|
6211 + | {
|
6212 + | #[allow(unused_mut)]
|
6213 + | let mut http_request = ::http::Request::builder()
|
6214 + | .uri("/MalformedLengthOverride")
|
6215 + | .method("POST")
|
6216 + | .header("content-type", "application/json")
|
6217 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6218 + | ::bytes::Bytes::copy_from_slice(
|
6219 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"],\n \"efg\": [\"abc\", \"def\", \"efg\"], \"fgh\": [\"abc\", \"def\", \"efg\"],\n \"ghi\": [\"abc\", \"def\", \"efg\"] } }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
6220 + | )
|
6221 + | )).unwrap();
|
6222 + | #[allow(unused_mut)]
|
6223 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6224 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6225 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6226 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6227 + | let sender = sender.clone();
|
6228 + | async move {
|
6229 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOverrideOutput, crate::error::MalformedLengthOverrideError> };
|
6230 + | sender.send(()).await.expect("receiver dropped early");
|
6231 + | result
|
6232 + | }
|
6233 + | })
|
6234 + | .build_unchecked();
|
6235 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6236 + | .await
|
6237 + | .expect("unable to make an HTTP request");
|
6238 + | ::pretty_assertions::assert_eq!(
|
6239 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6240 + | http_response.status()
|
6241 + | );
|
6242 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6243 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6244 + | http_response.headers(),
|
6245 + | expected_headers,
|
6246 + | ));
|
6247 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6248 + | .await
|
6249 + | .expect("unable to extract body to bytes");
|
6250 + | ::aws_smithy_protocol_test::assert_ok(
|
6251 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 7 at '/map' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 7 at '/map' failed to satisfy constraint: Member must have length between 4 and 6, inclusive\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6252 + | );
|
6253 + | }
|
6254 + | }
|
6255 + | }
|
6256 + |
|
6257 + | ::pin_project_lite::pin_project! {
|
6258 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6259 + | /// [`MalformedLengthInput`](crate::input::MalformedLengthInput) using modelled bindings.
|
6260 + | pub struct MalformedLengthInputFuture {
|
6261 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6262 + | }
|
6263 + | }
|
6264 + |
|
6265 + | impl std::future::Future for MalformedLengthInputFuture {
|
6266 + | type Output = Result<
|
6267 + | crate::input::MalformedLengthInput,
|
6268 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6269 + | >;
|
6270 + |
|
6271 + | fn poll(
|
6272 + | self: std::pin::Pin<&mut Self>,
|
6273 + | cx: &mut std::task::Context<'_>,
|
6274 + | ) -> std::task::Poll<Self::Output> {
|
6275 + | let this = self.project();
|
6276 + | this.inner.as_mut().poll(cx)
|
6277 + | }
|
6278 + | }
|
6279 + |
|
6280 + | impl<B>
|
6281 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
6282 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
6283 + | B,
|
6284 + | > for crate::input::MalformedLengthInput
|
6285 + | where
|
6286 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
6287 + | B: 'static,
|
6288 + |
|
6289 + | B::Data: Send,
|
6290 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6291 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
6292 + | {
|
6293 + | type Rejection =
|
6294 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6295 + | type Future = MalformedLengthInputFuture;
|
6296 + |
|
6297 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6298 + | let fut = async move {
|
6299 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
6300 + | request.headers(),
|
6301 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
6302 + | ) {
|
6303 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6304 + | }
|
6305 + | crate::protocol_serde::shape_malformed_length::de_malformed_length_http_request(request)
|
6306 + | .await
|
6307 + | };
|
6308 + | use ::futures_util::future::TryFutureExt;
|
6309 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6310 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6311 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
6312 + | });
|
6313 + | MalformedLengthInputFuture {
|
6314 + | inner: Box::pin(fut),
|
6315 + | }
|
6316 + | }
|
6317 + | }
|
6318 + | impl
|
6319 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
6320 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
6321 + | > for crate::output::MalformedLengthOutput
|
6322 + | {
|
6323 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
6324 + | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_response(
|
6325 + | self,
|
6326 + | ) {
|
6327 + | Ok(response) => response,
|
6328 + | Err(e) => {
|
6329 + | ::tracing::error!(error = %e, "failed to serialize response");
|
6330 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6331 + | }
|
6332 + | }
|
6333 + | }
|
6334 + | }
|
6335 + | impl
|
6336 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
6337 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
6338 + | > for crate::error::MalformedLengthError
|
6339 + | {
|
6340 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
6341 + | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_error(&self)
|
6342 + | {
|
6343 + | Ok(mut response) => {
|
6344 + | response.extensions_mut().insert(
|
6345 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
6346 + | self.name(),
|
6347 + | ),
|
6348 + | );
|
6349 + | response
|
6350 + | }
|
6351 + | Err(e) => {
|
6352 + | ::tracing::error!(error = %e, "failed to serialize response");
|
6353 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6354 + | }
|
6355 + | }
|
6356 + | }
|
6357 + | }
|
6358 + |
|
6359 + | #[allow(unreachable_code, unused_variables)]
|
6360 + | #[cfg(test)]
|
6361 + | mod malformed_length_test {
|
6362 + |
|
6363 + | /// When a blob member does not fit within length bounds,
|
6364 + | /// the response should be a 400 ValidationException.
|
6365 + | /// Test ID: RestJsonMalformedLengthBlob_case0
|
6366 + | #[::tokio::test]
|
6367 + | #[::tracing_test::traced_test]
|
6368 + | async fn rest_json_malformed_length_blob_case0_malformed_request() {
|
6369 + | {
|
6370 + | #[allow(unused_mut)]
|
6371 + | let mut http_request = ::http::Request::builder()
|
6372 + | .uri("/MalformedLength")
|
6373 + | .method("POST")
|
6374 + | .header("content-type", "application/json")
|
6375 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6376 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6377 + | "{ \"blob\" : \"YQ==\" }".as_bytes(),
|
6378 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6379 + | )),
|
6380 + | ))
|
6381 + | .unwrap();
|
6382 + | #[allow(unused_mut)]
|
6383 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6384 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6385 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6386 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6387 + | let sender = sender.clone();
|
6388 + | async move {
|
6389 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6390 + | sender.send(()).await.expect("receiver dropped early");
|
6391 + | result
|
6392 + | }
|
6393 + | })
|
6394 + | .build_unchecked();
|
6395 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6396 + | .await
|
6397 + | .expect("unable to make an HTTP request");
|
6398 + | ::pretty_assertions::assert_eq!(
|
6399 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6400 + | http_response.status()
|
6401 + | );
|
6402 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6403 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6404 + | http_response.headers(),
|
6405 + | expected_headers,
|
6406 + | ));
|
6407 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6408 + | .await
|
6409 + | .expect("unable to extract body to bytes");
|
6410 + | ::aws_smithy_protocol_test::assert_ok(
|
6411 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/blob' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/blob' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/blob\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6412 + | );
|
6413 + | }
|
6414 + | }
|
6415 + |
|
6416 + | /// When a blob member does not fit within length bounds,
|
6417 + | /// the response should be a 400 ValidationException.
|
6418 + | /// Test ID: RestJsonMalformedLengthBlob_case1
|
6419 + | #[::tokio::test]
|
6420 + | #[::tracing_test::traced_test]
|
6421 + | async fn rest_json_malformed_length_blob_case1_malformed_request() {
|
6422 + | {
|
6423 + | #[allow(unused_mut)]
|
6424 + | let mut http_request = ::http::Request::builder()
|
6425 + | .uri("/MalformedLength")
|
6426 + | .method("POST")
|
6427 + | .header("content-type", "application/json")
|
6428 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6429 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6430 + | "{ \"blob\" : \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" }".as_bytes(),
|
6431 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6432 + | )),
|
6433 + | ))
|
6434 + | .unwrap();
|
6435 + | #[allow(unused_mut)]
|
6436 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6437 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6438 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6439 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6440 + | let sender = sender.clone();
|
6441 + | async move {
|
6442 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6443 + | sender.send(()).await.expect("receiver dropped early");
|
6444 + | result
|
6445 + | }
|
6446 + | })
|
6447 + | .build_unchecked();
|
6448 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6449 + | .await
|
6450 + | .expect("unable to make an HTTP request");
|
6451 + | ::pretty_assertions::assert_eq!(
|
6452 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6453 + | http_response.status()
|
6454 + | );
|
6455 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6456 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6457 + | http_response.headers(),
|
6458 + | expected_headers,
|
6459 + | ));
|
6460 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6461 + | .await
|
6462 + | .expect("unable to extract body to bytes");
|
6463 + | ::aws_smithy_protocol_test::assert_ok(
|
6464 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 26 at '/blob' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 26 at '/blob' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/blob\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6465 + | );
|
6466 + | }
|
6467 + | }
|
6468 + |
|
6469 + | /// When a string member does not fit within length bounds,
|
6470 + | /// the response should be a 400 ValidationException.
|
6471 + | /// Test ID: RestJsonMalformedLengthString_case0
|
6472 + | #[::tokio::test]
|
6473 + | #[::tracing_test::traced_test]
|
6474 + | async fn rest_json_malformed_length_string_case0_malformed_request() {
|
6475 + | {
|
6476 + | #[allow(unused_mut)]
|
6477 + | let mut http_request = ::http::Request::builder()
|
6478 + | .uri("/MalformedLength")
|
6479 + | .method("POST")
|
6480 + | .header("content-type", "application/json")
|
6481 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6482 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6483 + | "{ \"string\" : \"a\" }".as_bytes(),
|
6484 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6485 + | )),
|
6486 + | ))
|
6487 + | .unwrap();
|
6488 + | #[allow(unused_mut)]
|
6489 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6490 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6491 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6492 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6493 + | let sender = sender.clone();
|
6494 + | async move {
|
6495 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6496 + | sender.send(()).await.expect("receiver dropped early");
|
6497 + | result
|
6498 + | }
|
6499 + | })
|
6500 + | .build_unchecked();
|
6501 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6502 + | .await
|
6503 + | .expect("unable to make an HTTP request");
|
6504 + | ::pretty_assertions::assert_eq!(
|
6505 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6506 + | http_response.status()
|
6507 + | );
|
6508 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6509 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6510 + | http_response.headers(),
|
6511 + | expected_headers,
|
6512 + | ));
|
6513 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6514 + | .await
|
6515 + | .expect("unable to extract body to bytes");
|
6516 + | ::aws_smithy_protocol_test::assert_ok(
|
6517 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6518 + | );
|
6519 + | }
|
6520 + | }
|
6521 + |
|
6522 + | /// When a string member does not fit within length bounds,
|
6523 + | /// the response should be a 400 ValidationException.
|
6524 + | /// Test ID: RestJsonMalformedLengthString_case1
|
6525 + | #[::tokio::test]
|
6526 + | #[::tracing_test::traced_test]
|
6527 + | async fn rest_json_malformed_length_string_case1_malformed_request() {
|
6528 + | {
|
6529 + | #[allow(unused_mut)]
|
6530 + | let mut http_request = ::http::Request::builder()
|
6531 + | .uri("/MalformedLength")
|
6532 + | .method("POST")
|
6533 + | .header("content-type", "application/json")
|
6534 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6535 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6536 + | "{ \"string\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
6537 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6538 + | )),
|
6539 + | ))
|
6540 + | .unwrap();
|
6541 + | #[allow(unused_mut)]
|
6542 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6543 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6544 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6545 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6546 + | let sender = sender.clone();
|
6547 + | async move {
|
6548 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6549 + | sender.send(()).await.expect("receiver dropped early");
|
6550 + | result
|
6551 + | }
|
6552 + | })
|
6553 + | .build_unchecked();
|
6554 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6555 + | .await
|
6556 + | .expect("unable to make an HTTP request");
|
6557 + | ::pretty_assertions::assert_eq!(
|
6558 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6559 + | http_response.status()
|
6560 + | );
|
6561 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6562 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6563 + | http_response.headers(),
|
6564 + | expected_headers,
|
6565 + | ));
|
6566 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6567 + | .await
|
6568 + | .expect("unable to extract body to bytes");
|
6569 + | ::aws_smithy_protocol_test::assert_ok(
|
6570 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 26 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 26 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6571 + | );
|
6572 + | }
|
6573 + | }
|
6574 + |
|
6575 + | /// When a string member does not fit within length bounds,
|
6576 + | /// the response should be a 400 ValidationException.
|
6577 + | /// Test ID: RestJsonMalformedLengthString_case2
|
6578 + | #[::tokio::test]
|
6579 + | #[::tracing_test::traced_test]
|
6580 + | async fn rest_json_malformed_length_string_case2_malformed_request() {
|
6581 + | {
|
6582 + | #[allow(unused_mut)]
|
6583 + | let mut http_request = ::http::Request::builder()
|
6584 + | .uri("/MalformedLength")
|
6585 + | .method("POST")
|
6586 + | .header("content-type", "application/json")
|
6587 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6588 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6589 + | "{ \"string\" : \"👍\" }".as_bytes(),
|
6590 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6591 + | )),
|
6592 + | ))
|
6593 + | .unwrap();
|
6594 + | #[allow(unused_mut)]
|
6595 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6596 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6597 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6598 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6599 + | let sender = sender.clone();
|
6600 + | async move {
|
6601 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6602 + | sender.send(()).await.expect("receiver dropped early");
|
6603 + | result
|
6604 + | }
|
6605 + | })
|
6606 + | .build_unchecked();
|
6607 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6608 + | .await
|
6609 + | .expect("unable to make an HTTP request");
|
6610 + | ::pretty_assertions::assert_eq!(
|
6611 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6612 + | http_response.status()
|
6613 + | );
|
6614 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6615 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6616 + | http_response.headers(),
|
6617 + | expected_headers,
|
6618 + | ));
|
6619 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6620 + | .await
|
6621 + | .expect("unable to extract body to bytes");
|
6622 + | ::aws_smithy_protocol_test::assert_ok(
|
6623 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/string' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6624 + | );
|
6625 + | }
|
6626 + | }
|
6627 + |
|
6628 + | /// When a string member does not fit within length bounds,
|
6629 + | /// the response should be a 400 ValidationException.
|
6630 + | /// Test ID: RestJsonMalformedLengthMinString
|
6631 + | #[::tokio::test]
|
6632 + | #[::tracing_test::traced_test]
|
6633 + | async fn rest_json_malformed_length_min_string_malformed_request() {
|
6634 + | {
|
6635 + | #[allow(unused_mut)]
|
6636 + | let mut http_request = ::http::Request::builder()
|
6637 + | .uri("/MalformedLength")
|
6638 + | .method("POST")
|
6639 + | .header("content-type", "application/json")
|
6640 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6641 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6642 + | "{ \"minString\" : \"a\" }".as_bytes(),
|
6643 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6644 + | )),
|
6645 + | ))
|
6646 + | .unwrap();
|
6647 + | #[allow(unused_mut)]
|
6648 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6649 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6650 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6651 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6652 + | let sender = sender.clone();
|
6653 + | async move {
|
6654 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6655 + | sender.send(()).await.expect("receiver dropped early");
|
6656 + | result
|
6657 + | }
|
6658 + | })
|
6659 + | .build_unchecked();
|
6660 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6661 + | .await
|
6662 + | .expect("unable to make an HTTP request");
|
6663 + | ::pretty_assertions::assert_eq!(
|
6664 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6665 + | http_response.status()
|
6666 + | );
|
6667 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6668 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6669 + | http_response.headers(),
|
6670 + | expected_headers,
|
6671 + | ));
|
6672 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6673 + | .await
|
6674 + | .expect("unable to extract body to bytes");
|
6675 + | ::aws_smithy_protocol_test::assert_ok(
|
6676 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/minString' failed to satisfy constraint: Member must have length greater than or equal to 2\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/minString' failed to satisfy constraint: Member must have length greater than or equal to 2\", \"path\": \"/minString\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6677 + | );
|
6678 + | }
|
6679 + | }
|
6680 + |
|
6681 + | /// When a string member does not fit within length bounds,
|
6682 + | /// the response should be a 400 ValidationException.
|
6683 + | /// Test ID: RestJsonMalformedLengthMaxString
|
6684 + | #[::tokio::test]
|
6685 + | #[::tracing_test::traced_test]
|
6686 + | async fn rest_json_malformed_length_max_string_malformed_request() {
|
6687 + | {
|
6688 + | #[allow(unused_mut)]
|
6689 + | let mut http_request = ::http::Request::builder()
|
6690 + | .uri("/MalformedLength")
|
6691 + | .method("POST")
|
6692 + | .header("content-type", "application/json")
|
6693 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6694 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6695 + | "{ \"maxString\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
6696 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6697 + | )),
|
6698 + | ))
|
6699 + | .unwrap();
|
6700 + | #[allow(unused_mut)]
|
6701 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6702 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6703 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6704 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6705 + | let sender = sender.clone();
|
6706 + | async move {
|
6707 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6708 + | sender.send(()).await.expect("receiver dropped early");
|
6709 + | result
|
6710 + | }
|
6711 + | })
|
6712 + | .build_unchecked();
|
6713 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6714 + | .await
|
6715 + | .expect("unable to make an HTTP request");
|
6716 + | ::pretty_assertions::assert_eq!(
|
6717 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6718 + | http_response.status()
|
6719 + | );
|
6720 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6721 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6722 + | http_response.headers(),
|
6723 + | expected_headers,
|
6724 + | ));
|
6725 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6726 + | .await
|
6727 + | .expect("unable to extract body to bytes");
|
6728 + | ::aws_smithy_protocol_test::assert_ok(
|
6729 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 26 at '/maxString' failed to satisfy constraint: Member must have length less than or equal to 8\",\n \"fieldList\" : [{\"message\": \"Value with length 26 at '/maxString' failed to satisfy constraint: Member must have length less than or equal to 8\", \"path\": \"/maxString\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6730 + | );
|
6731 + | }
|
6732 + | }
|
6733 + |
|
6734 + | /// When a list member does not fit within length bounds,
|
6735 + | /// the response should be a 400 ValidationException.
|
6736 + | /// Test ID: RestJsonMalformedLengthList_case0
|
6737 + | #[::tokio::test]
|
6738 + | #[::tracing_test::traced_test]
|
6739 + | async fn rest_json_malformed_length_list_case0_malformed_request() {
|
6740 + | {
|
6741 + | #[allow(unused_mut)]
|
6742 + | let mut http_request = ::http::Request::builder()
|
6743 + | .uri("/MalformedLength")
|
6744 + | .method("POST")
|
6745 + | .header("content-type", "application/json")
|
6746 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6747 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6748 + | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
6749 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6750 + | )),
|
6751 + | ))
|
6752 + | .unwrap();
|
6753 + | #[allow(unused_mut)]
|
6754 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6755 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6756 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6757 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6758 + | let sender = sender.clone();
|
6759 + | async move {
|
6760 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6761 + | sender.send(()).await.expect("receiver dropped early");
|
6762 + | result
|
6763 + | }
|
6764 + | })
|
6765 + | .build_unchecked();
|
6766 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6767 + | .await
|
6768 + | .expect("unable to make an HTTP request");
|
6769 + | ::pretty_assertions::assert_eq!(
|
6770 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6771 + | http_response.status()
|
6772 + | );
|
6773 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6774 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6775 + | http_response.headers(),
|
6776 + | expected_headers,
|
6777 + | ));
|
6778 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6779 + | .await
|
6780 + | .expect("unable to extract body to bytes");
|
6781 + | ::aws_smithy_protocol_test::assert_ok(
|
6782 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/list' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/list' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/list\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6783 + | );
|
6784 + | }
|
6785 + | }
|
6786 + |
|
6787 + | /// When a list member does not fit within length bounds,
|
6788 + | /// the response should be a 400 ValidationException.
|
6789 + | /// Test ID: RestJsonMalformedLengthList_case1
|
6790 + | #[::tokio::test]
|
6791 + | #[::tracing_test::traced_test]
|
6792 + | async fn rest_json_malformed_length_list_case1_malformed_request() {
|
6793 + | {
|
6794 + | #[allow(unused_mut)]
|
6795 + | let mut http_request = ::http::Request::builder()
|
6796 + | .uri("/MalformedLength")
|
6797 + | .method("POST")
|
6798 + | .header("content-type", "application/json")
|
6799 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6800 + | ::bytes::Bytes::copy_from_slice(
|
6801 + | &::aws_smithy_protocol_test::decode_body_data("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
6802 + | )
|
6803 + | )).unwrap();
|
6804 + | #[allow(unused_mut)]
|
6805 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6806 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6807 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6808 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6809 + | let sender = sender.clone();
|
6810 + | async move {
|
6811 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6812 + | sender.send(()).await.expect("receiver dropped early");
|
6813 + | result
|
6814 + | }
|
6815 + | })
|
6816 + | .build_unchecked();
|
6817 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6818 + | .await
|
6819 + | .expect("unable to make an HTTP request");
|
6820 + | ::pretty_assertions::assert_eq!(
|
6821 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6822 + | http_response.status()
|
6823 + | );
|
6824 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6825 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6826 + | http_response.headers(),
|
6827 + | expected_headers,
|
6828 + | ));
|
6829 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6830 + | .await
|
6831 + | .expect("unable to extract body to bytes");
|
6832 + | ::aws_smithy_protocol_test::assert_ok(
|
6833 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 10 at '/list' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 10 at '/list' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/list\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6834 + | );
|
6835 + | }
|
6836 + | }
|
6837 + |
|
6838 + | /// When a list member's value does not fit within length bounds,
|
6839 + | /// the response should be a 400 ValidationException.
|
6840 + | /// Test ID: RestJsonMalformedLengthListValue_case0
|
6841 + | #[::tokio::test]
|
6842 + | #[::tracing_test::traced_test]
|
6843 + | async fn rest_json_malformed_length_list_value_case0_malformed_request() {
|
6844 + | {
|
6845 + | #[allow(unused_mut)]
|
6846 + | let mut http_request = ::http::Request::builder()
|
6847 + | .uri("/MalformedLength")
|
6848 + | .method("POST")
|
6849 + | .header("content-type", "application/json")
|
6850 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6851 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6852 + | "{ \"list\" : [\"a\", \"abc\"] }".as_bytes(),
|
6853 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6854 + | )),
|
6855 + | ))
|
6856 + | .unwrap();
|
6857 + | #[allow(unused_mut)]
|
6858 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6859 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6860 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6861 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6862 + | let sender = sender.clone();
|
6863 + | async move {
|
6864 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6865 + | sender.send(()).await.expect("receiver dropped early");
|
6866 + | result
|
6867 + | }
|
6868 + | })
|
6869 + | .build_unchecked();
|
6870 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6871 + | .await
|
6872 + | .expect("unable to make an HTTP request");
|
6873 + | ::pretty_assertions::assert_eq!(
|
6874 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6875 + | http_response.status()
|
6876 + | );
|
6877 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6878 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6879 + | http_response.headers(),
|
6880 + | expected_headers,
|
6881 + | ));
|
6882 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6883 + | .await
|
6884 + | .expect("unable to extract body to bytes");
|
6885 + | ::aws_smithy_protocol_test::assert_ok(
|
6886 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/list/0' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/list/0' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6887 + | );
|
6888 + | }
|
6889 + | }
|
6890 + |
|
6891 + | /// When a list member's value does not fit within length bounds,
|
6892 + | /// the response should be a 400 ValidationException.
|
6893 + | /// Test ID: RestJsonMalformedLengthListValue_case1
|
6894 + | #[::tokio::test]
|
6895 + | #[::tracing_test::traced_test]
|
6896 + | async fn rest_json_malformed_length_list_value_case1_malformed_request() {
|
6897 + | {
|
6898 + | #[allow(unused_mut)]
|
6899 + | let mut http_request = ::http::Request::builder()
|
6900 + | .uri("/MalformedLength")
|
6901 + | .method("POST")
|
6902 + | .header("content-type", "application/json")
|
6903 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6904 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6905 + | "{ \"list\" : [\"abcdefghijklmnopqrstuvwxyz\", \"abc\"] }".as_bytes(),
|
6906 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6907 + | )),
|
6908 + | ))
|
6909 + | .unwrap();
|
6910 + | #[allow(unused_mut)]
|
6911 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6912 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6913 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6914 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6915 + | let sender = sender.clone();
|
6916 + | async move {
|
6917 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6918 + | sender.send(()).await.expect("receiver dropped early");
|
6919 + | result
|
6920 + | }
|
6921 + | })
|
6922 + | .build_unchecked();
|
6923 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6924 + | .await
|
6925 + | .expect("unable to make an HTTP request");
|
6926 + | ::pretty_assertions::assert_eq!(
|
6927 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6928 + | http_response.status()
|
6929 + | );
|
6930 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6931 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6932 + | http_response.headers(),
|
6933 + | expected_headers,
|
6934 + | ));
|
6935 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6936 + | .await
|
6937 + | .expect("unable to extract body to bytes");
|
6938 + | ::aws_smithy_protocol_test::assert_ok(
|
6939 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 26 at '/list/0' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 26 at '/list/0' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6940 + | );
|
6941 + | }
|
6942 + | }
|
6943 + |
|
6944 + | /// When a map member does not fit within length bounds,
|
6945 + | /// the response should be a 400 ValidationException.
|
6946 + | /// Test ID: RestJsonMalformedLengthMap_case0
|
6947 + | #[::tokio::test]
|
6948 + | #[::tracing_test::traced_test]
|
6949 + | async fn rest_json_malformed_length_map_case0_malformed_request() {
|
6950 + | {
|
6951 + | #[allow(unused_mut)]
|
6952 + | let mut http_request = ::http::Request::builder()
|
6953 + | .uri("/MalformedLength")
|
6954 + | .method("POST")
|
6955 + | .header("content-type", "application/json")
|
6956 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
6957 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
6958 + | "{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"]} }".as_bytes(),
|
6959 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6960 + | )),
|
6961 + | ))
|
6962 + | .unwrap();
|
6963 + | #[allow(unused_mut)]
|
6964 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6965 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6966 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6967 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6968 + | let sender = sender.clone();
|
6969 + | async move {
|
6970 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
6971 + | sender.send(()).await.expect("receiver dropped early");
|
6972 + | result
|
6973 + | }
|
6974 + | })
|
6975 + | .build_unchecked();
|
6976 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6977 + | .await
|
6978 + | .expect("unable to make an HTTP request");
|
6979 + | ::pretty_assertions::assert_eq!(
|
6980 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6981 + | http_response.status()
|
6982 + | );
|
6983 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6984 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6985 + | http_response.headers(),
|
6986 + | expected_headers,
|
6987 + | ));
|
6988 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6989 + | .await
|
6990 + | .expect("unable to extract body to bytes");
|
6991 + | ::aws_smithy_protocol_test::assert_ok(
|
6992 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
6993 + | );
|
6994 + | }
|
6995 + | }
|
6996 + |
|
6997 + | /// When a map member does not fit within length bounds,
|
6998 + | /// the response should be a 400 ValidationException.
|
6999 + | /// Test ID: RestJsonMalformedLengthMap_case1
|
7000 + | #[::tokio::test]
|
7001 + | #[::tracing_test::traced_test]
|
7002 + | async fn rest_json_malformed_length_map_case1_malformed_request() {
|
7003 + | {
|
7004 + | #[allow(unused_mut)]
|
7005 + | let mut http_request = ::http::Request::builder()
|
7006 + | .uri("/MalformedLength")
|
7007 + | .method("POST")
|
7008 + | .header("content-type", "application/json")
|
7009 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7010 + | ::bytes::Bytes::copy_from_slice(
|
7011 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"],\n \"efg\": [\"abc\", \"def\", \"efg\"], \"fgh\": [\"abc\", \"def\", \"efg\"],\n \"ghi\": [\"abc\", \"def\", \"efg\"], \"jkl\": [\"abc\", \"def\", \"efg\"],\n \"klm\": [\"abc\", \"def\", \"efg\"], \"lmn\": [\"abc\", \"def\", \"efg\"] } }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7012 + | )
|
7013 + | )).unwrap();
|
7014 + | #[allow(unused_mut)]
|
7015 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7016 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7017 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7018 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7019 + | let sender = sender.clone();
|
7020 + | async move {
|
7021 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
7022 + | sender.send(()).await.expect("receiver dropped early");
|
7023 + | result
|
7024 + | }
|
7025 + | })
|
7026 + | .build_unchecked();
|
7027 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7028 + | .await
|
7029 + | .expect("unable to make an HTTP request");
|
7030 + | ::pretty_assertions::assert_eq!(
|
7031 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7032 + | http_response.status()
|
7033 + | );
|
7034 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7035 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7036 + | http_response.headers(),
|
7037 + | expected_headers,
|
7038 + | ));
|
7039 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7040 + | .await
|
7041 + | .expect("unable to extract body to bytes");
|
7042 + | ::aws_smithy_protocol_test::assert_ok(
|
7043 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 10 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 10 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7044 + | );
|
7045 + | }
|
7046 + | }
|
7047 + |
|
7048 + | /// When a map member's key does not fit within length bounds,
|
7049 + | /// the response should be a 400 ValidationException.
|
7050 + | /// Test ID: RestJsonMalformedLengthMapKey_case0
|
7051 + | #[::tokio::test]
|
7052 + | #[::tracing_test::traced_test]
|
7053 + | async fn rest_json_malformed_length_map_key_case0_malformed_request() {
|
7054 + | {
|
7055 + | #[allow(unused_mut)]
|
7056 + | let mut http_request = ::http::Request::builder()
|
7057 + | .uri("/MalformedLength")
|
7058 + | .method("POST")
|
7059 + | .header("content-type", "application/json")
|
7060 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7061 + | ::bytes::Bytes::copy_from_slice(
|
7062 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"a\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7063 + | )
|
7064 + | )).unwrap();
|
7065 + | #[allow(unused_mut)]
|
7066 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7067 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7068 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7069 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7070 + | let sender = sender.clone();
|
7071 + | async move {
|
7072 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
7073 + | sender.send(()).await.expect("receiver dropped early");
|
7074 + | result
|
7075 + | }
|
7076 + | })
|
7077 + | .build_unchecked();
|
7078 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7079 + | .await
|
7080 + | .expect("unable to make an HTTP request");
|
7081 + | ::pretty_assertions::assert_eq!(
|
7082 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7083 + | http_response.status()
|
7084 + | );
|
7085 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7086 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7087 + | http_response.headers(),
|
7088 + | expected_headers,
|
7089 + | ));
|
7090 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7091 + | .await
|
7092 + | .expect("unable to extract body to bytes");
|
7093 + | ::aws_smithy_protocol_test::assert_ok(
|
7094 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7095 + | );
|
7096 + | }
|
7097 + | }
|
7098 + |
|
7099 + | /// When a map member's key does not fit within length bounds,
|
7100 + | /// the response should be a 400 ValidationException.
|
7101 + | /// Test ID: RestJsonMalformedLengthMapKey_case1
|
7102 + | #[::tokio::test]
|
7103 + | #[::tracing_test::traced_test]
|
7104 + | async fn rest_json_malformed_length_map_key_case1_malformed_request() {
|
7105 + | {
|
7106 + | #[allow(unused_mut)]
|
7107 + | let mut http_request = ::http::Request::builder()
|
7108 + | .uri("/MalformedLength")
|
7109 + | .method("POST")
|
7110 + | .header("content-type", "application/json")
|
7111 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7112 + | ::bytes::Bytes::copy_from_slice(
|
7113 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abcdefghijklmnopqrstuvwxyz\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7114 + | )
|
7115 + | )).unwrap();
|
7116 + | #[allow(unused_mut)]
|
7117 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7118 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7119 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7120 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7121 + | let sender = sender.clone();
|
7122 + | async move {
|
7123 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
7124 + | sender.send(()).await.expect("receiver dropped early");
|
7125 + | result
|
7126 + | }
|
7127 + | })
|
7128 + | .build_unchecked();
|
7129 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7130 + | .await
|
7131 + | .expect("unable to make an HTTP request");
|
7132 + | ::pretty_assertions::assert_eq!(
|
7133 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7134 + | http_response.status()
|
7135 + | );
|
7136 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7137 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7138 + | http_response.headers(),
|
7139 + | expected_headers,
|
7140 + | ));
|
7141 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7142 + | .await
|
7143 + | .expect("unable to extract body to bytes");
|
7144 + | ::aws_smithy_protocol_test::assert_ok(
|
7145 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 26 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 26 at '/map' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7146 + | );
|
7147 + | }
|
7148 + | }
|
7149 + |
|
7150 + | /// When a map member's value does not fit within length bounds,
|
7151 + | /// the response should be a 400 ValidationException.
|
7152 + | /// Test ID: RestJsonMalformedLengthMapValue_case0
|
7153 + | #[::tokio::test]
|
7154 + | #[::tracing_test::traced_test]
|
7155 + | async fn rest_json_malformed_length_map_value_case0_malformed_request() {
|
7156 + | {
|
7157 + | #[allow(unused_mut)]
|
7158 + | let mut http_request = ::http::Request::builder()
|
7159 + | .uri("/MalformedLength")
|
7160 + | .method("POST")
|
7161 + | .header("content-type", "application/json")
|
7162 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7163 + | ::bytes::Bytes::copy_from_slice(
|
7164 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7165 + | )
|
7166 + | )).unwrap();
|
7167 + | #[allow(unused_mut)]
|
7168 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7169 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7170 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7171 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7172 + | let sender = sender.clone();
|
7173 + | async move {
|
7174 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
7175 + | sender.send(()).await.expect("receiver dropped early");
|
7176 + | result
|
7177 + | }
|
7178 + | })
|
7179 + | .build_unchecked();
|
7180 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7181 + | .await
|
7182 + | .expect("unable to make an HTTP request");
|
7183 + | ::pretty_assertions::assert_eq!(
|
7184 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7185 + | http_response.status()
|
7186 + | );
|
7187 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7188 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7189 + | http_response.headers(),
|
7190 + | expected_headers,
|
7191 + | ));
|
7192 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7193 + | .await
|
7194 + | .expect("unable to extract body to bytes");
|
7195 + | ::aws_smithy_protocol_test::assert_ok(
|
7196 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 1 at '/map/abc' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 1 at '/map/abc' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/map/abc\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7197 + | );
|
7198 + | }
|
7199 + | }
|
7200 + |
|
7201 + | /// When a map member's value does not fit within length bounds,
|
7202 + | /// the response should be a 400 ValidationException.
|
7203 + | /// Test ID: RestJsonMalformedLengthMapValue_case1
|
7204 + | #[::tokio::test]
|
7205 + | #[::tracing_test::traced_test]
|
7206 + | async fn rest_json_malformed_length_map_value_case1_malformed_request() {
|
7207 + | {
|
7208 + | #[allow(unused_mut)]
|
7209 + | let mut http_request = ::http::Request::builder()
|
7210 + | .uri("/MalformedLength")
|
7211 + | .method("POST")
|
7212 + | .header("content-type", "application/json")
|
7213 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7214 + | ::bytes::Bytes::copy_from_slice(
|
7215 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\"],\n \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7216 + | )
|
7217 + | )).unwrap();
|
7218 + | #[allow(unused_mut)]
|
7219 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7220 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7221 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7222 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7223 + | let sender = sender.clone();
|
7224 + | async move {
|
7225 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedLengthOutput, crate::error::MalformedLengthError> };
|
7226 + | sender.send(()).await.expect("receiver dropped early");
|
7227 + | result
|
7228 + | }
|
7229 + | })
|
7230 + | .build_unchecked();
|
7231 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7232 + | .await
|
7233 + | .expect("unable to make an HTTP request");
|
7234 + | ::pretty_assertions::assert_eq!(
|
7235 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7236 + | http_response.status()
|
7237 + | );
|
7238 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7239 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7240 + | http_response.headers(),
|
7241 + | expected_headers,
|
7242 + | ));
|
7243 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7244 + | .await
|
7245 + | .expect("unable to extract body to bytes");
|
7246 + | ::aws_smithy_protocol_test::assert_ok(
|
7247 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with length 10 at '/map/abc' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\",\n \"fieldList\" : [{\"message\": \"Value with length 10 at '/map/abc' failed to satisfy constraint: Member must have length between 2 and 8, inclusive\", \"path\": \"/map/abc\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7248 + | );
|
7249 + | }
|
7250 + | }
|
7251 + | }
|
7252 + |
|
7253 + | ::pin_project_lite::pin_project! {
|
7254 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
7255 + | /// [`MalformedEnumInput`](crate::input::MalformedEnumInput) using modelled bindings.
|
7256 + | pub struct MalformedEnumInputFuture {
|
7257 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedEnumInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7258 + | }
|
7259 + | }
|
7260 + |
|
7261 + | impl std::future::Future for MalformedEnumInputFuture {
|
7262 + | type Output = Result<
|
7263 + | crate::input::MalformedEnumInput,
|
7264 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
7265 + | >;
|
7266 + |
|
7267 + | fn poll(
|
7268 + | self: std::pin::Pin<&mut Self>,
|
7269 + | cx: &mut std::task::Context<'_>,
|
7270 + | ) -> std::task::Poll<Self::Output> {
|
7271 + | let this = self.project();
|
7272 + | this.inner.as_mut().poll(cx)
|
7273 + | }
|
7274 + | }
|
7275 + |
|
7276 + | impl<B>
|
7277 + | ::aws_smithy_legacy_http_server::request::FromRequest<
|
7278 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
7279 + | B,
|
7280 + | > for crate::input::MalformedEnumInput
|
7281 + | where
|
7282 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
7283 + | B: 'static,
|
7284 + |
|
7285 + | B::Data: Send,
|
7286 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
7287 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
7288 + | {
|
7289 + | type Rejection =
|
7290 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
7291 + | type Future = MalformedEnumInputFuture;
|
7292 + |
|
7293 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
7294 + | let fut = async move {
|
7295 + | if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
|
7296 + | request.headers(),
|
7297 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
7298 + | ) {
|
7299 + | return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7300 + | }
|
7301 + | crate::protocol_serde::shape_malformed_enum::de_malformed_enum_http_request(request)
|
7302 + | .await
|
7303 + | };
|
7304 + | use ::futures_util::future::TryFutureExt;
|
7305 + | let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
7306 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
7307 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
|
7308 + | });
|
7309 + | MalformedEnumInputFuture {
|
7310 + | inner: Box::pin(fut),
|
7311 + | }
|
7312 + | }
|
7313 + | }
|
7314 + | impl
|
7315 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
7316 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
7317 + | > for crate::output::MalformedEnumOutput
|
7318 + | {
|
7319 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
7320 + | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_response(self) {
|
7321 + | Ok(response) => response,
|
7322 + | Err(e) => {
|
7323 + | ::tracing::error!(error = %e, "failed to serialize response");
|
7324 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7325 + | }
|
7326 + | }
|
7327 + | }
|
7328 + | }
|
7329 + | impl
|
7330 + | ::aws_smithy_legacy_http_server::response::IntoResponse<
|
7331 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
|
7332 + | > for crate::error::MalformedEnumError
|
7333 + | {
|
7334 + | fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
|
7335 + | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_error(&self) {
|
7336 + | Ok(mut response) => {
|
7337 + | response.extensions_mut().insert(
|
7338 + | ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
|
7339 + | self.name(),
|
7340 + | ),
|
7341 + | );
|
7342 + | response
|
7343 + | }
|
7344 + | Err(e) => {
|
7345 + | ::tracing::error!(error = %e, "failed to serialize response");
|
7346 + | ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7347 + | }
|
7348 + | }
|
7349 + | }
|
7350 + | }
|
7351 + |
|
7352 + | #[allow(unreachable_code, unused_variables)]
|
7353 + | #[cfg(test)]
|
7354 + | mod malformed_enum_test {
|
7355 + |
|
7356 + | /// When a string member does not contain a valid enum value,
|
7357 + | /// the response should be a 400 ValidationException. Internal-only
|
7358 + | /// enum values are excluded from the response message.
|
7359 + | /// Test ID: RestJsonMalformedEnumString_case0
|
7360 + | #[::tokio::test]
|
7361 + | #[::tracing_test::traced_test]
|
7362 + | #[should_panic]
|
7363 + | async fn rest_json_malformed_enum_string_case0_malformed_request() {
|
7364 + | {
|
7365 + | #[allow(unused_mut)]
|
7366 + | let mut http_request = ::http::Request::builder()
|
7367 + | .uri("/MalformedEnum")
|
7368 + | .method("POST")
|
7369 + | .header("content-type", "application/json")
|
7370 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7371 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7372 + | "{ \"string\" : \"ABC\" }".as_bytes(),
|
7373 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7374 + | )),
|
7375 + | ))
|
7376 + | .unwrap();
|
7377 + | #[allow(unused_mut)]
|
7378 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7379 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7380 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7381 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7382 + | let sender = sender.clone();
|
7383 + | async move {
|
7384 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7385 + | sender.send(()).await.expect("receiver dropped early");
|
7386 + | result
|
7387 + | }
|
7388 + | })
|
7389 + | .build_unchecked();
|
7390 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7391 + | .await
|
7392 + | .expect("unable to make an HTTP request");
|
7393 + | ::pretty_assertions::assert_eq!(
|
7394 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7395 + | http_response.status()
|
7396 + | );
|
7397 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7398 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7399 + | http_response.headers(),
|
7400 + | expected_headers,
|
7401 + | ));
|
7402 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7403 + | .await
|
7404 + | .expect("unable to extract body to bytes");
|
7405 + | ::aws_smithy_protocol_test::assert_ok(
|
7406 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7407 + | );
|
7408 + | }
|
7409 + | }
|
7410 + |
|
7411 + | /// When a string member does not contain a valid enum value,
|
7412 + | /// the response should be a 400 ValidationException. Internal-only
|
7413 + | /// enum values are excluded from the response message.
|
7414 + | /// Test ID: RestJsonMalformedEnumString_case1
|
7415 + | #[::tokio::test]
|
7416 + | #[::tracing_test::traced_test]
|
7417 + | #[should_panic]
|
7418 + | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
7419 + | {
|
7420 + | #[allow(unused_mut)]
|
7421 + | let mut http_request = ::http::Request::builder()
|
7422 + | .uri("/MalformedEnum")
|
7423 + | .method("POST")
|
7424 + | .header("content-type", "application/json")
|
7425 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7426 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7427 + | "{ \"string\" : \"XYZ\" }".as_bytes(),
|
7428 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7429 + | )),
|
7430 + | ))
|
7431 + | .unwrap();
|
7432 + | #[allow(unused_mut)]
|
7433 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7434 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7435 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7436 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7437 + | let sender = sender.clone();
|
7438 + | async move {
|
7439 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7440 + | sender.send(()).await.expect("receiver dropped early");
|
7441 + | result
|
7442 + | }
|
7443 + | })
|
7444 + | .build_unchecked();
|
7445 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7446 + | .await
|
7447 + | .expect("unable to make an HTTP request");
|
7448 + | ::pretty_assertions::assert_eq!(
|
7449 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7450 + | http_response.status()
|
7451 + | );
|
7452 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7453 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7454 + | http_response.headers(),
|
7455 + | expected_headers,
|
7456 + | ));
|
7457 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7458 + | .await
|
7459 + | .expect("unable to extract body to bytes");
|
7460 + | ::aws_smithy_protocol_test::assert_ok(
|
7461 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/string' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/string' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/string\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7462 + | );
|
7463 + | }
|
7464 + | }
|
7465 + |
|
7466 + | /// When a string member does not contain a valid enum value,
|
7467 + | /// the response should be a 400 ValidationException. Internal-only
|
7468 + | /// enum values are excluded from the response message.
|
7469 + | /// Test ID: RestJsonMalformedEnumTraitString_case0
|
7470 + | #[::tokio::test]
|
7471 + | #[::tracing_test::traced_test]
|
7472 + | #[should_panic]
|
7473 + | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
7474 + | {
|
7475 + | #[allow(unused_mut)]
|
7476 + | let mut http_request = ::http::Request::builder()
|
7477 + | .uri("/MalformedEnum")
|
7478 + | .method("POST")
|
7479 + | .header("content-type", "application/json")
|
7480 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7481 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7482 + | "{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes(),
|
7483 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7484 + | )),
|
7485 + | ))
|
7486 + | .unwrap();
|
7487 + | #[allow(unused_mut)]
|
7488 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7489 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7490 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7491 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7492 + | let sender = sender.clone();
|
7493 + | async move {
|
7494 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7495 + | sender.send(()).await.expect("receiver dropped early");
|
7496 + | result
|
7497 + | }
|
7498 + | })
|
7499 + | .build_unchecked();
|
7500 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7501 + | .await
|
7502 + | .expect("unable to make an HTTP request");
|
7503 + | ::pretty_assertions::assert_eq!(
|
7504 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7505 + | http_response.status()
|
7506 + | );
|
7507 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7508 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7509 + | http_response.headers(),
|
7510 + | expected_headers,
|
7511 + | ));
|
7512 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7513 + | .await
|
7514 + | .expect("unable to extract body to bytes");
|
7515 + | ::aws_smithy_protocol_test::assert_ok(
|
7516 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]\",\n \"fieldList\" : [{\"message\": \"Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]\", \"path\": \"/stringWithEnumTrait\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7517 + | );
|
7518 + | }
|
7519 + | }
|
7520 + |
|
7521 + | /// When a string member does not contain a valid enum value,
|
7522 + | /// the response should be a 400 ValidationException. Internal-only
|
7523 + | /// enum values are excluded from the response message.
|
7524 + | /// Test ID: RestJsonMalformedEnumTraitString_case1
|
7525 + | #[::tokio::test]
|
7526 + | #[::tracing_test::traced_test]
|
7527 + | #[should_panic]
|
7528 + | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
7529 + | {
|
7530 + | #[allow(unused_mut)]
|
7531 + | let mut http_request = ::http::Request::builder()
|
7532 + | .uri("/MalformedEnum")
|
7533 + | .method("POST")
|
7534 + | .header("content-type", "application/json")
|
7535 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7536 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7537 + | "{ \"stringWithEnumTrait\" : \"XYZ\" }".as_bytes(),
|
7538 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7539 + | )),
|
7540 + | ))
|
7541 + | .unwrap();
|
7542 + | #[allow(unused_mut)]
|
7543 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7544 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7545 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7546 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7547 + | let sender = sender.clone();
|
7548 + | async move {
|
7549 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7550 + | sender.send(()).await.expect("receiver dropped early");
|
7551 + | result
|
7552 + | }
|
7553 + | })
|
7554 + | .build_unchecked();
|
7555 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7556 + | .await
|
7557 + | .expect("unable to make an HTTP request");
|
7558 + | ::pretty_assertions::assert_eq!(
|
7559 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7560 + | http_response.status()
|
7561 + | );
|
7562 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7563 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7564 + | http_response.headers(),
|
7565 + | expected_headers,
|
7566 + | ));
|
7567 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7568 + | .await
|
7569 + | .expect("unable to extract body to bytes");
|
7570 + | ::aws_smithy_protocol_test::assert_ok(
|
7571 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]\",\n \"fieldList\" : [{\"message\": \"Value at '/stringWithEnumTrait' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]\", \"path\": \"/stringWithEnumTrait\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7572 + | );
|
7573 + | }
|
7574 + | }
|
7575 + |
|
7576 + | /// When a list member value does not contain a valid enum value,
|
7577 + | /// the response should be a 400 ValidationException. Internal-only
|
7578 + | /// enum values are excluded from the response message.
|
7579 + | /// Test ID: RestJsonMalformedEnumList_case0
|
7580 + | #[::tokio::test]
|
7581 + | #[::tracing_test::traced_test]
|
7582 + | #[should_panic]
|
7583 + | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
7584 + | {
|
7585 + | #[allow(unused_mut)]
|
7586 + | let mut http_request = ::http::Request::builder()
|
7587 + | .uri("/MalformedEnum")
|
7588 + | .method("POST")
|
7589 + | .header("content-type", "application/json")
|
7590 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7591 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7592 + | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
7593 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7594 + | )),
|
7595 + | ))
|
7596 + | .unwrap();
|
7597 + | #[allow(unused_mut)]
|
7598 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7599 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7600 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7601 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7602 + | let sender = sender.clone();
|
7603 + | async move {
|
7604 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7605 + | sender.send(()).await.expect("receiver dropped early");
|
7606 + | result
|
7607 + | }
|
7608 + | })
|
7609 + | .build_unchecked();
|
7610 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7611 + | .await
|
7612 + | .expect("unable to make an HTTP request");
|
7613 + | ::pretty_assertions::assert_eq!(
|
7614 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7615 + | http_response.status()
|
7616 + | );
|
7617 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7618 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7619 + | http_response.headers(),
|
7620 + | expected_headers,
|
7621 + | ));
|
7622 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7623 + | .await
|
7624 + | .expect("unable to extract body to bytes");
|
7625 + | ::aws_smithy_protocol_test::assert_ok(
|
7626 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/list/0' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/list/0' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7627 + | );
|
7628 + | }
|
7629 + | }
|
7630 + |
|
7631 + | /// When a list member value does not contain a valid enum value,
|
7632 + | /// the response should be a 400 ValidationException. Internal-only
|
7633 + | /// enum values are excluded from the response message.
|
7634 + | /// Test ID: RestJsonMalformedEnumList_case1
|
7635 + | #[::tokio::test]
|
7636 + | #[::tracing_test::traced_test]
|
7637 + | #[should_panic]
|
7638 + | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
7639 + | {
|
7640 + | #[allow(unused_mut)]
|
7641 + | let mut http_request = ::http::Request::builder()
|
7642 + | .uri("/MalformedEnum")
|
7643 + | .method("POST")
|
7644 + | .header("content-type", "application/json")
|
7645 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7646 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7647 + | "{ \"list\" : [\"XYZ\"] }".as_bytes(),
|
7648 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7649 + | )),
|
7650 + | ))
|
7651 + | .unwrap();
|
7652 + | #[allow(unused_mut)]
|
7653 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7654 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7655 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7656 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7657 + | let sender = sender.clone();
|
7658 + | async move {
|
7659 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7660 + | sender.send(()).await.expect("receiver dropped early");
|
7661 + | result
|
7662 + | }
|
7663 + | })
|
7664 + | .build_unchecked();
|
7665 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7666 + | .await
|
7667 + | .expect("unable to make an HTTP request");
|
7668 + | ::pretty_assertions::assert_eq!(
|
7669 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7670 + | http_response.status()
|
7671 + | );
|
7672 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7673 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7674 + | http_response.headers(),
|
7675 + | expected_headers,
|
7676 + | ));
|
7677 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7678 + | .await
|
7679 + | .expect("unable to extract body to bytes");
|
7680 + | ::aws_smithy_protocol_test::assert_ok(
|
7681 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/list/0' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/list/0' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/list/0\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7682 + | );
|
7683 + | }
|
7684 + | }
|
7685 + |
|
7686 + | /// When a map member's key does not contain a valid enum value,
|
7687 + | /// the response should be a 400 ValidationException. Internal-only
|
7688 + | /// enum values are excluded from the response message.
|
7689 + | /// Test ID: RestJsonMalformedEnumMapKey_case0
|
7690 + | #[::tokio::test]
|
7691 + | #[::tracing_test::traced_test]
|
7692 + | #[should_panic]
|
7693 + | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
7694 + | {
|
7695 + | #[allow(unused_mut)]
|
7696 + | let mut http_request = ::http::Request::builder()
|
7697 + | .uri("/MalformedEnum")
|
7698 + | .method("POST")
|
7699 + | .header("content-type", "application/json")
|
7700 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7701 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7702 + | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
7703 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7704 + | )),
|
7705 + | ))
|
7706 + | .unwrap();
|
7707 + | #[allow(unused_mut)]
|
7708 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7709 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7710 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7711 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7712 + | let sender = sender.clone();
|
7713 + | async move {
|
7714 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7715 + | sender.send(()).await.expect("receiver dropped early");
|
7716 + | result
|
7717 + | }
|
7718 + | })
|
7719 + | .build_unchecked();
|
7720 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7721 + | .await
|
7722 + | .expect("unable to make an HTTP request");
|
7723 + | ::pretty_assertions::assert_eq!(
|
7724 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7725 + | http_response.status()
|
7726 + | );
|
7727 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7728 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7729 + | http_response.headers(),
|
7730 + | expected_headers,
|
7731 + | ));
|
7732 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7733 + | .await
|
7734 + | .expect("unable to extract body to bytes");
|
7735 + | ::aws_smithy_protocol_test::assert_ok(
|
7736 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/map' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7737 + | );
|
7738 + | }
|
7739 + | }
|
7740 + |
|
7741 + | /// When a map member's key does not contain a valid enum value,
|
7742 + | /// the response should be a 400 ValidationException. Internal-only
|
7743 + | /// enum values are excluded from the response message.
|
7744 + | /// Test ID: RestJsonMalformedEnumMapKey_case1
|
7745 + | #[::tokio::test]
|
7746 + | #[::tracing_test::traced_test]
|
7747 + | #[should_panic]
|
7748 + | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
7749 + | {
|
7750 + | #[allow(unused_mut)]
|
7751 + | let mut http_request = ::http::Request::builder()
|
7752 + | .uri("/MalformedEnum")
|
7753 + | .method("POST")
|
7754 + | .header("content-type", "application/json")
|
7755 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7756 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7757 + | "{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes(),
|
7758 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7759 + | )),
|
7760 + | ))
|
7761 + | .unwrap();
|
7762 + | #[allow(unused_mut)]
|
7763 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7764 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7765 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7766 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7767 + | let sender = sender.clone();
|
7768 + | async move {
|
7769 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7770 + | sender.send(()).await.expect("receiver dropped early");
|
7771 + | result
|
7772 + | }
|
7773 + | })
|
7774 + | .build_unchecked();
|
7775 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7776 + | .await
|
7777 + | .expect("unable to make an HTTP request");
|
7778 + | ::pretty_assertions::assert_eq!(
|
7779 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7780 + | http_response.status()
|
7781 + | );
|
7782 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7783 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7784 + | http_response.headers(),
|
7785 + | expected_headers,
|
7786 + | ));
|
7787 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7788 + | .await
|
7789 + | .expect("unable to extract body to bytes");
|
7790 + | ::aws_smithy_protocol_test::assert_ok(
|
7791 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/map' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/map\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7792 + | );
|
7793 + | }
|
7794 + | }
|
7795 + |
|
7796 + | /// When a map member's value does not contain a valid enum value,
|
7797 + | /// the response should be a 400 ValidationException. Internal-only
|
7798 + | /// enum values are excluded from the response message.
|
7799 + | /// Test ID: RestJsonMalformedEnumMapValue_case0
|
7800 + | #[::tokio::test]
|
7801 + | #[::tracing_test::traced_test]
|
7802 + | #[should_panic]
|
7803 + | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
7804 + | {
|
7805 + | #[allow(unused_mut)]
|
7806 + | let mut http_request = ::http::Request::builder()
|
7807 + | .uri("/MalformedEnum")
|
7808 + | .method("POST")
|
7809 + | .header("content-type", "application/json")
|
7810 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7811 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7812 + | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
7813 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7814 + | )),
|
7815 + | ))
|
7816 + | .unwrap();
|
7817 + | #[allow(unused_mut)]
|
7818 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7819 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7820 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7821 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7822 + | let sender = sender.clone();
|
7823 + | async move {
|
7824 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7825 + | sender.send(()).await.expect("receiver dropped early");
|
7826 + | result
|
7827 + | }
|
7828 + | })
|
7829 + | .build_unchecked();
|
7830 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7831 + | .await
|
7832 + | .expect("unable to make an HTTP request");
|
7833 + | ::pretty_assertions::assert_eq!(
|
7834 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7835 + | http_response.status()
|
7836 + | );
|
7837 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7838 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7839 + | http_response.headers(),
|
7840 + | expected_headers,
|
7841 + | ));
|
7842 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7843 + | .await
|
7844 + | .expect("unable to extract body to bytes");
|
7845 + | ::aws_smithy_protocol_test::assert_ok(
|
7846 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map/abc' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/map/abc' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/map/abc\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7847 + | );
|
7848 + | }
|
7849 + | }
|
7850 + |
|
7851 + | /// When a map member's value does not contain a valid enum value,
|
7852 + | /// the response should be a 400 ValidationException. Internal-only
|
7853 + | /// enum values are excluded from the response message.
|
7854 + | /// Test ID: RestJsonMalformedEnumMapValue_case1
|
7855 + | #[::tokio::test]
|
7856 + | #[::tracing_test::traced_test]
|
7857 + | #[should_panic]
|
7858 + | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
7859 + | {
|
7860 + | #[allow(unused_mut)]
|
7861 + | let mut http_request = ::http::Request::builder()
|
7862 + | .uri("/MalformedEnum")
|
7863 + | .method("POST")
|
7864 + | .header("content-type", "application/json")
|
7865 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7866 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7867 + | "{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes(),
|
7868 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7869 + | )),
|
7870 + | ))
|
7871 + | .unwrap();
|
7872 + | #[allow(unused_mut)]
|
7873 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7874 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7875 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7876 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7877 + | let sender = sender.clone();
|
7878 + | async move {
|
7879 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7880 + | sender.send(()).await.expect("receiver dropped early");
|
7881 + | result
|
7882 + | }
|
7883 + | })
|
7884 + | .build_unchecked();
|
7885 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7886 + | .await
|
7887 + | .expect("unable to make an HTTP request");
|
7888 + | ::pretty_assertions::assert_eq!(
|
7889 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7890 + | http_response.status()
|
7891 + | );
|
7892 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7893 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7894 + | http_response.headers(),
|
7895 + | expected_headers,
|
7896 + | ));
|
7897 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7898 + | .await
|
7899 + | .expect("unable to extract body to bytes");
|
7900 + | ::aws_smithy_protocol_test::assert_ok(
|
7901 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/map/abc' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/map/abc' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/map/abc\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7902 + | );
|
7903 + | }
|
7904 + | }
|
7905 + |
|
7906 + | /// When a union member's value does not contain a valid enum value,
|
7907 + | /// the response should be a 400 ValidationException. Internal-only
|
7908 + | /// enum values are excluded from the response message.
|
7909 + | /// Test ID: RestJsonMalformedEnumUnion_case0
|
7910 + | #[::tokio::test]
|
7911 + | #[::tracing_test::traced_test]
|
7912 + | #[should_panic]
|
7913 + | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
7914 + | {
|
7915 + | #[allow(unused_mut)]
|
7916 + | let mut http_request = ::http::Request::builder()
|
7917 + | .uri("/MalformedEnum")
|
7918 + | .method("POST")
|
7919 + | .header("content-type", "application/json")
|
7920 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7921 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7922 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
7923 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7924 + | )),
|
7925 + | ))
|
7926 + | .unwrap();
|
7927 + | #[allow(unused_mut)]
|
7928 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7929 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7930 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7931 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7932 + | let sender = sender.clone();
|
7933 + | async move {
|
7934 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7935 + | sender.send(()).await.expect("receiver dropped early");
|
7936 + | result
|
7937 + | }
|
7938 + | })
|
7939 + | .build_unchecked();
|
7940 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7941 + | .await
|
7942 + | .expect("unable to make an HTTP request");
|
7943 + | ::pretty_assertions::assert_eq!(
|
7944 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7945 + | http_response.status()
|
7946 + | );
|
7947 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7948 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7949 + | http_response.headers(),
|
7950 + | expected_headers,
|
7951 + | ));
|
7952 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7953 + | .await
|
7954 + | .expect("unable to extract body to bytes");
|
7955 + | ::aws_smithy_protocol_test::assert_ok(
|
7956 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/union/first' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/union/first' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/union/first\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
7957 + | );
|
7958 + | }
|
7959 + | }
|
7960 + |
|
7961 + | /// When a union member's value does not contain a valid enum value,
|
7962 + | /// the response should be a 400 ValidationException. Internal-only
|
7963 + | /// enum values are excluded from the response message.
|
7964 + | /// Test ID: RestJsonMalformedEnumUnion_case1
|
7965 + | #[::tokio::test]
|
7966 + | #[::tracing_test::traced_test]
|
7967 + | #[should_panic]
|
7968 + | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
7969 + | {
|
7970 + | #[allow(unused_mut)]
|
7971 + | let mut http_request = ::http::Request::builder()
|
7972 + | .uri("/MalformedEnum")
|
7973 + | .method("POST")
|
7974 + | .header("content-type", "application/json")
|
7975 + | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
7976 + | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
7977 + | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|
7978 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7979 + | )),
|
7980 + | ))
|
7981 + | .unwrap();
|
7982 + | #[allow(unused_mut)]
|
7983 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7984 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7985 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7986 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7987 + | let sender = sender.clone();
|
7988 + | async move {
|
7989 + | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedEnumOutput, crate::error::MalformedEnumError> };
|
7990 + | sender.send(()).await.expect("receiver dropped early");
|
7991 + | result
|
7992 + | }
|
7993 + | })
|
7994 + | .build_unchecked();
|
7995 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7996 + | .await
|
7997 + | .expect("unable to make an HTTP request");
|
7998 + | ::pretty_assertions::assert_eq!(
|
7999 + | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8000 + | http_response.status()
|
8001 + | );
|
8002 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8003 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8004 + | http_response.headers(),
|
8005 + | expected_headers,
|
8006 + | ));
|
8007 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
8008 + | .await
|
8009 + | .expect("unable to extract body to bytes");
|
8010 + | ::aws_smithy_protocol_test::assert_ok(
|
8011 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/union/first' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\",\n \"fieldList\" : [{\"message\": \"Value at '/union/first' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, jkl]\", \"path\": \"/union/first\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
8012 + | );
|
8013 + | }
|
8014 + | }
|
8015 + | }
|