1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | #[cfg(test)]
|
3 - | #[allow(unreachable_code, unused_variables)]
|
4 - | mod server_malformed_enum_test {
|
5 - | /// When a string member does not contain a valid enum value,
|
6 - | /// the response should be a 400 ValidationException. Internal-only
|
7 - | /// enum values are excluded from the response message.
|
8 - | /// Test ID: RestJsonMalformedEnumString_case0
|
9 - | #[::tokio::test]
|
10 - | #[should_panic]
|
11 - | async fn rest_json_malformed_enum_string_case0_malformed_request() {
|
12 - | {
|
13 - | #[allow(unused_mut)]
|
14 - | let mut http_request = http::Request::builder()
|
15 - | .uri("/MalformedEnum")
|
16 - | .method("POST")
|
17 - | .header("content-type", "application/json")
|
18 - | .body(::aws_smithy_http_server::body::Body::from(
|
19 - | ::bytes::Bytes::from_static("{ \"string\" : \"ABC\" }".as_bytes()),
|
20 - | ))
|
21 - | .unwrap();
|
22 - | #[allow(unused_mut)]
|
23 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
24 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
25 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
26 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
27 - | let sender = sender.clone();
|
28 - | async move {
|
29 - | 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> };
|
30 - | sender.send(()).await.expect("receiver dropped early");
|
31 - | result
|
2 + | const CONTENT_TYPE_SENSITIVEVALIDATION: ::mime::Mime = ::mime::APPLICATION_JSON;
|
3 + | ::pin_project_lite::pin_project! {
|
4 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5 + | /// [`SensitiveValidationInput`](crate::input::SensitiveValidationInput) using modelled bindings.
|
6 + | pub struct SensitiveValidationInputFuture {
|
7 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SensitiveValidationInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
32 8 | }
|
33 - | })
|
34 - | .build_unchecked();
|
35 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
36 - | .await
|
37 - | .expect("unable to make an HTTP request");
|
38 - | ::pretty_assertions::assert_eq!(
|
39 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
40 - | http_response.status()
|
41 - | );
|
42 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
43 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
44 - | http_response.headers(),
|
45 - | expected_headers,
|
46 - | ));
|
47 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
9 + | }
|
10 + |
|
11 + | impl std::future::Future for SensitiveValidationInputFuture {
|
12 + | type Output = Result<
|
13 + | crate::input::SensitiveValidationInput,
|
14 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
15 + | >;
|
16 + |
|
17 + | fn poll(
|
18 + | self: std::pin::Pin<&mut Self>,
|
19 + | cx: &mut std::task::Context<'_>,
|
20 + | ) -> std::task::Poll<Self::Output> {
|
21 + | let this = self.project();
|
22 + | this.inner.as_mut().poll(cx)
|
23 + | }
|
24 + | }
|
25 + |
|
26 + | impl<B>
|
27 + | ::aws_smithy_http_server::request::FromRequest<
|
28 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
29 + | B,
|
30 + | > for crate::input::SensitiveValidationInput
|
31 + | where
|
32 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
33 + | B: 'static,
|
34 + |
|
35 + | B::Data: Send,
|
36 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
37 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
38 + | {
|
39 + | type Rejection = ::aws_smithy_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_http_server::protocol::accept_header_classifier(
|
45 + | request.headers(),
|
46 + | &CONTENT_TYPE_SENSITIVEVALIDATION,
|
47 + | ) {
|
48 + | return Err(::aws_smithy_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 + | )
|
48 53 | .await
|
49 - | .expect("unable to extract body to bytes");
|
50 - | ::aws_smithy_protocol_test::assert_ok(
|
51 - | ::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"))
|
54 + | .map_err(Into::into)
|
55 + | };
|
56 + | use ::futures_util::future::TryFutureExt;
|
57 + | let fut = fut.map_err(
|
58 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
59 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
60 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
61 + | e,
|
62 + | )
|
63 + | },
|
52 64 | );
|
65 + | SensitiveValidationInputFuture {
|
66 + | inner: Box::pin(fut),
|
53 67 | }
|
54 68 | }
|
55 - | /// When a string member does not contain a valid enum value,
|
56 - | /// the response should be a 400 ValidationException. Internal-only
|
57 - | /// enum values are excluded from the response message.
|
58 - | /// Test ID: RestJsonMalformedEnumString_case1
|
59 - | #[::tokio::test]
|
60 - | #[should_panic]
|
61 - | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
62 - | {
|
63 - | #[allow(unused_mut)]
|
64 - | let mut http_request = http::Request::builder()
|
65 - | .uri("/MalformedEnum")
|
66 - | .method("POST")
|
67 - | .header("content-type", "application/json")
|
68 - | .body(::aws_smithy_http_server::body::Body::from(
|
69 - | ::bytes::Bytes::from_static("{ \"string\" : \"XYZ\" }".as_bytes()),
|
70 - | ))
|
71 - | .unwrap();
|
72 - | #[allow(unused_mut)]
|
73 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
74 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
75 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
76 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
77 - | let sender = sender.clone();
|
78 - | async move {
|
79 - | 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> };
|
80 - | sender.send(()).await.expect("receiver dropped early");
|
81 - | result
|
69 + | }
|
70 + | impl
|
71 + | ::aws_smithy_http_server::response::IntoResponse<
|
72 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
73 + | > for crate::output::SensitiveValidationOutput
|
74 + | {
|
75 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
76 + | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_response(self) {
|
77 + | Ok(response) => response,
|
78 + | Err(e) => {
|
79 + | ::tracing::error!(error = %e, "failed to serialize response");
|
80 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
82 81 | }
|
83 - | })
|
84 - | .build_unchecked();
|
85 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
86 - | .await
|
87 - | .expect("unable to make an HTTP request");
|
88 - | ::pretty_assertions::assert_eq!(
|
89 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
90 - | http_response.status()
|
91 - | );
|
92 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
93 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
94 - | http_response.headers(),
|
95 - | expected_headers,
|
96 - | ));
|
97 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
98 - | .await
|
99 - | .expect("unable to extract body to bytes");
|
100 - | ::aws_smithy_protocol_test::assert_ok(
|
101 - | ::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"))
|
82 + | }
|
83 + | }
|
84 + | }
|
85 + | impl
|
86 + | ::aws_smithy_http_server::response::IntoResponse<
|
87 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
88 + | > for crate::error::SensitiveValidationError
|
89 + | {
|
90 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
91 + | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_error(
|
92 + | &self,
|
93 + | ) {
|
94 + | Ok(mut response) => {
|
95 + | response.extensions_mut().insert(
|
96 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
102 97 | );
|
98 + | response
|
99 + | }
|
100 + | Err(e) => {
|
101 + | ::tracing::error!(error = %e, "failed to serialize response");
|
102 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
103 103 | }
|
104 104 | }
|
105 - | /// When a string member does not contain a valid enum value,
|
106 - | /// the response should be a 400 ValidationException. Internal-only
|
107 - | /// enum values are excluded from the response message.
|
108 - | /// Test ID: RestJsonMalformedEnumTraitString_case0
|
105 + | }
|
106 + | }
|
107 + |
|
108 + | #[allow(unreachable_code, unused_variables)]
|
109 + | #[cfg(test)]
|
110 + | mod sensitive_validation_test {
|
111 + |
|
112 + | /// When a sensitive member fails validation, the resultant
|
113 + | /// ValidationException will omit the value of the input.
|
114 + | /// Test ID: RestJsonMalformedPatternSensitiveString
|
109 115 | #[::tokio::test]
|
110 - | #[should_panic]
|
111 - | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
116 + | #[::tracing_test::traced_test]
|
117 + | async fn rest_json_malformed_pattern_sensitive_string_malformed_request() {
|
112 118 | {
|
113 119 | #[allow(unused_mut)]
|
114 120 | let mut http_request = http::Request::builder()
|
115 - | .uri("/MalformedEnum")
|
121 + | .uri("/SensitiveValidation")
|
116 122 | .method("POST")
|
117 123 | .header("content-type", "application/json")
|
118 124 | .body(::aws_smithy_http_server::body::Body::from(
|
119 - | ::bytes::Bytes::from_static("{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes()),
|
125 + | ::bytes::Bytes::from_static("{ \"string\" : \"ABC\" }".as_bytes()),
|
120 126 | ))
|
121 127 | .unwrap();
|
122 128 | #[allow(unused_mut)]
|
123 129 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
124 130 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
125 131 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
126 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
132 + | .sensitive_validation(move |input: crate::input::SensitiveValidationInput| {
|
127 133 | let sender = sender.clone();
|
128 134 | async move {
|
129 - | 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> };
|
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> };
|
130 136 | sender.send(()).await.expect("receiver dropped early");
|
131 137 | result
|
132 138 | }
|
133 139 | })
|
134 140 | .build_unchecked();
|
135 141 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
136 142 | .await
|
137 143 | .expect("unable to make an HTTP request");
|
138 144 | ::pretty_assertions::assert_eq!(
|
139 145 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
140 146 | http_response.status()
|
141 147 | );
|
142 148 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
143 149 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
144 150 | http_response.headers(),
|
145 151 | expected_headers,
|
146 152 | ));
|
147 153 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
148 154 | .await
|
149 155 | .expect("unable to extract body to bytes");
|
150 156 | ::aws_smithy_protocol_test::assert_ok(
|
151 - | ::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"))
|
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"))
|
152 158 | );
|
153 159 | }
|
154 160 | }
|
155 - | /// When a string member does not contain a valid enum value,
|
156 - | /// the response should be a 400 ValidationException. Internal-only
|
157 - | /// enum values are excluded from the response message.
|
158 - | /// Test ID: RestJsonMalformedEnumTraitString_case1
|
159 - | #[::tokio::test]
|
160 - | #[should_panic]
|
161 - | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
162 - | {
|
163 - | #[allow(unused_mut)]
|
164 - | let mut http_request = http::Request::builder()
|
165 - | .uri("/MalformedEnum")
|
166 - | .method("POST")
|
167 - | .header("content-type", "application/json")
|
168 - | .body(::aws_smithy_http_server::body::Body::from(
|
169 - | ::bytes::Bytes::from_static("{ \"stringWithEnumTrait\" : \"XYZ\" }".as_bytes()),
|
170 - | ))
|
171 - | .unwrap();
|
172 - | #[allow(unused_mut)]
|
173 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
174 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
175 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
176 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
177 - | let sender = sender.clone();
|
178 - | async move {
|
179 - | 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> };
|
180 - | sender.send(()).await.expect("receiver dropped early");
|
181 - | result
|
161 + | }
|
162 + |
|
163 + | const CONTENT_TYPE_RECURSIVESTRUCTURES: ::mime::Mime = ::mime::APPLICATION_JSON;
|
164 + | ::pin_project_lite::pin_project! {
|
165 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
166 + | /// [`RecursiveStructuresInput`](crate::input::RecursiveStructuresInput) using modelled bindings.
|
167 + | pub struct RecursiveStructuresInputFuture {
|
168 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveStructuresInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
182 169 | }
|
183 - | })
|
184 - | .build_unchecked();
|
185 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
186 - | .await
|
187 - | .expect("unable to make an HTTP request");
|
188 - | ::pretty_assertions::assert_eq!(
|
189 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
190 - | http_response.status()
|
191 - | );
|
192 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
193 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
194 - | http_response.headers(),
|
195 - | expected_headers,
|
196 - | ));
|
197 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
170 + | }
|
171 + |
|
172 + | impl std::future::Future for RecursiveStructuresInputFuture {
|
173 + | type Output = Result<
|
174 + | crate::input::RecursiveStructuresInput,
|
175 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
176 + | >;
|
177 + |
|
178 + | fn poll(
|
179 + | self: std::pin::Pin<&mut Self>,
|
180 + | cx: &mut std::task::Context<'_>,
|
181 + | ) -> std::task::Poll<Self::Output> {
|
182 + | let this = self.project();
|
183 + | this.inner.as_mut().poll(cx)
|
184 + | }
|
185 + | }
|
186 + |
|
187 + | impl<B>
|
188 + | ::aws_smithy_http_server::request::FromRequest<
|
189 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
190 + | B,
|
191 + | > for crate::input::RecursiveStructuresInput
|
192 + | where
|
193 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
194 + | B: 'static,
|
195 + |
|
196 + | B::Data: Send,
|
197 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
198 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
199 + | {
|
200 + | type Rejection = ::aws_smithy_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_http_server::protocol::accept_header_classifier(
|
206 + | request.headers(),
|
207 + | &CONTENT_TYPE_RECURSIVESTRUCTURES,
|
208 + | ) {
|
209 + | return Err(::aws_smithy_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 + | )
|
198 214 | .await
|
199 - | .expect("unable to extract body to bytes");
|
200 - | ::aws_smithy_protocol_test::assert_ok(
|
201 - | ::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"))
|
215 + | .map_err(Into::into)
|
216 + | };
|
217 + | use ::futures_util::future::TryFutureExt;
|
218 + | let fut = fut.map_err(
|
219 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
220 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
221 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
222 + | e,
|
223 + | )
|
224 + | },
|
202 225 | );
|
226 + | RecursiveStructuresInputFuture {
|
227 + | inner: Box::pin(fut),
|
203 228 | }
|
204 229 | }
|
205 - | /// When a list member value does not contain a valid enum value,
|
206 - | /// the response should be a 400 ValidationException. Internal-only
|
207 - | /// enum values are excluded from the response message.
|
208 - | /// Test ID: RestJsonMalformedEnumList_case0
|
209 - | #[::tokio::test]
|
210 - | #[should_panic]
|
211 - | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
212 - | {
|
213 - | #[allow(unused_mut)]
|
214 - | let mut http_request = http::Request::builder()
|
215 - | .uri("/MalformedEnum")
|
216 - | .method("POST")
|
217 - | .header("content-type", "application/json")
|
218 - | .body(::aws_smithy_http_server::body::Body::from(
|
219 - | ::bytes::Bytes::from_static("{ \"list\" : [\"ABC\"] }".as_bytes()),
|
220 - | ))
|
221 - | .unwrap();
|
222 - | #[allow(unused_mut)]
|
223 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
224 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
225 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
226 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
227 - | let sender = sender.clone();
|
228 - | async move {
|
229 - | 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> };
|
230 - | sender.send(()).await.expect("receiver dropped early");
|
231 - | result
|
230 + | }
|
231 + | impl
|
232 + | ::aws_smithy_http_server::response::IntoResponse<
|
233 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
234 + | > for crate::output::RecursiveStructuresOutput
|
235 + | {
|
236 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
237 + | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_response(self) {
|
238 + | Ok(response) => response,
|
239 + | Err(e) => {
|
240 + | ::tracing::error!(error = %e, "failed to serialize response");
|
241 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
232 242 | }
|
233 - | })
|
234 - | .build_unchecked();
|
235 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
236 - | .await
|
237 - | .expect("unable to make an HTTP request");
|
238 - | ::pretty_assertions::assert_eq!(
|
239 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
240 - | http_response.status()
|
241 - | );
|
242 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
243 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
244 - | http_response.headers(),
|
245 - | expected_headers,
|
246 - | ));
|
247 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
248 - | .await
|
249 - | .expect("unable to extract body to bytes");
|
250 - | ::aws_smithy_protocol_test::assert_ok(
|
251 - | ::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"))
|
243 + | }
|
244 + | }
|
245 + | }
|
246 + | impl
|
247 + | ::aws_smithy_http_server::response::IntoResponse<
|
248 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
249 + | > for crate::error::RecursiveStructuresError
|
250 + | {
|
251 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
252 + | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_error(
|
253 + | &self,
|
254 + | ) {
|
255 + | Ok(mut response) => {
|
256 + | response.extensions_mut().insert(
|
257 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
252 258 | );
|
259 + | response
|
253 260 | }
|
261 + | Err(e) => {
|
262 + | ::tracing::error!(error = %e, "failed to serialize response");
|
263 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
254 264 | }
|
255 - | /// When a list member value does not contain a valid enum value,
|
256 - | /// the response should be a 400 ValidationException. Internal-only
|
257 - | /// enum values are excluded from the response message.
|
258 - | /// Test ID: RestJsonMalformedEnumList_case1
|
265 + | }
|
266 + | }
|
267 + | }
|
268 + |
|
269 + | #[allow(unreachable_code, unused_variables)]
|
270 + | #[cfg(test)]
|
271 + | mod recursive_structures_test {
|
272 + |
|
273 + | /// Validation should work with recursive structures.
|
274 + | /// Test ID: RestJsonRecursiveStructuresValidate
|
259 275 | #[::tokio::test]
|
260 - | #[should_panic]
|
261 - | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
262 - | {
|
276 + | #[::tracing_test::traced_test]
|
277 + | async fn rest_json_recursive_structures_validate_request() {
|
263 278 | #[allow(unused_mut)]
|
264 279 | let mut http_request = http::Request::builder()
|
265 - | .uri("/MalformedEnum")
|
280 + | .uri("/RecursiveStructures")
|
266 281 | .method("POST")
|
267 282 | .header("content-type", "application/json")
|
268 - | .body(::aws_smithy_http_server::body::Body::from(
|
269 - | ::bytes::Bytes::from_static("{ \"list\" : [\"XYZ\"] }".as_bytes()),
|
270 - | ))
|
271 - | .unwrap();
|
283 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"abc\" }\n }\n }\n}".as_bytes()))).unwrap();
|
272 284 | #[allow(unused_mut)]
|
273 285 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
274 286 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
275 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
276 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
287 + | let service =
|
288 + | crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
289 + | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
277 290 | let sender = sender.clone();
|
278 291 | async move {
|
279 - | 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> };
|
292 + | let result = {
|
293 + | let expected = crate::input::RecursiveStructuresInput {
|
294 + | union: ::std::option::Option::Some(
|
295 + | crate::model::RecursiveUnionOne::Union(::std::boxed::Box::new(
|
296 + | crate::model::RecursiveUnionTwo::Union(
|
297 + | crate::model::RecursiveUnionOne::String(
|
298 + | "abc"
|
299 + | .parse::<crate::model::RecursiveEnumString>()
|
300 + | .expect("static value validated to member"),
|
301 + | ),
|
302 + | ),
|
303 + | )),
|
304 + | ),
|
305 + | };
|
306 + | ::pretty_assertions::assert_eq!(input, expected);
|
307 + | let response = crate::output::RecursiveStructuresOutput {};
|
308 + | Ok(response)
|
309 + | };
|
280 310 | sender.send(()).await.expect("receiver dropped early");
|
281 311 | result
|
282 312 | }
|
283 313 | })
|
284 314 | .build_unchecked();
|
285 315 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
286 316 | .await
|
287 317 | .expect("unable to make an HTTP request");
|
288 - | ::pretty_assertions::assert_eq!(
|
289 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
290 - | http_response.status()
|
291 - | );
|
292 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
293 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
294 - | http_response.headers(),
|
295 - | expected_headers,
|
296 - | ));
|
297 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
298 - | .await
|
299 - | .expect("unable to extract body to bytes");
|
300 - | ::aws_smithy_protocol_test::assert_ok(
|
301 - | ::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"))
|
318 + | assert!(
|
319 + | receiver.recv().await.is_some(),
|
320 + | "we expected operation handler to be invoked but it was not entered"
|
302 321 | );
|
303 322 | }
|
304 - | }
|
305 - | /// When a map member's key does not contain a valid enum value,
|
306 - | /// the response should be a 400 ValidationException. Internal-only
|
307 - | /// enum values are excluded from the response message.
|
308 - | /// Test ID: RestJsonMalformedEnumMapKey_case0
|
323 + | /// When a value deeply nested in a recursive structure does not meet constraints,
|
324 + | /// a 400 ValidationException is returned.
|
325 + | /// Test ID: RestJsonMalformedRecursiveStructures
|
309 326 | #[::tokio::test]
|
310 - | #[should_panic]
|
311 - | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
327 + | #[::tracing_test::traced_test]
|
328 + | async fn rest_json_malformed_recursive_structures_malformed_request() {
|
312 329 | {
|
313 330 | #[allow(unused_mut)]
|
314 331 | let mut http_request = http::Request::builder()
|
315 - | .uri("/MalformedEnum")
|
332 + | .uri("/RecursiveStructures")
|
316 333 | .method("POST")
|
317 334 | .header("content-type", "application/json")
|
318 - | .body(::aws_smithy_http_server::body::Body::from(
|
319 - | ::bytes::Bytes::from_static("{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes()),
|
320 - | ))
|
321 - | .unwrap();
|
335 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"XYZ\" }\n }\n }\n}".as_bytes()))).unwrap();
|
322 336 | #[allow(unused_mut)]
|
323 337 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
324 338 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
325 339 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
326 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
340 + | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
327 341 | let sender = sender.clone();
|
328 342 | async move {
|
329 - | 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> };
|
343 + | 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> };
|
330 344 | sender.send(()).await.expect("receiver dropped early");
|
331 345 | result
|
332 346 | }
|
333 347 | })
|
334 348 | .build_unchecked();
|
335 349 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
336 350 | .await
|
337 351 | .expect("unable to make an HTTP request");
|
338 352 | ::pretty_assertions::assert_eq!(
|
339 353 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
340 354 | http_response.status()
|
341 355 | );
|
342 356 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
343 357 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
344 358 | http_response.headers(),
|
345 359 | expected_headers,
|
346 360 | ));
|
347 361 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
348 362 | .await
|
349 363 | .expect("unable to extract body to bytes");
|
350 364 | ::aws_smithy_protocol_test::assert_ok(
|
351 - | ::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"))
|
365 + | ::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"))
|
352 366 | );
|
353 367 | }
|
354 368 | }
|
355 - | /// When a map member's key does not contain a valid enum value,
|
356 - | /// the response should be a 400 ValidationException. Internal-only
|
357 - | /// enum values are excluded from the response message.
|
358 - | /// Test ID: RestJsonMalformedEnumMapKey_case1
|
359 - | #[::tokio::test]
|
360 - | #[should_panic]
|
361 - | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
362 - | {
|
363 - | #[allow(unused_mut)]
|
364 - | let mut http_request = http::Request::builder()
|
365 - | .uri("/MalformedEnum")
|
366 - | .method("POST")
|
367 - | .header("content-type", "application/json")
|
368 - | .body(::aws_smithy_http_server::body::Body::from(
|
369 - | ::bytes::Bytes::from_static("{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes()),
|
370 - | ))
|
371 - | .unwrap();
|
372 - | #[allow(unused_mut)]
|
373 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
374 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
375 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
376 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
377 - | let sender = sender.clone();
|
378 - | async move {
|
379 - | 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> };
|
380 - | sender.send(()).await.expect("receiver dropped early");
|
381 - | result
|
369 + | }
|
370 + |
|
371 + | const CONTENT_TYPE_MALFORMEDUNIQUEITEMS: ::mime::Mime = ::mime::APPLICATION_JSON;
|
372 + | ::pin_project_lite::pin_project! {
|
373 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
374 + | /// [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) using modelled bindings.
|
375 + | pub struct MalformedUniqueItemsInputFuture {
|
376 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedUniqueItemsInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
382 377 | }
|
383 - | })
|
384 - | .build_unchecked();
|
385 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
386 - | .await
|
387 - | .expect("unable to make an HTTP request");
|
388 - | ::pretty_assertions::assert_eq!(
|
389 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
390 - | http_response.status()
|
391 - | );
|
392 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
393 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
394 - | http_response.headers(),
|
395 - | expected_headers,
|
396 - | ));
|
397 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
378 + | }
|
379 + |
|
380 + | impl std::future::Future for MalformedUniqueItemsInputFuture {
|
381 + | type Output = Result<
|
382 + | crate::input::MalformedUniqueItemsInput,
|
383 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
384 + | >;
|
385 + |
|
386 + | fn poll(
|
387 + | self: std::pin::Pin<&mut Self>,
|
388 + | cx: &mut std::task::Context<'_>,
|
389 + | ) -> std::task::Poll<Self::Output> {
|
390 + | let this = self.project();
|
391 + | this.inner.as_mut().poll(cx)
|
392 + | }
|
393 + | }
|
394 + |
|
395 + | impl<B>
|
396 + | ::aws_smithy_http_server::request::FromRequest<
|
397 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
398 + | B,
|
399 + | > for crate::input::MalformedUniqueItemsInput
|
400 + | where
|
401 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
402 + | B: 'static,
|
403 + |
|
404 + | B::Data: Send,
|
405 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
406 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
407 + | {
|
408 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
409 + | type Future = MalformedUniqueItemsInputFuture;
|
410 + |
|
411 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
412 + | let fut = async move {
|
413 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
414 + | request.headers(),
|
415 + | &CONTENT_TYPE_MALFORMEDUNIQUEITEMS,
|
416 + | ) {
|
417 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
418 + | }
|
419 + | crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items_http_request(request)
|
398 420 | .await
|
399 - | .expect("unable to extract body to bytes");
|
400 - | ::aws_smithy_protocol_test::assert_ok(
|
401 - | ::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"))
|
421 + | .map_err(Into::into)
|
422 + | };
|
423 + | use ::futures_util::future::TryFutureExt;
|
424 + | let fut = fut.map_err(
|
425 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
426 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
427 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
428 + | e,
|
429 + | )
|
430 + | },
|
402 431 | );
|
432 + | MalformedUniqueItemsInputFuture {
|
433 + | inner: Box::pin(fut),
|
403 434 | }
|
404 435 | }
|
405 - | /// When a map member's value does not contain a valid enum value,
|
406 - | /// the response should be a 400 ValidationException. Internal-only
|
407 - | /// enum values are excluded from the response message.
|
408 - | /// Test ID: RestJsonMalformedEnumMapValue_case0
|
436 + | }
|
437 + | impl
|
438 + | ::aws_smithy_http_server::response::IntoResponse<
|
439 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
440 + | > for crate::output::MalformedUniqueItemsOutput
|
441 + | {
|
442 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
443 + | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_response(self) {
|
444 + | Ok(response) => response,
|
445 + | Err(e) => {
|
446 + | ::tracing::error!(error = %e, "failed to serialize response");
|
447 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
448 + | }
|
449 + | }
|
450 + | }
|
451 + | }
|
452 + | impl
|
453 + | ::aws_smithy_http_server::response::IntoResponse<
|
454 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
455 + | > for crate::error::MalformedUniqueItemsError
|
456 + | {
|
457 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
458 + | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_error(&self) {
|
459 + | Ok(mut response) => {
|
460 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
461 + | response
|
462 + | },
|
463 + | Err(e) => {
|
464 + | ::tracing::error!(error = %e, "failed to serialize response");
|
465 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
466 + | }
|
467 + | }
|
468 + | }
|
469 + | }
|
470 + |
|
471 + | #[allow(unreachable_code, unused_variables)]
|
472 + | #[cfg(test)]
|
473 + | mod malformed_unique_items_test {
|
474 + |
|
475 + | /// When a blob list contains non-unique values,
|
476 + | /// the response should be a 400 ValidationException.
|
477 + | /// Test ID: RestJsonMalformedUniqueItemsBlobList
|
409 478 | #[::tokio::test]
|
479 + | #[::tracing_test::traced_test]
|
410 480 | #[should_panic]
|
411 - | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
481 + | async fn rest_json_malformed_unique_items_blob_list_malformed_request() {
|
412 482 | {
|
413 483 | #[allow(unused_mut)]
|
414 484 | let mut http_request = http::Request::builder()
|
415 - | .uri("/MalformedEnum")
|
485 + | .uri("/MalformedUniqueItems")
|
416 486 | .method("POST")
|
417 487 | .header("content-type", "application/json")
|
418 488 | .body(::aws_smithy_http_server::body::Body::from(
|
419 - | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes()),
|
489 + | ::bytes::Bytes::from_static(
|
490 + | "{ \"blobList\" : [\"YQ==\", \"YQ==\"] }".as_bytes(),
|
491 + | ),
|
420 492 | ))
|
421 493 | .unwrap();
|
422 494 | #[allow(unused_mut)]
|
423 495 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
424 496 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
425 497 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
426 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
498 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
427 499 | let sender = sender.clone();
|
428 500 | async move {
|
429 - | 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> };
|
501 + | 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> };
|
430 502 | sender.send(()).await.expect("receiver dropped early");
|
431 503 | result
|
432 504 | }
|
433 505 | })
|
434 506 | .build_unchecked();
|
435 507 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
436 508 | .await
|
437 509 | .expect("unable to make an HTTP request");
|
438 510 | ::pretty_assertions::assert_eq!(
|
439 511 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
440 512 | http_response.status()
|
441 513 | );
|
442 514 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
443 515 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
444 516 | http_response.headers(),
|
445 517 | expected_headers,
|
446 518 | ));
|
447 519 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
448 520 | .await
|
449 521 | .expect("unable to extract body to bytes");
|
450 522 | ::aws_smithy_protocol_test::assert_ok(
|
451 - | ::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"))
|
523 + | ::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"))
|
452 524 | );
|
453 525 | }
|
454 526 | }
|
455 - | /// When a map member's value does not contain a valid enum value,
|
456 - | /// the response should be a 400 ValidationException. Internal-only
|
457 - | /// enum values are excluded from the response message.
|
458 - | /// Test ID: RestJsonMalformedEnumMapValue_case1
|
527 + | /// When a boolean list contains non-unique values,
|
528 + | /// the response should be a 400 ValidationException.
|
529 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case0
|
459 530 | #[::tokio::test]
|
531 + | #[::tracing_test::traced_test]
|
460 532 | #[should_panic]
|
461 - | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
533 + | async fn rest_json_malformed_unique_items_boolean_list_case0_malformed_request() {
|
462 534 | {
|
463 535 | #[allow(unused_mut)]
|
464 536 | let mut http_request = http::Request::builder()
|
465 - | .uri("/MalformedEnum")
|
537 + | .uri("/MalformedUniqueItems")
|
466 538 | .method("POST")
|
467 539 | .header("content-type", "application/json")
|
468 540 | .body(::aws_smithy_http_server::body::Body::from(
|
469 - | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes()),
|
541 + | ::bytes::Bytes::from_static("{ \"booleanList\" : [true, true] }".as_bytes()),
|
470 542 | ))
|
471 543 | .unwrap();
|
472 544 | #[allow(unused_mut)]
|
473 545 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
474 546 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
475 547 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
476 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
548 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
477 549 | let sender = sender.clone();
|
478 550 | async move {
|
479 - | 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> };
|
551 + | 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> };
|
480 552 | sender.send(()).await.expect("receiver dropped early");
|
481 553 | result
|
482 554 | }
|
483 555 | })
|
484 556 | .build_unchecked();
|
485 557 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
486 558 | .await
|
487 559 | .expect("unable to make an HTTP request");
|
488 560 | ::pretty_assertions::assert_eq!(
|
489 561 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
490 562 | http_response.status()
|
491 563 | );
|
492 564 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
493 565 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
494 566 | http_response.headers(),
|
495 567 | expected_headers,
|
496 568 | ));
|
497 569 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
498 570 | .await
|
499 571 | .expect("unable to extract body to bytes");
|
500 572 | ::aws_smithy_protocol_test::assert_ok(
|
501 - | ::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"))
|
573 + | ::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"))
|
502 574 | );
|
503 575 | }
|
504 576 | }
|
505 - | /// When a union member's value does not contain a valid enum value,
|
506 - | /// the response should be a 400 ValidationException. Internal-only
|
507 - | /// enum values are excluded from the response message.
|
508 - | /// Test ID: RestJsonMalformedEnumUnion_case0
|
577 + | /// When a boolean list contains non-unique values,
|
578 + | /// the response should be a 400 ValidationException.
|
579 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case1
|
509 580 | #[::tokio::test]
|
581 + | #[::tracing_test::traced_test]
|
510 582 | #[should_panic]
|
511 - | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
583 + | async fn rest_json_malformed_unique_items_boolean_list_case1_malformed_request() {
|
512 584 | {
|
513 585 | #[allow(unused_mut)]
|
514 586 | let mut http_request = http::Request::builder()
|
515 - | .uri("/MalformedEnum")
|
587 + | .uri("/MalformedUniqueItems")
|
516 588 | .method("POST")
|
517 589 | .header("content-type", "application/json")
|
518 590 | .body(::aws_smithy_http_server::body::Body::from(
|
519 - | ::bytes::Bytes::from_static(
|
520 - | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
521 - | ),
|
591 + | ::bytes::Bytes::from_static("{ \"booleanList\" : [false, false] }".as_bytes()),
|
522 592 | ))
|
523 593 | .unwrap();
|
524 594 | #[allow(unused_mut)]
|
525 595 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
526 596 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
527 597 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
528 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
598 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
529 599 | let sender = sender.clone();
|
530 600 | async move {
|
531 - | 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> };
|
601 + | 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> };
|
532 602 | sender.send(()).await.expect("receiver dropped early");
|
533 603 | result
|
534 604 | }
|
535 605 | })
|
536 606 | .build_unchecked();
|
537 607 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
538 608 | .await
|
539 609 | .expect("unable to make an HTTP request");
|
540 610 | ::pretty_assertions::assert_eq!(
|
541 611 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
542 612 | http_response.status()
|
543 613 | );
|
544 614 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
545 615 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
546 616 | http_response.headers(),
|
547 617 | expected_headers,
|
548 618 | ));
|
549 619 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
550 620 | .await
|
551 621 | .expect("unable to extract body to bytes");
|
552 622 | ::aws_smithy_protocol_test::assert_ok(
|
553 - | ::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"))
|
623 + | ::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"))
|
554 624 | );
|
555 625 | }
|
556 626 | }
|
557 - | /// When a union member's value does not contain a valid enum value,
|
558 - | /// the response should be a 400 ValidationException. Internal-only
|
559 - | /// enum values are excluded from the response message.
|
560 - | /// Test ID: RestJsonMalformedEnumUnion_case1
|
627 + | /// When a string list contains non-unique values,
|
628 + | /// the response should be a 400 ValidationException.
|
629 + | /// Test ID: RestJsonMalformedUniqueItemsStringList
|
561 630 | #[::tokio::test]
|
631 + | #[::tracing_test::traced_test]
|
562 632 | #[should_panic]
|
563 - | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
633 + | async fn rest_json_malformed_unique_items_string_list_malformed_request() {
|
564 634 | {
|
565 635 | #[allow(unused_mut)]
|
566 636 | let mut http_request = http::Request::builder()
|
567 - | .uri("/MalformedEnum")
|
637 + | .uri("/MalformedUniqueItems")
|
568 638 | .method("POST")
|
569 639 | .header("content-type", "application/json")
|
570 640 | .body(::aws_smithy_http_server::body::Body::from(
|
571 641 | ::bytes::Bytes::from_static(
|
572 - | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|
642 + | "{ \"stringList\" : [\"abc\", \"abc\"] }".as_bytes(),
|
573 643 | ),
|
574 644 | ))
|
575 645 | .unwrap();
|
576 646 | #[allow(unused_mut)]
|
577 647 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
578 648 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
579 649 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
580 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
650 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
581 651 | let sender = sender.clone();
|
582 652 | async move {
|
583 - | 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> };
|
653 + | 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> };
|
584 654 | sender.send(()).await.expect("receiver dropped early");
|
585 655 | result
|
586 656 | }
|
587 657 | })
|
588 658 | .build_unchecked();
|
589 659 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
590 660 | .await
|
591 661 | .expect("unable to make an HTTP request");
|
592 662 | ::pretty_assertions::assert_eq!(
|
593 663 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
594 664 | http_response.status()
|
595 665 | );
|
596 666 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
597 667 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
598 668 | http_response.headers(),
|
599 669 | expected_headers,
|
600 670 | ));
|
601 671 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
602 672 | .await
|
603 673 | .expect("unable to extract body to bytes");
|
604 674 | ::aws_smithy_protocol_test::assert_ok(
|
605 - | ::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"))
|
675 + | ::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"))
|
606 676 | );
|
607 677 | }
|
608 678 | }
|
609 - | }
|
610 - | #[cfg(test)]
|
611 - | #[allow(unreachable_code, unused_variables)]
|
612 - | mod server_malformed_length_test {
|
613 - | /// When a blob member does not fit within length bounds,
|
679 + | /// When a byte list contains non-unique values,
|
614 680 | /// the response should be a 400 ValidationException.
|
615 - | /// Test ID: RestJsonMalformedLengthBlob_case0
|
681 + | /// Test ID: RestJsonMalformedUniqueItemsByteList
|
616 682 | #[::tokio::test]
|
617 - | async fn rest_json_malformed_length_blob_case0_malformed_request() {
|
683 + | #[::tracing_test::traced_test]
|
684 + | #[should_panic]
|
685 + | async fn rest_json_malformed_unique_items_byte_list_malformed_request() {
|
618 686 | {
|
619 687 | #[allow(unused_mut)]
|
620 688 | let mut http_request = http::Request::builder()
|
621 - | .uri("/MalformedLength")
|
689 + | .uri("/MalformedUniqueItems")
|
622 690 | .method("POST")
|
623 691 | .header("content-type", "application/json")
|
624 692 | .body(::aws_smithy_http_server::body::Body::from(
|
625 - | ::bytes::Bytes::from_static("{ \"blob\" : \"YQ==\" }".as_bytes()),
|
693 + | ::bytes::Bytes::from_static("{ \"byteList\" : [1, 1] }".as_bytes()),
|
626 694 | ))
|
627 695 | .unwrap();
|
628 696 | #[allow(unused_mut)]
|
629 697 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
630 698 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
631 699 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
632 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
700 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
633 701 | let sender = sender.clone();
|
634 702 | async move {
|
635 - | 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> };
|
703 + | 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> };
|
636 704 | sender.send(()).await.expect("receiver dropped early");
|
637 705 | result
|
638 706 | }
|
639 707 | })
|
640 708 | .build_unchecked();
|
641 709 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
642 710 | .await
|
643 711 | .expect("unable to make an HTTP request");
|
644 712 | ::pretty_assertions::assert_eq!(
|
645 713 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
646 714 | http_response.status()
|
647 715 | );
|
648 716 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
649 717 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
650 718 | http_response.headers(),
|
651 719 | expected_headers,
|
652 720 | ));
|
653 721 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
654 722 | .await
|
655 723 | .expect("unable to extract body to bytes");
|
656 724 | ::aws_smithy_protocol_test::assert_ok(
|
657 - | ::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"))
|
725 + | ::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"))
|
658 726 | );
|
659 727 | }
|
660 728 | }
|
661 - | /// When a blob member does not fit within length bounds,
|
729 + | /// When a short list contains non-unique values,
|
662 730 | /// the response should be a 400 ValidationException.
|
663 - | /// Test ID: RestJsonMalformedLengthBlob_case1
|
731 + | /// Test ID: RestJsonMalformedUniqueItemsShortList
|
664 732 | #[::tokio::test]
|
665 - | async fn rest_json_malformed_length_blob_case1_malformed_request() {
|
733 + | #[::tracing_test::traced_test]
|
734 + | #[should_panic]
|
735 + | async fn rest_json_malformed_unique_items_short_list_malformed_request() {
|
666 736 | {
|
667 737 | #[allow(unused_mut)]
|
668 738 | let mut http_request = http::Request::builder()
|
669 - | .uri("/MalformedLength")
|
739 + | .uri("/MalformedUniqueItems")
|
670 740 | .method("POST")
|
671 741 | .header("content-type", "application/json")
|
672 742 | .body(::aws_smithy_http_server::body::Body::from(
|
673 - | ::bytes::Bytes::from_static(
|
674 - | "{ \"blob\" : \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" }".as_bytes(),
|
675 - | ),
|
743 + | ::bytes::Bytes::from_static("{ \"shortList\" : [2, 2] }".as_bytes()),
|
676 744 | ))
|
677 745 | .unwrap();
|
678 746 | #[allow(unused_mut)]
|
679 747 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
680 748 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
681 749 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
682 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
750 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
683 751 | let sender = sender.clone();
|
684 752 | async move {
|
685 - | 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> };
|
753 + | 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> };
|
686 754 | sender.send(()).await.expect("receiver dropped early");
|
687 755 | result
|
688 756 | }
|
689 757 | })
|
690 758 | .build_unchecked();
|
691 759 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
692 760 | .await
|
693 761 | .expect("unable to make an HTTP request");
|
694 762 | ::pretty_assertions::assert_eq!(
|
695 763 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
696 764 | http_response.status()
|
697 765 | );
|
698 766 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
699 767 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
700 768 | http_response.headers(),
|
701 769 | expected_headers,
|
702 770 | ));
|
703 771 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
704 772 | .await
|
705 773 | .expect("unable to extract body to bytes");
|
706 774 | ::aws_smithy_protocol_test::assert_ok(
|
707 - | ::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"))
|
775 + | ::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"))
|
708 776 | );
|
709 777 | }
|
710 778 | }
|
711 - | /// When a string member does not fit within length bounds,
|
779 + | /// When an integer list contains non-unique values,
|
712 780 | /// the response should be a 400 ValidationException.
|
713 - | /// Test ID: RestJsonMalformedLengthString_case0
|
781 + | /// Test ID: RestJsonMalformedUniqueItemsIntegerList
|
714 782 | #[::tokio::test]
|
715 - | async fn rest_json_malformed_length_string_case0_malformed_request() {
|
783 + | #[::tracing_test::traced_test]
|
784 + | #[should_panic]
|
785 + | async fn rest_json_malformed_unique_items_integer_list_malformed_request() {
|
716 786 | {
|
717 787 | #[allow(unused_mut)]
|
718 788 | let mut http_request = http::Request::builder()
|
719 - | .uri("/MalformedLength")
|
789 + | .uri("/MalformedUniqueItems")
|
720 790 | .method("POST")
|
721 791 | .header("content-type", "application/json")
|
722 792 | .body(::aws_smithy_http_server::body::Body::from(
|
723 - | ::bytes::Bytes::from_static("{ \"string\" : \"a\" }".as_bytes()),
|
793 + | ::bytes::Bytes::from_static("{ \"integerList\" : [3, 3] }".as_bytes()),
|
724 794 | ))
|
725 795 | .unwrap();
|
726 796 | #[allow(unused_mut)]
|
727 797 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
728 798 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
729 799 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
730 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
800 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
731 801 | let sender = sender.clone();
|
732 802 | async move {
|
733 - | 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> };
|
803 + | 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> };
|
734 804 | sender.send(()).await.expect("receiver dropped early");
|
735 805 | result
|
736 806 | }
|
737 807 | })
|
738 808 | .build_unchecked();
|
739 809 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
740 810 | .await
|
741 811 | .expect("unable to make an HTTP request");
|
742 812 | ::pretty_assertions::assert_eq!(
|
743 813 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
744 814 | http_response.status()
|
745 815 | );
|
746 816 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
747 817 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
748 818 | http_response.headers(),
|
749 819 | expected_headers,
|
750 820 | ));
|
751 821 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
752 822 | .await
|
753 823 | .expect("unable to extract body to bytes");
|
754 824 | ::aws_smithy_protocol_test::assert_ok(
|
755 - | ::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"))
|
825 + | ::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"))
|
756 826 | );
|
757 827 | }
|
758 828 | }
|
759 - | /// When a string member does not fit within length bounds,
|
829 + | /// When an integer list contains non-unique values,
|
760 830 | /// the response should be a 400 ValidationException.
|
761 - | /// Test ID: RestJsonMalformedLengthString_case1
|
831 + | /// Test ID: RestJsonMalformedUniqueItemsLongList
|
762 832 | #[::tokio::test]
|
763 - | async fn rest_json_malformed_length_string_case1_malformed_request() {
|
833 + | #[::tracing_test::traced_test]
|
834 + | #[should_panic]
|
835 + | async fn rest_json_malformed_unique_items_long_list_malformed_request() {
|
764 836 | {
|
765 837 | #[allow(unused_mut)]
|
766 838 | let mut http_request = http::Request::builder()
|
767 - | .uri("/MalformedLength")
|
839 + | .uri("/MalformedUniqueItems")
|
768 840 | .method("POST")
|
769 841 | .header("content-type", "application/json")
|
770 842 | .body(::aws_smithy_http_server::body::Body::from(
|
771 - | ::bytes::Bytes::from_static(
|
772 - | "{ \"string\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
773 - | ),
|
843 + | ::bytes::Bytes::from_static("{ \"longList\" : [4, 4] }".as_bytes()),
|
774 844 | ))
|
775 845 | .unwrap();
|
776 846 | #[allow(unused_mut)]
|
777 847 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
778 848 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
779 849 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
780 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
850 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
781 851 | let sender = sender.clone();
|
782 852 | async move {
|
783 - | 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> };
|
853 + | 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> };
|
784 854 | sender.send(()).await.expect("receiver dropped early");
|
785 855 | result
|
786 856 | }
|
787 857 | })
|
788 858 | .build_unchecked();
|
789 859 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
790 860 | .await
|
791 861 | .expect("unable to make an HTTP request");
|
792 862 | ::pretty_assertions::assert_eq!(
|
793 863 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
794 864 | http_response.status()
|
795 865 | );
|
796 866 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
797 867 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
798 868 | http_response.headers(),
|
799 869 | expected_headers,
|
800 870 | ));
|
801 871 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
802 872 | .await
|
803 873 | .expect("unable to extract body to bytes");
|
804 874 | ::aws_smithy_protocol_test::assert_ok(
|
805 - | ::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"))
|
875 + | ::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"))
|
806 876 | );
|
807 877 | }
|
808 878 | }
|
809 - | /// When a string member does not fit within length bounds,
|
879 + | /// When a timestamp list contains non-unique values,
|
810 880 | /// the response should be a 400 ValidationException.
|
811 - | /// Test ID: RestJsonMalformedLengthString_case2
|
881 + | /// Test ID: RestJsonMalformedUniqueItemsTimestampList
|
812 882 | #[::tokio::test]
|
813 - | async fn rest_json_malformed_length_string_case2_malformed_request() {
|
883 + | #[::tracing_test::traced_test]
|
884 + | #[should_panic]
|
885 + | async fn rest_json_malformed_unique_items_timestamp_list_malformed_request() {
|
814 886 | {
|
815 887 | #[allow(unused_mut)]
|
816 888 | let mut http_request = http::Request::builder()
|
817 - | .uri("/MalformedLength")
|
889 + | .uri("/MalformedUniqueItems")
|
818 890 | .method("POST")
|
819 891 | .header("content-type", "application/json")
|
820 892 | .body(::aws_smithy_http_server::body::Body::from(
|
821 - | ::bytes::Bytes::from_static("{ \"string\" : \"👍\" }".as_bytes()),
|
893 + | ::bytes::Bytes::from_static(
|
894 + | "{ \"timestampList\" : [1676660607, 1676660607] }".as_bytes(),
|
895 + | ),
|
822 896 | ))
|
823 897 | .unwrap();
|
824 898 | #[allow(unused_mut)]
|
825 899 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
826 900 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
827 901 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
828 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
902 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
829 903 | let sender = sender.clone();
|
830 904 | async move {
|
831 - | 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> };
|
905 + | 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> };
|
832 906 | sender.send(()).await.expect("receiver dropped early");
|
833 907 | result
|
834 908 | }
|
835 909 | })
|
836 910 | .build_unchecked();
|
837 911 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
838 912 | .await
|
839 913 | .expect("unable to make an HTTP request");
|
840 914 | ::pretty_assertions::assert_eq!(
|
841 915 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
842 916 | http_response.status()
|
843 917 | );
|
844 918 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
845 919 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
846 920 | http_response.headers(),
|
847 921 | expected_headers,
|
848 922 | ));
|
849 923 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
850 924 | .await
|
851 925 | .expect("unable to extract body to bytes");
|
852 926 | ::aws_smithy_protocol_test::assert_ok(
|
853 - | ::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"))
|
927 + | ::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"))
|
854 928 | );
|
855 929 | }
|
856 930 | }
|
857 - | /// When a string member does not fit within length bounds,
|
931 + | /// When a date-time timestamp list contains non-unique values,
|
858 932 | /// the response should be a 400 ValidationException.
|
859 - | /// Test ID: RestJsonMalformedLengthMinString
|
933 + | /// Test ID: RestJsonMalformedUniqueItemsDateTimeList
|
860 934 | #[::tokio::test]
|
861 - | async fn rest_json_malformed_length_min_string_malformed_request() {
|
935 + | #[::tracing_test::traced_test]
|
936 + | #[should_panic]
|
937 + | async fn rest_json_malformed_unique_items_date_time_list_malformed_request() {
|
862 938 | {
|
863 939 | #[allow(unused_mut)]
|
864 940 | let mut http_request = http::Request::builder()
|
865 - | .uri("/MalformedLength")
|
941 + | .uri("/MalformedUniqueItems")
|
866 942 | .method("POST")
|
867 943 | .header("content-type", "application/json")
|
868 - | .body(::aws_smithy_http_server::body::Body::from(
|
869 - | ::bytes::Bytes::from_static("{ \"minString\" : \"a\" }".as_bytes()),
|
870 - | ))
|
871 - | .unwrap();
|
944 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"dateTimeList\" : [\"1985-04-12T23:20:50.52Z\", \"1985-04-12T23:20:50.52Z\"] }".as_bytes()))).unwrap();
|
872 945 | #[allow(unused_mut)]
|
873 946 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
874 947 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
875 948 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
876 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
949 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
877 950 | let sender = sender.clone();
|
878 951 | async move {
|
879 - | 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> };
|
952 + | 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> };
|
880 953 | sender.send(()).await.expect("receiver dropped early");
|
881 954 | result
|
882 955 | }
|
883 956 | })
|
884 957 | .build_unchecked();
|
885 958 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
886 959 | .await
|
887 960 | .expect("unable to make an HTTP request");
|
888 961 | ::pretty_assertions::assert_eq!(
|
889 962 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
890 963 | http_response.status()
|
891 964 | );
|
892 965 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
893 966 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
894 967 | http_response.headers(),
|
895 968 | expected_headers,
|
896 969 | ));
|
897 970 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
898 971 | .await
|
899 972 | .expect("unable to extract body to bytes");
|
900 973 | ::aws_smithy_protocol_test::assert_ok(
|
901 - | ::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"))
|
974 + | ::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"))
|
902 975 | );
|
903 976 | }
|
904 977 | }
|
905 - | /// When a string member does not fit within length bounds,
|
978 + | /// When a http-date timestamp list contains non-unique values,
|
906 979 | /// the response should be a 400 ValidationException.
|
907 - | /// Test ID: RestJsonMalformedLengthMaxString
|
980 + | /// Test ID: RestJsonMalformedUniqueItemsHttpDateList_case0
|
908 981 | #[::tokio::test]
|
909 - | async fn rest_json_malformed_length_max_string_malformed_request() {
|
982 + | #[::tracing_test::traced_test]
|
983 + | #[should_panic]
|
984 + | async fn rest_json_malformed_unique_items_http_date_list_case0_malformed_request() {
|
910 985 | {
|
911 986 | #[allow(unused_mut)]
|
912 987 | let mut http_request = http::Request::builder()
|
913 - | .uri("/MalformedLength")
|
988 + | .uri("/MalformedUniqueItems")
|
914 989 | .method("POST")
|
915 990 | .header("content-type", "application/json")
|
916 - | .body(::aws_smithy_http_server::body::Body::from(
|
917 - | ::bytes::Bytes::from_static(
|
918 - | "{ \"maxString\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
919 - | ),
|
920 - | ))
|
921 - | .unwrap();
|
991 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"httpDateList\" : [\"Tue, 29 Apr 2014 18:30:38 GMT\", \"Tue, 29 Apr 2014 18:30:38 GMT\"] }".as_bytes()))).unwrap();
|
922 992 | #[allow(unused_mut)]
|
923 993 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
924 994 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
925 995 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
926 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
996 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
927 997 | let sender = sender.clone();
|
928 998 | async move {
|
929 - | 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> };
|
999 + | 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> };
|
930 1000 | sender.send(()).await.expect("receiver dropped early");
|
931 1001 | result
|
932 1002 | }
|
933 1003 | })
|
934 1004 | .build_unchecked();
|
935 1005 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
936 1006 | .await
|
937 1007 | .expect("unable to make an HTTP request");
|
938 1008 | ::pretty_assertions::assert_eq!(
|
939 1009 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
940 1010 | http_response.status()
|
941 1011 | );
|
942 1012 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
943 1013 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
944 1014 | http_response.headers(),
|
945 1015 | expected_headers,
|
946 1016 | ));
|
947 1017 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
948 1018 | .await
|
949 1019 | .expect("unable to extract body to bytes");
|
950 1020 | ::aws_smithy_protocol_test::assert_ok(
|
951 - | ::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"))
|
1021 + | ::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"))
|
952 1022 | );
|
953 1023 | }
|
954 1024 | }
|
955 - | /// When a list member does not fit within length bounds,
|
1025 + | /// When an enum list contains non-unique values,
|
956 1026 | /// the response should be a 400 ValidationException.
|
957 - | /// Test ID: RestJsonMalformedLengthList_case0
|
1027 + | /// Test ID: RestJsonMalformedUniqueItemsEnumList
|
958 1028 | #[::tokio::test]
|
959 - | async fn rest_json_malformed_length_list_case0_malformed_request() {
|
1029 + | #[::tracing_test::traced_test]
|
1030 + | #[should_panic]
|
1031 + | async fn rest_json_malformed_unique_items_enum_list_malformed_request() {
|
960 1032 | {
|
961 1033 | #[allow(unused_mut)]
|
962 1034 | let mut http_request = http::Request::builder()
|
963 - | .uri("/MalformedLength")
|
1035 + | .uri("/MalformedUniqueItems")
|
964 1036 | .method("POST")
|
965 1037 | .header("content-type", "application/json")
|
966 1038 | .body(::aws_smithy_http_server::body::Body::from(
|
967 - | ::bytes::Bytes::from_static("{ \"list\" : [\"abc\"] }".as_bytes()),
|
1039 + | ::bytes::Bytes::from_static("{ \"enumList\" : [\"Foo\", \"Foo\"] }".as_bytes()),
|
968 1040 | ))
|
969 1041 | .unwrap();
|
970 1042 | #[allow(unused_mut)]
|
971 1043 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
972 1044 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
973 1045 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
974 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1046 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
975 1047 | let sender = sender.clone();
|
976 1048 | async move {
|
977 - | 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> };
|
1049 + | 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> };
|
978 1050 | sender.send(()).await.expect("receiver dropped early");
|
979 1051 | result
|
980 1052 | }
|
981 1053 | })
|
982 1054 | .build_unchecked();
|
983 1055 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
984 1056 | .await
|
985 1057 | .expect("unable to make an HTTP request");
|
986 1058 | ::pretty_assertions::assert_eq!(
|
987 1059 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
988 1060 | http_response.status()
|
989 1061 | );
|
990 1062 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
991 1063 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
992 1064 | http_response.headers(),
|
993 1065 | expected_headers,
|
994 1066 | ));
|
995 1067 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
996 1068 | .await
|
997 1069 | .expect("unable to extract body to bytes");
|
998 1070 | ::aws_smithy_protocol_test::assert_ok(
|
999 - | ::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"))
|
1071 + | ::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"))
|
1000 1072 | );
|
1001 1073 | }
|
1002 1074 | }
|
1003 - | /// When a list member does not fit within length bounds,
|
1075 + | /// When an intEnum list contains non-unique values,
|
1004 1076 | /// the response should be a 400 ValidationException.
|
1005 - | /// Test ID: RestJsonMalformedLengthList_case1
|
1077 + | /// Test ID: RestJsonMalformedUniqueItemsIntEnumList
|
1006 1078 | #[::tokio::test]
|
1007 - | async fn rest_json_malformed_length_list_case1_malformed_request() {
|
1079 + | #[::tracing_test::traced_test]
|
1080 + | #[should_panic]
|
1081 + | async fn rest_json_malformed_unique_items_int_enum_list_malformed_request() {
|
1008 1082 | {
|
1009 1083 | #[allow(unused_mut)]
|
1010 1084 | let mut http_request = http::Request::builder()
|
1011 - | .uri("/MalformedLength")
|
1085 + | .uri("/MalformedUniqueItems")
|
1012 1086 | .method("POST")
|
1013 1087 | .header("content-type", "application/json")
|
1014 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes()))).unwrap();
|
1088 + | .body(::aws_smithy_http_server::body::Body::from(
|
1089 + | ::bytes::Bytes::from_static("{ \"intEnumList\" : [3, 3] }".as_bytes()),
|
1090 + | ))
|
1091 + | .unwrap();
|
1015 1092 | #[allow(unused_mut)]
|
1016 1093 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1017 1094 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1018 1095 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1019 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1096 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1020 1097 | let sender = sender.clone();
|
1021 1098 | async move {
|
1022 - | 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> };
|
1099 + | 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> };
|
1023 1100 | sender.send(()).await.expect("receiver dropped early");
|
1024 1101 | result
|
1025 1102 | }
|
1026 1103 | })
|
1027 1104 | .build_unchecked();
|
1028 1105 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1029 1106 | .await
|
1030 1107 | .expect("unable to make an HTTP request");
|
1031 1108 | ::pretty_assertions::assert_eq!(
|
1032 1109 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1033 1110 | http_response.status()
|
1034 1111 | );
|
1035 1112 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1036 1113 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1037 1114 | http_response.headers(),
|
1038 1115 | expected_headers,
|
1039 1116 | ));
|
1040 1117 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1041 1118 | .await
|
1042 1119 | .expect("unable to extract body to bytes");
|
1043 1120 | ::aws_smithy_protocol_test::assert_ok(
|
1044 - | ::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"))
|
1121 + | ::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"))
|
1045 1122 | );
|
1046 1123 | }
|
1047 1124 | }
|
1048 - | /// When a list member's value does not fit within length bounds,
|
1125 + | /// When an list of lists contains non-unique values,
|
1049 1126 | /// the response should be a 400 ValidationException.
|
1050 - | /// Test ID: RestJsonMalformedLengthListValue_case0
|
1127 + | /// Test ID: RestJsonMalformedUniqueItemsListList
|
1051 1128 | #[::tokio::test]
|
1052 - | async fn rest_json_malformed_length_list_value_case0_malformed_request() {
|
1129 + | #[::tracing_test::traced_test]
|
1130 + | #[should_panic]
|
1131 + | async fn rest_json_malformed_unique_items_list_list_malformed_request() {
|
1053 1132 | {
|
1054 1133 | #[allow(unused_mut)]
|
1055 1134 | let mut http_request = http::Request::builder()
|
1056 - | .uri("/MalformedLength")
|
1135 + | .uri("/MalformedUniqueItems")
|
1057 1136 | .method("POST")
|
1058 1137 | .header("content-type", "application/json")
|
1059 1138 | .body(::aws_smithy_http_server::body::Body::from(
|
1060 - | ::bytes::Bytes::from_static("{ \"list\" : [\"a\", \"abc\"] }".as_bytes()),
|
1139 + | ::bytes::Bytes::from_static(
|
1140 + | "{ \"listList\" : [[\"foo\",\"bar\"], [\"foo\",\"bar\"]] }".as_bytes(),
|
1141 + | ),
|
1061 1142 | ))
|
1062 1143 | .unwrap();
|
1063 1144 | #[allow(unused_mut)]
|
1064 1145 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1065 1146 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1066 1147 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1067 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1148 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1068 1149 | let sender = sender.clone();
|
1069 1150 | async move {
|
1070 - | 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> };
|
1151 + | 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> };
|
1071 1152 | sender.send(()).await.expect("receiver dropped early");
|
1072 1153 | result
|
1073 1154 | }
|
1074 1155 | })
|
1075 1156 | .build_unchecked();
|
1076 1157 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1077 1158 | .await
|
1078 1159 | .expect("unable to make an HTTP request");
|
1079 1160 | ::pretty_assertions::assert_eq!(
|
1080 1161 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1081 1162 | http_response.status()
|
1082 1163 | );
|
1083 1164 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1084 1165 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1085 1166 | http_response.headers(),
|
1086 1167 | expected_headers,
|
1087 1168 | ));
|
1088 1169 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1089 1170 | .await
|
1090 1171 | .expect("unable to extract body to bytes");
|
1091 1172 | ::aws_smithy_protocol_test::assert_ok(
|
1092 - | ::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"))
|
1173 + | ::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"))
|
1093 1174 | );
|
1094 1175 | }
|
1095 1176 | }
|
1096 - | /// When a list member's value does not fit within length bounds,
|
1177 + | /// When an list of structures contains non-unique values,
|
1097 1178 | /// the response should be a 400 ValidationException.
|
1098 - | /// Test ID: RestJsonMalformedLengthListValue_case1
|
1179 + | /// Test ID: RestJsonMalformedUniqueItemsStructureList
|
1099 1180 | #[::tokio::test]
|
1100 - | async fn rest_json_malformed_length_list_value_case1_malformed_request() {
|
1181 + | #[::tracing_test::traced_test]
|
1182 + | #[should_panic]
|
1183 + | async fn rest_json_malformed_unique_items_structure_list_malformed_request() {
|
1101 1184 | {
|
1102 1185 | #[allow(unused_mut)]
|
1103 1186 | let mut http_request = http::Request::builder()
|
1104 - | .uri("/MalformedLength")
|
1187 + | .uri("/MalformedUniqueItems")
|
1105 1188 | .method("POST")
|
1106 1189 | .header("content-type", "application/json")
|
1107 1190 | .body(::aws_smithy_http_server::body::Body::from(
|
1108 1191 | ::bytes::Bytes::from_static(
|
1109 - | "{ \"list\" : [\"abcdefghijklmnopqrstuvwxyz\", \"abc\"] }".as_bytes(),
|
1192 + | "{ \"structureList\" : [{\"hi\": \"hello\"}, {\"hi\": \"hello\"}] }"
|
1193 + | .as_bytes(),
|
1110 1194 | ),
|
1111 1195 | ))
|
1112 1196 | .unwrap();
|
1113 1197 | #[allow(unused_mut)]
|
1114 1198 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1115 1199 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1116 1200 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1117 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1201 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1118 1202 | let sender = sender.clone();
|
1119 1203 | async move {
|
1120 - | 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> };
|
1204 + | 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> };
|
1121 1205 | sender.send(()).await.expect("receiver dropped early");
|
1122 1206 | result
|
1123 1207 | }
|
1124 1208 | })
|
1125 1209 | .build_unchecked();
|
1126 1210 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1127 1211 | .await
|
1128 1212 | .expect("unable to make an HTTP request");
|
1129 1213 | ::pretty_assertions::assert_eq!(
|
1130 1214 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1131 1215 | http_response.status()
|
1132 1216 | );
|
1133 1217 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1134 1218 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1135 1219 | http_response.headers(),
|
1136 1220 | expected_headers,
|
1137 1221 | ));
|
1138 1222 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1139 1223 | .await
|
1140 1224 | .expect("unable to extract body to bytes");
|
1141 1225 | ::aws_smithy_protocol_test::assert_ok(
|
1142 - | ::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"))
|
1226 + | ::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"))
|
1143 1227 | );
|
1144 1228 | }
|
1145 1229 | }
|
1146 - | /// When a map member does not fit within length bounds,
|
1147 - | /// the response should be a 400 ValidationException.
|
1148 - | /// Test ID: RestJsonMalformedLengthMap_case0
|
1230 + | /// When a list of structures does not contain required keys,
|
1231 + | /// the response should be a 400 ValidationException and not
|
1232 + | /// a 500 error.
|
1233 + | /// Test ID: RestJsonMalformedUniqueItemsStructureMissingKeyList
|
1149 1234 | #[::tokio::test]
|
1150 - | async fn rest_json_malformed_length_map_case0_malformed_request() {
|
1235 + | #[::tracing_test::traced_test]
|
1236 + | async fn rest_json_malformed_unique_items_structure_missing_key_list_malformed_request() {
|
1151 1237 | {
|
1152 1238 | #[allow(unused_mut)]
|
1153 1239 | let mut http_request = http::Request::builder()
|
1154 - | .uri("/MalformedLength")
|
1240 + | .uri("/MalformedUniqueItems")
|
1155 1241 | .method("POST")
|
1156 1242 | .header("content-type", "application/json")
|
1157 1243 | .body(::aws_smithy_http_server::body::Body::from(
|
1158 1244 | ::bytes::Bytes::from_static(
|
1159 - | "{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"]} }".as_bytes(),
|
1245 + | "{ \"structureListWithNoKey\" : [{\"hi2\": \"bar\"}] }".as_bytes(),
|
1160 1246 | ),
|
1161 1247 | ))
|
1162 1248 | .unwrap();
|
1163 1249 | #[allow(unused_mut)]
|
1164 1250 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1165 1251 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1166 1252 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1167 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1253 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1168 1254 | let sender = sender.clone();
|
1169 1255 | async move {
|
1170 - | 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> };
|
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> };
|
1171 1257 | sender.send(()).await.expect("receiver dropped early");
|
1172 1258 | result
|
1173 1259 | }
|
1174 1260 | })
|
1175 1261 | .build_unchecked();
|
1176 1262 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1177 1263 | .await
|
1178 1264 | .expect("unable to make an HTTP request");
|
1179 1265 | ::pretty_assertions::assert_eq!(
|
1180 1266 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1181 1267 | http_response.status()
|
1182 1268 | );
|
1183 1269 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1184 1270 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1185 1271 | http_response.headers(),
|
1186 1272 | expected_headers,
|
1187 1273 | ));
|
1188 1274 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1189 1275 | .await
|
1190 1276 | .expect("unable to extract body to bytes");
|
1191 1277 | ::aws_smithy_protocol_test::assert_ok(
|
1192 - | ::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"))
|
1278 + | ::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"))
|
1193 1279 | );
|
1194 1280 | }
|
1195 1281 | }
|
1196 - | /// When a map member does not fit within length bounds,
|
1282 + | /// When an list of unions contains non-unique values,
|
1197 1283 | /// the response should be a 400 ValidationException.
|
1198 - | /// Test ID: RestJsonMalformedLengthMap_case1
|
1284 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case0
|
1199 1285 | #[::tokio::test]
|
1200 - | async fn rest_json_malformed_length_map_case1_malformed_request() {
|
1286 + | #[::tracing_test::traced_test]
|
1287 + | #[should_panic]
|
1288 + | async fn rest_json_malformed_unique_items_union_list_case0_malformed_request() {
|
1201 1289 | {
|
1202 1290 | #[allow(unused_mut)]
|
1203 1291 | let mut http_request = http::Request::builder()
|
1204 - | .uri("/MalformedLength")
|
1292 + | .uri("/MalformedUniqueItems")
|
1205 1293 | .method("POST")
|
1206 1294 | .header("content-type", "application/json")
|
1207 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"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()))).unwrap();
|
1295 + | .body(::aws_smithy_http_server::body::Body::from(
|
1296 + | ::bytes::Bytes::from_static(
|
1297 + | "{ \"unionList\" : [{\"string\": \"foo\"}, {\"string\": \"foo\"}] }"
|
1298 + | .as_bytes(),
|
1299 + | ),
|
1300 + | ))
|
1301 + | .unwrap();
|
1208 1302 | #[allow(unused_mut)]
|
1209 1303 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1210 1304 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1211 1305 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1212 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1306 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1213 1307 | let sender = sender.clone();
|
1214 1308 | async move {
|
1215 - | 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> };
|
1309 + | 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> };
|
1216 1310 | sender.send(()).await.expect("receiver dropped early");
|
1217 1311 | result
|
1218 1312 | }
|
1219 1313 | })
|
1220 1314 | .build_unchecked();
|
1221 1315 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1222 1316 | .await
|
1223 1317 | .expect("unable to make an HTTP request");
|
1224 1318 | ::pretty_assertions::assert_eq!(
|
1225 1319 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1226 1320 | http_response.status()
|
1227 1321 | );
|
1228 1322 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1229 1323 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1230 1324 | http_response.headers(),
|
1231 1325 | expected_headers,
|
1232 1326 | ));
|
1233 1327 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1234 1328 | .await
|
1235 1329 | .expect("unable to extract body to bytes");
|
1236 1330 | ::aws_smithy_protocol_test::assert_ok(
|
1237 - | ::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"))
|
1331 + | ::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"))
|
1238 1332 | );
|
1239 1333 | }
|
1240 1334 | }
|
1241 - | /// When a map member's key does not fit within length bounds,
|
1335 + | /// When an list of unions contains non-unique values,
|
1242 1336 | /// the response should be a 400 ValidationException.
|
1243 - | /// Test ID: RestJsonMalformedLengthMapKey_case0
|
1337 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case1
|
1244 1338 | #[::tokio::test]
|
1245 - | async fn rest_json_malformed_length_map_key_case0_malformed_request() {
|
1339 + | #[::tracing_test::traced_test]
|
1340 + | #[should_panic]
|
1341 + | async fn rest_json_malformed_unique_items_union_list_case1_malformed_request() {
|
1246 1342 | {
|
1247 1343 | #[allow(unused_mut)]
|
1248 1344 | let mut http_request = http::Request::builder()
|
1249 - | .uri("/MalformedLength")
|
1345 + | .uri("/MalformedUniqueItems")
|
1250 1346 | .method("POST")
|
1251 1347 | .header("content-type", "application/json")
|
1252 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"a\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
1348 + | .body(::aws_smithy_http_server::body::Body::from(
|
1349 + | ::bytes::Bytes::from_static(
|
1350 + | "{ \"unionList\" : [{\"integer\": 1}, {\"integer\": 1}] }".as_bytes(),
|
1351 + | ),
|
1352 + | ))
|
1353 + | .unwrap();
|
1253 1354 | #[allow(unused_mut)]
|
1254 1355 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1255 1356 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1256 1357 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1257 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1358 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1258 1359 | let sender = sender.clone();
|
1259 1360 | async move {
|
1260 - | 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> };
|
1361 + | 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> };
|
1261 1362 | sender.send(()).await.expect("receiver dropped early");
|
1262 1363 | result
|
1263 1364 | }
|
1264 1365 | })
|
1265 1366 | .build_unchecked();
|
1266 1367 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1267 1368 | .await
|
1268 1369 | .expect("unable to make an HTTP request");
|
1269 1370 | ::pretty_assertions::assert_eq!(
|
1270 1371 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1271 1372 | http_response.status()
|
1272 1373 | );
|
1273 1374 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1274 1375 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1275 1376 | http_response.headers(),
|
1276 1377 | expected_headers,
|
1277 1378 | ));
|
1278 1379 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1279 1380 | .await
|
1280 1381 | .expect("unable to extract body to bytes");
|
1281 1382 | ::aws_smithy_protocol_test::assert_ok(
|
1282 - | ::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"))
|
1383 + | ::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"))
|
1283 1384 | );
|
1284 1385 | }
|
1285 1386 | }
|
1286 - | /// When a map member's key does not fit within length bounds,
|
1287 - | /// the response should be a 400 ValidationException.
|
1288 - | /// Test ID: RestJsonMalformedLengthMapKey_case1
|
1289 - | #[::tokio::test]
|
1290 - | async fn rest_json_malformed_length_map_key_case1_malformed_request() {
|
1291 - | {
|
1292 - | #[allow(unused_mut)]
|
1293 - | let mut http_request = http::Request::builder()
|
1294 - | .uri("/MalformedLength")
|
1295 - | .method("POST")
|
1296 - | .header("content-type", "application/json")
|
1297 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abcdefghijklmnopqrstuvwxyz\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
1298 - | #[allow(unused_mut)]
|
1299 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1300 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1301 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1302 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1303 - | let sender = sender.clone();
|
1304 - | async move {
|
1305 - | 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> };
|
1306 - | sender.send(()).await.expect("receiver dropped early");
|
1307 - | result
|
1308 - | }
|
1309 - | })
|
1310 - | .build_unchecked();
|
1311 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1312 - | .await
|
1313 - | .expect("unable to make an HTTP request");
|
1314 - | ::pretty_assertions::assert_eq!(
|
1315 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1316 - | http_response.status()
|
1317 - | );
|
1318 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1319 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1320 - | http_response.headers(),
|
1321 - | expected_headers,
|
1322 - | ));
|
1323 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1324 - | .await
|
1325 - | .expect("unable to extract body to bytes");
|
1326 - | ::aws_smithy_protocol_test::assert_ok(
|
1327 - | ::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"))
|
1328 - | );
|
1387 + | }
|
1388 + |
|
1389 + | const CONTENT_TYPE_MALFORMEDREQUIRED: ::mime::Mime = ::mime::APPLICATION_JSON;
|
1390 + | ::pin_project_lite::pin_project! {
|
1391 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1392 + | /// [`MalformedRequiredInput`](crate::input::MalformedRequiredInput) using modelled bindings.
|
1393 + | pub struct MalformedRequiredInputFuture {
|
1394 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRequiredInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1329 1395 | }
|
1396 + | }
|
1397 + |
|
1398 + | impl std::future::Future for MalformedRequiredInputFuture {
|
1399 + | type Output = Result<
|
1400 + | crate::input::MalformedRequiredInput,
|
1401 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1402 + | >;
|
1403 + |
|
1404 + | fn poll(
|
1405 + | self: std::pin::Pin<&mut Self>,
|
1406 + | cx: &mut std::task::Context<'_>,
|
1407 + | ) -> std::task::Poll<Self::Output> {
|
1408 + | let this = self.project();
|
1409 + | this.inner.as_mut().poll(cx)
|
1330 1410 | }
|
1331 - | /// When a map member's value does not fit within length bounds,
|
1332 - | /// the response should be a 400 ValidationException.
|
1333 - | /// Test ID: RestJsonMalformedLengthMapValue_case0
|
1334 - | #[::tokio::test]
|
1335 - | async fn rest_json_malformed_length_map_value_case0_malformed_request() {
|
1336 - | {
|
1337 - | #[allow(unused_mut)]
|
1338 - | let mut http_request = http::Request::builder()
|
1339 - | .uri("/MalformedLength")
|
1340 - | .method("POST")
|
1341 - | .header("content-type", "application/json")
|
1342 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abc\": [\"def\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
1343 - | #[allow(unused_mut)]
|
1344 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1345 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1346 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1347 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1348 - | let sender = sender.clone();
|
1349 - | async move {
|
1350 - | 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> };
|
1351 - | sender.send(()).await.expect("receiver dropped early");
|
1352 - | result
|
1411 + | }
|
1412 + |
|
1413 + | impl<B>
|
1414 + | ::aws_smithy_http_server::request::FromRequest<
|
1415 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1416 + | B,
|
1417 + | > for crate::input::MalformedRequiredInput
|
1418 + | where
|
1419 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1420 + | B: 'static,
|
1421 + |
|
1422 + | B::Data: Send,
|
1423 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1424 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1425 + | {
|
1426 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1427 + | type Future = MalformedRequiredInputFuture;
|
1428 + |
|
1429 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1430 + | let fut = async move {
|
1431 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1432 + | request.headers(),
|
1433 + | &CONTENT_TYPE_MALFORMEDREQUIRED,
|
1434 + | ) {
|
1435 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1353 1436 | }
|
1354 - | })
|
1355 - | .build_unchecked();
|
1356 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1357 - | .await
|
1358 - | .expect("unable to make an HTTP request");
|
1359 - | ::pretty_assertions::assert_eq!(
|
1360 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1361 - | http_response.status()
|
1362 - | );
|
1363 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1364 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1365 - | http_response.headers(),
|
1366 - | expected_headers,
|
1367 - | ));
|
1368 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1437 + | crate::protocol_serde::shape_malformed_required::de_malformed_required_http_request(
|
1438 + | request,
|
1439 + | )
|
1369 1440 | .await
|
1370 - | .expect("unable to extract body to bytes");
|
1371 - | ::aws_smithy_protocol_test::assert_ok(
|
1372 - | ::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"))
|
1441 + | .map_err(Into::into)
|
1442 + | };
|
1443 + | use ::futures_util::future::TryFutureExt;
|
1444 + | let fut = fut.map_err(
|
1445 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1446 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1447 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
1448 + | e,
|
1449 + | )
|
1450 + | },
|
1373 1451 | );
|
1452 + | MalformedRequiredInputFuture {
|
1453 + | inner: Box::pin(fut),
|
1374 1454 | }
|
1375 1455 | }
|
1376 - | /// When a map member's value does not fit within length bounds,
|
1377 - | /// the response should be a 400 ValidationException.
|
1378 - | /// Test ID: RestJsonMalformedLengthMapValue_case1
|
1379 - | #[::tokio::test]
|
1380 - | async fn rest_json_malformed_length_map_value_case1_malformed_request() {
|
1381 - | {
|
1382 - | #[allow(unused_mut)]
|
1383 - | let mut http_request = http::Request::builder()
|
1384 - | .uri("/MalformedLength")
|
1385 - | .method("POST")
|
1386 - | .header("content-type", "application/json")
|
1387 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\"],\n \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
1388 - | #[allow(unused_mut)]
|
1389 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1390 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1391 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1392 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1393 - | let sender = sender.clone();
|
1394 - | async move {
|
1395 - | 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> };
|
1396 - | sender.send(()).await.expect("receiver dropped early");
|
1397 - | result
|
1456 + | }
|
1457 + | impl
|
1458 + | ::aws_smithy_http_server::response::IntoResponse<
|
1459 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1460 + | > for crate::output::MalformedRequiredOutput
|
1461 + | {
|
1462 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1463 + | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_response(
|
1464 + | self,
|
1465 + | ) {
|
1466 + | Ok(response) => response,
|
1467 + | Err(e) => {
|
1468 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1469 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1398 1470 | }
|
1399 - | })
|
1400 - | .build_unchecked();
|
1401 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1402 - | .await
|
1403 - | .expect("unable to make an HTTP request");
|
1404 - | ::pretty_assertions::assert_eq!(
|
1405 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1406 - | http_response.status()
|
1407 - | );
|
1408 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1409 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1410 - | http_response.headers(),
|
1411 - | expected_headers,
|
1412 - | ));
|
1413 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1414 - | .await
|
1415 - | .expect("unable to extract body to bytes");
|
1416 - | ::aws_smithy_protocol_test::assert_ok(
|
1417 - | ::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"))
|
1471 + | }
|
1472 + | }
|
1473 + | }
|
1474 + | impl
|
1475 + | ::aws_smithy_http_server::response::IntoResponse<
|
1476 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1477 + | > for crate::error::MalformedRequiredError
|
1478 + | {
|
1479 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1480 + | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_error(
|
1481 + | &self,
|
1482 + | ) {
|
1483 + | Ok(mut response) => {
|
1484 + | response.extensions_mut().insert(
|
1485 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
1418 1486 | );
|
1487 + | response
|
1488 + | }
|
1489 + | Err(e) => {
|
1490 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1491 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1492 + | }
|
1419 1493 | }
|
1420 1494 | }
|
1421 1495 | }
|
1422 - | #[cfg(test)]
|
1496 + |
|
1423 1497 | #[allow(unreachable_code, unused_variables)]
|
1424 - | mod server_malformed_length_override_test {
|
1425 - | /// When a blob member does not fit within length bounds,
|
1498 + | #[cfg(test)]
|
1499 + | mod malformed_required_test {
|
1500 + |
|
1501 + | /// When a required member is not set in the message body,
|
1426 1502 | /// the response should be a 400 ValidationException.
|
1427 - | /// Test ID: RestJsonMalformedLengthBlobOverride_case0
|
1503 + | /// Test ID: RestJsonMalformedRequiredBodyUnset
|
1428 1504 | #[::tokio::test]
|
1429 - | async fn rest_json_malformed_length_blob_override_case0_malformed_request() {
|
1505 + | #[::tracing_test::traced_test]
|
1506 + | async fn rest_json_malformed_required_body_unset_malformed_request() {
|
1430 1507 | {
|
1431 1508 | #[allow(unused_mut)]
|
1432 1509 | let mut http_request = http::Request::builder()
|
1433 - | .uri("/MalformedLengthOverride")
|
1510 + | .uri("/MalformedRequired")
|
1434 1511 | .method("POST")
|
1435 1512 | .header("content-type", "application/json")
|
1513 + | .header("string-in-headers", "abc")
|
1436 1514 | .body(::aws_smithy_http_server::body::Body::from(
|
1437 - | ::bytes::Bytes::from_static("{ \"blob\" : \"YWJj\" }".as_bytes()),
|
1515 + | ::bytes::Bytes::from_static("{ }".as_bytes()),
|
1438 1516 | ))
|
1439 1517 | .unwrap();
|
1518 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1440 1519 | #[allow(unused_mut)]
|
1441 1520 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1442 1521 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1443 1522 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1444 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1523 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1445 1524 | let sender = sender.clone();
|
1446 1525 | async move {
|
1447 - | 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> };
|
1526 + | 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> };
|
1448 1527 | sender.send(()).await.expect("receiver dropped early");
|
1449 1528 | result
|
1450 1529 | }
|
1451 1530 | })
|
1452 1531 | .build_unchecked();
|
1453 1532 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1454 1533 | .await
|
1455 1534 | .expect("unable to make an HTTP request");
|
1456 1535 | ::pretty_assertions::assert_eq!(
|
1457 1536 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1458 1537 | http_response.status()
|
1459 1538 | );
|
1460 1539 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1461 1540 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1462 1541 | http_response.headers(),
|
1463 1542 | expected_headers,
|
1464 1543 | ));
|
1465 1544 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1466 1545 | .await
|
1467 1546 | .expect("unable to extract body to bytes");
|
1468 1547 | ::aws_smithy_protocol_test::assert_ok(
|
1469 - | ::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"))
|
1548 + | ::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"))
|
1470 1549 | );
|
1471 1550 | }
|
1472 1551 | }
|
1473 - | /// When a blob member does not fit within length bounds,
|
1552 + | /// When a required member is set to null in the message body,
|
1474 1553 | /// the response should be a 400 ValidationException.
|
1475 - | /// Test ID: RestJsonMalformedLengthBlobOverride_case1
|
1554 + | /// Test ID: RestJsonMalformedRequiredBodyExplicitNull
|
1476 1555 | #[::tokio::test]
|
1477 - | async fn rest_json_malformed_length_blob_override_case1_malformed_request() {
|
1556 + | #[::tracing_test::traced_test]
|
1557 + | async fn rest_json_malformed_required_body_explicit_null_malformed_request() {
|
1478 1558 | {
|
1479 1559 | #[allow(unused_mut)]
|
1480 1560 | let mut http_request = http::Request::builder()
|
1481 - | .uri("/MalformedLengthOverride")
|
1561 + | .uri("/MalformedRequired")
|
1482 1562 | .method("POST")
|
1483 1563 | .header("content-type", "application/json")
|
1564 + | .header("string-in-headers", "abc")
|
1484 1565 | .body(::aws_smithy_http_server::body::Body::from(
|
1485 - | ::bytes::Bytes::from_static("{ \"blob\" : \"YWJjZGVmZw==\" }".as_bytes()),
|
1566 + | ::bytes::Bytes::from_static("{ \"string\": null }".as_bytes()),
|
1486 1567 | ))
|
1487 1568 | .unwrap();
|
1569 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1488 1570 | #[allow(unused_mut)]
|
1489 1571 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1490 1572 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1491 1573 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1492 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1574 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1493 1575 | let sender = sender.clone();
|
1494 1576 | async move {
|
1495 - | 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> };
|
1577 + | 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> };
|
1496 1578 | sender.send(()).await.expect("receiver dropped early");
|
1497 1579 | result
|
1498 1580 | }
|
1499 1581 | })
|
1500 1582 | .build_unchecked();
|
1501 1583 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1502 1584 | .await
|
1503 1585 | .expect("unable to make an HTTP request");
|
1504 1586 | ::pretty_assertions::assert_eq!(
|
1505 1587 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1506 1588 | http_response.status()
|
1507 1589 | );
|
1508 1590 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1509 1591 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1510 1592 | http_response.headers(),
|
1511 1593 | expected_headers,
|
1512 1594 | ));
|
1513 1595 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1514 1596 | .await
|
1515 1597 | .expect("unable to extract body to bytes");
|
1516 1598 | ::aws_smithy_protocol_test::assert_ok(
|
1517 - | ::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"))
|
1599 + | ::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"))
|
1518 1600 | );
|
1519 1601 | }
|
1520 1602 | }
|
1521 - | /// When a string member does not fit within length bounds,
|
1603 + | /// When a required member is not set in headers,
|
1522 1604 | /// the response should be a 400 ValidationException.
|
1523 - | /// Test ID: RestJsonMalformedLengthStringOverride_case0
|
1605 + | /// Test ID: RestJsonMalformedRequiredHeaderUnset
|
1524 1606 | #[::tokio::test]
|
1525 - | async fn rest_json_malformed_length_string_override_case0_malformed_request() {
|
1607 + | #[::tracing_test::traced_test]
|
1608 + | async fn rest_json_malformed_required_header_unset_malformed_request() {
|
1526 1609 | {
|
1527 1610 | #[allow(unused_mut)]
|
1528 1611 | let mut http_request = http::Request::builder()
|
1529 - | .uri("/MalformedLengthOverride")
|
1612 + | .uri("/MalformedRequired")
|
1530 1613 | .method("POST")
|
1531 1614 | .header("content-type", "application/json")
|
1532 1615 | .body(::aws_smithy_http_server::body::Body::from(
|
1533 - | ::bytes::Bytes::from_static("{ \"string\" : \"abc\" }".as_bytes()),
|
1616 + | ::bytes::Bytes::from_static("{ \"string\": \"abc\" }".as_bytes()),
|
1534 1617 | ))
|
1535 1618 | .unwrap();
|
1619 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1536 1620 | #[allow(unused_mut)]
|
1537 1621 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1538 1622 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1539 1623 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1540 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1624 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1541 1625 | let sender = sender.clone();
|
1542 1626 | async move {
|
1543 - | 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> };
|
1627 + | 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> };
|
1544 1628 | sender.send(()).await.expect("receiver dropped early");
|
1545 1629 | result
|
1546 1630 | }
|
1547 1631 | })
|
1548 1632 | .build_unchecked();
|
1549 1633 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1550 1634 | .await
|
1551 1635 | .expect("unable to make an HTTP request");
|
1552 1636 | ::pretty_assertions::assert_eq!(
|
1553 1637 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1554 1638 | http_response.status()
|
1555 1639 | );
|
1556 1640 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1557 1641 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1558 1642 | http_response.headers(),
|
1559 1643 | expected_headers,
|
1560 1644 | ));
|
1561 1645 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1562 1646 | .await
|
1563 1647 | .expect("unable to extract body to bytes");
|
1564 1648 | ::aws_smithy_protocol_test::assert_ok(
|
1565 - | ::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"))
|
1649 + | ::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"))
|
1566 1650 | );
|
1567 1651 | }
|
1568 1652 | }
|
1569 - | /// When a string member does not fit within length bounds,
|
1570 - | /// the response should be a 400 ValidationException.
|
1571 - | /// Test ID: RestJsonMalformedLengthStringOverride_case1
|
1572 - | #[::tokio::test]
|
1573 - | async fn rest_json_malformed_length_string_override_case1_malformed_request() {
|
1574 - | {
|
1575 - | #[allow(unused_mut)]
|
1576 - | let mut http_request = http::Request::builder()
|
1577 - | .uri("/MalformedLengthOverride")
|
1578 - | .method("POST")
|
1579 - | .header("content-type", "application/json")
|
1580 - | .body(::aws_smithy_http_server::body::Body::from(
|
1581 - | ::bytes::Bytes::from_static("{ \"string\" : \"abcdefg\" }".as_bytes()),
|
1582 - | ))
|
1583 - | .unwrap();
|
1584 - | #[allow(unused_mut)]
|
1585 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1586 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1653 + | }
|
1654 + |
|
1655 + | const CONTENT_TYPE_MALFORMEDRANGEOVERRIDE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
1656 + | ::pin_project_lite::pin_project! {
|
1657 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1658 + | /// [`MalformedRangeOverrideInput`](crate::input::MalformedRangeOverrideInput) using modelled bindings.
|
1659 + | pub struct MalformedRangeOverrideInputFuture {
|
1660 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRangeOverrideInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
1661 + | }
|
1662 + | }
|
1663 + |
|
1664 + | impl std::future::Future for MalformedRangeOverrideInputFuture {
|
1665 + | type Output = Result<
|
1666 + | crate::input::MalformedRangeOverrideInput,
|
1667 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1668 + | >;
|
1669 + |
|
1670 + | fn poll(
|
1671 + | self: std::pin::Pin<&mut Self>,
|
1672 + | cx: &mut std::task::Context<'_>,
|
1673 + | ) -> std::task::Poll<Self::Output> {
|
1674 + | let this = self.project();
|
1675 + | this.inner.as_mut().poll(cx)
|
1676 + | }
|
1677 + | }
|
1678 + |
|
1679 + | impl<B>
|
1680 + | ::aws_smithy_http_server::request::FromRequest<
|
1681 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1682 + | B,
|
1683 + | > for crate::input::MalformedRangeOverrideInput
|
1684 + | where
|
1685 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1686 + | B: 'static,
|
1687 + |
|
1688 + | B::Data: Send,
|
1689 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1690 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1691 + | {
|
1692 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1693 + | type Future = MalformedRangeOverrideInputFuture;
|
1694 + |
|
1695 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
1696 + | let fut = async move {
|
1697 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1698 + | request.headers(),
|
1699 + | &CONTENT_TYPE_MALFORMEDRANGEOVERRIDE,
|
1700 + | ) {
|
1701 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1702 + | }
|
1703 + | crate::protocol_serde::shape_malformed_range_override::de_malformed_range_override_http_request(request)
|
1704 + | .await
|
1705 + | .map_err(Into::into)
|
1706 + | };
|
1707 + | use ::futures_util::future::TryFutureExt;
|
1708 + | let fut = fut.map_err(
|
1709 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1710 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1711 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
1712 + | e,
|
1713 + | )
|
1714 + | },
|
1715 + | );
|
1716 + | MalformedRangeOverrideInputFuture {
|
1717 + | inner: Box::pin(fut),
|
1718 + | }
|
1719 + | }
|
1720 + | }
|
1721 + | impl
|
1722 + | ::aws_smithy_http_server::response::IntoResponse<
|
1723 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1724 + | > for crate::output::MalformedRangeOverrideOutput
|
1725 + | {
|
1726 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1727 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_response(self) {
|
1728 + | Ok(response) => response,
|
1729 + | Err(e) => {
|
1730 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1731 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1732 + | }
|
1733 + | }
|
1734 + | }
|
1735 + | }
|
1736 + | impl
|
1737 + | ::aws_smithy_http_server::response::IntoResponse<
|
1738 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1739 + | > for crate::error::MalformedRangeOverrideError
|
1740 + | {
|
1741 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1742 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_error(&self) {
|
1743 + | Ok(mut response) => {
|
1744 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1745 + | response
|
1746 + | },
|
1747 + | Err(e) => {
|
1748 + | ::tracing::error!(error = %e, "failed to serialize response");
|
1749 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
1750 + | }
|
1751 + | }
|
1752 + | }
|
1753 + | }
|
1754 + |
|
1755 + | #[allow(unreachable_code, unused_variables)]
|
1756 + | #[cfg(test)]
|
1757 + | mod malformed_range_override_test {
|
1758 + |
|
1759 + | /// When a byte member does not fit within range bounds,
|
1760 + | /// the response should be a 400 ValidationException.
|
1761 + | /// Test ID: RestJsonMalformedRangeByteOverride_case0
|
1762 + | #[::tokio::test]
|
1763 + | #[::tracing_test::traced_test]
|
1764 + | async fn rest_json_malformed_range_byte_override_case0_malformed_request() {
|
1765 + | {
|
1766 + | #[allow(unused_mut)]
|
1767 + | let mut http_request = http::Request::builder()
|
1768 + | .uri("/MalformedRangeOverride")
|
1769 + | .method("POST")
|
1770 + | .header("content-type", "application/json")
|
1771 + | .body(::aws_smithy_http_server::body::Body::from(
|
1772 + | ::bytes::Bytes::from_static("{ \"byte\" : 3 }".as_bytes()),
|
1773 + | ))
|
1774 + | .unwrap();
|
1775 + | #[allow(unused_mut)]
|
1776 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1777 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1587 1778 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1588 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1779 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1589 1780 | let sender = sender.clone();
|
1590 1781 | async move {
|
1591 - | 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> };
|
1782 + | 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> };
|
1592 1783 | sender.send(()).await.expect("receiver dropped early");
|
1593 1784 | result
|
1594 1785 | }
|
1595 1786 | })
|
1596 1787 | .build_unchecked();
|
1597 1788 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1598 1789 | .await
|
1599 1790 | .expect("unable to make an HTTP request");
|
1600 1791 | ::pretty_assertions::assert_eq!(
|
1601 1792 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1602 1793 | http_response.status()
|
1603 1794 | );
|
1604 1795 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1605 1796 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1606 1797 | http_response.headers(),
|
1607 1798 | expected_headers,
|
1608 1799 | ));
|
1609 1800 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1610 1801 | .await
|
1611 1802 | .expect("unable to extract body to bytes");
|
1612 1803 | ::aws_smithy_protocol_test::assert_ok(
|
1613 - | ::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"))
|
1804 + | ::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"))
|
1614 1805 | );
|
1615 1806 | }
|
1616 1807 | }
|
1617 - | /// When a string member does not fit within length bounds,
|
1808 + | /// When a byte member does not fit within range bounds,
|
1618 1809 | /// the response should be a 400 ValidationException.
|
1619 - | /// Test ID: RestJsonMalformedLengthStringOverride_case2
|
1810 + | /// Test ID: RestJsonMalformedRangeByteOverride_case1
|
1620 1811 | #[::tokio::test]
|
1621 - | async fn rest_json_malformed_length_string_override_case2_malformed_request() {
|
1812 + | #[::tracing_test::traced_test]
|
1813 + | async fn rest_json_malformed_range_byte_override_case1_malformed_request() {
|
1622 1814 | {
|
1623 1815 | #[allow(unused_mut)]
|
1624 1816 | let mut http_request = http::Request::builder()
|
1625 - | .uri("/MalformedLengthOverride")
|
1817 + | .uri("/MalformedRangeOverride")
|
1626 1818 | .method("POST")
|
1627 1819 | .header("content-type", "application/json")
|
1628 1820 | .body(::aws_smithy_http_server::body::Body::from(
|
1629 - | ::bytes::Bytes::from_static("{ \"string\" : \"👍👍👍\" }".as_bytes()),
|
1821 + | ::bytes::Bytes::from_static("{ \"byte\" : 7 }".as_bytes()),
|
1630 1822 | ))
|
1631 1823 | .unwrap();
|
1632 1824 | #[allow(unused_mut)]
|
1633 1825 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1634 1826 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1635 1827 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1636 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1828 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1637 1829 | let sender = sender.clone();
|
1638 1830 | async move {
|
1639 - | 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> };
|
1831 + | 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> };
|
1640 1832 | sender.send(()).await.expect("receiver dropped early");
|
1641 1833 | result
|
1642 1834 | }
|
1643 1835 | })
|
1644 1836 | .build_unchecked();
|
1645 1837 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1646 1838 | .await
|
1647 1839 | .expect("unable to make an HTTP request");
|
1648 1840 | ::pretty_assertions::assert_eq!(
|
1649 1841 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1650 1842 | http_response.status()
|
1651 1843 | );
|
1652 1844 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1653 1845 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1654 1846 | http_response.headers(),
|
1655 1847 | expected_headers,
|
1656 1848 | ));
|
1657 1849 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1658 1850 | .await
|
1659 1851 | .expect("unable to extract body to bytes");
|
1660 1852 | ::aws_smithy_protocol_test::assert_ok(
|
1661 - | ::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"))
|
1853 + | ::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"))
|
1662 1854 | );
|
1663 1855 | }
|
1664 1856 | }
|
1665 - | /// When a string member does not fit within length bounds,
|
1857 + | /// When a byte member does not fit within range bounds,
|
1666 1858 | /// the response should be a 400 ValidationException.
|
1667 - | /// Test ID: RestJsonMalformedLengthMinStringOverride
|
1859 + | /// Test ID: RestJsonMalformedRangeMinByteOverride
|
1668 1860 | #[::tokio::test]
|
1669 - | async fn rest_json_malformed_length_min_string_override_malformed_request() {
|
1861 + | #[::tracing_test::traced_test]
|
1862 + | async fn rest_json_malformed_range_min_byte_override_malformed_request() {
|
1670 1863 | {
|
1671 1864 | #[allow(unused_mut)]
|
1672 1865 | let mut http_request = http::Request::builder()
|
1673 - | .uri("/MalformedLengthOverride")
|
1866 + | .uri("/MalformedRangeOverride")
|
1674 1867 | .method("POST")
|
1675 1868 | .header("content-type", "application/json")
|
1676 1869 | .body(::aws_smithy_http_server::body::Body::from(
|
1677 - | ::bytes::Bytes::from_static("{ \"minString\" : \"abc\" }".as_bytes()),
|
1870 + | ::bytes::Bytes::from_static("{ \"minByte\" : 3 }".as_bytes()),
|
1678 1871 | ))
|
1679 1872 | .unwrap();
|
1680 1873 | #[allow(unused_mut)]
|
1681 1874 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1682 1875 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1683 1876 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1684 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1877 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1685 1878 | let sender = sender.clone();
|
1686 1879 | async move {
|
1687 - | 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> };
|
1880 + | 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> };
|
1688 1881 | sender.send(()).await.expect("receiver dropped early");
|
1689 1882 | result
|
1690 1883 | }
|
1691 1884 | })
|
1692 1885 | .build_unchecked();
|
1693 1886 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1694 1887 | .await
|
1695 1888 | .expect("unable to make an HTTP request");
|
1696 1889 | ::pretty_assertions::assert_eq!(
|
1697 1890 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1698 1891 | http_response.status()
|
1699 1892 | );
|
1700 1893 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1701 1894 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1702 1895 | http_response.headers(),
|
1703 1896 | expected_headers,
|
1704 1897 | ));
|
1705 1898 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1706 1899 | .await
|
1707 1900 | .expect("unable to extract body to bytes");
|
1708 1901 | ::aws_smithy_protocol_test::assert_ok(
|
1709 - | ::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"))
|
1902 + | ::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"))
|
1710 1903 | );
|
1711 1904 | }
|
1712 1905 | }
|
1713 - | /// When a string member does not fit within length bounds,
|
1906 + | /// When a byte member does not fit within range bounds,
|
1714 1907 | /// the response should be a 400 ValidationException.
|
1715 - | /// Test ID: RestJsonMalformedLengthMaxStringOverride
|
1908 + | /// Test ID: RestJsonMalformedRangeMaxByteOverride
|
1716 1909 | #[::tokio::test]
|
1717 - | async fn rest_json_malformed_length_max_string_override_malformed_request() {
|
1910 + | #[::tracing_test::traced_test]
|
1911 + | async fn rest_json_malformed_range_max_byte_override_malformed_request() {
|
1718 1912 | {
|
1719 1913 | #[allow(unused_mut)]
|
1720 1914 | let mut http_request = http::Request::builder()
|
1721 - | .uri("/MalformedLengthOverride")
|
1915 + | .uri("/MalformedRangeOverride")
|
1722 1916 | .method("POST")
|
1723 1917 | .header("content-type", "application/json")
|
1724 1918 | .body(::aws_smithy_http_server::body::Body::from(
|
1725 - | ::bytes::Bytes::from_static("{ \"maxString\" : \"abcdefg\" }".as_bytes()),
|
1919 + | ::bytes::Bytes::from_static("{ \"maxByte\" : 7 }".as_bytes()),
|
1726 1920 | ))
|
1727 1921 | .unwrap();
|
1728 1922 | #[allow(unused_mut)]
|
1729 1923 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1730 1924 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1731 1925 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1732 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1926 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1733 1927 | let sender = sender.clone();
|
1734 1928 | async move {
|
1735 - | 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> };
|
1929 + | 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> };
|
1736 1930 | sender.send(()).await.expect("receiver dropped early");
|
1737 1931 | result
|
1738 1932 | }
|
1739 1933 | })
|
1740 1934 | .build_unchecked();
|
1741 1935 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1742 1936 | .await
|
1743 1937 | .expect("unable to make an HTTP request");
|
1744 1938 | ::pretty_assertions::assert_eq!(
|
1745 1939 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1746 1940 | http_response.status()
|
1747 1941 | );
|
1748 1942 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1749 1943 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1750 1944 | http_response.headers(),
|
1751 1945 | expected_headers,
|
1752 1946 | ));
|
1753 1947 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1754 1948 | .await
|
1755 1949 | .expect("unable to extract body to bytes");
|
1756 1950 | ::aws_smithy_protocol_test::assert_ok(
|
1757 - | ::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"))
|
1951 + | ::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"))
|
1758 1952 | );
|
1759 1953 | }
|
1760 1954 | }
|
1761 - | /// When a list member does not fit within length bounds,
|
1955 + | /// When a float member does not fit within range bounds,
|
1762 1956 | /// the response should be a 400 ValidationException.
|
1763 - | /// Test ID: RestJsonMalformedLengthListOverride_case0
|
1957 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case0
|
1764 1958 | #[::tokio::test]
|
1765 - | async fn rest_json_malformed_length_list_override_case0_malformed_request() {
|
1959 + | #[::tracing_test::traced_test]
|
1960 + | #[should_panic]
|
1961 + | async fn rest_json_malformed_range_float_override_case0_malformed_request() {
|
1766 1962 | {
|
1767 1963 | #[allow(unused_mut)]
|
1768 1964 | let mut http_request = http::Request::builder()
|
1769 - | .uri("/MalformedLengthOverride")
|
1965 + | .uri("/MalformedRangeOverride")
|
1770 1966 | .method("POST")
|
1771 1967 | .header("content-type", "application/json")
|
1772 1968 | .body(::aws_smithy_http_server::body::Body::from(
|
1773 - | ::bytes::Bytes::from_static(
|
1774 - | "{ \"list\" : [\"abc\", \"def\", \"ghi\"] }".as_bytes(),
|
1775 - | ),
|
1969 + | ::bytes::Bytes::from_static("{ \"float\" : 4.3 }".as_bytes()),
|
1776 1970 | ))
|
1777 1971 | .unwrap();
|
1778 1972 | #[allow(unused_mut)]
|
1779 1973 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1780 1974 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1781 1975 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1782 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
1976 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1783 1977 | let sender = sender.clone();
|
1784 1978 | async move {
|
1785 - | 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> };
|
1979 + | 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> };
|
1786 1980 | sender.send(()).await.expect("receiver dropped early");
|
1787 1981 | result
|
1788 1982 | }
|
1789 1983 | })
|
1790 1984 | .build_unchecked();
|
1791 1985 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1792 1986 | .await
|
1793 1987 | .expect("unable to make an HTTP request");
|
1794 1988 | ::pretty_assertions::assert_eq!(
|
1795 1989 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1796 1990 | http_response.status()
|
1797 1991 | );
|
1798 1992 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1799 1993 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1800 1994 | http_response.headers(),
|
1801 1995 | expected_headers,
|
1802 1996 | ));
|
1803 1997 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1804 1998 | .await
|
1805 1999 | .expect("unable to extract body to bytes");
|
1806 2000 | ::aws_smithy_protocol_test::assert_ok(
|
1807 - | ::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"))
|
2001 + | ::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"))
|
1808 2002 | );
|
1809 2003 | }
|
1810 2004 | }
|
1811 - | /// When a list member does not fit within length bounds,
|
2005 + | /// When a float member does not fit within range bounds,
|
1812 2006 | /// the response should be a 400 ValidationException.
|
1813 - | /// Test ID: RestJsonMalformedLengthListOverride_case1
|
2007 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case1
|
1814 2008 | #[::tokio::test]
|
1815 - | async fn rest_json_malformed_length_list_override_case1_malformed_request() {
|
2009 + | #[::tracing_test::traced_test]
|
2010 + | #[should_panic]
|
2011 + | async fn rest_json_malformed_range_float_override_case1_malformed_request() {
|
1816 2012 | {
|
1817 2013 | #[allow(unused_mut)]
|
1818 2014 | let mut http_request = http::Request::builder()
|
1819 - | .uri("/MalformedLengthOverride")
|
2015 + | .uri("/MalformedRangeOverride")
|
1820 2016 | .method("POST")
|
1821 2017 | .header("content-type", "application/json")
|
1822 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes()))).unwrap();
|
2018 + | .body(::aws_smithy_http_server::body::Body::from(
|
2019 + | ::bytes::Bytes::from_static("{ \"float\" : 6.7 }".as_bytes()),
|
2020 + | ))
|
2021 + | .unwrap();
|
1823 2022 | #[allow(unused_mut)]
|
1824 2023 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1825 2024 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1826 2025 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1827 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2026 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1828 2027 | let sender = sender.clone();
|
1829 2028 | async move {
|
1830 - | 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> };
|
2029 + | 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> };
|
1831 2030 | sender.send(()).await.expect("receiver dropped early");
|
1832 2031 | result
|
1833 2032 | }
|
1834 2033 | })
|
1835 2034 | .build_unchecked();
|
1836 2035 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1837 2036 | .await
|
1838 2037 | .expect("unable to make an HTTP request");
|
1839 2038 | ::pretty_assertions::assert_eq!(
|
1840 2039 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1841 2040 | http_response.status()
|
1842 2041 | );
|
1843 2042 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1844 2043 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1845 2044 | http_response.headers(),
|
1846 2045 | expected_headers,
|
1847 2046 | ));
|
1848 2047 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1849 2048 | .await
|
1850 2049 | .expect("unable to extract body to bytes");
|
1851 2050 | ::aws_smithy_protocol_test::assert_ok(
|
1852 - | ::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"))
|
2051 + | ::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"))
|
1853 2052 | );
|
1854 2053 | }
|
1855 2054 | }
|
1856 - | /// When a map member does not fit within length bounds,
|
2055 + | /// When a float member does not fit within range bounds,
|
1857 2056 | /// the response should be a 400 ValidationException.
|
1858 - | /// Test ID: RestJsonMalformedLengthMapOverride_case0
|
2057 + | /// Test ID: RestJsonMalformedRangeMinFloatOverride
|
1859 2058 | #[::tokio::test]
|
1860 - | async fn rest_json_malformed_length_map_override_case0_malformed_request() {
|
2059 + | #[::tracing_test::traced_test]
|
2060 + | #[should_panic]
|
2061 + | async fn rest_json_malformed_range_min_float_override_malformed_request() {
|
1861 2062 | {
|
1862 2063 | #[allow(unused_mut)]
|
1863 2064 | let mut http_request = http::Request::builder()
|
1864 - | .uri("/MalformedLengthOverride")
|
2065 + | .uri("/MalformedRangeOverride")
|
1865 2066 | .method("POST")
|
1866 2067 | .header("content-type", "application/json")
|
1867 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
2068 + | .body(::aws_smithy_http_server::body::Body::from(
|
2069 + | ::bytes::Bytes::from_static("{ \"minFloat\" : 4.3 }".as_bytes()),
|
2070 + | ))
|
2071 + | .unwrap();
|
1868 2072 | #[allow(unused_mut)]
|
1869 2073 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1870 2074 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1871 2075 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1872 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2076 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1873 2077 | let sender = sender.clone();
|
1874 2078 | async move {
|
1875 - | 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> };
|
2079 + | 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> };
|
1876 2080 | sender.send(()).await.expect("receiver dropped early");
|
1877 2081 | result
|
1878 2082 | }
|
1879 2083 | })
|
1880 2084 | .build_unchecked();
|
1881 2085 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1882 2086 | .await
|
1883 2087 | .expect("unable to make an HTTP request");
|
1884 2088 | ::pretty_assertions::assert_eq!(
|
1885 2089 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1886 2090 | http_response.status()
|
1887 2091 | );
|
1888 2092 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1889 2093 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1890 2094 | http_response.headers(),
|
1891 2095 | expected_headers,
|
1892 2096 | ));
|
1893 2097 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1894 2098 | .await
|
1895 2099 | .expect("unable to extract body to bytes");
|
1896 2100 | ::aws_smithy_protocol_test::assert_ok(
|
1897 - | ::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"))
|
2101 + | ::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"))
|
1898 2102 | );
|
1899 2103 | }
|
1900 2104 | }
|
1901 - | /// When a map member does not fit within length bounds,
|
2105 + | /// When a float member does not fit within range bounds,
|
1902 2106 | /// the response should be a 400 ValidationException.
|
1903 - | /// Test ID: RestJsonMalformedLengthMapOverride_case1
|
2107 + | /// Test ID: RestJsonMalformedRangeMaxFloatOverride
|
1904 2108 | #[::tokio::test]
|
1905 - | async fn rest_json_malformed_length_map_override_case1_malformed_request() {
|
2109 + | #[::tracing_test::traced_test]
|
2110 + | #[should_panic]
|
2111 + | async fn rest_json_malformed_range_max_float_override_malformed_request() {
|
1906 2112 | {
|
1907 2113 | #[allow(unused_mut)]
|
1908 2114 | let mut http_request = http::Request::builder()
|
1909 - | .uri("/MalformedLengthOverride")
|
2115 + | .uri("/MalformedRangeOverride")
|
1910 2116 | .method("POST")
|
1911 2117 | .header("content-type", "application/json")
|
1912 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"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()))).unwrap();
|
2118 + | .body(::aws_smithy_http_server::body::Body::from(
|
2119 + | ::bytes::Bytes::from_static("{ \"maxFloat\" : 6.7 }".as_bytes()),
|
2120 + | ))
|
2121 + | .unwrap();
|
1913 2122 | #[allow(unused_mut)]
|
1914 2123 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1915 2124 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1916 2125 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1917 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2126 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1918 2127 | let sender = sender.clone();
|
1919 2128 | async move {
|
1920 - | 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> };
|
2129 + | 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> };
|
1921 2130 | sender.send(()).await.expect("receiver dropped early");
|
1922 2131 | result
|
1923 2132 | }
|
1924 2133 | })
|
1925 2134 | .build_unchecked();
|
1926 2135 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1927 2136 | .await
|
1928 2137 | .expect("unable to make an HTTP request");
|
1929 2138 | ::pretty_assertions::assert_eq!(
|
1930 2139 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1931 2140 | http_response.status()
|
1932 2141 | );
|
1933 2142 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1934 2143 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1935 2144 | http_response.headers(),
|
1936 2145 | expected_headers,
|
1937 2146 | ));
|
1938 2147 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1939 2148 | .await
|
1940 2149 | .expect("unable to extract body to bytes");
|
1941 2150 | ::aws_smithy_protocol_test::assert_ok(
|
1942 - | ::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"))
|
2151 + | ::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"))
|
1943 2152 | );
|
1944 2153 | }
|
1945 2154 | }
|
1946 - | }
|
1947 - | #[cfg(test)]
|
1948 - | #[allow(unreachable_code, unused_variables)]
|
1949 - | mod server_malformed_length_query_string_test {
|
1950 - | /// When a required member has no value in the query string,
|
2155 + | /// When a short member does not fit within range bounds,
|
1951 2156 | /// the response should be a 400 ValidationException.
|
1952 - | /// Test ID: RestJsonMalformedLengthQueryStringNoValue
|
2157 + | /// Test ID: RestJsonMalformedRangeShortOverride_case0
|
1953 2158 | #[::tokio::test]
|
1954 - | async fn rest_json_malformed_length_query_string_no_value_malformed_request() {
|
2159 + | #[::tracing_test::traced_test]
|
2160 + | async fn rest_json_malformed_range_short_override_case0_malformed_request() {
|
1955 2161 | {
|
1956 2162 | #[allow(unused_mut)]
|
1957 2163 | let mut http_request = http::Request::builder()
|
1958 - | .uri("/MalformedLengthQueryString")
|
2164 + | .uri("/MalformedRangeOverride")
|
1959 2165 | .method("POST")
|
1960 2166 | .header("content-type", "application/json")
|
1961 2167 | .body(::aws_smithy_http_server::body::Body::from(
|
1962 - | ::bytes::Bytes::from_static("{}".as_bytes()),
|
2168 + | ::bytes::Bytes::from_static("{ \"short\" : 3 }".as_bytes()),
|
1963 2169 | ))
|
1964 2170 | .unwrap();
|
1965 - | *http_request.uri_mut() = "/MalformedLengthQueryString?string".parse().unwrap();
|
1966 2171 | #[allow(unused_mut)]
|
1967 2172 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1968 2173 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1969 2174 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
1970 - | .malformed_length_query_string(move |input: crate::input::MalformedLengthQueryStringInput| {
|
2175 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1971 2176 | let sender = sender.clone();
|
1972 2177 | async move {
|
1973 - | 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> };
|
2178 + | 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> };
|
1974 2179 | sender.send(()).await.expect("receiver dropped early");
|
1975 2180 | result
|
1976 2181 | }
|
1977 2182 | })
|
1978 2183 | .build_unchecked();
|
1979 2184 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1980 2185 | .await
|
1981 2186 | .expect("unable to make an HTTP request");
|
1982 2187 | ::pretty_assertions::assert_eq!(
|
1983 2188 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1984 2189 | http_response.status()
|
1985 2190 | );
|
1986 2191 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1987 2192 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1988 2193 | http_response.headers(),
|
1989 2194 | expected_headers,
|
1990 2195 | ));
|
1991 2196 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
1992 2197 | .await
|
1993 2198 | .expect("unable to extract body to bytes");
|
1994 2199 | ::aws_smithy_protocol_test::assert_ok(
|
1995 - | ::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"))
|
2200 + | ::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"))
|
1996 2201 | );
|
1997 2202 | }
|
1998 2203 | }
|
1999 - | }
|
2000 - | #[cfg(test)]
|
2001 - | #[allow(unreachable_code, unused_variables)]
|
2002 - | mod server_malformed_pattern_test {
|
2003 - | /// When a string member does not match the specified pattern,
|
2204 + | /// When a short member does not fit within range bounds,
|
2004 2205 | /// the response should be a 400 ValidationException.
|
2005 - | /// Test ID: RestJsonMalformedPatternString_case0
|
2206 + | /// Test ID: RestJsonMalformedRangeShortOverride_case1
|
2006 2207 | #[::tokio::test]
|
2007 - | async fn rest_json_malformed_pattern_string_case0_malformed_request() {
|
2208 + | #[::tracing_test::traced_test]
|
2209 + | async fn rest_json_malformed_range_short_override_case1_malformed_request() {
|
2008 2210 | {
|
2009 2211 | #[allow(unused_mut)]
|
2010 2212 | let mut http_request = http::Request::builder()
|
2011 - | .uri("/MalformedPattern")
|
2213 + | .uri("/MalformedRangeOverride")
|
2012 2214 | .method("POST")
|
2013 2215 | .header("content-type", "application/json")
|
2014 2216 | .body(::aws_smithy_http_server::body::Body::from(
|
2015 - | ::bytes::Bytes::from_static("{ \"string\" : \"ABC\" }".as_bytes()),
|
2217 + | ::bytes::Bytes::from_static("{ \"short\" : 7 }".as_bytes()),
|
2016 2218 | ))
|
2017 2219 | .unwrap();
|
2018 2220 | #[allow(unused_mut)]
|
2019 2221 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2020 2222 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2021 2223 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2022 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2224 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2023 2225 | let sender = sender.clone();
|
2024 2226 | async move {
|
2025 - | 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> };
|
2227 + | 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> };
|
2026 2228 | sender.send(()).await.expect("receiver dropped early");
|
2027 2229 | result
|
2028 2230 | }
|
2029 2231 | })
|
2030 2232 | .build_unchecked();
|
2031 2233 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2032 2234 | .await
|
2033 2235 | .expect("unable to make an HTTP request");
|
2034 2236 | ::pretty_assertions::assert_eq!(
|
2035 2237 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2036 2238 | http_response.status()
|
2037 2239 | );
|
2038 2240 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2039 2241 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2040 2242 | http_response.headers(),
|
2041 2243 | expected_headers,
|
2042 2244 | ));
|
2043 2245 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2044 2246 | .await
|
2045 2247 | .expect("unable to extract body to bytes");
|
2046 2248 | ::aws_smithy_protocol_test::assert_ok(
|
2047 - | ::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"))
|
2249 + | ::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"))
|
2048 2250 | );
|
2049 2251 | }
|
2050 2252 | }
|
2051 - | /// When a string member does not match the specified pattern,
|
2253 + | /// When a short member does not fit within range bounds,
|
2052 2254 | /// the response should be a 400 ValidationException.
|
2053 - | /// Test ID: RestJsonMalformedPatternString_case1
|
2255 + | /// Test ID: RestJsonMalformedRangeMinShortOverride
|
2054 2256 | #[::tokio::test]
|
2055 - | async fn rest_json_malformed_pattern_string_case1_malformed_request() {
|
2257 + | #[::tracing_test::traced_test]
|
2258 + | async fn rest_json_malformed_range_min_short_override_malformed_request() {
|
2056 2259 | {
|
2057 2260 | #[allow(unused_mut)]
|
2058 2261 | let mut http_request = http::Request::builder()
|
2059 - | .uri("/MalformedPattern")
|
2262 + | .uri("/MalformedRangeOverride")
|
2060 2263 | .method("POST")
|
2061 2264 | .header("content-type", "application/json")
|
2062 2265 | .body(::aws_smithy_http_server::body::Body::from(
|
2063 - | ::bytes::Bytes::from_static("{ \"string\" : \"xyz\" }".as_bytes()),
|
2266 + | ::bytes::Bytes::from_static("{ \"minShort\" : 3 }".as_bytes()),
|
2064 2267 | ))
|
2065 2268 | .unwrap();
|
2066 2269 | #[allow(unused_mut)]
|
2067 2270 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2068 2271 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2069 2272 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2070 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2071 - | let sender = sender.clone();
|
2072 - | async move {
|
2073 - | 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> };
|
2074 - | sender.send(()).await.expect("receiver dropped early");
|
2075 - | result
|
2076 - | }
|
2077 - | })
|
2078 - | .build_unchecked();
|
2079 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2080 - | .await
|
2081 - | .expect("unable to make an HTTP request");
|
2082 - | ::pretty_assertions::assert_eq!(
|
2083 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2084 - | http_response.status()
|
2085 - | );
|
2086 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2087 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2088 - | http_response.headers(),
|
2089 - | expected_headers,
|
2090 - | ));
|
2091 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2092 - | .await
|
2093 - | .expect("unable to extract body to bytes");
|
2094 - | ::aws_smithy_protocol_test::assert_ok(
|
2095 - | ::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"))
|
2096 - | );
|
2097 - | }
|
2098 - | }
|
2099 - | /// When the specified pattern is susceptible to ReDOS, the service will not
|
2100 - | /// hang indefinitely while evaluating the pattern
|
2101 - | /// Test ID: RestJsonMalformedPatternReDOSString
|
2102 - | #[::tokio::test]
|
2103 - | async fn rest_json_malformed_pattern_re_dos_string_malformed_request() {
|
2104 - | {
|
2105 - | #[allow(unused_mut)]
|
2106 - | let mut http_request = http::Request::builder()
|
2107 - | .uri("/MalformedPattern")
|
2108 - | .method("POST")
|
2109 - | .header("content-type", "application/json")
|
2110 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes()))).unwrap();
|
2111 - | #[allow(unused_mut)]
|
2112 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2113 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2114 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2115 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2273 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2116 2274 | let sender = sender.clone();
|
2117 2275 | async move {
|
2118 - | 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> };
|
2276 + | 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> };
|
2119 2277 | sender.send(()).await.expect("receiver dropped early");
|
2120 2278 | result
|
2121 2279 | }
|
2122 2280 | })
|
2123 2281 | .build_unchecked();
|
2124 2282 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2125 2283 | .await
|
2126 2284 | .expect("unable to make an HTTP request");
|
2127 2285 | ::pretty_assertions::assert_eq!(
|
2128 2286 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2129 2287 | http_response.status()
|
2130 2288 | );
|
2131 2289 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2132 2290 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2133 2291 | http_response.headers(),
|
2134 2292 | expected_headers,
|
2135 2293 | ));
|
2136 2294 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2137 2295 | .await
|
2138 2296 | .expect("unable to extract body to bytes");
|
2139 2297 | ::aws_smithy_protocol_test::assert_ok(
|
2140 - | ::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"))
|
2298 + | ::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"))
|
2141 2299 | );
|
2142 2300 | }
|
2143 2301 | }
|
2144 - | /// When a list member value does not match the specified pattern,
|
2302 + | /// When a short member does not fit within range bounds,
|
2145 2303 | /// the response should be a 400 ValidationException.
|
2146 - | /// Test ID: RestJsonMalformedPatternList_case0
|
2304 + | /// Test ID: RestJsonMalformedRangeMaxShortOverride
|
2147 2305 | #[::tokio::test]
|
2148 - | async fn rest_json_malformed_pattern_list_case0_malformed_request() {
|
2306 + | #[::tracing_test::traced_test]
|
2307 + | async fn rest_json_malformed_range_max_short_override_malformed_request() {
|
2149 2308 | {
|
2150 2309 | #[allow(unused_mut)]
|
2151 2310 | let mut http_request = http::Request::builder()
|
2152 - | .uri("/MalformedPattern")
|
2311 + | .uri("/MalformedRangeOverride")
|
2153 2312 | .method("POST")
|
2154 2313 | .header("content-type", "application/json")
|
2155 2314 | .body(::aws_smithy_http_server::body::Body::from(
|
2156 - | ::bytes::Bytes::from_static("{ \"list\" : [\"ABC\"] }".as_bytes()),
|
2315 + | ::bytes::Bytes::from_static("{ \"maxShort\" : 7 }".as_bytes()),
|
2157 2316 | ))
|
2158 2317 | .unwrap();
|
2159 2318 | #[allow(unused_mut)]
|
2160 2319 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2161 2320 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2162 2321 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2163 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2322 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2164 2323 | let sender = sender.clone();
|
2165 2324 | async move {
|
2166 - | 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> };
|
2325 + | 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> };
|
2167 2326 | sender.send(()).await.expect("receiver dropped early");
|
2168 2327 | result
|
2169 2328 | }
|
2170 2329 | })
|
2171 2330 | .build_unchecked();
|
2172 2331 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2173 2332 | .await
|
2174 2333 | .expect("unable to make an HTTP request");
|
2175 2334 | ::pretty_assertions::assert_eq!(
|
2176 2335 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2177 2336 | http_response.status()
|
2178 2337 | );
|
2179 2338 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2180 2339 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2181 2340 | http_response.headers(),
|
2182 2341 | expected_headers,
|
2183 2342 | ));
|
2184 2343 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2185 2344 | .await
|
2186 2345 | .expect("unable to extract body to bytes");
|
2187 2346 | ::aws_smithy_protocol_test::assert_ok(
|
2188 - | ::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"))
|
2347 + | ::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"))
|
2189 2348 | );
|
2190 2349 | }
|
2191 2350 | }
|
2192 - | /// When a list member value does not match the specified pattern,
|
2351 + | /// When a integer member does not fit within range bounds,
|
2193 2352 | /// the response should be a 400 ValidationException.
|
2194 - | /// Test ID: RestJsonMalformedPatternList_case1
|
2353 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case0
|
2195 2354 | #[::tokio::test]
|
2196 - | async fn rest_json_malformed_pattern_list_case1_malformed_request() {
|
2355 + | #[::tracing_test::traced_test]
|
2356 + | async fn rest_json_malformed_range_integer_override_case0_malformed_request() {
|
2197 2357 | {
|
2198 2358 | #[allow(unused_mut)]
|
2199 2359 | let mut http_request = http::Request::builder()
|
2200 - | .uri("/MalformedPattern")
|
2360 + | .uri("/MalformedRangeOverride")
|
2201 2361 | .method("POST")
|
2202 2362 | .header("content-type", "application/json")
|
2203 2363 | .body(::aws_smithy_http_server::body::Body::from(
|
2204 - | ::bytes::Bytes::from_static("{ \"list\" : [\"xyz\"] }".as_bytes()),
|
2364 + | ::bytes::Bytes::from_static("{ \"integer\" : 3 }".as_bytes()),
|
2205 2365 | ))
|
2206 2366 | .unwrap();
|
2207 2367 | #[allow(unused_mut)]
|
2208 2368 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2209 2369 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2210 2370 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2211 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2371 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2212 2372 | let sender = sender.clone();
|
2213 2373 | async move {
|
2214 - | 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> };
|
2374 + | 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> };
|
2215 2375 | sender.send(()).await.expect("receiver dropped early");
|
2216 2376 | result
|
2217 2377 | }
|
2218 2378 | })
|
2219 2379 | .build_unchecked();
|
2220 2380 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2221 2381 | .await
|
2222 2382 | .expect("unable to make an HTTP request");
|
2223 2383 | ::pretty_assertions::assert_eq!(
|
2224 2384 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2225 2385 | http_response.status()
|
2226 2386 | );
|
2227 2387 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2228 2388 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2229 2389 | http_response.headers(),
|
2230 2390 | expected_headers,
|
2231 2391 | ));
|
2232 2392 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2233 2393 | .await
|
2234 2394 | .expect("unable to extract body to bytes");
|
2235 2395 | ::aws_smithy_protocol_test::assert_ok(
|
2236 - | ::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"))
|
2396 + | ::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"))
|
2237 2397 | );
|
2238 2398 | }
|
2239 2399 | }
|
2240 - | /// When a map member's key does not match the specified pattern,
|
2400 + | /// When a integer member does not fit within range bounds,
|
2241 2401 | /// the response should be a 400 ValidationException.
|
2242 - | /// Test ID: RestJsonMalformedPatternMapKey_case0
|
2402 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case1
|
2243 2403 | #[::tokio::test]
|
2244 - | async fn rest_json_malformed_pattern_map_key_case0_malformed_request() {
|
2404 + | #[::tracing_test::traced_test]
|
2405 + | async fn rest_json_malformed_range_integer_override_case1_malformed_request() {
|
2245 2406 | {
|
2246 2407 | #[allow(unused_mut)]
|
2247 2408 | let mut http_request = http::Request::builder()
|
2248 - | .uri("/MalformedPattern")
|
2409 + | .uri("/MalformedRangeOverride")
|
2249 2410 | .method("POST")
|
2250 2411 | .header("content-type", "application/json")
|
2251 2412 | .body(::aws_smithy_http_server::body::Body::from(
|
2252 - | ::bytes::Bytes::from_static("{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes()),
|
2413 + | ::bytes::Bytes::from_static("{ \"integer\" : 7 }".as_bytes()),
|
2253 2414 | ))
|
2254 2415 | .unwrap();
|
2255 2416 | #[allow(unused_mut)]
|
2256 2417 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2257 2418 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2258 2419 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2259 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2420 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2260 2421 | let sender = sender.clone();
|
2261 2422 | async move {
|
2262 - | 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> };
|
2423 + | 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> };
|
2263 2424 | sender.send(()).await.expect("receiver dropped early");
|
2264 2425 | result
|
2265 2426 | }
|
2266 2427 | })
|
2267 2428 | .build_unchecked();
|
2268 2429 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2269 2430 | .await
|
2270 2431 | .expect("unable to make an HTTP request");
|
2271 2432 | ::pretty_assertions::assert_eq!(
|
2272 2433 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2273 2434 | http_response.status()
|
2274 2435 | );
|
2275 2436 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2276 2437 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2277 2438 | http_response.headers(),
|
2278 2439 | expected_headers,
|
2279 2440 | ));
|
2280 2441 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2281 2442 | .await
|
2282 2443 | .expect("unable to extract body to bytes");
|
2283 2444 | ::aws_smithy_protocol_test::assert_ok(
|
2284 - | ::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"))
|
2445 + | ::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"))
|
2285 2446 | );
|
2286 2447 | }
|
2287 2448 | }
|
2288 - | /// When a map member's key does not match the specified pattern,
|
2449 + | /// When a integer member does not fit within range bounds,
|
2289 2450 | /// the response should be a 400 ValidationException.
|
2290 - | /// Test ID: RestJsonMalformedPatternMapKey_case1
|
2451 + | /// Test ID: RestJsonMalformedRangeMinIntegerOverride
|
2291 2452 | #[::tokio::test]
|
2292 - | async fn rest_json_malformed_pattern_map_key_case1_malformed_request() {
|
2453 + | #[::tracing_test::traced_test]
|
2454 + | async fn rest_json_malformed_range_min_integer_override_malformed_request() {
|
2293 2455 | {
|
2294 2456 | #[allow(unused_mut)]
|
2295 2457 | let mut http_request = http::Request::builder()
|
2296 - | .uri("/MalformedPattern")
|
2458 + | .uri("/MalformedRangeOverride")
|
2297 2459 | .method("POST")
|
2298 2460 | .header("content-type", "application/json")
|
2299 2461 | .body(::aws_smithy_http_server::body::Body::from(
|
2300 - | ::bytes::Bytes::from_static("{ \"map\" : { \"xyz\" : \"abc\" } }".as_bytes()),
|
2462 + | ::bytes::Bytes::from_static("{ \"minInteger\" : 3 }".as_bytes()),
|
2301 2463 | ))
|
2302 2464 | .unwrap();
|
2303 2465 | #[allow(unused_mut)]
|
2304 2466 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2305 2467 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2306 2468 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2307 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2469 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2308 2470 | let sender = sender.clone();
|
2309 2471 | async move {
|
2310 - | 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> };
|
2472 + | 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> };
|
2311 2473 | sender.send(()).await.expect("receiver dropped early");
|
2312 2474 | result
|
2313 2475 | }
|
2314 2476 | })
|
2315 2477 | .build_unchecked();
|
2316 2478 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2317 2479 | .await
|
2318 2480 | .expect("unable to make an HTTP request");
|
2319 2481 | ::pretty_assertions::assert_eq!(
|
2320 2482 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2321 2483 | http_response.status()
|
2322 2484 | );
|
2323 2485 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2324 2486 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2325 2487 | http_response.headers(),
|
2326 2488 | expected_headers,
|
2327 2489 | ));
|
2328 2490 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2329 2491 | .await
|
2330 2492 | .expect("unable to extract body to bytes");
|
2331 2493 | ::aws_smithy_protocol_test::assert_ok(
|
2332 - | ::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"))
|
2494 + | ::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"))
|
2333 2495 | );
|
2334 2496 | }
|
2335 2497 | }
|
2336 - | /// When a map member's value does not match the specified pattern,
|
2498 + | /// When a integer member does not fit within range bounds,
|
2337 2499 | /// the response should be a 400 ValidationException.
|
2338 - | /// Test ID: RestJsonMalformedPatternMapValue_case0
|
2500 + | /// Test ID: RestJsonMalformedRangeMaxIntegerOverride
|
2339 2501 | #[::tokio::test]
|
2340 - | async fn rest_json_malformed_pattern_map_value_case0_malformed_request() {
|
2502 + | #[::tracing_test::traced_test]
|
2503 + | async fn rest_json_malformed_range_max_integer_override_malformed_request() {
|
2341 2504 | {
|
2342 2505 | #[allow(unused_mut)]
|
2343 2506 | let mut http_request = http::Request::builder()
|
2344 - | .uri("/MalformedPattern")
|
2507 + | .uri("/MalformedRangeOverride")
|
2345 2508 | .method("POST")
|
2346 2509 | .header("content-type", "application/json")
|
2347 2510 | .body(::aws_smithy_http_server::body::Body::from(
|
2348 - | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes()),
|
2511 + | ::bytes::Bytes::from_static("{ \"maxInteger\" : 7 }".as_bytes()),
|
2349 2512 | ))
|
2350 2513 | .unwrap();
|
2351 2514 | #[allow(unused_mut)]
|
2352 2515 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2353 2516 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2354 2517 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2355 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2518 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2356 2519 | let sender = sender.clone();
|
2357 2520 | async move {
|
2358 - | 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> };
|
2521 + | 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> };
|
2359 2522 | sender.send(()).await.expect("receiver dropped early");
|
2360 2523 | result
|
2361 2524 | }
|
2362 2525 | })
|
2363 2526 | .build_unchecked();
|
2364 2527 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2365 2528 | .await
|
2366 2529 | .expect("unable to make an HTTP request");
|
2367 2530 | ::pretty_assertions::assert_eq!(
|
2368 2531 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2369 2532 | http_response.status()
|
2370 2533 | );
|
2371 2534 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2372 2535 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2373 2536 | http_response.headers(),
|
2374 2537 | expected_headers,
|
2375 2538 | ));
|
2376 2539 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2377 2540 | .await
|
2378 2541 | .expect("unable to extract body to bytes");
|
2379 2542 | ::aws_smithy_protocol_test::assert_ok(
|
2380 - | ::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"))
|
2543 + | ::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"))
|
2381 2544 | );
|
2382 2545 | }
|
2383 2546 | }
|
2384 - | /// When a map member's value does not match the specified pattern,
|
2547 + | /// When a long member does not fit within range bounds,
|
2385 2548 | /// the response should be a 400 ValidationException.
|
2386 - | /// Test ID: RestJsonMalformedPatternMapValue_case1
|
2549 + | /// Test ID: RestJsonMalformedRangeLongOverride_case0
|
2387 2550 | #[::tokio::test]
|
2388 - | async fn rest_json_malformed_pattern_map_value_case1_malformed_request() {
|
2551 + | #[::tracing_test::traced_test]
|
2552 + | async fn rest_json_malformed_range_long_override_case0_malformed_request() {
|
2389 2553 | {
|
2390 2554 | #[allow(unused_mut)]
|
2391 2555 | let mut http_request = http::Request::builder()
|
2392 - | .uri("/MalformedPattern")
|
2556 + | .uri("/MalformedRangeOverride")
|
2393 2557 | .method("POST")
|
2394 2558 | .header("content-type", "application/json")
|
2395 2559 | .body(::aws_smithy_http_server::body::Body::from(
|
2396 - | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"xyz\" } }".as_bytes()),
|
2560 + | ::bytes::Bytes::from_static("{ \"long\" : 3 }".as_bytes()),
|
2397 2561 | ))
|
2398 2562 | .unwrap();
|
2399 2563 | #[allow(unused_mut)]
|
2400 2564 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2401 2565 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2402 2566 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2403 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2567 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2404 2568 | let sender = sender.clone();
|
2405 2569 | async move {
|
2406 - | 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> };
|
2570 + | 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> };
|
2407 2571 | sender.send(()).await.expect("receiver dropped early");
|
2408 2572 | result
|
2409 2573 | }
|
2410 2574 | })
|
2411 2575 | .build_unchecked();
|
2412 2576 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2413 2577 | .await
|
2414 2578 | .expect("unable to make an HTTP request");
|
2415 2579 | ::pretty_assertions::assert_eq!(
|
2416 2580 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2417 2581 | http_response.status()
|
2418 2582 | );
|
2419 2583 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2420 2584 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2421 2585 | http_response.headers(),
|
2422 2586 | expected_headers,
|
2423 2587 | ));
|
2424 2588 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2425 2589 | .await
|
2426 2590 | .expect("unable to extract body to bytes");
|
2427 2591 | ::aws_smithy_protocol_test::assert_ok(
|
2428 - | ::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"))
|
2592 + | ::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"))
|
2429 2593 | );
|
2430 2594 | }
|
2431 2595 | }
|
2432 - | /// When a union member's value does not match the specified pattern,
|
2596 + | /// When a long member does not fit within range bounds,
|
2433 2597 | /// the response should be a 400 ValidationException.
|
2434 - | /// Test ID: RestJsonMalformedPatternUnion_case0
|
2598 + | /// Test ID: RestJsonMalformedRangeLongOverride_case1
|
2435 2599 | #[::tokio::test]
|
2436 - | async fn rest_json_malformed_pattern_union_case0_malformed_request() {
|
2600 + | #[::tracing_test::traced_test]
|
2601 + | async fn rest_json_malformed_range_long_override_case1_malformed_request() {
|
2437 2602 | {
|
2438 2603 | #[allow(unused_mut)]
|
2439 2604 | let mut http_request = http::Request::builder()
|
2440 - | .uri("/MalformedPattern")
|
2605 + | .uri("/MalformedRangeOverride")
|
2441 2606 | .method("POST")
|
2442 2607 | .header("content-type", "application/json")
|
2443 2608 | .body(::aws_smithy_http_server::body::Body::from(
|
2444 - | ::bytes::Bytes::from_static(
|
2445 - | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
2446 - | ),
|
2609 + | ::bytes::Bytes::from_static("{ \"long\" : 7 }".as_bytes()),
|
2447 2610 | ))
|
2448 2611 | .unwrap();
|
2449 2612 | #[allow(unused_mut)]
|
2450 2613 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2451 2614 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2452 2615 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2453 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2616 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2454 2617 | let sender = sender.clone();
|
2455 2618 | async move {
|
2456 - | 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> };
|
2619 + | 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> };
|
2457 2620 | sender.send(()).await.expect("receiver dropped early");
|
2458 2621 | result
|
2459 2622 | }
|
2460 2623 | })
|
2461 2624 | .build_unchecked();
|
2462 2625 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2463 2626 | .await
|
2464 2627 | .expect("unable to make an HTTP request");
|
2465 2628 | ::pretty_assertions::assert_eq!(
|
2466 2629 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2467 2630 | http_response.status()
|
2468 2631 | );
|
2469 2632 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2470 2633 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2471 2634 | http_response.headers(),
|
2472 2635 | expected_headers,
|
2473 2636 | ));
|
2474 2637 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2475 2638 | .await
|
2476 2639 | .expect("unable to extract body to bytes");
|
2477 2640 | ::aws_smithy_protocol_test::assert_ok(
|
2478 - | ::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"))
|
2641 + | ::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"))
|
2479 2642 | );
|
2480 2643 | }
|
2481 2644 | }
|
2482 - | /// When a union member's value does not match the specified pattern,
|
2645 + | /// When a long member does not fit within range bounds,
|
2483 2646 | /// the response should be a 400 ValidationException.
|
2484 - | /// Test ID: RestJsonMalformedPatternUnion_case1
|
2647 + | /// Test ID: RestJsonMalformedRangeMinLongOverride
|
2485 2648 | #[::tokio::test]
|
2486 - | async fn rest_json_malformed_pattern_union_case1_malformed_request() {
|
2649 + | #[::tracing_test::traced_test]
|
2650 + | async fn rest_json_malformed_range_min_long_override_malformed_request() {
|
2487 2651 | {
|
2488 2652 | #[allow(unused_mut)]
|
2489 2653 | let mut http_request = http::Request::builder()
|
2490 - | .uri("/MalformedPattern")
|
2654 + | .uri("/MalformedRangeOverride")
|
2491 2655 | .method("POST")
|
2492 2656 | .header("content-type", "application/json")
|
2493 2657 | .body(::aws_smithy_http_server::body::Body::from(
|
2494 - | ::bytes::Bytes::from_static(
|
2495 - | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
2496 - | ),
|
2658 + | ::bytes::Bytes::from_static("{ \"minLong\" : 3 }".as_bytes()),
|
2497 2659 | ))
|
2498 2660 | .unwrap();
|
2499 2661 | #[allow(unused_mut)]
|
2500 2662 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2501 2663 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2502 2664 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2503 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2665 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2504 2666 | let sender = sender.clone();
|
2505 2667 | async move {
|
2506 - | 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> };
|
2668 + | 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> };
|
2507 2669 | sender.send(()).await.expect("receiver dropped early");
|
2508 2670 | result
|
2509 2671 | }
|
2510 2672 | })
|
2511 2673 | .build_unchecked();
|
2512 2674 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2513 2675 | .await
|
2514 2676 | .expect("unable to make an HTTP request");
|
2515 2677 | ::pretty_assertions::assert_eq!(
|
2516 2678 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2517 2679 | http_response.status()
|
2518 2680 | );
|
2519 2681 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2520 2682 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2521 2683 | http_response.headers(),
|
2522 2684 | expected_headers,
|
2523 2685 | ));
|
2524 2686 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2525 2687 | .await
|
2526 2688 | .expect("unable to extract body to bytes");
|
2527 2689 | ::aws_smithy_protocol_test::assert_ok(
|
2528 - | ::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"))
|
2690 + | ::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"))
|
2529 2691 | );
|
2530 2692 | }
|
2531 2693 | }
|
2532 - | }
|
2533 - | #[cfg(test)]
|
2534 - | #[allow(unreachable_code, unused_variables)]
|
2535 - | mod server_malformed_pattern_override_test {
|
2536 - | /// When a string member does not match the specified pattern,
|
2694 + | /// When a long member does not fit within range bounds,
|
2537 2695 | /// the response should be a 400 ValidationException.
|
2538 - | /// Test ID: RestJsonMalformedPatternStringOverride_case0
|
2696 + | /// Test ID: RestJsonMalformedRangeMaxLongOverride
|
2539 2697 | #[::tokio::test]
|
2540 - | async fn rest_json_malformed_pattern_string_override_case0_malformed_request() {
|
2698 + | #[::tracing_test::traced_test]
|
2699 + | async fn rest_json_malformed_range_max_long_override_malformed_request() {
|
2541 2700 | {
|
2542 2701 | #[allow(unused_mut)]
|
2543 2702 | let mut http_request = http::Request::builder()
|
2544 - | .uri("/MalformedPatternOverride")
|
2703 + | .uri("/MalformedRangeOverride")
|
2545 2704 | .method("POST")
|
2546 2705 | .header("content-type", "application/json")
|
2547 2706 | .body(::aws_smithy_http_server::body::Body::from(
|
2548 - | ::bytes::Bytes::from_static("{ \"string\" : \"abc\" }".as_bytes()),
|
2707 + | ::bytes::Bytes::from_static("{ \"maxLong\" : 7 }".as_bytes()),
|
2549 2708 | ))
|
2550 2709 | .unwrap();
|
2551 2710 | #[allow(unused_mut)]
|
2552 2711 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2553 2712 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2554 2713 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2555 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
2714 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2556 2715 | let sender = sender.clone();
|
2557 2716 | async move {
|
2558 - | 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> };
|
2717 + | 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> };
|
2559 2718 | sender.send(()).await.expect("receiver dropped early");
|
2560 2719 | result
|
2561 2720 | }
|
2562 2721 | })
|
2563 2722 | .build_unchecked();
|
2564 2723 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2565 2724 | .await
|
2566 2725 | .expect("unable to make an HTTP request");
|
2567 2726 | ::pretty_assertions::assert_eq!(
|
2568 2727 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2569 2728 | http_response.status()
|
2570 2729 | );
|
2571 2730 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2572 2731 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2573 2732 | http_response.headers(),
|
2574 2733 | expected_headers,
|
2575 2734 | ));
|
2576 2735 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2577 2736 | .await
|
2578 2737 | .expect("unable to extract body to bytes");
|
2579 2738 | ::aws_smithy_protocol_test::assert_ok(
|
2580 - | ::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"))
|
2739 + | ::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"))
|
2581 2740 | );
|
2582 2741 | }
|
2583 2742 | }
|
2584 - | /// When a string member does not match the specified pattern,
|
2585 - | /// the response should be a 400 ValidationException.
|
2586 - | /// Test ID: RestJsonMalformedPatternStringOverride_case1
|
2587 - | #[::tokio::test]
|
2588 - | async fn rest_json_malformed_pattern_string_override_case1_malformed_request() {
|
2743 + | }
|
2744 + |
|
2745 + | const CONTENT_TYPE_MALFORMEDRANGE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
2746 + | ::pin_project_lite::pin_project! {
|
2747 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2748 + | /// [`MalformedRangeInput`](crate::input::MalformedRangeInput) using modelled bindings.
|
2749 + | pub struct MalformedRangeInputFuture {
|
2750 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRangeInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
2751 + | }
|
2752 + | }
|
2753 + |
|
2754 + | impl std::future::Future for MalformedRangeInputFuture {
|
2755 + | type Output = Result<
|
2756 + | crate::input::MalformedRangeInput,
|
2757 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
2758 + | >;
|
2759 + |
|
2760 + | fn poll(
|
2761 + | self: std::pin::Pin<&mut Self>,
|
2762 + | cx: &mut std::task::Context<'_>,
|
2763 + | ) -> std::task::Poll<Self::Output> {
|
2764 + | let this = self.project();
|
2765 + | this.inner.as_mut().poll(cx)
|
2766 + | }
|
2767 + | }
|
2768 + |
|
2769 + | impl<B>
|
2770 + | ::aws_smithy_http_server::request::FromRequest<
|
2771 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2772 + | B,
|
2773 + | > for crate::input::MalformedRangeInput
|
2774 + | where
|
2775 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
2776 + | B: 'static,
|
2777 + |
|
2778 + | B::Data: Send,
|
2779 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
2780 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
2781 + | {
|
2782 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
2783 + | type Future = MalformedRangeInputFuture;
|
2784 + |
|
2785 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
2786 + | let fut = async move {
|
2787 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
2788 + | request.headers(),
|
2789 + | &CONTENT_TYPE_MALFORMEDRANGE,
|
2790 + | ) {
|
2791 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
2792 + | }
|
2793 + | crate::protocol_serde::shape_malformed_range::de_malformed_range_http_request(request)
|
2794 + | .await
|
2795 + | .map_err(Into::into)
|
2796 + | };
|
2797 + | use ::futures_util::future::TryFutureExt;
|
2798 + | let fut = fut.map_err(
|
2799 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
2800 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2801 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
2802 + | e,
|
2803 + | )
|
2804 + | },
|
2805 + | );
|
2806 + | MalformedRangeInputFuture {
|
2807 + | inner: Box::pin(fut),
|
2808 + | }
|
2809 + | }
|
2810 + | }
|
2811 + | impl
|
2812 + | ::aws_smithy_http_server::response::IntoResponse<
|
2813 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2814 + | > for crate::output::MalformedRangeOutput
|
2815 + | {
|
2816 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2817 + | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_response(self)
|
2818 + | {
|
2819 + | Ok(response) => response,
|
2820 + | Err(e) => {
|
2821 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2822 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
2823 + | }
|
2824 + | }
|
2825 + | }
|
2826 + | }
|
2827 + | impl
|
2828 + | ::aws_smithy_http_server::response::IntoResponse<
|
2829 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2830 + | > for crate::error::MalformedRangeError
|
2831 + | {
|
2832 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2833 + | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_error(&self) {
|
2834 + | Ok(mut response) => {
|
2835 + | response.extensions_mut().insert(
|
2836 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
2837 + | );
|
2838 + | response
|
2839 + | }
|
2840 + | Err(e) => {
|
2841 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2842 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
2843 + | }
|
2844 + | }
|
2845 + | }
|
2846 + | }
|
2847 + |
|
2848 + | #[allow(unreachable_code, unused_variables)]
|
2849 + | #[cfg(test)]
|
2850 + | mod malformed_range_test {
|
2851 + |
|
2852 + | /// When a byte member does not fit within range bounds,
|
2853 + | /// the response should be a 400 ValidationException.
|
2854 + | /// Test ID: RestJsonMalformedRangeByte_case0
|
2855 + | #[::tokio::test]
|
2856 + | #[::tracing_test::traced_test]
|
2857 + | async fn rest_json_malformed_range_byte_case0_malformed_request() {
|
2589 2858 | {
|
2590 2859 | #[allow(unused_mut)]
|
2591 2860 | let mut http_request = http::Request::builder()
|
2592 - | .uri("/MalformedPatternOverride")
|
2861 + | .uri("/MalformedRange")
|
2593 2862 | .method("POST")
|
2594 2863 | .header("content-type", "application/json")
|
2595 2864 | .body(::aws_smithy_http_server::body::Body::from(
|
2596 - | ::bytes::Bytes::from_static("{ \"string\" : \"xyz\" }".as_bytes()),
|
2865 + | ::bytes::Bytes::from_static("{ \"byte\" : 1 }".as_bytes()),
|
2597 2866 | ))
|
2598 2867 | .unwrap();
|
2599 2868 | #[allow(unused_mut)]
|
2600 2869 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2601 2870 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2602 2871 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2603 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
2872 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2604 2873 | let sender = sender.clone();
|
2605 2874 | async move {
|
2606 - | 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> };
|
2875 + | 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> };
|
2607 2876 | sender.send(()).await.expect("receiver dropped early");
|
2608 2877 | result
|
2609 2878 | }
|
2610 2879 | })
|
2611 2880 | .build_unchecked();
|
2612 2881 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2613 2882 | .await
|
2614 2883 | .expect("unable to make an HTTP request");
|
2615 2884 | ::pretty_assertions::assert_eq!(
|
2616 2885 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2617 2886 | http_response.status()
|
2618 2887 | );
|
2619 2888 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2620 2889 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2621 2890 | http_response.headers(),
|
2622 2891 | expected_headers,
|
2623 2892 | ));
|
2624 2893 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2625 2894 | .await
|
2626 2895 | .expect("unable to extract body to bytes");
|
2627 2896 | ::aws_smithy_protocol_test::assert_ok(
|
2628 - | ::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"))
|
2897 + | ::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"))
|
2629 2898 | );
|
2630 2899 | }
|
2631 2900 | }
|
2632 - | /// When a list member value does not match the specified pattern,
|
2901 + | /// When a byte member does not fit within range bounds,
|
2633 2902 | /// the response should be a 400 ValidationException.
|
2634 - | /// Test ID: RestJsonMalformedPatternListOverride_case0
|
2903 + | /// Test ID: RestJsonMalformedRangeByte_case1
|
2635 2904 | #[::tokio::test]
|
2636 - | async fn rest_json_malformed_pattern_list_override_case0_malformed_request() {
|
2905 + | #[::tracing_test::traced_test]
|
2906 + | async fn rest_json_malformed_range_byte_case1_malformed_request() {
|
2637 2907 | {
|
2638 2908 | #[allow(unused_mut)]
|
2639 2909 | let mut http_request = http::Request::builder()
|
2640 - | .uri("/MalformedPatternOverride")
|
2910 + | .uri("/MalformedRange")
|
2641 2911 | .method("POST")
|
2642 2912 | .header("content-type", "application/json")
|
2643 2913 | .body(::aws_smithy_http_server::body::Body::from(
|
2644 - | ::bytes::Bytes::from_static("{ \"list\" : [\"abc\"] }".as_bytes()),
|
2914 + | ::bytes::Bytes::from_static("{ \"byte\" : 9 }".as_bytes()),
|
2645 2915 | ))
|
2646 2916 | .unwrap();
|
2647 2917 | #[allow(unused_mut)]
|
2648 2918 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2649 2919 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2650 2920 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2651 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
2921 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2652 2922 | let sender = sender.clone();
|
2653 2923 | async move {
|
2654 - | 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> };
|
2924 + | 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> };
|
2655 2925 | sender.send(()).await.expect("receiver dropped early");
|
2656 2926 | result
|
2657 2927 | }
|
2658 2928 | })
|
2659 2929 | .build_unchecked();
|
2660 2930 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2661 2931 | .await
|
2662 2932 | .expect("unable to make an HTTP request");
|
2663 2933 | ::pretty_assertions::assert_eq!(
|
2664 2934 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2665 2935 | http_response.status()
|
2666 2936 | );
|
2667 2937 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2668 2938 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2669 2939 | http_response.headers(),
|
2670 2940 | expected_headers,
|
2671 2941 | ));
|
2672 2942 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2673 2943 | .await
|
2674 2944 | .expect("unable to extract body to bytes");
|
2675 2945 | ::aws_smithy_protocol_test::assert_ok(
|
2676 - | ::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"))
|
2946 + | ::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"))
|
2677 2947 | );
|
2678 2948 | }
|
2679 2949 | }
|
2680 - | /// When a list member value does not match the specified pattern,
|
2950 + | /// When a byte member does not fit within range bounds,
|
2681 2951 | /// the response should be a 400 ValidationException.
|
2682 - | /// Test ID: RestJsonMalformedPatternListOverride_case1
|
2952 + | /// Test ID: RestJsonMalformedRangeMinByte
|
2683 2953 | #[::tokio::test]
|
2684 - | async fn rest_json_malformed_pattern_list_override_case1_malformed_request() {
|
2954 + | #[::tracing_test::traced_test]
|
2955 + | async fn rest_json_malformed_range_min_byte_malformed_request() {
|
2685 2956 | {
|
2686 2957 | #[allow(unused_mut)]
|
2687 2958 | let mut http_request = http::Request::builder()
|
2688 - | .uri("/MalformedPatternOverride")
|
2959 + | .uri("/MalformedRange")
|
2689 2960 | .method("POST")
|
2690 2961 | .header("content-type", "application/json")
|
2691 2962 | .body(::aws_smithy_http_server::body::Body::from(
|
2692 - | ::bytes::Bytes::from_static("{ \"list\" : [\"xyz\"] }".as_bytes()),
|
2963 + | ::bytes::Bytes::from_static("{ \"minByte\" : 1 }".as_bytes()),
|
2693 2964 | ))
|
2694 2965 | .unwrap();
|
2695 2966 | #[allow(unused_mut)]
|
2696 2967 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2697 2968 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2698 2969 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2699 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
2970 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2700 2971 | let sender = sender.clone();
|
2701 2972 | async move {
|
2702 - | 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> };
|
2973 + | 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> };
|
2703 2974 | sender.send(()).await.expect("receiver dropped early");
|
2704 2975 | result
|
2705 2976 | }
|
2706 2977 | })
|
2707 2978 | .build_unchecked();
|
2708 2979 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2709 2980 | .await
|
2710 2981 | .expect("unable to make an HTTP request");
|
2711 2982 | ::pretty_assertions::assert_eq!(
|
2712 2983 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2713 2984 | http_response.status()
|
2714 2985 | );
|
2715 2986 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2716 2987 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2717 2988 | http_response.headers(),
|
2718 2989 | expected_headers,
|
2719 2990 | ));
|
2720 2991 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2721 2992 | .await
|
2722 2993 | .expect("unable to extract body to bytes");
|
2723 2994 | ::aws_smithy_protocol_test::assert_ok(
|
2724 - | ::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"))
|
2995 + | ::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"))
|
2725 2996 | );
|
2726 2997 | }
|
2727 2998 | }
|
2728 - | /// When a map member's key does not match the specified pattern,
|
2999 + | /// When a byte member does not fit within range bounds,
|
2729 3000 | /// the response should be a 400 ValidationException.
|
2730 - | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case0
|
3001 + | /// Test ID: RestJsonMalformedRangeMaxByte
|
2731 3002 | #[::tokio::test]
|
2732 - | async fn rest_json_malformed_pattern_map_key_override_case0_malformed_request() {
|
3003 + | #[::tracing_test::traced_test]
|
3004 + | async fn rest_json_malformed_range_max_byte_malformed_request() {
|
2733 3005 | {
|
2734 3006 | #[allow(unused_mut)]
|
2735 3007 | let mut http_request = http::Request::builder()
|
2736 - | .uri("/MalformedPatternOverride")
|
3008 + | .uri("/MalformedRange")
|
2737 3009 | .method("POST")
|
2738 3010 | .header("content-type", "application/json")
|
2739 3011 | .body(::aws_smithy_http_server::body::Body::from(
|
2740 - | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\" : \"ghi\" } }".as_bytes()),
|
3012 + | ::bytes::Bytes::from_static("{ \"maxByte\" : 9 }".as_bytes()),
|
2741 3013 | ))
|
2742 3014 | .unwrap();
|
2743 3015 | #[allow(unused_mut)]
|
2744 3016 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2745 3017 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2746 3018 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2747 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3019 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2748 3020 | let sender = sender.clone();
|
2749 3021 | async move {
|
2750 - | 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> };
|
3022 + | 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> };
|
2751 3023 | sender.send(()).await.expect("receiver dropped early");
|
2752 3024 | result
|
2753 3025 | }
|
2754 3026 | })
|
2755 3027 | .build_unchecked();
|
2756 3028 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2757 3029 | .await
|
2758 3030 | .expect("unable to make an HTTP request");
|
2759 3031 | ::pretty_assertions::assert_eq!(
|
2760 3032 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2761 3033 | http_response.status()
|
2762 3034 | );
|
2763 3035 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2764 3036 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2765 3037 | http_response.headers(),
|
2766 3038 | expected_headers,
|
2767 3039 | ));
|
2768 3040 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2769 3041 | .await
|
2770 3042 | .expect("unable to extract body to bytes");
|
2771 3043 | ::aws_smithy_protocol_test::assert_ok(
|
2772 - | ::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"))
|
3044 + | ::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"))
|
2773 3045 | );
|
2774 3046 | }
|
2775 3047 | }
|
2776 - | /// When a map member's key does not match the specified pattern,
|
3048 + | /// When a float member does not fit within range bounds,
|
2777 3049 | /// the response should be a 400 ValidationException.
|
2778 - | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case1
|
3050 + | /// Test ID: RestJsonMalformedRangeFloat_case0
|
2779 3051 | #[::tokio::test]
|
2780 - | async fn rest_json_malformed_pattern_map_key_override_case1_malformed_request() {
|
3052 + | #[::tracing_test::traced_test]
|
3053 + | #[should_panic]
|
3054 + | async fn rest_json_malformed_range_float_case0_malformed_request() {
|
2781 3055 | {
|
2782 3056 | #[allow(unused_mut)]
|
2783 3057 | let mut http_request = http::Request::builder()
|
2784 - | .uri("/MalformedPatternOverride")
|
3058 + | .uri("/MalformedRange")
|
2785 3059 | .method("POST")
|
2786 3060 | .header("content-type", "application/json")
|
2787 3061 | .body(::aws_smithy_http_server::body::Body::from(
|
2788 - | ::bytes::Bytes::from_static("{ \"map\" : { \"xyz\" : \"ghi\" } }".as_bytes()),
|
3062 + | ::bytes::Bytes::from_static("{ \"float\" : 2.1 }".as_bytes()),
|
2789 3063 | ))
|
2790 3064 | .unwrap();
|
2791 3065 | #[allow(unused_mut)]
|
2792 3066 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2793 3067 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2794 3068 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2795 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3069 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2796 3070 | let sender = sender.clone();
|
2797 3071 | async move {
|
2798 - | 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> };
|
3072 + | 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> };
|
2799 3073 | sender.send(()).await.expect("receiver dropped early");
|
2800 3074 | result
|
2801 3075 | }
|
2802 3076 | })
|
2803 3077 | .build_unchecked();
|
2804 3078 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2805 3079 | .await
|
2806 3080 | .expect("unable to make an HTTP request");
|
2807 3081 | ::pretty_assertions::assert_eq!(
|
2808 3082 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2809 3083 | http_response.status()
|
2810 3084 | );
|
2811 3085 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2812 3086 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2813 3087 | http_response.headers(),
|
2814 3088 | expected_headers,
|
2815 3089 | ));
|
2816 3090 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2817 3091 | .await
|
2818 3092 | .expect("unable to extract body to bytes");
|
2819 3093 | ::aws_smithy_protocol_test::assert_ok(
|
2820 - | ::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"))
|
3094 + | ::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"))
|
2821 3095 | );
|
2822 3096 | }
|
2823 3097 | }
|
2824 - | /// When a map member's value does not match the specified pattern,
|
3098 + | /// When a float member does not fit within range bounds,
|
2825 3099 | /// the response should be a 400 ValidationException.
|
2826 - | /// Test ID: RestJsonMalformedPatternMapValueOverride_case0
|
3100 + | /// Test ID: RestJsonMalformedRangeFloat_case1
|
2827 3101 | #[::tokio::test]
|
2828 - | async fn rest_json_malformed_pattern_map_value_override_case0_malformed_request() {
|
3102 + | #[::tracing_test::traced_test]
|
3103 + | #[should_panic]
|
3104 + | async fn rest_json_malformed_range_float_case1_malformed_request() {
|
2829 3105 | {
|
2830 3106 | #[allow(unused_mut)]
|
2831 3107 | let mut http_request = http::Request::builder()
|
2832 - | .uri("/MalformedPatternOverride")
|
3108 + | .uri("/MalformedRange")
|
2833 3109 | .method("POST")
|
2834 3110 | .header("content-type", "application/json")
|
2835 3111 | .body(::aws_smithy_http_server::body::Body::from(
|
2836 - | ::bytes::Bytes::from_static("{ \"map\" : { \"ghi\": \"abc\" } }".as_bytes()),
|
3112 + | ::bytes::Bytes::from_static("{ \"float\" : 8.9 }".as_bytes()),
|
2837 3113 | ))
|
2838 3114 | .unwrap();
|
2839 3115 | #[allow(unused_mut)]
|
2840 3116 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2841 3117 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2842 3118 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2843 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3119 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2844 3120 | let sender = sender.clone();
|
2845 3121 | async move {
|
2846 - | 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> };
|
3122 + | 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> };
|
2847 3123 | sender.send(()).await.expect("receiver dropped early");
|
2848 3124 | result
|
2849 3125 | }
|
2850 3126 | })
|
2851 3127 | .build_unchecked();
|
2852 3128 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2853 3129 | .await
|
2854 3130 | .expect("unable to make an HTTP request");
|
2855 3131 | ::pretty_assertions::assert_eq!(
|
2856 3132 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2857 3133 | http_response.status()
|
2858 3134 | );
|
2859 3135 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2860 3136 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2861 3137 | http_response.headers(),
|
2862 3138 | expected_headers,
|
2863 3139 | ));
|
2864 3140 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2865 3141 | .await
|
2866 3142 | .expect("unable to extract body to bytes");
|
2867 3143 | ::aws_smithy_protocol_test::assert_ok(
|
2868 - | ::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"))
|
3144 + | ::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"))
|
2869 3145 | );
|
2870 3146 | }
|
2871 3147 | }
|
2872 - | /// When a map member's value does not match the specified pattern,
|
3148 + | /// When a float member does not fit within range bounds,
|
2873 3149 | /// the response should be a 400 ValidationException.
|
2874 - | /// Test ID: RestJsonMalformedPatternMapValueOverride_case1
|
3150 + | /// Test ID: RestJsonMalformedRangeMinFloat
|
2875 3151 | #[::tokio::test]
|
2876 - | async fn rest_json_malformed_pattern_map_value_override_case1_malformed_request() {
|
3152 + | #[::tracing_test::traced_test]
|
3153 + | #[should_panic]
|
3154 + | async fn rest_json_malformed_range_min_float_malformed_request() {
|
2877 3155 | {
|
2878 3156 | #[allow(unused_mut)]
|
2879 3157 | let mut http_request = http::Request::builder()
|
2880 - | .uri("/MalformedPatternOverride")
|
3158 + | .uri("/MalformedRange")
|
2881 3159 | .method("POST")
|
2882 3160 | .header("content-type", "application/json")
|
2883 3161 | .body(::aws_smithy_http_server::body::Body::from(
|
2884 - | ::bytes::Bytes::from_static("{ \"map\" : { \"ghi\": \"xyz\" } }".as_bytes()),
|
3162 + | ::bytes::Bytes::from_static("{ \"minFloat\" : 2.1 }".as_bytes()),
|
2885 3163 | ))
|
2886 3164 | .unwrap();
|
2887 3165 | #[allow(unused_mut)]
|
2888 3166 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2889 3167 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2890 3168 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2891 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3169 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2892 3170 | let sender = sender.clone();
|
2893 3171 | async move {
|
2894 - | 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> };
|
3172 + | 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> };
|
2895 3173 | sender.send(()).await.expect("receiver dropped early");
|
2896 3174 | result
|
2897 3175 | }
|
2898 3176 | })
|
2899 3177 | .build_unchecked();
|
2900 3178 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2901 3179 | .await
|
2902 3180 | .expect("unable to make an HTTP request");
|
2903 3181 | ::pretty_assertions::assert_eq!(
|
2904 3182 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2905 3183 | http_response.status()
|
2906 3184 | );
|
2907 3185 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2908 3186 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2909 3187 | http_response.headers(),
|
2910 3188 | expected_headers,
|
2911 3189 | ));
|
2912 3190 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2913 3191 | .await
|
2914 3192 | .expect("unable to extract body to bytes");
|
2915 3193 | ::aws_smithy_protocol_test::assert_ok(
|
2916 - | ::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"))
|
3194 + | ::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"))
|
2917 3195 | );
|
2918 3196 | }
|
2919 3197 | }
|
2920 - | /// When a union member's value does not match the specified pattern,
|
3198 + | /// When a float member does not fit within range bounds,
|
2921 3199 | /// the response should be a 400 ValidationException.
|
2922 - | /// Test ID: RestJsonMalformedPatternUnionOverride_case0
|
3200 + | /// Test ID: RestJsonMalformedRangeMaxFloat
|
2923 3201 | #[::tokio::test]
|
2924 - | async fn rest_json_malformed_pattern_union_override_case0_malformed_request() {
|
3202 + | #[::tracing_test::traced_test]
|
3203 + | #[should_panic]
|
3204 + | async fn rest_json_malformed_range_max_float_malformed_request() {
|
2925 3205 | {
|
2926 3206 | #[allow(unused_mut)]
|
2927 3207 | let mut http_request = http::Request::builder()
|
2928 - | .uri("/MalformedPatternOverride")
|
3208 + | .uri("/MalformedRange")
|
2929 3209 | .method("POST")
|
2930 3210 | .header("content-type", "application/json")
|
2931 3211 | .body(::aws_smithy_http_server::body::Body::from(
|
2932 - | ::bytes::Bytes::from_static(
|
2933 - | "{ \"union\" : { \"first\": \"abc\" } }".as_bytes(),
|
2934 - | ),
|
3212 + | ::bytes::Bytes::from_static("{ \"maxFloat\" : 8.9 }".as_bytes()),
|
2935 3213 | ))
|
2936 3214 | .unwrap();
|
2937 3215 | #[allow(unused_mut)]
|
2938 3216 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2939 3217 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2940 3218 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2941 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3219 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2942 3220 | let sender = sender.clone();
|
2943 3221 | async move {
|
2944 - | 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> };
|
3222 + | 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> };
|
2945 3223 | sender.send(()).await.expect("receiver dropped early");
|
2946 3224 | result
|
2947 3225 | }
|
2948 3226 | })
|
2949 3227 | .build_unchecked();
|
2950 3228 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2951 3229 | .await
|
2952 3230 | .expect("unable to make an HTTP request");
|
2953 3231 | ::pretty_assertions::assert_eq!(
|
2954 3232 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2955 3233 | http_response.status()
|
2956 3234 | );
|
2957 3235 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2958 3236 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2959 3237 | http_response.headers(),
|
2960 3238 | expected_headers,
|
2961 3239 | ));
|
2962 3240 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
2963 3241 | .await
|
2964 3242 | .expect("unable to extract body to bytes");
|
2965 3243 | ::aws_smithy_protocol_test::assert_ok(
|
2966 - | ::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"))
|
3244 + | ::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"))
|
2967 3245 | );
|
2968 3246 | }
|
2969 3247 | }
|
2970 - | /// When a union member's value does not match the specified pattern,
|
3248 + | /// When a short member does not fit within range bounds,
|
2971 3249 | /// the response should be a 400 ValidationException.
|
2972 - | /// Test ID: RestJsonMalformedPatternUnionOverride_case1
|
3250 + | /// Test ID: RestJsonMalformedRangeShort_case0
|
2973 3251 | #[::tokio::test]
|
2974 - | async fn rest_json_malformed_pattern_union_override_case1_malformed_request() {
|
3252 + | #[::tracing_test::traced_test]
|
3253 + | async fn rest_json_malformed_range_short_case0_malformed_request() {
|
2975 3254 | {
|
2976 3255 | #[allow(unused_mut)]
|
2977 3256 | let mut http_request = http::Request::builder()
|
2978 - | .uri("/MalformedPatternOverride")
|
3257 + | .uri("/MalformedRange")
|
2979 3258 | .method("POST")
|
2980 3259 | .header("content-type", "application/json")
|
2981 3260 | .body(::aws_smithy_http_server::body::Body::from(
|
2982 - | ::bytes::Bytes::from_static(
|
2983 - | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
2984 - | ),
|
3261 + | ::bytes::Bytes::from_static("{ \"short\" : 1 }".as_bytes()),
|
2985 3262 | ))
|
2986 3263 | .unwrap();
|
2987 3264 | #[allow(unused_mut)]
|
2988 3265 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2989 3266 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2990 3267 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
2991 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3268 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2992 3269 | let sender = sender.clone();
|
2993 3270 | async move {
|
2994 - | 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> };
|
3271 + | 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> };
|
2995 3272 | sender.send(()).await.expect("receiver dropped early");
|
2996 3273 | result
|
2997 3274 | }
|
2998 3275 | })
|
2999 3276 | .build_unchecked();
|
3000 3277 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3001 3278 | .await
|
3002 3279 | .expect("unable to make an HTTP request");
|
3003 3280 | ::pretty_assertions::assert_eq!(
|
3004 3281 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3005 3282 | http_response.status()
|
3006 3283 | );
|
3007 3284 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3008 3285 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3009 3286 | http_response.headers(),
|
3010 3287 | expected_headers,
|
3011 3288 | ));
|
3012 3289 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3013 3290 | .await
|
3014 3291 | .expect("unable to extract body to bytes");
|
3015 3292 | ::aws_smithy_protocol_test::assert_ok(
|
3016 - | ::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"))
|
3293 + | ::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"))
|
3017 3294 | );
|
3018 3295 | }
|
3019 3296 | }
|
3020 - | }
|
3021 - | #[cfg(test)]
|
3022 - | #[allow(unreachable_code, unused_variables)]
|
3023 - | mod server_malformed_range_test {
|
3024 - | /// When a byte member does not fit within range bounds,
|
3297 + | /// When a short member does not fit within range bounds,
|
3025 3298 | /// the response should be a 400 ValidationException.
|
3026 - | /// Test ID: RestJsonMalformedRangeByte_case0
|
3299 + | /// Test ID: RestJsonMalformedRangeShort_case1
|
3027 3300 | #[::tokio::test]
|
3028 - | async fn rest_json_malformed_range_byte_case0_malformed_request() {
|
3301 + | #[::tracing_test::traced_test]
|
3302 + | async fn rest_json_malformed_range_short_case1_malformed_request() {
|
3029 3303 | {
|
3030 3304 | #[allow(unused_mut)]
|
3031 3305 | let mut http_request = http::Request::builder()
|
3032 3306 | .uri("/MalformedRange")
|
3033 3307 | .method("POST")
|
3034 3308 | .header("content-type", "application/json")
|
3035 3309 | .body(::aws_smithy_http_server::body::Body::from(
|
3036 - | ::bytes::Bytes::from_static("{ \"byte\" : 1 }".as_bytes()),
|
3310 + | ::bytes::Bytes::from_static("{ \"short\" : 9 }".as_bytes()),
|
3037 3311 | ))
|
3038 3312 | .unwrap();
|
3039 3313 | #[allow(unused_mut)]
|
3040 3314 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3041 3315 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3042 3316 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3043 3317 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3044 3318 | let sender = sender.clone();
|
3045 3319 | async move {
|
3046 3320 | 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> };
|
3047 3321 | sender.send(()).await.expect("receiver dropped early");
|
3048 3322 | result
|
3049 3323 | }
|
3050 3324 | })
|
3051 3325 | .build_unchecked();
|
3052 3326 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3053 3327 | .await
|
3054 3328 | .expect("unable to make an HTTP request");
|
3055 3329 | ::pretty_assertions::assert_eq!(
|
3056 3330 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3057 3331 | http_response.status()
|
3058 3332 | );
|
3059 3333 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3060 3334 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3061 3335 | http_response.headers(),
|
3062 3336 | expected_headers,
|
3063 3337 | ));
|
3064 3338 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3065 3339 | .await
|
3066 3340 | .expect("unable to extract body to bytes");
|
3067 3341 | ::aws_smithy_protocol_test::assert_ok(
|
3068 - | ::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"))
|
3342 + | ::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"))
|
3069 3343 | );
|
3070 3344 | }
|
3071 3345 | }
|
3072 - | /// When a byte member does not fit within range bounds,
|
3346 + | /// When a short member does not fit within range bounds,
|
3073 3347 | /// the response should be a 400 ValidationException.
|
3074 - | /// Test ID: RestJsonMalformedRangeByte_case1
|
3348 + | /// Test ID: RestJsonMalformedRangeMinShort
|
3075 3349 | #[::tokio::test]
|
3076 - | async fn rest_json_malformed_range_byte_case1_malformed_request() {
|
3350 + | #[::tracing_test::traced_test]
|
3351 + | async fn rest_json_malformed_range_min_short_malformed_request() {
|
3077 3352 | {
|
3078 3353 | #[allow(unused_mut)]
|
3079 3354 | let mut http_request = http::Request::builder()
|
3080 3355 | .uri("/MalformedRange")
|
3081 3356 | .method("POST")
|
3082 3357 | .header("content-type", "application/json")
|
3083 3358 | .body(::aws_smithy_http_server::body::Body::from(
|
3084 - | ::bytes::Bytes::from_static("{ \"byte\" : 9 }".as_bytes()),
|
3359 + | ::bytes::Bytes::from_static("{ \"minShort\" : 1 }".as_bytes()),
|
3085 3360 | ))
|
3086 3361 | .unwrap();
|
3087 3362 | #[allow(unused_mut)]
|
3088 3363 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3089 3364 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3090 3365 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3091 3366 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3092 3367 | let sender = sender.clone();
|
3093 3368 | async move {
|
3094 3369 | 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> };
|
3095 3370 | sender.send(()).await.expect("receiver dropped early");
|
3096 3371 | result
|
3097 3372 | }
|
3098 3373 | })
|
3099 3374 | .build_unchecked();
|
3100 3375 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3101 3376 | .await
|
3102 3377 | .expect("unable to make an HTTP request");
|
3103 3378 | ::pretty_assertions::assert_eq!(
|
3104 3379 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3105 3380 | http_response.status()
|
3106 3381 | );
|
3107 3382 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3108 3383 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3109 3384 | http_response.headers(),
|
3110 3385 | expected_headers,
|
3111 3386 | ));
|
3112 3387 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3113 3388 | .await
|
3114 3389 | .expect("unable to extract body to bytes");
|
3115 3390 | ::aws_smithy_protocol_test::assert_ok(
|
3116 - | ::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"))
|
3391 + | ::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"))
|
3117 3392 | );
|
3118 3393 | }
|
3119 3394 | }
|
3120 - | /// When a byte member does not fit within range bounds,
|
3395 + | /// When a short member does not fit within range bounds,
|
3121 3396 | /// the response should be a 400 ValidationException.
|
3122 - | /// Test ID: RestJsonMalformedRangeMinByte
|
3397 + | /// Test ID: RestJsonMalformedRangeMaxShort
|
3123 3398 | #[::tokio::test]
|
3124 - | async fn rest_json_malformed_range_min_byte_malformed_request() {
|
3399 + | #[::tracing_test::traced_test]
|
3400 + | async fn rest_json_malformed_range_max_short_malformed_request() {
|
3125 3401 | {
|
3126 3402 | #[allow(unused_mut)]
|
3127 3403 | let mut http_request = http::Request::builder()
|
3128 3404 | .uri("/MalformedRange")
|
3129 3405 | .method("POST")
|
3130 3406 | .header("content-type", "application/json")
|
3131 3407 | .body(::aws_smithy_http_server::body::Body::from(
|
3132 - | ::bytes::Bytes::from_static("{ \"minByte\" : 1 }".as_bytes()),
|
3408 + | ::bytes::Bytes::from_static("{ \"maxShort\" : 9 }".as_bytes()),
|
3133 3409 | ))
|
3134 3410 | .unwrap();
|
3135 3411 | #[allow(unused_mut)]
|
3136 3412 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3137 3413 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3138 3414 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3139 3415 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3140 3416 | let sender = sender.clone();
|
3141 3417 | async move {
|
3142 3418 | 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> };
|
3143 3419 | sender.send(()).await.expect("receiver dropped early");
|
3144 3420 | result
|
3145 3421 | }
|
3146 3422 | })
|
3147 3423 | .build_unchecked();
|
3148 3424 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3149 3425 | .await
|
3150 3426 | .expect("unable to make an HTTP request");
|
3151 3427 | ::pretty_assertions::assert_eq!(
|
3152 3428 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3153 3429 | http_response.status()
|
3154 3430 | );
|
3155 3431 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3156 3432 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3157 3433 | http_response.headers(),
|
3158 3434 | expected_headers,
|
3159 3435 | ));
|
3160 3436 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3161 3437 | .await
|
3162 3438 | .expect("unable to extract body to bytes");
|
3163 3439 | ::aws_smithy_protocol_test::assert_ok(
|
3164 - | ::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"))
|
3440 + | ::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"))
|
3165 3441 | );
|
3166 3442 | }
|
3167 3443 | }
|
3168 - | /// When a byte member does not fit within range bounds,
|
3444 + | /// When a integer member does not fit within range bounds,
|
3169 3445 | /// the response should be a 400 ValidationException.
|
3170 - | /// Test ID: RestJsonMalformedRangeMaxByte
|
3446 + | /// Test ID: RestJsonMalformedRangeInteger_case0
|
3171 3447 | #[::tokio::test]
|
3172 - | async fn rest_json_malformed_range_max_byte_malformed_request() {
|
3448 + | #[::tracing_test::traced_test]
|
3449 + | async fn rest_json_malformed_range_integer_case0_malformed_request() {
|
3173 3450 | {
|
3174 3451 | #[allow(unused_mut)]
|
3175 3452 | let mut http_request = http::Request::builder()
|
3176 3453 | .uri("/MalformedRange")
|
3177 3454 | .method("POST")
|
3178 3455 | .header("content-type", "application/json")
|
3179 3456 | .body(::aws_smithy_http_server::body::Body::from(
|
3180 - | ::bytes::Bytes::from_static("{ \"maxByte\" : 9 }".as_bytes()),
|
3457 + | ::bytes::Bytes::from_static("{ \"integer\" : 1 }".as_bytes()),
|
3181 3458 | ))
|
3182 3459 | .unwrap();
|
3183 3460 | #[allow(unused_mut)]
|
3184 3461 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3185 3462 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3186 3463 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3187 3464 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3188 3465 | let sender = sender.clone();
|
3189 3466 | async move {
|
3190 3467 | 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> };
|
3191 3468 | sender.send(()).await.expect("receiver dropped early");
|
3192 3469 | result
|
3193 3470 | }
|
3194 3471 | })
|
3195 3472 | .build_unchecked();
|
3196 3473 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3197 3474 | .await
|
3198 3475 | .expect("unable to make an HTTP request");
|
3199 3476 | ::pretty_assertions::assert_eq!(
|
3200 3477 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3201 3478 | http_response.status()
|
3202 3479 | );
|
3203 3480 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3204 3481 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3205 3482 | http_response.headers(),
|
3206 3483 | expected_headers,
|
3207 3484 | ));
|
3208 3485 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3209 3486 | .await
|
3210 3487 | .expect("unable to extract body to bytes");
|
3211 3488 | ::aws_smithy_protocol_test::assert_ok(
|
3212 - | ::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"))
|
3489 + | ::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"))
|
3213 3490 | );
|
3214 3491 | }
|
3215 3492 | }
|
3216 - | /// When a float member does not fit within range bounds,
|
3493 + | /// When a integer member does not fit within range bounds,
|
3217 3494 | /// the response should be a 400 ValidationException.
|
3218 - | /// Test ID: RestJsonMalformedRangeFloat_case0
|
3495 + | /// Test ID: RestJsonMalformedRangeInteger_case1
|
3219 3496 | #[::tokio::test]
|
3220 - | #[should_panic]
|
3221 - | async fn rest_json_malformed_range_float_case0_malformed_request() {
|
3497 + | #[::tracing_test::traced_test]
|
3498 + | async fn rest_json_malformed_range_integer_case1_malformed_request() {
|
3222 3499 | {
|
3223 3500 | #[allow(unused_mut)]
|
3224 3501 | let mut http_request = http::Request::builder()
|
3225 3502 | .uri("/MalformedRange")
|
3226 3503 | .method("POST")
|
3227 3504 | .header("content-type", "application/json")
|
3228 3505 | .body(::aws_smithy_http_server::body::Body::from(
|
3229 - | ::bytes::Bytes::from_static("{ \"float\" : 2.1 }".as_bytes()),
|
3506 + | ::bytes::Bytes::from_static("{ \"integer\" : 9 }".as_bytes()),
|
3230 3507 | ))
|
3231 3508 | .unwrap();
|
3232 3509 | #[allow(unused_mut)]
|
3233 3510 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3234 3511 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3235 3512 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3236 3513 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3237 3514 | let sender = sender.clone();
|
3238 3515 | async move {
|
3239 3516 | 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> };
|
3240 3517 | sender.send(()).await.expect("receiver dropped early");
|
3241 3518 | result
|
3242 3519 | }
|
3243 3520 | })
|
3244 3521 | .build_unchecked();
|
3245 3522 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3246 3523 | .await
|
3247 3524 | .expect("unable to make an HTTP request");
|
3248 3525 | ::pretty_assertions::assert_eq!(
|
3249 3526 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3250 3527 | http_response.status()
|
3251 3528 | );
|
3252 3529 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3253 3530 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3254 3531 | http_response.headers(),
|
3255 3532 | expected_headers,
|
3256 3533 | ));
|
3257 3534 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3258 3535 | .await
|
3259 3536 | .expect("unable to extract body to bytes");
|
3260 3537 | ::aws_smithy_protocol_test::assert_ok(
|
3261 - | ::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"))
|
3538 + | ::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"))
|
3262 3539 | );
|
3263 3540 | }
|
3264 3541 | }
|
3265 - | /// When a float member does not fit within range bounds,
|
3542 + | /// When a integer member does not fit within range bounds,
|
3266 3543 | /// the response should be a 400 ValidationException.
|
3267 - | /// Test ID: RestJsonMalformedRangeFloat_case1
|
3544 + | /// Test ID: RestJsonMalformedRangeMinInteger
|
3268 3545 | #[::tokio::test]
|
3269 - | #[should_panic]
|
3270 - | async fn rest_json_malformed_range_float_case1_malformed_request() {
|
3546 + | #[::tracing_test::traced_test]
|
3547 + | async fn rest_json_malformed_range_min_integer_malformed_request() {
|
3271 3548 | {
|
3272 3549 | #[allow(unused_mut)]
|
3273 3550 | let mut http_request = http::Request::builder()
|
3274 3551 | .uri("/MalformedRange")
|
3275 3552 | .method("POST")
|
3276 3553 | .header("content-type", "application/json")
|
3277 3554 | .body(::aws_smithy_http_server::body::Body::from(
|
3278 - | ::bytes::Bytes::from_static("{ \"float\" : 8.9 }".as_bytes()),
|
3555 + | ::bytes::Bytes::from_static("{ \"minInteger\" : 1 }".as_bytes()),
|
3279 3556 | ))
|
3280 3557 | .unwrap();
|
3281 3558 | #[allow(unused_mut)]
|
3282 3559 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3283 3560 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3284 3561 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3285 3562 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3286 3563 | let sender = sender.clone();
|
3287 3564 | async move {
|
3288 3565 | 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> };
|
3289 3566 | sender.send(()).await.expect("receiver dropped early");
|
3290 3567 | result
|
3291 3568 | }
|
3292 3569 | })
|
3293 3570 | .build_unchecked();
|
3294 3571 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3295 3572 | .await
|
3296 3573 | .expect("unable to make an HTTP request");
|
3297 3574 | ::pretty_assertions::assert_eq!(
|
3298 3575 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3299 3576 | http_response.status()
|
3300 3577 | );
|
3301 3578 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3302 3579 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3303 3580 | http_response.headers(),
|
3304 3581 | expected_headers,
|
3305 3582 | ));
|
3306 3583 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3307 3584 | .await
|
3308 3585 | .expect("unable to extract body to bytes");
|
3309 3586 | ::aws_smithy_protocol_test::assert_ok(
|
3310 - | ::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"))
|
3587 + | ::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"))
|
3311 3588 | );
|
3312 3589 | }
|
3313 3590 | }
|
3314 - | /// When a float member does not fit within range bounds,
|
3591 + | /// When a integer member does not fit within range bounds,
|
3315 3592 | /// the response should be a 400 ValidationException.
|
3316 - | /// Test ID: RestJsonMalformedRangeMinFloat
|
3593 + | /// Test ID: RestJsonMalformedRangeMaxInteger
|
3317 3594 | #[::tokio::test]
|
3318 - | #[should_panic]
|
3319 - | async fn rest_json_malformed_range_min_float_malformed_request() {
|
3595 + | #[::tracing_test::traced_test]
|
3596 + | async fn rest_json_malformed_range_max_integer_malformed_request() {
|
3320 3597 | {
|
3321 3598 | #[allow(unused_mut)]
|
3322 3599 | let mut http_request = http::Request::builder()
|
3323 3600 | .uri("/MalformedRange")
|
3324 3601 | .method("POST")
|
3325 3602 | .header("content-type", "application/json")
|
3326 3603 | .body(::aws_smithy_http_server::body::Body::from(
|
3327 - | ::bytes::Bytes::from_static("{ \"minFloat\" : 2.1 }".as_bytes()),
|
3604 + | ::bytes::Bytes::from_static("{ \"maxInteger\" : 9 }".as_bytes()),
|
3328 3605 | ))
|
3329 3606 | .unwrap();
|
3330 3607 | #[allow(unused_mut)]
|
3331 3608 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3332 3609 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3333 3610 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3334 3611 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3335 3612 | let sender = sender.clone();
|
3336 3613 | async move {
|
3337 3614 | 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> };
|
3338 3615 | sender.send(()).await.expect("receiver dropped early");
|
3339 3616 | result
|
3340 3617 | }
|
3341 3618 | })
|
3342 3619 | .build_unchecked();
|
3343 3620 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3344 3621 | .await
|
3345 3622 | .expect("unable to make an HTTP request");
|
3346 3623 | ::pretty_assertions::assert_eq!(
|
3347 3624 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3348 3625 | http_response.status()
|
3349 3626 | );
|
3350 3627 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3351 3628 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3352 3629 | http_response.headers(),
|
3353 3630 | expected_headers,
|
3354 3631 | ));
|
3355 3632 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3356 3633 | .await
|
3357 3634 | .expect("unable to extract body to bytes");
|
3358 3635 | ::aws_smithy_protocol_test::assert_ok(
|
3359 - | ::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"))
|
3636 + | ::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"))
|
3360 3637 | );
|
3361 3638 | }
|
3362 3639 | }
|
3363 - | /// When a float member does not fit within range bounds,
|
3640 + | /// When a long member does not fit within range bounds,
|
3364 3641 | /// the response should be a 400 ValidationException.
|
3365 - | /// Test ID: RestJsonMalformedRangeMaxFloat
|
3642 + | /// Test ID: RestJsonMalformedRangeLong_case0
|
3366 3643 | #[::tokio::test]
|
3367 - | #[should_panic]
|
3368 - | async fn rest_json_malformed_range_max_float_malformed_request() {
|
3644 + | #[::tracing_test::traced_test]
|
3645 + | async fn rest_json_malformed_range_long_case0_malformed_request() {
|
3369 3646 | {
|
3370 3647 | #[allow(unused_mut)]
|
3371 3648 | let mut http_request = http::Request::builder()
|
3372 3649 | .uri("/MalformedRange")
|
3373 3650 | .method("POST")
|
3374 3651 | .header("content-type", "application/json")
|
3375 3652 | .body(::aws_smithy_http_server::body::Body::from(
|
3376 - | ::bytes::Bytes::from_static("{ \"maxFloat\" : 8.9 }".as_bytes()),
|
3653 + | ::bytes::Bytes::from_static("{ \"long\" : 1 }".as_bytes()),
|
3377 3654 | ))
|
3378 3655 | .unwrap();
|
3379 3656 | #[allow(unused_mut)]
|
3380 3657 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3381 3658 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3382 3659 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3383 3660 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3384 3661 | let sender = sender.clone();
|
3385 3662 | async move {
|
3386 3663 | 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> };
|
3387 3664 | sender.send(()).await.expect("receiver dropped early");
|
3388 3665 | result
|
3389 3666 | }
|
3390 3667 | })
|
3391 3668 | .build_unchecked();
|
3392 3669 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3393 3670 | .await
|
3394 3671 | .expect("unable to make an HTTP request");
|
3395 3672 | ::pretty_assertions::assert_eq!(
|
3396 3673 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3397 3674 | http_response.status()
|
3398 3675 | );
|
3399 3676 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3400 3677 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3401 3678 | http_response.headers(),
|
3402 3679 | expected_headers,
|
3403 3680 | ));
|
3404 3681 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3405 3682 | .await
|
3406 3683 | .expect("unable to extract body to bytes");
|
3407 3684 | ::aws_smithy_protocol_test::assert_ok(
|
3408 - | ::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"))
|
3685 + | ::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"))
|
3409 3686 | );
|
3410 3687 | }
|
3411 3688 | }
|
3412 - | /// When a short member does not fit within range bounds,
|
3689 + | /// When a long member does not fit within range bounds,
|
3413 3690 | /// the response should be a 400 ValidationException.
|
3414 - | /// Test ID: RestJsonMalformedRangeShort_case0
|
3691 + | /// Test ID: RestJsonMalformedRangeLong_case1
|
3415 3692 | #[::tokio::test]
|
3416 - | async fn rest_json_malformed_range_short_case0_malformed_request() {
|
3693 + | #[::tracing_test::traced_test]
|
3694 + | async fn rest_json_malformed_range_long_case1_malformed_request() {
|
3417 3695 | {
|
3418 3696 | #[allow(unused_mut)]
|
3419 3697 | let mut http_request = http::Request::builder()
|
3420 3698 | .uri("/MalformedRange")
|
3421 3699 | .method("POST")
|
3422 3700 | .header("content-type", "application/json")
|
3423 3701 | .body(::aws_smithy_http_server::body::Body::from(
|
3424 - | ::bytes::Bytes::from_static("{ \"short\" : 1 }".as_bytes()),
|
3702 + | ::bytes::Bytes::from_static("{ \"long\" : 9 }".as_bytes()),
|
3425 3703 | ))
|
3426 3704 | .unwrap();
|
3427 3705 | #[allow(unused_mut)]
|
3428 3706 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3429 3707 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3430 3708 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3431 3709 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3432 3710 | let sender = sender.clone();
|
3433 3711 | async move {
|
3434 3712 | 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> };
|
3435 3713 | sender.send(()).await.expect("receiver dropped early");
|
3436 3714 | result
|
3437 3715 | }
|
3438 3716 | })
|
3439 3717 | .build_unchecked();
|
3440 3718 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3441 3719 | .await
|
3442 3720 | .expect("unable to make an HTTP request");
|
3443 3721 | ::pretty_assertions::assert_eq!(
|
3444 3722 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3445 3723 | http_response.status()
|
3446 3724 | );
|
3447 3725 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3448 3726 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3449 3727 | http_response.headers(),
|
3450 3728 | expected_headers,
|
3451 3729 | ));
|
3452 3730 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3453 3731 | .await
|
3454 3732 | .expect("unable to extract body to bytes");
|
3455 3733 | ::aws_smithy_protocol_test::assert_ok(
|
3456 - | ::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"))
|
3734 + | ::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"))
|
3457 3735 | );
|
3458 3736 | }
|
3459 3737 | }
|
3460 - | /// When a short member does not fit within range bounds,
|
3738 + | /// When a long member does not fit within range bounds,
|
3461 3739 | /// the response should be a 400 ValidationException.
|
3462 - | /// Test ID: RestJsonMalformedRangeShort_case1
|
3740 + | /// Test ID: RestJsonMalformedRangeMinLong
|
3463 3741 | #[::tokio::test]
|
3464 - | async fn rest_json_malformed_range_short_case1_malformed_request() {
|
3742 + | #[::tracing_test::traced_test]
|
3743 + | async fn rest_json_malformed_range_min_long_malformed_request() {
|
3465 3744 | {
|
3466 3745 | #[allow(unused_mut)]
|
3467 3746 | let mut http_request = http::Request::builder()
|
3468 3747 | .uri("/MalformedRange")
|
3469 3748 | .method("POST")
|
3470 3749 | .header("content-type", "application/json")
|
3471 3750 | .body(::aws_smithy_http_server::body::Body::from(
|
3472 - | ::bytes::Bytes::from_static("{ \"short\" : 9 }".as_bytes()),
|
3751 + | ::bytes::Bytes::from_static("{ \"minLong\" : 1 }".as_bytes()),
|
3473 3752 | ))
|
3474 3753 | .unwrap();
|
3475 3754 | #[allow(unused_mut)]
|
3476 3755 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3477 3756 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3478 3757 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3479 3758 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3480 3759 | let sender = sender.clone();
|
3481 3760 | async move {
|
3482 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> };
|
3483 3762 | sender.send(()).await.expect("receiver dropped early");
|
3484 3763 | result
|
3485 3764 | }
|
3486 3765 | })
|
3487 3766 | .build_unchecked();
|
3488 3767 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3489 3768 | .await
|
3490 3769 | .expect("unable to make an HTTP request");
|
3491 3770 | ::pretty_assertions::assert_eq!(
|
3492 3771 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3493 3772 | http_response.status()
|
3494 3773 | );
|
3495 3774 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3496 3775 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3497 3776 | http_response.headers(),
|
3498 3777 | expected_headers,
|
3499 3778 | ));
|
3500 3779 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3501 3780 | .await
|
3502 3781 | .expect("unable to extract body to bytes");
|
3503 3782 | ::aws_smithy_protocol_test::assert_ok(
|
3504 - | ::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"))
|
3783 + | ::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"))
|
3505 3784 | );
|
3506 3785 | }
|
3507 3786 | }
|
3508 - | /// When a short member does not fit within range bounds,
|
3787 + | /// When a long member does not fit within range bounds,
|
3509 3788 | /// the response should be a 400 ValidationException.
|
3510 - | /// Test ID: RestJsonMalformedRangeMinShort
|
3789 + | /// Test ID: RestJsonMalformedRangeMaxLong
|
3511 3790 | #[::tokio::test]
|
3512 - | async fn rest_json_malformed_range_min_short_malformed_request() {
|
3791 + | #[::tracing_test::traced_test]
|
3792 + | async fn rest_json_malformed_range_max_long_malformed_request() {
|
3513 3793 | {
|
3514 3794 | #[allow(unused_mut)]
|
3515 3795 | let mut http_request = http::Request::builder()
|
3516 3796 | .uri("/MalformedRange")
|
3517 3797 | .method("POST")
|
3518 3798 | .header("content-type", "application/json")
|
3519 3799 | .body(::aws_smithy_http_server::body::Body::from(
|
3520 - | ::bytes::Bytes::from_static("{ \"minShort\" : 1 }".as_bytes()),
|
3800 + | ::bytes::Bytes::from_static("{ \"maxLong\" : 9 }".as_bytes()),
|
3521 3801 | ))
|
3522 3802 | .unwrap();
|
3523 3803 | #[allow(unused_mut)]
|
3524 3804 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3525 3805 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3526 3806 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3527 3807 | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3528 3808 | let sender = sender.clone();
|
3529 3809 | async move {
|
3530 3810 | 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> };
|
3531 3811 | sender.send(()).await.expect("receiver dropped early");
|
3532 3812 | result
|
3533 3813 | }
|
3534 3814 | })
|
3535 3815 | .build_unchecked();
|
3536 3816 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3537 3817 | .await
|
3538 3818 | .expect("unable to make an HTTP request");
|
3539 3819 | ::pretty_assertions::assert_eq!(
|
3540 3820 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3541 3821 | http_response.status()
|
3542 3822 | );
|
3543 3823 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3544 3824 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3545 3825 | http_response.headers(),
|
3546 3826 | expected_headers,
|
3547 3827 | ));
|
3548 3828 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3549 3829 | .await
|
3550 3830 | .expect("unable to extract body to bytes");
|
3551 3831 | ::aws_smithy_protocol_test::assert_ok(
|
3552 - | ::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"))
|
3832 + | ::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"))
|
3553 3833 | );
|
3554 3834 | }
|
3555 3835 | }
|
3556 - | /// When a short member does not fit within range bounds,
|
3836 + | }
|
3837 + |
|
3838 + | const CONTENT_TYPE_MALFORMEDPATTERNOVERRIDE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
3839 + | ::pin_project_lite::pin_project! {
|
3840 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3841 + | /// [`MalformedPatternOverrideInput`](crate::input::MalformedPatternOverrideInput) using modelled bindings.
|
3842 + | pub struct MalformedPatternOverrideInputFuture {
|
3843 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedPatternOverrideInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
3844 + | }
|
3845 + | }
|
3846 + |
|
3847 + | impl std::future::Future for MalformedPatternOverrideInputFuture {
|
3848 + | type Output = Result<
|
3849 + | crate::input::MalformedPatternOverrideInput,
|
3850 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
3851 + | >;
|
3852 + |
|
3853 + | fn poll(
|
3854 + | self: std::pin::Pin<&mut Self>,
|
3855 + | cx: &mut std::task::Context<'_>,
|
3856 + | ) -> std::task::Poll<Self::Output> {
|
3857 + | let this = self.project();
|
3858 + | this.inner.as_mut().poll(cx)
|
3859 + | }
|
3860 + | }
|
3861 + |
|
3862 + | impl<B>
|
3863 + | ::aws_smithy_http_server::request::FromRequest<
|
3864 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3865 + | B,
|
3866 + | > for crate::input::MalformedPatternOverrideInput
|
3867 + | where
|
3868 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
3869 + | B: 'static,
|
3870 + |
|
3871 + | B::Data: Send,
|
3872 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
3873 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
3874 + | {
|
3875 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
3876 + | type Future = MalformedPatternOverrideInputFuture;
|
3877 + |
|
3878 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
3879 + | let fut = async move {
|
3880 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
3881 + | request.headers(),
|
3882 + | &CONTENT_TYPE_MALFORMEDPATTERNOVERRIDE,
|
3883 + | ) {
|
3884 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
3885 + | }
|
3886 + | crate::protocol_serde::shape_malformed_pattern_override::de_malformed_pattern_override_http_request(request)
|
3887 + | .await
|
3888 + | .map_err(Into::into)
|
3889 + | };
|
3890 + | use ::futures_util::future::TryFutureExt;
|
3891 + | let fut = fut.map_err(
|
3892 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
3893 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3894 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
3895 + | e,
|
3896 + | )
|
3897 + | },
|
3898 + | );
|
3899 + | MalformedPatternOverrideInputFuture {
|
3900 + | inner: Box::pin(fut),
|
3901 + | }
|
3902 + | }
|
3903 + | }
|
3904 + | impl
|
3905 + | ::aws_smithy_http_server::response::IntoResponse<
|
3906 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3907 + | > for crate::output::MalformedPatternOverrideOutput
|
3908 + | {
|
3909 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3910 + | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_response(self) {
|
3911 + | Ok(response) => response,
|
3912 + | Err(e) => {
|
3913 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3914 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
3915 + | }
|
3916 + | }
|
3917 + | }
|
3918 + | }
|
3919 + | impl
|
3920 + | ::aws_smithy_http_server::response::IntoResponse<
|
3921 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3922 + | > for crate::error::MalformedPatternOverrideError
|
3923 + | {
|
3924 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3925 + | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_error(&self) {
|
3926 + | Ok(mut response) => {
|
3927 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
3928 + | response
|
3929 + | },
|
3930 + | Err(e) => {
|
3931 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3932 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
3933 + | }
|
3934 + | }
|
3935 + | }
|
3936 + | }
|
3937 + |
|
3938 + | #[allow(unreachable_code, unused_variables)]
|
3939 + | #[cfg(test)]
|
3940 + | mod malformed_pattern_override_test {
|
3941 + |
|
3942 + | /// When a string member does not match the specified pattern,
|
3557 3943 | /// the response should be a 400 ValidationException.
|
3558 - | /// Test ID: RestJsonMalformedRangeMaxShort
|
3944 + | /// Test ID: RestJsonMalformedPatternStringOverride_case0
|
3559 3945 | #[::tokio::test]
|
3560 - | async fn rest_json_malformed_range_max_short_malformed_request() {
|
3946 + | #[::tracing_test::traced_test]
|
3947 + | async fn rest_json_malformed_pattern_string_override_case0_malformed_request() {
|
3561 3948 | {
|
3562 3949 | #[allow(unused_mut)]
|
3563 3950 | let mut http_request = http::Request::builder()
|
3564 - | .uri("/MalformedRange")
|
3951 + | .uri("/MalformedPatternOverride")
|
3565 3952 | .method("POST")
|
3566 3953 | .header("content-type", "application/json")
|
3567 3954 | .body(::aws_smithy_http_server::body::Body::from(
|
3568 - | ::bytes::Bytes::from_static("{ \"maxShort\" : 9 }".as_bytes()),
|
3955 + | ::bytes::Bytes::from_static("{ \"string\" : \"abc\" }".as_bytes()),
|
3569 3956 | ))
|
3570 3957 | .unwrap();
|
3571 3958 | #[allow(unused_mut)]
|
3572 3959 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3573 3960 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3574 3961 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3575 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3962 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3576 3963 | let sender = sender.clone();
|
3577 3964 | async move {
|
3578 - | 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> };
|
3965 + | 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> };
|
3579 3966 | sender.send(()).await.expect("receiver dropped early");
|
3580 3967 | result
|
3581 3968 | }
|
3582 3969 | })
|
3583 3970 | .build_unchecked();
|
3584 3971 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3585 3972 | .await
|
3586 3973 | .expect("unable to make an HTTP request");
|
3587 3974 | ::pretty_assertions::assert_eq!(
|
3588 3975 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3589 3976 | http_response.status()
|
3590 3977 | );
|
3591 3978 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3592 3979 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3593 3980 | http_response.headers(),
|
3594 3981 | expected_headers,
|
3595 3982 | ));
|
3596 3983 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3597 3984 | .await
|
3598 3985 | .expect("unable to extract body to bytes");
|
3599 3986 | ::aws_smithy_protocol_test::assert_ok(
|
3600 - | ::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"))
|
3987 + | ::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"))
|
3601 3988 | );
|
3602 3989 | }
|
3603 3990 | }
|
3604 - | /// When a integer member does not fit within range bounds,
|
3991 + | /// When a string member does not match the specified pattern,
|
3605 3992 | /// the response should be a 400 ValidationException.
|
3606 - | /// Test ID: RestJsonMalformedRangeInteger_case0
|
3993 + | /// Test ID: RestJsonMalformedPatternStringOverride_case1
|
3607 3994 | #[::tokio::test]
|
3608 - | async fn rest_json_malformed_range_integer_case0_malformed_request() {
|
3995 + | #[::tracing_test::traced_test]
|
3996 + | async fn rest_json_malformed_pattern_string_override_case1_malformed_request() {
|
3609 3997 | {
|
3610 3998 | #[allow(unused_mut)]
|
3611 3999 | let mut http_request = http::Request::builder()
|
3612 - | .uri("/MalformedRange")
|
4000 + | .uri("/MalformedPatternOverride")
|
3613 4001 | .method("POST")
|
3614 4002 | .header("content-type", "application/json")
|
3615 4003 | .body(::aws_smithy_http_server::body::Body::from(
|
3616 - | ::bytes::Bytes::from_static("{ \"integer\" : 1 }".as_bytes()),
|
4004 + | ::bytes::Bytes::from_static("{ \"string\" : \"xyz\" }".as_bytes()),
|
3617 4005 | ))
|
3618 4006 | .unwrap();
|
3619 4007 | #[allow(unused_mut)]
|
3620 4008 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3621 4009 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3622 4010 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3623 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4011 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3624 4012 | let sender = sender.clone();
|
3625 4013 | async move {
|
3626 - | 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> };
|
4014 + | 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> };
|
3627 4015 | sender.send(()).await.expect("receiver dropped early");
|
3628 4016 | result
|
3629 4017 | }
|
3630 4018 | })
|
3631 4019 | .build_unchecked();
|
3632 4020 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3633 4021 | .await
|
3634 4022 | .expect("unable to make an HTTP request");
|
3635 4023 | ::pretty_assertions::assert_eq!(
|
3636 4024 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3637 4025 | http_response.status()
|
3638 4026 | );
|
3639 4027 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3640 4028 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3641 4029 | http_response.headers(),
|
3642 4030 | expected_headers,
|
3643 4031 | ));
|
3644 4032 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3645 4033 | .await
|
3646 4034 | .expect("unable to extract body to bytes");
|
3647 4035 | ::aws_smithy_protocol_test::assert_ok(
|
3648 - | ::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"))
|
4036 + | ::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"))
|
3649 4037 | );
|
3650 4038 | }
|
3651 4039 | }
|
3652 - | /// When a integer member does not fit within range bounds,
|
4040 + | /// When a list member value does not match the specified pattern,
|
3653 4041 | /// the response should be a 400 ValidationException.
|
3654 - | /// Test ID: RestJsonMalformedRangeInteger_case1
|
4042 + | /// Test ID: RestJsonMalformedPatternListOverride_case0
|
3655 4043 | #[::tokio::test]
|
3656 - | async fn rest_json_malformed_range_integer_case1_malformed_request() {
|
4044 + | #[::tracing_test::traced_test]
|
4045 + | async fn rest_json_malformed_pattern_list_override_case0_malformed_request() {
|
3657 4046 | {
|
3658 4047 | #[allow(unused_mut)]
|
3659 4048 | let mut http_request = http::Request::builder()
|
3660 - | .uri("/MalformedRange")
|
4049 + | .uri("/MalformedPatternOverride")
|
3661 4050 | .method("POST")
|
3662 4051 | .header("content-type", "application/json")
|
3663 4052 | .body(::aws_smithy_http_server::body::Body::from(
|
3664 - | ::bytes::Bytes::from_static("{ \"integer\" : 9 }".as_bytes()),
|
4053 + | ::bytes::Bytes::from_static("{ \"list\" : [\"abc\"] }".as_bytes()),
|
3665 4054 | ))
|
3666 4055 | .unwrap();
|
3667 4056 | #[allow(unused_mut)]
|
3668 4057 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3669 4058 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3670 4059 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3671 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4060 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3672 4061 | let sender = sender.clone();
|
3673 4062 | async move {
|
3674 - | 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> };
|
4063 + | 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> };
|
3675 4064 | sender.send(()).await.expect("receiver dropped early");
|
3676 4065 | result
|
3677 4066 | }
|
3678 4067 | })
|
3679 4068 | .build_unchecked();
|
3680 4069 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3681 4070 | .await
|
3682 4071 | .expect("unable to make an HTTP request");
|
3683 4072 | ::pretty_assertions::assert_eq!(
|
3684 4073 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3685 4074 | http_response.status()
|
3686 4075 | );
|
3687 4076 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3688 4077 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3689 4078 | http_response.headers(),
|
3690 4079 | expected_headers,
|
3691 4080 | ));
|
3692 4081 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3693 4082 | .await
|
3694 4083 | .expect("unable to extract body to bytes");
|
3695 4084 | ::aws_smithy_protocol_test::assert_ok(
|
3696 - | ::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"))
|
4085 + | ::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"))
|
3697 4086 | );
|
3698 4087 | }
|
3699 4088 | }
|
3700 - | /// When a integer member does not fit within range bounds,
|
4089 + | /// When a list member value does not match the specified pattern,
|
3701 4090 | /// the response should be a 400 ValidationException.
|
3702 - | /// Test ID: RestJsonMalformedRangeMinInteger
|
4091 + | /// Test ID: RestJsonMalformedPatternListOverride_case1
|
3703 4092 | #[::tokio::test]
|
3704 - | async fn rest_json_malformed_range_min_integer_malformed_request() {
|
4093 + | #[::tracing_test::traced_test]
|
4094 + | async fn rest_json_malformed_pattern_list_override_case1_malformed_request() {
|
3705 4095 | {
|
3706 4096 | #[allow(unused_mut)]
|
3707 4097 | let mut http_request = http::Request::builder()
|
3708 - | .uri("/MalformedRange")
|
4098 + | .uri("/MalformedPatternOverride")
|
3709 4099 | .method("POST")
|
3710 4100 | .header("content-type", "application/json")
|
3711 4101 | .body(::aws_smithy_http_server::body::Body::from(
|
3712 - | ::bytes::Bytes::from_static("{ \"minInteger\" : 1 }".as_bytes()),
|
4102 + | ::bytes::Bytes::from_static("{ \"list\" : [\"xyz\"] }".as_bytes()),
|
3713 4103 | ))
|
3714 4104 | .unwrap();
|
3715 4105 | #[allow(unused_mut)]
|
3716 4106 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3717 4107 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3718 4108 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3719 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4109 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3720 4110 | let sender = sender.clone();
|
3721 4111 | async move {
|
3722 - | 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> };
|
4112 + | 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> };
|
3723 4113 | sender.send(()).await.expect("receiver dropped early");
|
3724 4114 | result
|
3725 4115 | }
|
3726 4116 | })
|
3727 4117 | .build_unchecked();
|
3728 4118 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3729 4119 | .await
|
3730 4120 | .expect("unable to make an HTTP request");
|
3731 4121 | ::pretty_assertions::assert_eq!(
|
3732 4122 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3733 4123 | http_response.status()
|
3734 4124 | );
|
3735 4125 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3736 4126 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3737 4127 | http_response.headers(),
|
3738 4128 | expected_headers,
|
3739 4129 | ));
|
3740 4130 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3741 4131 | .await
|
3742 4132 | .expect("unable to extract body to bytes");
|
3743 4133 | ::aws_smithy_protocol_test::assert_ok(
|
3744 - | ::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"))
|
4134 + | ::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"))
|
3745 4135 | );
|
3746 4136 | }
|
3747 4137 | }
|
3748 - | /// When a integer member does not fit within range bounds,
|
4138 + | /// When a map member's key does not match the specified pattern,
|
3749 4139 | /// the response should be a 400 ValidationException.
|
3750 - | /// Test ID: RestJsonMalformedRangeMaxInteger
|
4140 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case0
|
3751 4141 | #[::tokio::test]
|
3752 - | async fn rest_json_malformed_range_max_integer_malformed_request() {
|
4142 + | #[::tracing_test::traced_test]
|
4143 + | async fn rest_json_malformed_pattern_map_key_override_case0_malformed_request() {
|
3753 4144 | {
|
3754 4145 | #[allow(unused_mut)]
|
3755 4146 | let mut http_request = http::Request::builder()
|
3756 - | .uri("/MalformedRange")
|
4147 + | .uri("/MalformedPatternOverride")
|
3757 4148 | .method("POST")
|
3758 4149 | .header("content-type", "application/json")
|
3759 4150 | .body(::aws_smithy_http_server::body::Body::from(
|
3760 - | ::bytes::Bytes::from_static("{ \"maxInteger\" : 9 }".as_bytes()),
|
4151 + | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\" : \"ghi\" } }".as_bytes()),
|
3761 4152 | ))
|
3762 4153 | .unwrap();
|
3763 4154 | #[allow(unused_mut)]
|
3764 4155 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3765 4156 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3766 4157 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3767 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4158 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3768 4159 | let sender = sender.clone();
|
3769 4160 | async move {
|
3770 - | 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> };
|
4161 + | 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> };
|
3771 4162 | sender.send(()).await.expect("receiver dropped early");
|
3772 4163 | result
|
3773 4164 | }
|
3774 4165 | })
|
3775 4166 | .build_unchecked();
|
3776 4167 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3777 4168 | .await
|
3778 4169 | .expect("unable to make an HTTP request");
|
3779 4170 | ::pretty_assertions::assert_eq!(
|
3780 4171 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3781 4172 | http_response.status()
|
3782 4173 | );
|
3783 4174 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3784 4175 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3785 4176 | http_response.headers(),
|
3786 4177 | expected_headers,
|
3787 4178 | ));
|
3788 4179 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3789 4180 | .await
|
3790 4181 | .expect("unable to extract body to bytes");
|
3791 4182 | ::aws_smithy_protocol_test::assert_ok(
|
3792 - | ::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"))
|
4183 + | ::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"))
|
3793 4184 | );
|
3794 4185 | }
|
3795 4186 | }
|
3796 - | /// When a long member does not fit within range bounds,
|
4187 + | /// When a map member's key does not match the specified pattern,
|
3797 4188 | /// the response should be a 400 ValidationException.
|
3798 - | /// Test ID: RestJsonMalformedRangeLong_case0
|
4189 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case1
|
3799 4190 | #[::tokio::test]
|
3800 - | async fn rest_json_malformed_range_long_case0_malformed_request() {
|
4191 + | #[::tracing_test::traced_test]
|
4192 + | async fn rest_json_malformed_pattern_map_key_override_case1_malformed_request() {
|
3801 4193 | {
|
3802 4194 | #[allow(unused_mut)]
|
3803 4195 | let mut http_request = http::Request::builder()
|
3804 - | .uri("/MalformedRange")
|
4196 + | .uri("/MalformedPatternOverride")
|
3805 4197 | .method("POST")
|
3806 4198 | .header("content-type", "application/json")
|
3807 4199 | .body(::aws_smithy_http_server::body::Body::from(
|
3808 - | ::bytes::Bytes::from_static("{ \"long\" : 1 }".as_bytes()),
|
4200 + | ::bytes::Bytes::from_static("{ \"map\" : { \"xyz\" : \"ghi\" } }".as_bytes()),
|
3809 4201 | ))
|
3810 4202 | .unwrap();
|
3811 4203 | #[allow(unused_mut)]
|
3812 4204 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3813 4205 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3814 4206 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3815 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4207 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3816 4208 | let sender = sender.clone();
|
3817 4209 | async move {
|
3818 - | 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> };
|
4210 + | 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> };
|
3819 4211 | sender.send(()).await.expect("receiver dropped early");
|
3820 4212 | result
|
3821 4213 | }
|
3822 4214 | })
|
3823 4215 | .build_unchecked();
|
3824 4216 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3825 4217 | .await
|
3826 4218 | .expect("unable to make an HTTP request");
|
3827 4219 | ::pretty_assertions::assert_eq!(
|
3828 4220 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3829 4221 | http_response.status()
|
3830 4222 | );
|
3831 4223 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3832 4224 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3833 4225 | http_response.headers(),
|
3834 4226 | expected_headers,
|
3835 4227 | ));
|
3836 4228 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3837 4229 | .await
|
3838 4230 | .expect("unable to extract body to bytes");
|
3839 4231 | ::aws_smithy_protocol_test::assert_ok(
|
3840 - | ::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"))
|
4232 + | ::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"))
|
3841 4233 | );
|
3842 4234 | }
|
3843 4235 | }
|
3844 - | /// When a long member does not fit within range bounds,
|
4236 + | /// When a map member's value does not match the specified pattern,
|
3845 4237 | /// the response should be a 400 ValidationException.
|
3846 - | /// Test ID: RestJsonMalformedRangeLong_case1
|
4238 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case0
|
3847 4239 | #[::tokio::test]
|
3848 - | async fn rest_json_malformed_range_long_case1_malformed_request() {
|
4240 + | #[::tracing_test::traced_test]
|
4241 + | async fn rest_json_malformed_pattern_map_value_override_case0_malformed_request() {
|
3849 4242 | {
|
3850 4243 | #[allow(unused_mut)]
|
3851 4244 | let mut http_request = http::Request::builder()
|
3852 - | .uri("/MalformedRange")
|
4245 + | .uri("/MalformedPatternOverride")
|
3853 4246 | .method("POST")
|
3854 4247 | .header("content-type", "application/json")
|
3855 4248 | .body(::aws_smithy_http_server::body::Body::from(
|
3856 - | ::bytes::Bytes::from_static("{ \"long\" : 9 }".as_bytes()),
|
4249 + | ::bytes::Bytes::from_static("{ \"map\" : { \"ghi\": \"abc\" } }".as_bytes()),
|
3857 4250 | ))
|
3858 4251 | .unwrap();
|
3859 4252 | #[allow(unused_mut)]
|
3860 4253 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3861 4254 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3862 4255 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3863 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4256 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3864 4257 | let sender = sender.clone();
|
3865 4258 | async move {
|
3866 - | 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> };
|
4259 + | 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> };
|
3867 4260 | sender.send(()).await.expect("receiver dropped early");
|
3868 4261 | result
|
3869 4262 | }
|
3870 4263 | })
|
3871 4264 | .build_unchecked();
|
3872 4265 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3873 4266 | .await
|
3874 4267 | .expect("unable to make an HTTP request");
|
3875 4268 | ::pretty_assertions::assert_eq!(
|
3876 4269 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3877 4270 | http_response.status()
|
3878 4271 | );
|
3879 4272 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3880 4273 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3881 4274 | http_response.headers(),
|
3882 4275 | expected_headers,
|
3883 4276 | ));
|
3884 4277 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3885 4278 | .await
|
3886 4279 | .expect("unable to extract body to bytes");
|
3887 4280 | ::aws_smithy_protocol_test::assert_ok(
|
3888 - | ::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"))
|
4281 + | ::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"))
|
3889 4282 | );
|
3890 4283 | }
|
3891 4284 | }
|
3892 - | /// When a long member does not fit within range bounds,
|
4285 + | /// When a map member's value does not match the specified pattern,
|
3893 4286 | /// the response should be a 400 ValidationException.
|
3894 - | /// Test ID: RestJsonMalformedRangeMinLong
|
4287 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case1
|
3895 4288 | #[::tokio::test]
|
3896 - | async fn rest_json_malformed_range_min_long_malformed_request() {
|
4289 + | #[::tracing_test::traced_test]
|
4290 + | async fn rest_json_malformed_pattern_map_value_override_case1_malformed_request() {
|
3897 4291 | {
|
3898 4292 | #[allow(unused_mut)]
|
3899 4293 | let mut http_request = http::Request::builder()
|
3900 - | .uri("/MalformedRange")
|
4294 + | .uri("/MalformedPatternOverride")
|
3901 4295 | .method("POST")
|
3902 4296 | .header("content-type", "application/json")
|
3903 4297 | .body(::aws_smithy_http_server::body::Body::from(
|
3904 - | ::bytes::Bytes::from_static("{ \"minLong\" : 1 }".as_bytes()),
|
4298 + | ::bytes::Bytes::from_static("{ \"map\" : { \"ghi\": \"xyz\" } }".as_bytes()),
|
3905 4299 | ))
|
3906 4300 | .unwrap();
|
3907 4301 | #[allow(unused_mut)]
|
3908 4302 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3909 4303 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3910 4304 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3911 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4305 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3912 4306 | let sender = sender.clone();
|
3913 4307 | async move {
|
3914 - | 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> };
|
4308 + | 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> };
|
3915 4309 | sender.send(()).await.expect("receiver dropped early");
|
3916 4310 | result
|
3917 4311 | }
|
3918 4312 | })
|
3919 4313 | .build_unchecked();
|
3920 4314 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3921 4315 | .await
|
3922 4316 | .expect("unable to make an HTTP request");
|
3923 4317 | ::pretty_assertions::assert_eq!(
|
3924 4318 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3925 4319 | http_response.status()
|
3926 4320 | );
|
3927 4321 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3928 4322 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3929 4323 | http_response.headers(),
|
3930 4324 | expected_headers,
|
3931 4325 | ));
|
3932 4326 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3933 4327 | .await
|
3934 4328 | .expect("unable to extract body to bytes");
|
3935 4329 | ::aws_smithy_protocol_test::assert_ok(
|
3936 - | ::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"))
|
4330 + | ::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"))
|
3937 4331 | );
|
3938 4332 | }
|
3939 4333 | }
|
3940 - | /// When a long member does not fit within range bounds,
|
4334 + | /// When a union member's value does not match the specified pattern,
|
3941 4335 | /// the response should be a 400 ValidationException.
|
3942 - | /// Test ID: RestJsonMalformedRangeMaxLong
|
4336 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case0
|
3943 4337 | #[::tokio::test]
|
3944 - | async fn rest_json_malformed_range_max_long_malformed_request() {
|
4338 + | #[::tracing_test::traced_test]
|
4339 + | async fn rest_json_malformed_pattern_union_override_case0_malformed_request() {
|
3945 4340 | {
|
3946 4341 | #[allow(unused_mut)]
|
3947 4342 | let mut http_request = http::Request::builder()
|
3948 - | .uri("/MalformedRange")
|
4343 + | .uri("/MalformedPatternOverride")
|
3949 4344 | .method("POST")
|
3950 4345 | .header("content-type", "application/json")
|
3951 4346 | .body(::aws_smithy_http_server::body::Body::from(
|
3952 - | ::bytes::Bytes::from_static("{ \"maxLong\" : 9 }".as_bytes()),
|
4347 + | ::bytes::Bytes::from_static(
|
4348 + | "{ \"union\" : { \"first\": \"abc\" } }".as_bytes(),
|
4349 + | ),
|
3953 4350 | ))
|
3954 4351 | .unwrap();
|
3955 4352 | #[allow(unused_mut)]
|
3956 4353 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3957 4354 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3958 4355 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
3959 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4356 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3960 4357 | let sender = sender.clone();
|
3961 4358 | async move {
|
3962 - | 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> };
|
4359 + | 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> };
|
3963 4360 | sender.send(()).await.expect("receiver dropped early");
|
3964 4361 | result
|
3965 4362 | }
|
3966 4363 | })
|
3967 4364 | .build_unchecked();
|
3968 4365 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3969 4366 | .await
|
3970 4367 | .expect("unable to make an HTTP request");
|
3971 4368 | ::pretty_assertions::assert_eq!(
|
3972 4369 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3973 4370 | http_response.status()
|
3974 4371 | );
|
3975 4372 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3976 4373 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3977 4374 | http_response.headers(),
|
3978 4375 | expected_headers,
|
3979 4376 | ));
|
3980 4377 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
3981 4378 | .await
|
3982 4379 | .expect("unable to extract body to bytes");
|
3983 4380 | ::aws_smithy_protocol_test::assert_ok(
|
3984 - | ::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"))
|
4381 + | ::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"))
|
3985 4382 | );
|
3986 4383 | }
|
3987 4384 | }
|
3988 - | }
|
3989 - | #[cfg(test)]
|
3990 - | #[allow(unreachable_code, unused_variables)]
|
3991 - | mod server_malformed_range_override_test {
|
3992 - | /// When a byte member does not fit within range bounds,
|
4385 + | /// When a union member's value does not match the specified pattern,
|
3993 4386 | /// the response should be a 400 ValidationException.
|
3994 - | /// Test ID: RestJsonMalformedRangeByteOverride_case0
|
4387 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case1
|
3995 4388 | #[::tokio::test]
|
3996 - | async fn rest_json_malformed_range_byte_override_case0_malformed_request() {
|
4389 + | #[::tracing_test::traced_test]
|
4390 + | async fn rest_json_malformed_pattern_union_override_case1_malformed_request() {
|
3997 4391 | {
|
3998 4392 | #[allow(unused_mut)]
|
3999 4393 | let mut http_request = http::Request::builder()
|
4000 - | .uri("/MalformedRangeOverride")
|
4394 + | .uri("/MalformedPatternOverride")
|
4001 4395 | .method("POST")
|
4002 4396 | .header("content-type", "application/json")
|
4003 4397 | .body(::aws_smithy_http_server::body::Body::from(
|
4004 - | ::bytes::Bytes::from_static("{ \"byte\" : 3 }".as_bytes()),
|
4398 + | ::bytes::Bytes::from_static(
|
4399 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
4400 + | ),
|
4005 4401 | ))
|
4006 4402 | .unwrap();
|
4007 4403 | #[allow(unused_mut)]
|
4008 4404 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4009 4405 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4010 4406 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4011 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4407 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4012 4408 | let sender = sender.clone();
|
4013 4409 | async move {
|
4014 - | 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> };
|
4410 + | 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> };
|
4015 4411 | sender.send(()).await.expect("receiver dropped early");
|
4016 4412 | result
|
4017 4413 | }
|
4018 4414 | })
|
4019 4415 | .build_unchecked();
|
4020 4416 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4021 4417 | .await
|
4022 4418 | .expect("unable to make an HTTP request");
|
4023 4419 | ::pretty_assertions::assert_eq!(
|
4024 4420 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4025 4421 | http_response.status()
|
4026 4422 | );
|
4027 4423 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4028 4424 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4029 4425 | http_response.headers(),
|
4030 4426 | expected_headers,
|
4031 4427 | ));
|
4032 4428 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4033 4429 | .await
|
4034 4430 | .expect("unable to extract body to bytes");
|
4035 4431 | ::aws_smithy_protocol_test::assert_ok(
|
4036 - | ::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"))
|
4432 + | ::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"))
|
4037 4433 | );
|
4038 4434 | }
|
4039 4435 | }
|
4040 - | /// When a byte member does not fit within range bounds,
|
4041 - | /// the response should be a 400 ValidationException.
|
4042 - | /// Test ID: RestJsonMalformedRangeByteOverride_case1
|
4043 - | #[::tokio::test]
|
4044 - | async fn rest_json_malformed_range_byte_override_case1_malformed_request() {
|
4045 - | {
|
4046 - | #[allow(unused_mut)]
|
4047 - | let mut http_request = http::Request::builder()
|
4048 - | .uri("/MalformedRangeOverride")
|
4049 - | .method("POST")
|
4050 - | .header("content-type", "application/json")
|
4051 - | .body(::aws_smithy_http_server::body::Body::from(
|
4052 - | ::bytes::Bytes::from_static("{ \"byte\" : 7 }".as_bytes()),
|
4053 - | ))
|
4054 - | .unwrap();
|
4055 - | #[allow(unused_mut)]
|
4056 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4057 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4058 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4059 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4060 - | let sender = sender.clone();
|
4061 - | async move {
|
4062 - | 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> };
|
4063 - | sender.send(()).await.expect("receiver dropped early");
|
4064 - | result
|
4436 + | }
|
4437 + |
|
4438 + | const CONTENT_TYPE_MALFORMEDPATTERN: ::mime::Mime = ::mime::APPLICATION_JSON;
|
4439 + | ::pin_project_lite::pin_project! {
|
4440 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4441 + | /// [`MalformedPatternInput`](crate::input::MalformedPatternInput) using modelled bindings.
|
4442 + | pub struct MalformedPatternInputFuture {
|
4443 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedPatternInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
4065 4444 | }
|
4066 - | })
|
4067 - | .build_unchecked();
|
4068 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4069 - | .await
|
4070 - | .expect("unable to make an HTTP request");
|
4071 - | ::pretty_assertions::assert_eq!(
|
4072 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4073 - | http_response.status()
|
4074 - | );
|
4075 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4076 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4077 - | http_response.headers(),
|
4078 - | expected_headers,
|
4079 - | ));
|
4080 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4445 + | }
|
4446 + |
|
4447 + | impl std::future::Future for MalformedPatternInputFuture {
|
4448 + | type Output = Result<
|
4449 + | crate::input::MalformedPatternInput,
|
4450 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
4451 + | >;
|
4452 + |
|
4453 + | fn poll(
|
4454 + | self: std::pin::Pin<&mut Self>,
|
4455 + | cx: &mut std::task::Context<'_>,
|
4456 + | ) -> std::task::Poll<Self::Output> {
|
4457 + | let this = self.project();
|
4458 + | this.inner.as_mut().poll(cx)
|
4459 + | }
|
4460 + | }
|
4461 + |
|
4462 + | impl<B>
|
4463 + | ::aws_smithy_http_server::request::FromRequest<
|
4464 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
4465 + | B,
|
4466 + | > for crate::input::MalformedPatternInput
|
4467 + | where
|
4468 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
4469 + | B: 'static,
|
4470 + |
|
4471 + | B::Data: Send,
|
4472 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
4473 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
4474 + | {
|
4475 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
4476 + | type Future = MalformedPatternInputFuture;
|
4477 + |
|
4478 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
4479 + | let fut = async move {
|
4480 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
4481 + | request.headers(),
|
4482 + | &CONTENT_TYPE_MALFORMEDPATTERN,
|
4483 + | ) {
|
4484 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
4485 + | }
|
4486 + | crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern_http_request(
|
4487 + | request,
|
4488 + | )
|
4081 4489 | .await
|
4082 - | .expect("unable to extract body to bytes");
|
4083 - | ::aws_smithy_protocol_test::assert_ok(
|
4084 - | ::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"))
|
4490 + | .map_err(Into::into)
|
4491 + | };
|
4492 + | use ::futures_util::future::TryFutureExt;
|
4493 + | let fut = fut.map_err(
|
4494 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
4495 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4496 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
4497 + | e,
|
4498 + | )
|
4499 + | },
|
4085 4500 | );
|
4501 + | MalformedPatternInputFuture {
|
4502 + | inner: Box::pin(fut),
|
4086 4503 | }
|
4087 4504 | }
|
4088 - | /// When a byte member does not fit within range bounds,
|
4089 - | /// the response should be a 400 ValidationException.
|
4090 - | /// Test ID: RestJsonMalformedRangeMinByteOverride
|
4091 - | #[::tokio::test]
|
4092 - | async fn rest_json_malformed_range_min_byte_override_malformed_request() {
|
4093 - | {
|
4094 - | #[allow(unused_mut)]
|
4095 - | let mut http_request = http::Request::builder()
|
4096 - | .uri("/MalformedRangeOverride")
|
4097 - | .method("POST")
|
4098 - | .header("content-type", "application/json")
|
4099 - | .body(::aws_smithy_http_server::body::Body::from(
|
4100 - | ::bytes::Bytes::from_static("{ \"minByte\" : 3 }".as_bytes()),
|
4505 + | }
|
4506 + | impl
|
4507 + | ::aws_smithy_http_server::response::IntoResponse<
|
4508 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
4509 + | > for crate::output::MalformedPatternOutput
|
4510 + | {
|
4511 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4512 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_response(
|
4513 + | self,
|
4514 + | ) {
|
4515 + | Ok(response) => response,
|
4516 + | Err(e) => {
|
4517 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4518 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
4519 + | }
|
4520 + | }
|
4521 + | }
|
4522 + | }
|
4523 + | impl
|
4524 + | ::aws_smithy_http_server::response::IntoResponse<
|
4525 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
4526 + | > for crate::error::MalformedPatternError
|
4527 + | {
|
4528 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4529 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_error(
|
4530 + | &self,
|
4531 + | ) {
|
4532 + | Ok(mut response) => {
|
4533 + | response.extensions_mut().insert(
|
4534 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
4535 + | );
|
4536 + | response
|
4537 + | }
|
4538 + | Err(e) => {
|
4539 + | ::tracing::error!(error = %e, "failed to serialize response");
|
4540 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
4541 + | }
|
4542 + | }
|
4543 + | }
|
4544 + | }
|
4545 + |
|
4546 + | #[allow(unreachable_code, unused_variables)]
|
4547 + | #[cfg(test)]
|
4548 + | mod malformed_pattern_test {
|
4549 + |
|
4550 + | /// When a string member does not match the specified pattern,
|
4551 + | /// the response should be a 400 ValidationException.
|
4552 + | /// Test ID: RestJsonMalformedPatternString_case0
|
4553 + | #[::tokio::test]
|
4554 + | #[::tracing_test::traced_test]
|
4555 + | async fn rest_json_malformed_pattern_string_case0_malformed_request() {
|
4556 + | {
|
4557 + | #[allow(unused_mut)]
|
4558 + | let mut http_request = http::Request::builder()
|
4559 + | .uri("/MalformedPattern")
|
4560 + | .method("POST")
|
4561 + | .header("content-type", "application/json")
|
4562 + | .body(::aws_smithy_http_server::body::Body::from(
|
4563 + | ::bytes::Bytes::from_static("{ \"string\" : \"ABC\" }".as_bytes()),
|
4101 4564 | ))
|
4102 4565 | .unwrap();
|
4103 4566 | #[allow(unused_mut)]
|
4104 4567 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4105 4568 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4106 4569 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4107 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4570 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4108 4571 | let sender = sender.clone();
|
4109 4572 | async move {
|
4110 - | 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> };
|
4573 + | 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> };
|
4111 4574 | sender.send(()).await.expect("receiver dropped early");
|
4112 4575 | result
|
4113 4576 | }
|
4114 4577 | })
|
4115 4578 | .build_unchecked();
|
4116 4579 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4117 4580 | .await
|
4118 4581 | .expect("unable to make an HTTP request");
|
4119 4582 | ::pretty_assertions::assert_eq!(
|
4120 4583 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4121 4584 | http_response.status()
|
4122 4585 | );
|
4123 4586 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4124 4587 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4125 4588 | http_response.headers(),
|
4126 4589 | expected_headers,
|
4127 4590 | ));
|
4128 4591 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4129 4592 | .await
|
4130 4593 | .expect("unable to extract body to bytes");
|
4131 4594 | ::aws_smithy_protocol_test::assert_ok(
|
4132 - | ::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"))
|
4595 + | ::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"))
|
4133 4596 | );
|
4134 4597 | }
|
4135 4598 | }
|
4136 - | /// When a byte member does not fit within range bounds,
|
4599 + | /// When a string member does not match the specified pattern,
|
4137 4600 | /// the response should be a 400 ValidationException.
|
4138 - | /// Test ID: RestJsonMalformedRangeMaxByteOverride
|
4601 + | /// Test ID: RestJsonMalformedPatternString_case1
|
4139 4602 | #[::tokio::test]
|
4140 - | async fn rest_json_malformed_range_max_byte_override_malformed_request() {
|
4603 + | #[::tracing_test::traced_test]
|
4604 + | async fn rest_json_malformed_pattern_string_case1_malformed_request() {
|
4141 4605 | {
|
4142 4606 | #[allow(unused_mut)]
|
4143 4607 | let mut http_request = http::Request::builder()
|
4144 - | .uri("/MalformedRangeOverride")
|
4608 + | .uri("/MalformedPattern")
|
4145 4609 | .method("POST")
|
4146 4610 | .header("content-type", "application/json")
|
4147 4611 | .body(::aws_smithy_http_server::body::Body::from(
|
4148 - | ::bytes::Bytes::from_static("{ \"maxByte\" : 7 }".as_bytes()),
|
4612 + | ::bytes::Bytes::from_static("{ \"string\" : \"xyz\" }".as_bytes()),
|
4149 4613 | ))
|
4150 4614 | .unwrap();
|
4151 4615 | #[allow(unused_mut)]
|
4152 4616 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4153 4617 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4154 4618 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4155 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4619 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4156 4620 | let sender = sender.clone();
|
4157 4621 | async move {
|
4158 - | 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> };
|
4622 + | 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> };
|
4159 4623 | sender.send(()).await.expect("receiver dropped early");
|
4160 4624 | result
|
4161 4625 | }
|
4162 4626 | })
|
4163 4627 | .build_unchecked();
|
4164 4628 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4165 4629 | .await
|
4166 4630 | .expect("unable to make an HTTP request");
|
4167 4631 | ::pretty_assertions::assert_eq!(
|
4168 4632 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4169 4633 | http_response.status()
|
4170 4634 | );
|
4171 4635 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4172 4636 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4173 4637 | http_response.headers(),
|
4174 4638 | expected_headers,
|
4175 4639 | ));
|
4176 4640 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4177 4641 | .await
|
4178 4642 | .expect("unable to extract body to bytes");
|
4179 4643 | ::aws_smithy_protocol_test::assert_ok(
|
4180 - | ::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"))
|
4644 + | ::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"))
|
4181 4645 | );
|
4182 4646 | }
|
4183 4647 | }
|
4184 - | /// When a float member does not fit within range bounds,
|
4185 - | /// the response should be a 400 ValidationException.
|
4186 - | /// Test ID: RestJsonMalformedRangeFloatOverride_case0
|
4648 + | /// When the specified pattern is susceptible to ReDOS, the service will not
|
4649 + | /// hang indefinitely while evaluating the pattern
|
4650 + | /// Test ID: RestJsonMalformedPatternReDOSString
|
4187 4651 | #[::tokio::test]
|
4188 - | #[should_panic]
|
4189 - | async fn rest_json_malformed_range_float_override_case0_malformed_request() {
|
4652 + | #[::tracing_test::traced_test]
|
4653 + | async fn rest_json_malformed_pattern_re_dos_string_malformed_request() {
|
4190 4654 | {
|
4191 4655 | #[allow(unused_mut)]
|
4192 4656 | let mut http_request = http::Request::builder()
|
4193 - | .uri("/MalformedRangeOverride")
|
4657 + | .uri("/MalformedPattern")
|
4194 4658 | .method("POST")
|
4195 4659 | .header("content-type", "application/json")
|
4196 - | .body(::aws_smithy_http_server::body::Body::from(
|
4197 - | ::bytes::Bytes::from_static("{ \"float\" : 4.3 }".as_bytes()),
|
4198 - | ))
|
4199 - | .unwrap();
|
4660 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes()))).unwrap();
|
4200 4661 | #[allow(unused_mut)]
|
4201 4662 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4202 4663 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4203 4664 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4204 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4665 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4205 4666 | let sender = sender.clone();
|
4206 4667 | async move {
|
4207 - | 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> };
|
4668 + | 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> };
|
4208 4669 | sender.send(()).await.expect("receiver dropped early");
|
4209 4670 | result
|
4210 4671 | }
|
4211 4672 | })
|
4212 4673 | .build_unchecked();
|
4213 4674 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4214 4675 | .await
|
4215 4676 | .expect("unable to make an HTTP request");
|
4216 4677 | ::pretty_assertions::assert_eq!(
|
4217 4678 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4218 4679 | http_response.status()
|
4219 4680 | );
|
4220 4681 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4221 4682 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4222 4683 | http_response.headers(),
|
4223 4684 | expected_headers,
|
4224 4685 | ));
|
4225 4686 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4226 4687 | .await
|
4227 4688 | .expect("unable to extract body to bytes");
|
4228 4689 | ::aws_smithy_protocol_test::assert_ok(
|
4229 - | ::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"))
|
4690 + | ::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"))
|
4230 4691 | );
|
4231 4692 | }
|
4232 4693 | }
|
4233 - | /// When a float member does not fit within range bounds,
|
4694 + | /// When a list member value does not match the specified pattern,
|
4234 4695 | /// the response should be a 400 ValidationException.
|
4235 - | /// Test ID: RestJsonMalformedRangeFloatOverride_case1
|
4696 + | /// Test ID: RestJsonMalformedPatternList_case0
|
4236 4697 | #[::tokio::test]
|
4237 - | #[should_panic]
|
4238 - | async fn rest_json_malformed_range_float_override_case1_malformed_request() {
|
4698 + | #[::tracing_test::traced_test]
|
4699 + | async fn rest_json_malformed_pattern_list_case0_malformed_request() {
|
4239 4700 | {
|
4240 4701 | #[allow(unused_mut)]
|
4241 4702 | let mut http_request = http::Request::builder()
|
4242 - | .uri("/MalformedRangeOverride")
|
4703 + | .uri("/MalformedPattern")
|
4243 4704 | .method("POST")
|
4244 4705 | .header("content-type", "application/json")
|
4245 4706 | .body(::aws_smithy_http_server::body::Body::from(
|
4246 - | ::bytes::Bytes::from_static("{ \"float\" : 6.7 }".as_bytes()),
|
4707 + | ::bytes::Bytes::from_static("{ \"list\" : [\"ABC\"] }".as_bytes()),
|
4247 4708 | ))
|
4248 4709 | .unwrap();
|
4249 4710 | #[allow(unused_mut)]
|
4250 4711 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4251 4712 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4252 4713 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4253 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4714 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4254 4715 | let sender = sender.clone();
|
4255 4716 | async move {
|
4256 - | 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> };
|
4717 + | 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> };
|
4257 4718 | sender.send(()).await.expect("receiver dropped early");
|
4258 4719 | result
|
4259 4720 | }
|
4260 4721 | })
|
4261 4722 | .build_unchecked();
|
4262 4723 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4263 4724 | .await
|
4264 4725 | .expect("unable to make an HTTP request");
|
4265 4726 | ::pretty_assertions::assert_eq!(
|
4266 4727 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4267 4728 | http_response.status()
|
4268 4729 | );
|
4269 4730 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4270 4731 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4271 4732 | http_response.headers(),
|
4272 4733 | expected_headers,
|
4273 4734 | ));
|
4274 4735 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4275 4736 | .await
|
4276 4737 | .expect("unable to extract body to bytes");
|
4277 4738 | ::aws_smithy_protocol_test::assert_ok(
|
4278 - | ::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"))
|
4739 + | ::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"))
|
4279 4740 | );
|
4280 4741 | }
|
4281 4742 | }
|
4282 - | /// When a float member does not fit within range bounds,
|
4743 + | /// When a list member value does not match the specified pattern,
|
4283 4744 | /// the response should be a 400 ValidationException.
|
4284 - | /// Test ID: RestJsonMalformedRangeMinFloatOverride
|
4745 + | /// Test ID: RestJsonMalformedPatternList_case1
|
4285 4746 | #[::tokio::test]
|
4286 - | #[should_panic]
|
4287 - | async fn rest_json_malformed_range_min_float_override_malformed_request() {
|
4747 + | #[::tracing_test::traced_test]
|
4748 + | async fn rest_json_malformed_pattern_list_case1_malformed_request() {
|
4288 4749 | {
|
4289 4750 | #[allow(unused_mut)]
|
4290 4751 | let mut http_request = http::Request::builder()
|
4291 - | .uri("/MalformedRangeOverride")
|
4752 + | .uri("/MalformedPattern")
|
4292 4753 | .method("POST")
|
4293 4754 | .header("content-type", "application/json")
|
4294 4755 | .body(::aws_smithy_http_server::body::Body::from(
|
4295 - | ::bytes::Bytes::from_static("{ \"minFloat\" : 4.3 }".as_bytes()),
|
4756 + | ::bytes::Bytes::from_static("{ \"list\" : [\"xyz\"] }".as_bytes()),
|
4296 4757 | ))
|
4297 4758 | .unwrap();
|
4298 4759 | #[allow(unused_mut)]
|
4299 4760 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4300 4761 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4301 4762 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4302 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4763 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4303 4764 | let sender = sender.clone();
|
4304 4765 | async move {
|
4305 - | 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> };
|
4766 + | 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> };
|
4306 4767 | sender.send(()).await.expect("receiver dropped early");
|
4307 4768 | result
|
4308 4769 | }
|
4309 4770 | })
|
4310 4771 | .build_unchecked();
|
4311 4772 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4312 4773 | .await
|
4313 4774 | .expect("unable to make an HTTP request");
|
4314 4775 | ::pretty_assertions::assert_eq!(
|
4315 4776 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4316 4777 | http_response.status()
|
4317 4778 | );
|
4318 4779 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4319 4780 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4320 4781 | http_response.headers(),
|
4321 4782 | expected_headers,
|
4322 4783 | ));
|
4323 4784 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4324 4785 | .await
|
4325 4786 | .expect("unable to extract body to bytes");
|
4326 4787 | ::aws_smithy_protocol_test::assert_ok(
|
4327 - | ::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"))
|
4788 + | ::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"))
|
4328 4789 | );
|
4329 4790 | }
|
4330 4791 | }
|
4331 - | /// When a float member does not fit within range bounds,
|
4792 + | /// When a map member's key does not match the specified pattern,
|
4332 4793 | /// the response should be a 400 ValidationException.
|
4333 - | /// Test ID: RestJsonMalformedRangeMaxFloatOverride
|
4794 + | /// Test ID: RestJsonMalformedPatternMapKey_case0
|
4334 4795 | #[::tokio::test]
|
4335 - | #[should_panic]
|
4336 - | async fn rest_json_malformed_range_max_float_override_malformed_request() {
|
4796 + | #[::tracing_test::traced_test]
|
4797 + | async fn rest_json_malformed_pattern_map_key_case0_malformed_request() {
|
4337 4798 | {
|
4338 4799 | #[allow(unused_mut)]
|
4339 4800 | let mut http_request = http::Request::builder()
|
4340 - | .uri("/MalformedRangeOverride")
|
4801 + | .uri("/MalformedPattern")
|
4341 4802 | .method("POST")
|
4342 4803 | .header("content-type", "application/json")
|
4343 4804 | .body(::aws_smithy_http_server::body::Body::from(
|
4344 - | ::bytes::Bytes::from_static("{ \"maxFloat\" : 6.7 }".as_bytes()),
|
4805 + | ::bytes::Bytes::from_static("{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes()),
|
4345 4806 | ))
|
4346 4807 | .unwrap();
|
4347 4808 | #[allow(unused_mut)]
|
4348 4809 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4349 4810 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4350 4811 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4351 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4812 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4352 4813 | let sender = sender.clone();
|
4353 4814 | async move {
|
4354 - | 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> };
|
4815 + | 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> };
|
4355 4816 | sender.send(()).await.expect("receiver dropped early");
|
4356 4817 | result
|
4357 4818 | }
|
4358 4819 | })
|
4359 4820 | .build_unchecked();
|
4360 4821 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4361 4822 | .await
|
4362 4823 | .expect("unable to make an HTTP request");
|
4363 4824 | ::pretty_assertions::assert_eq!(
|
4364 4825 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4365 4826 | http_response.status()
|
4366 4827 | );
|
4367 4828 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4368 4829 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4369 4830 | http_response.headers(),
|
4370 4831 | expected_headers,
|
4371 4832 | ));
|
4372 4833 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4373 4834 | .await
|
4374 4835 | .expect("unable to extract body to bytes");
|
4375 4836 | ::aws_smithy_protocol_test::assert_ok(
|
4376 - | ::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"))
|
4837 + | ::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"))
|
4377 4838 | );
|
4378 4839 | }
|
4379 4840 | }
|
4380 - | /// When a short member does not fit within range bounds,
|
4841 + | /// When a map member's key does not match the specified pattern,
|
4381 4842 | /// the response should be a 400 ValidationException.
|
4382 - | /// Test ID: RestJsonMalformedRangeShortOverride_case0
|
4843 + | /// Test ID: RestJsonMalformedPatternMapKey_case1
|
4383 4844 | #[::tokio::test]
|
4384 - | async fn rest_json_malformed_range_short_override_case0_malformed_request() {
|
4845 + | #[::tracing_test::traced_test]
|
4846 + | async fn rest_json_malformed_pattern_map_key_case1_malformed_request() {
|
4385 4847 | {
|
4386 4848 | #[allow(unused_mut)]
|
4387 4849 | let mut http_request = http::Request::builder()
|
4388 - | .uri("/MalformedRangeOverride")
|
4850 + | .uri("/MalformedPattern")
|
4389 4851 | .method("POST")
|
4390 4852 | .header("content-type", "application/json")
|
4391 4853 | .body(::aws_smithy_http_server::body::Body::from(
|
4392 - | ::bytes::Bytes::from_static("{ \"short\" : 3 }".as_bytes()),
|
4854 + | ::bytes::Bytes::from_static("{ \"map\" : { \"xyz\" : \"abc\" } }".as_bytes()),
|
4393 4855 | ))
|
4394 4856 | .unwrap();
|
4395 4857 | #[allow(unused_mut)]
|
4396 4858 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4397 4859 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4398 4860 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4399 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4861 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4400 4862 | let sender = sender.clone();
|
4401 4863 | async move {
|
4402 - | 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> };
|
4864 + | 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> };
|
4403 4865 | sender.send(()).await.expect("receiver dropped early");
|
4404 4866 | result
|
4405 4867 | }
|
4406 4868 | })
|
4407 4869 | .build_unchecked();
|
4408 4870 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4409 4871 | .await
|
4410 4872 | .expect("unable to make an HTTP request");
|
4411 4873 | ::pretty_assertions::assert_eq!(
|
4412 4874 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4413 4875 | http_response.status()
|
4414 4876 | );
|
4415 4877 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4416 4878 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4417 4879 | http_response.headers(),
|
4418 4880 | expected_headers,
|
4419 4881 | ));
|
4420 4882 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4421 4883 | .await
|
4422 4884 | .expect("unable to extract body to bytes");
|
4423 4885 | ::aws_smithy_protocol_test::assert_ok(
|
4424 - | ::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"))
|
4886 + | ::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"))
|
4425 4887 | );
|
4426 4888 | }
|
4427 4889 | }
|
4428 - | /// When a short member does not fit within range bounds,
|
4890 + | /// When a map member's value does not match the specified pattern,
|
4429 4891 | /// the response should be a 400 ValidationException.
|
4430 - | /// Test ID: RestJsonMalformedRangeShortOverride_case1
|
4892 + | /// Test ID: RestJsonMalformedPatternMapValue_case0
|
4431 4893 | #[::tokio::test]
|
4432 - | async fn rest_json_malformed_range_short_override_case1_malformed_request() {
|
4894 + | #[::tracing_test::traced_test]
|
4895 + | async fn rest_json_malformed_pattern_map_value_case0_malformed_request() {
|
4433 4896 | {
|
4434 4897 | #[allow(unused_mut)]
|
4435 4898 | let mut http_request = http::Request::builder()
|
4436 - | .uri("/MalformedRangeOverride")
|
4899 + | .uri("/MalformedPattern")
|
4437 4900 | .method("POST")
|
4438 4901 | .header("content-type", "application/json")
|
4439 4902 | .body(::aws_smithy_http_server::body::Body::from(
|
4440 - | ::bytes::Bytes::from_static("{ \"short\" : 7 }".as_bytes()),
|
4903 + | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes()),
|
4441 4904 | ))
|
4442 4905 | .unwrap();
|
4443 4906 | #[allow(unused_mut)]
|
4444 4907 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4445 4908 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4446 4909 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4447 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4910 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4448 4911 | let sender = sender.clone();
|
4449 4912 | async move {
|
4450 - | 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> };
|
4913 + | 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> };
|
4451 4914 | sender.send(()).await.expect("receiver dropped early");
|
4452 4915 | result
|
4453 4916 | }
|
4454 4917 | })
|
4455 4918 | .build_unchecked();
|
4456 4919 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4457 4920 | .await
|
4458 4921 | .expect("unable to make an HTTP request");
|
4459 4922 | ::pretty_assertions::assert_eq!(
|
4460 4923 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4461 4924 | http_response.status()
|
4462 4925 | );
|
4463 4926 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4464 4927 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4465 4928 | http_response.headers(),
|
4466 4929 | expected_headers,
|
4467 4930 | ));
|
4468 4931 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4469 4932 | .await
|
4470 4933 | .expect("unable to extract body to bytes");
|
4471 4934 | ::aws_smithy_protocol_test::assert_ok(
|
4472 - | ::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"))
|
4935 + | ::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"))
|
4473 4936 | );
|
4474 4937 | }
|
4475 4938 | }
|
4476 - | /// When a short member does not fit within range bounds,
|
4939 + | /// When a map member's value does not match the specified pattern,
|
4477 4940 | /// the response should be a 400 ValidationException.
|
4478 - | /// Test ID: RestJsonMalformedRangeMinShortOverride
|
4941 + | /// Test ID: RestJsonMalformedPatternMapValue_case1
|
4479 4942 | #[::tokio::test]
|
4480 - | async fn rest_json_malformed_range_min_short_override_malformed_request() {
|
4943 + | #[::tracing_test::traced_test]
|
4944 + | async fn rest_json_malformed_pattern_map_value_case1_malformed_request() {
|
4481 4945 | {
|
4482 4946 | #[allow(unused_mut)]
|
4483 4947 | let mut http_request = http::Request::builder()
|
4484 - | .uri("/MalformedRangeOverride")
|
4948 + | .uri("/MalformedPattern")
|
4485 4949 | .method("POST")
|
4486 4950 | .header("content-type", "application/json")
|
4487 4951 | .body(::aws_smithy_http_server::body::Body::from(
|
4488 - | ::bytes::Bytes::from_static("{ \"minShort\" : 3 }".as_bytes()),
|
4952 + | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"xyz\" } }".as_bytes()),
|
4489 4953 | ))
|
4490 4954 | .unwrap();
|
4491 4955 | #[allow(unused_mut)]
|
4492 4956 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4493 4957 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4494 4958 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4495 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
4959 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4496 4960 | let sender = sender.clone();
|
4497 4961 | async move {
|
4498 - | 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> };
|
4962 + | 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> };
|
4499 4963 | sender.send(()).await.expect("receiver dropped early");
|
4500 4964 | result
|
4501 4965 | }
|
4502 4966 | })
|
4503 4967 | .build_unchecked();
|
4504 4968 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4505 4969 | .await
|
4506 4970 | .expect("unable to make an HTTP request");
|
4507 4971 | ::pretty_assertions::assert_eq!(
|
4508 4972 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4509 4973 | http_response.status()
|
4510 4974 | );
|
4511 4975 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4512 4976 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4513 4977 | http_response.headers(),
|
4514 4978 | expected_headers,
|
4515 4979 | ));
|
4516 4980 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4517 4981 | .await
|
4518 4982 | .expect("unable to extract body to bytes");
|
4519 4983 | ::aws_smithy_protocol_test::assert_ok(
|
4520 - | ::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"))
|
4984 + | ::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"))
|
4521 4985 | );
|
4522 4986 | }
|
4523 4987 | }
|
4524 - | /// When a short member does not fit within range bounds,
|
4988 + | /// When a union member's value does not match the specified pattern,
|
4525 4989 | /// the response should be a 400 ValidationException.
|
4526 - | /// Test ID: RestJsonMalformedRangeMaxShortOverride
|
4990 + | /// Test ID: RestJsonMalformedPatternUnion_case0
|
4527 4991 | #[::tokio::test]
|
4528 - | async fn rest_json_malformed_range_max_short_override_malformed_request() {
|
4992 + | #[::tracing_test::traced_test]
|
4993 + | async fn rest_json_malformed_pattern_union_case0_malformed_request() {
|
4529 4994 | {
|
4530 4995 | #[allow(unused_mut)]
|
4531 4996 | let mut http_request = http::Request::builder()
|
4532 - | .uri("/MalformedRangeOverride")
|
4997 + | .uri("/MalformedPattern")
|
4533 4998 | .method("POST")
|
4534 4999 | .header("content-type", "application/json")
|
4535 5000 | .body(::aws_smithy_http_server::body::Body::from(
|
4536 - | ::bytes::Bytes::from_static("{ \"maxShort\" : 7 }".as_bytes()),
|
5001 + | ::bytes::Bytes::from_static(
|
5002 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
5003 + | ),
|
4537 5004 | ))
|
4538 5005 | .unwrap();
|
4539 5006 | #[allow(unused_mut)]
|
4540 5007 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4541 5008 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4542 5009 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4543 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5010 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4544 5011 | let sender = sender.clone();
|
4545 5012 | async move {
|
4546 - | 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> };
|
5013 + | 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> };
|
4547 5014 | sender.send(()).await.expect("receiver dropped early");
|
4548 5015 | result
|
4549 5016 | }
|
4550 5017 | })
|
4551 5018 | .build_unchecked();
|
4552 5019 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4553 5020 | .await
|
4554 5021 | .expect("unable to make an HTTP request");
|
4555 5022 | ::pretty_assertions::assert_eq!(
|
4556 5023 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4557 5024 | http_response.status()
|
4558 5025 | );
|
4559 5026 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4560 5027 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4561 5028 | http_response.headers(),
|
4562 5029 | expected_headers,
|
4563 5030 | ));
|
4564 5031 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4565 5032 | .await
|
4566 5033 | .expect("unable to extract body to bytes");
|
4567 5034 | ::aws_smithy_protocol_test::assert_ok(
|
4568 - | ::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"))
|
5035 + | ::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"))
|
4569 5036 | );
|
4570 5037 | }
|
4571 5038 | }
|
4572 - | /// When a integer member does not fit within range bounds,
|
5039 + | /// When a union member's value does not match the specified pattern,
|
4573 5040 | /// the response should be a 400 ValidationException.
|
4574 - | /// Test ID: RestJsonMalformedRangeIntegerOverride_case0
|
5041 + | /// Test ID: RestJsonMalformedPatternUnion_case1
|
4575 5042 | #[::tokio::test]
|
4576 - | async fn rest_json_malformed_range_integer_override_case0_malformed_request() {
|
5043 + | #[::tracing_test::traced_test]
|
5044 + | async fn rest_json_malformed_pattern_union_case1_malformed_request() {
|
4577 5045 | {
|
4578 5046 | #[allow(unused_mut)]
|
4579 5047 | let mut http_request = http::Request::builder()
|
4580 - | .uri("/MalformedRangeOverride")
|
5048 + | .uri("/MalformedPattern")
|
4581 5049 | .method("POST")
|
4582 5050 | .header("content-type", "application/json")
|
4583 5051 | .body(::aws_smithy_http_server::body::Body::from(
|
4584 - | ::bytes::Bytes::from_static("{ \"integer\" : 3 }".as_bytes()),
|
5052 + | ::bytes::Bytes::from_static(
|
5053 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
5054 + | ),
|
4585 5055 | ))
|
4586 5056 | .unwrap();
|
4587 5057 | #[allow(unused_mut)]
|
4588 5058 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4589 5059 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4590 5060 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4591 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5061 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
4592 5062 | let sender = sender.clone();
|
4593 5063 | async move {
|
4594 - | 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> };
|
5064 + | 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> };
|
4595 5065 | sender.send(()).await.expect("receiver dropped early");
|
4596 5066 | result
|
4597 5067 | }
|
4598 5068 | })
|
4599 5069 | .build_unchecked();
|
4600 5070 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4601 5071 | .await
|
4602 5072 | .expect("unable to make an HTTP request");
|
4603 5073 | ::pretty_assertions::assert_eq!(
|
4604 5074 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4605 5075 | http_response.status()
|
4606 5076 | );
|
4607 5077 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4608 5078 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4609 5079 | http_response.headers(),
|
4610 5080 | expected_headers,
|
4611 5081 | ));
|
4612 5082 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4613 5083 | .await
|
4614 5084 | .expect("unable to extract body to bytes");
|
4615 5085 | ::aws_smithy_protocol_test::assert_ok(
|
4616 - | ::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"))
|
5086 + | ::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"))
|
4617 5087 | );
|
4618 5088 | }
|
4619 5089 | }
|
4620 - | /// When a integer member does not fit within range bounds,
|
4621 - | /// the response should be a 400 ValidationException.
|
4622 - | /// Test ID: RestJsonMalformedRangeIntegerOverride_case1
|
4623 - | #[::tokio::test]
|
4624 - | async fn rest_json_malformed_range_integer_override_case1_malformed_request() {
|
4625 - | {
|
4626 - | #[allow(unused_mut)]
|
4627 - | let mut http_request = http::Request::builder()
|
4628 - | .uri("/MalformedRangeOverride")
|
4629 - | .method("POST")
|
4630 - | .header("content-type", "application/json")
|
4631 - | .body(::aws_smithy_http_server::body::Body::from(
|
4632 - | ::bytes::Bytes::from_static("{ \"integer\" : 7 }".as_bytes()),
|
4633 - | ))
|
4634 - | .unwrap();
|
4635 - | #[allow(unused_mut)]
|
4636 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4637 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4638 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4639 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5090 + | }
|
5091 + |
|
5092 + | const CONTENT_TYPE_MALFORMEDLENGTHQUERYSTRING: ::mime::Mime = ::mime::APPLICATION_JSON;
|
5093 + | ::pin_project_lite::pin_project! {
|
5094 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5095 + | /// [`MalformedLengthQueryStringInput`](crate::input::MalformedLengthQueryStringInput) using modelled bindings.
|
5096 + | pub struct MalformedLengthQueryStringInputFuture {
|
5097 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthQueryStringInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
5098 + | }
|
5099 + | }
|
5100 + |
|
5101 + | impl std::future::Future for MalformedLengthQueryStringInputFuture {
|
5102 + | type Output = Result<
|
5103 + | crate::input::MalformedLengthQueryStringInput,
|
5104 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5105 + | >;
|
5106 + |
|
5107 + | fn poll(
|
5108 + | self: std::pin::Pin<&mut Self>,
|
5109 + | cx: &mut std::task::Context<'_>,
|
5110 + | ) -> std::task::Poll<Self::Output> {
|
5111 + | let this = self.project();
|
5112 + | this.inner.as_mut().poll(cx)
|
5113 + | }
|
5114 + | }
|
5115 + |
|
5116 + | impl<B>
|
5117 + | ::aws_smithy_http_server::request::FromRequest<
|
5118 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5119 + | B,
|
5120 + | > for crate::input::MalformedLengthQueryStringInput
|
5121 + | where
|
5122 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5123 + | B: 'static,
|
5124 + |
|
5125 + | B::Data: Send,
|
5126 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5127 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5128 + | {
|
5129 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5130 + | type Future = MalformedLengthQueryStringInputFuture;
|
5131 + |
|
5132 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5133 + | let fut = async move {
|
5134 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5135 + | request.headers(),
|
5136 + | &CONTENT_TYPE_MALFORMEDLENGTHQUERYSTRING,
|
5137 + | ) {
|
5138 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5139 + | }
|
5140 + | crate::protocol_serde::shape_malformed_length_query_string::de_malformed_length_query_string_http_request(request)
|
5141 + | .await
|
5142 + | .map_err(Into::into)
|
5143 + | };
|
5144 + | use ::futures_util::future::TryFutureExt;
|
5145 + | let fut = fut.map_err(
|
5146 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5147 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5148 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
5149 + | e,
|
5150 + | )
|
5151 + | },
|
5152 + | );
|
5153 + | MalformedLengthQueryStringInputFuture {
|
5154 + | inner: Box::pin(fut),
|
5155 + | }
|
5156 + | }
|
5157 + | }
|
5158 + | impl
|
5159 + | ::aws_smithy_http_server::response::IntoResponse<
|
5160 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5161 + | > for crate::output::MalformedLengthQueryStringOutput
|
5162 + | {
|
5163 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5164 + | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_response(self) {
|
5165 + | Ok(response) => response,
|
5166 + | Err(e) => {
|
5167 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5168 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5169 + | }
|
5170 + | }
|
5171 + | }
|
5172 + | }
|
5173 + | impl
|
5174 + | ::aws_smithy_http_server::response::IntoResponse<
|
5175 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5176 + | > for crate::error::MalformedLengthQueryStringError
|
5177 + | {
|
5178 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5179 + | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_error(&self) {
|
5180 + | Ok(mut response) => {
|
5181 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
5182 + | response
|
5183 + | },
|
5184 + | Err(e) => {
|
5185 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5186 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5187 + | }
|
5188 + | }
|
5189 + | }
|
5190 + | }
|
5191 + |
|
5192 + | #[allow(unreachable_code, unused_variables)]
|
5193 + | #[cfg(test)]
|
5194 + | mod malformed_length_query_string_test {
|
5195 + |
|
5196 + | /// When a required member has no value in the query string,
|
5197 + | /// the response should be a 400 ValidationException.
|
5198 + | /// Test ID: RestJsonMalformedLengthQueryStringNoValue
|
5199 + | #[::tokio::test]
|
5200 + | #[::tracing_test::traced_test]
|
5201 + | async fn rest_json_malformed_length_query_string_no_value_malformed_request() {
|
5202 + | {
|
5203 + | #[allow(unused_mut)]
|
5204 + | let mut http_request = http::Request::builder()
|
5205 + | .uri("/MalformedLengthQueryString")
|
5206 + | .method("POST")
|
5207 + | .header("content-type", "application/json")
|
5208 + | .body(::aws_smithy_http_server::body::Body::from(
|
5209 + | ::bytes::Bytes::from_static("{}".as_bytes()),
|
5210 + | ))
|
5211 + | .unwrap();
|
5212 + | *http_request.uri_mut() = "/MalformedLengthQueryString?string".parse().unwrap();
|
5213 + | #[allow(unused_mut)]
|
5214 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5215 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5216 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5217 + | .malformed_length_query_string(move |input: crate::input::MalformedLengthQueryStringInput| {
|
4640 5218 | let sender = sender.clone();
|
4641 5219 | async move {
|
4642 - | 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> };
|
5220 + | 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> };
|
4643 5221 | sender.send(()).await.expect("receiver dropped early");
|
4644 5222 | result
|
4645 5223 | }
|
4646 5224 | })
|
4647 5225 | .build_unchecked();
|
4648 5226 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4649 5227 | .await
|
4650 5228 | .expect("unable to make an HTTP request");
|
4651 5229 | ::pretty_assertions::assert_eq!(
|
4652 5230 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4653 5231 | http_response.status()
|
4654 5232 | );
|
4655 5233 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4656 5234 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4657 5235 | http_response.headers(),
|
4658 5236 | expected_headers,
|
4659 5237 | ));
|
4660 5238 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4661 5239 | .await
|
4662 5240 | .expect("unable to extract body to bytes");
|
4663 5241 | ::aws_smithy_protocol_test::assert_ok(
|
4664 - | ::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"))
|
5242 + | ::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"))
|
4665 5243 | );
|
4666 5244 | }
|
4667 5245 | }
|
4668 - | /// When a integer member does not fit within range bounds,
|
5246 + | }
|
5247 + |
|
5248 + | const CONTENT_TYPE_MALFORMEDLENGTHOVERRIDE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
5249 + | ::pin_project_lite::pin_project! {
|
5250 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5251 + | /// [`MalformedLengthOverrideInput`](crate::input::MalformedLengthOverrideInput) using modelled bindings.
|
5252 + | pub struct MalformedLengthOverrideInputFuture {
|
5253 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthOverrideInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
5254 + | }
|
5255 + | }
|
5256 + |
|
5257 + | impl std::future::Future for MalformedLengthOverrideInputFuture {
|
5258 + | type Output = Result<
|
5259 + | crate::input::MalformedLengthOverrideInput,
|
5260 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5261 + | >;
|
5262 + |
|
5263 + | fn poll(
|
5264 + | self: std::pin::Pin<&mut Self>,
|
5265 + | cx: &mut std::task::Context<'_>,
|
5266 + | ) -> std::task::Poll<Self::Output> {
|
5267 + | let this = self.project();
|
5268 + | this.inner.as_mut().poll(cx)
|
5269 + | }
|
5270 + | }
|
5271 + |
|
5272 + | impl<B>
|
5273 + | ::aws_smithy_http_server::request::FromRequest<
|
5274 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5275 + | B,
|
5276 + | > for crate::input::MalformedLengthOverrideInput
|
5277 + | where
|
5278 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5279 + | B: 'static,
|
5280 + |
|
5281 + | B::Data: Send,
|
5282 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5283 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5284 + | {
|
5285 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5286 + | type Future = MalformedLengthOverrideInputFuture;
|
5287 + |
|
5288 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5289 + | let fut = async move {
|
5290 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5291 + | request.headers(),
|
5292 + | &CONTENT_TYPE_MALFORMEDLENGTHOVERRIDE,
|
5293 + | ) {
|
5294 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5295 + | }
|
5296 + | crate::protocol_serde::shape_malformed_length_override::de_malformed_length_override_http_request(request)
|
5297 + | .await
|
5298 + | .map_err(Into::into)
|
5299 + | };
|
5300 + | use ::futures_util::future::TryFutureExt;
|
5301 + | let fut = fut.map_err(
|
5302 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5303 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5304 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
5305 + | e,
|
5306 + | )
|
5307 + | },
|
5308 + | );
|
5309 + | MalformedLengthOverrideInputFuture {
|
5310 + | inner: Box::pin(fut),
|
5311 + | }
|
5312 + | }
|
5313 + | }
|
5314 + | impl
|
5315 + | ::aws_smithy_http_server::response::IntoResponse<
|
5316 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5317 + | > for crate::output::MalformedLengthOverrideOutput
|
5318 + | {
|
5319 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5320 + | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_response(self) {
|
5321 + | Ok(response) => response,
|
5322 + | Err(e) => {
|
5323 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5324 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5325 + | }
|
5326 + | }
|
5327 + | }
|
5328 + | }
|
5329 + | impl
|
5330 + | ::aws_smithy_http_server::response::IntoResponse<
|
5331 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5332 + | > for crate::error::MalformedLengthOverrideError
|
5333 + | {
|
5334 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5335 + | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_error(&self) {
|
5336 + | Ok(mut response) => {
|
5337 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
5338 + | response
|
5339 + | },
|
5340 + | Err(e) => {
|
5341 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5342 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5343 + | }
|
5344 + | }
|
5345 + | }
|
5346 + | }
|
5347 + |
|
5348 + | #[allow(unreachable_code, unused_variables)]
|
5349 + | #[cfg(test)]
|
5350 + | mod malformed_length_override_test {
|
5351 + |
|
5352 + | /// When a blob member does not fit within length bounds,
|
4669 5353 | /// the response should be a 400 ValidationException.
|
4670 - | /// Test ID: RestJsonMalformedRangeMinIntegerOverride
|
5354 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case0
|
4671 5355 | #[::tokio::test]
|
4672 - | async fn rest_json_malformed_range_min_integer_override_malformed_request() {
|
5356 + | #[::tracing_test::traced_test]
|
5357 + | async fn rest_json_malformed_length_blob_override_case0_malformed_request() {
|
4673 5358 | {
|
4674 5359 | #[allow(unused_mut)]
|
4675 5360 | let mut http_request = http::Request::builder()
|
4676 - | .uri("/MalformedRangeOverride")
|
5361 + | .uri("/MalformedLengthOverride")
|
4677 5362 | .method("POST")
|
4678 5363 | .header("content-type", "application/json")
|
4679 5364 | .body(::aws_smithy_http_server::body::Body::from(
|
4680 - | ::bytes::Bytes::from_static("{ \"minInteger\" : 3 }".as_bytes()),
|
5365 + | ::bytes::Bytes::from_static("{ \"blob\" : \"YWJj\" }".as_bytes()),
|
4681 5366 | ))
|
4682 5367 | .unwrap();
|
4683 5368 | #[allow(unused_mut)]
|
4684 5369 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4685 5370 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4686 5371 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4687 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5372 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
4688 5373 | let sender = sender.clone();
|
4689 5374 | async move {
|
4690 - | 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> };
|
5375 + | 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> };
|
4691 5376 | sender.send(()).await.expect("receiver dropped early");
|
4692 5377 | result
|
4693 5378 | }
|
4694 5379 | })
|
4695 5380 | .build_unchecked();
|
4696 5381 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4697 5382 | .await
|
4698 5383 | .expect("unable to make an HTTP request");
|
4699 5384 | ::pretty_assertions::assert_eq!(
|
4700 5385 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4701 5386 | http_response.status()
|
4702 5387 | );
|
4703 5388 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4704 5389 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4705 5390 | http_response.headers(),
|
4706 5391 | expected_headers,
|
4707 5392 | ));
|
4708 5393 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4709 5394 | .await
|
4710 5395 | .expect("unable to extract body to bytes");
|
4711 5396 | ::aws_smithy_protocol_test::assert_ok(
|
4712 - | ::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"))
|
5397 + | ::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"))
|
4713 5398 | );
|
4714 5399 | }
|
4715 5400 | }
|
4716 - | /// When a integer member does not fit within range bounds,
|
5401 + | /// When a blob member does not fit within length bounds,
|
4717 5402 | /// the response should be a 400 ValidationException.
|
4718 - | /// Test ID: RestJsonMalformedRangeMaxIntegerOverride
|
5403 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case1
|
4719 5404 | #[::tokio::test]
|
4720 - | async fn rest_json_malformed_range_max_integer_override_malformed_request() {
|
5405 + | #[::tracing_test::traced_test]
|
5406 + | async fn rest_json_malformed_length_blob_override_case1_malformed_request() {
|
4721 5407 | {
|
4722 5408 | #[allow(unused_mut)]
|
4723 5409 | let mut http_request = http::Request::builder()
|
4724 - | .uri("/MalformedRangeOverride")
|
5410 + | .uri("/MalformedLengthOverride")
|
4725 5411 | .method("POST")
|
4726 5412 | .header("content-type", "application/json")
|
4727 5413 | .body(::aws_smithy_http_server::body::Body::from(
|
4728 - | ::bytes::Bytes::from_static("{ \"maxInteger\" : 7 }".as_bytes()),
|
5414 + | ::bytes::Bytes::from_static("{ \"blob\" : \"YWJjZGVmZw==\" }".as_bytes()),
|
4729 5415 | ))
|
4730 5416 | .unwrap();
|
4731 5417 | #[allow(unused_mut)]
|
4732 5418 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4733 5419 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4734 5420 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4735 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5421 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
4736 5422 | let sender = sender.clone();
|
4737 5423 | async move {
|
4738 - | 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> };
|
5424 + | 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> };
|
4739 5425 | sender.send(()).await.expect("receiver dropped early");
|
4740 5426 | result
|
4741 5427 | }
|
4742 5428 | })
|
4743 5429 | .build_unchecked();
|
4744 5430 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4745 5431 | .await
|
4746 5432 | .expect("unable to make an HTTP request");
|
4747 5433 | ::pretty_assertions::assert_eq!(
|
4748 5434 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4749 5435 | http_response.status()
|
4750 5436 | );
|
4751 5437 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4752 5438 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4753 5439 | http_response.headers(),
|
4754 5440 | expected_headers,
|
4755 5441 | ));
|
4756 5442 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4757 5443 | .await
|
4758 5444 | .expect("unable to extract body to bytes");
|
4759 5445 | ::aws_smithy_protocol_test::assert_ok(
|
4760 - | ::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"))
|
5446 + | ::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"))
|
4761 5447 | );
|
4762 5448 | }
|
4763 5449 | }
|
4764 - | /// When a long member does not fit within range bounds,
|
5450 + | /// When a string member does not fit within length bounds,
|
4765 5451 | /// the response should be a 400 ValidationException.
|
4766 - | /// Test ID: RestJsonMalformedRangeLongOverride_case0
|
5452 + | /// Test ID: RestJsonMalformedLengthStringOverride_case0
|
4767 5453 | #[::tokio::test]
|
4768 - | async fn rest_json_malformed_range_long_override_case0_malformed_request() {
|
5454 + | #[::tracing_test::traced_test]
|
5455 + | async fn rest_json_malformed_length_string_override_case0_malformed_request() {
|
4769 5456 | {
|
4770 5457 | #[allow(unused_mut)]
|
4771 5458 | let mut http_request = http::Request::builder()
|
4772 - | .uri("/MalformedRangeOverride")
|
5459 + | .uri("/MalformedLengthOverride")
|
4773 5460 | .method("POST")
|
4774 5461 | .header("content-type", "application/json")
|
4775 5462 | .body(::aws_smithy_http_server::body::Body::from(
|
4776 - | ::bytes::Bytes::from_static("{ \"long\" : 3 }".as_bytes()),
|
5463 + | ::bytes::Bytes::from_static("{ \"string\" : \"abc\" }".as_bytes()),
|
4777 5464 | ))
|
4778 5465 | .unwrap();
|
4779 5466 | #[allow(unused_mut)]
|
4780 5467 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4781 5468 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4782 5469 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4783 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5470 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
4784 5471 | let sender = sender.clone();
|
4785 5472 | async move {
|
4786 - | 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> };
|
5473 + | 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> };
|
4787 5474 | sender.send(()).await.expect("receiver dropped early");
|
4788 5475 | result
|
4789 5476 | }
|
4790 5477 | })
|
4791 5478 | .build_unchecked();
|
4792 5479 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4793 5480 | .await
|
4794 5481 | .expect("unable to make an HTTP request");
|
4795 5482 | ::pretty_assertions::assert_eq!(
|
4796 5483 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4797 5484 | http_response.status()
|
4798 5485 | );
|
4799 5486 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4800 5487 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4801 5488 | http_response.headers(),
|
4802 5489 | expected_headers,
|
4803 5490 | ));
|
4804 5491 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4805 5492 | .await
|
4806 5493 | .expect("unable to extract body to bytes");
|
4807 5494 | ::aws_smithy_protocol_test::assert_ok(
|
4808 - | ::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"))
|
5495 + | ::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"))
|
4809 5496 | );
|
4810 5497 | }
|
4811 5498 | }
|
4812 - | /// When a long member does not fit within range bounds,
|
5499 + | /// When a string member does not fit within length bounds,
|
4813 5500 | /// the response should be a 400 ValidationException.
|
4814 - | /// Test ID: RestJsonMalformedRangeLongOverride_case1
|
5501 + | /// Test ID: RestJsonMalformedLengthStringOverride_case1
|
4815 5502 | #[::tokio::test]
|
4816 - | async fn rest_json_malformed_range_long_override_case1_malformed_request() {
|
5503 + | #[::tracing_test::traced_test]
|
5504 + | async fn rest_json_malformed_length_string_override_case1_malformed_request() {
|
4817 5505 | {
|
4818 5506 | #[allow(unused_mut)]
|
4819 5507 | let mut http_request = http::Request::builder()
|
4820 - | .uri("/MalformedRangeOverride")
|
5508 + | .uri("/MalformedLengthOverride")
|
4821 5509 | .method("POST")
|
4822 5510 | .header("content-type", "application/json")
|
4823 5511 | .body(::aws_smithy_http_server::body::Body::from(
|
4824 - | ::bytes::Bytes::from_static("{ \"long\" : 7 }".as_bytes()),
|
5512 + | ::bytes::Bytes::from_static("{ \"string\" : \"abcdefg\" }".as_bytes()),
|
4825 5513 | ))
|
4826 5514 | .unwrap();
|
4827 5515 | #[allow(unused_mut)]
|
4828 5516 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4829 5517 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4830 5518 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4831 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5519 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
4832 5520 | let sender = sender.clone();
|
4833 5521 | async move {
|
4834 - | 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> };
|
5522 + | 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> };
|
4835 5523 | sender.send(()).await.expect("receiver dropped early");
|
4836 5524 | result
|
4837 5525 | }
|
4838 5526 | })
|
4839 5527 | .build_unchecked();
|
4840 5528 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4841 5529 | .await
|
4842 5530 | .expect("unable to make an HTTP request");
|
4843 5531 | ::pretty_assertions::assert_eq!(
|
4844 5532 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4845 5533 | http_response.status()
|
4846 5534 | );
|
4847 5535 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4848 5536 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4849 5537 | http_response.headers(),
|
4850 5538 | expected_headers,
|
4851 5539 | ));
|
4852 5540 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4853 5541 | .await
|
4854 5542 | .expect("unable to extract body to bytes");
|
4855 5543 | ::aws_smithy_protocol_test::assert_ok(
|
4856 - | ::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"))
|
5544 + | ::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"))
|
4857 5545 | );
|
4858 5546 | }
|
4859 5547 | }
|
4860 - | /// When a long member does not fit within range bounds,
|
5548 + | /// When a string member does not fit within length bounds,
|
4861 5549 | /// the response should be a 400 ValidationException.
|
4862 - | /// Test ID: RestJsonMalformedRangeMinLongOverride
|
5550 + | /// Test ID: RestJsonMalformedLengthStringOverride_case2
|
4863 5551 | #[::tokio::test]
|
4864 - | async fn rest_json_malformed_range_min_long_override_malformed_request() {
|
5552 + | #[::tracing_test::traced_test]
|
5553 + | async fn rest_json_malformed_length_string_override_case2_malformed_request() {
|
4865 5554 | {
|
4866 5555 | #[allow(unused_mut)]
|
4867 5556 | let mut http_request = http::Request::builder()
|
4868 - | .uri("/MalformedRangeOverride")
|
5557 + | .uri("/MalformedLengthOverride")
|
4869 5558 | .method("POST")
|
4870 5559 | .header("content-type", "application/json")
|
4871 5560 | .body(::aws_smithy_http_server::body::Body::from(
|
4872 - | ::bytes::Bytes::from_static("{ \"minLong\" : 3 }".as_bytes()),
|
5561 + | ::bytes::Bytes::from_static("{ \"string\" : \"👍👍👍\" }".as_bytes()),
|
4873 5562 | ))
|
4874 5563 | .unwrap();
|
4875 5564 | #[allow(unused_mut)]
|
4876 5565 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4877 5566 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4878 5567 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4879 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5568 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
4880 5569 | let sender = sender.clone();
|
4881 5570 | async move {
|
4882 - | 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> };
|
5571 + | 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> };
|
4883 5572 | sender.send(()).await.expect("receiver dropped early");
|
4884 5573 | result
|
4885 5574 | }
|
4886 5575 | })
|
4887 5576 | .build_unchecked();
|
4888 5577 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4889 5578 | .await
|
4890 5579 | .expect("unable to make an HTTP request");
|
4891 5580 | ::pretty_assertions::assert_eq!(
|
4892 5581 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4893 5582 | http_response.status()
|
4894 5583 | );
|
4895 5584 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4896 5585 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4897 5586 | http_response.headers(),
|
4898 5587 | expected_headers,
|
4899 5588 | ));
|
4900 5589 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4901 5590 | .await
|
4902 5591 | .expect("unable to extract body to bytes");
|
4903 5592 | ::aws_smithy_protocol_test::assert_ok(
|
4904 - | ::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"))
|
5593 + | ::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"))
|
4905 5594 | );
|
4906 5595 | }
|
4907 5596 | }
|
4908 - | /// When a long member does not fit within range bounds,
|
5597 + | /// When a string member does not fit within length bounds,
|
4909 5598 | /// the response should be a 400 ValidationException.
|
4910 - | /// Test ID: RestJsonMalformedRangeMaxLongOverride
|
5599 + | /// Test ID: RestJsonMalformedLengthMinStringOverride
|
4911 5600 | #[::tokio::test]
|
4912 - | async fn rest_json_malformed_range_max_long_override_malformed_request() {
|
5601 + | #[::tracing_test::traced_test]
|
5602 + | async fn rest_json_malformed_length_min_string_override_malformed_request() {
|
4913 5603 | {
|
4914 5604 | #[allow(unused_mut)]
|
4915 5605 | let mut http_request = http::Request::builder()
|
4916 - | .uri("/MalformedRangeOverride")
|
5606 + | .uri("/MalformedLengthOverride")
|
4917 5607 | .method("POST")
|
4918 5608 | .header("content-type", "application/json")
|
4919 5609 | .body(::aws_smithy_http_server::body::Body::from(
|
4920 - | ::bytes::Bytes::from_static("{ \"maxLong\" : 7 }".as_bytes()),
|
5610 + | ::bytes::Bytes::from_static("{ \"minString\" : \"abc\" }".as_bytes()),
|
4921 5611 | ))
|
4922 5612 | .unwrap();
|
4923 5613 | #[allow(unused_mut)]
|
4924 5614 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4925 5615 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4926 5616 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4927 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5617 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
4928 5618 | let sender = sender.clone();
|
4929 5619 | async move {
|
4930 - | 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> };
|
5620 + | 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> };
|
4931 5621 | sender.send(()).await.expect("receiver dropped early");
|
4932 5622 | result
|
4933 5623 | }
|
4934 5624 | })
|
4935 5625 | .build_unchecked();
|
4936 5626 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4937 5627 | .await
|
4938 5628 | .expect("unable to make an HTTP request");
|
4939 5629 | ::pretty_assertions::assert_eq!(
|
4940 5630 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4941 5631 | http_response.status()
|
4942 5632 | );
|
4943 5633 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4944 5634 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4945 5635 | http_response.headers(),
|
4946 5636 | expected_headers,
|
4947 5637 | ));
|
4948 5638 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
4949 5639 | .await
|
4950 5640 | .expect("unable to extract body to bytes");
|
4951 5641 | ::aws_smithy_protocol_test::assert_ok(
|
4952 - | ::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"))
|
5642 + | ::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"))
|
4953 5643 | );
|
4954 5644 | }
|
4955 5645 | }
|
4956 - | }
|
4957 - | #[cfg(test)]
|
4958 - | #[allow(unreachable_code, unused_variables)]
|
4959 - | mod server_malformed_required_test {
|
4960 - | /// When a required member is not set in the message body,
|
5646 + | /// When a string member does not fit within length bounds,
|
4961 5647 | /// the response should be a 400 ValidationException.
|
4962 - | /// Test ID: RestJsonMalformedRequiredBodyUnset
|
5648 + | /// Test ID: RestJsonMalformedLengthMaxStringOverride
|
4963 5649 | #[::tokio::test]
|
4964 - | async fn rest_json_malformed_required_body_unset_malformed_request() {
|
5650 + | #[::tracing_test::traced_test]
|
5651 + | async fn rest_json_malformed_length_max_string_override_malformed_request() {
|
4965 5652 | {
|
4966 5653 | #[allow(unused_mut)]
|
4967 5654 | let mut http_request = http::Request::builder()
|
4968 - | .uri("/MalformedRequired")
|
5655 + | .uri("/MalformedLengthOverride")
|
4969 5656 | .method("POST")
|
4970 5657 | .header("content-type", "application/json")
|
4971 - | .header("string-in-headers", "abc")
|
4972 5658 | .body(::aws_smithy_http_server::body::Body::from(
|
4973 - | ::bytes::Bytes::from_static("{ }".as_bytes()),
|
5659 + | ::bytes::Bytes::from_static("{ \"maxString\" : \"abcdefg\" }".as_bytes()),
|
4974 5660 | ))
|
4975 5661 | .unwrap();
|
4976 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
4977 5662 | #[allow(unused_mut)]
|
4978 5663 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4979 5664 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4980 5665 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
4981 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
5666 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
4982 5667 | let sender = sender.clone();
|
4983 5668 | async move {
|
4984 - | 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> };
|
5669 + | 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> };
|
4985 5670 | sender.send(()).await.expect("receiver dropped early");
|
4986 5671 | result
|
4987 5672 | }
|
4988 5673 | })
|
4989 5674 | .build_unchecked();
|
4990 5675 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4991 5676 | .await
|
4992 5677 | .expect("unable to make an HTTP request");
|
4993 5678 | ::pretty_assertions::assert_eq!(
|
4994 5679 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4995 5680 | http_response.status()
|
4996 5681 | );
|
4997 5682 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4998 5683 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4999 5684 | http_response.headers(),
|
5000 5685 | expected_headers,
|
5001 5686 | ));
|
5002 5687 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5003 5688 | .await
|
5004 5689 | .expect("unable to extract body to bytes");
|
5005 5690 | ::aws_smithy_protocol_test::assert_ok(
|
5006 - | ::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"))
|
5691 + | ::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"))
|
5007 5692 | );
|
5008 5693 | }
|
5009 5694 | }
|
5010 - | /// When a required member is set to null in the message body,
|
5695 + | /// When a list member does not fit within length bounds,
|
5011 5696 | /// the response should be a 400 ValidationException.
|
5012 - | /// Test ID: RestJsonMalformedRequiredBodyExplicitNull
|
5697 + | /// Test ID: RestJsonMalformedLengthListOverride_case0
|
5013 5698 | #[::tokio::test]
|
5014 - | async fn rest_json_malformed_required_body_explicit_null_malformed_request() {
|
5699 + | #[::tracing_test::traced_test]
|
5700 + | async fn rest_json_malformed_length_list_override_case0_malformed_request() {
|
5015 5701 | {
|
5016 5702 | #[allow(unused_mut)]
|
5017 5703 | let mut http_request = http::Request::builder()
|
5018 - | .uri("/MalformedRequired")
|
5704 + | .uri("/MalformedLengthOverride")
|
5019 5705 | .method("POST")
|
5020 5706 | .header("content-type", "application/json")
|
5021 - | .header("string-in-headers", "abc")
|
5022 5707 | .body(::aws_smithy_http_server::body::Body::from(
|
5023 - | ::bytes::Bytes::from_static("{ \"string\": null }".as_bytes()),
|
5708 + | ::bytes::Bytes::from_static(
|
5709 + | "{ \"list\" : [\"abc\", \"def\", \"ghi\"] }".as_bytes(),
|
5710 + | ),
|
5024 5711 | ))
|
5025 5712 | .unwrap();
|
5026 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
5027 5713 | #[allow(unused_mut)]
|
5028 5714 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5029 5715 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5030 5716 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5031 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
5717 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5032 5718 | let sender = sender.clone();
|
5033 5719 | async move {
|
5034 - | 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> };
|
5720 + | 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> };
|
5035 5721 | sender.send(()).await.expect("receiver dropped early");
|
5036 5722 | result
|
5037 5723 | }
|
5038 5724 | })
|
5039 5725 | .build_unchecked();
|
5040 5726 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5041 5727 | .await
|
5042 5728 | .expect("unable to make an HTTP request");
|
5043 5729 | ::pretty_assertions::assert_eq!(
|
5044 5730 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5045 5731 | http_response.status()
|
5046 5732 | );
|
5047 5733 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5048 5734 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5049 5735 | http_response.headers(),
|
5050 5736 | expected_headers,
|
5051 5737 | ));
|
5052 5738 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5053 5739 | .await
|
5054 5740 | .expect("unable to extract body to bytes");
|
5055 5741 | ::aws_smithy_protocol_test::assert_ok(
|
5056 - | ::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"))
|
5742 + | ::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"))
|
5057 5743 | );
|
5058 5744 | }
|
5059 5745 | }
|
5060 - | /// When a required member is not set in headers,
|
5746 + | /// When a list member does not fit within length bounds,
|
5061 5747 | /// the response should be a 400 ValidationException.
|
5062 - | /// Test ID: RestJsonMalformedRequiredHeaderUnset
|
5748 + | /// Test ID: RestJsonMalformedLengthListOverride_case1
|
5063 5749 | #[::tokio::test]
|
5064 - | async fn rest_json_malformed_required_header_unset_malformed_request() {
|
5750 + | #[::tracing_test::traced_test]
|
5751 + | async fn rest_json_malformed_length_list_override_case1_malformed_request() {
|
5065 5752 | {
|
5066 5753 | #[allow(unused_mut)]
|
5067 5754 | let mut http_request = http::Request::builder()
|
5068 - | .uri("/MalformedRequired")
|
5755 + | .uri("/MalformedLengthOverride")
|
5069 5756 | .method("POST")
|
5070 5757 | .header("content-type", "application/json")
|
5071 - | .body(::aws_smithy_http_server::body::Body::from(
|
5072 - | ::bytes::Bytes::from_static("{ \"string\": \"abc\" }".as_bytes()),
|
5073 - | ))
|
5074 - | .unwrap();
|
5075 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
5758 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes()))).unwrap();
|
5076 5759 | #[allow(unused_mut)]
|
5077 5760 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5078 5761 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5079 5762 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5080 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
5763 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5081 5764 | let sender = sender.clone();
|
5082 5765 | async move {
|
5083 - | 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> };
|
5766 + | 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> };
|
5084 5767 | sender.send(()).await.expect("receiver dropped early");
|
5085 5768 | result
|
5086 5769 | }
|
5087 5770 | })
|
5088 5771 | .build_unchecked();
|
5089 5772 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5090 5773 | .await
|
5091 5774 | .expect("unable to make an HTTP request");
|
5092 5775 | ::pretty_assertions::assert_eq!(
|
5093 5776 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5094 5777 | http_response.status()
|
5095 5778 | );
|
5096 5779 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5097 5780 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5098 5781 | http_response.headers(),
|
5099 5782 | expected_headers,
|
5100 5783 | ));
|
5101 5784 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5102 5785 | .await
|
5103 5786 | .expect("unable to extract body to bytes");
|
5104 5787 | ::aws_smithy_protocol_test::assert_ok(
|
5105 - | ::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"))
|
5788 + | ::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"))
|
5106 5789 | );
|
5107 5790 | }
|
5108 5791 | }
|
5109 - | }
|
5110 - | #[cfg(test)]
|
5111 - | #[allow(unreachable_code, unused_variables)]
|
5112 - | mod server_malformed_unique_items_test {
|
5113 - | /// When a blob list contains non-unique values,
|
5792 + | /// When a map member does not fit within length bounds,
|
5114 5793 | /// the response should be a 400 ValidationException.
|
5115 - | /// Test ID: RestJsonMalformedUniqueItemsBlobList
|
5794 + | /// Test ID: RestJsonMalformedLengthMapOverride_case0
|
5116 5795 | #[::tokio::test]
|
5117 - | #[should_panic]
|
5118 - | async fn rest_json_malformed_unique_items_blob_list_malformed_request() {
|
5796 + | #[::tracing_test::traced_test]
|
5797 + | async fn rest_json_malformed_length_map_override_case0_malformed_request() {
|
5119 5798 | {
|
5120 5799 | #[allow(unused_mut)]
|
5121 5800 | let mut http_request = http::Request::builder()
|
5122 - | .uri("/MalformedUniqueItems")
|
5801 + | .uri("/MalformedLengthOverride")
|
5123 5802 | .method("POST")
|
5124 5803 | .header("content-type", "application/json")
|
5125 - | .body(::aws_smithy_http_server::body::Body::from(
|
5126 - | ::bytes::Bytes::from_static(
|
5127 - | "{ \"blobList\" : [\"YQ==\", \"YQ==\"] }".as_bytes(),
|
5128 - | ),
|
5129 - | ))
|
5130 - | .unwrap();
|
5804 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
5131 5805 | #[allow(unused_mut)]
|
5132 5806 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5133 5807 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5134 5808 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5135 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
5809 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5136 5810 | let sender = sender.clone();
|
5137 5811 | async move {
|
5138 - | 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> };
|
5812 + | 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> };
|
5139 5813 | sender.send(()).await.expect("receiver dropped early");
|
5140 5814 | result
|
5141 5815 | }
|
5142 5816 | })
|
5143 5817 | .build_unchecked();
|
5144 5818 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5145 5819 | .await
|
5146 5820 | .expect("unable to make an HTTP request");
|
5147 5821 | ::pretty_assertions::assert_eq!(
|
5148 5822 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5149 5823 | http_response.status()
|
5150 5824 | );
|
5151 5825 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5152 5826 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5153 5827 | http_response.headers(),
|
5154 5828 | expected_headers,
|
5155 5829 | ));
|
5156 5830 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5157 5831 | .await
|
5158 5832 | .expect("unable to extract body to bytes");
|
5159 5833 | ::aws_smithy_protocol_test::assert_ok(
|
5160 - | ::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"))
|
5834 + | ::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"))
|
5161 5835 | );
|
5162 5836 | }
|
5163 5837 | }
|
5164 - | /// When a boolean list contains non-unique values,
|
5838 + | /// When a map member does not fit within length bounds,
|
5165 5839 | /// the response should be a 400 ValidationException.
|
5166 - | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case0
|
5840 + | /// Test ID: RestJsonMalformedLengthMapOverride_case1
|
5167 5841 | #[::tokio::test]
|
5168 - | #[should_panic]
|
5169 - | async fn rest_json_malformed_unique_items_boolean_list_case0_malformed_request() {
|
5842 + | #[::tracing_test::traced_test]
|
5843 + | async fn rest_json_malformed_length_map_override_case1_malformed_request() {
|
5170 5844 | {
|
5171 5845 | #[allow(unused_mut)]
|
5172 5846 | let mut http_request = http::Request::builder()
|
5173 - | .uri("/MalformedUniqueItems")
|
5847 + | .uri("/MalformedLengthOverride")
|
5174 5848 | .method("POST")
|
5175 5849 | .header("content-type", "application/json")
|
5176 - | .body(::aws_smithy_http_server::body::Body::from(
|
5177 - | ::bytes::Bytes::from_static("{ \"booleanList\" : [true, true] }".as_bytes()),
|
5178 - | ))
|
5179 - | .unwrap();
|
5850 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"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()))).unwrap();
|
5180 5851 | #[allow(unused_mut)]
|
5181 5852 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5182 5853 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5183 5854 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5184 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
5855 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5185 5856 | let sender = sender.clone();
|
5186 5857 | async move {
|
5187 - | 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> };
|
5858 + | 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> };
|
5188 5859 | sender.send(()).await.expect("receiver dropped early");
|
5189 5860 | result
|
5190 5861 | }
|
5191 5862 | })
|
5192 5863 | .build_unchecked();
|
5193 5864 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5194 5865 | .await
|
5195 5866 | .expect("unable to make an HTTP request");
|
5196 5867 | ::pretty_assertions::assert_eq!(
|
5197 5868 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5198 5869 | http_response.status()
|
5199 5870 | );
|
5200 5871 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5201 5872 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5202 5873 | http_response.headers(),
|
5203 5874 | expected_headers,
|
5204 5875 | ));
|
5205 5876 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5206 5877 | .await
|
5207 5878 | .expect("unable to extract body to bytes");
|
5208 5879 | ::aws_smithy_protocol_test::assert_ok(
|
5209 - | ::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"))
|
5880 + | ::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"))
|
5210 5881 | );
|
5211 5882 | }
|
5212 5883 | }
|
5213 - | /// When a boolean list contains non-unique values,
|
5214 - | /// the response should be a 400 ValidationException.
|
5215 - | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case1
|
5216 - | #[::tokio::test]
|
5217 - | #[should_panic]
|
5218 - | async fn rest_json_malformed_unique_items_boolean_list_case1_malformed_request() {
|
5219 - | {
|
5220 - | #[allow(unused_mut)]
|
5221 - | let mut http_request = http::Request::builder()
|
5222 - | .uri("/MalformedUniqueItems")
|
5223 - | .method("POST")
|
5224 - | .header("content-type", "application/json")
|
5225 - | .body(::aws_smithy_http_server::body::Body::from(
|
5226 - | ::bytes::Bytes::from_static("{ \"booleanList\" : [false, false] }".as_bytes()),
|
5227 - | ))
|
5228 - | .unwrap();
|
5229 - | #[allow(unused_mut)]
|
5230 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5231 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5232 - | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5233 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
5234 - | let sender = sender.clone();
|
5235 - | async move {
|
5236 - | 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> };
|
5237 - | sender.send(()).await.expect("receiver dropped early");
|
5238 - | result
|
5239 - | }
|
5240 - | })
|
5241 - | .build_unchecked();
|
5242 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5243 - | .await
|
5244 - | .expect("unable to make an HTTP request");
|
5245 - | ::pretty_assertions::assert_eq!(
|
5246 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5247 - | http_response.status()
|
5248 - | );
|
5249 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5250 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5251 - | http_response.headers(),
|
5252 - | expected_headers,
|
5253 - | ));
|
5254 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5255 - | .await
|
5256 - | .expect("unable to extract body to bytes");
|
5257 - | ::aws_smithy_protocol_test::assert_ok(
|
5258 - | ::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"))
|
5259 - | );
|
5884 + | }
|
5885 + |
|
5886 + | const CONTENT_TYPE_MALFORMEDLENGTH: ::mime::Mime = ::mime::APPLICATION_JSON;
|
5887 + | ::pin_project_lite::pin_project! {
|
5888 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5889 + | /// [`MalformedLengthInput`](crate::input::MalformedLengthInput) using modelled bindings.
|
5890 + | pub struct MalformedLengthInputFuture {
|
5891 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
5260 5892 | }
|
5893 + | }
|
5894 + |
|
5895 + | impl std::future::Future for MalformedLengthInputFuture {
|
5896 + | type Output = Result<
|
5897 + | crate::input::MalformedLengthInput,
|
5898 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5899 + | >;
|
5900 + |
|
5901 + | fn poll(
|
5902 + | self: std::pin::Pin<&mut Self>,
|
5903 + | cx: &mut std::task::Context<'_>,
|
5904 + | ) -> std::task::Poll<Self::Output> {
|
5905 + | let this = self.project();
|
5906 + | this.inner.as_mut().poll(cx)
|
5261 5907 | }
|
5262 - | /// When a string list contains non-unique values,
|
5263 - | /// the response should be a 400 ValidationException.
|
5264 - | /// Test ID: RestJsonMalformedUniqueItemsStringList
|
5265 - | #[::tokio::test]
|
5266 - | #[should_panic]
|
5267 - | async fn rest_json_malformed_unique_items_string_list_malformed_request() {
|
5908 + | }
|
5909 + |
|
5910 + | impl<B>
|
5911 + | ::aws_smithy_http_server::request::FromRequest<
|
5912 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5913 + | B,
|
5914 + | > for crate::input::MalformedLengthInput
|
5915 + | where
|
5916 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5917 + | B: 'static,
|
5918 + |
|
5919 + | B::Data: Send,
|
5920 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5921 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5922 + | {
|
5923 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5924 + | type Future = MalformedLengthInputFuture;
|
5925 + |
|
5926 + | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
5927 + | let fut = async move {
|
5928 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5929 + | request.headers(),
|
5930 + | &CONTENT_TYPE_MALFORMEDLENGTH,
|
5931 + | ) {
|
5932 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5933 + | }
|
5934 + | crate::protocol_serde::shape_malformed_length::de_malformed_length_http_request(request)
|
5935 + | .await
|
5936 + | .map_err(Into::into)
|
5937 + | };
|
5938 + | use ::futures_util::future::TryFutureExt;
|
5939 + | let fut = fut.map_err(
|
5940 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5941 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5942 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
5943 + | e,
|
5944 + | )
|
5945 + | },
|
5946 + | );
|
5947 + | MalformedLengthInputFuture {
|
5948 + | inner: Box::pin(fut),
|
5949 + | }
|
5950 + | }
|
5951 + | }
|
5952 + | impl
|
5953 + | ::aws_smithy_http_server::response::IntoResponse<
|
5954 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5955 + | > for crate::output::MalformedLengthOutput
|
5956 + | {
|
5957 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5958 + | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_response(
|
5959 + | self,
|
5960 + | ) {
|
5961 + | Ok(response) => response,
|
5962 + | Err(e) => {
|
5963 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5964 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5965 + | }
|
5966 + | }
|
5967 + | }
|
5968 + | }
|
5969 + | impl
|
5970 + | ::aws_smithy_http_server::response::IntoResponse<
|
5971 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5972 + | > for crate::error::MalformedLengthError
|
5973 + | {
|
5974 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5975 + | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_error(&self)
|
5976 + | {
|
5977 + | Ok(mut response) => {
|
5978 + | response.extensions_mut().insert(
|
5979 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
5980 + | );
|
5981 + | response
|
5982 + | }
|
5983 + | Err(e) => {
|
5984 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5985 + | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
5986 + | }
|
5987 + | }
|
5988 + | }
|
5989 + | }
|
5990 + |
|
5991 + | #[allow(unreachable_code, unused_variables)]
|
5992 + | #[cfg(test)]
|
5993 + | mod malformed_length_test {
|
5994 + |
|
5995 + | /// When a blob member does not fit within length bounds,
|
5996 + | /// the response should be a 400 ValidationException.
|
5997 + | /// Test ID: RestJsonMalformedLengthBlob_case0
|
5998 + | #[::tokio::test]
|
5999 + | #[::tracing_test::traced_test]
|
6000 + | async fn rest_json_malformed_length_blob_case0_malformed_request() {
|
5268 6001 | {
|
5269 6002 | #[allow(unused_mut)]
|
5270 6003 | let mut http_request = http::Request::builder()
|
5271 - | .uri("/MalformedUniqueItems")
|
6004 + | .uri("/MalformedLength")
|
5272 6005 | .method("POST")
|
5273 6006 | .header("content-type", "application/json")
|
5274 6007 | .body(::aws_smithy_http_server::body::Body::from(
|
5275 - | ::bytes::Bytes::from_static(
|
5276 - | "{ \"stringList\" : [\"abc\", \"abc\"] }".as_bytes(),
|
5277 - | ),
|
6008 + | ::bytes::Bytes::from_static("{ \"blob\" : \"YQ==\" }".as_bytes()),
|
5278 6009 | ))
|
5279 6010 | .unwrap();
|
5280 6011 | #[allow(unused_mut)]
|
5281 6012 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5282 6013 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5283 6014 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5284 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6015 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5285 6016 | let sender = sender.clone();
|
5286 6017 | async move {
|
5287 - | 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> };
|
6018 + | 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> };
|
5288 6019 | sender.send(()).await.expect("receiver dropped early");
|
5289 6020 | result
|
5290 6021 | }
|
5291 6022 | })
|
5292 6023 | .build_unchecked();
|
5293 6024 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5294 6025 | .await
|
5295 6026 | .expect("unable to make an HTTP request");
|
5296 6027 | ::pretty_assertions::assert_eq!(
|
5297 6028 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5298 6029 | http_response.status()
|
5299 6030 | );
|
5300 6031 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5301 6032 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5302 6033 | http_response.headers(),
|
5303 6034 | expected_headers,
|
5304 6035 | ));
|
5305 6036 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5306 6037 | .await
|
5307 6038 | .expect("unable to extract body to bytes");
|
5308 6039 | ::aws_smithy_protocol_test::assert_ok(
|
5309 - | ::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"))
|
6040 + | ::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"))
|
5310 6041 | );
|
5311 6042 | }
|
5312 6043 | }
|
5313 - | /// When a byte list contains non-unique values,
|
6044 + | /// When a blob member does not fit within length bounds,
|
5314 6045 | /// the response should be a 400 ValidationException.
|
5315 - | /// Test ID: RestJsonMalformedUniqueItemsByteList
|
6046 + | /// Test ID: RestJsonMalformedLengthBlob_case1
|
5316 6047 | #[::tokio::test]
|
5317 - | #[should_panic]
|
5318 - | async fn rest_json_malformed_unique_items_byte_list_malformed_request() {
|
6048 + | #[::tracing_test::traced_test]
|
6049 + | async fn rest_json_malformed_length_blob_case1_malformed_request() {
|
5319 6050 | {
|
5320 6051 | #[allow(unused_mut)]
|
5321 6052 | let mut http_request = http::Request::builder()
|
5322 - | .uri("/MalformedUniqueItems")
|
6053 + | .uri("/MalformedLength")
|
5323 6054 | .method("POST")
|
5324 6055 | .header("content-type", "application/json")
|
5325 6056 | .body(::aws_smithy_http_server::body::Body::from(
|
5326 - | ::bytes::Bytes::from_static("{ \"byteList\" : [1, 1] }".as_bytes()),
|
6057 + | ::bytes::Bytes::from_static(
|
6058 + | "{ \"blob\" : \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" }".as_bytes(),
|
6059 + | ),
|
5327 6060 | ))
|
5328 6061 | .unwrap();
|
5329 6062 | #[allow(unused_mut)]
|
5330 6063 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5331 6064 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5332 6065 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5333 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6066 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5334 6067 | let sender = sender.clone();
|
5335 6068 | async move {
|
5336 - | 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> };
|
6069 + | 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> };
|
5337 6070 | sender.send(()).await.expect("receiver dropped early");
|
5338 6071 | result
|
5339 6072 | }
|
5340 6073 | })
|
5341 6074 | .build_unchecked();
|
5342 6075 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5343 6076 | .await
|
5344 6077 | .expect("unable to make an HTTP request");
|
5345 6078 | ::pretty_assertions::assert_eq!(
|
5346 6079 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5347 6080 | http_response.status()
|
5348 6081 | );
|
5349 6082 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5350 6083 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5351 6084 | http_response.headers(),
|
5352 6085 | expected_headers,
|
5353 6086 | ));
|
5354 6087 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5355 6088 | .await
|
5356 6089 | .expect("unable to extract body to bytes");
|
5357 6090 | ::aws_smithy_protocol_test::assert_ok(
|
5358 - | ::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"))
|
6091 + | ::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"))
|
5359 6092 | );
|
5360 6093 | }
|
5361 6094 | }
|
5362 - | /// When a short list contains non-unique values,
|
6095 + | /// When a string member does not fit within length bounds,
|
5363 6096 | /// the response should be a 400 ValidationException.
|
5364 - | /// Test ID: RestJsonMalformedUniqueItemsShortList
|
6097 + | /// Test ID: RestJsonMalformedLengthString_case0
|
5365 6098 | #[::tokio::test]
|
5366 - | #[should_panic]
|
5367 - | async fn rest_json_malformed_unique_items_short_list_malformed_request() {
|
6099 + | #[::tracing_test::traced_test]
|
6100 + | async fn rest_json_malformed_length_string_case0_malformed_request() {
|
5368 6101 | {
|
5369 6102 | #[allow(unused_mut)]
|
5370 6103 | let mut http_request = http::Request::builder()
|
5371 - | .uri("/MalformedUniqueItems")
|
6104 + | .uri("/MalformedLength")
|
5372 6105 | .method("POST")
|
5373 6106 | .header("content-type", "application/json")
|
5374 6107 | .body(::aws_smithy_http_server::body::Body::from(
|
5375 - | ::bytes::Bytes::from_static("{ \"shortList\" : [2, 2] }".as_bytes()),
|
6108 + | ::bytes::Bytes::from_static("{ \"string\" : \"a\" }".as_bytes()),
|
5376 6109 | ))
|
5377 6110 | .unwrap();
|
5378 6111 | #[allow(unused_mut)]
|
5379 6112 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5380 6113 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5381 6114 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5382 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6115 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5383 6116 | let sender = sender.clone();
|
5384 6117 | async move {
|
5385 - | 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> };
|
6118 + | 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> };
|
5386 6119 | sender.send(()).await.expect("receiver dropped early");
|
5387 6120 | result
|
5388 6121 | }
|
5389 6122 | })
|
5390 6123 | .build_unchecked();
|
5391 6124 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5392 6125 | .await
|
5393 6126 | .expect("unable to make an HTTP request");
|
5394 6127 | ::pretty_assertions::assert_eq!(
|
5395 6128 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5396 6129 | http_response.status()
|
5397 6130 | );
|
5398 6131 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5399 6132 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5400 6133 | http_response.headers(),
|
5401 6134 | expected_headers,
|
5402 6135 | ));
|
5403 6136 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5404 6137 | .await
|
5405 6138 | .expect("unable to extract body to bytes");
|
5406 6139 | ::aws_smithy_protocol_test::assert_ok(
|
5407 - | ::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"))
|
6140 + | ::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"))
|
5408 6141 | );
|
5409 6142 | }
|
5410 6143 | }
|
5411 - | /// When an integer list contains non-unique values,
|
6144 + | /// When a string member does not fit within length bounds,
|
5412 6145 | /// the response should be a 400 ValidationException.
|
5413 - | /// Test ID: RestJsonMalformedUniqueItemsIntegerList
|
6146 + | /// Test ID: RestJsonMalformedLengthString_case1
|
5414 6147 | #[::tokio::test]
|
5415 - | #[should_panic]
|
5416 - | async fn rest_json_malformed_unique_items_integer_list_malformed_request() {
|
6148 + | #[::tracing_test::traced_test]
|
6149 + | async fn rest_json_malformed_length_string_case1_malformed_request() {
|
5417 6150 | {
|
5418 6151 | #[allow(unused_mut)]
|
5419 6152 | let mut http_request = http::Request::builder()
|
5420 - | .uri("/MalformedUniqueItems")
|
6153 + | .uri("/MalformedLength")
|
5421 6154 | .method("POST")
|
5422 6155 | .header("content-type", "application/json")
|
5423 6156 | .body(::aws_smithy_http_server::body::Body::from(
|
5424 - | ::bytes::Bytes::from_static("{ \"integerList\" : [3, 3] }".as_bytes()),
|
6157 + | ::bytes::Bytes::from_static(
|
6158 + | "{ \"string\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
6159 + | ),
|
5425 6160 | ))
|
5426 6161 | .unwrap();
|
5427 6162 | #[allow(unused_mut)]
|
5428 6163 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5429 6164 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5430 6165 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5431 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6166 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5432 6167 | let sender = sender.clone();
|
5433 6168 | async move {
|
5434 - | 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> };
|
6169 + | 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> };
|
5435 6170 | sender.send(()).await.expect("receiver dropped early");
|
5436 6171 | result
|
5437 6172 | }
|
5438 6173 | })
|
5439 6174 | .build_unchecked();
|
5440 6175 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5441 6176 | .await
|
5442 6177 | .expect("unable to make an HTTP request");
|
5443 6178 | ::pretty_assertions::assert_eq!(
|
5444 6179 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5445 6180 | http_response.status()
|
5446 6181 | );
|
5447 6182 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5448 6183 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5449 6184 | http_response.headers(),
|
5450 6185 | expected_headers,
|
5451 6186 | ));
|
5452 6187 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5453 6188 | .await
|
5454 6189 | .expect("unable to extract body to bytes");
|
5455 6190 | ::aws_smithy_protocol_test::assert_ok(
|
5456 - | ::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"))
|
6191 + | ::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"))
|
5457 6192 | );
|
5458 6193 | }
|
5459 6194 | }
|
5460 - | /// When an integer list contains non-unique values,
|
6195 + | /// When a string member does not fit within length bounds,
|
5461 6196 | /// the response should be a 400 ValidationException.
|
5462 - | /// Test ID: RestJsonMalformedUniqueItemsLongList
|
6197 + | /// Test ID: RestJsonMalformedLengthString_case2
|
5463 6198 | #[::tokio::test]
|
5464 - | #[should_panic]
|
5465 - | async fn rest_json_malformed_unique_items_long_list_malformed_request() {
|
6199 + | #[::tracing_test::traced_test]
|
6200 + | async fn rest_json_malformed_length_string_case2_malformed_request() {
|
5466 6201 | {
|
5467 6202 | #[allow(unused_mut)]
|
5468 6203 | let mut http_request = http::Request::builder()
|
5469 - | .uri("/MalformedUniqueItems")
|
6204 + | .uri("/MalformedLength")
|
5470 6205 | .method("POST")
|
5471 6206 | .header("content-type", "application/json")
|
5472 6207 | .body(::aws_smithy_http_server::body::Body::from(
|
5473 - | ::bytes::Bytes::from_static("{ \"longList\" : [4, 4] }".as_bytes()),
|
6208 + | ::bytes::Bytes::from_static("{ \"string\" : \"👍\" }".as_bytes()),
|
5474 6209 | ))
|
5475 6210 | .unwrap();
|
5476 6211 | #[allow(unused_mut)]
|
5477 6212 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5478 6213 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5479 6214 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5480 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6215 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5481 6216 | let sender = sender.clone();
|
5482 6217 | async move {
|
5483 - | 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> };
|
6218 + | 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> };
|
5484 6219 | sender.send(()).await.expect("receiver dropped early");
|
5485 6220 | result
|
5486 6221 | }
|
5487 6222 | })
|
5488 6223 | .build_unchecked();
|
5489 6224 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5490 6225 | .await
|
5491 6226 | .expect("unable to make an HTTP request");
|
5492 6227 | ::pretty_assertions::assert_eq!(
|
5493 6228 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5494 6229 | http_response.status()
|
5495 6230 | );
|
5496 6231 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5497 6232 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5498 6233 | http_response.headers(),
|
5499 6234 | expected_headers,
|
5500 6235 | ));
|
5501 6236 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5502 6237 | .await
|
5503 6238 | .expect("unable to extract body to bytes");
|
5504 6239 | ::aws_smithy_protocol_test::assert_ok(
|
5505 - | ::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"))
|
6240 + | ::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"))
|
5506 6241 | );
|
5507 6242 | }
|
5508 6243 | }
|
5509 - | /// When a timestamp list contains non-unique values,
|
6244 + | /// When a string member does not fit within length bounds,
|
5510 6245 | /// the response should be a 400 ValidationException.
|
5511 - | /// Test ID: RestJsonMalformedUniqueItemsTimestampList
|
6246 + | /// Test ID: RestJsonMalformedLengthMinString
|
5512 6247 | #[::tokio::test]
|
5513 - | #[should_panic]
|
5514 - | async fn rest_json_malformed_unique_items_timestamp_list_malformed_request() {
|
6248 + | #[::tracing_test::traced_test]
|
6249 + | async fn rest_json_malformed_length_min_string_malformed_request() {
|
5515 6250 | {
|
5516 6251 | #[allow(unused_mut)]
|
5517 6252 | let mut http_request = http::Request::builder()
|
5518 - | .uri("/MalformedUniqueItems")
|
6253 + | .uri("/MalformedLength")
|
5519 6254 | .method("POST")
|
5520 6255 | .header("content-type", "application/json")
|
5521 6256 | .body(::aws_smithy_http_server::body::Body::from(
|
5522 - | ::bytes::Bytes::from_static(
|
5523 - | "{ \"timestampList\" : [1676660607, 1676660607] }".as_bytes(),
|
5524 - | ),
|
6257 + | ::bytes::Bytes::from_static("{ \"minString\" : \"a\" }".as_bytes()),
|
5525 6258 | ))
|
5526 6259 | .unwrap();
|
5527 6260 | #[allow(unused_mut)]
|
5528 6261 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5529 6262 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5530 6263 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5531 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6264 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5532 6265 | let sender = sender.clone();
|
5533 6266 | async move {
|
5534 - | 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> };
|
6267 + | 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> };
|
5535 6268 | sender.send(()).await.expect("receiver dropped early");
|
5536 6269 | result
|
5537 6270 | }
|
5538 6271 | })
|
5539 6272 | .build_unchecked();
|
5540 6273 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5541 6274 | .await
|
5542 6275 | .expect("unable to make an HTTP request");
|
5543 6276 | ::pretty_assertions::assert_eq!(
|
5544 6277 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5545 6278 | http_response.status()
|
5546 6279 | );
|
5547 6280 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5548 6281 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5549 6282 | http_response.headers(),
|
5550 6283 | expected_headers,
|
5551 6284 | ));
|
5552 6285 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5553 6286 | .await
|
5554 6287 | .expect("unable to extract body to bytes");
|
5555 6288 | ::aws_smithy_protocol_test::assert_ok(
|
5556 - | ::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"))
|
6289 + | ::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"))
|
5557 6290 | );
|
5558 6291 | }
|
5559 6292 | }
|
5560 - | /// When a date-time timestamp list contains non-unique values,
|
6293 + | /// When a string member does not fit within length bounds,
|
5561 6294 | /// the response should be a 400 ValidationException.
|
5562 - | /// Test ID: RestJsonMalformedUniqueItemsDateTimeList
|
6295 + | /// Test ID: RestJsonMalformedLengthMaxString
|
5563 6296 | #[::tokio::test]
|
5564 - | #[should_panic]
|
5565 - | async fn rest_json_malformed_unique_items_date_time_list_malformed_request() {
|
6297 + | #[::tracing_test::traced_test]
|
6298 + | async fn rest_json_malformed_length_max_string_malformed_request() {
|
5566 6299 | {
|
5567 6300 | #[allow(unused_mut)]
|
5568 6301 | let mut http_request = http::Request::builder()
|
5569 - | .uri("/MalformedUniqueItems")
|
6302 + | .uri("/MalformedLength")
|
5570 6303 | .method("POST")
|
5571 6304 | .header("content-type", "application/json")
|
5572 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"dateTimeList\" : [\"1985-04-12T23:20:50.52Z\", \"1985-04-12T23:20:50.52Z\"] }".as_bytes()))).unwrap();
|
6305 + | .body(::aws_smithy_http_server::body::Body::from(
|
6306 + | ::bytes::Bytes::from_static(
|
6307 + | "{ \"maxString\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
6308 + | ),
|
6309 + | ))
|
6310 + | .unwrap();
|
5573 6311 | #[allow(unused_mut)]
|
5574 6312 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5575 6313 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5576 6314 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5577 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6315 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5578 6316 | let sender = sender.clone();
|
5579 6317 | async move {
|
5580 - | 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> };
|
6318 + | 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> };
|
5581 6319 | sender.send(()).await.expect("receiver dropped early");
|
5582 6320 | result
|
5583 6321 | }
|
5584 6322 | })
|
5585 6323 | .build_unchecked();
|
5586 6324 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5587 6325 | .await
|
5588 6326 | .expect("unable to make an HTTP request");
|
5589 6327 | ::pretty_assertions::assert_eq!(
|
5590 6328 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5591 6329 | http_response.status()
|
5592 6330 | );
|
5593 6331 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5594 6332 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5595 6333 | http_response.headers(),
|
5596 6334 | expected_headers,
|
5597 6335 | ));
|
5598 6336 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5599 6337 | .await
|
5600 6338 | .expect("unable to extract body to bytes");
|
5601 6339 | ::aws_smithy_protocol_test::assert_ok(
|
5602 - | ::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"))
|
6340 + | ::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"))
|
5603 6341 | );
|
5604 6342 | }
|
5605 6343 | }
|
5606 - | /// When a http-date timestamp list contains non-unique values,
|
6344 + | /// When a list member does not fit within length bounds,
|
5607 6345 | /// the response should be a 400 ValidationException.
|
5608 - | /// Test ID: RestJsonMalformedUniqueItemsHttpDateList_case0
|
6346 + | /// Test ID: RestJsonMalformedLengthList_case0
|
5609 6347 | #[::tokio::test]
|
5610 - | #[should_panic]
|
5611 - | async fn rest_json_malformed_unique_items_http_date_list_case0_malformed_request() {
|
6348 + | #[::tracing_test::traced_test]
|
6349 + | async fn rest_json_malformed_length_list_case0_malformed_request() {
|
5612 6350 | {
|
5613 6351 | #[allow(unused_mut)]
|
5614 6352 | let mut http_request = http::Request::builder()
|
5615 - | .uri("/MalformedUniqueItems")
|
6353 + | .uri("/MalformedLength")
|
5616 6354 | .method("POST")
|
5617 6355 | .header("content-type", "application/json")
|
5618 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"httpDateList\" : [\"Tue, 29 Apr 2014 18:30:38 GMT\", \"Tue, 29 Apr 2014 18:30:38 GMT\"] }".as_bytes()))).unwrap();
|
6356 + | .body(::aws_smithy_http_server::body::Body::from(
|
6357 + | ::bytes::Bytes::from_static("{ \"list\" : [\"abc\"] }".as_bytes()),
|
6358 + | ))
|
6359 + | .unwrap();
|
5619 6360 | #[allow(unused_mut)]
|
5620 6361 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5621 6362 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5622 6363 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5623 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6364 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5624 6365 | let sender = sender.clone();
|
5625 6366 | async move {
|
5626 - | 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> };
|
6367 + | 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> };
|
5627 6368 | sender.send(()).await.expect("receiver dropped early");
|
5628 6369 | result
|
5629 6370 | }
|
5630 6371 | })
|
5631 6372 | .build_unchecked();
|
5632 6373 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5633 6374 | .await
|
5634 6375 | .expect("unable to make an HTTP request");
|
5635 6376 | ::pretty_assertions::assert_eq!(
|
5636 6377 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5637 6378 | http_response.status()
|
5638 6379 | );
|
5639 6380 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5640 6381 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5641 6382 | http_response.headers(),
|
5642 6383 | expected_headers,
|
5643 6384 | ));
|
5644 6385 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5645 6386 | .await
|
5646 6387 | .expect("unable to extract body to bytes");
|
5647 6388 | ::aws_smithy_protocol_test::assert_ok(
|
5648 - | ::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"))
|
6389 + | ::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"))
|
5649 6390 | );
|
5650 6391 | }
|
5651 6392 | }
|
5652 - | /// When an enum list contains non-unique values,
|
6393 + | /// When a list member does not fit within length bounds,
|
5653 6394 | /// the response should be a 400 ValidationException.
|
5654 - | /// Test ID: RestJsonMalformedUniqueItemsEnumList
|
6395 + | /// Test ID: RestJsonMalformedLengthList_case1
|
5655 6396 | #[::tokio::test]
|
5656 - | #[should_panic]
|
5657 - | async fn rest_json_malformed_unique_items_enum_list_malformed_request() {
|
6397 + | #[::tracing_test::traced_test]
|
6398 + | async fn rest_json_malformed_length_list_case1_malformed_request() {
|
5658 6399 | {
|
5659 6400 | #[allow(unused_mut)]
|
5660 6401 | let mut http_request = http::Request::builder()
|
5661 - | .uri("/MalformedUniqueItems")
|
6402 + | .uri("/MalformedLength")
|
5662 6403 | .method("POST")
|
5663 6404 | .header("content-type", "application/json")
|
5664 - | .body(::aws_smithy_http_server::body::Body::from(
|
5665 - | ::bytes::Bytes::from_static("{ \"enumList\" : [\"Foo\", \"Foo\"] }".as_bytes()),
|
5666 - | ))
|
5667 - | .unwrap();
|
6405 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes()))).unwrap();
|
5668 6406 | #[allow(unused_mut)]
|
5669 6407 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5670 6408 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5671 6409 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5672 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6410 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5673 6411 | let sender = sender.clone();
|
5674 6412 | async move {
|
5675 - | 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> };
|
6413 + | 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> };
|
5676 6414 | sender.send(()).await.expect("receiver dropped early");
|
5677 6415 | result
|
5678 6416 | }
|
5679 6417 | })
|
5680 6418 | .build_unchecked();
|
5681 6419 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5682 6420 | .await
|
5683 6421 | .expect("unable to make an HTTP request");
|
5684 6422 | ::pretty_assertions::assert_eq!(
|
5685 6423 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5686 6424 | http_response.status()
|
5687 6425 | );
|
5688 6426 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5689 6427 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5690 6428 | http_response.headers(),
|
5691 6429 | expected_headers,
|
5692 6430 | ));
|
5693 6431 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5694 6432 | .await
|
5695 6433 | .expect("unable to extract body to bytes");
|
5696 6434 | ::aws_smithy_protocol_test::assert_ok(
|
5697 - | ::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"))
|
6435 + | ::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"))
|
5698 6436 | );
|
5699 6437 | }
|
5700 6438 | }
|
5701 - | /// When an intEnum list contains non-unique values,
|
6439 + | /// When a list member's value does not fit within length bounds,
|
5702 6440 | /// the response should be a 400 ValidationException.
|
5703 - | /// Test ID: RestJsonMalformedUniqueItemsIntEnumList
|
6441 + | /// Test ID: RestJsonMalformedLengthListValue_case0
|
5704 6442 | #[::tokio::test]
|
5705 - | #[should_panic]
|
5706 - | async fn rest_json_malformed_unique_items_int_enum_list_malformed_request() {
|
6443 + | #[::tracing_test::traced_test]
|
6444 + | async fn rest_json_malformed_length_list_value_case0_malformed_request() {
|
5707 6445 | {
|
5708 6446 | #[allow(unused_mut)]
|
5709 6447 | let mut http_request = http::Request::builder()
|
5710 - | .uri("/MalformedUniqueItems")
|
6448 + | .uri("/MalformedLength")
|
5711 6449 | .method("POST")
|
5712 6450 | .header("content-type", "application/json")
|
5713 6451 | .body(::aws_smithy_http_server::body::Body::from(
|
5714 - | ::bytes::Bytes::from_static("{ \"intEnumList\" : [3, 3] }".as_bytes()),
|
6452 + | ::bytes::Bytes::from_static("{ \"list\" : [\"a\", \"abc\"] }".as_bytes()),
|
5715 6453 | ))
|
5716 6454 | .unwrap();
|
5717 6455 | #[allow(unused_mut)]
|
5718 6456 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5719 6457 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5720 6458 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5721 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6459 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5722 6460 | let sender = sender.clone();
|
5723 6461 | async move {
|
5724 - | 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> };
|
6462 + | 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> };
|
5725 6463 | sender.send(()).await.expect("receiver dropped early");
|
5726 6464 | result
|
5727 6465 | }
|
5728 6466 | })
|
5729 6467 | .build_unchecked();
|
5730 6468 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5731 6469 | .await
|
5732 6470 | .expect("unable to make an HTTP request");
|
5733 6471 | ::pretty_assertions::assert_eq!(
|
5734 6472 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5735 6473 | http_response.status()
|
5736 6474 | );
|
5737 6475 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5738 6476 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5739 6477 | http_response.headers(),
|
5740 6478 | expected_headers,
|
5741 6479 | ));
|
5742 6480 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5743 6481 | .await
|
5744 6482 | .expect("unable to extract body to bytes");
|
5745 6483 | ::aws_smithy_protocol_test::assert_ok(
|
5746 - | ::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"))
|
6484 + | ::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"))
|
5747 6485 | );
|
5748 6486 | }
|
5749 6487 | }
|
5750 - | /// When an list of lists contains non-unique values,
|
6488 + | /// When a list member's value does not fit within length bounds,
|
5751 6489 | /// the response should be a 400 ValidationException.
|
5752 - | /// Test ID: RestJsonMalformedUniqueItemsListList
|
6490 + | /// Test ID: RestJsonMalformedLengthListValue_case1
|
5753 6491 | #[::tokio::test]
|
5754 - | #[should_panic]
|
5755 - | async fn rest_json_malformed_unique_items_list_list_malformed_request() {
|
6492 + | #[::tracing_test::traced_test]
|
6493 + | async fn rest_json_malformed_length_list_value_case1_malformed_request() {
|
5756 6494 | {
|
5757 6495 | #[allow(unused_mut)]
|
5758 6496 | let mut http_request = http::Request::builder()
|
5759 - | .uri("/MalformedUniqueItems")
|
6497 + | .uri("/MalformedLength")
|
5760 6498 | .method("POST")
|
5761 6499 | .header("content-type", "application/json")
|
5762 6500 | .body(::aws_smithy_http_server::body::Body::from(
|
5763 6501 | ::bytes::Bytes::from_static(
|
5764 - | "{ \"listList\" : [[\"foo\",\"bar\"], [\"foo\",\"bar\"]] }".as_bytes(),
|
6502 + | "{ \"list\" : [\"abcdefghijklmnopqrstuvwxyz\", \"abc\"] }".as_bytes(),
|
5765 6503 | ),
|
5766 6504 | ))
|
5767 6505 | .unwrap();
|
5768 6506 | #[allow(unused_mut)]
|
5769 6507 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5770 6508 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5771 6509 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5772 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6510 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5773 6511 | let sender = sender.clone();
|
5774 6512 | async move {
|
5775 - | 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> };
|
6513 + | 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> };
|
5776 6514 | sender.send(()).await.expect("receiver dropped early");
|
5777 6515 | result
|
5778 6516 | }
|
5779 6517 | })
|
5780 6518 | .build_unchecked();
|
5781 6519 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5782 6520 | .await
|
5783 6521 | .expect("unable to make an HTTP request");
|
5784 6522 | ::pretty_assertions::assert_eq!(
|
5785 6523 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5786 6524 | http_response.status()
|
5787 6525 | );
|
5788 6526 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5789 6527 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5790 6528 | http_response.headers(),
|
5791 6529 | expected_headers,
|
5792 6530 | ));
|
5793 6531 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5794 6532 | .await
|
5795 6533 | .expect("unable to extract body to bytes");
|
5796 6534 | ::aws_smithy_protocol_test::assert_ok(
|
5797 - | ::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"))
|
6535 + | ::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"))
|
5798 6536 | );
|
5799 6537 | }
|
5800 6538 | }
|
5801 - | /// When an list of structures contains non-unique values,
|
6539 + | /// When a map member does not fit within length bounds,
|
5802 6540 | /// the response should be a 400 ValidationException.
|
5803 - | /// Test ID: RestJsonMalformedUniqueItemsStructureList
|
6541 + | /// Test ID: RestJsonMalformedLengthMap_case0
|
5804 6542 | #[::tokio::test]
|
5805 - | #[should_panic]
|
5806 - | async fn rest_json_malformed_unique_items_structure_list_malformed_request() {
|
6543 + | #[::tracing_test::traced_test]
|
6544 + | async fn rest_json_malformed_length_map_case0_malformed_request() {
|
5807 6545 | {
|
5808 6546 | #[allow(unused_mut)]
|
5809 6547 | let mut http_request = http::Request::builder()
|
5810 - | .uri("/MalformedUniqueItems")
|
6548 + | .uri("/MalformedLength")
|
5811 6549 | .method("POST")
|
5812 6550 | .header("content-type", "application/json")
|
5813 6551 | .body(::aws_smithy_http_server::body::Body::from(
|
5814 6552 | ::bytes::Bytes::from_static(
|
5815 - | "{ \"structureList\" : [{\"hi\": \"hello\"}, {\"hi\": \"hello\"}] }"
|
5816 - | .as_bytes(),
|
6553 + | "{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"]} }".as_bytes(),
|
5817 6554 | ),
|
5818 6555 | ))
|
5819 6556 | .unwrap();
|
5820 6557 | #[allow(unused_mut)]
|
5821 6558 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5822 6559 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5823 6560 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5824 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6561 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5825 6562 | let sender = sender.clone();
|
5826 6563 | async move {
|
5827 - | 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> };
|
6564 + | 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> };
|
5828 6565 | sender.send(()).await.expect("receiver dropped early");
|
5829 6566 | result
|
5830 6567 | }
|
5831 6568 | })
|
5832 6569 | .build_unchecked();
|
5833 6570 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5834 6571 | .await
|
5835 6572 | .expect("unable to make an HTTP request");
|
5836 6573 | ::pretty_assertions::assert_eq!(
|
5837 6574 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5838 6575 | http_response.status()
|
5839 6576 | );
|
5840 6577 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5841 6578 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5842 6579 | http_response.headers(),
|
5843 6580 | expected_headers,
|
5844 6581 | ));
|
5845 6582 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5846 6583 | .await
|
5847 6584 | .expect("unable to extract body to bytes");
|
5848 6585 | ::aws_smithy_protocol_test::assert_ok(
|
5849 - | ::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"))
|
6586 + | ::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"))
|
5850 6587 | );
|
5851 6588 | }
|
5852 6589 | }
|
5853 - | /// When a list of structures does not contain required keys,
|
5854 - | /// the response should be a 400 ValidationException and not
|
5855 - | /// a 500 error.
|
5856 - | /// Test ID: RestJsonMalformedUniqueItemsStructureMissingKeyList
|
6590 + | /// When a map member does not fit within length bounds,
|
6591 + | /// the response should be a 400 ValidationException.
|
6592 + | /// Test ID: RestJsonMalformedLengthMap_case1
|
5857 6593 | #[::tokio::test]
|
5858 - | async fn rest_json_malformed_unique_items_structure_missing_key_list_malformed_request() {
|
6594 + | #[::tracing_test::traced_test]
|
6595 + | async fn rest_json_malformed_length_map_case1_malformed_request() {
|
5859 6596 | {
|
5860 6597 | #[allow(unused_mut)]
|
5861 6598 | let mut http_request = http::Request::builder()
|
5862 - | .uri("/MalformedUniqueItems")
|
6599 + | .uri("/MalformedLength")
|
5863 6600 | .method("POST")
|
5864 6601 | .header("content-type", "application/json")
|
5865 - | .body(::aws_smithy_http_server::body::Body::from(
|
5866 - | ::bytes::Bytes::from_static(
|
5867 - | "{ \"structureListWithNoKey\" : [{\"hi2\": \"bar\"}] }".as_bytes(),
|
5868 - | ),
|
5869 - | ))
|
5870 - | .unwrap();
|
6602 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"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()))).unwrap();
|
5871 6603 | #[allow(unused_mut)]
|
5872 6604 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5873 6605 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5874 6606 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5875 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6607 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5876 6608 | let sender = sender.clone();
|
5877 6609 | async move {
|
5878 - | 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> };
|
6610 + | 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> };
|
5879 6611 | sender.send(()).await.expect("receiver dropped early");
|
5880 6612 | result
|
5881 6613 | }
|
5882 6614 | })
|
5883 6615 | .build_unchecked();
|
5884 6616 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5885 6617 | .await
|
5886 6618 | .expect("unable to make an HTTP request");
|
5887 6619 | ::pretty_assertions::assert_eq!(
|
5888 6620 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5889 6621 | http_response.status()
|
5890 6622 | );
|
5891 6623 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5892 6624 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5893 6625 | http_response.headers(),
|
5894 6626 | expected_headers,
|
5895 6627 | ));
|
5896 6628 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5897 6629 | .await
|
5898 6630 | .expect("unable to extract body to bytes");
|
5899 6631 | ::aws_smithy_protocol_test::assert_ok(
|
5900 - | ::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"))
|
6632 + | ::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"))
|
5901 6633 | );
|
5902 6634 | }
|
5903 6635 | }
|
5904 - | /// When an list of unions contains non-unique values,
|
6636 + | /// When a map member's key does not fit within length bounds,
|
5905 6637 | /// the response should be a 400 ValidationException.
|
5906 - | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case0
|
6638 + | /// Test ID: RestJsonMalformedLengthMapKey_case0
|
5907 6639 | #[::tokio::test]
|
5908 - | #[should_panic]
|
5909 - | async fn rest_json_malformed_unique_items_union_list_case0_malformed_request() {
|
6640 + | #[::tracing_test::traced_test]
|
6641 + | async fn rest_json_malformed_length_map_key_case0_malformed_request() {
|
5910 6642 | {
|
5911 6643 | #[allow(unused_mut)]
|
5912 6644 | let mut http_request = http::Request::builder()
|
5913 - | .uri("/MalformedUniqueItems")
|
6645 + | .uri("/MalformedLength")
|
5914 6646 | .method("POST")
|
5915 6647 | .header("content-type", "application/json")
|
5916 - | .body(::aws_smithy_http_server::body::Body::from(
|
5917 - | ::bytes::Bytes::from_static(
|
5918 - | "{ \"unionList\" : [{\"string\": \"foo\"}, {\"string\": \"foo\"}] }"
|
5919 - | .as_bytes(),
|
5920 - | ),
|
5921 - | ))
|
5922 - | .unwrap();
|
6648 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"a\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
5923 6649 | #[allow(unused_mut)]
|
5924 6650 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5925 6651 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5926 6652 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5927 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6653 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5928 6654 | let sender = sender.clone();
|
5929 6655 | async move {
|
5930 - | 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> };
|
6656 + | 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> };
|
5931 6657 | sender.send(()).await.expect("receiver dropped early");
|
5932 6658 | result
|
5933 6659 | }
|
5934 6660 | })
|
5935 6661 | .build_unchecked();
|
5936 6662 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5937 6663 | .await
|
5938 6664 | .expect("unable to make an HTTP request");
|
5939 6665 | ::pretty_assertions::assert_eq!(
|
5940 6666 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5941 6667 | http_response.status()
|
5942 6668 | );
|
5943 6669 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5944 6670 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5945 6671 | http_response.headers(),
|
5946 6672 | expected_headers,
|
5947 6673 | ));
|
5948 6674 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
5949 6675 | .await
|
5950 6676 | .expect("unable to extract body to bytes");
|
5951 6677 | ::aws_smithy_protocol_test::assert_ok(
|
5952 - | ::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"))
|
6678 + | ::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"))
|
5953 6679 | );
|
5954 6680 | }
|
5955 6681 | }
|
5956 - | /// When an list of unions contains non-unique values,
|
6682 + | /// When a map member's key does not fit within length bounds,
|
5957 6683 | /// the response should be a 400 ValidationException.
|
5958 - | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case1
|
6684 + | /// Test ID: RestJsonMalformedLengthMapKey_case1
|
5959 6685 | #[::tokio::test]
|
5960 - | #[should_panic]
|
5961 - | async fn rest_json_malformed_unique_items_union_list_case1_malformed_request() {
|
6686 + | #[::tracing_test::traced_test]
|
6687 + | async fn rest_json_malformed_length_map_key_case1_malformed_request() {
|
5962 6688 | {
|
5963 6689 | #[allow(unused_mut)]
|
5964 6690 | let mut http_request = http::Request::builder()
|
5965 - | .uri("/MalformedUniqueItems")
|
6691 + | .uri("/MalformedLength")
|
5966 6692 | .method("POST")
|
5967 6693 | .header("content-type", "application/json")
|
5968 - | .body(::aws_smithy_http_server::body::Body::from(
|
5969 - | ::bytes::Bytes::from_static(
|
5970 - | "{ \"unionList\" : [{\"integer\": 1}, {\"integer\": 1}] }".as_bytes(),
|
5971 - | ),
|
5972 - | ))
|
5973 - | .unwrap();
|
6694 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abcdefghijklmnopqrstuvwxyz\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
5974 6695 | #[allow(unused_mut)]
|
5975 6696 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5976 6697 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5977 6698 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
5978 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
6699 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
5979 6700 | let sender = sender.clone();
|
5980 6701 | async move {
|
5981 - | 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> };
|
6702 + | 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> };
|
5982 6703 | sender.send(()).await.expect("receiver dropped early");
|
5983 6704 | result
|
5984 6705 | }
|
5985 6706 | })
|
5986 6707 | .build_unchecked();
|
5987 6708 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5988 6709 | .await
|
5989 6710 | .expect("unable to make an HTTP request");
|
5990 6711 | ::pretty_assertions::assert_eq!(
|
5991 6712 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5992 6713 | http_response.status()
|
5993 6714 | );
|
5994 6715 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5995 6716 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5996 6717 | http_response.headers(),
|
5997 6718 | expected_headers,
|
5998 6719 | ));
|
5999 6720 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6000 6721 | .await
|
6001 6722 | .expect("unable to extract body to bytes");
|
6002 6723 | ::aws_smithy_protocol_test::assert_ok(
|
6003 - | ::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"))
|
6724 + | ::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"))
|
6004 6725 | );
|
6005 6726 | }
|
6006 6727 | }
|
6007 - | }
|
6008 - | #[cfg(test)]
|
6009 - | #[allow(unreachable_code, unused_variables)]
|
6010 - | mod server_recursive_structures_test {
|
6011 - | /// Validation should work with recursive structures.
|
6012 - | /// Test ID: RestJsonRecursiveStructuresValidate
|
6013 - | #[::tokio::test]
|
6014 - | async fn rest_json_recursive_structures_validate_request() {
|
6015 - | #[allow(unused_mut)]
|
6016 - | let mut http_request = http::Request::builder()
|
6017 - | .uri("/RecursiveStructures")
|
6018 - | .method("POST")
|
6019 - | .header("content-type", "application/json")
|
6020 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"abc\" }\n }\n }\n}".as_bytes()))).unwrap();
|
6021 - | #[allow(unused_mut)]
|
6022 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6023 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6024 - | let service =
|
6025 - | crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6026 - | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
6027 - | let sender = sender.clone();
|
6028 - | async move {
|
6029 - | let result = {
|
6030 - | let expected = crate::input::RecursiveStructuresInput {
|
6031 - | union: ::std::option::Option::Some(
|
6032 - | crate::model::RecursiveUnionOne::Union(::std::boxed::Box::new(
|
6033 - | crate::model::RecursiveUnionTwo::Union(
|
6034 - | crate::model::RecursiveUnionOne::String(
|
6035 - | "abc"
|
6036 - | .parse::<crate::model::RecursiveEnumString>()
|
6037 - | .expect("static value validated to member"),
|
6038 - | ),
|
6039 - | ),
|
6040 - | )),
|
6041 - | ),
|
6042 - | };
|
6043 - | ::pretty_assertions::assert_eq!(input, expected);
|
6044 - | let response = crate::output::RecursiveStructuresOutput {};
|
6045 - | Ok(response)
|
6046 - | };
|
6047 - | sender.send(()).await.expect("receiver dropped early");
|
6048 - | result
|
6049 - | }
|
6050 - | })
|
6051 - | .build_unchecked();
|
6052 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6053 - | .await
|
6054 - | .expect("unable to make an HTTP request");
|
6055 - | assert!(receiver.recv().await.is_some());
|
6056 - | }
|
6057 - | /// When a value deeply nested in a recursive structure does not meet constraints,
|
6058 - | /// a 400 ValidationException is returned.
|
6059 - | /// Test ID: RestJsonMalformedRecursiveStructures
|
6728 + | /// When a map member's value does not fit within length bounds,
|
6729 + | /// the response should be a 400 ValidationException.
|
6730 + | /// Test ID: RestJsonMalformedLengthMapValue_case0
|
6060 6731 | #[::tokio::test]
|
6061 - | async fn rest_json_malformed_recursive_structures_malformed_request() {
|
6732 + | #[::tracing_test::traced_test]
|
6733 + | async fn rest_json_malformed_length_map_value_case0_malformed_request() {
|
6062 6734 | {
|
6063 6735 | #[allow(unused_mut)]
|
6064 6736 | let mut http_request = http::Request::builder()
|
6065 - | .uri("/RecursiveStructures")
|
6737 + | .uri("/MalformedLength")
|
6066 6738 | .method("POST")
|
6067 6739 | .header("content-type", "application/json")
|
6068 - | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"XYZ\" }\n }\n }\n}".as_bytes()))).unwrap();
|
6740 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abc\": [\"def\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
6069 6741 | #[allow(unused_mut)]
|
6070 6742 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6071 6743 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6072 6744 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6073 - | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
6745 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6074 6746 | let sender = sender.clone();
|
6075 6747 | async move {
|
6076 - | 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> };
|
6748 + | 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> };
|
6077 6749 | sender.send(()).await.expect("receiver dropped early");
|
6078 6750 | result
|
6079 6751 | }
|
6080 6752 | })
|
6081 6753 | .build_unchecked();
|
6082 6754 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6083 6755 | .await
|
6084 6756 | .expect("unable to make an HTTP request");
|
6085 6757 | ::pretty_assertions::assert_eq!(
|
6086 6758 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6087 6759 | http_response.status()
|
6088 6760 | );
|
6089 6761 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6090 6762 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6091 6763 | http_response.headers(),
|
6092 6764 | expected_headers,
|
6093 6765 | ));
|
6094 6766 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6095 6767 | .await
|
6096 6768 | .expect("unable to extract body to bytes");
|
6097 6769 | ::aws_smithy_protocol_test::assert_ok(
|
6098 - | ::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"))
|
6770 + | ::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"))
|
6099 6771 | );
|
6100 6772 | }
|
6101 6773 | }
|
6102 - | }
|
6103 - | #[cfg(test)]
|
6104 - | #[allow(unreachable_code, unused_variables)]
|
6105 - | mod server_sensitive_validation_test {
|
6106 - | /// When a sensitive member fails validation, the resultant
|
6107 - | /// ValidationException will omit the value of the input.
|
6108 - | /// Test ID: RestJsonMalformedPatternSensitiveString
|
6774 + | /// When a map member's value does not fit within length bounds,
|
6775 + | /// the response should be a 400 ValidationException.
|
6776 + | /// Test ID: RestJsonMalformedLengthMapValue_case1
|
6109 6777 | #[::tokio::test]
|
6110 - | async fn rest_json_malformed_pattern_sensitive_string_malformed_request() {
|
6778 + | #[::tracing_test::traced_test]
|
6779 + | async fn rest_json_malformed_length_map_value_case1_malformed_request() {
|
6111 6780 | {
|
6112 6781 | #[allow(unused_mut)]
|
6113 6782 | let mut http_request = http::Request::builder()
|
6114 - | .uri("/SensitiveValidation")
|
6783 + | .uri("/MalformedLength")
|
6115 6784 | .method("POST")
|
6116 6785 | .header("content-type", "application/json")
|
6117 - | .body(::aws_smithy_http_server::body::Body::from(
|
6118 - | ::bytes::Bytes::from_static("{ \"string\" : \"ABC\" }".as_bytes()),
|
6119 - | ))
|
6120 - | .unwrap();
|
6786 + | .body(::aws_smithy_http_server::body::Body::from(::bytes::Bytes::from_static("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\"],\n \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes()))).unwrap();
|
6121 6787 | #[allow(unused_mut)]
|
6122 6788 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6123 6789 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6124 6790 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6125 - | .sensitive_validation(move |input: crate::input::SensitiveValidationInput| {
|
6791 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6126 6792 | let sender = sender.clone();
|
6127 6793 | async move {
|
6128 - | 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> };
|
6794 + | 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> };
|
6129 6795 | sender.send(()).await.expect("receiver dropped early");
|
6130 6796 | result
|
6131 6797 | }
|
6132 6798 | })
|
6133 6799 | .build_unchecked();
|
6134 6800 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6135 6801 | .await
|
6136 6802 | .expect("unable to make an HTTP request");
|
6137 6803 | ::pretty_assertions::assert_eq!(
|
6138 6804 | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6139 6805 | http_response.status()
|
6140 6806 | );
|
6141 6807 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6142 6808 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6143 6809 | http_response.headers(),
|
6144 6810 | expected_headers,
|
6145 6811 | ));
|
6146 6812 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6147 6813 | .await
|
6148 6814 | .expect("unable to extract body to bytes");
|
6149 6815 | ::aws_smithy_protocol_test::assert_ok(
|
6150 - | ::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"))
|
6816 + | ::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"))
|
6151 6817 | );
|
6152 6818 | }
|
6153 6819 | }
|
6154 6820 | }
|
6155 6821 |
|
6156 - | const CONTENT_TYPE_SENSITIVEVALIDATION: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6822 + | const CONTENT_TYPE_MALFORMEDENUM: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6157 6823 | ::pin_project_lite::pin_project! {
|
6158 6824 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6159 - | /// [`SensitiveValidationInput`](crate::input::SensitiveValidationInput) using modelled bindings.
|
6160 - | pub struct SensitiveValidationInputFuture {
|
6161 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SensitiveValidationInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6825 + | /// [`MalformedEnumInput`](crate::input::MalformedEnumInput) using modelled bindings.
|
6826 + | pub struct MalformedEnumInputFuture {
|
6827 + | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedEnumInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6162 6828 | }
|
6163 6829 | }
|
6164 6830 |
|
6165 - | impl std::future::Future for SensitiveValidationInputFuture {
|
6831 + | impl std::future::Future for MalformedEnumInputFuture {
|
6166 6832 | type Output = Result<
|
6167 - | crate::input::SensitiveValidationInput,
|
6833 + | crate::input::MalformedEnumInput,
|
6168 6834 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6169 6835 | >;
|
6170 6836 |
|
6171 6837 | fn poll(
|
6172 6838 | self: std::pin::Pin<&mut Self>,
|
6173 6839 | cx: &mut std::task::Context<'_>,
|
6174 6840 | ) -> std::task::Poll<Self::Output> {
|
6175 6841 | let this = self.project();
|
6176 6842 | this.inner.as_mut().poll(cx)
|
6177 6843 | }
|
6178 6844 | }
|
6179 6845 |
|
6180 6846 | impl<B>
|
6181 6847 | ::aws_smithy_http_server::request::FromRequest<
|
6182 6848 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6183 6849 | B,
|
6184 - | > for crate::input::SensitiveValidationInput
|
6850 + | > for crate::input::MalformedEnumInput
|
6185 6851 | where
|
6186 6852 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6187 6853 | B: 'static,
|
6188 6854 |
|
6189 6855 | B::Data: Send,
|
6190 6856 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6191 6857 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6192 6858 | {
|
6193 6859 | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6194 - | type Future = SensitiveValidationInputFuture;
|
6860 + | type Future = MalformedEnumInputFuture;
|
6195 6861 |
|
6196 6862 | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6197 6863 | let fut = async move {
|
6198 6864 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6199 6865 | request.headers(),
|
6200 - | &CONTENT_TYPE_SENSITIVEVALIDATION,
|
6866 + | &CONTENT_TYPE_MALFORMEDENUM,
|
6201 6867 | ) {
|
6202 6868 | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6203 6869 | }
|
6204 - | crate::protocol_serde::shape_sensitive_validation::de_sensitive_validation_http_request(
|
6205 - | request,
|
6206 - | )
|
6870 + | crate::protocol_serde::shape_malformed_enum::de_malformed_enum_http_request(request)
|
6207 6871 | .await
|
6208 6872 | .map_err(Into::into)
|
6209 6873 | };
|
6210 6874 | use ::futures_util::future::TryFutureExt;
|
6211 6875 | let fut = fut.map_err(
|
6212 6876 | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6213 6877 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6214 6878 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6215 6879 | e,
|
6216 6880 | )
|
6217 6881 | },
|
6218 6882 | );
|
6219 - | SensitiveValidationInputFuture {
|
6883 + | MalformedEnumInputFuture {
|
6220 6884 | inner: Box::pin(fut),
|
6221 6885 | }
|
6222 6886 | }
|
6223 6887 | }
|
6224 6888 | impl
|
6225 6889 | ::aws_smithy_http_server::response::IntoResponse<
|
6226 6890 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6227 - | > for crate::output::SensitiveValidationOutput
|
6891 + | > for crate::output::MalformedEnumOutput
|
6228 6892 | {
|
6229 6893 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6230 - | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_response(self) {
|
6894 + | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_response(self) {
|
6231 6895 | Ok(response) => response,
|
6232 6896 | Err(e) => {
|
6233 6897 | ::tracing::error!(error = %e, "failed to serialize response");
|
6234 6898 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6235 6899 | }
|
6236 6900 | }
|
6237 6901 | }
|
6238 6902 | }
|
6239 6903 | impl
|
6240 6904 | ::aws_smithy_http_server::response::IntoResponse<
|
6241 6905 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6242 - | > for crate::error::SensitiveValidationError
|
6906 + | > for crate::error::MalformedEnumError
|
6243 6907 | {
|
6244 6908 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6245 - | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_error(
|
6246 - | &self,
|
6247 - | ) {
|
6909 + | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_error(&self) {
|
6248 6910 | Ok(mut response) => {
|
6249 6911 | response.extensions_mut().insert(
|
6250 6912 | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
6251 6913 | );
|
6252 6914 | response
|
6253 6915 | }
|
6254 6916 | Err(e) => {
|
6255 6917 | ::tracing::error!(error = %e, "failed to serialize response");
|
6256 6918 | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6257 6919 | }
|
6258 6920 | }
|
6259 6921 | }
|
6260 6922 | }
|
6261 6923 |
|
6262 - | const CONTENT_TYPE_RECURSIVESTRUCTURES: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6263 - | ::pin_project_lite::pin_project! {
|
6264 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6265 - | /// [`RecursiveStructuresInput`](crate::input::RecursiveStructuresInput) using modelled bindings.
|
6266 - | pub struct RecursiveStructuresInputFuture {
|
6267 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::RecursiveStructuresInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6268 - | }
|
6269 - | }
|
6924 + | #[allow(unreachable_code, unused_variables)]
|
6925 + | #[cfg(test)]
|
6926 + | mod malformed_enum_test {
|
6270 6927 |
|
6271 - | impl std::future::Future for RecursiveStructuresInputFuture {
|
6272 - | type Output = Result<
|
6273 - | crate::input::RecursiveStructuresInput,
|
6274 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6275 - | >;
|
6276 - |
|
6277 - | fn poll(
|
6278 - | self: std::pin::Pin<&mut Self>,
|
6279 - | cx: &mut std::task::Context<'_>,
|
6280 - | ) -> std::task::Poll<Self::Output> {
|
6281 - | let this = self.project();
|
6282 - | this.inner.as_mut().poll(cx)
|
6283 - | }
|
6284 - | }
|
6285 - |
|
6286 - | impl<B>
|
6287 - | ::aws_smithy_http_server::request::FromRequest<
|
6288 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6289 - | B,
|
6290 - | > for crate::input::RecursiveStructuresInput
|
6291 - | where
|
6292 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6293 - | B: 'static,
|
6294 - |
|
6295 - | B::Data: Send,
|
6296 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6297 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6298 - | {
|
6299 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6300 - | type Future = RecursiveStructuresInputFuture;
|
6301 - |
|
6302 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6303 - | let fut = async move {
|
6304 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6305 - | request.headers(),
|
6306 - | &CONTENT_TYPE_RECURSIVESTRUCTURES,
|
6307 - | ) {
|
6308 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6928 + | /// When a string member does not contain a valid enum value,
|
6929 + | /// the response should be a 400 ValidationException. Internal-only
|
6930 + | /// enum values are excluded from the response message.
|
6931 + | /// Test ID: RestJsonMalformedEnumString_case0
|
6932 + | #[::tokio::test]
|
6933 + | #[::tracing_test::traced_test]
|
6934 + | #[should_panic]
|
6935 + | async fn rest_json_malformed_enum_string_case0_malformed_request() {
|
6936 + | {
|
6937 + | #[allow(unused_mut)]
|
6938 + | let mut http_request = http::Request::builder()
|
6939 + | .uri("/MalformedEnum")
|
6940 + | .method("POST")
|
6941 + | .header("content-type", "application/json")
|
6942 + | .body(::aws_smithy_http_server::body::Body::from(
|
6943 + | ::bytes::Bytes::from_static("{ \"string\" : \"ABC\" }".as_bytes()),
|
6944 + | ))
|
6945 + | .unwrap();
|
6946 + | #[allow(unused_mut)]
|
6947 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6948 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6949 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
6950 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
6951 + | let sender = sender.clone();
|
6952 + | async move {
|
6953 + | 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> };
|
6954 + | sender.send(()).await.expect("receiver dropped early");
|
6955 + | result
|
6309 6956 | }
|
6310 - | crate::protocol_serde::shape_recursive_structures::de_recursive_structures_http_request(
|
6311 - | request,
|
6312 - | )
|
6957 + | })
|
6958 + | .build_unchecked();
|
6959 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6313 6960 | .await
|
6314 - | .map_err(Into::into)
|
6315 - | };
|
6316 - | use ::futures_util::future::TryFutureExt;
|
6317 - | let fut = fut.map_err(
|
6318 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6319 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6320 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6321 - | e,
|
6322 - | )
|
6323 - | },
|
6961 + | .expect("unable to make an HTTP request");
|
6962 + | ::pretty_assertions::assert_eq!(
|
6963 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6964 + | http_response.status()
|
6965 + | );
|
6966 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6967 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6968 + | http_response.headers(),
|
6969 + | expected_headers,
|
6970 + | ));
|
6971 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6972 + | .await
|
6973 + | .expect("unable to extract body to bytes");
|
6974 + | ::aws_smithy_protocol_test::assert_ok(
|
6975 + | ::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"))
|
6324 6976 | );
|
6325 - | RecursiveStructuresInputFuture {
|
6326 - | inner: Box::pin(fut),
|
6327 - | }
|
6328 - | }
|
6329 - | }
|
6330 - | impl
|
6331 - | ::aws_smithy_http_server::response::IntoResponse<
|
6332 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6333 - | > for crate::output::RecursiveStructuresOutput
|
6334 - | {
|
6335 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6336 - | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_response(self) {
|
6337 - | Ok(response) => response,
|
6338 - | Err(e) => {
|
6339 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6340 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6341 6977 | }
|
6342 6978 | }
|
6979 + | /// When a string member does not contain a valid enum value,
|
6980 + | /// the response should be a 400 ValidationException. Internal-only
|
6981 + | /// enum values are excluded from the response message.
|
6982 + | /// Test ID: RestJsonMalformedEnumString_case1
|
6983 + | #[::tokio::test]
|
6984 + | #[::tracing_test::traced_test]
|
6985 + | #[should_panic]
|
6986 + | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
6987 + | {
|
6988 + | #[allow(unused_mut)]
|
6989 + | let mut http_request = http::Request::builder()
|
6990 + | .uri("/MalformedEnum")
|
6991 + | .method("POST")
|
6992 + | .header("content-type", "application/json")
|
6993 + | .body(::aws_smithy_http_server::body::Body::from(
|
6994 + | ::bytes::Bytes::from_static("{ \"string\" : \"XYZ\" }".as_bytes()),
|
6995 + | ))
|
6996 + | .unwrap();
|
6997 + | #[allow(unused_mut)]
|
6998 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6999 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7000 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7001 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7002 + | let sender = sender.clone();
|
7003 + | async move {
|
7004 + | 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> };
|
7005 + | sender.send(()).await.expect("receiver dropped early");
|
7006 + | result
|
6343 7007 | }
|
6344 - | }
|
6345 - | impl
|
6346 - | ::aws_smithy_http_server::response::IntoResponse<
|
6347 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6348 - | > for crate::error::RecursiveStructuresError
|
6349 - | {
|
6350 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6351 - | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_error(
|
6352 - | &self,
|
6353 - | ) {
|
6354 - | Ok(mut response) => {
|
6355 - | response.extensions_mut().insert(
|
6356 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
7008 + | })
|
7009 + | .build_unchecked();
|
7010 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7011 + | .await
|
7012 + | .expect("unable to make an HTTP request");
|
7013 + | ::pretty_assertions::assert_eq!(
|
7014 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7015 + | http_response.status()
|
7016 + | );
|
7017 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7018 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7019 + | http_response.headers(),
|
7020 + | expected_headers,
|
7021 + | ));
|
7022 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7023 + | .await
|
7024 + | .expect("unable to extract body to bytes");
|
7025 + | ::aws_smithy_protocol_test::assert_ok(
|
7026 + | ::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"))
|
6357 7027 | );
|
6358 - | response
|
6359 - | }
|
6360 - | Err(e) => {
|
6361 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6362 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6363 7028 | }
|
6364 7029 | }
|
7030 + | /// When a string member does not contain a valid enum value,
|
7031 + | /// the response should be a 400 ValidationException. Internal-only
|
7032 + | /// enum values are excluded from the response message.
|
7033 + | /// Test ID: RestJsonMalformedEnumTraitString_case0
|
7034 + | #[::tokio::test]
|
7035 + | #[::tracing_test::traced_test]
|
7036 + | #[should_panic]
|
7037 + | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
7038 + | {
|
7039 + | #[allow(unused_mut)]
|
7040 + | let mut http_request = http::Request::builder()
|
7041 + | .uri("/MalformedEnum")
|
7042 + | .method("POST")
|
7043 + | .header("content-type", "application/json")
|
7044 + | .body(::aws_smithy_http_server::body::Body::from(
|
7045 + | ::bytes::Bytes::from_static("{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes()),
|
7046 + | ))
|
7047 + | .unwrap();
|
7048 + | #[allow(unused_mut)]
|
7049 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7050 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7051 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7052 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7053 + | let sender = sender.clone();
|
7054 + | async move {
|
7055 + | 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> };
|
7056 + | sender.send(()).await.expect("receiver dropped early");
|
7057 + | result
|
6365 7058 | }
|
6366 - | }
|
6367 - |
|
6368 - | const CONTENT_TYPE_MALFORMEDUNIQUEITEMS: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6369 - | ::pin_project_lite::pin_project! {
|
6370 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6371 - | /// [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) using modelled bindings.
|
6372 - | pub struct MalformedUniqueItemsInputFuture {
|
6373 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedUniqueItemsInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7059 + | })
|
7060 + | .build_unchecked();
|
7061 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7062 + | .await
|
7063 + | .expect("unable to make an HTTP request");
|
7064 + | ::pretty_assertions::assert_eq!(
|
7065 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7066 + | http_response.status()
|
7067 + | );
|
7068 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7069 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7070 + | http_response.headers(),
|
7071 + | expected_headers,
|
7072 + | ));
|
7073 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7074 + | .await
|
7075 + | .expect("unable to extract body to bytes");
|
7076 + | ::aws_smithy_protocol_test::assert_ok(
|
7077 + | ::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"))
|
7078 + | );
|
6374 7079 | }
|
6375 - | }
|
6376 - |
|
6377 - | impl std::future::Future for MalformedUniqueItemsInputFuture {
|
6378 - | type Output = Result<
|
6379 - | crate::input::MalformedUniqueItemsInput,
|
6380 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6381 - | >;
|
6382 - |
|
6383 - | fn poll(
|
6384 - | self: std::pin::Pin<&mut Self>,
|
6385 - | cx: &mut std::task::Context<'_>,
|
6386 - | ) -> std::task::Poll<Self::Output> {
|
6387 - | let this = self.project();
|
6388 - | this.inner.as_mut().poll(cx)
|
6389 7080 | }
|
6390 - | }
|
6391 - |
|
6392 - | impl<B>
|
6393 - | ::aws_smithy_http_server::request::FromRequest<
|
6394 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6395 - | B,
|
6396 - | > for crate::input::MalformedUniqueItemsInput
|
6397 - | where
|
6398 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6399 - | B: 'static,
|
6400 - |
|
6401 - | B::Data: Send,
|
6402 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6403 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6404 - | {
|
6405 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6406 - | type Future = MalformedUniqueItemsInputFuture;
|
6407 - |
|
6408 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6409 - | let fut = async move {
|
6410 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6411 - | request.headers(),
|
6412 - | &CONTENT_TYPE_MALFORMEDUNIQUEITEMS,
|
6413 - | ) {
|
6414 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7081 + | /// When a string member does not contain a valid enum value,
|
7082 + | /// the response should be a 400 ValidationException. Internal-only
|
7083 + | /// enum values are excluded from the response message.
|
7084 + | /// Test ID: RestJsonMalformedEnumTraitString_case1
|
7085 + | #[::tokio::test]
|
7086 + | #[::tracing_test::traced_test]
|
7087 + | #[should_panic]
|
7088 + | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
7089 + | {
|
7090 + | #[allow(unused_mut)]
|
7091 + | let mut http_request = http::Request::builder()
|
7092 + | .uri("/MalformedEnum")
|
7093 + | .method("POST")
|
7094 + | .header("content-type", "application/json")
|
7095 + | .body(::aws_smithy_http_server::body::Body::from(
|
7096 + | ::bytes::Bytes::from_static("{ \"stringWithEnumTrait\" : \"XYZ\" }".as_bytes()),
|
7097 + | ))
|
7098 + | .unwrap();
|
7099 + | #[allow(unused_mut)]
|
7100 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7101 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7102 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7103 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7104 + | let sender = sender.clone();
|
7105 + | async move {
|
7106 + | 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> };
|
7107 + | sender.send(()).await.expect("receiver dropped early");
|
7108 + | result
|
6415 7109 | }
|
6416 - | crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items_http_request(request)
|
7110 + | })
|
7111 + | .build_unchecked();
|
7112 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6417 7113 | .await
|
6418 - | .map_err(Into::into)
|
6419 - | };
|
6420 - | use ::futures_util::future::TryFutureExt;
|
6421 - | let fut = fut.map_err(
|
6422 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6423 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6424 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6425 - | e,
|
6426 - | )
|
6427 - | },
|
7114 + | .expect("unable to make an HTTP request");
|
7115 + | ::pretty_assertions::assert_eq!(
|
7116 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7117 + | http_response.status()
|
6428 7118 | );
|
6429 - | MalformedUniqueItemsInputFuture {
|
6430 - | inner: Box::pin(fut),
|
6431 - | }
|
6432 - | }
|
6433 - | }
|
6434 - | impl
|
6435 - | ::aws_smithy_http_server::response::IntoResponse<
|
6436 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6437 - | > for crate::output::MalformedUniqueItemsOutput
|
6438 - | {
|
6439 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6440 - | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_response(self) {
|
6441 - | Ok(response) => response,
|
6442 - | Err(e) => {
|
6443 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6444 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6445 - | }
|
6446 - | }
|
6447 - | }
|
6448 - | }
|
6449 - | impl
|
6450 - | ::aws_smithy_http_server::response::IntoResponse<
|
6451 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6452 - | > for crate::error::MalformedUniqueItemsError
|
6453 - | {
|
6454 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6455 - | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_error(&self) {
|
6456 - | Ok(mut response) => {
|
6457 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
6458 - | response
|
6459 - | },
|
6460 - | Err(e) => {
|
6461 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6462 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6463 - | }
|
6464 - | }
|
6465 - | }
|
6466 - | }
|
6467 - |
|
6468 - | const CONTENT_TYPE_MALFORMEDREQUIRED: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6469 - | ::pin_project_lite::pin_project! {
|
6470 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6471 - | /// [`MalformedRequiredInput`](crate::input::MalformedRequiredInput) using modelled bindings.
|
6472 - | pub struct MalformedRequiredInputFuture {
|
6473 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRequiredInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6474 - | }
|
6475 - | }
|
6476 - |
|
6477 - | impl std::future::Future for MalformedRequiredInputFuture {
|
6478 - | type Output = Result<
|
6479 - | crate::input::MalformedRequiredInput,
|
6480 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6481 - | >;
|
6482 - |
|
6483 - | fn poll(
|
6484 - | self: std::pin::Pin<&mut Self>,
|
6485 - | cx: &mut std::task::Context<'_>,
|
6486 - | ) -> std::task::Poll<Self::Output> {
|
6487 - | let this = self.project();
|
6488 - | this.inner.as_mut().poll(cx)
|
6489 - | }
|
6490 - | }
|
6491 - |
|
6492 - | impl<B>
|
6493 - | ::aws_smithy_http_server::request::FromRequest<
|
6494 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6495 - | B,
|
6496 - | > for crate::input::MalformedRequiredInput
|
6497 - | where
|
6498 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6499 - | B: 'static,
|
6500 - |
|
6501 - | B::Data: Send,
|
6502 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6503 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6504 - | {
|
6505 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6506 - | type Future = MalformedRequiredInputFuture;
|
6507 - |
|
6508 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6509 - | let fut = async move {
|
6510 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6511 - | request.headers(),
|
6512 - | &CONTENT_TYPE_MALFORMEDREQUIRED,
|
6513 - | ) {
|
6514 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6515 - | }
|
6516 - | crate::protocol_serde::shape_malformed_required::de_malformed_required_http_request(
|
6517 - | request,
|
6518 - | )
|
7119 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7120 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7121 + | http_response.headers(),
|
7122 + | expected_headers,
|
7123 + | ));
|
7124 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
6519 7125 | .await
|
6520 - | .map_err(Into::into)
|
6521 - | };
|
6522 - | use ::futures_util::future::TryFutureExt;
|
6523 - | let fut = fut.map_err(
|
6524 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6525 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6526 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6527 - | e,
|
6528 - | )
|
6529 - | },
|
7126 + | .expect("unable to extract body to bytes");
|
7127 + | ::aws_smithy_protocol_test::assert_ok(
|
7128 + | ::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"))
|
6530 7129 | );
|
6531 - | MalformedRequiredInputFuture {
|
6532 - | inner: Box::pin(fut),
|
6533 - | }
|
6534 - | }
|
6535 - | }
|
6536 - | impl
|
6537 - | ::aws_smithy_http_server::response::IntoResponse<
|
6538 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6539 - | > for crate::output::MalformedRequiredOutput
|
6540 - | {
|
6541 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6542 - | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_response(
|
6543 - | self,
|
6544 - | ) {
|
6545 - | Ok(response) => response,
|
6546 - | Err(e) => {
|
6547 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6548 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6549 7130 | }
|
6550 7131 | }
|
7132 + | /// When a list member value does not contain a valid enum value,
|
7133 + | /// the response should be a 400 ValidationException. Internal-only
|
7134 + | /// enum values are excluded from the response message.
|
7135 + | /// Test ID: RestJsonMalformedEnumList_case0
|
7136 + | #[::tokio::test]
|
7137 + | #[::tracing_test::traced_test]
|
7138 + | #[should_panic]
|
7139 + | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
7140 + | {
|
7141 + | #[allow(unused_mut)]
|
7142 + | let mut http_request = http::Request::builder()
|
7143 + | .uri("/MalformedEnum")
|
7144 + | .method("POST")
|
7145 + | .header("content-type", "application/json")
|
7146 + | .body(::aws_smithy_http_server::body::Body::from(
|
7147 + | ::bytes::Bytes::from_static("{ \"list\" : [\"ABC\"] }".as_bytes()),
|
7148 + | ))
|
7149 + | .unwrap();
|
7150 + | #[allow(unused_mut)]
|
7151 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7152 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7153 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7154 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7155 + | let sender = sender.clone();
|
7156 + | async move {
|
7157 + | 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> };
|
7158 + | sender.send(()).await.expect("receiver dropped early");
|
7159 + | result
|
6551 7160 | }
|
6552 - | }
|
6553 - | impl
|
6554 - | ::aws_smithy_http_server::response::IntoResponse<
|
6555 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6556 - | > for crate::error::MalformedRequiredError
|
6557 - | {
|
6558 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6559 - | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_error(
|
6560 - | &self,
|
6561 - | ) {
|
6562 - | Ok(mut response) => {
|
6563 - | response.extensions_mut().insert(
|
6564 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
7161 + | })
|
7162 + | .build_unchecked();
|
7163 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7164 + | .await
|
7165 + | .expect("unable to make an HTTP request");
|
7166 + | ::pretty_assertions::assert_eq!(
|
7167 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7168 + | http_response.status()
|
6565 7169 | );
|
6566 - | response
|
6567 - | }
|
6568 - | Err(e) => {
|
6569 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6570 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6571 - | }
|
6572 - | }
|
6573 - | }
|
6574 - | }
|
6575 - |
|
6576 - | const CONTENT_TYPE_MALFORMEDRANGEOVERRIDE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6577 - | ::pin_project_lite::pin_project! {
|
6578 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6579 - | /// [`MalformedRangeOverrideInput`](crate::input::MalformedRangeOverrideInput) using modelled bindings.
|
6580 - | pub struct MalformedRangeOverrideInputFuture {
|
6581 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRangeOverrideInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6582 - | }
|
6583 - | }
|
6584 - |
|
6585 - | impl std::future::Future for MalformedRangeOverrideInputFuture {
|
6586 - | type Output = Result<
|
6587 - | crate::input::MalformedRangeOverrideInput,
|
6588 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6589 - | >;
|
6590 - |
|
6591 - | fn poll(
|
6592 - | self: std::pin::Pin<&mut Self>,
|
6593 - | cx: &mut std::task::Context<'_>,
|
6594 - | ) -> std::task::Poll<Self::Output> {
|
6595 - | let this = self.project();
|
6596 - | this.inner.as_mut().poll(cx)
|
6597 - | }
|
6598 - | }
|
6599 - |
|
6600 - | impl<B>
|
6601 - | ::aws_smithy_http_server::request::FromRequest<
|
6602 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6603 - | B,
|
6604 - | > for crate::input::MalformedRangeOverrideInput
|
6605 - | where
|
6606 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6607 - | B: 'static,
|
6608 - |
|
6609 - | B::Data: Send,
|
6610 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6611 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6612 - | {
|
6613 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6614 - | type Future = MalformedRangeOverrideInputFuture;
|
6615 - |
|
6616 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6617 - | let fut = async move {
|
6618 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6619 - | request.headers(),
|
6620 - | &CONTENT_TYPE_MALFORMEDRANGEOVERRIDE,
|
6621 - | ) {
|
6622 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6623 - | }
|
6624 - | crate::protocol_serde::shape_malformed_range_override::de_malformed_range_override_http_request(request)
|
6625 - | .await
|
6626 - | .map_err(Into::into)
|
6627 - | };
|
6628 - | use ::futures_util::future::TryFutureExt;
|
6629 - | let fut = fut.map_err(
|
6630 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6631 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6632 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6633 - | e,
|
6634 - | )
|
6635 - | },
|
6636 - | );
|
6637 - | MalformedRangeOverrideInputFuture {
|
6638 - | inner: Box::pin(fut),
|
6639 - | }
|
6640 - | }
|
6641 - | }
|
6642 - | impl
|
6643 - | ::aws_smithy_http_server::response::IntoResponse<
|
6644 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6645 - | > for crate::output::MalformedRangeOverrideOutput
|
6646 - | {
|
6647 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6648 - | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_response(self) {
|
6649 - | Ok(response) => response,
|
6650 - | Err(e) => {
|
6651 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6652 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6653 - | }
|
6654 - | }
|
6655 - | }
|
6656 - | }
|
6657 - | impl
|
6658 - | ::aws_smithy_http_server::response::IntoResponse<
|
6659 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6660 - | > for crate::error::MalformedRangeOverrideError
|
6661 - | {
|
6662 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6663 - | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_error(&self) {
|
6664 - | Ok(mut response) => {
|
6665 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
6666 - | response
|
6667 - | },
|
6668 - | Err(e) => {
|
6669 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6670 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6671 - | }
|
6672 - | }
|
6673 - | }
|
6674 - | }
|
6675 - |
|
6676 - | const CONTENT_TYPE_MALFORMEDRANGE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6677 - | ::pin_project_lite::pin_project! {
|
6678 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6679 - | /// [`MalformedRangeInput`](crate::input::MalformedRangeInput) using modelled bindings.
|
6680 - | pub struct MalformedRangeInputFuture {
|
6681 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedRangeInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6682 - | }
|
6683 - | }
|
6684 - |
|
6685 - | impl std::future::Future for MalformedRangeInputFuture {
|
6686 - | type Output = Result<
|
6687 - | crate::input::MalformedRangeInput,
|
6688 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6689 - | >;
|
6690 - |
|
6691 - | fn poll(
|
6692 - | self: std::pin::Pin<&mut Self>,
|
6693 - | cx: &mut std::task::Context<'_>,
|
6694 - | ) -> std::task::Poll<Self::Output> {
|
6695 - | let this = self.project();
|
6696 - | this.inner.as_mut().poll(cx)
|
6697 - | }
|
6698 - | }
|
6699 - |
|
6700 - | impl<B>
|
6701 - | ::aws_smithy_http_server::request::FromRequest<
|
6702 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6703 - | B,
|
6704 - | > for crate::input::MalformedRangeInput
|
6705 - | where
|
6706 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6707 - | B: 'static,
|
6708 - |
|
6709 - | B::Data: Send,
|
6710 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6711 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6712 - | {
|
6713 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6714 - | type Future = MalformedRangeInputFuture;
|
6715 - |
|
6716 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6717 - | let fut = async move {
|
6718 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6719 - | request.headers(),
|
6720 - | &CONTENT_TYPE_MALFORMEDRANGE,
|
6721 - | ) {
|
6722 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6723 - | }
|
6724 - | crate::protocol_serde::shape_malformed_range::de_malformed_range_http_request(request)
|
6725 - | .await
|
6726 - | .map_err(Into::into)
|
6727 - | };
|
6728 - | use ::futures_util::future::TryFutureExt;
|
6729 - | let fut = fut.map_err(
|
6730 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6731 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6732 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6733 - | e,
|
6734 - | )
|
6735 - | },
|
6736 - | );
|
6737 - | MalformedRangeInputFuture {
|
6738 - | inner: Box::pin(fut),
|
6739 - | }
|
6740 - | }
|
6741 - | }
|
6742 - | impl
|
6743 - | ::aws_smithy_http_server::response::IntoResponse<
|
6744 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6745 - | > for crate::output::MalformedRangeOutput
|
6746 - | {
|
6747 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6748 - | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_response(self)
|
6749 - | {
|
6750 - | Ok(response) => response,
|
6751 - | Err(e) => {
|
6752 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6753 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6754 - | }
|
6755 - | }
|
6756 - | }
|
6757 - | }
|
6758 - | impl
|
6759 - | ::aws_smithy_http_server::response::IntoResponse<
|
6760 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6761 - | > for crate::error::MalformedRangeError
|
6762 - | {
|
6763 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6764 - | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_error(&self) {
|
6765 - | Ok(mut response) => {
|
6766 - | response.extensions_mut().insert(
|
6767 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
6768 - | );
|
6769 - | response
|
6770 - | }
|
6771 - | Err(e) => {
|
6772 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6773 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6774 - | }
|
6775 - | }
|
6776 - | }
|
6777 - | }
|
6778 - |
|
6779 - | const CONTENT_TYPE_MALFORMEDPATTERNOVERRIDE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6780 - | ::pin_project_lite::pin_project! {
|
6781 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6782 - | /// [`MalformedPatternOverrideInput`](crate::input::MalformedPatternOverrideInput) using modelled bindings.
|
6783 - | pub struct MalformedPatternOverrideInputFuture {
|
6784 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedPatternOverrideInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6785 - | }
|
6786 - | }
|
6787 - |
|
6788 - | impl std::future::Future for MalformedPatternOverrideInputFuture {
|
6789 - | type Output = Result<
|
6790 - | crate::input::MalformedPatternOverrideInput,
|
6791 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6792 - | >;
|
6793 - |
|
6794 - | fn poll(
|
6795 - | self: std::pin::Pin<&mut Self>,
|
6796 - | cx: &mut std::task::Context<'_>,
|
6797 - | ) -> std::task::Poll<Self::Output> {
|
6798 - | let this = self.project();
|
6799 - | this.inner.as_mut().poll(cx)
|
6800 - | }
|
6801 - | }
|
6802 - |
|
6803 - | impl<B>
|
6804 - | ::aws_smithy_http_server::request::FromRequest<
|
6805 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6806 - | B,
|
6807 - | > for crate::input::MalformedPatternOverrideInput
|
6808 - | where
|
6809 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6810 - | B: 'static,
|
6811 - |
|
6812 - | B::Data: Send,
|
6813 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6814 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6815 - | {
|
6816 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6817 - | type Future = MalformedPatternOverrideInputFuture;
|
6818 - |
|
6819 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6820 - | let fut = async move {
|
6821 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6822 - | request.headers(),
|
6823 - | &CONTENT_TYPE_MALFORMEDPATTERNOVERRIDE,
|
6824 - | ) {
|
6825 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6826 - | }
|
6827 - | crate::protocol_serde::shape_malformed_pattern_override::de_malformed_pattern_override_http_request(request)
|
6828 - | .await
|
6829 - | .map_err(Into::into)
|
6830 - | };
|
6831 - | use ::futures_util::future::TryFutureExt;
|
6832 - | let fut = fut.map_err(
|
6833 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6834 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6835 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6836 - | e,
|
6837 - | )
|
6838 - | },
|
6839 - | );
|
6840 - | MalformedPatternOverrideInputFuture {
|
6841 - | inner: Box::pin(fut),
|
6842 - | }
|
6843 - | }
|
6844 - | }
|
6845 - | impl
|
6846 - | ::aws_smithy_http_server::response::IntoResponse<
|
6847 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6848 - | > for crate::output::MalformedPatternOverrideOutput
|
6849 - | {
|
6850 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6851 - | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_response(self) {
|
6852 - | Ok(response) => response,
|
6853 - | Err(e) => {
|
6854 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6855 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6856 - | }
|
6857 - | }
|
6858 - | }
|
6859 - | }
|
6860 - | impl
|
6861 - | ::aws_smithy_http_server::response::IntoResponse<
|
6862 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6863 - | > for crate::error::MalformedPatternOverrideError
|
6864 - | {
|
6865 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6866 - | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_error(&self) {
|
6867 - | Ok(mut response) => {
|
6868 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
6869 - | response
|
6870 - | },
|
6871 - | Err(e) => {
|
6872 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6873 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6874 - | }
|
6875 - | }
|
6876 - | }
|
6877 - | }
|
6878 - |
|
6879 - | const CONTENT_TYPE_MALFORMEDPATTERN: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6880 - | ::pin_project_lite::pin_project! {
|
6881 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6882 - | /// [`MalformedPatternInput`](crate::input::MalformedPatternInput) using modelled bindings.
|
6883 - | pub struct MalformedPatternInputFuture {
|
6884 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedPatternInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6885 - | }
|
6886 - | }
|
6887 - |
|
6888 - | impl std::future::Future for MalformedPatternInputFuture {
|
6889 - | type Output = Result<
|
6890 - | crate::input::MalformedPatternInput,
|
6891 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6892 - | >;
|
6893 - |
|
6894 - | fn poll(
|
6895 - | self: std::pin::Pin<&mut Self>,
|
6896 - | cx: &mut std::task::Context<'_>,
|
6897 - | ) -> std::task::Poll<Self::Output> {
|
6898 - | let this = self.project();
|
6899 - | this.inner.as_mut().poll(cx)
|
6900 - | }
|
6901 - | }
|
6902 - |
|
6903 - | impl<B>
|
6904 - | ::aws_smithy_http_server::request::FromRequest<
|
6905 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6906 - | B,
|
6907 - | > for crate::input::MalformedPatternInput
|
6908 - | where
|
6909 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6910 - | B: 'static,
|
6911 - |
|
6912 - | B::Data: Send,
|
6913 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6914 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6915 - | {
|
6916 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6917 - | type Future = MalformedPatternInputFuture;
|
6918 - |
|
6919 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
6920 - | let fut = async move {
|
6921 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6922 - | request.headers(),
|
6923 - | &CONTENT_TYPE_MALFORMEDPATTERN,
|
6924 - | ) {
|
6925 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6926 - | }
|
6927 - | crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern_http_request(
|
6928 - | request,
|
6929 - | )
|
6930 - | .await
|
6931 - | .map_err(Into::into)
|
6932 - | };
|
6933 - | use ::futures_util::future::TryFutureExt;
|
6934 - | let fut = fut.map_err(
|
6935 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6936 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6937 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6938 - | e,
|
6939 - | )
|
6940 - | },
|
6941 - | );
|
6942 - | MalformedPatternInputFuture {
|
6943 - | inner: Box::pin(fut),
|
6944 - | }
|
6945 - | }
|
6946 - | }
|
6947 - | impl
|
6948 - | ::aws_smithy_http_server::response::IntoResponse<
|
6949 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6950 - | > for crate::output::MalformedPatternOutput
|
6951 - | {
|
6952 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6953 - | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_response(
|
6954 - | self,
|
6955 - | ) {
|
6956 - | Ok(response) => response,
|
6957 - | Err(e) => {
|
6958 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6959 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6960 - | }
|
6961 - | }
|
6962 - | }
|
6963 - | }
|
6964 - | impl
|
6965 - | ::aws_smithy_http_server::response::IntoResponse<
|
6966 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6967 - | > for crate::error::MalformedPatternError
|
6968 - | {
|
6969 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6970 - | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_error(
|
6971 - | &self,
|
6972 - | ) {
|
6973 - | Ok(mut response) => {
|
6974 - | response.extensions_mut().insert(
|
6975 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
6976 - | );
|
6977 - | response
|
6978 - | }
|
6979 - | Err(e) => {
|
6980 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6981 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
6982 - | }
|
6983 - | }
|
6984 - | }
|
6985 - | }
|
6986 - |
|
6987 - | const CONTENT_TYPE_MALFORMEDLENGTHQUERYSTRING: ::mime::Mime = ::mime::APPLICATION_JSON;
|
6988 - | ::pin_project_lite::pin_project! {
|
6989 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6990 - | /// [`MalformedLengthQueryStringInput`](crate::input::MalformedLengthQueryStringInput) using modelled bindings.
|
6991 - | pub struct MalformedLengthQueryStringInputFuture {
|
6992 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthQueryStringInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
6993 - | }
|
6994 - | }
|
6995 - |
|
6996 - | impl std::future::Future for MalformedLengthQueryStringInputFuture {
|
6997 - | type Output = Result<
|
6998 - | crate::input::MalformedLengthQueryStringInput,
|
6999 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
7000 - | >;
|
7001 - |
|
7002 - | fn poll(
|
7003 - | self: std::pin::Pin<&mut Self>,
|
7004 - | cx: &mut std::task::Context<'_>,
|
7005 - | ) -> std::task::Poll<Self::Output> {
|
7006 - | let this = self.project();
|
7007 - | this.inner.as_mut().poll(cx)
|
7008 - | }
|
7009 - | }
|
7010 - |
|
7011 - | impl<B>
|
7012 - | ::aws_smithy_http_server::request::FromRequest<
|
7013 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7014 - | B,
|
7015 - | > for crate::input::MalformedLengthQueryStringInput
|
7016 - | where
|
7017 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
7018 - | B: 'static,
|
7019 - |
|
7020 - | B::Data: Send,
|
7021 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
7022 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
7023 - | {
|
7024 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
7025 - | type Future = MalformedLengthQueryStringInputFuture;
|
7026 - |
|
7027 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
7028 - | let fut = async move {
|
7029 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
7030 - | request.headers(),
|
7031 - | &CONTENT_TYPE_MALFORMEDLENGTHQUERYSTRING,
|
7032 - | ) {
|
7033 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7034 - | }
|
7035 - | crate::protocol_serde::shape_malformed_length_query_string::de_malformed_length_query_string_http_request(request)
|
7036 - | .await
|
7037 - | .map_err(Into::into)
|
7038 - | };
|
7039 - | use ::futures_util::future::TryFutureExt;
|
7040 - | let fut = fut.map_err(
|
7041 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
7042 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
7043 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
7044 - | e,
|
7045 - | )
|
7046 - | },
|
7047 - | );
|
7048 - | MalformedLengthQueryStringInputFuture {
|
7049 - | inner: Box::pin(fut),
|
7050 - | }
|
7051 - | }
|
7052 - | }
|
7053 - | impl
|
7054 - | ::aws_smithy_http_server::response::IntoResponse<
|
7055 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7056 - | > for crate::output::MalformedLengthQueryStringOutput
|
7057 - | {
|
7058 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7059 - | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_response(self) {
|
7060 - | Ok(response) => response,
|
7061 - | Err(e) => {
|
7062 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7063 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7064 - | }
|
7065 - | }
|
7066 - | }
|
7067 - | }
|
7068 - | impl
|
7069 - | ::aws_smithy_http_server::response::IntoResponse<
|
7070 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7071 - | > for crate::error::MalformedLengthQueryStringError
|
7072 - | {
|
7073 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7074 - | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_error(&self) {
|
7075 - | Ok(mut response) => {
|
7076 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
7077 - | response
|
7078 - | },
|
7079 - | Err(e) => {
|
7080 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7081 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7082 - | }
|
7083 - | }
|
7084 - | }
|
7085 - | }
|
7086 - |
|
7087 - | const CONTENT_TYPE_MALFORMEDLENGTHOVERRIDE: ::mime::Mime = ::mime::APPLICATION_JSON;
|
7088 - | ::pin_project_lite::pin_project! {
|
7089 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
7090 - | /// [`MalformedLengthOverrideInput`](crate::input::MalformedLengthOverrideInput) using modelled bindings.
|
7091 - | pub struct MalformedLengthOverrideInputFuture {
|
7092 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthOverrideInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7093 - | }
|
7094 - | }
|
7095 - |
|
7096 - | impl std::future::Future for MalformedLengthOverrideInputFuture {
|
7097 - | type Output = Result<
|
7098 - | crate::input::MalformedLengthOverrideInput,
|
7099 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
7100 - | >;
|
7101 - |
|
7102 - | fn poll(
|
7103 - | self: std::pin::Pin<&mut Self>,
|
7104 - | cx: &mut std::task::Context<'_>,
|
7105 - | ) -> std::task::Poll<Self::Output> {
|
7106 - | let this = self.project();
|
7107 - | this.inner.as_mut().poll(cx)
|
7108 - | }
|
7109 - | }
|
7110 - |
|
7111 - | impl<B>
|
7112 - | ::aws_smithy_http_server::request::FromRequest<
|
7113 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7114 - | B,
|
7115 - | > for crate::input::MalformedLengthOverrideInput
|
7116 - | where
|
7117 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
7118 - | B: 'static,
|
7119 - |
|
7120 - | B::Data: Send,
|
7121 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
7122 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
7123 - | {
|
7124 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
7125 - | type Future = MalformedLengthOverrideInputFuture;
|
7126 - |
|
7127 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
7128 - | let fut = async move {
|
7129 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
7130 - | request.headers(),
|
7131 - | &CONTENT_TYPE_MALFORMEDLENGTHOVERRIDE,
|
7132 - | ) {
|
7133 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7134 - | }
|
7135 - | crate::protocol_serde::shape_malformed_length_override::de_malformed_length_override_http_request(request)
|
7170 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7171 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7172 + | http_response.headers(),
|
7173 + | expected_headers,
|
7174 + | ));
|
7175 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7136 7176 | .await
|
7137 - | .map_err(Into::into)
|
7138 - | };
|
7139 - | use ::futures_util::future::TryFutureExt;
|
7140 - | let fut = fut.map_err(
|
7141 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
7142 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
7143 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
7144 - | e,
|
7145 - | )
|
7146 - | },
|
7147 - | );
|
7148 - | MalformedLengthOverrideInputFuture {
|
7149 - | inner: Box::pin(fut),
|
7150 - | }
|
7151 - | }
|
7152 - | }
|
7153 - | impl
|
7154 - | ::aws_smithy_http_server::response::IntoResponse<
|
7155 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7156 - | > for crate::output::MalformedLengthOverrideOutput
|
7157 - | {
|
7158 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7159 - | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_response(self) {
|
7160 - | Ok(response) => response,
|
7161 - | Err(e) => {
|
7162 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7163 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7164 - | }
|
7165 - | }
|
7166 - | }
|
7167 - | }
|
7168 - | impl
|
7169 - | ::aws_smithy_http_server::response::IntoResponse<
|
7170 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7171 - | > for crate::error::MalformedLengthOverrideError
|
7172 - | {
|
7173 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7174 - | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_error(&self) {
|
7175 - | Ok(mut response) => {
|
7176 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
7177 - | response
|
7178 - | },
|
7179 - | Err(e) => {
|
7180 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7181 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7177 + | .expect("unable to extract body to bytes");
|
7178 + | ::aws_smithy_protocol_test::assert_ok(
|
7179 + | ::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"))
|
7180 + | );
|
7182 7181 | }
|
7183 7182 | }
|
7183 + | /// When a list member value does not contain a valid enum value,
|
7184 + | /// the response should be a 400 ValidationException. Internal-only
|
7185 + | /// enum values are excluded from the response message.
|
7186 + | /// Test ID: RestJsonMalformedEnumList_case1
|
7187 + | #[::tokio::test]
|
7188 + | #[::tracing_test::traced_test]
|
7189 + | #[should_panic]
|
7190 + | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
7191 + | {
|
7192 + | #[allow(unused_mut)]
|
7193 + | let mut http_request = http::Request::builder()
|
7194 + | .uri("/MalformedEnum")
|
7195 + | .method("POST")
|
7196 + | .header("content-type", "application/json")
|
7197 + | .body(::aws_smithy_http_server::body::Body::from(
|
7198 + | ::bytes::Bytes::from_static("{ \"list\" : [\"XYZ\"] }".as_bytes()),
|
7199 + | ))
|
7200 + | .unwrap();
|
7201 + | #[allow(unused_mut)]
|
7202 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7203 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7204 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7205 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7206 + | let sender = sender.clone();
|
7207 + | async move {
|
7208 + | 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> };
|
7209 + | sender.send(()).await.expect("receiver dropped early");
|
7210 + | result
|
7184 7211 | }
|
7185 - | }
|
7186 - |
|
7187 - | const CONTENT_TYPE_MALFORMEDLENGTH: ::mime::Mime = ::mime::APPLICATION_JSON;
|
7188 - | ::pin_project_lite::pin_project! {
|
7189 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
7190 - | /// [`MalformedLengthInput`](crate::input::MalformedLengthInput) using modelled bindings.
|
7191 - | pub struct MalformedLengthInputFuture {
|
7192 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedLengthInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7212 + | })
|
7213 + | .build_unchecked();
|
7214 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7215 + | .await
|
7216 + | .expect("unable to make an HTTP request");
|
7217 + | ::pretty_assertions::assert_eq!(
|
7218 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7219 + | http_response.status()
|
7220 + | );
|
7221 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7222 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7223 + | http_response.headers(),
|
7224 + | expected_headers,
|
7225 + | ));
|
7226 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7227 + | .await
|
7228 + | .expect("unable to extract body to bytes");
|
7229 + | ::aws_smithy_protocol_test::assert_ok(
|
7230 + | ::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"))
|
7231 + | );
|
7193 7232 | }
|
7194 - | }
|
7195 - |
|
7196 - | impl std::future::Future for MalformedLengthInputFuture {
|
7197 - | type Output = Result<
|
7198 - | crate::input::MalformedLengthInput,
|
7199 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
7200 - | >;
|
7201 - |
|
7202 - | fn poll(
|
7203 - | self: std::pin::Pin<&mut Self>,
|
7204 - | cx: &mut std::task::Context<'_>,
|
7205 - | ) -> std::task::Poll<Self::Output> {
|
7206 - | let this = self.project();
|
7207 - | this.inner.as_mut().poll(cx)
|
7208 7233 | }
|
7209 - | }
|
7210 - |
|
7211 - | impl<B>
|
7212 - | ::aws_smithy_http_server::request::FromRequest<
|
7213 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7214 - | B,
|
7215 - | > for crate::input::MalformedLengthInput
|
7216 - | where
|
7217 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
7218 - | B: 'static,
|
7219 - |
|
7220 - | B::Data: Send,
|
7221 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
7222 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
7223 - | {
|
7224 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
7225 - | type Future = MalformedLengthInputFuture;
|
7226 - |
|
7227 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
7228 - | let fut = async move {
|
7229 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
7230 - | request.headers(),
|
7231 - | &CONTENT_TYPE_MALFORMEDLENGTH,
|
7232 - | ) {
|
7233 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7234 + | /// When a map member's key does not contain a valid enum value,
|
7235 + | /// the response should be a 400 ValidationException. Internal-only
|
7236 + | /// enum values are excluded from the response message.
|
7237 + | /// Test ID: RestJsonMalformedEnumMapKey_case0
|
7238 + | #[::tokio::test]
|
7239 + | #[::tracing_test::traced_test]
|
7240 + | #[should_panic]
|
7241 + | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
7242 + | {
|
7243 + | #[allow(unused_mut)]
|
7244 + | let mut http_request = http::Request::builder()
|
7245 + | .uri("/MalformedEnum")
|
7246 + | .method("POST")
|
7247 + | .header("content-type", "application/json")
|
7248 + | .body(::aws_smithy_http_server::body::Body::from(
|
7249 + | ::bytes::Bytes::from_static("{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes()),
|
7250 + | ))
|
7251 + | .unwrap();
|
7252 + | #[allow(unused_mut)]
|
7253 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7254 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7255 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7256 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7257 + | let sender = sender.clone();
|
7258 + | async move {
|
7259 + | 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> };
|
7260 + | sender.send(()).await.expect("receiver dropped early");
|
7261 + | result
|
7234 7262 | }
|
7235 - | crate::protocol_serde::shape_malformed_length::de_malformed_length_http_request(request)
|
7263 + | })
|
7264 + | .build_unchecked();
|
7265 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7236 7266 | .await
|
7237 - | .map_err(Into::into)
|
7238 - | };
|
7239 - | use ::futures_util::future::TryFutureExt;
|
7240 - | let fut = fut.map_err(
|
7241 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
7242 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
7243 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
7244 - | e,
|
7245 - | )
|
7246 - | },
|
7267 + | .expect("unable to make an HTTP request");
|
7268 + | ::pretty_assertions::assert_eq!(
|
7269 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7270 + | http_response.status()
|
7271 + | );
|
7272 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7273 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7274 + | http_response.headers(),
|
7275 + | expected_headers,
|
7276 + | ));
|
7277 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7278 + | .await
|
7279 + | .expect("unable to extract body to bytes");
|
7280 + | ::aws_smithy_protocol_test::assert_ok(
|
7281 + | ::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"))
|
7247 7282 | );
|
7248 - | MalformedLengthInputFuture {
|
7249 - | inner: Box::pin(fut),
|
7250 7283 | }
|
7251 7284 | }
|
7252 - | }
|
7253 - | impl
|
7254 - | ::aws_smithy_http_server::response::IntoResponse<
|
7255 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7256 - | > for crate::output::MalformedLengthOutput
|
7257 - | {
|
7258 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7259 - | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_response(
|
7260 - | self,
|
7261 - | ) {
|
7262 - | Ok(response) => response,
|
7263 - | Err(e) => {
|
7264 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7265 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7285 + | /// When a map member's key does not contain a valid enum value,
|
7286 + | /// the response should be a 400 ValidationException. Internal-only
|
7287 + | /// enum values are excluded from the response message.
|
7288 + | /// Test ID: RestJsonMalformedEnumMapKey_case1
|
7289 + | #[::tokio::test]
|
7290 + | #[::tracing_test::traced_test]
|
7291 + | #[should_panic]
|
7292 + | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
7293 + | {
|
7294 + | #[allow(unused_mut)]
|
7295 + | let mut http_request = http::Request::builder()
|
7296 + | .uri("/MalformedEnum")
|
7297 + | .method("POST")
|
7298 + | .header("content-type", "application/json")
|
7299 + | .body(::aws_smithy_http_server::body::Body::from(
|
7300 + | ::bytes::Bytes::from_static("{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes()),
|
7301 + | ))
|
7302 + | .unwrap();
|
7303 + | #[allow(unused_mut)]
|
7304 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7305 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7306 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7307 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7308 + | let sender = sender.clone();
|
7309 + | async move {
|
7310 + | 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> };
|
7311 + | sender.send(()).await.expect("receiver dropped early");
|
7312 + | result
|
7266 7313 | }
|
7314 + | })
|
7315 + | .build_unchecked();
|
7316 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7317 + | .await
|
7318 + | .expect("unable to make an HTTP request");
|
7319 + | ::pretty_assertions::assert_eq!(
|
7320 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7321 + | http_response.status()
|
7322 + | );
|
7323 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7324 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7325 + | http_response.headers(),
|
7326 + | expected_headers,
|
7327 + | ));
|
7328 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7329 + | .await
|
7330 + | .expect("unable to extract body to bytes");
|
7331 + | ::aws_smithy_protocol_test::assert_ok(
|
7332 + | ::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"))
|
7333 + | );
|
7267 7334 | }
|
7268 7335 | }
|
7269 - | }
|
7270 - | impl
|
7271 - | ::aws_smithy_http_server::response::IntoResponse<
|
7272 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7273 - | > for crate::error::MalformedLengthError
|
7274 - | {
|
7275 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7276 - | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_error(&self)
|
7336 + | /// When a map member's value does not contain a valid enum value,
|
7337 + | /// the response should be a 400 ValidationException. Internal-only
|
7338 + | /// enum values are excluded from the response message.
|
7339 + | /// Test ID: RestJsonMalformedEnumMapValue_case0
|
7340 + | #[::tokio::test]
|
7341 + | #[::tracing_test::traced_test]
|
7342 + | #[should_panic]
|
7343 + | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
7277 7344 | {
|
7278 - | Ok(mut response) => {
|
7279 - | response.extensions_mut().insert(
|
7280 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
7281 - | );
|
7282 - | response
|
7345 + | #[allow(unused_mut)]
|
7346 + | let mut http_request = http::Request::builder()
|
7347 + | .uri("/MalformedEnum")
|
7348 + | .method("POST")
|
7349 + | .header("content-type", "application/json")
|
7350 + | .body(::aws_smithy_http_server::body::Body::from(
|
7351 + | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes()),
|
7352 + | ))
|
7353 + | .unwrap();
|
7354 + | #[allow(unused_mut)]
|
7355 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7356 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7357 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7358 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7359 + | let sender = sender.clone();
|
7360 + | async move {
|
7361 + | 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> };
|
7362 + | sender.send(()).await.expect("receiver dropped early");
|
7363 + | result
|
7283 7364 | }
|
7284 - | Err(e) => {
|
7285 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7286 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7365 + | })
|
7366 + | .build_unchecked();
|
7367 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7368 + | .await
|
7369 + | .expect("unable to make an HTTP request");
|
7370 + | ::pretty_assertions::assert_eq!(
|
7371 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7372 + | http_response.status()
|
7373 + | );
|
7374 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7375 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7376 + | http_response.headers(),
|
7377 + | expected_headers,
|
7378 + | ));
|
7379 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7380 + | .await
|
7381 + | .expect("unable to extract body to bytes");
|
7382 + | ::aws_smithy_protocol_test::assert_ok(
|
7383 + | ::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"))
|
7384 + | );
|
7287 7385 | }
|
7288 7386 | }
|
7387 + | /// When a map member's value does not contain a valid enum value,
|
7388 + | /// the response should be a 400 ValidationException. Internal-only
|
7389 + | /// enum values are excluded from the response message.
|
7390 + | /// Test ID: RestJsonMalformedEnumMapValue_case1
|
7391 + | #[::tokio::test]
|
7392 + | #[::tracing_test::traced_test]
|
7393 + | #[should_panic]
|
7394 + | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
7395 + | {
|
7396 + | #[allow(unused_mut)]
|
7397 + | let mut http_request = http::Request::builder()
|
7398 + | .uri("/MalformedEnum")
|
7399 + | .method("POST")
|
7400 + | .header("content-type", "application/json")
|
7401 + | .body(::aws_smithy_http_server::body::Body::from(
|
7402 + | ::bytes::Bytes::from_static("{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes()),
|
7403 + | ))
|
7404 + | .unwrap();
|
7405 + | #[allow(unused_mut)]
|
7406 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7407 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7408 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7409 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7410 + | let sender = sender.clone();
|
7411 + | async move {
|
7412 + | 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> };
|
7413 + | sender.send(()).await.expect("receiver dropped early");
|
7414 + | result
|
7289 7415 | }
|
7290 - | }
|
7291 - |
|
7292 - | const CONTENT_TYPE_MALFORMEDENUM: ::mime::Mime = ::mime::APPLICATION_JSON;
|
7293 - | ::pin_project_lite::pin_project! {
|
7294 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
7295 - | /// [`MalformedEnumInput`](crate::input::MalformedEnumInput) using modelled bindings.
|
7296 - | pub struct MalformedEnumInputFuture {
|
7297 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedEnumInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
7416 + | })
|
7417 + | .build_unchecked();
|
7418 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7419 + | .await
|
7420 + | .expect("unable to make an HTTP request");
|
7421 + | ::pretty_assertions::assert_eq!(
|
7422 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7423 + | http_response.status()
|
7424 + | );
|
7425 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7426 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7427 + | http_response.headers(),
|
7428 + | expected_headers,
|
7429 + | ));
|
7430 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7431 + | .await
|
7432 + | .expect("unable to extract body to bytes");
|
7433 + | ::aws_smithy_protocol_test::assert_ok(
|
7434 + | ::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"))
|
7435 + | );
|
7298 7436 | }
|
7299 - | }
|
7300 - |
|
7301 - | impl std::future::Future for MalformedEnumInputFuture {
|
7302 - | type Output = Result<
|
7303 - | crate::input::MalformedEnumInput,
|
7304 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
7305 - | >;
|
7306 - |
|
7307 - | fn poll(
|
7308 - | self: std::pin::Pin<&mut Self>,
|
7309 - | cx: &mut std::task::Context<'_>,
|
7310 - | ) -> std::task::Poll<Self::Output> {
|
7311 - | let this = self.project();
|
7312 - | this.inner.as_mut().poll(cx)
|
7313 7437 | }
|
7314 - | }
|
7315 - |
|
7316 - | impl<B>
|
7317 - | ::aws_smithy_http_server::request::FromRequest<
|
7318 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7319 - | B,
|
7320 - | > for crate::input::MalformedEnumInput
|
7321 - | where
|
7322 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
7323 - | B: 'static,
|
7324 - |
|
7325 - | B::Data: Send,
|
7326 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
7327 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
7328 - | {
|
7329 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
7330 - | type Future = MalformedEnumInputFuture;
|
7331 - |
|
7332 - | fn from_request(request: ::http::Request<B>) -> Self::Future {
|
7333 - | let fut = async move {
|
7334 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
7335 - | request.headers(),
|
7336 - | &CONTENT_TYPE_MALFORMEDENUM,
|
7337 - | ) {
|
7338 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7438 + | /// When a union member's value does not contain a valid enum value,
|
7439 + | /// the response should be a 400 ValidationException. Internal-only
|
7440 + | /// enum values are excluded from the response message.
|
7441 + | /// Test ID: RestJsonMalformedEnumUnion_case0
|
7442 + | #[::tokio::test]
|
7443 + | #[::tracing_test::traced_test]
|
7444 + | #[should_panic]
|
7445 + | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
7446 + | {
|
7447 + | #[allow(unused_mut)]
|
7448 + | let mut http_request = http::Request::builder()
|
7449 + | .uri("/MalformedEnum")
|
7450 + | .method("POST")
|
7451 + | .header("content-type", "application/json")
|
7452 + | .body(::aws_smithy_http_server::body::Body::from(
|
7453 + | ::bytes::Bytes::from_static(
|
7454 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
7455 + | ),
|
7456 + | ))
|
7457 + | .unwrap();
|
7458 + | #[allow(unused_mut)]
|
7459 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7460 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7461 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7462 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7463 + | let sender = sender.clone();
|
7464 + | async move {
|
7465 + | 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> };
|
7466 + | sender.send(()).await.expect("receiver dropped early");
|
7467 + | result
|
7339 7468 | }
|
7340 - | crate::protocol_serde::shape_malformed_enum::de_malformed_enum_http_request(request)
|
7469 + | })
|
7470 + | .build_unchecked();
|
7471 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7341 7472 | .await
|
7342 - | .map_err(Into::into)
|
7343 - | };
|
7344 - | use ::futures_util::future::TryFutureExt;
|
7345 - | let fut = fut.map_err(
|
7346 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
7347 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
7348 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
7349 - | e,
|
7350 - | )
|
7351 - | },
|
7473 + | .expect("unable to make an HTTP request");
|
7474 + | ::pretty_assertions::assert_eq!(
|
7475 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7476 + | http_response.status()
|
7477 + | );
|
7478 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7479 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7480 + | http_response.headers(),
|
7481 + | expected_headers,
|
7482 + | ));
|
7483 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7484 + | .await
|
7485 + | .expect("unable to extract body to bytes");
|
7486 + | ::aws_smithy_protocol_test::assert_ok(
|
7487 + | ::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"))
|
7352 7488 | );
|
7353 - | MalformedEnumInputFuture {
|
7354 - | inner: Box::pin(fut),
|
7355 - | }
|
7356 - | }
|
7357 - | }
|
7358 - | impl
|
7359 - | ::aws_smithy_http_server::response::IntoResponse<
|
7360 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7361 - | > for crate::output::MalformedEnumOutput
|
7362 - | {
|
7363 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7364 - | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_response(self) {
|
7365 - | Ok(response) => response,
|
7366 - | Err(e) => {
|
7367 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7368 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7369 7489 | }
|
7370 7490 | }
|
7491 + | /// When a union member's value does not contain a valid enum value,
|
7492 + | /// the response should be a 400 ValidationException. Internal-only
|
7493 + | /// enum values are excluded from the response message.
|
7494 + | /// Test ID: RestJsonMalformedEnumUnion_case1
|
7495 + | #[::tokio::test]
|
7496 + | #[::tracing_test::traced_test]
|
7497 + | #[should_panic]
|
7498 + | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
7499 + | {
|
7500 + | #[allow(unused_mut)]
|
7501 + | let mut http_request = http::Request::builder()
|
7502 + | .uri("/MalformedEnum")
|
7503 + | .method("POST")
|
7504 + | .header("content-type", "application/json")
|
7505 + | .body(::aws_smithy_http_server::body::Body::from(
|
7506 + | ::bytes::Bytes::from_static(
|
7507 + | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|
7508 + | ),
|
7509 + | ))
|
7510 + | .unwrap();
|
7511 + | #[allow(unused_mut)]
|
7512 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7513 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7514 + | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
7515 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7516 + | let sender = sender.clone();
|
7517 + | async move {
|
7518 + | 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> };
|
7519 + | sender.send(()).await.expect("receiver dropped early");
|
7520 + | result
|
7371 7521 | }
|
7372 - | }
|
7373 - | impl
|
7374 - | ::aws_smithy_http_server::response::IntoResponse<
|
7375 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7376 - | > for crate::error::MalformedEnumError
|
7377 - | {
|
7378 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7379 - | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_error(&self) {
|
7380 - | Ok(mut response) => {
|
7381 - | response.extensions_mut().insert(
|
7382 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
7522 + | })
|
7523 + | .build_unchecked();
|
7524 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7525 + | .await
|
7526 + | .expect("unable to make an HTTP request");
|
7527 + | ::pretty_assertions::assert_eq!(
|
7528 + | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7529 + | http_response.status()
|
7530 + | );
|
7531 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7532 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7533 + | http_response.headers(),
|
7534 + | expected_headers,
|
7535 + | ));
|
7536 + | let body = ::hyper::body::to_bytes(http_response.into_body())
|
7537 + | .await
|
7538 + | .expect("unable to extract body to bytes");
|
7539 + | ::aws_smithy_protocol_test::assert_ok(
|
7540 + | ::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"))
|
7383 7541 | );
|
7384 - | response
|
7385 - | }
|
7386 - | Err(e) => {
|
7387 - | ::tracing::error!(error = %e, "failed to serialize response");
|
7388 - | ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
|
7389 - | }
|
7390 7542 | }
|
7391 7543 | }
|
7392 7544 | }
|