1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | ::pin_project_lite::pin_project! {
|
3 3 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4 - | /// [`SensitiveValidationInput`](crate::input::SensitiveValidationInput) using modelled bindings.
|
5 - | pub struct SensitiveValidationInputFuture {
|
6 - | inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::SensitiveValidationInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
|
4 + | /// [`MalformedEnumInput`](crate::input::MalformedEnumInput) using modelled bindings.
|
5 + | pub struct MalformedEnumInputFuture {
|
6 + | 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>>
|
7 7 | }
|
8 8 | }
|
9 9 |
|
10 - | impl std::future::Future for SensitiveValidationInputFuture {
|
10 + | impl std::future::Future for MalformedEnumInputFuture {
|
11 11 | type Output = Result<
|
12 - | crate::input::SensitiveValidationInput,
|
12 + | crate::input::MalformedEnumInput,
|
13 13 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
14 14 | >;
|
15 15 |
|
16 16 | fn poll(
|
17 17 | self: std::pin::Pin<&mut Self>,
|
18 18 | cx: &mut std::task::Context<'_>,
|
19 19 | ) -> std::task::Poll<Self::Output> {
|
20 20 | let this = self.project();
|
21 21 | this.inner.as_mut().poll(cx)
|
22 22 | }
|
23 23 | }
|
24 24 |
|
25 25 | impl<B>
|
26 26 | ::aws_smithy_http_server::request::FromRequest<
|
27 27 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
28 28 | B,
|
29 - | > for crate::input::SensitiveValidationInput
|
29 + | > for crate::input::MalformedEnumInput
|
30 30 | where
|
31 31 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
32 32 | B: 'static,
|
33 33 |
|
34 34 | B::Data: Send,
|
35 35 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
36 36 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
37 37 | {
|
38 38 | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
39 - | type Future = SensitiveValidationInputFuture;
|
39 + | type Future = MalformedEnumInputFuture;
|
40 40 |
|
41 41 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
42 42 | let fut = async move {
|
43 43 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
44 44 | request.headers(),
|
45 45 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
46 46 | ) {
|
47 47 | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
48 48 | }
|
49 - | crate::protocol_serde::shape_sensitive_validation::de_sensitive_validation_http_request(
|
50 - | request,
|
51 - | )
|
49 + | crate::protocol_serde::shape_malformed_enum::de_malformed_enum_http_request(request)
|
52 50 | .await
|
53 51 | };
|
54 52 | use ::futures_util::future::TryFutureExt;
|
55 53 | let fut = fut.map_err(
|
56 54 | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
57 55 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
58 56 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
59 57 | e,
|
60 58 | )
|
61 59 | },
|
62 60 | );
|
63 - | SensitiveValidationInputFuture {
|
61 + | MalformedEnumInputFuture {
|
64 62 | inner: Box::pin(fut),
|
65 63 | }
|
66 64 | }
|
67 65 | }
|
68 66 | impl
|
69 67 | ::aws_smithy_http_server::response::IntoResponse<
|
70 68 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
71 - | > for crate::output::SensitiveValidationOutput
|
69 + | > for crate::output::MalformedEnumOutput
|
72 70 | {
|
73 71 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
74 - | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_response(self) {
|
72 + | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_response(self) {
|
75 73 | Ok(response) => response,
|
76 74 | Err(e) => {
|
77 75 | ::tracing::error!(error = %e, "failed to serialize response");
|
78 76 | ::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))
|
79 77 | }
|
80 78 | }
|
81 79 | }
|
82 80 | }
|
83 81 | impl
|
84 82 | ::aws_smithy_http_server::response::IntoResponse<
|
85 83 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
86 - | > for crate::error::SensitiveValidationError
|
84 + | > for crate::error::MalformedEnumError
|
87 85 | {
|
88 86 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
89 - | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_error(
|
90 - | &self,
|
91 - | ) {
|
87 + | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_error(&self) {
|
92 88 | Ok(mut response) => {
|
93 89 | response.extensions_mut().insert(
|
94 90 | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
95 91 | );
|
96 92 | response
|
97 93 | }
|
98 94 | Err(e) => {
|
99 95 | ::tracing::error!(error = %e, "failed to serialize response");
|
100 96 | ::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))
|
101 97 | }
|
102 98 | }
|
103 99 | }
|
104 100 | }
|
105 101 |
|
106 102 | #[allow(unreachable_code, unused_variables)]
|
107 103 | #[cfg(test)]
|
108 - | mod sensitive_validation_test {
|
104 + | mod malformed_enum_test {
|
109 105 |
|
110 - | /// When a sensitive member fails validation, the resultant
|
111 - | /// ValidationException will omit the value of the input.
|
112 - | /// Test ID: RestJsonMalformedPatternSensitiveString
|
106 + | /// When a string member does not contain a valid enum value,
|
107 + | /// the response should be a 400 ValidationException. Internal-only
|
108 + | /// enum values are excluded from the response message.
|
109 + | /// Test ID: RestJsonMalformedEnumString_case0
|
113 110 | #[::tokio::test]
|
114 111 | #[::tracing_test::traced_test]
|
115 - | async fn rest_json_malformed_pattern_sensitive_string_malformed_request() {
|
112 + | #[should_panic]
|
113 + | async fn rest_json_malformed_enum_string_case0_malformed_request() {
|
116 114 | {
|
117 115 | #[allow(unused_mut)]
|
118 116 | let mut http_request = ::http_1x::Request::builder()
|
119 - | .uri("/SensitiveValidation")
|
117 + | .uri("/MalformedEnum")
|
120 118 | .method("POST")
|
121 119 | .header("content-type", "application/json")
|
122 120 | .body(::aws_smithy_http_server::body::boxed(
|
123 121 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
124 122 | &::aws_smithy_protocol_test::decode_body_data(
|
125 123 | "{ \"string\" : \"ABC\" }".as_bytes(),
|
126 124 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
127 125 | ),
|
128 126 | )),
|
129 127 | ))
|
130 128 | .unwrap();
|
131 129 | #[allow(unused_mut)]
|
132 130 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
133 131 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
134 132 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
135 - | .sensitive_validation(move |input: crate::input::SensitiveValidationInput| {
|
133 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
136 134 | let sender = sender.clone();
|
137 135 | async move {
|
138 - | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::SensitiveValidationOutput, crate::error::SensitiveValidationError> };
|
136 + | 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> };
|
139 137 | sender.send(()).await.expect("receiver dropped early");
|
140 138 | result
|
141 139 | }
|
142 140 | })
|
143 141 | .build_unchecked();
|
144 142 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
145 143 | .await
|
146 144 | .expect("unable to make an HTTP request");
|
147 145 | ::pretty_assertions::assert_eq!(
|
148 146 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
149 147 | http_response.status()
|
150 148 | );
|
151 149 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
152 150 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
153 151 | http_response.headers(),
|
154 152 | expected_headers,
|
155 153 | ));
|
156 154 | use ::http_body_util::BodyExt;
|
157 155 | let body = http_response
|
158 156 | .into_body()
|
159 157 | .collect()
|
160 158 | .await
|
161 159 | .expect("unable to collect body")
|
162 160 | .to_bytes();
|
163 161 | ::aws_smithy_protocol_test::assert_ok(
|
164 - | ::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"))
|
165 - | );
|
166 - | }
|
167 - | }
|
168 - | }
|
169 - |
|
170 - | ::pin_project_lite::pin_project! {
|
171 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
172 - | /// [`RecursiveStructuresInput`](crate::input::RecursiveStructuresInput) using modelled bindings.
|
173 - | pub struct RecursiveStructuresInputFuture {
|
174 - | 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>>
|
175 - | }
|
176 - | }
|
177 - |
|
178 - | impl std::future::Future for RecursiveStructuresInputFuture {
|
179 - | type Output = Result<
|
180 - | crate::input::RecursiveStructuresInput,
|
181 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
182 - | >;
|
183 - |
|
184 - | fn poll(
|
185 - | self: std::pin::Pin<&mut Self>,
|
186 - | cx: &mut std::task::Context<'_>,
|
187 - | ) -> std::task::Poll<Self::Output> {
|
188 - | let this = self.project();
|
189 - | this.inner.as_mut().poll(cx)
|
190 - | }
|
191 - | }
|
192 - |
|
193 - | impl<B>
|
194 - | ::aws_smithy_http_server::request::FromRequest<
|
195 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
196 - | B,
|
197 - | > for crate::input::RecursiveStructuresInput
|
198 - | where
|
199 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
200 - | B: 'static,
|
201 - |
|
202 - | B::Data: Send,
|
203 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
204 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
205 - | {
|
206 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
207 - | type Future = RecursiveStructuresInputFuture;
|
208 - |
|
209 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
210 - | let fut = async move {
|
211 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
212 - | request.headers(),
|
213 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
214 - | ) {
|
215 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
216 - | }
|
217 - | crate::protocol_serde::shape_recursive_structures::de_recursive_structures_http_request(
|
218 - | request,
|
219 - | )
|
220 - | .await
|
221 - | };
|
222 - | use ::futures_util::future::TryFutureExt;
|
223 - | let fut = fut.map_err(
|
224 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
225 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
226 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
227 - | e,
|
228 - | )
|
229 - | },
|
230 - | );
|
231 - | RecursiveStructuresInputFuture {
|
232 - | inner: Box::pin(fut),
|
233 - | }
|
234 - | }
|
235 - | }
|
236 - | impl
|
237 - | ::aws_smithy_http_server::response::IntoResponse<
|
238 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
239 - | > for crate::output::RecursiveStructuresOutput
|
240 - | {
|
241 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
242 - | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_response(self) {
|
243 - | Ok(response) => response,
|
244 - | Err(e) => {
|
245 - | ::tracing::error!(error = %e, "failed to serialize response");
|
246 - | ::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))
|
247 - | }
|
248 - | }
|
249 - | }
|
250 - | }
|
251 - | impl
|
252 - | ::aws_smithy_http_server::response::IntoResponse<
|
253 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
254 - | > for crate::error::RecursiveStructuresError
|
255 - | {
|
256 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
257 - | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_error(
|
258 - | &self,
|
259 - | ) {
|
260 - | Ok(mut response) => {
|
261 - | response.extensions_mut().insert(
|
262 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
162 + | ::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"))
|
263 163 | );
|
264 - | response
|
265 - | }
|
266 - | Err(e) => {
|
267 - | ::tracing::error!(error = %e, "failed to serialize response");
|
268 - | ::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))
|
269 - | }
|
270 164 | }
|
271 165 | }
|
272 - | }
|
273 - |
|
274 - | #[allow(unreachable_code, unused_variables)]
|
275 - | #[cfg(test)]
|
276 - | mod recursive_structures_test {
|
277 166 |
|
278 - | /// Validation should work with recursive structures.
|
279 - | /// Test ID: RestJsonRecursiveStructuresValidate
|
167 + | /// When a string member does not contain a valid enum value,
|
168 + | /// the response should be a 400 ValidationException. Internal-only
|
169 + | /// enum values are excluded from the response message.
|
170 + | /// Test ID: RestJsonMalformedEnumString_case1
|
280 171 | #[::tokio::test]
|
281 172 | #[::tracing_test::traced_test]
|
282 - | async fn rest_json_recursive_structures_validate_request() {
|
173 + | #[should_panic]
|
174 + | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
175 + | {
|
283 176 | #[allow(unused_mut)]
|
284 177 | let mut http_request = ::http_1x::Request::builder()
|
285 - | .uri("/RecursiveStructures")
|
178 + | .uri("/MalformedEnum")
|
286 179 | .method("POST")
|
287 180 | .header("content-type", "application/json")
|
288 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
289 - | ::bytes::Bytes::copy_from_slice(
|
290 - | &::aws_smithy_protocol_test::decode_body_data("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"abc\" }\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
291 - | )
|
292 - | ))).unwrap();
|
293 - | #[allow(unused_mut)]
|
294 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
295 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
296 - | let service = crate::service::RestJsonValidation::builder::<
|
297 - | ::aws_smithy_http_server::body::BoxBody,
|
298 - | _,
|
299 - | _,
|
300 - | _,
|
301 - | >(config)
|
302 - | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
303 - | let sender = sender.clone();
|
304 - | async move {
|
305 - | let result = {
|
306 - | let expected = crate::input::RecursiveStructuresInput {
|
307 - | union: ::std::option::Option::Some(crate::model::RecursiveUnionOne::Union(
|
308 - | ::std::boxed::Box::new(crate::model::RecursiveUnionTwo::Union(
|
309 - | crate::model::RecursiveUnionOne::String(
|
310 - | "abc"
|
311 - | .parse::<crate::model::RecursiveEnumString>()
|
312 - | .expect("static value validated to member"),
|
181 + | .body(::aws_smithy_http_server::body::boxed(
|
182 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
183 + | &::aws_smithy_protocol_test::decode_body_data(
|
184 + | "{ \"string\" : \"XYZ\" }".as_bytes(),
|
185 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
313 186 | ),
|
314 187 | )),
|
315 - | )),
|
316 - | };
|
317 - | ::pretty_assertions::assert_eq!(input, expected);
|
318 - | let output = crate::output::RecursiveStructuresOutput {};
|
319 - | Ok(output)
|
320 - | };
|
321 - | sender.send(()).await.expect("receiver dropped early");
|
322 - | result
|
323 - | }
|
324 - | })
|
325 - | .build_unchecked();
|
326 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
327 - | .await
|
328 - | .expect("unable to make an HTTP request");
|
329 - | assert!(
|
330 - | receiver.recv().await.is_some(),
|
331 - | "we expected operation handler to be invoked but it was not entered"
|
332 - | );
|
333 - | }
|
334 - |
|
335 - | /// When a value deeply nested in a recursive structure does not meet constraints,
|
336 - | /// a 400 ValidationException is returned.
|
337 - | /// Test ID: RestJsonMalformedRecursiveStructures
|
338 - | #[::tokio::test]
|
339 - | #[::tracing_test::traced_test]
|
340 - | async fn rest_json_malformed_recursive_structures_malformed_request() {
|
341 - | {
|
342 - | #[allow(unused_mut)]
|
343 - | let mut http_request = ::http_1x::Request::builder()
|
344 - | .uri("/RecursiveStructures")
|
345 - | .method("POST")
|
346 - | .header("content-type", "application/json")
|
347 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
348 - | ::bytes::Bytes::copy_from_slice(
|
349 - | &::aws_smithy_protocol_test::decode_body_data("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"XYZ\" }\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
350 - | )
|
351 - | ))).unwrap();
|
188 + | ))
|
189 + | .unwrap();
|
352 190 | #[allow(unused_mut)]
|
353 191 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
354 192 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
355 193 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
356 - | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
194 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
357 195 | let sender = sender.clone();
|
358 196 | async move {
|
359 - | 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> };
|
197 + | 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> };
|
360 198 | sender.send(()).await.expect("receiver dropped early");
|
361 199 | result
|
362 200 | }
|
363 201 | })
|
364 202 | .build_unchecked();
|
365 203 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
366 204 | .await
|
367 205 | .expect("unable to make an HTTP request");
|
368 206 | ::pretty_assertions::assert_eq!(
|
369 207 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
370 208 | http_response.status()
|
371 209 | );
|
372 210 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
373 211 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
374 212 | http_response.headers(),
|
375 213 | expected_headers,
|
376 214 | ));
|
377 215 | use ::http_body_util::BodyExt;
|
378 216 | let body = http_response
|
379 217 | .into_body()
|
380 218 | .collect()
|
381 219 | .await
|
382 220 | .expect("unable to collect body")
|
383 221 | .to_bytes();
|
384 222 | ::aws_smithy_protocol_test::assert_ok(
|
385 - | ::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"))
|
223 + | ::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"))
|
386 224 | );
|
387 225 | }
|
388 226 | }
|
389 - | }
|
390 - |
|
391 - | ::pin_project_lite::pin_project! {
|
392 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
393 - | /// [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) using modelled bindings.
|
394 - | pub struct MalformedUniqueItemsInputFuture {
|
395 - | 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>>
|
396 - | }
|
397 - | }
|
398 227 |
|
399 - | impl std::future::Future for MalformedUniqueItemsInputFuture {
|
400 - | type Output = Result<
|
401 - | crate::input::MalformedUniqueItemsInput,
|
402 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
403 - | >;
|
404 - |
|
405 - | fn poll(
|
406 - | self: std::pin::Pin<&mut Self>,
|
407 - | cx: &mut std::task::Context<'_>,
|
408 - | ) -> std::task::Poll<Self::Output> {
|
409 - | let this = self.project();
|
410 - | this.inner.as_mut().poll(cx)
|
411 - | }
|
412 - | }
|
413 - |
|
414 - | impl<B>
|
415 - | ::aws_smithy_http_server::request::FromRequest<
|
416 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
417 - | B,
|
418 - | > for crate::input::MalformedUniqueItemsInput
|
419 - | where
|
420 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
421 - | B: 'static,
|
422 - |
|
423 - | B::Data: Send,
|
424 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
425 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
426 - | {
|
427 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
428 - | type Future = MalformedUniqueItemsInputFuture;
|
429 - |
|
430 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
431 - | let fut = async move {
|
432 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
433 - | request.headers(),
|
434 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
435 - | ) {
|
436 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
437 - | }
|
438 - | crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items_http_request(request)
|
439 - | .await
|
440 - | };
|
441 - | use ::futures_util::future::TryFutureExt;
|
442 - | let fut = fut.map_err(
|
443 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
444 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
445 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
446 - | e,
|
447 - | )
|
448 - | },
|
449 - | );
|
450 - | MalformedUniqueItemsInputFuture {
|
451 - | inner: Box::pin(fut),
|
452 - | }
|
453 - | }
|
454 - | }
|
455 - | impl
|
456 - | ::aws_smithy_http_server::response::IntoResponse<
|
457 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
458 - | > for crate::output::MalformedUniqueItemsOutput
|
459 - | {
|
460 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
461 - | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_response(self) {
|
462 - | Ok(response) => response,
|
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 - | impl
|
471 - | ::aws_smithy_http_server::response::IntoResponse<
|
472 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
473 - | > for crate::error::MalformedUniqueItemsError
|
474 - | {
|
475 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
476 - | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_error(&self) {
|
477 - | Ok(mut response) => {
|
478 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
479 - | response
|
480 - | },
|
481 - | Err(e) => {
|
482 - | ::tracing::error!(error = %e, "failed to serialize response");
|
483 - | ::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))
|
484 - | }
|
485 - | }
|
486 - | }
|
487 - | }
|
488 - |
|
489 - | #[allow(unreachable_code, unused_variables)]
|
490 - | #[cfg(test)]
|
491 - | mod malformed_unique_items_test {
|
492 - |
|
493 - | /// When a blob list contains non-unique values,
|
494 - | /// the response should be a 400 ValidationException.
|
495 - | /// Test ID: RestJsonMalformedUniqueItemsBlobList
|
228 + | /// When a string member does not contain a valid enum value,
|
229 + | /// the response should be a 400 ValidationException. Internal-only
|
230 + | /// enum values are excluded from the response message.
|
231 + | /// Test ID: RestJsonMalformedEnumTraitString_case0
|
496 232 | #[::tokio::test]
|
497 233 | #[::tracing_test::traced_test]
|
498 234 | #[should_panic]
|
499 - | async fn rest_json_malformed_unique_items_blob_list_malformed_request() {
|
235 + | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
500 236 | {
|
501 237 | #[allow(unused_mut)]
|
502 238 | let mut http_request = ::http_1x::Request::builder()
|
503 - | .uri("/MalformedUniqueItems")
|
239 + | .uri("/MalformedEnum")
|
504 240 | .method("POST")
|
505 241 | .header("content-type", "application/json")
|
506 242 | .body(::aws_smithy_http_server::body::boxed(
|
507 243 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
508 244 | &::aws_smithy_protocol_test::decode_body_data(
|
509 - | "{ \"blobList\" : [\"YQ==\", \"YQ==\"] }".as_bytes(),
|
245 + | "{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes(),
|
510 246 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
511 247 | ),
|
512 248 | )),
|
513 249 | ))
|
514 250 | .unwrap();
|
515 251 | #[allow(unused_mut)]
|
516 252 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
517 253 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
518 254 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
519 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
255 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
520 256 | let sender = sender.clone();
|
521 257 | async move {
|
522 - | 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> };
|
258 + | 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> };
|
523 259 | sender.send(()).await.expect("receiver dropped early");
|
524 260 | result
|
525 261 | }
|
526 262 | })
|
527 263 | .build_unchecked();
|
528 264 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
529 265 | .await
|
530 266 | .expect("unable to make an HTTP request");
|
531 267 | ::pretty_assertions::assert_eq!(
|
532 268 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
533 269 | http_response.status()
|
534 270 | );
|
535 271 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
536 272 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
537 273 | http_response.headers(),
|
538 274 | expected_headers,
|
539 275 | ));
|
540 276 | use ::http_body_util::BodyExt;
|
541 277 | let body = http_response
|
542 278 | .into_body()
|
543 279 | .collect()
|
544 280 | .await
|
545 281 | .expect("unable to collect body")
|
546 282 | .to_bytes();
|
547 283 | ::aws_smithy_protocol_test::assert_ok(
|
548 - | ::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"))
|
284 + | ::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"))
|
549 285 | );
|
550 286 | }
|
551 287 | }
|
552 288 |
|
553 - | /// When a boolean list contains non-unique values,
|
554 - | /// the response should be a 400 ValidationException.
|
555 - | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case0
|
289 + | /// When a string member does not contain a valid enum value,
|
290 + | /// the response should be a 400 ValidationException. Internal-only
|
291 + | /// enum values are excluded from the response message.
|
292 + | /// Test ID: RestJsonMalformedEnumTraitString_case1
|
556 293 | #[::tokio::test]
|
557 294 | #[::tracing_test::traced_test]
|
558 295 | #[should_panic]
|
559 - | async fn rest_json_malformed_unique_items_boolean_list_case0_malformed_request() {
|
296 + | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
560 297 | {
|
561 298 | #[allow(unused_mut)]
|
562 299 | let mut http_request = ::http_1x::Request::builder()
|
563 - | .uri("/MalformedUniqueItems")
|
300 + | .uri("/MalformedEnum")
|
564 301 | .method("POST")
|
565 302 | .header("content-type", "application/json")
|
566 303 | .body(::aws_smithy_http_server::body::boxed(
|
567 304 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
568 305 | &::aws_smithy_protocol_test::decode_body_data(
|
569 - | "{ \"booleanList\" : [true, true] }".as_bytes(),
|
306 + | "{ \"stringWithEnumTrait\" : \"XYZ\" }".as_bytes(),
|
570 307 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
571 308 | ),
|
572 309 | )),
|
573 310 | ))
|
574 311 | .unwrap();
|
575 312 | #[allow(unused_mut)]
|
576 313 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
577 314 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
578 315 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
579 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
316 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
580 317 | let sender = sender.clone();
|
581 318 | async move {
|
582 - | 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> };
|
319 + | 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> };
|
583 320 | sender.send(()).await.expect("receiver dropped early");
|
584 321 | result
|
585 322 | }
|
586 323 | })
|
587 324 | .build_unchecked();
|
588 325 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
589 326 | .await
|
590 327 | .expect("unable to make an HTTP request");
|
591 328 | ::pretty_assertions::assert_eq!(
|
592 329 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
593 330 | http_response.status()
|
594 331 | );
|
595 332 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
596 333 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
597 334 | http_response.headers(),
|
598 335 | expected_headers,
|
599 336 | ));
|
600 337 | use ::http_body_util::BodyExt;
|
601 338 | let body = http_response
|
602 339 | .into_body()
|
603 340 | .collect()
|
604 341 | .await
|
605 342 | .expect("unable to collect body")
|
606 343 | .to_bytes();
|
607 344 | ::aws_smithy_protocol_test::assert_ok(
|
608 - | ::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"))
|
345 + | ::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"))
|
609 346 | );
|
610 347 | }
|
611 348 | }
|
612 349 |
|
613 - | /// When a boolean list contains non-unique values,
|
614 - | /// the response should be a 400 ValidationException.
|
615 - | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case1
|
350 + | /// When a list member value does not contain a valid enum value,
|
351 + | /// the response should be a 400 ValidationException. Internal-only
|
352 + | /// enum values are excluded from the response message.
|
353 + | /// Test ID: RestJsonMalformedEnumList_case0
|
616 354 | #[::tokio::test]
|
617 355 | #[::tracing_test::traced_test]
|
618 356 | #[should_panic]
|
619 - | async fn rest_json_malformed_unique_items_boolean_list_case1_malformed_request() {
|
357 + | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
620 358 | {
|
621 359 | #[allow(unused_mut)]
|
622 360 | let mut http_request = ::http_1x::Request::builder()
|
623 - | .uri("/MalformedUniqueItems")
|
361 + | .uri("/MalformedEnum")
|
624 362 | .method("POST")
|
625 363 | .header("content-type", "application/json")
|
626 364 | .body(::aws_smithy_http_server::body::boxed(
|
627 365 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
628 366 | &::aws_smithy_protocol_test::decode_body_data(
|
629 - | "{ \"booleanList\" : [false, false] }".as_bytes(),
|
367 + | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
630 368 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
631 369 | ),
|
632 370 | )),
|
633 371 | ))
|
634 372 | .unwrap();
|
635 373 | #[allow(unused_mut)]
|
636 374 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
637 375 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
638 376 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
639 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
377 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
640 378 | let sender = sender.clone();
|
641 379 | async move {
|
642 - | 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> };
|
380 + | 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> };
|
643 381 | sender.send(()).await.expect("receiver dropped early");
|
644 382 | result
|
645 383 | }
|
646 384 | })
|
647 385 | .build_unchecked();
|
648 386 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
649 387 | .await
|
650 388 | .expect("unable to make an HTTP request");
|
651 389 | ::pretty_assertions::assert_eq!(
|
652 390 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
653 391 | http_response.status()
|
654 392 | );
|
655 393 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
656 394 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
657 395 | http_response.headers(),
|
658 396 | expected_headers,
|
659 397 | ));
|
660 398 | use ::http_body_util::BodyExt;
|
661 399 | let body = http_response
|
662 400 | .into_body()
|
663 401 | .collect()
|
664 402 | .await
|
665 403 | .expect("unable to collect body")
|
666 404 | .to_bytes();
|
667 405 | ::aws_smithy_protocol_test::assert_ok(
|
668 - | ::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"))
|
406 + | ::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"))
|
669 407 | );
|
670 408 | }
|
671 409 | }
|
672 410 |
|
673 - | /// When a string list contains non-unique values,
|
674 - | /// the response should be a 400 ValidationException.
|
675 - | /// Test ID: RestJsonMalformedUniqueItemsStringList
|
411 + | /// When a list member value does not contain a valid enum value,
|
412 + | /// the response should be a 400 ValidationException. Internal-only
|
413 + | /// enum values are excluded from the response message.
|
414 + | /// Test ID: RestJsonMalformedEnumList_case1
|
676 415 | #[::tokio::test]
|
677 416 | #[::tracing_test::traced_test]
|
678 417 | #[should_panic]
|
679 - | async fn rest_json_malformed_unique_items_string_list_malformed_request() {
|
418 + | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
680 419 | {
|
681 420 | #[allow(unused_mut)]
|
682 421 | let mut http_request = ::http_1x::Request::builder()
|
683 - | .uri("/MalformedUniqueItems")
|
422 + | .uri("/MalformedEnum")
|
684 423 | .method("POST")
|
685 424 | .header("content-type", "application/json")
|
686 425 | .body(::aws_smithy_http_server::body::boxed(
|
687 426 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
688 427 | &::aws_smithy_protocol_test::decode_body_data(
|
689 - | "{ \"stringList\" : [\"abc\", \"abc\"] }".as_bytes(),
|
428 + | "{ \"list\" : [\"XYZ\"] }".as_bytes(),
|
690 429 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
691 430 | ),
|
692 431 | )),
|
693 432 | ))
|
694 433 | .unwrap();
|
695 434 | #[allow(unused_mut)]
|
696 435 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
697 436 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
698 437 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
699 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
438 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
700 439 | let sender = sender.clone();
|
701 440 | async move {
|
702 - | 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> };
|
441 + | 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> };
|
703 442 | sender.send(()).await.expect("receiver dropped early");
|
704 443 | result
|
705 444 | }
|
706 445 | })
|
707 446 | .build_unchecked();
|
708 447 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
709 448 | .await
|
710 449 | .expect("unable to make an HTTP request");
|
711 450 | ::pretty_assertions::assert_eq!(
|
712 451 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
713 452 | http_response.status()
|
714 453 | );
|
715 454 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
716 455 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
717 456 | http_response.headers(),
|
718 457 | expected_headers,
|
719 458 | ));
|
720 459 | use ::http_body_util::BodyExt;
|
721 460 | let body = http_response
|
722 461 | .into_body()
|
723 462 | .collect()
|
724 463 | .await
|
725 464 | .expect("unable to collect body")
|
726 465 | .to_bytes();
|
727 466 | ::aws_smithy_protocol_test::assert_ok(
|
728 - | ::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"))
|
467 + | ::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"))
|
729 468 | );
|
730 469 | }
|
731 470 | }
|
732 471 |
|
733 - | /// When a byte list contains non-unique values,
|
734 - | /// the response should be a 400 ValidationException.
|
735 - | /// Test ID: RestJsonMalformedUniqueItemsByteList
|
472 + | /// When a map member's key does not contain a valid enum value,
|
473 + | /// the response should be a 400 ValidationException. Internal-only
|
474 + | /// enum values are excluded from the response message.
|
475 + | /// Test ID: RestJsonMalformedEnumMapKey_case0
|
736 476 | #[::tokio::test]
|
737 477 | #[::tracing_test::traced_test]
|
738 478 | #[should_panic]
|
739 - | async fn rest_json_malformed_unique_items_byte_list_malformed_request() {
|
479 + | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
740 480 | {
|
741 481 | #[allow(unused_mut)]
|
742 482 | let mut http_request = ::http_1x::Request::builder()
|
743 - | .uri("/MalformedUniqueItems")
|
483 + | .uri("/MalformedEnum")
|
744 484 | .method("POST")
|
745 485 | .header("content-type", "application/json")
|
746 486 | .body(::aws_smithy_http_server::body::boxed(
|
747 487 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
748 488 | &::aws_smithy_protocol_test::decode_body_data(
|
749 - | "{ \"byteList\" : [1, 1] }".as_bytes(),
|
489 + | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
750 490 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
751 491 | ),
|
752 492 | )),
|
753 493 | ))
|
754 494 | .unwrap();
|
755 495 | #[allow(unused_mut)]
|
756 496 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
757 497 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
758 498 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
759 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
499 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
760 500 | let sender = sender.clone();
|
761 501 | async move {
|
762 - | 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> };
|
502 + | 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> };
|
763 503 | sender.send(()).await.expect("receiver dropped early");
|
764 504 | result
|
765 505 | }
|
766 506 | })
|
767 507 | .build_unchecked();
|
768 508 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
769 509 | .await
|
770 510 | .expect("unable to make an HTTP request");
|
771 511 | ::pretty_assertions::assert_eq!(
|
772 512 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
773 513 | http_response.status()
|
774 514 | );
|
775 515 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
776 516 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
777 517 | http_response.headers(),
|
778 518 | expected_headers,
|
779 519 | ));
|
780 520 | use ::http_body_util::BodyExt;
|
781 521 | let body = http_response
|
782 522 | .into_body()
|
783 523 | .collect()
|
784 524 | .await
|
785 525 | .expect("unable to collect body")
|
786 526 | .to_bytes();
|
787 527 | ::aws_smithy_protocol_test::assert_ok(
|
788 - | ::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"))
|
528 + | ::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"))
|
789 529 | );
|
790 530 | }
|
791 531 | }
|
792 532 |
|
793 - | /// When a short list contains non-unique values,
|
794 - | /// the response should be a 400 ValidationException.
|
795 - | /// Test ID: RestJsonMalformedUniqueItemsShortList
|
533 + | /// When a map member's key does not contain a valid enum value,
|
534 + | /// the response should be a 400 ValidationException. Internal-only
|
535 + | /// enum values are excluded from the response message.
|
536 + | /// Test ID: RestJsonMalformedEnumMapKey_case1
|
796 537 | #[::tokio::test]
|
797 538 | #[::tracing_test::traced_test]
|
798 539 | #[should_panic]
|
799 - | async fn rest_json_malformed_unique_items_short_list_malformed_request() {
|
540 + | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
800 541 | {
|
801 542 | #[allow(unused_mut)]
|
802 543 | let mut http_request = ::http_1x::Request::builder()
|
803 - | .uri("/MalformedUniqueItems")
|
544 + | .uri("/MalformedEnum")
|
804 545 | .method("POST")
|
805 546 | .header("content-type", "application/json")
|
806 547 | .body(::aws_smithy_http_server::body::boxed(
|
807 548 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
808 549 | &::aws_smithy_protocol_test::decode_body_data(
|
809 - | "{ \"shortList\" : [2, 2] }".as_bytes(),
|
550 + | "{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes(),
|
810 551 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
811 552 | ),
|
812 553 | )),
|
813 554 | ))
|
814 555 | .unwrap();
|
815 556 | #[allow(unused_mut)]
|
816 557 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
817 558 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
818 559 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
819 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
560 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
820 561 | let sender = sender.clone();
|
821 562 | async move {
|
822 - | 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> };
|
563 + | 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> };
|
823 564 | sender.send(()).await.expect("receiver dropped early");
|
824 565 | result
|
825 566 | }
|
826 567 | })
|
827 568 | .build_unchecked();
|
828 569 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
829 570 | .await
|
830 571 | .expect("unable to make an HTTP request");
|
831 572 | ::pretty_assertions::assert_eq!(
|
832 573 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
833 574 | http_response.status()
|
834 575 | );
|
835 576 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
836 577 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
837 578 | http_response.headers(),
|
838 579 | expected_headers,
|
839 580 | ));
|
840 581 | use ::http_body_util::BodyExt;
|
841 582 | let body = http_response
|
842 583 | .into_body()
|
843 584 | .collect()
|
844 585 | .await
|
845 586 | .expect("unable to collect body")
|
846 587 | .to_bytes();
|
847 588 | ::aws_smithy_protocol_test::assert_ok(
|
848 - | ::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"))
|
589 + | ::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"))
|
849 590 | );
|
850 591 | }
|
851 592 | }
|
852 593 |
|
853 - | /// When an integer list contains non-unique values,
|
854 - | /// the response should be a 400 ValidationException.
|
855 - | /// Test ID: RestJsonMalformedUniqueItemsIntegerList
|
594 + | /// When a map member's value does not contain a valid enum value,
|
595 + | /// the response should be a 400 ValidationException. Internal-only
|
596 + | /// enum values are excluded from the response message.
|
597 + | /// Test ID: RestJsonMalformedEnumMapValue_case0
|
856 598 | #[::tokio::test]
|
857 599 | #[::tracing_test::traced_test]
|
858 600 | #[should_panic]
|
859 - | async fn rest_json_malformed_unique_items_integer_list_malformed_request() {
|
601 + | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
860 602 | {
|
861 603 | #[allow(unused_mut)]
|
862 604 | let mut http_request = ::http_1x::Request::builder()
|
863 - | .uri("/MalformedUniqueItems")
|
605 + | .uri("/MalformedEnum")
|
864 606 | .method("POST")
|
865 607 | .header("content-type", "application/json")
|
866 608 | .body(::aws_smithy_http_server::body::boxed(
|
867 609 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
868 610 | &::aws_smithy_protocol_test::decode_body_data(
|
869 - | "{ \"integerList\" : [3, 3] }".as_bytes(),
|
611 + | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
870 612 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
871 613 | ),
|
872 614 | )),
|
873 615 | ))
|
874 616 | .unwrap();
|
875 617 | #[allow(unused_mut)]
|
876 618 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
877 619 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
878 620 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
879 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
621 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
880 622 | let sender = sender.clone();
|
881 623 | async move {
|
882 - | 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> };
|
624 + | 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> };
|
883 625 | sender.send(()).await.expect("receiver dropped early");
|
884 626 | result
|
885 627 | }
|
886 628 | })
|
887 629 | .build_unchecked();
|
888 630 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
889 631 | .await
|
890 632 | .expect("unable to make an HTTP request");
|
891 633 | ::pretty_assertions::assert_eq!(
|
892 634 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
893 635 | http_response.status()
|
894 636 | );
|
895 637 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
896 638 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
897 639 | http_response.headers(),
|
898 640 | expected_headers,
|
899 641 | ));
|
900 642 | use ::http_body_util::BodyExt;
|
901 643 | let body = http_response
|
902 644 | .into_body()
|
903 645 | .collect()
|
904 646 | .await
|
905 647 | .expect("unable to collect body")
|
906 648 | .to_bytes();
|
907 649 | ::aws_smithy_protocol_test::assert_ok(
|
908 - | ::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"))
|
650 + | ::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"))
|
909 651 | );
|
910 652 | }
|
911 653 | }
|
912 654 |
|
913 - | /// When an integer list contains non-unique values,
|
914 - | /// the response should be a 400 ValidationException.
|
915 - | /// Test ID: RestJsonMalformedUniqueItemsLongList
|
655 + | /// When a map member's value does not contain a valid enum value,
|
656 + | /// the response should be a 400 ValidationException. Internal-only
|
657 + | /// enum values are excluded from the response message.
|
658 + | /// Test ID: RestJsonMalformedEnumMapValue_case1
|
916 659 | #[::tokio::test]
|
917 660 | #[::tracing_test::traced_test]
|
918 661 | #[should_panic]
|
919 - | async fn rest_json_malformed_unique_items_long_list_malformed_request() {
|
662 + | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
920 663 | {
|
921 664 | #[allow(unused_mut)]
|
922 665 | let mut http_request = ::http_1x::Request::builder()
|
923 - | .uri("/MalformedUniqueItems")
|
666 + | .uri("/MalformedEnum")
|
924 667 | .method("POST")
|
925 668 | .header("content-type", "application/json")
|
926 669 | .body(::aws_smithy_http_server::body::boxed(
|
927 670 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
928 671 | &::aws_smithy_protocol_test::decode_body_data(
|
929 - | "{ \"longList\" : [4, 4] }".as_bytes(),
|
672 + | "{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes(),
|
930 673 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
931 674 | ),
|
932 675 | )),
|
933 676 | ))
|
934 677 | .unwrap();
|
935 678 | #[allow(unused_mut)]
|
936 679 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
937 680 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
938 681 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
939 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
682 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
940 683 | let sender = sender.clone();
|
941 684 | async move {
|
942 - | 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> };
|
685 + | 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> };
|
943 686 | sender.send(()).await.expect("receiver dropped early");
|
944 687 | result
|
945 688 | }
|
946 689 | })
|
947 690 | .build_unchecked();
|
948 691 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
949 692 | .await
|
950 693 | .expect("unable to make an HTTP request");
|
951 694 | ::pretty_assertions::assert_eq!(
|
952 695 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
953 696 | http_response.status()
|
954 697 | );
|
955 698 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
956 699 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
957 700 | http_response.headers(),
|
958 701 | expected_headers,
|
959 702 | ));
|
960 703 | use ::http_body_util::BodyExt;
|
961 704 | let body = http_response
|
962 705 | .into_body()
|
963 706 | .collect()
|
964 707 | .await
|
965 708 | .expect("unable to collect body")
|
966 709 | .to_bytes();
|
967 710 | ::aws_smithy_protocol_test::assert_ok(
|
968 - | ::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"))
|
711 + | ::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"))
|
969 712 | );
|
970 713 | }
|
971 714 | }
|
972 715 |
|
973 - | /// When a timestamp list contains non-unique values,
|
974 - | /// the response should be a 400 ValidationException.
|
975 - | /// Test ID: RestJsonMalformedUniqueItemsTimestampList
|
716 + | /// When a union member's value does not contain a valid enum value,
|
717 + | /// the response should be a 400 ValidationException. Internal-only
|
718 + | /// enum values are excluded from the response message.
|
719 + | /// Test ID: RestJsonMalformedEnumUnion_case0
|
976 720 | #[::tokio::test]
|
977 721 | #[::tracing_test::traced_test]
|
978 722 | #[should_panic]
|
979 - | async fn rest_json_malformed_unique_items_timestamp_list_malformed_request() {
|
723 + | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
980 724 | {
|
981 725 | #[allow(unused_mut)]
|
982 726 | let mut http_request = ::http_1x::Request::builder()
|
983 - | .uri("/MalformedUniqueItems")
|
727 + | .uri("/MalformedEnum")
|
984 728 | .method("POST")
|
985 729 | .header("content-type", "application/json")
|
986 730 | .body(::aws_smithy_http_server::body::boxed(
|
987 731 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
988 732 | &::aws_smithy_protocol_test::decode_body_data(
|
989 - | "{ \"timestampList\" : [1676660607, 1676660607] }".as_bytes(),
|
733 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
990 734 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
991 735 | ),
|
992 736 | )),
|
993 737 | ))
|
994 738 | .unwrap();
|
995 739 | #[allow(unused_mut)]
|
996 740 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
997 741 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
998 742 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
999 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
743 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
1000 744 | let sender = sender.clone();
|
1001 745 | async move {
|
1002 - | 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> };
|
746 + | 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> };
|
1003 747 | sender.send(()).await.expect("receiver dropped early");
|
1004 748 | result
|
1005 749 | }
|
1006 750 | })
|
1007 751 | .build_unchecked();
|
1008 752 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1009 753 | .await
|
1010 754 | .expect("unable to make an HTTP request");
|
1011 755 | ::pretty_assertions::assert_eq!(
|
1012 756 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1013 757 | http_response.status()
|
1014 758 | );
|
1015 759 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1016 760 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1017 761 | http_response.headers(),
|
1018 762 | expected_headers,
|
1019 763 | ));
|
1020 764 | use ::http_body_util::BodyExt;
|
1021 765 | let body = http_response
|
1022 766 | .into_body()
|
1023 767 | .collect()
|
1024 768 | .await
|
1025 769 | .expect("unable to collect body")
|
1026 770 | .to_bytes();
|
1027 771 | ::aws_smithy_protocol_test::assert_ok(
|
1028 - | ::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"))
|
772 + | ::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"))
|
1029 773 | );
|
1030 774 | }
|
1031 775 | }
|
1032 776 |
|
1033 - | /// When a date-time timestamp list contains non-unique values,
|
1034 - | /// the response should be a 400 ValidationException.
|
1035 - | /// Test ID: RestJsonMalformedUniqueItemsDateTimeList
|
777 + | /// When a union member's value does not contain a valid enum value,
|
778 + | /// the response should be a 400 ValidationException. Internal-only
|
779 + | /// enum values are excluded from the response message.
|
780 + | /// Test ID: RestJsonMalformedEnumUnion_case1
|
1036 781 | #[::tokio::test]
|
1037 782 | #[::tracing_test::traced_test]
|
1038 783 | #[should_panic]
|
1039 - | async fn rest_json_malformed_unique_items_date_time_list_malformed_request() {
|
784 + | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
1040 785 | {
|
1041 786 | #[allow(unused_mut)]
|
1042 787 | let mut http_request = ::http_1x::Request::builder()
|
1043 - | .uri("/MalformedUniqueItems")
|
788 + | .uri("/MalformedEnum")
|
1044 789 | .method("POST")
|
1045 790 | .header("content-type", "application/json")
|
1046 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1047 - | ::bytes::Bytes::copy_from_slice(
|
1048 - | &::aws_smithy_protocol_test::decode_body_data("{ \"dateTimeList\" : [\"1985-04-12T23:20:50.52Z\", \"1985-04-12T23:20:50.52Z\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1049 - | )
|
1050 - | ))).unwrap();
|
791 + | .body(::aws_smithy_http_server::body::boxed(
|
792 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
793 + | &::aws_smithy_protocol_test::decode_body_data(
|
794 + | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|
795 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
796 + | ),
|
797 + | )),
|
798 + | ))
|
799 + | .unwrap();
|
1051 800 | #[allow(unused_mut)]
|
1052 801 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1053 802 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1054 803 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1055 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
804 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
1056 805 | let sender = sender.clone();
|
1057 806 | async move {
|
1058 - | 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> };
|
807 + | 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> };
|
1059 808 | sender.send(()).await.expect("receiver dropped early");
|
1060 809 | result
|
1061 810 | }
|
1062 811 | })
|
1063 812 | .build_unchecked();
|
1064 813 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1065 814 | .await
|
1066 815 | .expect("unable to make an HTTP request");
|
1067 816 | ::pretty_assertions::assert_eq!(
|
1068 817 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1069 818 | http_response.status()
|
1070 819 | );
|
1071 820 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1072 821 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1073 822 | http_response.headers(),
|
1074 823 | expected_headers,
|
1075 824 | ));
|
1076 825 | use ::http_body_util::BodyExt;
|
1077 826 | let body = http_response
|
1078 827 | .into_body()
|
1079 828 | .collect()
|
1080 829 | .await
|
1081 830 | .expect("unable to collect body")
|
1082 831 | .to_bytes();
|
1083 832 | ::aws_smithy_protocol_test::assert_ok(
|
1084 - | ::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"))
|
833 + | ::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"))
|
1085 834 | );
|
1086 835 | }
|
1087 836 | }
|
837 + | }
|
1088 838 |
|
1089 - | /// When a http-date timestamp list contains non-unique values,
|
839 + | ::pin_project_lite::pin_project! {
|
840 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
841 + | /// [`MalformedLengthInput`](crate::input::MalformedLengthInput) using modelled bindings.
|
842 + | pub struct MalformedLengthInputFuture {
|
843 + | 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>>
|
844 + | }
|
845 + | }
|
846 + |
|
847 + | impl std::future::Future for MalformedLengthInputFuture {
|
848 + | type Output = Result<
|
849 + | crate::input::MalformedLengthInput,
|
850 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
851 + | >;
|
852 + |
|
853 + | fn poll(
|
854 + | self: std::pin::Pin<&mut Self>,
|
855 + | cx: &mut std::task::Context<'_>,
|
856 + | ) -> std::task::Poll<Self::Output> {
|
857 + | let this = self.project();
|
858 + | this.inner.as_mut().poll(cx)
|
859 + | }
|
860 + | }
|
861 + |
|
862 + | impl<B>
|
863 + | ::aws_smithy_http_server::request::FromRequest<
|
864 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
865 + | B,
|
866 + | > for crate::input::MalformedLengthInput
|
867 + | where
|
868 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
869 + | B: 'static,
|
870 + |
|
871 + | B::Data: Send,
|
872 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
873 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
874 + | {
|
875 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
876 + | type Future = MalformedLengthInputFuture;
|
877 + |
|
878 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
879 + | let fut = async move {
|
880 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
881 + | request.headers(),
|
882 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
883 + | ) {
|
884 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
885 + | }
|
886 + | crate::protocol_serde::shape_malformed_length::de_malformed_length_http_request(request)
|
887 + | .await
|
888 + | };
|
889 + | use ::futures_util::future::TryFutureExt;
|
890 + | let fut = fut.map_err(
|
891 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
892 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
893 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
894 + | e,
|
895 + | )
|
896 + | },
|
897 + | );
|
898 + | MalformedLengthInputFuture {
|
899 + | inner: Box::pin(fut),
|
900 + | }
|
901 + | }
|
902 + | }
|
903 + | impl
|
904 + | ::aws_smithy_http_server::response::IntoResponse<
|
905 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
906 + | > for crate::output::MalformedLengthOutput
|
907 + | {
|
908 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
909 + | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_response(
|
910 + | self,
|
911 + | ) {
|
912 + | Ok(response) => response,
|
913 + | Err(e) => {
|
914 + | ::tracing::error!(error = %e, "failed to serialize response");
|
915 + | ::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))
|
916 + | }
|
917 + | }
|
918 + | }
|
919 + | }
|
920 + | impl
|
921 + | ::aws_smithy_http_server::response::IntoResponse<
|
922 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
923 + | > for crate::error::MalformedLengthError
|
924 + | {
|
925 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
926 + | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_error(&self)
|
927 + | {
|
928 + | Ok(mut response) => {
|
929 + | response.extensions_mut().insert(
|
930 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
931 + | );
|
932 + | response
|
933 + | }
|
934 + | Err(e) => {
|
935 + | ::tracing::error!(error = %e, "failed to serialize response");
|
936 + | ::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))
|
937 + | }
|
938 + | }
|
939 + | }
|
940 + | }
|
941 + |
|
942 + | #[allow(unreachable_code, unused_variables)]
|
943 + | #[cfg(test)]
|
944 + | mod malformed_length_test {
|
945 + |
|
946 + | /// When a blob member does not fit within length bounds,
|
1090 947 | /// the response should be a 400 ValidationException.
|
1091 - | /// Test ID: RestJsonMalformedUniqueItemsHttpDateList_case0
|
948 + | /// Test ID: RestJsonMalformedLengthBlob_case0
|
1092 949 | #[::tokio::test]
|
1093 950 | #[::tracing_test::traced_test]
|
1094 - | #[should_panic]
|
1095 - | async fn rest_json_malformed_unique_items_http_date_list_case0_malformed_request() {
|
951 + | async fn rest_json_malformed_length_blob_case0_malformed_request() {
|
1096 952 | {
|
1097 953 | #[allow(unused_mut)]
|
1098 954 | let mut http_request = ::http_1x::Request::builder()
|
1099 - | .uri("/MalformedUniqueItems")
|
955 + | .uri("/MalformedLength")
|
1100 956 | .method("POST")
|
1101 957 | .header("content-type", "application/json")
|
1102 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1103 - | ::bytes::Bytes::copy_from_slice(
|
1104 - | &::aws_smithy_protocol_test::decode_body_data("{ \"httpDateList\" : [\"Tue, 29 Apr 2014 18:30:38 GMT\", \"Tue, 29 Apr 2014 18:30:38 GMT\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1105 - | )
|
1106 - | ))).unwrap();
|
958 + | .body(::aws_smithy_http_server::body::boxed(
|
959 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
960 + | &::aws_smithy_protocol_test::decode_body_data(
|
961 + | "{ \"blob\" : \"YQ==\" }".as_bytes(),
|
962 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
963 + | ),
|
964 + | )),
|
965 + | ))
|
966 + | .unwrap();
|
1107 967 | #[allow(unused_mut)]
|
1108 968 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1109 969 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1110 970 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1111 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
971 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1112 972 | let sender = sender.clone();
|
1113 973 | async move {
|
1114 - | 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> };
|
974 + | 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> };
|
1115 975 | sender.send(()).await.expect("receiver dropped early");
|
1116 976 | result
|
1117 977 | }
|
1118 978 | })
|
1119 979 | .build_unchecked();
|
1120 980 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1121 981 | .await
|
1122 982 | .expect("unable to make an HTTP request");
|
1123 983 | ::pretty_assertions::assert_eq!(
|
1124 984 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1125 985 | http_response.status()
|
1126 986 | );
|
1127 987 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1128 988 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1129 989 | http_response.headers(),
|
1130 990 | expected_headers,
|
1131 991 | ));
|
1132 992 | use ::http_body_util::BodyExt;
|
1133 993 | let body = http_response
|
1134 994 | .into_body()
|
1135 995 | .collect()
|
1136 996 | .await
|
1137 997 | .expect("unable to collect body")
|
1138 998 | .to_bytes();
|
1139 999 | ::aws_smithy_protocol_test::assert_ok(
|
1140 - | ::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"))
|
1000 + | ::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"))
|
1141 1001 | );
|
1142 1002 | }
|
1143 1003 | }
|
1144 1004 |
|
1145 - | /// When an enum list contains non-unique values,
|
1005 + | /// When a blob member does not fit within length bounds,
|
1146 1006 | /// the response should be a 400 ValidationException.
|
1147 - | /// Test ID: RestJsonMalformedUniqueItemsEnumList
|
1007 + | /// Test ID: RestJsonMalformedLengthBlob_case1
|
1148 1008 | #[::tokio::test]
|
1149 1009 | #[::tracing_test::traced_test]
|
1150 - | #[should_panic]
|
1151 - | async fn rest_json_malformed_unique_items_enum_list_malformed_request() {
|
1010 + | async fn rest_json_malformed_length_blob_case1_malformed_request() {
|
1152 1011 | {
|
1153 1012 | #[allow(unused_mut)]
|
1154 1013 | let mut http_request = ::http_1x::Request::builder()
|
1155 - | .uri("/MalformedUniqueItems")
|
1014 + | .uri("/MalformedLength")
|
1156 1015 | .method("POST")
|
1157 1016 | .header("content-type", "application/json")
|
1158 1017 | .body(::aws_smithy_http_server::body::boxed(
|
1159 1018 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1160 1019 | &::aws_smithy_protocol_test::decode_body_data(
|
1161 - | "{ \"enumList\" : [\"Foo\", \"Foo\"] }".as_bytes(),
|
1020 + | "{ \"blob\" : \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" }".as_bytes(),
|
1162 1021 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1163 1022 | ),
|
1164 1023 | )),
|
1165 1024 | ))
|
1166 1025 | .unwrap();
|
1167 1026 | #[allow(unused_mut)]
|
1168 1027 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1169 1028 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1170 1029 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1171 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1030 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1172 1031 | let sender = sender.clone();
|
1173 1032 | async move {
|
1174 - | 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> };
|
1033 + | 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> };
|
1175 1034 | sender.send(()).await.expect("receiver dropped early");
|
1176 1035 | result
|
1177 1036 | }
|
1178 1037 | })
|
1179 1038 | .build_unchecked();
|
1180 1039 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1181 1040 | .await
|
1182 1041 | .expect("unable to make an HTTP request");
|
1183 1042 | ::pretty_assertions::assert_eq!(
|
1184 1043 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1185 1044 | http_response.status()
|
1186 1045 | );
|
1187 1046 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1188 1047 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1189 1048 | http_response.headers(),
|
1190 1049 | expected_headers,
|
1191 1050 | ));
|
1192 1051 | use ::http_body_util::BodyExt;
|
1193 1052 | let body = http_response
|
1194 1053 | .into_body()
|
1195 1054 | .collect()
|
1196 1055 | .await
|
1197 1056 | .expect("unable to collect body")
|
1198 1057 | .to_bytes();
|
1199 1058 | ::aws_smithy_protocol_test::assert_ok(
|
1200 - | ::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"))
|
1059 + | ::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"))
|
1201 1060 | );
|
1202 1061 | }
|
1203 1062 | }
|
1204 1063 |
|
1205 - | /// When an intEnum list contains non-unique values,
|
1064 + | /// When a string member does not fit within length bounds,
|
1206 1065 | /// the response should be a 400 ValidationException.
|
1207 - | /// Test ID: RestJsonMalformedUniqueItemsIntEnumList
|
1066 + | /// Test ID: RestJsonMalformedLengthString_case0
|
1208 1067 | #[::tokio::test]
|
1209 1068 | #[::tracing_test::traced_test]
|
1210 - | #[should_panic]
|
1211 - | async fn rest_json_malformed_unique_items_int_enum_list_malformed_request() {
|
1069 + | async fn rest_json_malformed_length_string_case0_malformed_request() {
|
1212 1070 | {
|
1213 1071 | #[allow(unused_mut)]
|
1214 1072 | let mut http_request = ::http_1x::Request::builder()
|
1215 - | .uri("/MalformedUniqueItems")
|
1073 + | .uri("/MalformedLength")
|
1216 1074 | .method("POST")
|
1217 1075 | .header("content-type", "application/json")
|
1218 1076 | .body(::aws_smithy_http_server::body::boxed(
|
1219 1077 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1220 1078 | &::aws_smithy_protocol_test::decode_body_data(
|
1221 - | "{ \"intEnumList\" : [3, 3] }".as_bytes(),
|
1079 + | "{ \"string\" : \"a\" }".as_bytes(),
|
1222 1080 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1223 1081 | ),
|
1224 1082 | )),
|
1225 1083 | ))
|
1226 1084 | .unwrap();
|
1227 1085 | #[allow(unused_mut)]
|
1228 1086 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1229 1087 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1230 1088 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1231 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1089 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1232 1090 | let sender = sender.clone();
|
1233 1091 | async move {
|
1234 - | 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> };
|
1092 + | 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> };
|
1235 1093 | sender.send(()).await.expect("receiver dropped early");
|
1236 1094 | result
|
1237 1095 | }
|
1238 1096 | })
|
1239 1097 | .build_unchecked();
|
1240 1098 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1241 1099 | .await
|
1242 1100 | .expect("unable to make an HTTP request");
|
1243 1101 | ::pretty_assertions::assert_eq!(
|
1244 1102 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1245 1103 | http_response.status()
|
1246 1104 | );
|
1247 1105 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1248 1106 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1249 1107 | http_response.headers(),
|
1250 1108 | expected_headers,
|
1251 1109 | ));
|
1252 1110 | use ::http_body_util::BodyExt;
|
1253 1111 | let body = http_response
|
1254 1112 | .into_body()
|
1255 1113 | .collect()
|
1256 1114 | .await
|
1257 1115 | .expect("unable to collect body")
|
1258 1116 | .to_bytes();
|
1259 1117 | ::aws_smithy_protocol_test::assert_ok(
|
1260 - | ::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"))
|
1118 + | ::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"))
|
1261 1119 | );
|
1262 1120 | }
|
1263 1121 | }
|
1264 1122 |
|
1265 - | /// When an list of lists contains non-unique values,
|
1123 + | /// When a string member does not fit within length bounds,
|
1266 1124 | /// the response should be a 400 ValidationException.
|
1267 - | /// Test ID: RestJsonMalformedUniqueItemsListList
|
1125 + | /// Test ID: RestJsonMalformedLengthString_case1
|
1268 1126 | #[::tokio::test]
|
1269 1127 | #[::tracing_test::traced_test]
|
1270 - | #[should_panic]
|
1271 - | async fn rest_json_malformed_unique_items_list_list_malformed_request() {
|
1128 + | async fn rest_json_malformed_length_string_case1_malformed_request() {
|
1272 1129 | {
|
1273 1130 | #[allow(unused_mut)]
|
1274 1131 | let mut http_request = ::http_1x::Request::builder()
|
1275 - | .uri("/MalformedUniqueItems")
|
1132 + | .uri("/MalformedLength")
|
1276 1133 | .method("POST")
|
1277 1134 | .header("content-type", "application/json")
|
1278 1135 | .body(::aws_smithy_http_server::body::boxed(
|
1279 1136 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1280 1137 | &::aws_smithy_protocol_test::decode_body_data(
|
1281 - | "{ \"listList\" : [[\"foo\",\"bar\"], [\"foo\",\"bar\"]] }".as_bytes(),
|
1138 + | "{ \"string\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
1282 1139 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1283 1140 | ),
|
1284 1141 | )),
|
1285 1142 | ))
|
1286 1143 | .unwrap();
|
1287 1144 | #[allow(unused_mut)]
|
1288 1145 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1289 1146 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1290 1147 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1291 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1148 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1292 1149 | let sender = sender.clone();
|
1293 1150 | async move {
|
1294 - | 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> };
|
1151 + | 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> };
|
1295 1152 | sender.send(()).await.expect("receiver dropped early");
|
1296 1153 | result
|
1297 1154 | }
|
1298 1155 | })
|
1299 1156 | .build_unchecked();
|
1300 1157 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1301 1158 | .await
|
1302 1159 | .expect("unable to make an HTTP request");
|
1303 1160 | ::pretty_assertions::assert_eq!(
|
1304 1161 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1305 1162 | http_response.status()
|
1306 1163 | );
|
1307 1164 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1308 1165 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1309 1166 | http_response.headers(),
|
1310 1167 | expected_headers,
|
1311 1168 | ));
|
1312 1169 | use ::http_body_util::BodyExt;
|
1313 1170 | let body = http_response
|
1314 1171 | .into_body()
|
1315 1172 | .collect()
|
1316 1173 | .await
|
1317 1174 | .expect("unable to collect body")
|
1318 1175 | .to_bytes();
|
1319 1176 | ::aws_smithy_protocol_test::assert_ok(
|
1320 - | ::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"))
|
1177 + | ::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"))
|
1321 1178 | );
|
1322 1179 | }
|
1323 1180 | }
|
1324 1181 |
|
1325 - | /// When an list of structures contains non-unique values,
|
1182 + | /// When a string member does not fit within length bounds,
|
1326 1183 | /// the response should be a 400 ValidationException.
|
1327 - | /// Test ID: RestJsonMalformedUniqueItemsStructureList
|
1184 + | /// Test ID: RestJsonMalformedLengthString_case2
|
1328 1185 | #[::tokio::test]
|
1329 1186 | #[::tracing_test::traced_test]
|
1330 - | #[should_panic]
|
1331 - | async fn rest_json_malformed_unique_items_structure_list_malformed_request() {
|
1187 + | async fn rest_json_malformed_length_string_case2_malformed_request() {
|
1332 1188 | {
|
1333 1189 | #[allow(unused_mut)]
|
1334 1190 | let mut http_request = ::http_1x::Request::builder()
|
1335 - | .uri("/MalformedUniqueItems")
|
1191 + | .uri("/MalformedLength")
|
1336 1192 | .method("POST")
|
1337 1193 | .header("content-type", "application/json")
|
1338 1194 | .body(::aws_smithy_http_server::body::boxed(
|
1339 1195 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1340 1196 | &::aws_smithy_protocol_test::decode_body_data(
|
1341 - | "{ \"structureList\" : [{\"hi\": \"hello\"}, {\"hi\": \"hello\"}] }"
|
1342 - | .as_bytes(),
|
1197 + | "{ \"string\" : \"👍\" }".as_bytes(),
|
1343 1198 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1344 1199 | ),
|
1345 1200 | )),
|
1346 1201 | ))
|
1347 1202 | .unwrap();
|
1348 1203 | #[allow(unused_mut)]
|
1349 1204 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1350 1205 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1351 1206 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1352 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1207 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1353 1208 | let sender = sender.clone();
|
1354 1209 | async move {
|
1355 - | 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> };
|
1210 + | 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> };
|
1356 1211 | sender.send(()).await.expect("receiver dropped early");
|
1357 1212 | result
|
1358 1213 | }
|
1359 1214 | })
|
1360 1215 | .build_unchecked();
|
1361 1216 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1362 1217 | .await
|
1363 1218 | .expect("unable to make an HTTP request");
|
1364 1219 | ::pretty_assertions::assert_eq!(
|
1365 1220 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1366 1221 | http_response.status()
|
1367 1222 | );
|
1368 1223 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1369 1224 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1370 1225 | http_response.headers(),
|
1371 1226 | expected_headers,
|
1372 1227 | ));
|
1373 1228 | use ::http_body_util::BodyExt;
|
1374 1229 | let body = http_response
|
1375 1230 | .into_body()
|
1376 1231 | .collect()
|
1377 1232 | .await
|
1378 1233 | .expect("unable to collect body")
|
1379 1234 | .to_bytes();
|
1380 1235 | ::aws_smithy_protocol_test::assert_ok(
|
1381 - | ::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"))
|
1236 + | ::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"))
|
1382 1237 | );
|
1383 1238 | }
|
1384 1239 | }
|
1385 1240 |
|
1386 - | /// When a list of structures does not contain required keys,
|
1387 - | /// the response should be a 400 ValidationException and not
|
1388 - | /// a 500 error.
|
1389 - | /// Test ID: RestJsonMalformedUniqueItemsStructureMissingKeyList
|
1241 + | /// When a string member does not fit within length bounds,
|
1242 + | /// the response should be a 400 ValidationException.
|
1243 + | /// Test ID: RestJsonMalformedLengthMinString
|
1390 1244 | #[::tokio::test]
|
1391 1245 | #[::tracing_test::traced_test]
|
1392 - | async fn rest_json_malformed_unique_items_structure_missing_key_list_malformed_request() {
|
1246 + | async fn rest_json_malformed_length_min_string_malformed_request() {
|
1393 1247 | {
|
1394 1248 | #[allow(unused_mut)]
|
1395 1249 | let mut http_request = ::http_1x::Request::builder()
|
1396 - | .uri("/MalformedUniqueItems")
|
1250 + | .uri("/MalformedLength")
|
1397 1251 | .method("POST")
|
1398 1252 | .header("content-type", "application/json")
|
1399 1253 | .body(::aws_smithy_http_server::body::boxed(
|
1400 1254 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1401 1255 | &::aws_smithy_protocol_test::decode_body_data(
|
1402 - | "{ \"structureListWithNoKey\" : [{\"hi2\": \"bar\"}] }".as_bytes(),
|
1256 + | "{ \"minString\" : \"a\" }".as_bytes(),
|
1403 1257 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1404 1258 | ),
|
1405 1259 | )),
|
1406 1260 | ))
|
1407 1261 | .unwrap();
|
1408 1262 | #[allow(unused_mut)]
|
1409 1263 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1410 1264 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1411 1265 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1412 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1266 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1413 1267 | let sender = sender.clone();
|
1414 1268 | async move {
|
1415 - | 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> };
|
1269 + | 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> };
|
1416 1270 | sender.send(()).await.expect("receiver dropped early");
|
1417 1271 | result
|
1418 1272 | }
|
1419 1273 | })
|
1420 1274 | .build_unchecked();
|
1421 1275 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1422 1276 | .await
|
1423 1277 | .expect("unable to make an HTTP request");
|
1424 1278 | ::pretty_assertions::assert_eq!(
|
1425 1279 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1426 1280 | http_response.status()
|
1427 1281 | );
|
1428 1282 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1429 1283 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1430 1284 | http_response.headers(),
|
1431 1285 | expected_headers,
|
1432 1286 | ));
|
1433 1287 | use ::http_body_util::BodyExt;
|
1434 1288 | let body = http_response
|
1435 1289 | .into_body()
|
1436 1290 | .collect()
|
1437 1291 | .await
|
1438 1292 | .expect("unable to collect body")
|
1439 1293 | .to_bytes();
|
1440 1294 | ::aws_smithy_protocol_test::assert_ok(
|
1441 - | ::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"))
|
1295 + | ::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"))
|
1442 1296 | );
|
1443 1297 | }
|
1444 1298 | }
|
1445 1299 |
|
1446 - | /// When an list of unions contains non-unique values,
|
1300 + | /// When a string member does not fit within length bounds,
|
1447 1301 | /// the response should be a 400 ValidationException.
|
1448 - | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case0
|
1302 + | /// Test ID: RestJsonMalformedLengthMaxString
|
1449 1303 | #[::tokio::test]
|
1450 1304 | #[::tracing_test::traced_test]
|
1451 - | #[should_panic]
|
1452 - | async fn rest_json_malformed_unique_items_union_list_case0_malformed_request() {
|
1305 + | async fn rest_json_malformed_length_max_string_malformed_request() {
|
1453 1306 | {
|
1454 1307 | #[allow(unused_mut)]
|
1455 1308 | let mut http_request = ::http_1x::Request::builder()
|
1456 - | .uri("/MalformedUniqueItems")
|
1309 + | .uri("/MalformedLength")
|
1457 1310 | .method("POST")
|
1458 1311 | .header("content-type", "application/json")
|
1459 1312 | .body(::aws_smithy_http_server::body::boxed(
|
1460 1313 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1461 1314 | &::aws_smithy_protocol_test::decode_body_data(
|
1462 - | "{ \"unionList\" : [{\"string\": \"foo\"}, {\"string\": \"foo\"}] }"
|
1463 - | .as_bytes(),
|
1315 + | "{ \"maxString\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
1464 1316 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1465 1317 | ),
|
1466 1318 | )),
|
1467 1319 | ))
|
1468 1320 | .unwrap();
|
1469 1321 | #[allow(unused_mut)]
|
1470 1322 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1471 1323 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1472 1324 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1473 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1325 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1474 1326 | let sender = sender.clone();
|
1475 1327 | async move {
|
1476 - | 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> };
|
1328 + | 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> };
|
1477 1329 | sender.send(()).await.expect("receiver dropped early");
|
1478 1330 | result
|
1479 1331 | }
|
1480 1332 | })
|
1481 1333 | .build_unchecked();
|
1482 1334 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1483 1335 | .await
|
1484 1336 | .expect("unable to make an HTTP request");
|
1485 1337 | ::pretty_assertions::assert_eq!(
|
1486 1338 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1487 1339 | http_response.status()
|
1488 1340 | );
|
1489 1341 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1490 1342 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1491 1343 | http_response.headers(),
|
1492 1344 | expected_headers,
|
1493 1345 | ));
|
1494 1346 | use ::http_body_util::BodyExt;
|
1495 1347 | let body = http_response
|
1496 1348 | .into_body()
|
1497 1349 | .collect()
|
1498 1350 | .await
|
1499 1351 | .expect("unable to collect body")
|
1500 1352 | .to_bytes();
|
1501 1353 | ::aws_smithy_protocol_test::assert_ok(
|
1502 - | ::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"))
|
1354 + | ::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"))
|
1503 1355 | );
|
1504 1356 | }
|
1505 1357 | }
|
1506 1358 |
|
1507 - | /// When an list of unions contains non-unique values,
|
1359 + | /// When a list member does not fit within length bounds,
|
1508 1360 | /// the response should be a 400 ValidationException.
|
1509 - | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case1
|
1361 + | /// Test ID: RestJsonMalformedLengthList_case0
|
1510 1362 | #[::tokio::test]
|
1511 1363 | #[::tracing_test::traced_test]
|
1512 - | #[should_panic]
|
1513 - | async fn rest_json_malformed_unique_items_union_list_case1_malformed_request() {
|
1364 + | async fn rest_json_malformed_length_list_case0_malformed_request() {
|
1514 1365 | {
|
1515 1366 | #[allow(unused_mut)]
|
1516 1367 | let mut http_request = ::http_1x::Request::builder()
|
1517 - | .uri("/MalformedUniqueItems")
|
1368 + | .uri("/MalformedLength")
|
1518 1369 | .method("POST")
|
1519 1370 | .header("content-type", "application/json")
|
1520 1371 | .body(::aws_smithy_http_server::body::boxed(
|
1521 1372 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1522 1373 | &::aws_smithy_protocol_test::decode_body_data(
|
1523 - | "{ \"unionList\" : [{\"integer\": 1}, {\"integer\": 1}] }".as_bytes(),
|
1374 + | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
1524 1375 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1525 1376 | ),
|
1526 1377 | )),
|
1527 1378 | ))
|
1528 1379 | .unwrap();
|
1529 1380 | #[allow(unused_mut)]
|
1530 1381 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1531 1382 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1532 1383 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1533 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1384 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1534 1385 | let sender = sender.clone();
|
1535 1386 | async move {
|
1536 - | 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> };
|
1387 + | 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> };
|
1537 1388 | sender.send(()).await.expect("receiver dropped early");
|
1538 1389 | result
|
1539 1390 | }
|
1540 1391 | })
|
1541 1392 | .build_unchecked();
|
1542 1393 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1543 1394 | .await
|
1544 1395 | .expect("unable to make an HTTP request");
|
1545 1396 | ::pretty_assertions::assert_eq!(
|
1546 1397 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1547 1398 | http_response.status()
|
1548 1399 | );
|
1549 1400 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1550 1401 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1551 1402 | http_response.headers(),
|
1552 1403 | expected_headers,
|
1553 1404 | ));
|
1554 1405 | use ::http_body_util::BodyExt;
|
1555 1406 | let body = http_response
|
1556 1407 | .into_body()
|
1557 1408 | .collect()
|
1558 1409 | .await
|
1559 1410 | .expect("unable to collect body")
|
1560 1411 | .to_bytes();
|
1561 1412 | ::aws_smithy_protocol_test::assert_ok(
|
1562 - | ::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"))
|
1413 + | ::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"))
|
1563 1414 | );
|
1564 1415 | }
|
1565 1416 | }
|
1566 - | }
|
1567 - |
|
1568 - | ::pin_project_lite::pin_project! {
|
1569 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1570 - | /// [`MalformedRequiredInput`](crate::input::MalformedRequiredInput) using modelled bindings.
|
1571 - | pub struct MalformedRequiredInputFuture {
|
1572 - | 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>>
|
1573 - | }
|
1574 - | }
|
1575 - |
|
1576 - | impl std::future::Future for MalformedRequiredInputFuture {
|
1577 - | type Output = Result<
|
1578 - | crate::input::MalformedRequiredInput,
|
1579 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1580 - | >;
|
1581 - |
|
1582 - | fn poll(
|
1583 - | self: std::pin::Pin<&mut Self>,
|
1584 - | cx: &mut std::task::Context<'_>,
|
1585 - | ) -> std::task::Poll<Self::Output> {
|
1586 - | let this = self.project();
|
1587 - | this.inner.as_mut().poll(cx)
|
1588 - | }
|
1589 - | }
|
1590 - |
|
1591 - | impl<B>
|
1592 - | ::aws_smithy_http_server::request::FromRequest<
|
1593 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1594 - | B,
|
1595 - | > for crate::input::MalformedRequiredInput
|
1596 - | where
|
1597 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1598 - | B: 'static,
|
1599 - |
|
1600 - | B::Data: Send,
|
1601 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1602 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1603 - | {
|
1604 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1605 - | type Future = MalformedRequiredInputFuture;
|
1606 1417 |
|
1607 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1608 - | let fut = async move {
|
1609 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1610 - | request.headers(),
|
1611 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1612 - | ) {
|
1613 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1614 - | }
|
1615 - | crate::protocol_serde::shape_malformed_required::de_malformed_required_http_request(
|
1616 - | request,
|
1418 + | /// When a list member does not fit within length bounds,
|
1419 + | /// the response should be a 400 ValidationException.
|
1420 + | /// Test ID: RestJsonMalformedLengthList_case1
|
1421 + | #[::tokio::test]
|
1422 + | #[::tracing_test::traced_test]
|
1423 + | async fn rest_json_malformed_length_list_case1_malformed_request() {
|
1424 + | {
|
1425 + | #[allow(unused_mut)]
|
1426 + | let mut http_request = ::http_1x::Request::builder()
|
1427 + | .uri("/MalformedLength")
|
1428 + | .method("POST")
|
1429 + | .header("content-type", "application/json")
|
1430 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1431 + | ::bytes::Bytes::copy_from_slice(
|
1432 + | &::aws_smithy_protocol_test::decode_body_data("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1617 1433 | )
|
1434 + | ))).unwrap();
|
1435 + | #[allow(unused_mut)]
|
1436 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1437 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1438 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1439 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1440 + | let sender = sender.clone();
|
1441 + | async move {
|
1442 + | 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> };
|
1443 + | sender.send(()).await.expect("receiver dropped early");
|
1444 + | result
|
1445 + | }
|
1446 + | })
|
1447 + | .build_unchecked();
|
1448 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1618 1449 | .await
|
1619 - | };
|
1620 - | use ::futures_util::future::TryFutureExt;
|
1621 - | let fut = fut.map_err(
|
1622 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1623 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1624 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
1625 - | e,
|
1626 - | )
|
1627 - | },
|
1450 + | .expect("unable to make an HTTP request");
|
1451 + | ::pretty_assertions::assert_eq!(
|
1452 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1453 + | http_response.status()
|
1628 1454 | );
|
1629 - | MalformedRequiredInputFuture {
|
1630 - | inner: Box::pin(fut),
|
1631 - | }
|
1632 - | }
|
1633 - | }
|
1634 - | impl
|
1635 - | ::aws_smithy_http_server::response::IntoResponse<
|
1636 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1637 - | > for crate::output::MalformedRequiredOutput
|
1638 - | {
|
1639 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1640 - | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_response(
|
1641 - | self,
|
1642 - | ) {
|
1643 - | Ok(response) => response,
|
1644 - | Err(e) => {
|
1645 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1646 - | ::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))
|
1647 - | }
|
1648 - | }
|
1649 - | }
|
1650 - | }
|
1651 - | impl
|
1652 - | ::aws_smithy_http_server::response::IntoResponse<
|
1653 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1654 - | > for crate::error::MalformedRequiredError
|
1655 - | {
|
1656 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1657 - | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_error(
|
1658 - | &self,
|
1659 - | ) {
|
1660 - | Ok(mut response) => {
|
1661 - | response.extensions_mut().insert(
|
1662 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
1455 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1456 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1457 + | http_response.headers(),
|
1458 + | expected_headers,
|
1459 + | ));
|
1460 + | use ::http_body_util::BodyExt;
|
1461 + | let body = http_response
|
1462 + | .into_body()
|
1463 + | .collect()
|
1464 + | .await
|
1465 + | .expect("unable to collect body")
|
1466 + | .to_bytes();
|
1467 + | ::aws_smithy_protocol_test::assert_ok(
|
1468 + | ::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"))
|
1663 1469 | );
|
1664 - | response
|
1665 - | }
|
1666 - | Err(e) => {
|
1667 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1668 - | ::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))
|
1669 - | }
|
1670 1470 | }
|
1671 1471 | }
|
1672 - | }
|
1673 - |
|
1674 - | #[allow(unreachable_code, unused_variables)]
|
1675 - | #[cfg(test)]
|
1676 - | mod malformed_required_test {
|
1677 1472 |
|
1678 - | /// When a required member is not set in the message body,
|
1473 + | /// When a list member's value does not fit within length bounds,
|
1679 1474 | /// the response should be a 400 ValidationException.
|
1680 - | /// Test ID: RestJsonMalformedRequiredBodyUnset
|
1475 + | /// Test ID: RestJsonMalformedLengthListValue_case0
|
1681 1476 | #[::tokio::test]
|
1682 1477 | #[::tracing_test::traced_test]
|
1683 - | async fn rest_json_malformed_required_body_unset_malformed_request() {
|
1478 + | async fn rest_json_malformed_length_list_value_case0_malformed_request() {
|
1684 1479 | {
|
1685 1480 | #[allow(unused_mut)]
|
1686 1481 | let mut http_request = ::http_1x::Request::builder()
|
1687 - | .uri("/MalformedRequired")
|
1482 + | .uri("/MalformedLength")
|
1688 1483 | .method("POST")
|
1689 1484 | .header("content-type", "application/json")
|
1690 - | .header("string-in-headers", "abc")
|
1691 1485 | .body(::aws_smithy_http_server::body::boxed(
|
1692 1486 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1693 1487 | &::aws_smithy_protocol_test::decode_body_data(
|
1694 - | "{ }".as_bytes(),
|
1488 + | "{ \"list\" : [\"a\", \"abc\"] }".as_bytes(),
|
1695 1489 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1696 1490 | ),
|
1697 1491 | )),
|
1698 1492 | ))
|
1699 1493 | .unwrap();
|
1700 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1701 1494 | #[allow(unused_mut)]
|
1702 1495 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1703 1496 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1704 1497 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1705 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1498 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1706 1499 | let sender = sender.clone();
|
1707 1500 | async move {
|
1708 - | 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> };
|
1501 + | 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> };
|
1709 1502 | sender.send(()).await.expect("receiver dropped early");
|
1710 1503 | result
|
1711 1504 | }
|
1712 1505 | })
|
1713 1506 | .build_unchecked();
|
1714 1507 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1715 1508 | .await
|
1716 1509 | .expect("unable to make an HTTP request");
|
1717 1510 | ::pretty_assertions::assert_eq!(
|
1718 1511 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1719 1512 | http_response.status()
|
1720 1513 | );
|
1721 1514 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1722 1515 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1723 1516 | http_response.headers(),
|
1724 1517 | expected_headers,
|
1725 1518 | ));
|
1726 1519 | use ::http_body_util::BodyExt;
|
1727 1520 | let body = http_response
|
1728 1521 | .into_body()
|
1729 1522 | .collect()
|
1730 1523 | .await
|
1731 1524 | .expect("unable to collect body")
|
1732 1525 | .to_bytes();
|
1733 1526 | ::aws_smithy_protocol_test::assert_ok(
|
1734 - | ::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"))
|
1527 + | ::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"))
|
1735 1528 | );
|
1736 1529 | }
|
1737 1530 | }
|
1738 1531 |
|
1739 - | /// When a required member is set to null in the message body,
|
1532 + | /// When a list member's value does not fit within length bounds,
|
1740 1533 | /// the response should be a 400 ValidationException.
|
1741 - | /// Test ID: RestJsonMalformedRequiredBodyExplicitNull
|
1534 + | /// Test ID: RestJsonMalformedLengthListValue_case1
|
1742 1535 | #[::tokio::test]
|
1743 1536 | #[::tracing_test::traced_test]
|
1744 - | async fn rest_json_malformed_required_body_explicit_null_malformed_request() {
|
1537 + | async fn rest_json_malformed_length_list_value_case1_malformed_request() {
|
1745 1538 | {
|
1746 1539 | #[allow(unused_mut)]
|
1747 1540 | let mut http_request = ::http_1x::Request::builder()
|
1748 - | .uri("/MalformedRequired")
|
1541 + | .uri("/MalformedLength")
|
1749 1542 | .method("POST")
|
1750 1543 | .header("content-type", "application/json")
|
1751 - | .header("string-in-headers", "abc")
|
1752 1544 | .body(::aws_smithy_http_server::body::boxed(
|
1753 1545 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1754 1546 | &::aws_smithy_protocol_test::decode_body_data(
|
1755 - | "{ \"string\": null }".as_bytes(),
|
1547 + | "{ \"list\" : [\"abcdefghijklmnopqrstuvwxyz\", \"abc\"] }".as_bytes(),
|
1756 1548 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1757 1549 | ),
|
1758 1550 | )),
|
1759 1551 | ))
|
1760 1552 | .unwrap();
|
1761 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1762 1553 | #[allow(unused_mut)]
|
1763 1554 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1764 1555 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1765 1556 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1766 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1557 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1767 1558 | let sender = sender.clone();
|
1768 1559 | async move {
|
1769 - | 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> };
|
1560 + | 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> };
|
1770 1561 | sender.send(()).await.expect("receiver dropped early");
|
1771 1562 | result
|
1772 1563 | }
|
1773 1564 | })
|
1774 1565 | .build_unchecked();
|
1775 1566 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1776 1567 | .await
|
1777 1568 | .expect("unable to make an HTTP request");
|
1778 1569 | ::pretty_assertions::assert_eq!(
|
1779 1570 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1780 1571 | http_response.status()
|
1781 1572 | );
|
1782 1573 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1783 1574 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1784 1575 | http_response.headers(),
|
1785 1576 | expected_headers,
|
1786 1577 | ));
|
1787 1578 | use ::http_body_util::BodyExt;
|
1788 1579 | let body = http_response
|
1789 1580 | .into_body()
|
1790 1581 | .collect()
|
1791 1582 | .await
|
1792 1583 | .expect("unable to collect body")
|
1793 1584 | .to_bytes();
|
1794 1585 | ::aws_smithy_protocol_test::assert_ok(
|
1795 - | ::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"))
|
1586 + | ::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"))
|
1796 1587 | );
|
1797 1588 | }
|
1798 1589 | }
|
1799 1590 |
|
1800 - | /// When a required member is not set in headers,
|
1591 + | /// When a map member does not fit within length bounds,
|
1801 1592 | /// the response should be a 400 ValidationException.
|
1802 - | /// Test ID: RestJsonMalformedRequiredHeaderUnset
|
1593 + | /// Test ID: RestJsonMalformedLengthMap_case0
|
1803 1594 | #[::tokio::test]
|
1804 1595 | #[::tracing_test::traced_test]
|
1805 - | async fn rest_json_malformed_required_header_unset_malformed_request() {
|
1596 + | async fn rest_json_malformed_length_map_case0_malformed_request() {
|
1806 1597 | {
|
1807 1598 | #[allow(unused_mut)]
|
1808 1599 | let mut http_request = ::http_1x::Request::builder()
|
1809 - | .uri("/MalformedRequired")
|
1600 + | .uri("/MalformedLength")
|
1810 1601 | .method("POST")
|
1811 1602 | .header("content-type", "application/json")
|
1812 1603 | .body(::aws_smithy_http_server::body::boxed(
|
1813 1604 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1814 1605 | &::aws_smithy_protocol_test::decode_body_data(
|
1815 - | "{ \"string\": \"abc\" }".as_bytes(),
|
1606 + | "{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"]} }".as_bytes(),
|
1816 1607 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1817 1608 | ),
|
1818 1609 | )),
|
1819 1610 | ))
|
1820 1611 | .unwrap();
|
1821 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1822 1612 | #[allow(unused_mut)]
|
1823 1613 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1824 1614 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1825 1615 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1826 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1616 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1827 1617 | let sender = sender.clone();
|
1828 1618 | async move {
|
1829 - | 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> };
|
1619 + | 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> };
|
1830 1620 | sender.send(()).await.expect("receiver dropped early");
|
1831 1621 | result
|
1832 1622 | }
|
1833 1623 | })
|
1834 1624 | .build_unchecked();
|
1835 1625 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1836 1626 | .await
|
1837 1627 | .expect("unable to make an HTTP request");
|
1838 1628 | ::pretty_assertions::assert_eq!(
|
1839 1629 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1840 1630 | http_response.status()
|
1841 1631 | );
|
1842 1632 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1843 1633 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1844 1634 | http_response.headers(),
|
1845 1635 | expected_headers,
|
1846 1636 | ));
|
1847 1637 | use ::http_body_util::BodyExt;
|
1848 1638 | let body = http_response
|
1849 1639 | .into_body()
|
1850 1640 | .collect()
|
1851 1641 | .await
|
1852 1642 | .expect("unable to collect body")
|
1853 1643 | .to_bytes();
|
1854 1644 | ::aws_smithy_protocol_test::assert_ok(
|
1855 - | ::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"))
|
1645 + | ::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"))
|
1856 1646 | );
|
1857 1647 | }
|
1858 1648 | }
|
1859 - | }
|
1860 1649 |
|
1861 - | ::pin_project_lite::pin_project! {
|
1862 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1863 - | /// [`MalformedRangeOverrideInput`](crate::input::MalformedRangeOverrideInput) using modelled bindings.
|
1864 - | pub struct MalformedRangeOverrideInputFuture {
|
1865 - | 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>>
|
1866 - | }
|
1867 - | }
|
1868 - |
|
1869 - | impl std::future::Future for MalformedRangeOverrideInputFuture {
|
1870 - | type Output = Result<
|
1871 - | crate::input::MalformedRangeOverrideInput,
|
1872 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1873 - | >;
|
1874 - |
|
1875 - | fn poll(
|
1876 - | self: std::pin::Pin<&mut Self>,
|
1877 - | cx: &mut std::task::Context<'_>,
|
1878 - | ) -> std::task::Poll<Self::Output> {
|
1879 - | let this = self.project();
|
1880 - | this.inner.as_mut().poll(cx)
|
1881 - | }
|
1882 - | }
|
1883 - |
|
1884 - | impl<B>
|
1885 - | ::aws_smithy_http_server::request::FromRequest<
|
1886 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1887 - | B,
|
1888 - | > for crate::input::MalformedRangeOverrideInput
|
1889 - | where
|
1890 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1891 - | B: 'static,
|
1892 - |
|
1893 - | B::Data: Send,
|
1894 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1895 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1896 - | {
|
1897 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1898 - | type Future = MalformedRangeOverrideInputFuture;
|
1899 - |
|
1900 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1901 - | let fut = async move {
|
1902 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1903 - | request.headers(),
|
1904 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1905 - | ) {
|
1906 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1907 - | }
|
1908 - | crate::protocol_serde::shape_malformed_range_override::de_malformed_range_override_http_request(request)
|
1909 - | .await
|
1910 - | };
|
1911 - | use ::futures_util::future::TryFutureExt;
|
1912 - | let fut = fut.map_err(
|
1913 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1914 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1915 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
1916 - | e,
|
1917 - | )
|
1918 - | },
|
1919 - | );
|
1920 - | MalformedRangeOverrideInputFuture {
|
1921 - | inner: Box::pin(fut),
|
1922 - | }
|
1923 - | }
|
1924 - | }
|
1925 - | impl
|
1926 - | ::aws_smithy_http_server::response::IntoResponse<
|
1927 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1928 - | > for crate::output::MalformedRangeOverrideOutput
|
1929 - | {
|
1930 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1931 - | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_response(self) {
|
1932 - | Ok(response) => response,
|
1933 - | Err(e) => {
|
1934 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1935 - | ::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))
|
1936 - | }
|
1937 - | }
|
1938 - | }
|
1939 - | }
|
1940 - | impl
|
1941 - | ::aws_smithy_http_server::response::IntoResponse<
|
1942 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1943 - | > for crate::error::MalformedRangeOverrideError
|
1944 - | {
|
1945 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1946 - | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_error(&self) {
|
1947 - | Ok(mut response) => {
|
1948 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
1949 - | response
|
1950 - | },
|
1951 - | Err(e) => {
|
1952 - | ::tracing::error!(error = %e, "failed to serialize response");
|
1953 - | ::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))
|
1954 - | }
|
1955 - | }
|
1956 - | }
|
1957 - | }
|
1958 - |
|
1959 - | #[allow(unreachable_code, unused_variables)]
|
1960 - | #[cfg(test)]
|
1961 - | mod malformed_range_override_test {
|
1962 - |
|
1963 - | /// When a byte member does not fit within range bounds,
|
1650 + | /// When a map member does not fit within length bounds,
|
1964 1651 | /// the response should be a 400 ValidationException.
|
1965 - | /// Test ID: RestJsonMalformedRangeByteOverride_case0
|
1652 + | /// Test ID: RestJsonMalformedLengthMap_case1
|
1966 1653 | #[::tokio::test]
|
1967 1654 | #[::tracing_test::traced_test]
|
1968 - | async fn rest_json_malformed_range_byte_override_case0_malformed_request() {
|
1655 + | async fn rest_json_malformed_length_map_case1_malformed_request() {
|
1969 1656 | {
|
1970 1657 | #[allow(unused_mut)]
|
1971 1658 | let mut http_request = ::http_1x::Request::builder()
|
1972 - | .uri("/MalformedRangeOverride")
|
1659 + | .uri("/MalformedLength")
|
1973 1660 | .method("POST")
|
1974 1661 | .header("content-type", "application/json")
|
1975 - | .body(::aws_smithy_http_server::body::boxed(
|
1976 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1977 - | &::aws_smithy_protocol_test::decode_body_data(
|
1978 - | "{ \"byte\" : 3 }".as_bytes(),
|
1979 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1980 - | ),
|
1981 - | )),
|
1982 - | ))
|
1983 - | .unwrap();
|
1662 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1663 + | ::bytes::Bytes::copy_from_slice(
|
1664 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"],\n \"efg\": [\"abc\", \"def\", \"efg\"], \"fgh\": [\"abc\", \"def\", \"efg\"],\n \"ghi\": [\"abc\", \"def\", \"efg\"], \"jkl\": [\"abc\", \"def\", \"efg\"],\n \"klm\": [\"abc\", \"def\", \"efg\"], \"lmn\": [\"abc\", \"def\", \"efg\"] } }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1665 + | )
|
1666 + | ))).unwrap();
|
1984 1667 | #[allow(unused_mut)]
|
1985 1668 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1986 1669 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1987 1670 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1988 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1671 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1989 1672 | let sender = sender.clone();
|
1990 1673 | async move {
|
1991 - | 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> };
|
1674 + | 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> };
|
1992 1675 | sender.send(()).await.expect("receiver dropped early");
|
1993 1676 | result
|
1994 1677 | }
|
1995 1678 | })
|
1996 1679 | .build_unchecked();
|
1997 1680 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1998 1681 | .await
|
1999 1682 | .expect("unable to make an HTTP request");
|
2000 1683 | ::pretty_assertions::assert_eq!(
|
2001 1684 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2002 1685 | http_response.status()
|
2003 1686 | );
|
2004 1687 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2005 1688 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2006 1689 | http_response.headers(),
|
2007 1690 | expected_headers,
|
2008 1691 | ));
|
2009 1692 | use ::http_body_util::BodyExt;
|
2010 1693 | let body = http_response
|
2011 1694 | .into_body()
|
2012 1695 | .collect()
|
2013 1696 | .await
|
2014 1697 | .expect("unable to collect body")
|
2015 1698 | .to_bytes();
|
2016 1699 | ::aws_smithy_protocol_test::assert_ok(
|
2017 - | ::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"))
|
1700 + | ::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"))
|
2018 1701 | );
|
2019 1702 | }
|
2020 1703 | }
|
2021 1704 |
|
2022 - | /// When a byte member does not fit within range bounds,
|
1705 + | /// When a map member's key does not fit within length bounds,
|
2023 1706 | /// the response should be a 400 ValidationException.
|
2024 - | /// Test ID: RestJsonMalformedRangeByteOverride_case1
|
1707 + | /// Test ID: RestJsonMalformedLengthMapKey_case0
|
2025 1708 | #[::tokio::test]
|
2026 1709 | #[::tracing_test::traced_test]
|
2027 - | async fn rest_json_malformed_range_byte_override_case1_malformed_request() {
|
1710 + | async fn rest_json_malformed_length_map_key_case0_malformed_request() {
|
2028 1711 | {
|
2029 1712 | #[allow(unused_mut)]
|
2030 1713 | let mut http_request = ::http_1x::Request::builder()
|
2031 - | .uri("/MalformedRangeOverride")
|
1714 + | .uri("/MalformedLength")
|
2032 1715 | .method("POST")
|
2033 1716 | .header("content-type", "application/json")
|
2034 - | .body(::aws_smithy_http_server::body::boxed(
|
2035 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2036 - | &::aws_smithy_protocol_test::decode_body_data(
|
2037 - | "{ \"byte\" : 7 }".as_bytes(),
|
2038 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2039 - | ),
|
2040 - | )),
|
2041 - | ))
|
2042 - | .unwrap();
|
1717 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1718 + | ::bytes::Bytes::copy_from_slice(
|
1719 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"a\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1720 + | )
|
1721 + | ))).unwrap();
|
2043 1722 | #[allow(unused_mut)]
|
2044 1723 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2045 1724 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2046 1725 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2047 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1726 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
2048 1727 | let sender = sender.clone();
|
2049 1728 | async move {
|
2050 - | 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> };
|
1729 + | 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> };
|
2051 1730 | sender.send(()).await.expect("receiver dropped early");
|
2052 1731 | result
|
2053 1732 | }
|
2054 1733 | })
|
2055 1734 | .build_unchecked();
|
2056 1735 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2057 1736 | .await
|
2058 1737 | .expect("unable to make an HTTP request");
|
2059 1738 | ::pretty_assertions::assert_eq!(
|
2060 1739 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2061 1740 | http_response.status()
|
2062 1741 | );
|
2063 1742 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2064 1743 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2065 1744 | http_response.headers(),
|
2066 1745 | expected_headers,
|
2067 1746 | ));
|
2068 1747 | use ::http_body_util::BodyExt;
|
2069 1748 | let body = http_response
|
2070 1749 | .into_body()
|
2071 1750 | .collect()
|
2072 1751 | .await
|
2073 1752 | .expect("unable to collect body")
|
2074 1753 | .to_bytes();
|
2075 1754 | ::aws_smithy_protocol_test::assert_ok(
|
2076 - | ::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"))
|
1755 + | ::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"))
|
2077 1756 | );
|
2078 1757 | }
|
2079 1758 | }
|
2080 1759 |
|
2081 - | /// When a byte member does not fit within range bounds,
|
1760 + | /// When a map member's key does not fit within length bounds,
|
2082 1761 | /// the response should be a 400 ValidationException.
|
2083 - | /// Test ID: RestJsonMalformedRangeMinByteOverride
|
1762 + | /// Test ID: RestJsonMalformedLengthMapKey_case1
|
2084 1763 | #[::tokio::test]
|
2085 1764 | #[::tracing_test::traced_test]
|
2086 - | async fn rest_json_malformed_range_min_byte_override_malformed_request() {
|
1765 + | async fn rest_json_malformed_length_map_key_case1_malformed_request() {
|
2087 1766 | {
|
2088 1767 | #[allow(unused_mut)]
|
2089 1768 | let mut http_request = ::http_1x::Request::builder()
|
2090 - | .uri("/MalformedRangeOverride")
|
1769 + | .uri("/MalformedLength")
|
2091 1770 | .method("POST")
|
2092 1771 | .header("content-type", "application/json")
|
2093 - | .body(::aws_smithy_http_server::body::boxed(
|
2094 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2095 - | &::aws_smithy_protocol_test::decode_body_data(
|
2096 - | "{ \"minByte\" : 3 }".as_bytes(),
|
2097 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2098 - | ),
|
2099 - | )),
|
2100 - | ))
|
2101 - | .unwrap();
|
1772 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1773 + | ::bytes::Bytes::copy_from_slice(
|
1774 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abcdefghijklmnopqrstuvwxyz\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1775 + | )
|
1776 + | ))).unwrap();
|
2102 1777 | #[allow(unused_mut)]
|
2103 1778 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2104 1779 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2105 1780 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2106 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1781 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
2107 1782 | let sender = sender.clone();
|
2108 1783 | async move {
|
2109 - | 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> };
|
1784 + | 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> };
|
2110 1785 | sender.send(()).await.expect("receiver dropped early");
|
2111 1786 | result
|
2112 1787 | }
|
2113 1788 | })
|
2114 1789 | .build_unchecked();
|
2115 1790 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2116 1791 | .await
|
2117 1792 | .expect("unable to make an HTTP request");
|
2118 1793 | ::pretty_assertions::assert_eq!(
|
2119 1794 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2120 1795 | http_response.status()
|
2121 1796 | );
|
2122 1797 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2123 1798 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2124 1799 | http_response.headers(),
|
2125 1800 | expected_headers,
|
2126 1801 | ));
|
2127 1802 | use ::http_body_util::BodyExt;
|
2128 1803 | let body = http_response
|
2129 1804 | .into_body()
|
2130 1805 | .collect()
|
2131 1806 | .await
|
2132 1807 | .expect("unable to collect body")
|
2133 1808 | .to_bytes();
|
2134 1809 | ::aws_smithy_protocol_test::assert_ok(
|
2135 - | ::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"))
|
1810 + | ::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"))
|
2136 1811 | );
|
2137 1812 | }
|
2138 1813 | }
|
2139 1814 |
|
2140 - | /// When a byte member does not fit within range bounds,
|
1815 + | /// When a map member's value does not fit within length bounds,
|
2141 1816 | /// the response should be a 400 ValidationException.
|
2142 - | /// Test ID: RestJsonMalformedRangeMaxByteOverride
|
1817 + | /// Test ID: RestJsonMalformedLengthMapValue_case0
|
2143 1818 | #[::tokio::test]
|
2144 1819 | #[::tracing_test::traced_test]
|
2145 - | async fn rest_json_malformed_range_max_byte_override_malformed_request() {
|
1820 + | async fn rest_json_malformed_length_map_value_case0_malformed_request() {
|
2146 1821 | {
|
2147 1822 | #[allow(unused_mut)]
|
2148 1823 | let mut http_request = ::http_1x::Request::builder()
|
2149 - | .uri("/MalformedRangeOverride")
|
1824 + | .uri("/MalformedLength")
|
2150 1825 | .method("POST")
|
2151 1826 | .header("content-type", "application/json")
|
2152 - | .body(::aws_smithy_http_server::body::boxed(
|
2153 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2154 - | &::aws_smithy_protocol_test::decode_body_data(
|
2155 - | "{ \"maxByte\" : 7 }".as_bytes(),
|
2156 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2157 - | ),
|
2158 - | )),
|
2159 - | ))
|
2160 - | .unwrap();
|
1827 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1828 + | ::bytes::Bytes::copy_from_slice(
|
1829 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1830 + | )
|
1831 + | ))).unwrap();
|
2161 1832 | #[allow(unused_mut)]
|
2162 1833 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2163 1834 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2164 1835 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2165 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1836 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
2166 1837 | let sender = sender.clone();
|
2167 1838 | async move {
|
2168 - | 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> };
|
1839 + | 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> };
|
2169 1840 | sender.send(()).await.expect("receiver dropped early");
|
2170 1841 | result
|
2171 1842 | }
|
2172 1843 | })
|
2173 1844 | .build_unchecked();
|
2174 1845 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2175 1846 | .await
|
2176 1847 | .expect("unable to make an HTTP request");
|
2177 1848 | ::pretty_assertions::assert_eq!(
|
2178 1849 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2179 1850 | http_response.status()
|
2180 1851 | );
|
2181 1852 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2182 1853 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2183 1854 | http_response.headers(),
|
2184 1855 | expected_headers,
|
2185 1856 | ));
|
2186 1857 | use ::http_body_util::BodyExt;
|
2187 1858 | let body = http_response
|
2188 1859 | .into_body()
|
2189 1860 | .collect()
|
2190 1861 | .await
|
2191 1862 | .expect("unable to collect body")
|
2192 1863 | .to_bytes();
|
2193 1864 | ::aws_smithy_protocol_test::assert_ok(
|
2194 - | ::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"))
|
1865 + | ::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"))
|
2195 1866 | );
|
2196 1867 | }
|
2197 1868 | }
|
2198 1869 |
|
2199 - | /// When a float member does not fit within range bounds,
|
1870 + | /// When a map member's value does not fit within length bounds,
|
2200 1871 | /// the response should be a 400 ValidationException.
|
2201 - | /// Test ID: RestJsonMalformedRangeFloatOverride_case0
|
1872 + | /// Test ID: RestJsonMalformedLengthMapValue_case1
|
2202 1873 | #[::tokio::test]
|
2203 1874 | #[::tracing_test::traced_test]
|
2204 - | #[should_panic]
|
2205 - | async fn rest_json_malformed_range_float_override_case0_malformed_request() {
|
1875 + | async fn rest_json_malformed_length_map_value_case1_malformed_request() {
|
2206 1876 | {
|
2207 1877 | #[allow(unused_mut)]
|
2208 1878 | let mut http_request = ::http_1x::Request::builder()
|
2209 - | .uri("/MalformedRangeOverride")
|
1879 + | .uri("/MalformedLength")
|
2210 1880 | .method("POST")
|
2211 1881 | .header("content-type", "application/json")
|
2212 - | .body(::aws_smithy_http_server::body::boxed(
|
2213 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2214 - | &::aws_smithy_protocol_test::decode_body_data(
|
2215 - | "{ \"float\" : 4.3 }".as_bytes(),
|
2216 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2217 - | ),
|
2218 - | )),
|
2219 - | ))
|
2220 - | .unwrap();
|
1882 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
1883 + | ::bytes::Bytes::copy_from_slice(
|
1884 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\"],\n \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
1885 + | )
|
1886 + | ))).unwrap();
|
2221 1887 | #[allow(unused_mut)]
|
2222 1888 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2223 1889 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2224 1890 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2225 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1891 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
2226 1892 | let sender = sender.clone();
|
2227 1893 | async move {
|
2228 - | 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> };
|
1894 + | 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> };
|
2229 1895 | sender.send(()).await.expect("receiver dropped early");
|
2230 1896 | result
|
2231 1897 | }
|
2232 1898 | })
|
2233 1899 | .build_unchecked();
|
2234 1900 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2235 1901 | .await
|
2236 1902 | .expect("unable to make an HTTP request");
|
2237 1903 | ::pretty_assertions::assert_eq!(
|
2238 1904 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2239 1905 | http_response.status()
|
2240 1906 | );
|
2241 1907 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2242 1908 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2243 1909 | http_response.headers(),
|
2244 1910 | expected_headers,
|
2245 1911 | ));
|
2246 1912 | use ::http_body_util::BodyExt;
|
2247 1913 | let body = http_response
|
2248 1914 | .into_body()
|
2249 1915 | .collect()
|
2250 1916 | .await
|
2251 1917 | .expect("unable to collect body")
|
2252 1918 | .to_bytes();
|
2253 1919 | ::aws_smithy_protocol_test::assert_ok(
|
2254 - | ::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"))
|
1920 + | ::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"))
|
2255 1921 | );
|
2256 1922 | }
|
2257 1923 | }
|
1924 + | }
|
2258 1925 |
|
2259 - | /// When a float member does not fit within range bounds,
|
2260 - | /// the response should be a 400 ValidationException.
|
2261 - | /// Test ID: RestJsonMalformedRangeFloatOverride_case1
|
2262 - | #[::tokio::test]
|
2263 - | #[::tracing_test::traced_test]
|
2264 - | #[should_panic]
|
2265 - | async fn rest_json_malformed_range_float_override_case1_malformed_request() {
|
2266 - | {
|
2267 - | #[allow(unused_mut)]
|
2268 - | let mut http_request = ::http_1x::Request::builder()
|
2269 - | .uri("/MalformedRangeOverride")
|
2270 - | .method("POST")
|
2271 - | .header("content-type", "application/json")
|
2272 - | .body(::aws_smithy_http_server::body::boxed(
|
2273 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2274 - | &::aws_smithy_protocol_test::decode_body_data(
|
2275 - | "{ \"float\" : 6.7 }".as_bytes(),
|
2276 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2277 - | ),
|
1926 + | ::pin_project_lite::pin_project! {
|
1927 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
1928 + | /// [`MalformedLengthOverrideInput`](crate::input::MalformedLengthOverrideInput) using modelled bindings.
|
1929 + | pub struct MalformedLengthOverrideInputFuture {
|
1930 + | 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>>
|
1931 + | }
|
1932 + | }
|
1933 + |
|
1934 + | impl std::future::Future for MalformedLengthOverrideInputFuture {
|
1935 + | type Output = Result<
|
1936 + | crate::input::MalformedLengthOverrideInput,
|
1937 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
1938 + | >;
|
1939 + |
|
1940 + | fn poll(
|
1941 + | self: std::pin::Pin<&mut Self>,
|
1942 + | cx: &mut std::task::Context<'_>,
|
1943 + | ) -> std::task::Poll<Self::Output> {
|
1944 + | let this = self.project();
|
1945 + | this.inner.as_mut().poll(cx)
|
1946 + | }
|
1947 + | }
|
1948 + |
|
1949 + | impl<B>
|
1950 + | ::aws_smithy_http_server::request::FromRequest<
|
1951 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1952 + | B,
|
1953 + | > for crate::input::MalformedLengthOverrideInput
|
1954 + | where
|
1955 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
1956 + | B: 'static,
|
1957 + |
|
1958 + | B::Data: Send,
|
1959 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
1960 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
1961 + | {
|
1962 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
1963 + | type Future = MalformedLengthOverrideInputFuture;
|
1964 + |
|
1965 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
1966 + | let fut = async move {
|
1967 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
1968 + | request.headers(),
|
1969 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
1970 + | ) {
|
1971 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
1972 + | }
|
1973 + | crate::protocol_serde::shape_malformed_length_override::de_malformed_length_override_http_request(request)
|
1974 + | .await
|
1975 + | };
|
1976 + | use ::futures_util::future::TryFutureExt;
|
1977 + | let fut = fut.map_err(
|
1978 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
1979 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
1980 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
1981 + | e,
|
1982 + | )
|
1983 + | },
|
1984 + | );
|
1985 + | MalformedLengthOverrideInputFuture {
|
1986 + | inner: Box::pin(fut),
|
1987 + | }
|
1988 + | }
|
1989 + | }
|
1990 + | impl
|
1991 + | ::aws_smithy_http_server::response::IntoResponse<
|
1992 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
1993 + | > for crate::output::MalformedLengthOverrideOutput
|
1994 + | {
|
1995 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
1996 + | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_response(self) {
|
1997 + | Ok(response) => response,
|
1998 + | Err(e) => {
|
1999 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2000 + | ::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))
|
2001 + | }
|
2002 + | }
|
2003 + | }
|
2004 + | }
|
2005 + | impl
|
2006 + | ::aws_smithy_http_server::response::IntoResponse<
|
2007 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2008 + | > for crate::error::MalformedLengthOverrideError
|
2009 + | {
|
2010 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2011 + | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_error(&self) {
|
2012 + | Ok(mut response) => {
|
2013 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
2014 + | response
|
2015 + | },
|
2016 + | Err(e) => {
|
2017 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2018 + | ::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))
|
2019 + | }
|
2020 + | }
|
2021 + | }
|
2022 + | }
|
2023 + |
|
2024 + | #[allow(unreachable_code, unused_variables)]
|
2025 + | #[cfg(test)]
|
2026 + | mod malformed_length_override_test {
|
2027 + |
|
2028 + | /// When a blob member does not fit within length bounds,
|
2029 + | /// the response should be a 400 ValidationException.
|
2030 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case0
|
2031 + | #[::tokio::test]
|
2032 + | #[::tracing_test::traced_test]
|
2033 + | async fn rest_json_malformed_length_blob_override_case0_malformed_request() {
|
2034 + | {
|
2035 + | #[allow(unused_mut)]
|
2036 + | let mut http_request = ::http_1x::Request::builder()
|
2037 + | .uri("/MalformedLengthOverride")
|
2038 + | .method("POST")
|
2039 + | .header("content-type", "application/json")
|
2040 + | .body(::aws_smithy_http_server::body::boxed(
|
2041 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2042 + | &::aws_smithy_protocol_test::decode_body_data(
|
2043 + | "{ \"blob\" : \"YWJj\" }".as_bytes(),
|
2044 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2045 + | ),
|
2278 2046 | )),
|
2279 2047 | ))
|
2280 2048 | .unwrap();
|
2281 2049 | #[allow(unused_mut)]
|
2282 2050 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2283 2051 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2284 2052 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2285 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2053 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2286 2054 | let sender = sender.clone();
|
2287 2055 | async move {
|
2288 - | 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> };
|
2056 + | 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> };
|
2289 2057 | sender.send(()).await.expect("receiver dropped early");
|
2290 2058 | result
|
2291 2059 | }
|
2292 2060 | })
|
2293 2061 | .build_unchecked();
|
2294 2062 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2295 2063 | .await
|
2296 2064 | .expect("unable to make an HTTP request");
|
2297 2065 | ::pretty_assertions::assert_eq!(
|
2298 2066 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2299 2067 | http_response.status()
|
2300 2068 | );
|
2301 2069 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2302 2070 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2303 2071 | http_response.headers(),
|
2304 2072 | expected_headers,
|
2305 2073 | ));
|
2306 2074 | use ::http_body_util::BodyExt;
|
2307 2075 | let body = http_response
|
2308 2076 | .into_body()
|
2309 2077 | .collect()
|
2310 2078 | .await
|
2311 2079 | .expect("unable to collect body")
|
2312 2080 | .to_bytes();
|
2313 2081 | ::aws_smithy_protocol_test::assert_ok(
|
2314 - | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/float' failed to satisfy constraint: Member must be between 4.4 and 6.6, inclusive\",\n \"fieldList\" : [{\"message\": \"Value at '/float' failed to satisfy constraint: Member must be between 4.4 and 6.6, inclusive\", \"path\": \"/float\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
2082 + | ::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"))
|
2315 2083 | );
|
2316 2084 | }
|
2317 2085 | }
|
2318 2086 |
|
2319 - | /// When a float member does not fit within range bounds,
|
2087 + | /// When a blob member does not fit within length bounds,
|
2320 2088 | /// the response should be a 400 ValidationException.
|
2321 - | /// Test ID: RestJsonMalformedRangeMinFloatOverride
|
2089 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case1
|
2322 2090 | #[::tokio::test]
|
2323 2091 | #[::tracing_test::traced_test]
|
2324 - | #[should_panic]
|
2325 - | async fn rest_json_malformed_range_min_float_override_malformed_request() {
|
2092 + | async fn rest_json_malformed_length_blob_override_case1_malformed_request() {
|
2326 2093 | {
|
2327 2094 | #[allow(unused_mut)]
|
2328 2095 | let mut http_request = ::http_1x::Request::builder()
|
2329 - | .uri("/MalformedRangeOverride")
|
2096 + | .uri("/MalformedLengthOverride")
|
2330 2097 | .method("POST")
|
2331 2098 | .header("content-type", "application/json")
|
2332 2099 | .body(::aws_smithy_http_server::body::boxed(
|
2333 2100 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2334 2101 | &::aws_smithy_protocol_test::decode_body_data(
|
2335 - | "{ \"minFloat\" : 4.3 }".as_bytes(),
|
2102 + | "{ \"blob\" : \"YWJjZGVmZw==\" }".as_bytes(),
|
2336 2103 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2337 2104 | ),
|
2338 2105 | )),
|
2339 2106 | ))
|
2340 2107 | .unwrap();
|
2341 2108 | #[allow(unused_mut)]
|
2342 2109 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2343 2110 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2344 2111 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2345 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2112 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2346 2113 | let sender = sender.clone();
|
2347 2114 | async move {
|
2348 - | 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> };
|
2115 + | 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> };
|
2349 2116 | sender.send(()).await.expect("receiver dropped early");
|
2350 2117 | result
|
2351 2118 | }
|
2352 2119 | })
|
2353 2120 | .build_unchecked();
|
2354 2121 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2355 2122 | .await
|
2356 2123 | .expect("unable to make an HTTP request");
|
2357 2124 | ::pretty_assertions::assert_eq!(
|
2358 2125 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2359 2126 | http_response.status()
|
2360 2127 | );
|
2361 2128 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2362 2129 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2363 2130 | http_response.headers(),
|
2364 2131 | expected_headers,
|
2365 2132 | ));
|
2366 2133 | use ::http_body_util::BodyExt;
|
2367 2134 | let body = http_response
|
2368 2135 | .into_body()
|
2369 2136 | .collect()
|
2370 2137 | .await
|
2371 2138 | .expect("unable to collect body")
|
2372 2139 | .to_bytes();
|
2373 2140 | ::aws_smithy_protocol_test::assert_ok(
|
2374 - | ::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"))
|
2141 + | ::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"))
|
2375 2142 | );
|
2376 2143 | }
|
2377 2144 | }
|
2378 2145 |
|
2379 - | /// When a float member does not fit within range bounds,
|
2146 + | /// When a string member does not fit within length bounds,
|
2380 2147 | /// the response should be a 400 ValidationException.
|
2381 - | /// Test ID: RestJsonMalformedRangeMaxFloatOverride
|
2148 + | /// Test ID: RestJsonMalformedLengthStringOverride_case0
|
2382 2149 | #[::tokio::test]
|
2383 2150 | #[::tracing_test::traced_test]
|
2384 - | #[should_panic]
|
2385 - | async fn rest_json_malformed_range_max_float_override_malformed_request() {
|
2151 + | async fn rest_json_malformed_length_string_override_case0_malformed_request() {
|
2386 2152 | {
|
2387 2153 | #[allow(unused_mut)]
|
2388 2154 | let mut http_request = ::http_1x::Request::builder()
|
2389 - | .uri("/MalformedRangeOverride")
|
2155 + | .uri("/MalformedLengthOverride")
|
2390 2156 | .method("POST")
|
2391 2157 | .header("content-type", "application/json")
|
2392 2158 | .body(::aws_smithy_http_server::body::boxed(
|
2393 2159 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2394 2160 | &::aws_smithy_protocol_test::decode_body_data(
|
2395 - | "{ \"maxFloat\" : 6.7 }".as_bytes(),
|
2161 + | "{ \"string\" : \"abc\" }".as_bytes(),
|
2396 2162 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2397 2163 | ),
|
2398 2164 | )),
|
2399 2165 | ))
|
2400 2166 | .unwrap();
|
2401 2167 | #[allow(unused_mut)]
|
2402 2168 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2403 2169 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2404 2170 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2405 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2171 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2406 2172 | let sender = sender.clone();
|
2407 2173 | async move {
|
2408 - | 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> };
|
2174 + | 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> };
|
2409 2175 | sender.send(()).await.expect("receiver dropped early");
|
2410 2176 | result
|
2411 2177 | }
|
2412 2178 | })
|
2413 2179 | .build_unchecked();
|
2414 2180 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2415 2181 | .await
|
2416 2182 | .expect("unable to make an HTTP request");
|
2417 2183 | ::pretty_assertions::assert_eq!(
|
2418 2184 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2419 2185 | http_response.status()
|
2420 2186 | );
|
2421 2187 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2422 2188 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2423 2189 | http_response.headers(),
|
2424 2190 | expected_headers,
|
2425 2191 | ));
|
2426 2192 | use ::http_body_util::BodyExt;
|
2427 2193 | let body = http_response
|
2428 2194 | .into_body()
|
2429 2195 | .collect()
|
2430 2196 | .await
|
2431 2197 | .expect("unable to collect body")
|
2432 2198 | .to_bytes();
|
2433 2199 | ::aws_smithy_protocol_test::assert_ok(
|
2434 - | ::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"))
|
2200 + | ::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"))
|
2435 2201 | );
|
2436 2202 | }
|
2437 2203 | }
|
2438 2204 |
|
2439 - | /// When a short member does not fit within range bounds,
|
2205 + | /// When a string member does not fit within length bounds,
|
2440 2206 | /// the response should be a 400 ValidationException.
|
2441 - | /// Test ID: RestJsonMalformedRangeShortOverride_case0
|
2207 + | /// Test ID: RestJsonMalformedLengthStringOverride_case1
|
2442 2208 | #[::tokio::test]
|
2443 2209 | #[::tracing_test::traced_test]
|
2444 - | async fn rest_json_malformed_range_short_override_case0_malformed_request() {
|
2210 + | async fn rest_json_malformed_length_string_override_case1_malformed_request() {
|
2445 2211 | {
|
2446 2212 | #[allow(unused_mut)]
|
2447 2213 | let mut http_request = ::http_1x::Request::builder()
|
2448 - | .uri("/MalformedRangeOverride")
|
2214 + | .uri("/MalformedLengthOverride")
|
2449 2215 | .method("POST")
|
2450 2216 | .header("content-type", "application/json")
|
2451 2217 | .body(::aws_smithy_http_server::body::boxed(
|
2452 2218 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2453 2219 | &::aws_smithy_protocol_test::decode_body_data(
|
2454 - | "{ \"short\" : 3 }".as_bytes(),
|
2220 + | "{ \"string\" : \"abcdefg\" }".as_bytes(),
|
2455 2221 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2456 2222 | ),
|
2457 2223 | )),
|
2458 2224 | ))
|
2459 2225 | .unwrap();
|
2460 2226 | #[allow(unused_mut)]
|
2461 2227 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2462 2228 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2463 2229 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2464 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2230 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2465 2231 | let sender = sender.clone();
|
2466 2232 | async move {
|
2467 - | 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> };
|
2233 + | 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> };
|
2468 2234 | sender.send(()).await.expect("receiver dropped early");
|
2469 2235 | result
|
2470 2236 | }
|
2471 2237 | })
|
2472 2238 | .build_unchecked();
|
2473 2239 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2474 2240 | .await
|
2475 2241 | .expect("unable to make an HTTP request");
|
2476 2242 | ::pretty_assertions::assert_eq!(
|
2477 2243 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2478 2244 | http_response.status()
|
2479 2245 | );
|
2480 2246 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2481 2247 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2482 2248 | http_response.headers(),
|
2483 2249 | expected_headers,
|
2484 2250 | ));
|
2485 2251 | use ::http_body_util::BodyExt;
|
2486 2252 | let body = http_response
|
2487 2253 | .into_body()
|
2488 2254 | .collect()
|
2489 2255 | .await
|
2490 2256 | .expect("unable to collect body")
|
2491 2257 | .to_bytes();
|
2492 2258 | ::aws_smithy_protocol_test::assert_ok(
|
2493 - | ::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"))
|
2259 + | ::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"))
|
2494 2260 | );
|
2495 2261 | }
|
2496 2262 | }
|
2497 2263 |
|
2498 - | /// When a short member does not fit within range bounds,
|
2264 + | /// When a string member does not fit within length bounds,
|
2499 2265 | /// the response should be a 400 ValidationException.
|
2500 - | /// Test ID: RestJsonMalformedRangeShortOverride_case1
|
2266 + | /// Test ID: RestJsonMalformedLengthStringOverride_case2
|
2501 2267 | #[::tokio::test]
|
2502 2268 | #[::tracing_test::traced_test]
|
2503 - | async fn rest_json_malformed_range_short_override_case1_malformed_request() {
|
2269 + | async fn rest_json_malformed_length_string_override_case2_malformed_request() {
|
2504 2270 | {
|
2505 2271 | #[allow(unused_mut)]
|
2506 2272 | let mut http_request = ::http_1x::Request::builder()
|
2507 - | .uri("/MalformedRangeOverride")
|
2273 + | .uri("/MalformedLengthOverride")
|
2508 2274 | .method("POST")
|
2509 2275 | .header("content-type", "application/json")
|
2510 2276 | .body(::aws_smithy_http_server::body::boxed(
|
2511 2277 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2512 2278 | &::aws_smithy_protocol_test::decode_body_data(
|
2513 - | "{ \"short\" : 7 }".as_bytes(),
|
2279 + | "{ \"string\" : \"👍👍👍\" }".as_bytes(),
|
2514 2280 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2515 2281 | ),
|
2516 2282 | )),
|
2517 2283 | ))
|
2518 2284 | .unwrap();
|
2519 2285 | #[allow(unused_mut)]
|
2520 2286 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2521 2287 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2522 2288 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2523 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2289 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2524 2290 | let sender = sender.clone();
|
2525 2291 | async move {
|
2526 - | 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> };
|
2292 + | 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> };
|
2527 2293 | sender.send(()).await.expect("receiver dropped early");
|
2528 2294 | result
|
2529 2295 | }
|
2530 2296 | })
|
2531 2297 | .build_unchecked();
|
2532 2298 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2533 2299 | .await
|
2534 2300 | .expect("unable to make an HTTP request");
|
2535 2301 | ::pretty_assertions::assert_eq!(
|
2536 2302 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2537 2303 | http_response.status()
|
2538 2304 | );
|
2539 2305 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2540 2306 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2541 2307 | http_response.headers(),
|
2542 2308 | expected_headers,
|
2543 2309 | ));
|
2544 2310 | use ::http_body_util::BodyExt;
|
2545 2311 | let body = http_response
|
2546 2312 | .into_body()
|
2547 2313 | .collect()
|
2548 2314 | .await
|
2549 2315 | .expect("unable to collect body")
|
2550 2316 | .to_bytes();
|
2551 2317 | ::aws_smithy_protocol_test::assert_ok(
|
2552 - | ::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"))
|
2318 + | ::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"))
|
2553 2319 | );
|
2554 2320 | }
|
2555 2321 | }
|
2556 2322 |
|
2557 - | /// When a short member does not fit within range bounds,
|
2323 + | /// When a string member does not fit within length bounds,
|
2558 2324 | /// the response should be a 400 ValidationException.
|
2559 - | /// Test ID: RestJsonMalformedRangeMinShortOverride
|
2325 + | /// Test ID: RestJsonMalformedLengthMinStringOverride
|
2560 2326 | #[::tokio::test]
|
2561 2327 | #[::tracing_test::traced_test]
|
2562 - | async fn rest_json_malformed_range_min_short_override_malformed_request() {
|
2328 + | async fn rest_json_malformed_length_min_string_override_malformed_request() {
|
2563 2329 | {
|
2564 2330 | #[allow(unused_mut)]
|
2565 2331 | let mut http_request = ::http_1x::Request::builder()
|
2566 - | .uri("/MalformedRangeOverride")
|
2332 + | .uri("/MalformedLengthOverride")
|
2567 2333 | .method("POST")
|
2568 2334 | .header("content-type", "application/json")
|
2569 2335 | .body(::aws_smithy_http_server::body::boxed(
|
2570 2336 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2571 2337 | &::aws_smithy_protocol_test::decode_body_data(
|
2572 - | "{ \"minShort\" : 3 }".as_bytes(),
|
2338 + | "{ \"minString\" : \"abc\" }".as_bytes(),
|
2573 2339 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2574 2340 | ),
|
2575 2341 | )),
|
2576 2342 | ))
|
2577 2343 | .unwrap();
|
2578 2344 | #[allow(unused_mut)]
|
2579 2345 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2580 2346 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2581 2347 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2582 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2348 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2583 2349 | let sender = sender.clone();
|
2584 2350 | async move {
|
2585 - | 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> };
|
2351 + | 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> };
|
2586 2352 | sender.send(()).await.expect("receiver dropped early");
|
2587 2353 | result
|
2588 2354 | }
|
2589 2355 | })
|
2590 2356 | .build_unchecked();
|
2591 2357 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2592 2358 | .await
|
2593 2359 | .expect("unable to make an HTTP request");
|
2594 2360 | ::pretty_assertions::assert_eq!(
|
2595 2361 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2596 2362 | http_response.status()
|
2597 2363 | );
|
2598 2364 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2599 2365 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2600 2366 | http_response.headers(),
|
2601 2367 | expected_headers,
|
2602 2368 | ));
|
2603 2369 | use ::http_body_util::BodyExt;
|
2604 2370 | let body = http_response
|
2605 2371 | .into_body()
|
2606 2372 | .collect()
|
2607 2373 | .await
|
2608 2374 | .expect("unable to collect body")
|
2609 2375 | .to_bytes();
|
2610 2376 | ::aws_smithy_protocol_test::assert_ok(
|
2611 - | ::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"))
|
2377 + | ::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"))
|
2612 2378 | );
|
2613 2379 | }
|
2614 2380 | }
|
2615 2381 |
|
2616 - | /// When a short member does not fit within range bounds,
|
2382 + | /// When a string member does not fit within length bounds,
|
2617 2383 | /// the response should be a 400 ValidationException.
|
2618 - | /// Test ID: RestJsonMalformedRangeMaxShortOverride
|
2384 + | /// Test ID: RestJsonMalformedLengthMaxStringOverride
|
2619 2385 | #[::tokio::test]
|
2620 2386 | #[::tracing_test::traced_test]
|
2621 - | async fn rest_json_malformed_range_max_short_override_malformed_request() {
|
2387 + | async fn rest_json_malformed_length_max_string_override_malformed_request() {
|
2622 2388 | {
|
2623 2389 | #[allow(unused_mut)]
|
2624 2390 | let mut http_request = ::http_1x::Request::builder()
|
2625 - | .uri("/MalformedRangeOverride")
|
2391 + | .uri("/MalformedLengthOverride")
|
2626 2392 | .method("POST")
|
2627 2393 | .header("content-type", "application/json")
|
2628 2394 | .body(::aws_smithy_http_server::body::boxed(
|
2629 2395 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2630 2396 | &::aws_smithy_protocol_test::decode_body_data(
|
2631 - | "{ \"maxShort\" : 7 }".as_bytes(),
|
2397 + | "{ \"maxString\" : \"abcdefg\" }".as_bytes(),
|
2632 2398 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2633 2399 | ),
|
2634 2400 | )),
|
2635 2401 | ))
|
2636 2402 | .unwrap();
|
2637 2403 | #[allow(unused_mut)]
|
2638 2404 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2639 2405 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2640 2406 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2641 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2407 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2642 2408 | let sender = sender.clone();
|
2643 2409 | async move {
|
2644 - | 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> };
|
2410 + | 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> };
|
2645 2411 | sender.send(()).await.expect("receiver dropped early");
|
2646 2412 | result
|
2647 2413 | }
|
2648 2414 | })
|
2649 2415 | .build_unchecked();
|
2650 2416 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2651 2417 | .await
|
2652 2418 | .expect("unable to make an HTTP request");
|
2653 2419 | ::pretty_assertions::assert_eq!(
|
2654 2420 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2655 2421 | http_response.status()
|
2656 2422 | );
|
2657 2423 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2658 2424 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2659 2425 | http_response.headers(),
|
2660 2426 | expected_headers,
|
2661 2427 | ));
|
2662 2428 | use ::http_body_util::BodyExt;
|
2663 2429 | let body = http_response
|
2664 2430 | .into_body()
|
2665 2431 | .collect()
|
2666 2432 | .await
|
2667 2433 | .expect("unable to collect body")
|
2668 2434 | .to_bytes();
|
2669 2435 | ::aws_smithy_protocol_test::assert_ok(
|
2670 - | ::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"))
|
2436 + | ::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"))
|
2671 2437 | );
|
2672 2438 | }
|
2673 2439 | }
|
2674 2440 |
|
2675 - | /// When a integer member does not fit within range bounds,
|
2441 + | /// When a list member does not fit within length bounds,
|
2676 2442 | /// the response should be a 400 ValidationException.
|
2677 - | /// Test ID: RestJsonMalformedRangeIntegerOverride_case0
|
2443 + | /// Test ID: RestJsonMalformedLengthListOverride_case0
|
2678 2444 | #[::tokio::test]
|
2679 2445 | #[::tracing_test::traced_test]
|
2680 - | async fn rest_json_malformed_range_integer_override_case0_malformed_request() {
|
2446 + | async fn rest_json_malformed_length_list_override_case0_malformed_request() {
|
2681 2447 | {
|
2682 2448 | #[allow(unused_mut)]
|
2683 2449 | let mut http_request = ::http_1x::Request::builder()
|
2684 - | .uri("/MalformedRangeOverride")
|
2450 + | .uri("/MalformedLengthOverride")
|
2685 2451 | .method("POST")
|
2686 2452 | .header("content-type", "application/json")
|
2687 2453 | .body(::aws_smithy_http_server::body::boxed(
|
2688 2454 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2689 2455 | &::aws_smithy_protocol_test::decode_body_data(
|
2690 - | "{ \"integer\" : 3 }".as_bytes(),
|
2456 + | "{ \"list\" : [\"abc\", \"def\", \"ghi\"] }".as_bytes(),
|
2691 2457 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2692 2458 | ),
|
2693 2459 | )),
|
2694 2460 | ))
|
2695 2461 | .unwrap();
|
2696 2462 | #[allow(unused_mut)]
|
2697 2463 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2698 2464 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2699 2465 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2700 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2466 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2701 2467 | let sender = sender.clone();
|
2702 2468 | async move {
|
2703 - | 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> };
|
2469 + | 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> };
|
2704 2470 | sender.send(()).await.expect("receiver dropped early");
|
2705 2471 | result
|
2706 2472 | }
|
2707 2473 | })
|
2708 2474 | .build_unchecked();
|
2709 2475 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2710 2476 | .await
|
2711 2477 | .expect("unable to make an HTTP request");
|
2712 2478 | ::pretty_assertions::assert_eq!(
|
2713 2479 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2714 2480 | http_response.status()
|
2715 2481 | );
|
2716 2482 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2717 2483 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2718 2484 | http_response.headers(),
|
2719 2485 | expected_headers,
|
2720 2486 | ));
|
2721 2487 | use ::http_body_util::BodyExt;
|
2722 2488 | let body = http_response
|
2723 2489 | .into_body()
|
2724 2490 | .collect()
|
2725 2491 | .await
|
2726 2492 | .expect("unable to collect body")
|
2727 2493 | .to_bytes();
|
2728 2494 | ::aws_smithy_protocol_test::assert_ok(
|
2729 - | ::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"))
|
2495 + | ::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"))
|
2730 2496 | );
|
2731 2497 | }
|
2732 2498 | }
|
2733 2499 |
|
2734 - | /// When a integer member does not fit within range bounds,
|
2500 + | /// When a list member does not fit within length bounds,
|
2735 2501 | /// the response should be a 400 ValidationException.
|
2736 - | /// Test ID: RestJsonMalformedRangeIntegerOverride_case1
|
2502 + | /// Test ID: RestJsonMalformedLengthListOverride_case1
|
2737 2503 | #[::tokio::test]
|
2738 2504 | #[::tracing_test::traced_test]
|
2739 - | async fn rest_json_malformed_range_integer_override_case1_malformed_request() {
|
2505 + | async fn rest_json_malformed_length_list_override_case1_malformed_request() {
|
2740 2506 | {
|
2741 2507 | #[allow(unused_mut)]
|
2742 2508 | let mut http_request = ::http_1x::Request::builder()
|
2743 - | .uri("/MalformedRangeOverride")
|
2509 + | .uri("/MalformedLengthOverride")
|
2744 2510 | .method("POST")
|
2745 2511 | .header("content-type", "application/json")
|
2746 - | .body(::aws_smithy_http_server::body::boxed(
|
2747 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2748 - | &::aws_smithy_protocol_test::decode_body_data(
|
2749 - | "{ \"integer\" : 7 }".as_bytes(),
|
2750 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2751 - | ),
|
2752 - | )),
|
2753 - | ))
|
2754 - | .unwrap();
|
2512 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2513 + | ::bytes::Bytes::copy_from_slice(
|
2514 + | &::aws_smithy_protocol_test::decode_body_data("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
2515 + | )
|
2516 + | ))).unwrap();
|
2755 2517 | #[allow(unused_mut)]
|
2756 2518 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2757 2519 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2758 2520 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2759 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2521 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2760 2522 | let sender = sender.clone();
|
2761 2523 | async move {
|
2762 - | 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> };
|
2524 + | 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> };
|
2763 2525 | sender.send(()).await.expect("receiver dropped early");
|
2764 2526 | result
|
2765 2527 | }
|
2766 2528 | })
|
2767 2529 | .build_unchecked();
|
2768 2530 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2769 2531 | .await
|
2770 2532 | .expect("unable to make an HTTP request");
|
2771 2533 | ::pretty_assertions::assert_eq!(
|
2772 2534 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2773 2535 | http_response.status()
|
2774 2536 | );
|
2775 2537 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2776 2538 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2777 2539 | http_response.headers(),
|
2778 2540 | expected_headers,
|
2779 2541 | ));
|
2780 2542 | use ::http_body_util::BodyExt;
|
2781 2543 | let body = http_response
|
2782 2544 | .into_body()
|
2783 2545 | .collect()
|
2784 2546 | .await
|
2785 2547 | .expect("unable to collect body")
|
2786 2548 | .to_bytes();
|
2787 2549 | ::aws_smithy_protocol_test::assert_ok(
|
2788 - | ::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"))
|
2550 + | ::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"))
|
2789 2551 | );
|
2790 2552 | }
|
2791 2553 | }
|
2792 2554 |
|
2793 - | /// When a integer member does not fit within range bounds,
|
2555 + | /// When a map member does not fit within length bounds,
|
2794 2556 | /// the response should be a 400 ValidationException.
|
2795 - | /// Test ID: RestJsonMalformedRangeMinIntegerOverride
|
2557 + | /// Test ID: RestJsonMalformedLengthMapOverride_case0
|
2796 2558 | #[::tokio::test]
|
2797 2559 | #[::tracing_test::traced_test]
|
2798 - | async fn rest_json_malformed_range_min_integer_override_malformed_request() {
|
2560 + | async fn rest_json_malformed_length_map_override_case0_malformed_request() {
|
2799 2561 | {
|
2800 2562 | #[allow(unused_mut)]
|
2801 2563 | let mut http_request = ::http_1x::Request::builder()
|
2802 - | .uri("/MalformedRangeOverride")
|
2564 + | .uri("/MalformedLengthOverride")
|
2803 2565 | .method("POST")
|
2804 2566 | .header("content-type", "application/json")
|
2805 - | .body(::aws_smithy_http_server::body::boxed(
|
2806 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2807 - | &::aws_smithy_protocol_test::decode_body_data(
|
2808 - | "{ \"minInteger\" : 3 }".as_bytes(),
|
2809 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2810 - | ),
|
2811 - | )),
|
2812 - | ))
|
2813 - | .unwrap();
|
2567 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2568 + | ::bytes::Bytes::copy_from_slice(
|
2569 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
2570 + | )
|
2571 + | ))).unwrap();
|
2814 2572 | #[allow(unused_mut)]
|
2815 2573 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2816 2574 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2817 2575 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2818 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2576 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2819 2577 | let sender = sender.clone();
|
2820 2578 | async move {
|
2821 - | 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> };
|
2579 + | 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> };
|
2822 2580 | sender.send(()).await.expect("receiver dropped early");
|
2823 2581 | result
|
2824 2582 | }
|
2825 2583 | })
|
2826 2584 | .build_unchecked();
|
2827 2585 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2828 2586 | .await
|
2829 2587 | .expect("unable to make an HTTP request");
|
2830 2588 | ::pretty_assertions::assert_eq!(
|
2831 2589 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2832 2590 | http_response.status()
|
2833 2591 | );
|
2834 2592 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2835 2593 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2836 2594 | http_response.headers(),
|
2837 2595 | expected_headers,
|
2838 2596 | ));
|
2839 2597 | use ::http_body_util::BodyExt;
|
2840 2598 | let body = http_response
|
2841 2599 | .into_body()
|
2842 2600 | .collect()
|
2843 2601 | .await
|
2844 2602 | .expect("unable to collect body")
|
2845 2603 | .to_bytes();
|
2846 2604 | ::aws_smithy_protocol_test::assert_ok(
|
2847 - | ::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"))
|
2605 + | ::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"))
|
2848 2606 | );
|
2849 2607 | }
|
2850 2608 | }
|
2851 2609 |
|
2852 - | /// When a integer member does not fit within range bounds,
|
2610 + | /// When a map member does not fit within length bounds,
|
2853 2611 | /// the response should be a 400 ValidationException.
|
2854 - | /// Test ID: RestJsonMalformedRangeMaxIntegerOverride
|
2612 + | /// Test ID: RestJsonMalformedLengthMapOverride_case1
|
2855 2613 | #[::tokio::test]
|
2856 2614 | #[::tracing_test::traced_test]
|
2857 - | async fn rest_json_malformed_range_max_integer_override_malformed_request() {
|
2615 + | async fn rest_json_malformed_length_map_override_case1_malformed_request() {
|
2858 2616 | {
|
2859 2617 | #[allow(unused_mut)]
|
2860 2618 | let mut http_request = ::http_1x::Request::builder()
|
2861 - | .uri("/MalformedRangeOverride")
|
2619 + | .uri("/MalformedLengthOverride")
|
2862 2620 | .method("POST")
|
2863 2621 | .header("content-type", "application/json")
|
2864 - | .body(::aws_smithy_http_server::body::boxed(
|
2865 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2866 - | &::aws_smithy_protocol_test::decode_body_data(
|
2867 - | "{ \"maxInteger\" : 7 }".as_bytes(),
|
2868 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2869 - | ),
|
2870 - | )),
|
2871 - | ))
|
2872 - | .unwrap();
|
2622 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
2623 + | ::bytes::Bytes::copy_from_slice(
|
2624 + | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"],\n \"efg\": [\"abc\", \"def\", \"efg\"], \"fgh\": [\"abc\", \"def\", \"efg\"],\n \"ghi\": [\"abc\", \"def\", \"efg\"] } }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
2625 + | )
|
2626 + | ))).unwrap();
|
2873 2627 | #[allow(unused_mut)]
|
2874 2628 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2875 2629 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2876 2630 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2877 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2631 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2878 2632 | let sender = sender.clone();
|
2879 2633 | async move {
|
2880 - | 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> };
|
2634 + | 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> };
|
2881 2635 | sender.send(()).await.expect("receiver dropped early");
|
2882 2636 | result
|
2883 2637 | }
|
2884 2638 | })
|
2885 2639 | .build_unchecked();
|
2886 2640 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2887 2641 | .await
|
2888 2642 | .expect("unable to make an HTTP request");
|
2889 2643 | ::pretty_assertions::assert_eq!(
|
2890 2644 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2891 2645 | http_response.status()
|
2892 2646 | );
|
2893 2647 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2894 2648 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2895 2649 | http_response.headers(),
|
2896 2650 | expected_headers,
|
2897 2651 | ));
|
2898 2652 | use ::http_body_util::BodyExt;
|
2899 2653 | let body = http_response
|
2900 2654 | .into_body()
|
2901 2655 | .collect()
|
2902 2656 | .await
|
2903 2657 | .expect("unable to collect body")
|
2904 2658 | .to_bytes();
|
2905 2659 | ::aws_smithy_protocol_test::assert_ok(
|
2906 - | ::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"))
|
2660 + | ::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"))
|
2907 2661 | );
|
2908 2662 | }
|
2909 2663 | }
|
2664 + | }
|
2910 2665 |
|
2911 - | /// When a long member does not fit within range bounds,
|
2912 - | /// the response should be a 400 ValidationException.
|
2913 - | /// Test ID: RestJsonMalformedRangeLongOverride_case0
|
2914 - | #[::tokio::test]
|
2915 - | #[::tracing_test::traced_test]
|
2916 - | async fn rest_json_malformed_range_long_override_case0_malformed_request() {
|
2917 - | {
|
2918 - | #[allow(unused_mut)]
|
2919 - | let mut http_request = ::http_1x::Request::builder()
|
2920 - | .uri("/MalformedRangeOverride")
|
2921 - | .method("POST")
|
2922 - | .header("content-type", "application/json")
|
2923 - | .body(::aws_smithy_http_server::body::boxed(
|
2924 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2925 - | &::aws_smithy_protocol_test::decode_body_data(
|
2926 - | "{ \"long\" : 3 }".as_bytes(),
|
2927 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2928 - | ),
|
2929 - | )),
|
2930 - | ))
|
2931 - | .unwrap();
|
2932 - | #[allow(unused_mut)]
|
2933 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2934 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2935 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2936 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2937 - | let sender = sender.clone();
|
2938 - | async move {
|
2939 - | 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> };
|
2940 - | sender.send(()).await.expect("receiver dropped early");
|
2941 - | result
|
2666 + | ::pin_project_lite::pin_project! {
|
2667 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
2668 + | /// [`MalformedLengthQueryStringInput`](crate::input::MalformedLengthQueryStringInput) using modelled bindings.
|
2669 + | pub struct MalformedLengthQueryStringInputFuture {
|
2670 + | 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>>
|
2942 2671 | }
|
2943 - | })
|
2944 - | .build_unchecked();
|
2945 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2946 - | .await
|
2947 - | .expect("unable to make an HTTP request");
|
2948 - | ::pretty_assertions::assert_eq!(
|
2949 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2950 - | http_response.status()
|
2951 - | );
|
2952 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2953 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2954 - | http_response.headers(),
|
2955 - | expected_headers,
|
2956 - | ));
|
2957 - | use ::http_body_util::BodyExt;
|
2958 - | let body = http_response
|
2959 - | .into_body()
|
2960 - | .collect()
|
2672 + | }
|
2673 + |
|
2674 + | impl std::future::Future for MalformedLengthQueryStringInputFuture {
|
2675 + | type Output = Result<
|
2676 + | crate::input::MalformedLengthQueryStringInput,
|
2677 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
2678 + | >;
|
2679 + |
|
2680 + | fn poll(
|
2681 + | self: std::pin::Pin<&mut Self>,
|
2682 + | cx: &mut std::task::Context<'_>,
|
2683 + | ) -> std::task::Poll<Self::Output> {
|
2684 + | let this = self.project();
|
2685 + | this.inner.as_mut().poll(cx)
|
2686 + | }
|
2687 + | }
|
2688 + |
|
2689 + | impl<B>
|
2690 + | ::aws_smithy_http_server::request::FromRequest<
|
2691 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2692 + | B,
|
2693 + | > for crate::input::MalformedLengthQueryStringInput
|
2694 + | where
|
2695 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
2696 + | B: 'static,
|
2697 + |
|
2698 + | B::Data: Send,
|
2699 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
2700 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
2701 + | {
|
2702 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
2703 + | type Future = MalformedLengthQueryStringInputFuture;
|
2704 + |
|
2705 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
2706 + | let fut = async move {
|
2707 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
2708 + | request.headers(),
|
2709 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
2710 + | ) {
|
2711 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
2712 + | }
|
2713 + | crate::protocol_serde::shape_malformed_length_query_string::de_malformed_length_query_string_http_request(request)
|
2961 2714 | .await
|
2962 - | .expect("unable to collect body")
|
2963 - | .to_bytes();
|
2964 - | ::aws_smithy_protocol_test::assert_ok(
|
2965 - | ::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"))
|
2715 + | };
|
2716 + | use ::futures_util::future::TryFutureExt;
|
2717 + | let fut = fut.map_err(
|
2718 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
2719 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2720 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
2721 + | e,
|
2722 + | )
|
2723 + | },
|
2966 2724 | );
|
2725 + | MalformedLengthQueryStringInputFuture {
|
2726 + | inner: Box::pin(fut),
|
2727 + | }
|
2728 + | }
|
2729 + | }
|
2730 + | impl
|
2731 + | ::aws_smithy_http_server::response::IntoResponse<
|
2732 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2733 + | > for crate::output::MalformedLengthQueryStringOutput
|
2734 + | {
|
2735 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2736 + | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_response(self) {
|
2737 + | Ok(response) => response,
|
2738 + | Err(e) => {
|
2739 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2740 + | ::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))
|
2741 + | }
|
2742 + | }
|
2743 + | }
|
2744 + | }
|
2745 + | impl
|
2746 + | ::aws_smithy_http_server::response::IntoResponse<
|
2747 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2748 + | > for crate::error::MalformedLengthQueryStringError
|
2749 + | {
|
2750 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2751 + | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_error(&self) {
|
2752 + | Ok(mut response) => {
|
2753 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
2754 + | response
|
2755 + | },
|
2756 + | Err(e) => {
|
2757 + | ::tracing::error!(error = %e, "failed to serialize response");
|
2758 + | ::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))
|
2967 2759 | }
|
2968 2760 | }
|
2761 + | }
|
2762 + | }
|
2969 2763 |
|
2970 - | /// When a long member does not fit within range bounds,
|
2764 + | #[allow(unreachable_code, unused_variables)]
|
2765 + | #[cfg(test)]
|
2766 + | mod malformed_length_query_string_test {
|
2767 + |
|
2768 + | /// When a required member has no value in the query string,
|
2971 2769 | /// the response should be a 400 ValidationException.
|
2972 - | /// Test ID: RestJsonMalformedRangeLongOverride_case1
|
2770 + | /// Test ID: RestJsonMalformedLengthQueryStringNoValue
|
2973 2771 | #[::tokio::test]
|
2974 2772 | #[::tracing_test::traced_test]
|
2975 - | async fn rest_json_malformed_range_long_override_case1_malformed_request() {
|
2773 + | async fn rest_json_malformed_length_query_string_no_value_malformed_request() {
|
2976 2774 | {
|
2977 2775 | #[allow(unused_mut)]
|
2978 2776 | let mut http_request = ::http_1x::Request::builder()
|
2979 - | .uri("/MalformedRangeOverride")
|
2777 + | .uri("/MalformedLengthQueryString")
|
2980 2778 | .method("POST")
|
2981 - | .header("content-type", "application/json")
|
2982 2779 | .body(::aws_smithy_http_server::body::boxed(
|
2983 2780 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2984 2781 | &::aws_smithy_protocol_test::decode_body_data(
|
2985 - | "{ \"long\" : 7 }".as_bytes(),
|
2782 + | "{}".as_bytes(),
|
2986 2783 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2987 2784 | ),
|
2988 2785 | )),
|
2989 2786 | ))
|
2990 2787 | .unwrap();
|
2788 + | *http_request.uri_mut() = "/MalformedLengthQueryString?string".parse().unwrap();
|
2991 2789 | #[allow(unused_mut)]
|
2992 2790 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2993 2791 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2994 2792 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2995 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2793 + | .malformed_length_query_string(move |input: crate::input::MalformedLengthQueryStringInput| {
|
2996 2794 | let sender = sender.clone();
|
2997 2795 | async move {
|
2998 - | 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> };
|
2796 + | 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> };
|
2999 2797 | sender.send(()).await.expect("receiver dropped early");
|
3000 2798 | result
|
3001 2799 | }
|
3002 2800 | })
|
3003 2801 | .build_unchecked();
|
3004 2802 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3005 2803 | .await
|
3006 2804 | .expect("unable to make an HTTP request");
|
3007 2805 | ::pretty_assertions::assert_eq!(
|
3008 2806 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3009 2807 | http_response.status()
|
3010 2808 | );
|
3011 2809 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3012 2810 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3013 2811 | http_response.headers(),
|
3014 2812 | expected_headers,
|
3015 2813 | ));
|
3016 2814 | use ::http_body_util::BodyExt;
|
3017 2815 | let body = http_response
|
3018 2816 | .into_body()
|
3019 2817 | .collect()
|
3020 2818 | .await
|
3021 2819 | .expect("unable to collect body")
|
3022 2820 | .to_bytes();
|
3023 2821 | ::aws_smithy_protocol_test::assert_ok(
|
3024 - | ::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"))
|
2822 + | ::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"))
|
3025 2823 | );
|
3026 2824 | }
|
3027 2825 | }
|
3028 - |
|
3029 - | /// When a long member does not fit within range bounds,
|
3030 - | /// the response should be a 400 ValidationException.
|
3031 - | /// Test ID: RestJsonMalformedRangeMinLongOverride
|
3032 - | #[::tokio::test]
|
3033 - | #[::tracing_test::traced_test]
|
3034 - | async fn rest_json_malformed_range_min_long_override_malformed_request() {
|
3035 - | {
|
3036 - | #[allow(unused_mut)]
|
3037 - | let mut http_request = ::http_1x::Request::builder()
|
3038 - | .uri("/MalformedRangeOverride")
|
3039 - | .method("POST")
|
3040 - | .header("content-type", "application/json")
|
3041 - | .body(::aws_smithy_http_server::body::boxed(
|
3042 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3043 - | &::aws_smithy_protocol_test::decode_body_data(
|
3044 - | "{ \"minLong\" : 3 }".as_bytes(),
|
3045 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3046 - | ),
|
3047 - | )),
|
3048 - | ))
|
3049 - | .unwrap();
|
3050 - | #[allow(unused_mut)]
|
3051 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3052 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3053 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3054 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
3055 - | let sender = sender.clone();
|
3056 - | async move {
|
3057 - | 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> };
|
3058 - | sender.send(()).await.expect("receiver dropped early");
|
3059 - | result
|
3060 - | }
|
3061 - | })
|
3062 - | .build_unchecked();
|
3063 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3064 - | .await
|
3065 - | .expect("unable to make an HTTP request");
|
3066 - | ::pretty_assertions::assert_eq!(
|
3067 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3068 - | http_response.status()
|
3069 - | );
|
3070 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3071 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3072 - | http_response.headers(),
|
3073 - | expected_headers,
|
3074 - | ));
|
3075 - | use ::http_body_util::BodyExt;
|
3076 - | let body = http_response
|
3077 - | .into_body()
|
3078 - | .collect()
|
3079 - | .await
|
3080 - | .expect("unable to collect body")
|
3081 - | .to_bytes();
|
3082 - | ::aws_smithy_protocol_test::assert_ok(
|
3083 - | ::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"))
|
3084 - | );
|
3085 - | }
|
3086 - | }
|
3087 - |
|
3088 - | /// When a long member does not fit within range bounds,
|
3089 - | /// the response should be a 400 ValidationException.
|
3090 - | /// Test ID: RestJsonMalformedRangeMaxLongOverride
|
3091 - | #[::tokio::test]
|
3092 - | #[::tracing_test::traced_test]
|
3093 - | async fn rest_json_malformed_range_max_long_override_malformed_request() {
|
3094 - | {
|
3095 - | #[allow(unused_mut)]
|
3096 - | let mut http_request = ::http_1x::Request::builder()
|
3097 - | .uri("/MalformedRangeOverride")
|
3098 - | .method("POST")
|
3099 - | .header("content-type", "application/json")
|
3100 - | .body(::aws_smithy_http_server::body::boxed(
|
3101 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3102 - | &::aws_smithy_protocol_test::decode_body_data(
|
3103 - | "{ \"maxLong\" : 7 }".as_bytes(),
|
3104 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3105 - | ),
|
3106 - | )),
|
3107 - | ))
|
3108 - | .unwrap();
|
3109 - | #[allow(unused_mut)]
|
3110 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3111 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3112 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3113 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
3114 - | let sender = sender.clone();
|
3115 - | async move {
|
3116 - | 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> };
|
3117 - | sender.send(()).await.expect("receiver dropped early");
|
3118 - | result
|
3119 - | }
|
3120 - | })
|
3121 - | .build_unchecked();
|
3122 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3123 - | .await
|
3124 - | .expect("unable to make an HTTP request");
|
3125 - | ::pretty_assertions::assert_eq!(
|
3126 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3127 - | http_response.status()
|
3128 - | );
|
3129 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3130 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3131 - | http_response.headers(),
|
3132 - | expected_headers,
|
3133 - | ));
|
3134 - | use ::http_body_util::BodyExt;
|
3135 - | let body = http_response
|
3136 - | .into_body()
|
3137 - | .collect()
|
3138 - | .await
|
3139 - | .expect("unable to collect body")
|
3140 - | .to_bytes();
|
3141 - | ::aws_smithy_protocol_test::assert_ok(
|
3142 - | ::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"))
|
3143 - | );
|
3144 - | }
|
3145 - | }
|
3146 - | }
|
2826 + | }
|
3147 2827 |
|
3148 2828 | ::pin_project_lite::pin_project! {
|
3149 2829 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3150 - | /// [`MalformedRangeInput`](crate::input::MalformedRangeInput) using modelled bindings.
|
3151 - | pub struct MalformedRangeInputFuture {
|
3152 - | 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>>
|
2830 + | /// [`MalformedPatternInput`](crate::input::MalformedPatternInput) using modelled bindings.
|
2831 + | pub struct MalformedPatternInputFuture {
|
2832 + | 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>>
|
3153 2833 | }
|
3154 2834 | }
|
3155 2835 |
|
3156 - | impl std::future::Future for MalformedRangeInputFuture {
|
2836 + | impl std::future::Future for MalformedPatternInputFuture {
|
3157 2837 | type Output = Result<
|
3158 - | crate::input::MalformedRangeInput,
|
2838 + | crate::input::MalformedPatternInput,
|
3159 2839 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
3160 2840 | >;
|
3161 2841 |
|
3162 2842 | fn poll(
|
3163 2843 | self: std::pin::Pin<&mut Self>,
|
3164 2844 | cx: &mut std::task::Context<'_>,
|
3165 2845 | ) -> std::task::Poll<Self::Output> {
|
3166 2846 | let this = self.project();
|
3167 2847 | this.inner.as_mut().poll(cx)
|
3168 2848 | }
|
3169 2849 | }
|
3170 2850 |
|
3171 2851 | impl<B>
|
3172 2852 | ::aws_smithy_http_server::request::FromRequest<
|
3173 2853 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3174 2854 | B,
|
3175 - | > for crate::input::MalformedRangeInput
|
2855 + | > for crate::input::MalformedPatternInput
|
3176 2856 | where
|
3177 2857 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
3178 2858 | B: 'static,
|
3179 2859 |
|
3180 2860 | B::Data: Send,
|
3181 2861 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
3182 2862 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
3183 2863 | {
|
3184 2864 | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
3185 - | type Future = MalformedRangeInputFuture;
|
2865 + | type Future = MalformedPatternInputFuture;
|
3186 2866 |
|
3187 2867 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
3188 2868 | let fut = async move {
|
3189 2869 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
3190 2870 | request.headers(),
|
3191 2871 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
3192 2872 | ) {
|
3193 2873 | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
3194 2874 | }
|
3195 - | crate::protocol_serde::shape_malformed_range::de_malformed_range_http_request(request)
|
2875 + | crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern_http_request(
|
2876 + | request,
|
2877 + | )
|
3196 2878 | .await
|
3197 2879 | };
|
3198 2880 | use ::futures_util::future::TryFutureExt;
|
3199 2881 | let fut = fut.map_err(
|
3200 2882 | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
3201 2883 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3202 2884 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
3203 2885 | e,
|
3204 2886 | )
|
3205 2887 | },
|
3206 2888 | );
|
3207 - | MalformedRangeInputFuture {
|
2889 + | MalformedPatternInputFuture {
|
3208 2890 | inner: Box::pin(fut),
|
3209 2891 | }
|
3210 2892 | }
|
3211 2893 | }
|
3212 2894 | impl
|
3213 2895 | ::aws_smithy_http_server::response::IntoResponse<
|
3214 2896 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3215 - | > for crate::output::MalformedRangeOutput
|
2897 + | > for crate::output::MalformedPatternOutput
|
3216 2898 | {
|
3217 2899 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3218 - | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_response(self)
|
3219 - | {
|
2900 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_response(
|
2901 + | self,
|
2902 + | ) {
|
3220 2903 | Ok(response) => response,
|
3221 2904 | Err(e) => {
|
3222 2905 | ::tracing::error!(error = %e, "failed to serialize response");
|
3223 2906 | ::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))
|
3224 2907 | }
|
3225 2908 | }
|
3226 2909 | }
|
3227 2910 | }
|
3228 2911 | impl
|
3229 2912 | ::aws_smithy_http_server::response::IntoResponse<
|
3230 2913 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3231 - | > for crate::error::MalformedRangeError
|
2914 + | > for crate::error::MalformedPatternError
|
3232 2915 | {
|
3233 2916 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3234 - | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_error(&self) {
|
2917 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_error(
|
2918 + | &self,
|
2919 + | ) {
|
3235 2920 | Ok(mut response) => {
|
3236 2921 | response.extensions_mut().insert(
|
3237 2922 | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
3238 2923 | );
|
3239 2924 | response
|
3240 2925 | }
|
3241 2926 | Err(e) => {
|
3242 2927 | ::tracing::error!(error = %e, "failed to serialize response");
|
3243 2928 | ::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))
|
3244 2929 | }
|
3245 2930 | }
|
3246 2931 | }
|
3247 2932 | }
|
3248 2933 |
|
3249 2934 | #[allow(unreachable_code, unused_variables)]
|
3250 2935 | #[cfg(test)]
|
3251 - | mod malformed_range_test {
|
2936 + | mod malformed_pattern_test {
|
3252 2937 |
|
3253 - | /// When a byte member does not fit within range bounds,
|
2938 + | /// When a string member does not match the specified pattern,
|
3254 2939 | /// the response should be a 400 ValidationException.
|
3255 - | /// Test ID: RestJsonMalformedRangeByte_case0
|
2940 + | /// Test ID: RestJsonMalformedPatternString_case0
|
3256 2941 | #[::tokio::test]
|
3257 2942 | #[::tracing_test::traced_test]
|
3258 - | async fn rest_json_malformed_range_byte_case0_malformed_request() {
|
2943 + | async fn rest_json_malformed_pattern_string_case0_malformed_request() {
|
3259 2944 | {
|
3260 2945 | #[allow(unused_mut)]
|
3261 2946 | let mut http_request = ::http_1x::Request::builder()
|
3262 - | .uri("/MalformedRange")
|
2947 + | .uri("/MalformedPattern")
|
3263 2948 | .method("POST")
|
3264 2949 | .header("content-type", "application/json")
|
3265 2950 | .body(::aws_smithy_http_server::body::boxed(
|
3266 2951 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3267 2952 | &::aws_smithy_protocol_test::decode_body_data(
|
3268 - | "{ \"byte\" : 1 }".as_bytes(),
|
2953 + | "{ \"string\" : \"ABC\" }".as_bytes(),
|
3269 2954 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3270 2955 | ),
|
3271 2956 | )),
|
3272 2957 | ))
|
3273 2958 | .unwrap();
|
3274 2959 | #[allow(unused_mut)]
|
3275 2960 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3276 2961 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3277 2962 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3278 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
2963 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3279 2964 | let sender = sender.clone();
|
3280 2965 | async move {
|
3281 - | 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> };
|
2966 + | 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> };
|
3282 2967 | sender.send(()).await.expect("receiver dropped early");
|
3283 2968 | result
|
3284 2969 | }
|
3285 2970 | })
|
3286 2971 | .build_unchecked();
|
3287 2972 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3288 2973 | .await
|
3289 2974 | .expect("unable to make an HTTP request");
|
3290 2975 | ::pretty_assertions::assert_eq!(
|
3291 2976 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3292 2977 | http_response.status()
|
3293 2978 | );
|
3294 2979 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3295 2980 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3296 2981 | http_response.headers(),
|
3297 2982 | expected_headers,
|
3298 2983 | ));
|
3299 2984 | use ::http_body_util::BodyExt;
|
3300 2985 | let body = http_response
|
3301 2986 | .into_body()
|
3302 2987 | .collect()
|
3303 2988 | .await
|
3304 2989 | .expect("unable to collect body")
|
3305 2990 | .to_bytes();
|
3306 2991 | ::aws_smithy_protocol_test::assert_ok(
|
3307 - | ::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"))
|
2992 + | ::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"))
|
3308 2993 | );
|
3309 2994 | }
|
3310 2995 | }
|
3311 2996 |
|
3312 - | /// When a byte member does not fit within range bounds,
|
2997 + | /// When a string member does not match the specified pattern,
|
3313 2998 | /// the response should be a 400 ValidationException.
|
3314 - | /// Test ID: RestJsonMalformedRangeByte_case1
|
2999 + | /// Test ID: RestJsonMalformedPatternString_case1
|
3315 3000 | #[::tokio::test]
|
3316 3001 | #[::tracing_test::traced_test]
|
3317 - | async fn rest_json_malformed_range_byte_case1_malformed_request() {
|
3002 + | async fn rest_json_malformed_pattern_string_case1_malformed_request() {
|
3318 3003 | {
|
3319 3004 | #[allow(unused_mut)]
|
3320 3005 | let mut http_request = ::http_1x::Request::builder()
|
3321 - | .uri("/MalformedRange")
|
3006 + | .uri("/MalformedPattern")
|
3322 3007 | .method("POST")
|
3323 3008 | .header("content-type", "application/json")
|
3324 3009 | .body(::aws_smithy_http_server::body::boxed(
|
3325 3010 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3326 3011 | &::aws_smithy_protocol_test::decode_body_data(
|
3327 - | "{ \"byte\" : 9 }".as_bytes(),
|
3012 + | "{ \"string\" : \"xyz\" }".as_bytes(),
|
3328 3013 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3329 3014 | ),
|
3330 3015 | )),
|
3331 3016 | ))
|
3332 3017 | .unwrap();
|
3333 3018 | #[allow(unused_mut)]
|
3334 3019 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3335 3020 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3336 3021 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3337 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3022 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3338 3023 | let sender = sender.clone();
|
3339 3024 | async move {
|
3340 - | 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> };
|
3025 + | 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> };
|
3341 3026 | sender.send(()).await.expect("receiver dropped early");
|
3342 3027 | result
|
3343 3028 | }
|
3344 3029 | })
|
3345 3030 | .build_unchecked();
|
3346 3031 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3347 3032 | .await
|
3348 3033 | .expect("unable to make an HTTP request");
|
3349 3034 | ::pretty_assertions::assert_eq!(
|
3350 3035 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3351 3036 | http_response.status()
|
3352 3037 | );
|
3353 3038 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3354 3039 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3355 3040 | http_response.headers(),
|
3356 3041 | expected_headers,
|
3357 3042 | ));
|
3358 3043 | use ::http_body_util::BodyExt;
|
3359 3044 | let body = http_response
|
3360 3045 | .into_body()
|
3361 3046 | .collect()
|
3362 3047 | .await
|
3363 3048 | .expect("unable to collect body")
|
3364 3049 | .to_bytes();
|
3365 3050 | ::aws_smithy_protocol_test::assert_ok(
|
3366 - | ::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"))
|
3051 + | ::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"))
|
3367 3052 | );
|
3368 3053 | }
|
3369 3054 | }
|
3370 3055 |
|
3371 - | /// When a byte member does not fit within range bounds,
|
3372 - | /// the response should be a 400 ValidationException.
|
3373 - | /// Test ID: RestJsonMalformedRangeMinByte
|
3056 + | /// When the specified pattern is susceptible to ReDOS, the service will not
|
3057 + | /// hang indefinitely while evaluating the pattern
|
3058 + | /// Test ID: RestJsonMalformedPatternReDOSString
|
3374 3059 | #[::tokio::test]
|
3375 3060 | #[::tracing_test::traced_test]
|
3376 - | async fn rest_json_malformed_range_min_byte_malformed_request() {
|
3061 + | #[should_panic]
|
3062 + | async fn rest_json_malformed_pattern_re_dos_string_malformed_request() {
|
3377 3063 | {
|
3378 3064 | #[allow(unused_mut)]
|
3379 3065 | let mut http_request = ::http_1x::Request::builder()
|
3380 - | .uri("/MalformedRange")
|
3066 + | .uri("/MalformedPattern")
|
3381 3067 | .method("POST")
|
3382 3068 | .header("content-type", "application/json")
|
3383 - | .body(::aws_smithy_http_server::body::boxed(
|
3384 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3385 - | &::aws_smithy_protocol_test::decode_body_data(
|
3386 - | "{ \"minByte\" : 1 }".as_bytes(),
|
3387 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3388 - | ),
|
3389 - | )),
|
3390 - | ))
|
3391 - | .unwrap();
|
3069 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
3070 + | ::bytes::Bytes::copy_from_slice(
|
3071 + | &::aws_smithy_protocol_test::decode_body_data("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
3072 + | )
|
3073 + | ))).unwrap();
|
3392 3074 | #[allow(unused_mut)]
|
3393 3075 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3394 3076 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3395 3077 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3396 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3078 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3397 3079 | let sender = sender.clone();
|
3398 3080 | async move {
|
3399 - | 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> };
|
3081 + | 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> };
|
3400 3082 | sender.send(()).await.expect("receiver dropped early");
|
3401 3083 | result
|
3402 3084 | }
|
3403 3085 | })
|
3404 3086 | .build_unchecked();
|
3405 3087 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3406 3088 | .await
|
3407 3089 | .expect("unable to make an HTTP request");
|
3408 3090 | ::pretty_assertions::assert_eq!(
|
3409 3091 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3410 3092 | http_response.status()
|
3411 3093 | );
|
3412 3094 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3413 3095 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3414 3096 | http_response.headers(),
|
3415 3097 | expected_headers,
|
3416 3098 | ));
|
3417 3099 | use ::http_body_util::BodyExt;
|
3418 3100 | let body = http_response
|
3419 3101 | .into_body()
|
3420 3102 | .collect()
|
3421 3103 | .await
|
3422 3104 | .expect("unable to collect body")
|
3423 3105 | .to_bytes();
|
3424 3106 | ::aws_smithy_protocol_test::assert_ok(
|
3425 - | ::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"))
|
3107 + | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$$\",\n \"fieldList\" : [{\"message\": \"Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$$\", \"path\": \"/evilString\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
3426 3108 | );
|
3427 3109 | }
|
3428 3110 | }
|
3429 3111 |
|
3430 - | /// When a byte member does not fit within range bounds,
|
3431 - | /// the response should be a 400 ValidationException.
|
3432 - | /// Test ID: RestJsonMalformedRangeMaxByte
|
3112 + | /// When the specified pattern is susceptible to ReDOS, the service will not
|
3113 + | /// hang indefinitely while evaluating the pattern
|
3114 + | /// Test ID: RestJsonMalformedPatternReDOSString_hotfixed
|
3433 3115 | #[::tokio::test]
|
3434 3116 | #[::tracing_test::traced_test]
|
3435 - | async fn rest_json_malformed_range_max_byte_malformed_request() {
|
3117 + | async fn rest_json_malformed_pattern_re_dos_string_hotfixed_malformed_request() {
|
3436 3118 | {
|
3437 3119 | #[allow(unused_mut)]
|
3438 3120 | let mut http_request = ::http_1x::Request::builder()
|
3439 - | .uri("/MalformedRange")
|
3121 + | .uri("/MalformedPattern")
|
3440 3122 | .method("POST")
|
3441 3123 | .header("content-type", "application/json")
|
3442 - | .body(::aws_smithy_http_server::body::boxed(
|
3443 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3444 - | &::aws_smithy_protocol_test::decode_body_data(
|
3445 - | "{ \"maxByte\" : 9 }".as_bytes(),
|
3446 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3447 - | ),
|
3448 - | )),
|
3449 - | ))
|
3450 - | .unwrap();
|
3124 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
3125 + | ::bytes::Bytes::copy_from_slice(
|
3126 + | &::aws_smithy_protocol_test::decode_body_data("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
3127 + | )
|
3128 + | ))).unwrap();
|
3451 3129 | #[allow(unused_mut)]
|
3452 3130 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3453 3131 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3454 3132 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3455 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3133 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3456 3134 | let sender = sender.clone();
|
3457 3135 | async move {
|
3458 - | 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> };
|
3136 + | 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> };
|
3459 3137 | sender.send(()).await.expect("receiver dropped early");
|
3460 3138 | result
|
3461 3139 | }
|
3462 3140 | })
|
3463 3141 | .build_unchecked();
|
3464 3142 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3465 3143 | .await
|
3466 3144 | .expect("unable to make an HTTP request");
|
3467 3145 | ::pretty_assertions::assert_eq!(
|
3468 3146 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3469 3147 | http_response.status()
|
3470 3148 | );
|
3471 3149 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3472 3150 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3473 3151 | http_response.headers(),
|
3474 3152 | expected_headers,
|
3475 3153 | ));
|
3476 3154 | use ::http_body_util::BodyExt;
|
3477 3155 | let body = http_response
|
3478 3156 | .into_body()
|
3479 3157 | .collect()
|
3480 3158 | .await
|
3481 3159 | .expect("unable to collect body")
|
3482 3160 | .to_bytes();
|
3483 3161 | ::aws_smithy_protocol_test::assert_ok(
|
3484 - | ::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"))
|
3162 + | ::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"))
|
3485 3163 | );
|
3486 3164 | }
|
3487 3165 | }
|
3488 3166 |
|
3489 - | /// When a float member does not fit within range bounds,
|
3167 + | /// When a list member value does not match the specified pattern,
|
3490 3168 | /// the response should be a 400 ValidationException.
|
3491 - | /// Test ID: RestJsonMalformedRangeFloat_case0
|
3169 + | /// Test ID: RestJsonMalformedPatternList_case0
|
3492 3170 | #[::tokio::test]
|
3493 3171 | #[::tracing_test::traced_test]
|
3494 - | #[should_panic]
|
3495 - | async fn rest_json_malformed_range_float_case0_malformed_request() {
|
3172 + | async fn rest_json_malformed_pattern_list_case0_malformed_request() {
|
3496 3173 | {
|
3497 3174 | #[allow(unused_mut)]
|
3498 3175 | let mut http_request = ::http_1x::Request::builder()
|
3499 - | .uri("/MalformedRange")
|
3176 + | .uri("/MalformedPattern")
|
3500 3177 | .method("POST")
|
3501 3178 | .header("content-type", "application/json")
|
3502 3179 | .body(::aws_smithy_http_server::body::boxed(
|
3503 3180 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3504 3181 | &::aws_smithy_protocol_test::decode_body_data(
|
3505 - | "{ \"float\" : 2.1 }".as_bytes(),
|
3182 + | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
3506 3183 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3507 3184 | ),
|
3508 3185 | )),
|
3509 3186 | ))
|
3510 3187 | .unwrap();
|
3511 3188 | #[allow(unused_mut)]
|
3512 3189 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3513 3190 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3514 3191 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3515 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3192 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3516 3193 | let sender = sender.clone();
|
3517 3194 | async move {
|
3518 - | 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> };
|
3195 + | 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> };
|
3519 3196 | sender.send(()).await.expect("receiver dropped early");
|
3520 3197 | result
|
3521 3198 | }
|
3522 3199 | })
|
3523 3200 | .build_unchecked();
|
3524 3201 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3525 3202 | .await
|
3526 3203 | .expect("unable to make an HTTP request");
|
3527 3204 | ::pretty_assertions::assert_eq!(
|
3528 3205 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3529 3206 | http_response.status()
|
3530 3207 | );
|
3531 3208 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3532 3209 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3533 3210 | http_response.headers(),
|
3534 3211 | expected_headers,
|
3535 3212 | ));
|
3536 3213 | use ::http_body_util::BodyExt;
|
3537 3214 | let body = http_response
|
3538 3215 | .into_body()
|
3539 3216 | .collect()
|
3540 3217 | .await
|
3541 3218 | .expect("unable to collect body")
|
3542 3219 | .to_bytes();
|
3543 3220 | ::aws_smithy_protocol_test::assert_ok(
|
3544 - | ::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"))
|
3221 + | ::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"))
|
3545 3222 | );
|
3546 3223 | }
|
3547 3224 | }
|
3548 3225 |
|
3549 - | /// When a float member does not fit within range bounds,
|
3226 + | /// When a list member value does not match the specified pattern,
|
3550 3227 | /// the response should be a 400 ValidationException.
|
3551 - | /// Test ID: RestJsonMalformedRangeFloat_case1
|
3228 + | /// Test ID: RestJsonMalformedPatternList_case1
|
3552 3229 | #[::tokio::test]
|
3553 3230 | #[::tracing_test::traced_test]
|
3554 - | #[should_panic]
|
3555 - | async fn rest_json_malformed_range_float_case1_malformed_request() {
|
3231 + | async fn rest_json_malformed_pattern_list_case1_malformed_request() {
|
3556 3232 | {
|
3557 3233 | #[allow(unused_mut)]
|
3558 3234 | let mut http_request = ::http_1x::Request::builder()
|
3559 - | .uri("/MalformedRange")
|
3235 + | .uri("/MalformedPattern")
|
3560 3236 | .method("POST")
|
3561 3237 | .header("content-type", "application/json")
|
3562 3238 | .body(::aws_smithy_http_server::body::boxed(
|
3563 3239 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3564 3240 | &::aws_smithy_protocol_test::decode_body_data(
|
3565 - | "{ \"float\" : 8.9 }".as_bytes(),
|
3241 + | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
3566 3242 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3567 3243 | ),
|
3568 3244 | )),
|
3569 3245 | ))
|
3570 3246 | .unwrap();
|
3571 3247 | #[allow(unused_mut)]
|
3572 3248 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3573 3249 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3574 3250 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3575 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3251 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3576 3252 | let sender = sender.clone();
|
3577 3253 | 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> };
|
3254 + | 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> };
|
3579 3255 | sender.send(()).await.expect("receiver dropped early");
|
3580 3256 | result
|
3581 3257 | }
|
3582 3258 | })
|
3583 3259 | .build_unchecked();
|
3584 3260 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3585 3261 | .await
|
3586 3262 | .expect("unable to make an HTTP request");
|
3587 3263 | ::pretty_assertions::assert_eq!(
|
3588 3264 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3589 3265 | http_response.status()
|
3590 3266 | );
|
3591 3267 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3592 3268 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3593 3269 | http_response.headers(),
|
3594 3270 | expected_headers,
|
3595 3271 | ));
|
3596 3272 | use ::http_body_util::BodyExt;
|
3597 3273 | let body = http_response
|
3598 3274 | .into_body()
|
3599 3275 | .collect()
|
3600 3276 | .await
|
3601 3277 | .expect("unable to collect body")
|
3602 3278 | .to_bytes();
|
3603 3279 | ::aws_smithy_protocol_test::assert_ok(
|
3604 - | ::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"))
|
3280 + | ::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"))
|
3605 3281 | );
|
3606 3282 | }
|
3607 3283 | }
|
3608 3284 |
|
3609 - | /// When a float member does not fit within range bounds,
|
3285 + | /// When a map member's key does not match the specified pattern,
|
3610 3286 | /// the response should be a 400 ValidationException.
|
3611 - | /// Test ID: RestJsonMalformedRangeMinFloat
|
3287 + | /// Test ID: RestJsonMalformedPatternMapKey_case0
|
3612 3288 | #[::tokio::test]
|
3613 3289 | #[::tracing_test::traced_test]
|
3614 - | #[should_panic]
|
3615 - | async fn rest_json_malformed_range_min_float_malformed_request() {
|
3290 + | async fn rest_json_malformed_pattern_map_key_case0_malformed_request() {
|
3616 3291 | {
|
3617 3292 | #[allow(unused_mut)]
|
3618 3293 | let mut http_request = ::http_1x::Request::builder()
|
3619 - | .uri("/MalformedRange")
|
3294 + | .uri("/MalformedPattern")
|
3620 3295 | .method("POST")
|
3621 3296 | .header("content-type", "application/json")
|
3622 3297 | .body(::aws_smithy_http_server::body::boxed(
|
3623 3298 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3624 3299 | &::aws_smithy_protocol_test::decode_body_data(
|
3625 - | "{ \"minFloat\" : 2.1 }".as_bytes(),
|
3300 + | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
3626 3301 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3627 3302 | ),
|
3628 3303 | )),
|
3629 3304 | ))
|
3630 3305 | .unwrap();
|
3631 3306 | #[allow(unused_mut)]
|
3632 3307 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3633 3308 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3634 3309 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3635 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3310 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3636 3311 | let sender = sender.clone();
|
3637 3312 | async move {
|
3638 - | 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> };
|
3313 + | 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> };
|
3639 3314 | sender.send(()).await.expect("receiver dropped early");
|
3640 3315 | result
|
3641 3316 | }
|
3642 3317 | })
|
3643 3318 | .build_unchecked();
|
3644 3319 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3645 3320 | .await
|
3646 3321 | .expect("unable to make an HTTP request");
|
3647 3322 | ::pretty_assertions::assert_eq!(
|
3648 3323 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3649 3324 | http_response.status()
|
3650 3325 | );
|
3651 3326 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3652 3327 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3653 3328 | http_response.headers(),
|
3654 3329 | expected_headers,
|
3655 3330 | ));
|
3656 3331 | use ::http_body_util::BodyExt;
|
3657 3332 | let body = http_response
|
3658 3333 | .into_body()
|
3659 3334 | .collect()
|
3660 3335 | .await
|
3661 3336 | .expect("unable to collect body")
|
3662 3337 | .to_bytes();
|
3663 3338 | ::aws_smithy_protocol_test::assert_ok(
|
3664 - | ::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"))
|
3339 + | ::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"))
|
3665 3340 | );
|
3666 3341 | }
|
3667 3342 | }
|
3668 3343 |
|
3669 - | /// When a float member does not fit within range bounds,
|
3344 + | /// When a map member's key does not match the specified pattern,
|
3670 3345 | /// the response should be a 400 ValidationException.
|
3671 - | /// Test ID: RestJsonMalformedRangeMaxFloat
|
3346 + | /// Test ID: RestJsonMalformedPatternMapKey_case1
|
3672 3347 | #[::tokio::test]
|
3673 3348 | #[::tracing_test::traced_test]
|
3674 - | #[should_panic]
|
3675 - | async fn rest_json_malformed_range_max_float_malformed_request() {
|
3349 + | async fn rest_json_malformed_pattern_map_key_case1_malformed_request() {
|
3676 3350 | {
|
3677 3351 | #[allow(unused_mut)]
|
3678 3352 | let mut http_request = ::http_1x::Request::builder()
|
3679 - | .uri("/MalformedRange")
|
3353 + | .uri("/MalformedPattern")
|
3680 3354 | .method("POST")
|
3681 3355 | .header("content-type", "application/json")
|
3682 3356 | .body(::aws_smithy_http_server::body::boxed(
|
3683 3357 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3684 3358 | &::aws_smithy_protocol_test::decode_body_data(
|
3685 - | "{ \"maxFloat\" : 8.9 }".as_bytes(),
|
3359 + | "{ \"map\" : { \"xyz\" : \"abc\" } }".as_bytes(),
|
3686 3360 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3687 3361 | ),
|
3688 3362 | )),
|
3689 3363 | ))
|
3690 3364 | .unwrap();
|
3691 3365 | #[allow(unused_mut)]
|
3692 3366 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3693 3367 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3694 3368 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3695 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3369 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3696 3370 | let sender = sender.clone();
|
3697 3371 | async move {
|
3698 - | 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> };
|
3372 + | 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> };
|
3699 3373 | sender.send(()).await.expect("receiver dropped early");
|
3700 3374 | result
|
3701 3375 | }
|
3702 3376 | })
|
3703 3377 | .build_unchecked();
|
3704 3378 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3705 3379 | .await
|
3706 3380 | .expect("unable to make an HTTP request");
|
3707 3381 | ::pretty_assertions::assert_eq!(
|
3708 3382 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3709 3383 | http_response.status()
|
3710 3384 | );
|
3711 3385 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3712 3386 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3713 3387 | http_response.headers(),
|
3714 3388 | expected_headers,
|
3715 3389 | ));
|
3716 3390 | use ::http_body_util::BodyExt;
|
3717 3391 | let body = http_response
|
3718 3392 | .into_body()
|
3719 3393 | .collect()
|
3720 3394 | .await
|
3721 3395 | .expect("unable to collect body")
|
3722 3396 | .to_bytes();
|
3723 3397 | ::aws_smithy_protocol_test::assert_ok(
|
3724 - | ::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"))
|
3398 + | ::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"))
|
3725 3399 | );
|
3726 3400 | }
|
3727 3401 | }
|
3728 3402 |
|
3729 - | /// When a short member does not fit within range bounds,
|
3403 + | /// When a map member's value does not match the specified pattern,
|
3730 3404 | /// the response should be a 400 ValidationException.
|
3731 - | /// Test ID: RestJsonMalformedRangeShort_case0
|
3405 + | /// Test ID: RestJsonMalformedPatternMapValue_case0
|
3732 3406 | #[::tokio::test]
|
3733 3407 | #[::tracing_test::traced_test]
|
3734 - | async fn rest_json_malformed_range_short_case0_malformed_request() {
|
3408 + | async fn rest_json_malformed_pattern_map_value_case0_malformed_request() {
|
3735 3409 | {
|
3736 3410 | #[allow(unused_mut)]
|
3737 3411 | let mut http_request = ::http_1x::Request::builder()
|
3738 - | .uri("/MalformedRange")
|
3412 + | .uri("/MalformedPattern")
|
3739 3413 | .method("POST")
|
3740 3414 | .header("content-type", "application/json")
|
3741 3415 | .body(::aws_smithy_http_server::body::boxed(
|
3742 3416 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3743 3417 | &::aws_smithy_protocol_test::decode_body_data(
|
3744 - | "{ \"short\" : 1 }".as_bytes(),
|
3418 + | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
3745 3419 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3746 3420 | ),
|
3747 3421 | )),
|
3748 3422 | ))
|
3749 3423 | .unwrap();
|
3750 3424 | #[allow(unused_mut)]
|
3751 3425 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3752 3426 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3753 3427 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3754 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3428 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3755 3429 | let sender = sender.clone();
|
3756 3430 | async move {
|
3757 - | 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> };
|
3431 + | 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> };
|
3758 3432 | sender.send(()).await.expect("receiver dropped early");
|
3759 3433 | result
|
3760 3434 | }
|
3761 3435 | })
|
3762 3436 | .build_unchecked();
|
3763 3437 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3764 3438 | .await
|
3765 3439 | .expect("unable to make an HTTP request");
|
3766 3440 | ::pretty_assertions::assert_eq!(
|
3767 3441 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3768 3442 | http_response.status()
|
3769 3443 | );
|
3770 3444 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3771 3445 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3772 3446 | http_response.headers(),
|
3773 3447 | expected_headers,
|
3774 3448 | ));
|
3775 3449 | use ::http_body_util::BodyExt;
|
3776 3450 | let body = http_response
|
3777 3451 | .into_body()
|
3778 3452 | .collect()
|
3779 3453 | .await
|
3780 3454 | .expect("unable to collect body")
|
3781 3455 | .to_bytes();
|
3782 3456 | ::aws_smithy_protocol_test::assert_ok(
|
3783 - | ::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"))
|
3457 + | ::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"))
|
3784 3458 | );
|
3785 3459 | }
|
3786 3460 | }
|
3787 3461 |
|
3788 - | /// When a short member does not fit within range bounds,
|
3462 + | /// When a map member's value does not match the specified pattern,
|
3789 3463 | /// the response should be a 400 ValidationException.
|
3790 - | /// Test ID: RestJsonMalformedRangeShort_case1
|
3464 + | /// Test ID: RestJsonMalformedPatternMapValue_case1
|
3791 3465 | #[::tokio::test]
|
3792 3466 | #[::tracing_test::traced_test]
|
3793 - | async fn rest_json_malformed_range_short_case1_malformed_request() {
|
3467 + | async fn rest_json_malformed_pattern_map_value_case1_malformed_request() {
|
3794 3468 | {
|
3795 3469 | #[allow(unused_mut)]
|
3796 3470 | let mut http_request = ::http_1x::Request::builder()
|
3797 - | .uri("/MalformedRange")
|
3471 + | .uri("/MalformedPattern")
|
3798 3472 | .method("POST")
|
3799 3473 | .header("content-type", "application/json")
|
3800 3474 | .body(::aws_smithy_http_server::body::boxed(
|
3801 3475 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3802 3476 | &::aws_smithy_protocol_test::decode_body_data(
|
3803 - | "{ \"short\" : 9 }".as_bytes(),
|
3477 + | "{ \"map\" : { \"abc\": \"xyz\" } }".as_bytes(),
|
3804 3478 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3805 3479 | ),
|
3806 3480 | )),
|
3807 3481 | ))
|
3808 3482 | .unwrap();
|
3809 3483 | #[allow(unused_mut)]
|
3810 3484 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3811 3485 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3812 3486 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3813 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3487 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3814 3488 | let sender = sender.clone();
|
3815 3489 | async move {
|
3816 - | 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> };
|
3490 + | 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> };
|
3817 3491 | sender.send(()).await.expect("receiver dropped early");
|
3818 3492 | result
|
3819 3493 | }
|
3820 3494 | })
|
3821 3495 | .build_unchecked();
|
3822 3496 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3823 3497 | .await
|
3824 3498 | .expect("unable to make an HTTP request");
|
3825 3499 | ::pretty_assertions::assert_eq!(
|
3826 3500 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3827 3501 | http_response.status()
|
3828 3502 | );
|
3829 3503 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3830 3504 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3831 3505 | http_response.headers(),
|
3832 3506 | expected_headers,
|
3833 3507 | ));
|
3834 3508 | use ::http_body_util::BodyExt;
|
3835 3509 | let body = http_response
|
3836 3510 | .into_body()
|
3837 3511 | .collect()
|
3838 3512 | .await
|
3839 3513 | .expect("unable to collect body")
|
3840 3514 | .to_bytes();
|
3841 3515 | ::aws_smithy_protocol_test::assert_ok(
|
3842 - | ::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"))
|
3516 + | ::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"))
|
3843 3517 | );
|
3844 3518 | }
|
3845 3519 | }
|
3846 3520 |
|
3847 - | /// When a short member does not fit within range bounds,
|
3521 + | /// When a union member's value does not match the specified pattern,
|
3848 3522 | /// the response should be a 400 ValidationException.
|
3849 - | /// Test ID: RestJsonMalformedRangeMinShort
|
3523 + | /// Test ID: RestJsonMalformedPatternUnion_case0
|
3850 3524 | #[::tokio::test]
|
3851 3525 | #[::tracing_test::traced_test]
|
3852 - | async fn rest_json_malformed_range_min_short_malformed_request() {
|
3526 + | async fn rest_json_malformed_pattern_union_case0_malformed_request() {
|
3853 3527 | {
|
3854 3528 | #[allow(unused_mut)]
|
3855 3529 | let mut http_request = ::http_1x::Request::builder()
|
3856 - | .uri("/MalformedRange")
|
3530 + | .uri("/MalformedPattern")
|
3857 3531 | .method("POST")
|
3858 3532 | .header("content-type", "application/json")
|
3859 3533 | .body(::aws_smithy_http_server::body::boxed(
|
3860 3534 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3861 3535 | &::aws_smithy_protocol_test::decode_body_data(
|
3862 - | "{ \"minShort\" : 1 }".as_bytes(),
|
3536 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
3863 3537 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3864 3538 | ),
|
3865 3539 | )),
|
3866 3540 | ))
|
3867 3541 | .unwrap();
|
3868 3542 | #[allow(unused_mut)]
|
3869 3543 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3870 3544 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3871 3545 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3872 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3546 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3873 3547 | let sender = sender.clone();
|
3874 3548 | async move {
|
3875 - | 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> };
|
3549 + | 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> };
|
3876 3550 | sender.send(()).await.expect("receiver dropped early");
|
3877 3551 | result
|
3878 3552 | }
|
3879 3553 | })
|
3880 3554 | .build_unchecked();
|
3881 3555 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3882 3556 | .await
|
3883 3557 | .expect("unable to make an HTTP request");
|
3884 3558 | ::pretty_assertions::assert_eq!(
|
3885 3559 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3886 3560 | http_response.status()
|
3887 3561 | );
|
3888 3562 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3889 3563 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3890 3564 | http_response.headers(),
|
3891 3565 | expected_headers,
|
3892 3566 | ));
|
3893 3567 | use ::http_body_util::BodyExt;
|
3894 3568 | let body = http_response
|
3895 3569 | .into_body()
|
3896 3570 | .collect()
|
3897 3571 | .await
|
3898 3572 | .expect("unable to collect body")
|
3899 3573 | .to_bytes();
|
3900 3574 | ::aws_smithy_protocol_test::assert_ok(
|
3901 - | ::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"))
|
3575 + | ::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"))
|
3902 3576 | );
|
3903 3577 | }
|
3904 3578 | }
|
3905 3579 |
|
3906 - | /// When a short member does not fit within range bounds,
|
3580 + | /// When a union member's value does not match the specified pattern,
|
3907 3581 | /// the response should be a 400 ValidationException.
|
3908 - | /// Test ID: RestJsonMalformedRangeMaxShort
|
3582 + | /// Test ID: RestJsonMalformedPatternUnion_case1
|
3909 3583 | #[::tokio::test]
|
3910 3584 | #[::tracing_test::traced_test]
|
3911 - | async fn rest_json_malformed_range_max_short_malformed_request() {
|
3585 + | async fn rest_json_malformed_pattern_union_case1_malformed_request() {
|
3912 3586 | {
|
3913 3587 | #[allow(unused_mut)]
|
3914 3588 | let mut http_request = ::http_1x::Request::builder()
|
3915 - | .uri("/MalformedRange")
|
3589 + | .uri("/MalformedPattern")
|
3916 3590 | .method("POST")
|
3917 3591 | .header("content-type", "application/json")
|
3918 3592 | .body(::aws_smithy_http_server::body::boxed(
|
3919 3593 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3920 3594 | &::aws_smithy_protocol_test::decode_body_data(
|
3921 - | "{ \"maxShort\" : 9 }".as_bytes(),
|
3595 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
3922 3596 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3923 3597 | ),
|
3924 3598 | )),
|
3925 3599 | ))
|
3926 3600 | .unwrap();
|
3927 3601 | #[allow(unused_mut)]
|
3928 3602 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3929 3603 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3930 3604 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3931 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3605 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3932 3606 | let sender = sender.clone();
|
3933 3607 | async move {
|
3934 - | 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> };
|
3608 + | 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> };
|
3935 3609 | sender.send(()).await.expect("receiver dropped early");
|
3936 3610 | result
|
3937 3611 | }
|
3938 3612 | })
|
3939 3613 | .build_unchecked();
|
3940 3614 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3941 3615 | .await
|
3942 3616 | .expect("unable to make an HTTP request");
|
3943 3617 | ::pretty_assertions::assert_eq!(
|
3944 3618 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3945 3619 | http_response.status()
|
3946 3620 | );
|
3947 3621 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3948 3622 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3949 3623 | http_response.headers(),
|
3950 3624 | expected_headers,
|
3951 3625 | ));
|
3952 3626 | use ::http_body_util::BodyExt;
|
3953 3627 | let body = http_response
|
3954 3628 | .into_body()
|
3955 3629 | .collect()
|
3956 3630 | .await
|
3957 3631 | .expect("unable to collect body")
|
3958 3632 | .to_bytes();
|
3959 3633 | ::aws_smithy_protocol_test::assert_ok(
|
3960 - | ::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"))
|
3634 + | ::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"))
|
3961 3635 | );
|
3962 3636 | }
|
3963 3637 | }
|
3638 + | }
|
3964 3639 |
|
3965 - | /// When a integer member does not fit within range bounds,
|
3640 + | ::pin_project_lite::pin_project! {
|
3641 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
3642 + | /// [`MalformedPatternOverrideInput`](crate::input::MalformedPatternOverrideInput) using modelled bindings.
|
3643 + | pub struct MalformedPatternOverrideInputFuture {
|
3644 + | 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>>
|
3645 + | }
|
3646 + | }
|
3647 + |
|
3648 + | impl std::future::Future for MalformedPatternOverrideInputFuture {
|
3649 + | type Output = Result<
|
3650 + | crate::input::MalformedPatternOverrideInput,
|
3651 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
3652 + | >;
|
3653 + |
|
3654 + | fn poll(
|
3655 + | self: std::pin::Pin<&mut Self>,
|
3656 + | cx: &mut std::task::Context<'_>,
|
3657 + | ) -> std::task::Poll<Self::Output> {
|
3658 + | let this = self.project();
|
3659 + | this.inner.as_mut().poll(cx)
|
3660 + | }
|
3661 + | }
|
3662 + |
|
3663 + | impl<B>
|
3664 + | ::aws_smithy_http_server::request::FromRequest<
|
3665 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3666 + | B,
|
3667 + | > for crate::input::MalformedPatternOverrideInput
|
3668 + | where
|
3669 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
3670 + | B: 'static,
|
3671 + |
|
3672 + | B::Data: Send,
|
3673 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
3674 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
3675 + | {
|
3676 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
3677 + | type Future = MalformedPatternOverrideInputFuture;
|
3678 + |
|
3679 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
3680 + | let fut = async move {
|
3681 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
3682 + | request.headers(),
|
3683 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
3684 + | ) {
|
3685 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
3686 + | }
|
3687 + | crate::protocol_serde::shape_malformed_pattern_override::de_malformed_pattern_override_http_request(request)
|
3688 + | .await
|
3689 + | };
|
3690 + | use ::futures_util::future::TryFutureExt;
|
3691 + | let fut = fut.map_err(
|
3692 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
3693 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3694 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
3695 + | e,
|
3696 + | )
|
3697 + | },
|
3698 + | );
|
3699 + | MalformedPatternOverrideInputFuture {
|
3700 + | inner: Box::pin(fut),
|
3701 + | }
|
3702 + | }
|
3703 + | }
|
3704 + | impl
|
3705 + | ::aws_smithy_http_server::response::IntoResponse<
|
3706 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3707 + | > for crate::output::MalformedPatternOverrideOutput
|
3708 + | {
|
3709 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3710 + | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_response(self) {
|
3711 + | Ok(response) => response,
|
3712 + | Err(e) => {
|
3713 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3714 + | ::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))
|
3715 + | }
|
3716 + | }
|
3717 + | }
|
3718 + | }
|
3719 + | impl
|
3720 + | ::aws_smithy_http_server::response::IntoResponse<
|
3721 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3722 + | > for crate::error::MalformedPatternOverrideError
|
3723 + | {
|
3724 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3725 + | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_error(&self) {
|
3726 + | Ok(mut response) => {
|
3727 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
3728 + | response
|
3729 + | },
|
3730 + | Err(e) => {
|
3731 + | ::tracing::error!(error = %e, "failed to serialize response");
|
3732 + | ::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))
|
3733 + | }
|
3734 + | }
|
3735 + | }
|
3736 + | }
|
3737 + |
|
3738 + | #[allow(unreachable_code, unused_variables)]
|
3739 + | #[cfg(test)]
|
3740 + | mod malformed_pattern_override_test {
|
3741 + |
|
3742 + | /// When a string member does not match the specified pattern,
|
3966 3743 | /// the response should be a 400 ValidationException.
|
3967 - | /// Test ID: RestJsonMalformedRangeInteger_case0
|
3744 + | /// Test ID: RestJsonMalformedPatternStringOverride_case0
|
3968 3745 | #[::tokio::test]
|
3969 3746 | #[::tracing_test::traced_test]
|
3970 - | async fn rest_json_malformed_range_integer_case0_malformed_request() {
|
3747 + | async fn rest_json_malformed_pattern_string_override_case0_malformed_request() {
|
3971 3748 | {
|
3972 3749 | #[allow(unused_mut)]
|
3973 3750 | let mut http_request = ::http_1x::Request::builder()
|
3974 - | .uri("/MalformedRange")
|
3751 + | .uri("/MalformedPatternOverride")
|
3975 3752 | .method("POST")
|
3976 3753 | .header("content-type", "application/json")
|
3977 3754 | .body(::aws_smithy_http_server::body::boxed(
|
3978 3755 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3979 3756 | &::aws_smithy_protocol_test::decode_body_data(
|
3980 - | "{ \"integer\" : 1 }".as_bytes(),
|
3757 + | "{ \"string\" : \"abc\" }".as_bytes(),
|
3981 3758 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3982 3759 | ),
|
3983 3760 | )),
|
3984 3761 | ))
|
3985 3762 | .unwrap();
|
3986 3763 | #[allow(unused_mut)]
|
3987 3764 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3988 3765 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3989 3766 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3990 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3767 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3991 3768 | let sender = sender.clone();
|
3992 3769 | async move {
|
3993 - | 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> };
|
3770 + | 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> };
|
3994 3771 | sender.send(()).await.expect("receiver dropped early");
|
3995 3772 | result
|
3996 3773 | }
|
3997 3774 | })
|
3998 3775 | .build_unchecked();
|
3999 3776 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4000 3777 | .await
|
4001 3778 | .expect("unable to make an HTTP request");
|
4002 3779 | ::pretty_assertions::assert_eq!(
|
4003 3780 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4004 3781 | http_response.status()
|
4005 3782 | );
|
4006 3783 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4007 3784 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4008 3785 | http_response.headers(),
|
4009 3786 | expected_headers,
|
4010 3787 | ));
|
4011 3788 | use ::http_body_util::BodyExt;
|
4012 3789 | let body = http_response
|
4013 3790 | .into_body()
|
4014 3791 | .collect()
|
4015 3792 | .await
|
4016 3793 | .expect("unable to collect body")
|
4017 3794 | .to_bytes();
|
4018 3795 | ::aws_smithy_protocol_test::assert_ok(
|
4019 - | ::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"))
|
3796 + | ::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"))
|
4020 3797 | );
|
4021 3798 | }
|
4022 3799 | }
|
4023 3800 |
|
4024 - | /// When a integer member does not fit within range bounds,
|
3801 + | /// When a string member does not match the specified pattern,
|
4025 3802 | /// the response should be a 400 ValidationException.
|
4026 - | /// Test ID: RestJsonMalformedRangeInteger_case1
|
3803 + | /// Test ID: RestJsonMalformedPatternStringOverride_case1
|
4027 3804 | #[::tokio::test]
|
4028 3805 | #[::tracing_test::traced_test]
|
4029 - | async fn rest_json_malformed_range_integer_case1_malformed_request() {
|
3806 + | async fn rest_json_malformed_pattern_string_override_case1_malformed_request() {
|
4030 3807 | {
|
4031 3808 | #[allow(unused_mut)]
|
4032 3809 | let mut http_request = ::http_1x::Request::builder()
|
4033 - | .uri("/MalformedRange")
|
3810 + | .uri("/MalformedPatternOverride")
|
4034 3811 | .method("POST")
|
4035 3812 | .header("content-type", "application/json")
|
4036 3813 | .body(::aws_smithy_http_server::body::boxed(
|
4037 3814 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4038 3815 | &::aws_smithy_protocol_test::decode_body_data(
|
4039 - | "{ \"integer\" : 9 }".as_bytes(),
|
3816 + | "{ \"string\" : \"xyz\" }".as_bytes(),
|
4040 3817 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4041 3818 | ),
|
4042 3819 | )),
|
4043 3820 | ))
|
4044 3821 | .unwrap();
|
4045 3822 | #[allow(unused_mut)]
|
4046 3823 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4047 3824 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4048 3825 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4049 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3826 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4050 3827 | let sender = sender.clone();
|
4051 3828 | async move {
|
4052 - | 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> };
|
3829 + | 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> };
|
4053 3830 | sender.send(()).await.expect("receiver dropped early");
|
4054 3831 | result
|
4055 3832 | }
|
4056 3833 | })
|
4057 3834 | .build_unchecked();
|
4058 3835 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4059 3836 | .await
|
4060 3837 | .expect("unable to make an HTTP request");
|
4061 3838 | ::pretty_assertions::assert_eq!(
|
4062 3839 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4063 3840 | http_response.status()
|
4064 3841 | );
|
4065 3842 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4066 3843 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4067 3844 | http_response.headers(),
|
4068 3845 | expected_headers,
|
4069 3846 | ));
|
4070 3847 | use ::http_body_util::BodyExt;
|
4071 3848 | let body = http_response
|
4072 3849 | .into_body()
|
4073 3850 | .collect()
|
4074 3851 | .await
|
4075 3852 | .expect("unable to collect body")
|
4076 3853 | .to_bytes();
|
4077 3854 | ::aws_smithy_protocol_test::assert_ok(
|
4078 - | ::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"))
|
3855 + | ::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"))
|
4079 3856 | );
|
4080 3857 | }
|
4081 3858 | }
|
4082 3859 |
|
4083 - | /// When a integer member does not fit within range bounds,
|
3860 + | /// When a list member value does not match the specified pattern,
|
4084 3861 | /// the response should be a 400 ValidationException.
|
4085 - | /// Test ID: RestJsonMalformedRangeMinInteger
|
3862 + | /// Test ID: RestJsonMalformedPatternListOverride_case0
|
4086 3863 | #[::tokio::test]
|
4087 3864 | #[::tracing_test::traced_test]
|
4088 - | async fn rest_json_malformed_range_min_integer_malformed_request() {
|
3865 + | async fn rest_json_malformed_pattern_list_override_case0_malformed_request() {
|
4089 3866 | {
|
4090 3867 | #[allow(unused_mut)]
|
4091 3868 | let mut http_request = ::http_1x::Request::builder()
|
4092 - | .uri("/MalformedRange")
|
3869 + | .uri("/MalformedPatternOverride")
|
4093 3870 | .method("POST")
|
4094 3871 | .header("content-type", "application/json")
|
4095 3872 | .body(::aws_smithy_http_server::body::boxed(
|
4096 3873 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4097 3874 | &::aws_smithy_protocol_test::decode_body_data(
|
4098 - | "{ \"minInteger\" : 1 }".as_bytes(),
|
3875 + | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
4099 3876 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4100 3877 | ),
|
4101 3878 | )),
|
4102 3879 | ))
|
4103 3880 | .unwrap();
|
4104 3881 | #[allow(unused_mut)]
|
4105 3882 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4106 3883 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4107 3884 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4108 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3885 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4109 3886 | let sender = sender.clone();
|
4110 3887 | async move {
|
4111 - | 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> };
|
3888 + | 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> };
|
4112 3889 | sender.send(()).await.expect("receiver dropped early");
|
4113 3890 | result
|
4114 3891 | }
|
4115 3892 | })
|
4116 3893 | .build_unchecked();
|
4117 3894 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4118 3895 | .await
|
4119 3896 | .expect("unable to make an HTTP request");
|
4120 3897 | ::pretty_assertions::assert_eq!(
|
4121 3898 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4122 3899 | http_response.status()
|
4123 3900 | );
|
4124 3901 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4125 3902 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4126 3903 | http_response.headers(),
|
4127 3904 | expected_headers,
|
4128 3905 | ));
|
4129 3906 | use ::http_body_util::BodyExt;
|
4130 3907 | let body = http_response
|
4131 3908 | .into_body()
|
4132 3909 | .collect()
|
4133 3910 | .await
|
4134 3911 | .expect("unable to collect body")
|
4135 3912 | .to_bytes();
|
4136 3913 | ::aws_smithy_protocol_test::assert_ok(
|
4137 - | ::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"))
|
3914 + | ::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"))
|
4138 3915 | );
|
4139 3916 | }
|
4140 3917 | }
|
4141 3918 |
|
4142 - | /// When a integer member does not fit within range bounds,
|
3919 + | /// When a list member value does not match the specified pattern,
|
4143 3920 | /// the response should be a 400 ValidationException.
|
4144 - | /// Test ID: RestJsonMalformedRangeMaxInteger
|
3921 + | /// Test ID: RestJsonMalformedPatternListOverride_case1
|
4145 3922 | #[::tokio::test]
|
4146 3923 | #[::tracing_test::traced_test]
|
4147 - | async fn rest_json_malformed_range_max_integer_malformed_request() {
|
3924 + | async fn rest_json_malformed_pattern_list_override_case1_malformed_request() {
|
4148 3925 | {
|
4149 3926 | #[allow(unused_mut)]
|
4150 3927 | let mut http_request = ::http_1x::Request::builder()
|
4151 - | .uri("/MalformedRange")
|
3928 + | .uri("/MalformedPatternOverride")
|
4152 3929 | .method("POST")
|
4153 3930 | .header("content-type", "application/json")
|
4154 3931 | .body(::aws_smithy_http_server::body::boxed(
|
4155 3932 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4156 3933 | &::aws_smithy_protocol_test::decode_body_data(
|
4157 - | "{ \"maxInteger\" : 9 }".as_bytes(),
|
3934 + | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
4158 3935 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4159 3936 | ),
|
4160 3937 | )),
|
4161 3938 | ))
|
4162 3939 | .unwrap();
|
4163 3940 | #[allow(unused_mut)]
|
4164 3941 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4165 3942 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4166 3943 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4167 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3944 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4168 3945 | let sender = sender.clone();
|
4169 3946 | async move {
|
4170 - | 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> };
|
3947 + | 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> };
|
4171 3948 | sender.send(()).await.expect("receiver dropped early");
|
4172 3949 | result
|
4173 3950 | }
|
4174 3951 | })
|
4175 3952 | .build_unchecked();
|
4176 3953 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4177 3954 | .await
|
4178 3955 | .expect("unable to make an HTTP request");
|
4179 3956 | ::pretty_assertions::assert_eq!(
|
4180 3957 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4181 3958 | http_response.status()
|
4182 3959 | );
|
4183 3960 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4184 3961 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4185 3962 | http_response.headers(),
|
4186 3963 | expected_headers,
|
4187 3964 | ));
|
4188 3965 | use ::http_body_util::BodyExt;
|
4189 3966 | let body = http_response
|
4190 3967 | .into_body()
|
4191 3968 | .collect()
|
4192 3969 | .await
|
4193 3970 | .expect("unable to collect body")
|
4194 3971 | .to_bytes();
|
4195 3972 | ::aws_smithy_protocol_test::assert_ok(
|
4196 - | ::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"))
|
3973 + | ::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"))
|
4197 3974 | );
|
4198 3975 | }
|
4199 3976 | }
|
4200 3977 |
|
4201 - | /// When a long member does not fit within range bounds,
|
3978 + | /// When a map member's key does not match the specified pattern,
|
4202 3979 | /// the response should be a 400 ValidationException.
|
4203 - | /// Test ID: RestJsonMalformedRangeLong_case0
|
3980 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case0
|
4204 3981 | #[::tokio::test]
|
4205 3982 | #[::tracing_test::traced_test]
|
4206 - | async fn rest_json_malformed_range_long_case0_malformed_request() {
|
3983 + | async fn rest_json_malformed_pattern_map_key_override_case0_malformed_request() {
|
4207 3984 | {
|
4208 3985 | #[allow(unused_mut)]
|
4209 3986 | let mut http_request = ::http_1x::Request::builder()
|
4210 - | .uri("/MalformedRange")
|
3987 + | .uri("/MalformedPatternOverride")
|
4211 3988 | .method("POST")
|
4212 3989 | .header("content-type", "application/json")
|
4213 3990 | .body(::aws_smithy_http_server::body::boxed(
|
4214 3991 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4215 3992 | &::aws_smithy_protocol_test::decode_body_data(
|
4216 - | "{ \"long\" : 1 }".as_bytes(),
|
3993 + | "{ \"map\" : { \"abc\" : \"ghi\" } }".as_bytes(),
|
4217 3994 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4218 3995 | ),
|
4219 3996 | )),
|
4220 3997 | ))
|
4221 3998 | .unwrap();
|
4222 3999 | #[allow(unused_mut)]
|
4223 4000 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4224 4001 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4225 4002 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4226 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4003 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4227 4004 | let sender = sender.clone();
|
4228 4005 | async move {
|
4229 - | 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> };
|
4006 + | 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> };
|
4230 4007 | sender.send(()).await.expect("receiver dropped early");
|
4231 4008 | result
|
4232 4009 | }
|
4233 4010 | })
|
4234 4011 | .build_unchecked();
|
4235 4012 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4236 4013 | .await
|
4237 4014 | .expect("unable to make an HTTP request");
|
4238 4015 | ::pretty_assertions::assert_eq!(
|
4239 4016 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4240 4017 | http_response.status()
|
4241 4018 | );
|
4242 4019 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4243 4020 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4244 4021 | http_response.headers(),
|
4245 4022 | expected_headers,
|
4246 4023 | ));
|
4247 4024 | use ::http_body_util::BodyExt;
|
4248 4025 | let body = http_response
|
4249 4026 | .into_body()
|
4250 4027 | .collect()
|
4251 4028 | .await
|
4252 4029 | .expect("unable to collect body")
|
4253 4030 | .to_bytes();
|
4254 4031 | ::aws_smithy_protocol_test::assert_ok(
|
4255 - | ::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"))
|
4032 + | ::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"))
|
4256 4033 | );
|
4257 4034 | }
|
4258 4035 | }
|
4259 4036 |
|
4260 - | /// When a long member does not fit within range bounds,
|
4037 + | /// When a map member's key does not match the specified pattern,
|
4261 4038 | /// the response should be a 400 ValidationException.
|
4262 - | /// Test ID: RestJsonMalformedRangeLong_case1
|
4039 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case1
|
4263 4040 | #[::tokio::test]
|
4264 4041 | #[::tracing_test::traced_test]
|
4265 - | async fn rest_json_malformed_range_long_case1_malformed_request() {
|
4042 + | async fn rest_json_malformed_pattern_map_key_override_case1_malformed_request() {
|
4266 4043 | {
|
4267 4044 | #[allow(unused_mut)]
|
4268 4045 | let mut http_request = ::http_1x::Request::builder()
|
4269 - | .uri("/MalformedRange")
|
4046 + | .uri("/MalformedPatternOverride")
|
4270 4047 | .method("POST")
|
4271 4048 | .header("content-type", "application/json")
|
4272 4049 | .body(::aws_smithy_http_server::body::boxed(
|
4273 4050 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4274 4051 | &::aws_smithy_protocol_test::decode_body_data(
|
4275 - | "{ \"long\" : 9 }".as_bytes(),
|
4052 + | "{ \"map\" : { \"xyz\" : \"ghi\" } }".as_bytes(),
|
4276 4053 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4277 4054 | ),
|
4278 4055 | )),
|
4279 4056 | ))
|
4280 4057 | .unwrap();
|
4281 4058 | #[allow(unused_mut)]
|
4282 4059 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4283 4060 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4284 4061 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4285 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4062 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4286 4063 | let sender = sender.clone();
|
4287 4064 | async move {
|
4288 - | 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> };
|
4065 + | 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> };
|
4289 4066 | sender.send(()).await.expect("receiver dropped early");
|
4290 4067 | result
|
4291 4068 | }
|
4292 4069 | })
|
4293 4070 | .build_unchecked();
|
4294 4071 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4295 4072 | .await
|
4296 4073 | .expect("unable to make an HTTP request");
|
4297 4074 | ::pretty_assertions::assert_eq!(
|
4298 4075 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4299 4076 | http_response.status()
|
4300 4077 | );
|
4301 4078 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4302 4079 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4303 4080 | http_response.headers(),
|
4304 4081 | expected_headers,
|
4305 4082 | ));
|
4306 4083 | use ::http_body_util::BodyExt;
|
4307 4084 | let body = http_response
|
4308 4085 | .into_body()
|
4309 4086 | .collect()
|
4310 4087 | .await
|
4311 4088 | .expect("unable to collect body")
|
4312 4089 | .to_bytes();
|
4313 4090 | ::aws_smithy_protocol_test::assert_ok(
|
4314 - | ::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"))
|
4091 + | ::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"))
|
4315 4092 | );
|
4316 4093 | }
|
4317 4094 | }
|
4318 4095 |
|
4319 - | /// When a long member does not fit within range bounds,
|
4096 + | /// When a map member's value does not match the specified pattern,
|
4320 4097 | /// the response should be a 400 ValidationException.
|
4321 - | /// Test ID: RestJsonMalformedRangeMinLong
|
4098 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case0
|
4322 4099 | #[::tokio::test]
|
4323 4100 | #[::tracing_test::traced_test]
|
4324 - | async fn rest_json_malformed_range_min_long_malformed_request() {
|
4101 + | async fn rest_json_malformed_pattern_map_value_override_case0_malformed_request() {
|
4325 4102 | {
|
4326 4103 | #[allow(unused_mut)]
|
4327 4104 | let mut http_request = ::http_1x::Request::builder()
|
4328 - | .uri("/MalformedRange")
|
4105 + | .uri("/MalformedPatternOverride")
|
4329 4106 | .method("POST")
|
4330 4107 | .header("content-type", "application/json")
|
4331 4108 | .body(::aws_smithy_http_server::body::boxed(
|
4332 4109 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4333 4110 | &::aws_smithy_protocol_test::decode_body_data(
|
4334 - | "{ \"minLong\" : 1 }".as_bytes(),
|
4111 + | "{ \"map\" : { \"ghi\": \"abc\" } }".as_bytes(),
|
4335 4112 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4336 4113 | ),
|
4337 4114 | )),
|
4338 4115 | ))
|
4339 4116 | .unwrap();
|
4340 4117 | #[allow(unused_mut)]
|
4341 4118 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4342 4119 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4343 4120 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4344 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4121 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4345 4122 | let sender = sender.clone();
|
4346 4123 | async move {
|
4347 - | 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> };
|
4124 + | 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> };
|
4348 4125 | sender.send(()).await.expect("receiver dropped early");
|
4349 4126 | result
|
4350 4127 | }
|
4351 4128 | })
|
4352 4129 | .build_unchecked();
|
4353 4130 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4354 4131 | .await
|
4355 4132 | .expect("unable to make an HTTP request");
|
4356 4133 | ::pretty_assertions::assert_eq!(
|
4357 4134 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4358 4135 | http_response.status()
|
4359 4136 | );
|
4360 4137 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4361 4138 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4362 4139 | http_response.headers(),
|
4363 4140 | expected_headers,
|
4364 4141 | ));
|
4365 4142 | use ::http_body_util::BodyExt;
|
4366 4143 | let body = http_response
|
4367 4144 | .into_body()
|
4368 4145 | .collect()
|
4369 4146 | .await
|
4370 4147 | .expect("unable to collect body")
|
4371 4148 | .to_bytes();
|
4372 4149 | ::aws_smithy_protocol_test::assert_ok(
|
4373 - | ::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"))
|
4150 + | ::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"))
|
4374 4151 | );
|
4375 4152 | }
|
4376 4153 | }
|
4377 4154 |
|
4378 - | /// When a long member does not fit within range bounds,
|
4155 + | /// When a map member's value does not match the specified pattern,
|
4379 4156 | /// the response should be a 400 ValidationException.
|
4380 - | /// Test ID: RestJsonMalformedRangeMaxLong
|
4157 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case1
|
4381 4158 | #[::tokio::test]
|
4382 4159 | #[::tracing_test::traced_test]
|
4383 - | async fn rest_json_malformed_range_max_long_malformed_request() {
|
4160 + | async fn rest_json_malformed_pattern_map_value_override_case1_malformed_request() {
|
4384 4161 | {
|
4385 4162 | #[allow(unused_mut)]
|
4386 4163 | let mut http_request = ::http_1x::Request::builder()
|
4387 - | .uri("/MalformedRange")
|
4164 + | .uri("/MalformedPatternOverride")
|
4388 4165 | .method("POST")
|
4389 4166 | .header("content-type", "application/json")
|
4390 4167 | .body(::aws_smithy_http_server::body::boxed(
|
4391 4168 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4392 4169 | &::aws_smithy_protocol_test::decode_body_data(
|
4393 - | "{ \"maxLong\" : 9 }".as_bytes(),
|
4170 + | "{ \"map\" : { \"ghi\": \"xyz\" } }".as_bytes(),
|
4394 4171 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4395 4172 | ),
|
4396 4173 | )),
|
4397 4174 | ))
|
4398 4175 | .unwrap();
|
4399 4176 | #[allow(unused_mut)]
|
4400 4177 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4401 4178 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4402 4179 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4403 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4180 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4404 4181 | let sender = sender.clone();
|
4405 4182 | async move {
|
4406 - | 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> };
|
4183 + | 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> };
|
4407 4184 | sender.send(()).await.expect("receiver dropped early");
|
4408 4185 | result
|
4409 4186 | }
|
4410 4187 | })
|
4411 4188 | .build_unchecked();
|
4412 4189 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4413 4190 | .await
|
4414 4191 | .expect("unable to make an HTTP request");
|
4415 4192 | ::pretty_assertions::assert_eq!(
|
4416 4193 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4417 4194 | http_response.status()
|
4418 4195 | );
|
4419 4196 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4420 4197 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4421 4198 | http_response.headers(),
|
4422 4199 | expected_headers,
|
4423 4200 | ));
|
4424 4201 | use ::http_body_util::BodyExt;
|
4425 4202 | let body = http_response
|
4426 4203 | .into_body()
|
4427 4204 | .collect()
|
4428 4205 | .await
|
4429 4206 | .expect("unable to collect body")
|
4430 4207 | .to_bytes();
|
4431 4208 | ::aws_smithy_protocol_test::assert_ok(
|
4432 - | ::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"))
|
4209 + | ::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"))
|
4210 + | );
|
4211 + | }
|
4212 + | }
|
4213 + |
|
4214 + | /// When a union member's value does not match the specified pattern,
|
4215 + | /// the response should be a 400 ValidationException.
|
4216 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case0
|
4217 + | #[::tokio::test]
|
4218 + | #[::tracing_test::traced_test]
|
4219 + | async fn rest_json_malformed_pattern_union_override_case0_malformed_request() {
|
4220 + | {
|
4221 + | #[allow(unused_mut)]
|
4222 + | let mut http_request = ::http_1x::Request::builder()
|
4223 + | .uri("/MalformedPatternOverride")
|
4224 + | .method("POST")
|
4225 + | .header("content-type", "application/json")
|
4226 + | .body(::aws_smithy_http_server::body::boxed(
|
4227 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4228 + | &::aws_smithy_protocol_test::decode_body_data(
|
4229 + | "{ \"union\" : { \"first\": \"abc\" } }".as_bytes(),
|
4230 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4231 + | ),
|
4232 + | )),
|
4233 + | ))
|
4234 + | .unwrap();
|
4235 + | #[allow(unused_mut)]
|
4236 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4237 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4238 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4239 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4240 + | let sender = sender.clone();
|
4241 + | async move {
|
4242 + | 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> };
|
4243 + | sender.send(()).await.expect("receiver dropped early");
|
4244 + | result
|
4245 + | }
|
4246 + | })
|
4247 + | .build_unchecked();
|
4248 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4249 + | .await
|
4250 + | .expect("unable to make an HTTP request");
|
4251 + | ::pretty_assertions::assert_eq!(
|
4252 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4253 + | http_response.status()
|
4254 + | );
|
4255 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4256 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4257 + | http_response.headers(),
|
4258 + | expected_headers,
|
4259 + | ));
|
4260 + | use ::http_body_util::BodyExt;
|
4261 + | let body = http_response
|
4262 + | .into_body()
|
4263 + | .collect()
|
4264 + | .await
|
4265 + | .expect("unable to collect body")
|
4266 + | .to_bytes();
|
4267 + | ::aws_smithy_protocol_test::assert_ok(
|
4268 + | ::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"))
|
4269 + | );
|
4270 + | }
|
4271 + | }
|
4272 + |
|
4273 + | /// When a union member's value does not match the specified pattern,
|
4274 + | /// the response should be a 400 ValidationException.
|
4275 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case1
|
4276 + | #[::tokio::test]
|
4277 + | #[::tracing_test::traced_test]
|
4278 + | async fn rest_json_malformed_pattern_union_override_case1_malformed_request() {
|
4279 + | {
|
4280 + | #[allow(unused_mut)]
|
4281 + | let mut http_request = ::http_1x::Request::builder()
|
4282 + | .uri("/MalformedPatternOverride")
|
4283 + | .method("POST")
|
4284 + | .header("content-type", "application/json")
|
4285 + | .body(::aws_smithy_http_server::body::boxed(
|
4286 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4287 + | &::aws_smithy_protocol_test::decode_body_data(
|
4288 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
4289 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4290 + | ),
|
4291 + | )),
|
4292 + | ))
|
4293 + | .unwrap();
|
4294 + | #[allow(unused_mut)]
|
4295 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4296 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4297 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4298 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4299 + | let sender = sender.clone();
|
4300 + | async move {
|
4301 + | 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> };
|
4302 + | sender.send(()).await.expect("receiver dropped early");
|
4303 + | result
|
4304 + | }
|
4305 + | })
|
4306 + | .build_unchecked();
|
4307 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4308 + | .await
|
4309 + | .expect("unable to make an HTTP request");
|
4310 + | ::pretty_assertions::assert_eq!(
|
4311 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4312 + | http_response.status()
|
4313 + | );
|
4314 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4315 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4316 + | http_response.headers(),
|
4317 + | expected_headers,
|
4318 + | ));
|
4319 + | use ::http_body_util::BodyExt;
|
4320 + | let body = http_response
|
4321 + | .into_body()
|
4322 + | .collect()
|
4323 + | .await
|
4324 + | .expect("unable to collect body")
|
4325 + | .to_bytes();
|
4326 + | ::aws_smithy_protocol_test::assert_ok(
|
4327 + | ::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"))
|
4433 4328 | );
|
4434 4329 | }
|
4435 4330 | }
|
4436 4331 | }
|
4437 4332 |
|
4438 4333 | ::pin_project_lite::pin_project! {
|
4439 4334 | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
4440 - | /// [`MalformedPatternOverrideInput`](crate::input::MalformedPatternOverrideInput) using modelled bindings.
|
4441 - | pub struct MalformedPatternOverrideInputFuture {
|
4442 - | 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>>
|
4335 + | /// [`MalformedRangeInput`](crate::input::MalformedRangeInput) using modelled bindings.
|
4336 + | pub struct MalformedRangeInputFuture {
|
4337 + | 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>>
|
4443 4338 | }
|
4444 4339 | }
|
4445 4340 |
|
4446 - | impl std::future::Future for MalformedPatternOverrideInputFuture {
|
4341 + | impl std::future::Future for MalformedRangeInputFuture {
|
4447 4342 | type Output = Result<
|
4448 - | crate::input::MalformedPatternOverrideInput,
|
4343 + | crate::input::MalformedRangeInput,
|
4449 4344 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
4450 4345 | >;
|
4451 4346 |
|
4452 4347 | fn poll(
|
4453 4348 | self: std::pin::Pin<&mut Self>,
|
4454 4349 | cx: &mut std::task::Context<'_>,
|
4455 4350 | ) -> std::task::Poll<Self::Output> {
|
4456 4351 | let this = self.project();
|
4457 4352 | this.inner.as_mut().poll(cx)
|
4458 4353 | }
|
4459 4354 | }
|
4460 4355 |
|
4461 4356 | impl<B>
|
4462 4357 | ::aws_smithy_http_server::request::FromRequest<
|
4463 4358 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
4464 4359 | B,
|
4465 - | > for crate::input::MalformedPatternOverrideInput
|
4360 + | > for crate::input::MalformedRangeInput
|
4466 4361 | where
|
4467 4362 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
4468 4363 | B: 'static,
|
4469 4364 |
|
4470 4365 | B::Data: Send,
|
4471 4366 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
4472 4367 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
4473 4368 | {
|
4474 4369 | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
4475 - | type Future = MalformedPatternOverrideInputFuture;
|
4370 + | type Future = MalformedRangeInputFuture;
|
4476 4371 |
|
4477 4372 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
4478 4373 | let fut = async move {
|
4479 4374 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
4480 4375 | request.headers(),
|
4481 4376 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
4482 4377 | ) {
|
4483 4378 | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
4484 4379 | }
|
4485 - | crate::protocol_serde::shape_malformed_pattern_override::de_malformed_pattern_override_http_request(request)
|
4380 + | crate::protocol_serde::shape_malformed_range::de_malformed_range_http_request(request)
|
4486 4381 | .await
|
4487 4382 | };
|
4488 4383 | use ::futures_util::future::TryFutureExt;
|
4489 4384 | let fut = fut.map_err(
|
4490 4385 | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
4491 4386 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
4492 4387 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
4493 4388 | e,
|
4494 4389 | )
|
4495 4390 | },
|
4496 4391 | );
|
4497 - | MalformedPatternOverrideInputFuture {
|
4392 + | MalformedRangeInputFuture {
|
4498 4393 | inner: Box::pin(fut),
|
4499 4394 | }
|
4500 4395 | }
|
4501 4396 | }
|
4502 4397 | impl
|
4503 4398 | ::aws_smithy_http_server::response::IntoResponse<
|
4504 4399 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
4505 - | > for crate::output::MalformedPatternOverrideOutput
|
4400 + | > for crate::output::MalformedRangeOutput
|
4506 4401 | {
|
4507 4402 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4508 - | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_response(self) {
|
4403 + | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_response(self)
|
4404 + | {
|
4509 4405 | Ok(response) => response,
|
4510 4406 | Err(e) => {
|
4511 4407 | ::tracing::error!(error = %e, "failed to serialize response");
|
4512 4408 | ::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))
|
4513 4409 | }
|
4514 4410 | }
|
4515 4411 | }
|
4516 4412 | }
|
4517 4413 | impl
|
4518 4414 | ::aws_smithy_http_server::response::IntoResponse<
|
4519 4415 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
4520 - | > for crate::error::MalformedPatternOverrideError
|
4416 + | > for crate::error::MalformedRangeError
|
4521 4417 | {
|
4522 4418 | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
4523 - | match crate::protocol_serde::shape_malformed_pattern_override::ser_malformed_pattern_override_http_error(&self) {
|
4419 + | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_error(&self) {
|
4524 4420 | Ok(mut response) => {
|
4525 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
4421 + | response.extensions_mut().insert(
|
4422 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
4423 + | );
|
4526 4424 | response
|
4527 - | },
|
4425 + | }
|
4528 4426 | Err(e) => {
|
4529 4427 | ::tracing::error!(error = %e, "failed to serialize response");
|
4530 4428 | ::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))
|
4531 4429 | }
|
4532 4430 | }
|
4533 4431 | }
|
4534 4432 | }
|
4535 4433 |
|
4536 4434 | #[allow(unreachable_code, unused_variables)]
|
4537 4435 | #[cfg(test)]
|
4538 - | mod malformed_pattern_override_test {
|
4436 + | mod malformed_range_test {
|
4539 4437 |
|
4540 - | /// When a string member does not match the specified pattern,
|
4438 + | /// When a byte member does not fit within range bounds,
|
4541 4439 | /// the response should be a 400 ValidationException.
|
4542 - | /// Test ID: RestJsonMalformedPatternStringOverride_case0
|
4440 + | /// Test ID: RestJsonMalformedRangeByte_case0
|
4543 4441 | #[::tokio::test]
|
4544 4442 | #[::tracing_test::traced_test]
|
4545 - | async fn rest_json_malformed_pattern_string_override_case0_malformed_request() {
|
4443 + | async fn rest_json_malformed_range_byte_case0_malformed_request() {
|
4546 4444 | {
|
4547 4445 | #[allow(unused_mut)]
|
4548 4446 | let mut http_request = ::http_1x::Request::builder()
|
4549 - | .uri("/MalformedPatternOverride")
|
4447 + | .uri("/MalformedRange")
|
4550 4448 | .method("POST")
|
4551 4449 | .header("content-type", "application/json")
|
4552 4450 | .body(::aws_smithy_http_server::body::boxed(
|
4553 4451 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4554 4452 | &::aws_smithy_protocol_test::decode_body_data(
|
4555 - | "{ \"string\" : \"abc\" }".as_bytes(),
|
4453 + | "{ \"byte\" : 1 }".as_bytes(),
|
4556 4454 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4557 4455 | ),
|
4558 4456 | )),
|
4559 4457 | ))
|
4560 4458 | .unwrap();
|
4561 4459 | #[allow(unused_mut)]
|
4562 4460 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4563 4461 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4564 4462 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4565 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4463 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4566 4464 | let sender = sender.clone();
|
4567 4465 | async move {
|
4568 - | 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> };
|
4466 + | 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> };
|
4569 4467 | sender.send(()).await.expect("receiver dropped early");
|
4570 4468 | result
|
4571 4469 | }
|
4572 4470 | })
|
4573 4471 | .build_unchecked();
|
4574 4472 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4575 4473 | .await
|
4576 4474 | .expect("unable to make an HTTP request");
|
4577 4475 | ::pretty_assertions::assert_eq!(
|
4578 4476 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4579 4477 | http_response.status()
|
4580 4478 | );
|
4581 4479 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4582 4480 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4583 4481 | http_response.headers(),
|
4584 4482 | expected_headers,
|
4585 4483 | ));
|
4586 4484 | use ::http_body_util::BodyExt;
|
4587 4485 | let body = http_response
|
4588 4486 | .into_body()
|
4589 4487 | .collect()
|
4590 4488 | .await
|
4591 4489 | .expect("unable to collect body")
|
4592 4490 | .to_bytes();
|
4593 4491 | ::aws_smithy_protocol_test::assert_ok(
|
4594 - | ::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"))
|
4492 + | ::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"))
|
4595 4493 | );
|
4596 4494 | }
|
4597 4495 | }
|
4598 4496 |
|
4599 - | /// When a string member does not match the specified pattern,
|
4497 + | /// When a byte member does not fit within range bounds,
|
4600 4498 | /// the response should be a 400 ValidationException.
|
4601 - | /// Test ID: RestJsonMalformedPatternStringOverride_case1
|
4499 + | /// Test ID: RestJsonMalformedRangeByte_case1
|
4602 4500 | #[::tokio::test]
|
4603 4501 | #[::tracing_test::traced_test]
|
4604 - | async fn rest_json_malformed_pattern_string_override_case1_malformed_request() {
|
4502 + | async fn rest_json_malformed_range_byte_case1_malformed_request() {
|
4605 4503 | {
|
4606 4504 | #[allow(unused_mut)]
|
4607 4505 | let mut http_request = ::http_1x::Request::builder()
|
4608 - | .uri("/MalformedPatternOverride")
|
4506 + | .uri("/MalformedRange")
|
4609 4507 | .method("POST")
|
4610 4508 | .header("content-type", "application/json")
|
4611 4509 | .body(::aws_smithy_http_server::body::boxed(
|
4612 4510 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4613 4511 | &::aws_smithy_protocol_test::decode_body_data(
|
4614 - | "{ \"string\" : \"xyz\" }".as_bytes(),
|
4512 + | "{ \"byte\" : 9 }".as_bytes(),
|
4615 4513 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4616 4514 | ),
|
4617 4515 | )),
|
4618 4516 | ))
|
4619 4517 | .unwrap();
|
4620 4518 | #[allow(unused_mut)]
|
4621 4519 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4622 4520 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4623 4521 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4624 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4522 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4625 4523 | let sender = sender.clone();
|
4626 4524 | async move {
|
4627 - | 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> };
|
4525 + | 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> };
|
4628 4526 | sender.send(()).await.expect("receiver dropped early");
|
4629 4527 | result
|
4630 4528 | }
|
4631 4529 | })
|
4632 4530 | .build_unchecked();
|
4633 4531 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4634 4532 | .await
|
4635 4533 | .expect("unable to make an HTTP request");
|
4636 4534 | ::pretty_assertions::assert_eq!(
|
4637 4535 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4638 4536 | http_response.status()
|
4639 4537 | );
|
4640 4538 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4641 4539 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4642 4540 | http_response.headers(),
|
4643 4541 | expected_headers,
|
4644 4542 | ));
|
4645 4543 | use ::http_body_util::BodyExt;
|
4646 4544 | let body = http_response
|
4647 4545 | .into_body()
|
4648 4546 | .collect()
|
4649 4547 | .await
|
4650 4548 | .expect("unable to collect body")
|
4651 4549 | .to_bytes();
|
4652 4550 | ::aws_smithy_protocol_test::assert_ok(
|
4653 - | ::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"))
|
4551 + | ::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"))
|
4654 4552 | );
|
4655 4553 | }
|
4656 4554 | }
|
4657 4555 |
|
4658 - | /// When a list member value does not match the specified pattern,
|
4556 + | /// When a byte member does not fit within range bounds,
|
4659 4557 | /// the response should be a 400 ValidationException.
|
4660 - | /// Test ID: RestJsonMalformedPatternListOverride_case0
|
4558 + | /// Test ID: RestJsonMalformedRangeMinByte
|
4661 4559 | #[::tokio::test]
|
4662 4560 | #[::tracing_test::traced_test]
|
4663 - | async fn rest_json_malformed_pattern_list_override_case0_malformed_request() {
|
4561 + | async fn rest_json_malformed_range_min_byte_malformed_request() {
|
4664 4562 | {
|
4665 4563 | #[allow(unused_mut)]
|
4666 4564 | let mut http_request = ::http_1x::Request::builder()
|
4667 - | .uri("/MalformedPatternOverride")
|
4565 + | .uri("/MalformedRange")
|
4668 4566 | .method("POST")
|
4669 4567 | .header("content-type", "application/json")
|
4670 4568 | .body(::aws_smithy_http_server::body::boxed(
|
4671 4569 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4672 4570 | &::aws_smithy_protocol_test::decode_body_data(
|
4673 - | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
4571 + | "{ \"minByte\" : 1 }".as_bytes(),
|
4674 4572 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4675 4573 | ),
|
4676 4574 | )),
|
4677 4575 | ))
|
4678 4576 | .unwrap();
|
4679 4577 | #[allow(unused_mut)]
|
4680 4578 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4681 4579 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4682 4580 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4683 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4581 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4684 4582 | let sender = sender.clone();
|
4685 4583 | async move {
|
4686 - | 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> };
|
4584 + | 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> };
|
4687 4585 | sender.send(()).await.expect("receiver dropped early");
|
4688 4586 | result
|
4689 4587 | }
|
4690 4588 | })
|
4691 4589 | .build_unchecked();
|
4692 4590 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4693 4591 | .await
|
4694 4592 | .expect("unable to make an HTTP request");
|
4695 4593 | ::pretty_assertions::assert_eq!(
|
4696 4594 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4697 4595 | http_response.status()
|
4698 4596 | );
|
4699 4597 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4700 4598 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4701 4599 | http_response.headers(),
|
4702 4600 | expected_headers,
|
4703 4601 | ));
|
4704 4602 | use ::http_body_util::BodyExt;
|
4705 4603 | let body = http_response
|
4706 4604 | .into_body()
|
4707 4605 | .collect()
|
4708 4606 | .await
|
4709 4607 | .expect("unable to collect body")
|
4710 4608 | .to_bytes();
|
4711 4609 | ::aws_smithy_protocol_test::assert_ok(
|
4712 - | ::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"))
|
4610 + | ::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"))
|
4713 4611 | );
|
4714 4612 | }
|
4715 4613 | }
|
4716 4614 |
|
4717 - | /// When a list member value does not match the specified pattern,
|
4615 + | /// When a byte member does not fit within range bounds,
|
4718 4616 | /// the response should be a 400 ValidationException.
|
4719 - | /// Test ID: RestJsonMalformedPatternListOverride_case1
|
4617 + | /// Test ID: RestJsonMalformedRangeMaxByte
|
4720 4618 | #[::tokio::test]
|
4721 4619 | #[::tracing_test::traced_test]
|
4722 - | async fn rest_json_malformed_pattern_list_override_case1_malformed_request() {
|
4620 + | async fn rest_json_malformed_range_max_byte_malformed_request() {
|
4723 4621 | {
|
4724 4622 | #[allow(unused_mut)]
|
4725 4623 | let mut http_request = ::http_1x::Request::builder()
|
4726 - | .uri("/MalformedPatternOverride")
|
4624 + | .uri("/MalformedRange")
|
4727 4625 | .method("POST")
|
4728 4626 | .header("content-type", "application/json")
|
4729 4627 | .body(::aws_smithy_http_server::body::boxed(
|
4730 4628 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4731 4629 | &::aws_smithy_protocol_test::decode_body_data(
|
4732 - | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
4630 + | "{ \"maxByte\" : 9 }".as_bytes(),
|
4733 4631 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4734 4632 | ),
|
4735 4633 | )),
|
4736 4634 | ))
|
4737 4635 | .unwrap();
|
4738 4636 | #[allow(unused_mut)]
|
4739 4637 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4740 4638 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4741 4639 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4742 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4640 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4743 4641 | let sender = sender.clone();
|
4744 4642 | async move {
|
4745 - | 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> };
|
4643 + | 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> };
|
4746 4644 | sender.send(()).await.expect("receiver dropped early");
|
4747 4645 | result
|
4748 4646 | }
|
4749 4647 | })
|
4750 4648 | .build_unchecked();
|
4751 4649 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4752 4650 | .await
|
4753 4651 | .expect("unable to make an HTTP request");
|
4754 4652 | ::pretty_assertions::assert_eq!(
|
4755 4653 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4756 4654 | http_response.status()
|
4757 4655 | );
|
4758 4656 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4759 4657 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4760 4658 | http_response.headers(),
|
4761 4659 | expected_headers,
|
4762 4660 | ));
|
4763 4661 | use ::http_body_util::BodyExt;
|
4764 4662 | let body = http_response
|
4765 4663 | .into_body()
|
4766 4664 | .collect()
|
4767 4665 | .await
|
4768 4666 | .expect("unable to collect body")
|
4769 4667 | .to_bytes();
|
4770 4668 | ::aws_smithy_protocol_test::assert_ok(
|
4771 - | ::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"))
|
4669 + | ::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"))
|
4772 4670 | );
|
4773 4671 | }
|
4774 4672 | }
|
4775 4673 |
|
4776 - | /// When a map member's key does not match the specified pattern,
|
4674 + | /// When a float member does not fit within range bounds,
|
4777 4675 | /// the response should be a 400 ValidationException.
|
4778 - | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case0
|
4676 + | /// Test ID: RestJsonMalformedRangeFloat_case0
|
4779 4677 | #[::tokio::test]
|
4780 4678 | #[::tracing_test::traced_test]
|
4781 - | async fn rest_json_malformed_pattern_map_key_override_case0_malformed_request() {
|
4679 + | #[should_panic]
|
4680 + | async fn rest_json_malformed_range_float_case0_malformed_request() {
|
4782 4681 | {
|
4783 4682 | #[allow(unused_mut)]
|
4784 4683 | let mut http_request = ::http_1x::Request::builder()
|
4785 - | .uri("/MalformedPatternOverride")
|
4684 + | .uri("/MalformedRange")
|
4786 4685 | .method("POST")
|
4787 4686 | .header("content-type", "application/json")
|
4788 4687 | .body(::aws_smithy_http_server::body::boxed(
|
4789 4688 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4790 4689 | &::aws_smithy_protocol_test::decode_body_data(
|
4791 - | "{ \"map\" : { \"abc\" : \"ghi\" } }".as_bytes(),
|
4690 + | "{ \"float\" : 2.1 }".as_bytes(),
|
4792 4691 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4793 4692 | ),
|
4794 4693 | )),
|
4795 4694 | ))
|
4796 4695 | .unwrap();
|
4797 4696 | #[allow(unused_mut)]
|
4798 4697 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4799 4698 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4800 4699 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4801 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4700 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4802 4701 | let sender = sender.clone();
|
4803 4702 | async move {
|
4804 - | 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> };
|
4703 + | 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> };
|
4805 4704 | sender.send(()).await.expect("receiver dropped early");
|
4806 4705 | result
|
4807 4706 | }
|
4808 4707 | })
|
4809 4708 | .build_unchecked();
|
4810 4709 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4811 4710 | .await
|
4812 4711 | .expect("unable to make an HTTP request");
|
4813 4712 | ::pretty_assertions::assert_eq!(
|
4814 4713 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4815 4714 | http_response.status()
|
4816 4715 | );
|
4817 4716 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4818 4717 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4819 4718 | http_response.headers(),
|
4820 4719 | expected_headers,
|
4821 4720 | ));
|
4822 4721 | use ::http_body_util::BodyExt;
|
4823 4722 | let body = http_response
|
4824 4723 | .into_body()
|
4825 4724 | .collect()
|
4826 4725 | .await
|
4827 4726 | .expect("unable to collect body")
|
4828 4727 | .to_bytes();
|
4829 4728 | ::aws_smithy_protocol_test::assert_ok(
|
4830 - | ::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"))
|
4729 + | ::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"))
|
4831 4730 | );
|
4832 4731 | }
|
4833 4732 | }
|
4834 4733 |
|
4835 - | /// When a map member's key does not match the specified pattern,
|
4734 + | /// When a float member does not fit within range bounds,
|
4836 4735 | /// the response should be a 400 ValidationException.
|
4837 - | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case1
|
4736 + | /// Test ID: RestJsonMalformedRangeFloat_case1
|
4838 4737 | #[::tokio::test]
|
4839 4738 | #[::tracing_test::traced_test]
|
4840 - | async fn rest_json_malformed_pattern_map_key_override_case1_malformed_request() {
|
4739 + | #[should_panic]
|
4740 + | async fn rest_json_malformed_range_float_case1_malformed_request() {
|
4841 4741 | {
|
4842 4742 | #[allow(unused_mut)]
|
4843 4743 | let mut http_request = ::http_1x::Request::builder()
|
4844 - | .uri("/MalformedPatternOverride")
|
4744 + | .uri("/MalformedRange")
|
4845 4745 | .method("POST")
|
4846 4746 | .header("content-type", "application/json")
|
4847 4747 | .body(::aws_smithy_http_server::body::boxed(
|
4848 4748 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4849 4749 | &::aws_smithy_protocol_test::decode_body_data(
|
4850 - | "{ \"map\" : { \"xyz\" : \"ghi\" } }".as_bytes(),
|
4750 + | "{ \"float\" : 8.9 }".as_bytes(),
|
4851 4751 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4852 4752 | ),
|
4853 4753 | )),
|
4854 4754 | ))
|
4855 4755 | .unwrap();
|
4856 4756 | #[allow(unused_mut)]
|
4857 4757 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4858 4758 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4859 4759 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4860 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4760 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4861 4761 | let sender = sender.clone();
|
4862 4762 | async move {
|
4863 - | 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> };
|
4763 + | 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> };
|
4864 4764 | sender.send(()).await.expect("receiver dropped early");
|
4865 4765 | result
|
4866 4766 | }
|
4867 4767 | })
|
4868 4768 | .build_unchecked();
|
4869 4769 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4870 4770 | .await
|
4871 4771 | .expect("unable to make an HTTP request");
|
4872 4772 | ::pretty_assertions::assert_eq!(
|
4873 4773 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4874 4774 | http_response.status()
|
4875 4775 | );
|
4876 4776 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4877 4777 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4878 4778 | http_response.headers(),
|
4879 4779 | expected_headers,
|
4880 4780 | ));
|
4881 4781 | use ::http_body_util::BodyExt;
|
4882 4782 | let body = http_response
|
4883 4783 | .into_body()
|
4884 4784 | .collect()
|
4885 4785 | .await
|
4886 4786 | .expect("unable to collect body")
|
4887 4787 | .to_bytes();
|
4888 4788 | ::aws_smithy_protocol_test::assert_ok(
|
4889 - | ::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"))
|
4789 + | ::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"))
|
4890 4790 | );
|
4891 4791 | }
|
4892 4792 | }
|
4893 4793 |
|
4894 - | /// When a map member's value does not match the specified pattern,
|
4794 + | /// When a float member does not fit within range bounds,
|
4895 4795 | /// the response should be a 400 ValidationException.
|
4896 - | /// Test ID: RestJsonMalformedPatternMapValueOverride_case0
|
4796 + | /// Test ID: RestJsonMalformedRangeMinFloat
|
4897 4797 | #[::tokio::test]
|
4898 4798 | #[::tracing_test::traced_test]
|
4899 - | async fn rest_json_malformed_pattern_map_value_override_case0_malformed_request() {
|
4799 + | #[should_panic]
|
4800 + | async fn rest_json_malformed_range_min_float_malformed_request() {
|
4900 4801 | {
|
4901 4802 | #[allow(unused_mut)]
|
4902 4803 | let mut http_request = ::http_1x::Request::builder()
|
4903 - | .uri("/MalformedPatternOverride")
|
4804 + | .uri("/MalformedRange")
|
4904 4805 | .method("POST")
|
4905 4806 | .header("content-type", "application/json")
|
4906 4807 | .body(::aws_smithy_http_server::body::boxed(
|
4907 4808 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4908 4809 | &::aws_smithy_protocol_test::decode_body_data(
|
4909 - | "{ \"map\" : { \"ghi\": \"abc\" } }".as_bytes(),
|
4810 + | "{ \"minFloat\" : 2.1 }".as_bytes(),
|
4910 4811 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4911 4812 | ),
|
4912 4813 | )),
|
4913 4814 | ))
|
4914 4815 | .unwrap();
|
4915 4816 | #[allow(unused_mut)]
|
4916 4817 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4917 4818 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4918 4819 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4919 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4820 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4920 4821 | let sender = sender.clone();
|
4921 4822 | async move {
|
4922 - | 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> };
|
4823 + | 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> };
|
4923 4824 | sender.send(()).await.expect("receiver dropped early");
|
4924 4825 | result
|
4925 4826 | }
|
4926 4827 | })
|
4927 4828 | .build_unchecked();
|
4928 4829 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4929 4830 | .await
|
4930 4831 | .expect("unable to make an HTTP request");
|
4931 4832 | ::pretty_assertions::assert_eq!(
|
4932 4833 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4933 4834 | http_response.status()
|
4934 4835 | );
|
4935 4836 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4936 4837 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4937 4838 | http_response.headers(),
|
4938 4839 | expected_headers,
|
4939 4840 | ));
|
4940 4841 | use ::http_body_util::BodyExt;
|
4941 4842 | let body = http_response
|
4942 4843 | .into_body()
|
4943 4844 | .collect()
|
4944 4845 | .await
|
4945 4846 | .expect("unable to collect body")
|
4946 4847 | .to_bytes();
|
4947 4848 | ::aws_smithy_protocol_test::assert_ok(
|
4948 - | ::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"))
|
4849 + | ::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"))
|
4949 4850 | );
|
4950 4851 | }
|
4951 4852 | }
|
4952 4853 |
|
4953 - | /// When a map member's value does not match the specified pattern,
|
4854 + | /// When a float member does not fit within range bounds,
|
4954 4855 | /// the response should be a 400 ValidationException.
|
4955 - | /// Test ID: RestJsonMalformedPatternMapValueOverride_case1
|
4856 + | /// Test ID: RestJsonMalformedRangeMaxFloat
|
4956 4857 | #[::tokio::test]
|
4957 4858 | #[::tracing_test::traced_test]
|
4958 - | async fn rest_json_malformed_pattern_map_value_override_case1_malformed_request() {
|
4859 + | #[should_panic]
|
4860 + | async fn rest_json_malformed_range_max_float_malformed_request() {
|
4959 4861 | {
|
4960 4862 | #[allow(unused_mut)]
|
4961 4863 | let mut http_request = ::http_1x::Request::builder()
|
4962 - | .uri("/MalformedPatternOverride")
|
4864 + | .uri("/MalformedRange")
|
4963 4865 | .method("POST")
|
4964 4866 | .header("content-type", "application/json")
|
4965 4867 | .body(::aws_smithy_http_server::body::boxed(
|
4966 4868 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4967 4869 | &::aws_smithy_protocol_test::decode_body_data(
|
4968 - | "{ \"map\" : { \"ghi\": \"xyz\" } }".as_bytes(),
|
4870 + | "{ \"maxFloat\" : 8.9 }".as_bytes(),
|
4969 4871 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4970 4872 | ),
|
4971 4873 | )),
|
4972 4874 | ))
|
4973 4875 | .unwrap();
|
4974 4876 | #[allow(unused_mut)]
|
4975 4877 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4976 4878 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4977 4879 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4978 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4880 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4979 4881 | let sender = sender.clone();
|
4980 4882 | async move {
|
4981 - | 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> };
|
4883 + | 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> };
|
4982 4884 | sender.send(()).await.expect("receiver dropped early");
|
4983 4885 | result
|
4984 4886 | }
|
4985 4887 | })
|
4986 4888 | .build_unchecked();
|
4987 4889 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4988 4890 | .await
|
4989 4891 | .expect("unable to make an HTTP request");
|
4990 4892 | ::pretty_assertions::assert_eq!(
|
4991 4893 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4992 4894 | http_response.status()
|
4993 4895 | );
|
4994 4896 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4995 4897 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4996 4898 | http_response.headers(),
|
4997 4899 | expected_headers,
|
4998 4900 | ));
|
4999 4901 | use ::http_body_util::BodyExt;
|
5000 4902 | let body = http_response
|
5001 4903 | .into_body()
|
5002 4904 | .collect()
|
5003 4905 | .await
|
5004 4906 | .expect("unable to collect body")
|
5005 4907 | .to_bytes();
|
5006 4908 | ::aws_smithy_protocol_test::assert_ok(
|
5007 - | ::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"))
|
4909 + | ::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"))
|
5008 4910 | );
|
5009 4911 | }
|
5010 4912 | }
|
5011 4913 |
|
5012 - | /// When a union member's value does not match the specified pattern,
|
4914 + | /// When a short member does not fit within range bounds,
|
5013 4915 | /// the response should be a 400 ValidationException.
|
5014 - | /// Test ID: RestJsonMalformedPatternUnionOverride_case0
|
4916 + | /// Test ID: RestJsonMalformedRangeShort_case0
|
5015 4917 | #[::tokio::test]
|
5016 4918 | #[::tracing_test::traced_test]
|
5017 - | async fn rest_json_malformed_pattern_union_override_case0_malformed_request() {
|
4919 + | async fn rest_json_malformed_range_short_case0_malformed_request() {
|
5018 4920 | {
|
5019 4921 | #[allow(unused_mut)]
|
5020 4922 | let mut http_request = ::http_1x::Request::builder()
|
5021 - | .uri("/MalformedPatternOverride")
|
4923 + | .uri("/MalformedRange")
|
5022 4924 | .method("POST")
|
5023 4925 | .header("content-type", "application/json")
|
5024 4926 | .body(::aws_smithy_http_server::body::boxed(
|
5025 4927 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5026 4928 | &::aws_smithy_protocol_test::decode_body_data(
|
5027 - | "{ \"union\" : { \"first\": \"abc\" } }".as_bytes(),
|
4929 + | "{ \"short\" : 1 }".as_bytes(),
|
5028 4930 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5029 4931 | ),
|
5030 4932 | )),
|
5031 4933 | ))
|
5032 4934 | .unwrap();
|
5033 4935 | #[allow(unused_mut)]
|
5034 4936 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5035 4937 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5036 4938 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5037 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4939 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5038 4940 | let sender = sender.clone();
|
5039 4941 | async move {
|
5040 - | 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> };
|
4942 + | 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> };
|
5041 4943 | sender.send(()).await.expect("receiver dropped early");
|
5042 4944 | result
|
5043 4945 | }
|
5044 4946 | })
|
5045 4947 | .build_unchecked();
|
5046 4948 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5047 4949 | .await
|
5048 4950 | .expect("unable to make an HTTP request");
|
5049 4951 | ::pretty_assertions::assert_eq!(
|
5050 4952 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5051 4953 | http_response.status()
|
5052 4954 | );
|
5053 4955 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5054 4956 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5055 4957 | http_response.headers(),
|
5056 4958 | expected_headers,
|
5057 4959 | ));
|
5058 4960 | use ::http_body_util::BodyExt;
|
5059 4961 | let body = http_response
|
5060 4962 | .into_body()
|
5061 4963 | .collect()
|
5062 4964 | .await
|
5063 4965 | .expect("unable to collect body")
|
5064 4966 | .to_bytes();
|
5065 4967 | ::aws_smithy_protocol_test::assert_ok(
|
5066 - | ::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"))
|
4968 + | ::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"))
|
5067 4969 | );
|
5068 4970 | }
|
5069 4971 | }
|
5070 4972 |
|
5071 - | /// When a union member's value does not match the specified pattern,
|
4973 + | /// When a short member does not fit within range bounds,
|
5072 4974 | /// the response should be a 400 ValidationException.
|
5073 - | /// Test ID: RestJsonMalformedPatternUnionOverride_case1
|
4975 + | /// Test ID: RestJsonMalformedRangeShort_case1
|
5074 4976 | #[::tokio::test]
|
5075 4977 | #[::tracing_test::traced_test]
|
5076 - | async fn rest_json_malformed_pattern_union_override_case1_malformed_request() {
|
4978 + | async fn rest_json_malformed_range_short_case1_malformed_request() {
|
5077 4979 | {
|
5078 4980 | #[allow(unused_mut)]
|
5079 4981 | let mut http_request = ::http_1x::Request::builder()
|
5080 - | .uri("/MalformedPatternOverride")
|
4982 + | .uri("/MalformedRange")
|
5081 4983 | .method("POST")
|
5082 4984 | .header("content-type", "application/json")
|
5083 4985 | .body(::aws_smithy_http_server::body::boxed(
|
5084 4986 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5085 4987 | &::aws_smithy_protocol_test::decode_body_data(
|
5086 - | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
4988 + | "{ \"short\" : 9 }".as_bytes(),
|
5087 4989 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5088 4990 | ),
|
5089 4991 | )),
|
5090 4992 | ))
|
5091 4993 | .unwrap();
|
5092 4994 | #[allow(unused_mut)]
|
5093 4995 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5094 4996 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5095 4997 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5096 - | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4998 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5097 4999 | let sender = sender.clone();
|
5098 5000 | async move {
|
5099 - | 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> };
|
5001 + | 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> };
|
5100 5002 | sender.send(()).await.expect("receiver dropped early");
|
5101 5003 | result
|
5102 5004 | }
|
5103 5005 | })
|
5104 5006 | .build_unchecked();
|
5105 5007 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5106 5008 | .await
|
5107 5009 | .expect("unable to make an HTTP request");
|
5108 5010 | ::pretty_assertions::assert_eq!(
|
5109 5011 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5110 5012 | http_response.status()
|
5111 5013 | );
|
5112 5014 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5113 5015 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5114 5016 | http_response.headers(),
|
5115 5017 | expected_headers,
|
5116 5018 | ));
|
5117 5019 | use ::http_body_util::BodyExt;
|
5118 5020 | let body = http_response
|
5119 5021 | .into_body()
|
5120 5022 | .collect()
|
5121 5023 | .await
|
5122 5024 | .expect("unable to collect body")
|
5123 5025 | .to_bytes();
|
5124 5026 | ::aws_smithy_protocol_test::assert_ok(
|
5125 - | ::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"))
|
5027 + | ::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"))
|
5126 5028 | );
|
5127 5029 | }
|
5128 5030 | }
|
5129 - | }
|
5130 - |
|
5131 - | ::pin_project_lite::pin_project! {
|
5132 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5133 - | /// [`MalformedPatternInput`](crate::input::MalformedPatternInput) using modelled bindings.
|
5134 - | pub struct MalformedPatternInputFuture {
|
5135 - | 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>>
|
5136 - | }
|
5137 - | }
|
5138 - |
|
5139 - | impl std::future::Future for MalformedPatternInputFuture {
|
5140 - | type Output = Result<
|
5141 - | crate::input::MalformedPatternInput,
|
5142 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5143 - | >;
|
5144 - |
|
5145 - | fn poll(
|
5146 - | self: std::pin::Pin<&mut Self>,
|
5147 - | cx: &mut std::task::Context<'_>,
|
5148 - | ) -> std::task::Poll<Self::Output> {
|
5149 - | let this = self.project();
|
5150 - | this.inner.as_mut().poll(cx)
|
5151 - | }
|
5152 - | }
|
5153 - |
|
5154 - | impl<B>
|
5155 - | ::aws_smithy_http_server::request::FromRequest<
|
5156 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5157 - | B,
|
5158 - | > for crate::input::MalformedPatternInput
|
5159 - | where
|
5160 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5161 - | B: 'static,
|
5162 - |
|
5163 - | B::Data: Send,
|
5164 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5165 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5166 - | {
|
5167 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5168 - | type Future = MalformedPatternInputFuture;
|
5169 5031 |
|
5170 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5171 - | let fut = async move {
|
5172 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5173 - | request.headers(),
|
5174 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
5175 - | ) {
|
5176 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5032 + | /// When a short member does not fit within range bounds,
|
5033 + | /// the response should be a 400 ValidationException.
|
5034 + | /// Test ID: RestJsonMalformedRangeMinShort
|
5035 + | #[::tokio::test]
|
5036 + | #[::tracing_test::traced_test]
|
5037 + | async fn rest_json_malformed_range_min_short_malformed_request() {
|
5038 + | {
|
5039 + | #[allow(unused_mut)]
|
5040 + | let mut http_request = ::http_1x::Request::builder()
|
5041 + | .uri("/MalformedRange")
|
5042 + | .method("POST")
|
5043 + | .header("content-type", "application/json")
|
5044 + | .body(::aws_smithy_http_server::body::boxed(
|
5045 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5046 + | &::aws_smithy_protocol_test::decode_body_data(
|
5047 + | "{ \"minShort\" : 1 }".as_bytes(),
|
5048 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5049 + | ),
|
5050 + | )),
|
5051 + | ))
|
5052 + | .unwrap();
|
5053 + | #[allow(unused_mut)]
|
5054 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5055 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5056 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5057 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5058 + | let sender = sender.clone();
|
5059 + | async move {
|
5060 + | 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> };
|
5061 + | sender.send(()).await.expect("receiver dropped early");
|
5062 + | result
|
5177 5063 | }
|
5178 - | crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern_http_request(
|
5179 - | request,
|
5180 - | )
|
5064 + | })
|
5065 + | .build_unchecked();
|
5066 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5181 5067 | .await
|
5182 - | };
|
5183 - | use ::futures_util::future::TryFutureExt;
|
5184 - | let fut = fut.map_err(
|
5185 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5186 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5187 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
5188 - | e,
|
5189 - | )
|
5190 - | },
|
5068 + | .expect("unable to make an HTTP request");
|
5069 + | ::pretty_assertions::assert_eq!(
|
5070 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5071 + | http_response.status()
|
5072 + | );
|
5073 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5074 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5075 + | http_response.headers(),
|
5076 + | expected_headers,
|
5077 + | ));
|
5078 + | use ::http_body_util::BodyExt;
|
5079 + | let body = http_response
|
5080 + | .into_body()
|
5081 + | .collect()
|
5082 + | .await
|
5083 + | .expect("unable to collect body")
|
5084 + | .to_bytes();
|
5085 + | ::aws_smithy_protocol_test::assert_ok(
|
5086 + | ::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"))
|
5191 5087 | );
|
5192 - | MalformedPatternInputFuture {
|
5193 - | inner: Box::pin(fut),
|
5194 5088 | }
|
5195 5089 | }
|
5196 - | }
|
5197 - | impl
|
5198 - | ::aws_smithy_http_server::response::IntoResponse<
|
5199 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5200 - | > for crate::output::MalformedPatternOutput
|
5201 - | {
|
5202 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5203 - | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_response(
|
5204 - | self,
|
5205 - | ) {
|
5206 - | Ok(response) => response,
|
5207 - | Err(e) => {
|
5208 - | ::tracing::error!(error = %e, "failed to serialize response");
|
5209 - | ::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))
|
5210 - | }
|
5211 - | }
|
5212 - | }
|
5213 - | }
|
5214 - | impl
|
5215 - | ::aws_smithy_http_server::response::IntoResponse<
|
5216 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5217 - | > for crate::error::MalformedPatternError
|
5218 - | {
|
5219 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5220 - | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_error(
|
5221 - | &self,
|
5222 - | ) {
|
5223 - | Ok(mut response) => {
|
5224 - | response.extensions_mut().insert(
|
5225 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
5226 - | );
|
5227 - | response
|
5228 - | }
|
5229 - | Err(e) => {
|
5230 - | ::tracing::error!(error = %e, "failed to serialize response");
|
5231 - | ::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))
|
5232 - | }
|
5233 - | }
|
5234 - | }
|
5235 - | }
|
5236 - |
|
5237 - | #[allow(unreachable_code, unused_variables)]
|
5238 - | #[cfg(test)]
|
5239 - | mod malformed_pattern_test {
|
5240 5090 |
|
5241 - | /// When a string member does not match the specified pattern,
|
5091 + | /// When a short member does not fit within range bounds,
|
5242 5092 | /// the response should be a 400 ValidationException.
|
5243 - | /// Test ID: RestJsonMalformedPatternString_case0
|
5093 + | /// Test ID: RestJsonMalformedRangeMaxShort
|
5244 5094 | #[::tokio::test]
|
5245 5095 | #[::tracing_test::traced_test]
|
5246 - | async fn rest_json_malformed_pattern_string_case0_malformed_request() {
|
5096 + | async fn rest_json_malformed_range_max_short_malformed_request() {
|
5247 5097 | {
|
5248 5098 | #[allow(unused_mut)]
|
5249 5099 | let mut http_request = ::http_1x::Request::builder()
|
5250 - | .uri("/MalformedPattern")
|
5100 + | .uri("/MalformedRange")
|
5251 5101 | .method("POST")
|
5252 5102 | .header("content-type", "application/json")
|
5253 5103 | .body(::aws_smithy_http_server::body::boxed(
|
5254 5104 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5255 5105 | &::aws_smithy_protocol_test::decode_body_data(
|
5256 - | "{ \"string\" : \"ABC\" }".as_bytes(),
|
5106 + | "{ \"maxShort\" : 9 }".as_bytes(),
|
5257 5107 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5258 5108 | ),
|
5259 5109 | )),
|
5260 5110 | ))
|
5261 5111 | .unwrap();
|
5262 5112 | #[allow(unused_mut)]
|
5263 5113 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5264 5114 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5265 5115 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5266 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5116 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5267 5117 | let sender = sender.clone();
|
5268 5118 | async move {
|
5269 - | 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> };
|
5119 + | 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> };
|
5270 5120 | sender.send(()).await.expect("receiver dropped early");
|
5271 5121 | result
|
5272 5122 | }
|
5273 5123 | })
|
5274 5124 | .build_unchecked();
|
5275 5125 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5276 5126 | .await
|
5277 5127 | .expect("unable to make an HTTP request");
|
5278 5128 | ::pretty_assertions::assert_eq!(
|
5279 5129 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5280 5130 | http_response.status()
|
5281 5131 | );
|
5282 5132 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5283 5133 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5284 5134 | http_response.headers(),
|
5285 5135 | expected_headers,
|
5286 5136 | ));
|
5287 5137 | use ::http_body_util::BodyExt;
|
5288 5138 | let body = http_response
|
5289 5139 | .into_body()
|
5290 5140 | .collect()
|
5291 5141 | .await
|
5292 5142 | .expect("unable to collect body")
|
5293 5143 | .to_bytes();
|
5294 5144 | ::aws_smithy_protocol_test::assert_ok(
|
5295 - | ::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"))
|
5145 + | ::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"))
|
5296 5146 | );
|
5297 5147 | }
|
5298 5148 | }
|
5299 5149 |
|
5300 - | /// When a string member does not match the specified pattern,
|
5150 + | /// When a integer member does not fit within range bounds,
|
5301 5151 | /// the response should be a 400 ValidationException.
|
5302 - | /// Test ID: RestJsonMalformedPatternString_case1
|
5152 + | /// Test ID: RestJsonMalformedRangeInteger_case0
|
5303 5153 | #[::tokio::test]
|
5304 5154 | #[::tracing_test::traced_test]
|
5305 - | async fn rest_json_malformed_pattern_string_case1_malformed_request() {
|
5155 + | async fn rest_json_malformed_range_integer_case0_malformed_request() {
|
5306 5156 | {
|
5307 5157 | #[allow(unused_mut)]
|
5308 5158 | let mut http_request = ::http_1x::Request::builder()
|
5309 - | .uri("/MalformedPattern")
|
5159 + | .uri("/MalformedRange")
|
5310 5160 | .method("POST")
|
5311 5161 | .header("content-type", "application/json")
|
5312 5162 | .body(::aws_smithy_http_server::body::boxed(
|
5313 5163 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5314 5164 | &::aws_smithy_protocol_test::decode_body_data(
|
5315 - | "{ \"string\" : \"xyz\" }".as_bytes(),
|
5165 + | "{ \"integer\" : 1 }".as_bytes(),
|
5316 5166 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5317 5167 | ),
|
5318 5168 | )),
|
5319 5169 | ))
|
5320 5170 | .unwrap();
|
5321 5171 | #[allow(unused_mut)]
|
5322 5172 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5323 5173 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5324 5174 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5325 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5326 - | let sender = sender.clone();
|
5327 - | async move {
|
5328 - | 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> };
|
5329 - | sender.send(()).await.expect("receiver dropped early");
|
5330 - | result
|
5331 - | }
|
5332 - | })
|
5333 - | .build_unchecked();
|
5334 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5335 - | .await
|
5336 - | .expect("unable to make an HTTP request");
|
5337 - | ::pretty_assertions::assert_eq!(
|
5338 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5339 - | http_response.status()
|
5340 - | );
|
5341 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5342 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5343 - | http_response.headers(),
|
5344 - | expected_headers,
|
5345 - | ));
|
5346 - | use ::http_body_util::BodyExt;
|
5347 - | let body = http_response
|
5348 - | .into_body()
|
5349 - | .collect()
|
5350 - | .await
|
5351 - | .expect("unable to collect body")
|
5352 - | .to_bytes();
|
5353 - | ::aws_smithy_protocol_test::assert_ok(
|
5354 - | ::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"))
|
5355 - | );
|
5356 - | }
|
5357 - | }
|
5358 - |
|
5359 - | /// When the specified pattern is susceptible to ReDOS, the service will not
|
5360 - | /// hang indefinitely while evaluating the pattern
|
5361 - | /// Test ID: RestJsonMalformedPatternReDOSString
|
5362 - | #[::tokio::test]
|
5363 - | #[::tracing_test::traced_test]
|
5364 - | #[should_panic]
|
5365 - | async fn rest_json_malformed_pattern_re_dos_string_malformed_request() {
|
5366 - | {
|
5367 - | #[allow(unused_mut)]
|
5368 - | let mut http_request = ::http_1x::Request::builder()
|
5369 - | .uri("/MalformedPattern")
|
5370 - | .method("POST")
|
5371 - | .header("content-type", "application/json")
|
5372 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
5373 - | ::bytes::Bytes::copy_from_slice(
|
5374 - | &::aws_smithy_protocol_test::decode_body_data("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
5375 - | )
|
5376 - | ))).unwrap();
|
5377 - | #[allow(unused_mut)]
|
5378 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5379 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5380 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5381 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5175 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5382 5176 | let sender = sender.clone();
|
5383 5177 | async move {
|
5384 - | 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> };
|
5178 + | 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> };
|
5385 5179 | sender.send(()).await.expect("receiver dropped early");
|
5386 5180 | result
|
5387 5181 | }
|
5388 5182 | })
|
5389 5183 | .build_unchecked();
|
5390 5184 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5391 5185 | .await
|
5392 5186 | .expect("unable to make an HTTP request");
|
5393 5187 | ::pretty_assertions::assert_eq!(
|
5394 5188 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5395 5189 | http_response.status()
|
5396 5190 | );
|
5397 5191 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5398 5192 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5399 5193 | http_response.headers(),
|
5400 5194 | expected_headers,
|
5401 5195 | ));
|
5402 5196 | use ::http_body_util::BodyExt;
|
5403 5197 | let body = http_response
|
5404 5198 | .into_body()
|
5405 5199 | .collect()
|
5406 5200 | .await
|
5407 5201 | .expect("unable to collect body")
|
5408 5202 | .to_bytes();
|
5409 5203 | ::aws_smithy_protocol_test::assert_ok(
|
5410 - | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$$\",\n \"fieldList\" : [{\"message\": \"Value at '/evilString' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$$\", \"path\": \"/evilString\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
5204 + | ::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"))
|
5411 5205 | );
|
5412 5206 | }
|
5413 5207 | }
|
5414 5208 |
|
5415 - | /// When the specified pattern is susceptible to ReDOS, the service will not
|
5416 - | /// hang indefinitely while evaluating the pattern
|
5417 - | /// Test ID: RestJsonMalformedPatternReDOSString_hotfixed
|
5209 + | /// When a integer member does not fit within range bounds,
|
5210 + | /// the response should be a 400 ValidationException.
|
5211 + | /// Test ID: RestJsonMalformedRangeInteger_case1
|
5418 5212 | #[::tokio::test]
|
5419 5213 | #[::tracing_test::traced_test]
|
5420 - | async fn rest_json_malformed_pattern_re_dos_string_hotfixed_malformed_request() {
|
5214 + | async fn rest_json_malformed_range_integer_case1_malformed_request() {
|
5421 5215 | {
|
5422 5216 | #[allow(unused_mut)]
|
5423 5217 | let mut http_request = ::http_1x::Request::builder()
|
5424 - | .uri("/MalformedPattern")
|
5218 + | .uri("/MalformedRange")
|
5425 5219 | .method("POST")
|
5426 5220 | .header("content-type", "application/json")
|
5427 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
5428 - | ::bytes::Bytes::copy_from_slice(
|
5429 - | &::aws_smithy_protocol_test::decode_body_data("{ \"evilString\" : \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000!\" }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
5430 - | )
|
5431 - | ))).unwrap();
|
5221 + | .body(::aws_smithy_http_server::body::boxed(
|
5222 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5223 + | &::aws_smithy_protocol_test::decode_body_data(
|
5224 + | "{ \"integer\" : 9 }".as_bytes(),
|
5225 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5226 + | ),
|
5227 + | )),
|
5228 + | ))
|
5229 + | .unwrap();
|
5432 5230 | #[allow(unused_mut)]
|
5433 5231 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5434 5232 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5435 5233 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5436 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5234 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5437 5235 | let sender = sender.clone();
|
5438 5236 | async move {
|
5439 - | 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> };
|
5237 + | 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> };
|
5440 5238 | sender.send(()).await.expect("receiver dropped early");
|
5441 5239 | result
|
5442 5240 | }
|
5443 5241 | })
|
5444 5242 | .build_unchecked();
|
5445 5243 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5446 5244 | .await
|
5447 5245 | .expect("unable to make an HTTP request");
|
5448 5246 | ::pretty_assertions::assert_eq!(
|
5449 5247 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5450 5248 | http_response.status()
|
5451 5249 | );
|
5452 5250 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5453 5251 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5454 5252 | http_response.headers(),
|
5455 5253 | expected_headers,
|
5456 5254 | ));
|
5457 5255 | use ::http_body_util::BodyExt;
|
5458 5256 | let body = http_response
|
5459 5257 | .into_body()
|
5460 5258 | .collect()
|
5461 5259 | .await
|
5462 5260 | .expect("unable to collect body")
|
5463 5261 | .to_bytes();
|
5464 5262 | ::aws_smithy_protocol_test::assert_ok(
|
5465 - | ::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"))
|
5263 + | ::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"))
|
5466 5264 | );
|
5467 5265 | }
|
5468 5266 | }
|
5469 5267 |
|
5470 - | /// When a list member value does not match the specified pattern,
|
5268 + | /// When a integer member does not fit within range bounds,
|
5471 5269 | /// the response should be a 400 ValidationException.
|
5472 - | /// Test ID: RestJsonMalformedPatternList_case0
|
5270 + | /// Test ID: RestJsonMalformedRangeMinInteger
|
5473 5271 | #[::tokio::test]
|
5474 5272 | #[::tracing_test::traced_test]
|
5475 - | async fn rest_json_malformed_pattern_list_case0_malformed_request() {
|
5273 + | async fn rest_json_malformed_range_min_integer_malformed_request() {
|
5476 5274 | {
|
5477 5275 | #[allow(unused_mut)]
|
5478 5276 | let mut http_request = ::http_1x::Request::builder()
|
5479 - | .uri("/MalformedPattern")
|
5277 + | .uri("/MalformedRange")
|
5480 5278 | .method("POST")
|
5481 5279 | .header("content-type", "application/json")
|
5482 5280 | .body(::aws_smithy_http_server::body::boxed(
|
5483 5281 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5484 5282 | &::aws_smithy_protocol_test::decode_body_data(
|
5485 - | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
5283 + | "{ \"minInteger\" : 1 }".as_bytes(),
|
5486 5284 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5487 5285 | ),
|
5488 5286 | )),
|
5489 5287 | ))
|
5490 5288 | .unwrap();
|
5491 5289 | #[allow(unused_mut)]
|
5492 5290 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5493 5291 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5494 5292 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5495 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5293 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5496 5294 | let sender = sender.clone();
|
5497 5295 | async move {
|
5498 - | 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> };
|
5296 + | 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> };
|
5499 5297 | sender.send(()).await.expect("receiver dropped early");
|
5500 5298 | result
|
5501 5299 | }
|
5502 5300 | })
|
5503 5301 | .build_unchecked();
|
5504 5302 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5505 5303 | .await
|
5506 5304 | .expect("unable to make an HTTP request");
|
5507 5305 | ::pretty_assertions::assert_eq!(
|
5508 5306 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5509 5307 | http_response.status()
|
5510 5308 | );
|
5511 5309 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5512 5310 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5513 5311 | http_response.headers(),
|
5514 5312 | expected_headers,
|
5515 5313 | ));
|
5516 5314 | use ::http_body_util::BodyExt;
|
5517 5315 | let body = http_response
|
5518 5316 | .into_body()
|
5519 5317 | .collect()
|
5520 5318 | .await
|
5521 5319 | .expect("unable to collect body")
|
5522 5320 | .to_bytes();
|
5523 5321 | ::aws_smithy_protocol_test::assert_ok(
|
5524 - | ::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"))
|
5322 + | ::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"))
|
5525 5323 | );
|
5526 5324 | }
|
5527 5325 | }
|
5528 5326 |
|
5529 - | /// When a list member value does not match the specified pattern,
|
5327 + | /// When a integer member does not fit within range bounds,
|
5530 5328 | /// the response should be a 400 ValidationException.
|
5531 - | /// Test ID: RestJsonMalformedPatternList_case1
|
5329 + | /// Test ID: RestJsonMalformedRangeMaxInteger
|
5532 5330 | #[::tokio::test]
|
5533 5331 | #[::tracing_test::traced_test]
|
5534 - | async fn rest_json_malformed_pattern_list_case1_malformed_request() {
|
5332 + | async fn rest_json_malformed_range_max_integer_malformed_request() {
|
5535 5333 | {
|
5536 5334 | #[allow(unused_mut)]
|
5537 5335 | let mut http_request = ::http_1x::Request::builder()
|
5538 - | .uri("/MalformedPattern")
|
5336 + | .uri("/MalformedRange")
|
5539 5337 | .method("POST")
|
5540 5338 | .header("content-type", "application/json")
|
5541 5339 | .body(::aws_smithy_http_server::body::boxed(
|
5542 5340 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5543 5341 | &::aws_smithy_protocol_test::decode_body_data(
|
5544 - | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
5342 + | "{ \"maxInteger\" : 9 }".as_bytes(),
|
5545 5343 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5546 5344 | ),
|
5547 5345 | )),
|
5548 5346 | ))
|
5549 5347 | .unwrap();
|
5550 5348 | #[allow(unused_mut)]
|
5551 5349 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5552 5350 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5553 5351 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5554 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5352 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5555 5353 | let sender = sender.clone();
|
5556 5354 | async move {
|
5557 - | 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> };
|
5355 + | 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> };
|
5558 5356 | sender.send(()).await.expect("receiver dropped early");
|
5559 5357 | result
|
5560 5358 | }
|
5561 5359 | })
|
5562 5360 | .build_unchecked();
|
5563 5361 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5564 5362 | .await
|
5565 5363 | .expect("unable to make an HTTP request");
|
5566 5364 | ::pretty_assertions::assert_eq!(
|
5567 5365 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5568 5366 | http_response.status()
|
5569 5367 | );
|
5570 5368 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5571 5369 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5572 5370 | http_response.headers(),
|
5573 5371 | expected_headers,
|
5574 5372 | ));
|
5575 5373 | use ::http_body_util::BodyExt;
|
5576 5374 | let body = http_response
|
5577 5375 | .into_body()
|
5578 5376 | .collect()
|
5579 5377 | .await
|
5580 5378 | .expect("unable to collect body")
|
5581 5379 | .to_bytes();
|
5582 5380 | ::aws_smithy_protocol_test::assert_ok(
|
5583 - | ::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"))
|
5381 + | ::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"))
|
5584 5382 | );
|
5585 5383 | }
|
5586 5384 | }
|
5587 5385 |
|
5588 - | /// When a map member's key does not match the specified pattern,
|
5386 + | /// When a long member does not fit within range bounds,
|
5589 5387 | /// the response should be a 400 ValidationException.
|
5590 - | /// Test ID: RestJsonMalformedPatternMapKey_case0
|
5388 + | /// Test ID: RestJsonMalformedRangeLong_case0
|
5591 5389 | #[::tokio::test]
|
5592 5390 | #[::tracing_test::traced_test]
|
5593 - | async fn rest_json_malformed_pattern_map_key_case0_malformed_request() {
|
5391 + | async fn rest_json_malformed_range_long_case0_malformed_request() {
|
5594 5392 | {
|
5595 5393 | #[allow(unused_mut)]
|
5596 5394 | let mut http_request = ::http_1x::Request::builder()
|
5597 - | .uri("/MalformedPattern")
|
5395 + | .uri("/MalformedRange")
|
5598 5396 | .method("POST")
|
5599 5397 | .header("content-type", "application/json")
|
5600 5398 | .body(::aws_smithy_http_server::body::boxed(
|
5601 5399 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5602 5400 | &::aws_smithy_protocol_test::decode_body_data(
|
5603 - | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
5401 + | "{ \"long\" : 1 }".as_bytes(),
|
5604 5402 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5605 5403 | ),
|
5606 5404 | )),
|
5607 5405 | ))
|
5608 5406 | .unwrap();
|
5609 5407 | #[allow(unused_mut)]
|
5610 5408 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5611 5409 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5612 5410 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5613 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5411 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5614 5412 | let sender = sender.clone();
|
5615 5413 | async move {
|
5616 - | 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> };
|
5414 + | 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> };
|
5617 5415 | sender.send(()).await.expect("receiver dropped early");
|
5618 5416 | result
|
5619 5417 | }
|
5620 5418 | })
|
5621 5419 | .build_unchecked();
|
5622 5420 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5623 5421 | .await
|
5624 5422 | .expect("unable to make an HTTP request");
|
5625 5423 | ::pretty_assertions::assert_eq!(
|
5626 5424 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5627 5425 | http_response.status()
|
5628 5426 | );
|
5629 5427 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5630 5428 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5631 5429 | http_response.headers(),
|
5632 5430 | expected_headers,
|
5633 5431 | ));
|
5634 5432 | use ::http_body_util::BodyExt;
|
5635 5433 | let body = http_response
|
5636 5434 | .into_body()
|
5637 5435 | .collect()
|
5638 5436 | .await
|
5639 5437 | .expect("unable to collect body")
|
5640 5438 | .to_bytes();
|
5641 5439 | ::aws_smithy_protocol_test::assert_ok(
|
5642 - | ::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"))
|
5440 + | ::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"))
|
5643 5441 | );
|
5644 5442 | }
|
5645 5443 | }
|
5646 5444 |
|
5647 - | /// When a map member's key does not match the specified pattern,
|
5445 + | /// When a long member does not fit within range bounds,
|
5648 5446 | /// the response should be a 400 ValidationException.
|
5649 - | /// Test ID: RestJsonMalformedPatternMapKey_case1
|
5447 + | /// Test ID: RestJsonMalformedRangeLong_case1
|
5650 5448 | #[::tokio::test]
|
5651 5449 | #[::tracing_test::traced_test]
|
5652 - | async fn rest_json_malformed_pattern_map_key_case1_malformed_request() {
|
5450 + | async fn rest_json_malformed_range_long_case1_malformed_request() {
|
5653 5451 | {
|
5654 5452 | #[allow(unused_mut)]
|
5655 5453 | let mut http_request = ::http_1x::Request::builder()
|
5656 - | .uri("/MalformedPattern")
|
5454 + | .uri("/MalformedRange")
|
5657 5455 | .method("POST")
|
5658 5456 | .header("content-type", "application/json")
|
5659 5457 | .body(::aws_smithy_http_server::body::boxed(
|
5660 5458 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5661 5459 | &::aws_smithy_protocol_test::decode_body_data(
|
5662 - | "{ \"map\" : { \"xyz\" : \"abc\" } }".as_bytes(),
|
5460 + | "{ \"long\" : 9 }".as_bytes(),
|
5663 5461 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5664 5462 | ),
|
5665 5463 | )),
|
5666 5464 | ))
|
5667 5465 | .unwrap();
|
5668 5466 | #[allow(unused_mut)]
|
5669 5467 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5670 5468 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5671 5469 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5672 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5470 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5673 5471 | let sender = sender.clone();
|
5674 5472 | async move {
|
5675 - | 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> };
|
5473 + | 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> };
|
5676 5474 | sender.send(()).await.expect("receiver dropped early");
|
5677 5475 | result
|
5678 5476 | }
|
5679 5477 | })
|
5680 5478 | .build_unchecked();
|
5681 5479 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5682 5480 | .await
|
5683 5481 | .expect("unable to make an HTTP request");
|
5684 5482 | ::pretty_assertions::assert_eq!(
|
5685 5483 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5686 5484 | http_response.status()
|
5687 5485 | );
|
5688 5486 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5689 5487 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5690 5488 | http_response.headers(),
|
5691 5489 | expected_headers,
|
5692 5490 | ));
|
5693 5491 | use ::http_body_util::BodyExt;
|
5694 5492 | let body = http_response
|
5695 5493 | .into_body()
|
5696 5494 | .collect()
|
5697 5495 | .await
|
5698 5496 | .expect("unable to collect body")
|
5699 5497 | .to_bytes();
|
5700 5498 | ::aws_smithy_protocol_test::assert_ok(
|
5701 - | ::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"))
|
5499 + | ::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"))
|
5702 5500 | );
|
5703 5501 | }
|
5704 5502 | }
|
5705 5503 |
|
5706 - | /// When a map member's value does not match the specified pattern,
|
5504 + | /// When a long member does not fit within range bounds,
|
5707 5505 | /// the response should be a 400 ValidationException.
|
5708 - | /// Test ID: RestJsonMalformedPatternMapValue_case0
|
5506 + | /// Test ID: RestJsonMalformedRangeMinLong
|
5709 5507 | #[::tokio::test]
|
5710 5508 | #[::tracing_test::traced_test]
|
5711 - | async fn rest_json_malformed_pattern_map_value_case0_malformed_request() {
|
5509 + | async fn rest_json_malformed_range_min_long_malformed_request() {
|
5712 5510 | {
|
5713 5511 | #[allow(unused_mut)]
|
5714 5512 | let mut http_request = ::http_1x::Request::builder()
|
5715 - | .uri("/MalformedPattern")
|
5513 + | .uri("/MalformedRange")
|
5716 5514 | .method("POST")
|
5717 5515 | .header("content-type", "application/json")
|
5718 5516 | .body(::aws_smithy_http_server::body::boxed(
|
5719 5517 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5720 5518 | &::aws_smithy_protocol_test::decode_body_data(
|
5721 - | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
5519 + | "{ \"minLong\" : 1 }".as_bytes(),
|
5722 5520 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5723 5521 | ),
|
5724 5522 | )),
|
5725 5523 | ))
|
5726 5524 | .unwrap();
|
5727 5525 | #[allow(unused_mut)]
|
5728 5526 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5729 5527 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5730 5528 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5731 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5529 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5732 5530 | let sender = sender.clone();
|
5733 5531 | async move {
|
5734 - | 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> };
|
5532 + | 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> };
|
5735 5533 | sender.send(()).await.expect("receiver dropped early");
|
5736 5534 | result
|
5737 5535 | }
|
5738 5536 | })
|
5739 5537 | .build_unchecked();
|
5740 5538 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5741 5539 | .await
|
5742 5540 | .expect("unable to make an HTTP request");
|
5743 5541 | ::pretty_assertions::assert_eq!(
|
5744 5542 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5745 5543 | http_response.status()
|
5746 5544 | );
|
5747 5545 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5748 5546 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5749 5547 | http_response.headers(),
|
5750 5548 | expected_headers,
|
5751 5549 | ));
|
5752 5550 | use ::http_body_util::BodyExt;
|
5753 5551 | let body = http_response
|
5754 5552 | .into_body()
|
5755 5553 | .collect()
|
5756 5554 | .await
|
5757 5555 | .expect("unable to collect body")
|
5758 5556 | .to_bytes();
|
5759 5557 | ::aws_smithy_protocol_test::assert_ok(
|
5760 - | ::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"))
|
5558 + | ::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"))
|
5761 5559 | );
|
5762 5560 | }
|
5763 5561 | }
|
5764 5562 |
|
5765 - | /// When a map member's value does not match the specified pattern,
|
5563 + | /// When a long member does not fit within range bounds,
|
5766 5564 | /// the response should be a 400 ValidationException.
|
5767 - | /// Test ID: RestJsonMalformedPatternMapValue_case1
|
5565 + | /// Test ID: RestJsonMalformedRangeMaxLong
|
5768 5566 | #[::tokio::test]
|
5769 5567 | #[::tracing_test::traced_test]
|
5770 - | async fn rest_json_malformed_pattern_map_value_case1_malformed_request() {
|
5568 + | async fn rest_json_malformed_range_max_long_malformed_request() {
|
5771 5569 | {
|
5772 5570 | #[allow(unused_mut)]
|
5773 5571 | let mut http_request = ::http_1x::Request::builder()
|
5774 - | .uri("/MalformedPattern")
|
5572 + | .uri("/MalformedRange")
|
5775 5573 | .method("POST")
|
5776 5574 | .header("content-type", "application/json")
|
5777 5575 | .body(::aws_smithy_http_server::body::boxed(
|
5778 5576 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5779 5577 | &::aws_smithy_protocol_test::decode_body_data(
|
5780 - | "{ \"map\" : { \"abc\": \"xyz\" } }".as_bytes(),
|
5578 + | "{ \"maxLong\" : 9 }".as_bytes(),
|
5781 5579 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5782 5580 | ),
|
5783 5581 | )),
|
5784 5582 | ))
|
5785 5583 | .unwrap();
|
5786 5584 | #[allow(unused_mut)]
|
5787 5585 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5788 5586 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5789 5587 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5790 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5588 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5791 5589 | let sender = sender.clone();
|
5792 5590 | async move {
|
5793 - | 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> };
|
5591 + | 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> };
|
5794 5592 | sender.send(()).await.expect("receiver dropped early");
|
5795 5593 | result
|
5796 5594 | }
|
5797 5595 | })
|
5798 5596 | .build_unchecked();
|
5799 5597 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5800 5598 | .await
|
5801 5599 | .expect("unable to make an HTTP request");
|
5802 5600 | ::pretty_assertions::assert_eq!(
|
5803 5601 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5804 5602 | http_response.status()
|
5805 5603 | );
|
5806 5604 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5807 5605 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5808 5606 | http_response.headers(),
|
5809 5607 | expected_headers,
|
5810 5608 | ));
|
5811 5609 | use ::http_body_util::BodyExt;
|
5812 5610 | let body = http_response
|
5813 5611 | .into_body()
|
5814 5612 | .collect()
|
5815 5613 | .await
|
5816 5614 | .expect("unable to collect body")
|
5817 5615 | .to_bytes();
|
5818 5616 | ::aws_smithy_protocol_test::assert_ok(
|
5819 - | ::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"))
|
5617 + | ::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"))
|
5820 5618 | );
|
5821 5619 | }
|
5822 5620 | }
|
5621 + | }
|
5823 5622 |
|
5824 - | /// When a union member's value does not match the specified pattern,
|
5623 + | ::pin_project_lite::pin_project! {
|
5624 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5625 + | /// [`MalformedRangeOverrideInput`](crate::input::MalformedRangeOverrideInput) using modelled bindings.
|
5626 + | pub struct MalformedRangeOverrideInputFuture {
|
5627 + | 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>>
|
5628 + | }
|
5629 + | }
|
5630 + |
|
5631 + | impl std::future::Future for MalformedRangeOverrideInputFuture {
|
5632 + | type Output = Result<
|
5633 + | crate::input::MalformedRangeOverrideInput,
|
5634 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5635 + | >;
|
5636 + |
|
5637 + | fn poll(
|
5638 + | self: std::pin::Pin<&mut Self>,
|
5639 + | cx: &mut std::task::Context<'_>,
|
5640 + | ) -> std::task::Poll<Self::Output> {
|
5641 + | let this = self.project();
|
5642 + | this.inner.as_mut().poll(cx)
|
5643 + | }
|
5644 + | }
|
5645 + |
|
5646 + | impl<B>
|
5647 + | ::aws_smithy_http_server::request::FromRequest<
|
5648 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5649 + | B,
|
5650 + | > for crate::input::MalformedRangeOverrideInput
|
5651 + | where
|
5652 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5653 + | B: 'static,
|
5654 + |
|
5655 + | B::Data: Send,
|
5656 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5657 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5658 + | {
|
5659 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5660 + | type Future = MalformedRangeOverrideInputFuture;
|
5661 + |
|
5662 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5663 + | let fut = async move {
|
5664 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5665 + | request.headers(),
|
5666 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
5667 + | ) {
|
5668 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5669 + | }
|
5670 + | crate::protocol_serde::shape_malformed_range_override::de_malformed_range_override_http_request(request)
|
5671 + | .await
|
5672 + | };
|
5673 + | use ::futures_util::future::TryFutureExt;
|
5674 + | let fut = fut.map_err(
|
5675 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5676 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5677 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
5678 + | e,
|
5679 + | )
|
5680 + | },
|
5681 + | );
|
5682 + | MalformedRangeOverrideInputFuture {
|
5683 + | inner: Box::pin(fut),
|
5684 + | }
|
5685 + | }
|
5686 + | }
|
5687 + | impl
|
5688 + | ::aws_smithy_http_server::response::IntoResponse<
|
5689 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5690 + | > for crate::output::MalformedRangeOverrideOutput
|
5691 + | {
|
5692 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5693 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_response(self) {
|
5694 + | Ok(response) => response,
|
5695 + | Err(e) => {
|
5696 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5697 + | ::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))
|
5698 + | }
|
5699 + | }
|
5700 + | }
|
5701 + | }
|
5702 + | impl
|
5703 + | ::aws_smithy_http_server::response::IntoResponse<
|
5704 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5705 + | > for crate::error::MalformedRangeOverrideError
|
5706 + | {
|
5707 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
5708 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_error(&self) {
|
5709 + | Ok(mut response) => {
|
5710 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
5711 + | response
|
5712 + | },
|
5713 + | Err(e) => {
|
5714 + | ::tracing::error!(error = %e, "failed to serialize response");
|
5715 + | ::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))
|
5716 + | }
|
5717 + | }
|
5718 + | }
|
5719 + | }
|
5720 + |
|
5721 + | #[allow(unreachable_code, unused_variables)]
|
5722 + | #[cfg(test)]
|
5723 + | mod malformed_range_override_test {
|
5724 + |
|
5725 + | /// When a byte member does not fit within range bounds,
|
5825 5726 | /// the response should be a 400 ValidationException.
|
5826 - | /// Test ID: RestJsonMalformedPatternUnion_case0
|
5727 + | /// Test ID: RestJsonMalformedRangeByteOverride_case0
|
5827 5728 | #[::tokio::test]
|
5828 5729 | #[::tracing_test::traced_test]
|
5829 - | async fn rest_json_malformed_pattern_union_case0_malformed_request() {
|
5730 + | async fn rest_json_malformed_range_byte_override_case0_malformed_request() {
|
5830 5731 | {
|
5831 5732 | #[allow(unused_mut)]
|
5832 5733 | let mut http_request = ::http_1x::Request::builder()
|
5833 - | .uri("/MalformedPattern")
|
5734 + | .uri("/MalformedRangeOverride")
|
5834 5735 | .method("POST")
|
5835 5736 | .header("content-type", "application/json")
|
5836 5737 | .body(::aws_smithy_http_server::body::boxed(
|
5837 5738 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5838 5739 | &::aws_smithy_protocol_test::decode_body_data(
|
5839 - | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
5740 + | "{ \"byte\" : 3 }".as_bytes(),
|
5840 5741 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5841 5742 | ),
|
5842 5743 | )),
|
5843 5744 | ))
|
5844 5745 | .unwrap();
|
5845 5746 | #[allow(unused_mut)]
|
5846 5747 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5847 5748 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5848 5749 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5849 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5750 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5850 5751 | let sender = sender.clone();
|
5851 5752 | async move {
|
5852 - | 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> };
|
5753 + | 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> };
|
5853 5754 | sender.send(()).await.expect("receiver dropped early");
|
5854 5755 | result
|
5855 5756 | }
|
5856 5757 | })
|
5857 5758 | .build_unchecked();
|
5858 5759 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5859 5760 | .await
|
5860 5761 | .expect("unable to make an HTTP request");
|
5861 5762 | ::pretty_assertions::assert_eq!(
|
5862 5763 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5863 5764 | http_response.status()
|
5864 5765 | );
|
5865 5766 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5866 5767 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5867 5768 | http_response.headers(),
|
5868 5769 | expected_headers,
|
5869 5770 | ));
|
5870 5771 | use ::http_body_util::BodyExt;
|
5871 5772 | let body = http_response
|
5872 5773 | .into_body()
|
5873 5774 | .collect()
|
5874 5775 | .await
|
5875 5776 | .expect("unable to collect body")
|
5876 5777 | .to_bytes();
|
5877 5778 | ::aws_smithy_protocol_test::assert_ok(
|
5878 - | ::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"))
|
5779 + | ::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"))
|
5879 5780 | );
|
5880 5781 | }
|
5881 5782 | }
|
5882 5783 |
|
5883 - | /// When a union member's value does not match the specified pattern,
|
5784 + | /// When a byte member does not fit within range bounds,
|
5884 5785 | /// the response should be a 400 ValidationException.
|
5885 - | /// Test ID: RestJsonMalformedPatternUnion_case1
|
5786 + | /// Test ID: RestJsonMalformedRangeByteOverride_case1
|
5886 5787 | #[::tokio::test]
|
5887 5788 | #[::tracing_test::traced_test]
|
5888 - | async fn rest_json_malformed_pattern_union_case1_malformed_request() {
|
5789 + | async fn rest_json_malformed_range_byte_override_case1_malformed_request() {
|
5889 5790 | {
|
5890 5791 | #[allow(unused_mut)]
|
5891 5792 | let mut http_request = ::http_1x::Request::builder()
|
5892 - | .uri("/MalformedPattern")
|
5793 + | .uri("/MalformedRangeOverride")
|
5893 5794 | .method("POST")
|
5894 5795 | .header("content-type", "application/json")
|
5895 5796 | .body(::aws_smithy_http_server::body::boxed(
|
5896 5797 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5897 5798 | &::aws_smithy_protocol_test::decode_body_data(
|
5898 - | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
5799 + | "{ \"byte\" : 7 }".as_bytes(),
|
5899 5800 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5900 5801 | ),
|
5901 5802 | )),
|
5902 5803 | ))
|
5903 5804 | .unwrap();
|
5904 5805 | #[allow(unused_mut)]
|
5905 5806 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5906 5807 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5907 5808 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5908 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5809 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
5909 5810 | let sender = sender.clone();
|
5910 5811 | async move {
|
5911 - | 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> };
|
5812 + | 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> };
|
5912 5813 | sender.send(()).await.expect("receiver dropped early");
|
5913 5814 | result
|
5914 5815 | }
|
5915 5816 | })
|
5916 5817 | .build_unchecked();
|
5917 5818 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5918 5819 | .await
|
5919 5820 | .expect("unable to make an HTTP request");
|
5920 5821 | ::pretty_assertions::assert_eq!(
|
5921 5822 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5922 5823 | http_response.status()
|
5923 5824 | );
|
5924 5825 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5925 5826 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5926 5827 | http_response.headers(),
|
5927 5828 | expected_headers,
|
5928 5829 | ));
|
5929 5830 | use ::http_body_util::BodyExt;
|
5930 5831 | let body = http_response
|
5931 5832 | .into_body()
|
5932 5833 | .collect()
|
5933 5834 | .await
|
5934 5835 | .expect("unable to collect body")
|
5935 5836 | .to_bytes();
|
5936 5837 | ::aws_smithy_protocol_test::assert_ok(
|
5937 - | ::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"))
|
5938 - | );
|
5939 - | }
|
5940 - | }
|
5941 - | }
|
5942 - |
|
5943 - | ::pin_project_lite::pin_project! {
|
5944 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
5945 - | /// [`MalformedLengthQueryStringInput`](crate::input::MalformedLengthQueryStringInput) using modelled bindings.
|
5946 - | pub struct MalformedLengthQueryStringInputFuture {
|
5947 - | 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>>
|
5948 - | }
|
5949 - | }
|
5950 - |
|
5951 - | impl std::future::Future for MalformedLengthQueryStringInputFuture {
|
5952 - | type Output = Result<
|
5953 - | crate::input::MalformedLengthQueryStringInput,
|
5954 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5955 - | >;
|
5956 - |
|
5957 - | fn poll(
|
5958 - | self: std::pin::Pin<&mut Self>,
|
5959 - | cx: &mut std::task::Context<'_>,
|
5960 - | ) -> std::task::Poll<Self::Output> {
|
5961 - | let this = self.project();
|
5962 - | this.inner.as_mut().poll(cx)
|
5963 - | }
|
5964 - | }
|
5965 - |
|
5966 - | impl<B>
|
5967 - | ::aws_smithy_http_server::request::FromRequest<
|
5968 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5969 - | B,
|
5970 - | > for crate::input::MalformedLengthQueryStringInput
|
5971 - | where
|
5972 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5973 - | B: 'static,
|
5974 - |
|
5975 - | B::Data: Send,
|
5976 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5977 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5978 - | {
|
5979 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5980 - | type Future = MalformedLengthQueryStringInputFuture;
|
5981 - |
|
5982 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5983 - | let fut = async move {
|
5984 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5985 - | request.headers(),
|
5986 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
5987 - | ) {
|
5988 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5989 - | }
|
5990 - | crate::protocol_serde::shape_malformed_length_query_string::de_malformed_length_query_string_http_request(request)
|
5991 - | .await
|
5992 - | };
|
5993 - | use ::futures_util::future::TryFutureExt;
|
5994 - | let fut = fut.map_err(
|
5995 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5996 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5997 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
5998 - | e,
|
5999 - | )
|
6000 - | },
|
5838 + | ::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"))
|
6001 5839 | );
|
6002 - | MalformedLengthQueryStringInputFuture {
|
6003 - | inner: Box::pin(fut),
|
6004 - | }
|
6005 - | }
|
6006 - | }
|
6007 - | impl
|
6008 - | ::aws_smithy_http_server::response::IntoResponse<
|
6009 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6010 - | > for crate::output::MalformedLengthQueryStringOutput
|
6011 - | {
|
6012 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6013 - | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_response(self) {
|
6014 - | Ok(response) => response,
|
6015 - | Err(e) => {
|
6016 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6017 - | ::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))
|
6018 - | }
|
6019 - | }
|
6020 - | }
|
6021 - | }
|
6022 - | impl
|
6023 - | ::aws_smithy_http_server::response::IntoResponse<
|
6024 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6025 - | > for crate::error::MalformedLengthQueryStringError
|
6026 - | {
|
6027 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6028 - | match crate::protocol_serde::shape_malformed_length_query_string::ser_malformed_length_query_string_http_error(&self) {
|
6029 - | Ok(mut response) => {
|
6030 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
6031 - | response
|
6032 - | },
|
6033 - | Err(e) => {
|
6034 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6035 - | ::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))
|
6036 5840 | }
|
6037 5841 | }
|
6038 - | }
|
6039 - | }
|
6040 - |
|
6041 - | #[allow(unreachable_code, unused_variables)]
|
6042 - | #[cfg(test)]
|
6043 - | mod malformed_length_query_string_test {
|
6044 5842 |
|
6045 - | /// When a required member has no value in the query string,
|
5843 + | /// When a byte member does not fit within range bounds,
|
6046 5844 | /// the response should be a 400 ValidationException.
|
6047 - | /// Test ID: RestJsonMalformedLengthQueryStringNoValue
|
5845 + | /// Test ID: RestJsonMalformedRangeMinByteOverride
|
6048 5846 | #[::tokio::test]
|
6049 5847 | #[::tracing_test::traced_test]
|
6050 - | async fn rest_json_malformed_length_query_string_no_value_malformed_request() {
|
5848 + | async fn rest_json_malformed_range_min_byte_override_malformed_request() {
|
6051 5849 | {
|
6052 5850 | #[allow(unused_mut)]
|
6053 5851 | let mut http_request = ::http_1x::Request::builder()
|
6054 - | .uri("/MalformedLengthQueryString")
|
5852 + | .uri("/MalformedRangeOverride")
|
6055 5853 | .method("POST")
|
5854 + | .header("content-type", "application/json")
|
6056 5855 | .body(::aws_smithy_http_server::body::boxed(
|
6057 5856 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6058 5857 | &::aws_smithy_protocol_test::decode_body_data(
|
6059 - | "{}".as_bytes(),
|
5858 + | "{ \"minByte\" : 3 }".as_bytes(),
|
6060 5859 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6061 5860 | ),
|
6062 5861 | )),
|
6063 5862 | ))
|
6064 5863 | .unwrap();
|
6065 - | *http_request.uri_mut() = "/MalformedLengthQueryString?string".parse().unwrap();
|
6066 5864 | #[allow(unused_mut)]
|
6067 5865 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6068 5866 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6069 5867 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6070 - | .malformed_length_query_string(move |input: crate::input::MalformedLengthQueryStringInput| {
|
5868 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6071 5869 | let sender = sender.clone();
|
6072 5870 | async move {
|
6073 - | 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> };
|
5871 + | 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> };
|
6074 5872 | sender.send(()).await.expect("receiver dropped early");
|
6075 5873 | result
|
6076 5874 | }
|
6077 5875 | })
|
6078 5876 | .build_unchecked();
|
6079 5877 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6080 5878 | .await
|
6081 5879 | .expect("unable to make an HTTP request");
|
6082 5880 | ::pretty_assertions::assert_eq!(
|
6083 5881 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6084 5882 | http_response.status()
|
6085 5883 | );
|
6086 5884 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6087 5885 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6088 5886 | http_response.headers(),
|
6089 5887 | expected_headers,
|
6090 5888 | ));
|
6091 5889 | use ::http_body_util::BodyExt;
|
6092 5890 | let body = http_response
|
6093 5891 | .into_body()
|
6094 5892 | .collect()
|
6095 5893 | .await
|
6096 5894 | .expect("unable to collect body")
|
6097 5895 | .to_bytes();
|
6098 5896 | ::aws_smithy_protocol_test::assert_ok(
|
6099 - | ::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"))
|
5897 + | ::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"))
|
6100 5898 | );
|
6101 5899 | }
|
6102 5900 | }
|
6103 - | }
|
6104 - |
|
6105 - | ::pin_project_lite::pin_project! {
|
6106 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6107 - | /// [`MalformedLengthOverrideInput`](crate::input::MalformedLengthOverrideInput) using modelled bindings.
|
6108 - | pub struct MalformedLengthOverrideInputFuture {
|
6109 - | 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>>
|
6110 - | }
|
6111 - | }
|
6112 - |
|
6113 - | impl std::future::Future for MalformedLengthOverrideInputFuture {
|
6114 - | type Output = Result<
|
6115 - | crate::input::MalformedLengthOverrideInput,
|
6116 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6117 - | >;
|
6118 - |
|
6119 - | fn poll(
|
6120 - | self: std::pin::Pin<&mut Self>,
|
6121 - | cx: &mut std::task::Context<'_>,
|
6122 - | ) -> std::task::Poll<Self::Output> {
|
6123 - | let this = self.project();
|
6124 - | this.inner.as_mut().poll(cx)
|
6125 - | }
|
6126 - | }
|
6127 - |
|
6128 - | impl<B>
|
6129 - | ::aws_smithy_http_server::request::FromRequest<
|
6130 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6131 - | B,
|
6132 - | > for crate::input::MalformedLengthOverrideInput
|
6133 - | where
|
6134 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6135 - | B: 'static,
|
6136 - |
|
6137 - | B::Data: Send,
|
6138 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6139 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6140 - | {
|
6141 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6142 - | type Future = MalformedLengthOverrideInputFuture;
|
6143 - |
|
6144 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
6145 - | let fut = async move {
|
6146 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6147 - | request.headers(),
|
6148 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
6149 - | ) {
|
6150 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6151 - | }
|
6152 - | crate::protocol_serde::shape_malformed_length_override::de_malformed_length_override_http_request(request)
|
6153 - | .await
|
6154 - | };
|
6155 - | use ::futures_util::future::TryFutureExt;
|
6156 - | let fut = fut.map_err(
|
6157 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6158 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6159 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6160 - | e,
|
6161 - | )
|
6162 - | },
|
6163 - | );
|
6164 - | MalformedLengthOverrideInputFuture {
|
6165 - | inner: Box::pin(fut),
|
6166 - | }
|
6167 - | }
|
6168 - | }
|
6169 - | impl
|
6170 - | ::aws_smithy_http_server::response::IntoResponse<
|
6171 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6172 - | > for crate::output::MalformedLengthOverrideOutput
|
6173 - | {
|
6174 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6175 - | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_response(self) {
|
6176 - | Ok(response) => response,
|
6177 - | Err(e) => {
|
6178 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6179 - | ::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))
|
6180 - | }
|
6181 - | }
|
6182 - | }
|
6183 - | }
|
6184 - | impl
|
6185 - | ::aws_smithy_http_server::response::IntoResponse<
|
6186 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6187 - | > for crate::error::MalformedLengthOverrideError
|
6188 - | {
|
6189 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6190 - | match crate::protocol_serde::shape_malformed_length_override::ser_malformed_length_override_http_error(&self) {
|
6191 - | Ok(mut response) => {
|
6192 - | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
6193 - | response
|
6194 - | },
|
6195 - | Err(e) => {
|
6196 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6197 - | ::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))
|
6198 - | }
|
6199 - | }
|
6200 - | }
|
6201 - | }
|
6202 - |
|
6203 - | #[allow(unreachable_code, unused_variables)]
|
6204 - | #[cfg(test)]
|
6205 - | mod malformed_length_override_test {
|
6206 5901 |
|
6207 - | /// When a blob member does not fit within length bounds,
|
5902 + | /// When a byte member does not fit within range bounds,
|
6208 5903 | /// the response should be a 400 ValidationException.
|
6209 - | /// Test ID: RestJsonMalformedLengthBlobOverride_case0
|
5904 + | /// Test ID: RestJsonMalformedRangeMaxByteOverride
|
6210 5905 | #[::tokio::test]
|
6211 5906 | #[::tracing_test::traced_test]
|
6212 - | async fn rest_json_malformed_length_blob_override_case0_malformed_request() {
|
5907 + | async fn rest_json_malformed_range_max_byte_override_malformed_request() {
|
6213 5908 | {
|
6214 5909 | #[allow(unused_mut)]
|
6215 5910 | let mut http_request = ::http_1x::Request::builder()
|
6216 - | .uri("/MalformedLengthOverride")
|
5911 + | .uri("/MalformedRangeOverride")
|
6217 5912 | .method("POST")
|
6218 5913 | .header("content-type", "application/json")
|
6219 5914 | .body(::aws_smithy_http_server::body::boxed(
|
6220 5915 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6221 5916 | &::aws_smithy_protocol_test::decode_body_data(
|
6222 - | "{ \"blob\" : \"YWJj\" }".as_bytes(),
|
5917 + | "{ \"maxByte\" : 7 }".as_bytes(),
|
6223 5918 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6224 5919 | ),
|
6225 5920 | )),
|
6226 5921 | ))
|
6227 5922 | .unwrap();
|
6228 5923 | #[allow(unused_mut)]
|
6229 5924 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6230 5925 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6231 5926 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6232 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5927 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6233 5928 | let sender = sender.clone();
|
6234 5929 | async move {
|
6235 - | 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> };
|
5930 + | 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> };
|
6236 5931 | sender.send(()).await.expect("receiver dropped early");
|
6237 5932 | result
|
6238 5933 | }
|
6239 5934 | })
|
6240 5935 | .build_unchecked();
|
6241 5936 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6242 5937 | .await
|
6243 5938 | .expect("unable to make an HTTP request");
|
6244 5939 | ::pretty_assertions::assert_eq!(
|
6245 5940 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6246 5941 | http_response.status()
|
6247 5942 | );
|
6248 5943 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6249 5944 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6250 5945 | http_response.headers(),
|
6251 5946 | expected_headers,
|
6252 5947 | ));
|
6253 5948 | use ::http_body_util::BodyExt;
|
6254 5949 | let body = http_response
|
6255 5950 | .into_body()
|
6256 5951 | .collect()
|
6257 5952 | .await
|
6258 5953 | .expect("unable to collect body")
|
6259 5954 | .to_bytes();
|
6260 5955 | ::aws_smithy_protocol_test::assert_ok(
|
6261 - | ::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"))
|
5956 + | ::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"))
|
6262 5957 | );
|
6263 5958 | }
|
6264 5959 | }
|
6265 5960 |
|
6266 - | /// When a blob member does not fit within length bounds,
|
5961 + | /// When a float member does not fit within range bounds,
|
6267 5962 | /// the response should be a 400 ValidationException.
|
6268 - | /// Test ID: RestJsonMalformedLengthBlobOverride_case1
|
5963 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case0
|
6269 5964 | #[::tokio::test]
|
6270 5965 | #[::tracing_test::traced_test]
|
6271 - | async fn rest_json_malformed_length_blob_override_case1_malformed_request() {
|
5966 + | #[should_panic]
|
5967 + | async fn rest_json_malformed_range_float_override_case0_malformed_request() {
|
6272 5968 | {
|
6273 5969 | #[allow(unused_mut)]
|
6274 5970 | let mut http_request = ::http_1x::Request::builder()
|
6275 - | .uri("/MalformedLengthOverride")
|
5971 + | .uri("/MalformedRangeOverride")
|
6276 5972 | .method("POST")
|
6277 5973 | .header("content-type", "application/json")
|
6278 5974 | .body(::aws_smithy_http_server::body::boxed(
|
6279 5975 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6280 5976 | &::aws_smithy_protocol_test::decode_body_data(
|
6281 - | "{ \"blob\" : \"YWJjZGVmZw==\" }".as_bytes(),
|
5977 + | "{ \"float\" : 4.3 }".as_bytes(),
|
6282 5978 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6283 5979 | ),
|
6284 5980 | )),
|
6285 5981 | ))
|
6286 5982 | .unwrap();
|
6287 5983 | #[allow(unused_mut)]
|
6288 5984 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6289 5985 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6290 5986 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6291 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5987 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6292 5988 | let sender = sender.clone();
|
6293 5989 | async move {
|
6294 - | 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> };
|
5990 + | 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> };
|
6295 5991 | sender.send(()).await.expect("receiver dropped early");
|
6296 5992 | result
|
6297 5993 | }
|
6298 5994 | })
|
6299 5995 | .build_unchecked();
|
6300 5996 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6301 5997 | .await
|
6302 5998 | .expect("unable to make an HTTP request");
|
6303 5999 | ::pretty_assertions::assert_eq!(
|
6304 6000 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6305 6001 | http_response.status()
|
6306 6002 | );
|
6307 6003 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6308 6004 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6309 6005 | http_response.headers(),
|
6310 6006 | expected_headers,
|
6311 6007 | ));
|
6312 6008 | use ::http_body_util::BodyExt;
|
6313 6009 | let body = http_response
|
6314 6010 | .into_body()
|
6315 6011 | .collect()
|
6316 6012 | .await
|
6317 6013 | .expect("unable to collect body")
|
6318 6014 | .to_bytes();
|
6319 6015 | ::aws_smithy_protocol_test::assert_ok(
|
6320 - | ::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"))
|
6016 + | ::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"))
|
6321 6017 | );
|
6322 6018 | }
|
6323 6019 | }
|
6324 6020 |
|
6325 - | /// When a string member does not fit within length bounds,
|
6021 + | /// When a float member does not fit within range bounds,
|
6326 6022 | /// the response should be a 400 ValidationException.
|
6327 - | /// Test ID: RestJsonMalformedLengthStringOverride_case0
|
6023 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case1
|
6328 6024 | #[::tokio::test]
|
6329 6025 | #[::tracing_test::traced_test]
|
6330 - | async fn rest_json_malformed_length_string_override_case0_malformed_request() {
|
6026 + | #[should_panic]
|
6027 + | async fn rest_json_malformed_range_float_override_case1_malformed_request() {
|
6331 6028 | {
|
6332 6029 | #[allow(unused_mut)]
|
6333 6030 | let mut http_request = ::http_1x::Request::builder()
|
6334 - | .uri("/MalformedLengthOverride")
|
6031 + | .uri("/MalformedRangeOverride")
|
6335 6032 | .method("POST")
|
6336 6033 | .header("content-type", "application/json")
|
6337 6034 | .body(::aws_smithy_http_server::body::boxed(
|
6338 6035 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6339 6036 | &::aws_smithy_protocol_test::decode_body_data(
|
6340 - | "{ \"string\" : \"abc\" }".as_bytes(),
|
6037 + | "{ \"float\" : 6.7 }".as_bytes(),
|
6341 6038 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6342 6039 | ),
|
6343 6040 | )),
|
6344 6041 | ))
|
6345 6042 | .unwrap();
|
6346 6043 | #[allow(unused_mut)]
|
6347 6044 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6348 6045 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6349 6046 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6350 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6047 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6351 6048 | let sender = sender.clone();
|
6352 6049 | async move {
|
6353 - | 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> };
|
6050 + | 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> };
|
6354 6051 | sender.send(()).await.expect("receiver dropped early");
|
6355 6052 | result
|
6356 6053 | }
|
6357 6054 | })
|
6358 6055 | .build_unchecked();
|
6359 6056 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6360 6057 | .await
|
6361 6058 | .expect("unable to make an HTTP request");
|
6362 6059 | ::pretty_assertions::assert_eq!(
|
6363 6060 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6364 6061 | http_response.status()
|
6365 6062 | );
|
6366 6063 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6367 6064 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6368 6065 | http_response.headers(),
|
6369 6066 | expected_headers,
|
6370 6067 | ));
|
6371 6068 | use ::http_body_util::BodyExt;
|
6372 6069 | let body = http_response
|
6373 6070 | .into_body()
|
6374 6071 | .collect()
|
6375 6072 | .await
|
6376 6073 | .expect("unable to collect body")
|
6377 6074 | .to_bytes();
|
6378 6075 | ::aws_smithy_protocol_test::assert_ok(
|
6379 - | ::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"))
|
6076 + | ::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"))
|
6380 6077 | );
|
6381 6078 | }
|
6382 6079 | }
|
6383 6080 |
|
6384 - | /// When a string member does not fit within length bounds,
|
6081 + | /// When a float member does not fit within range bounds,
|
6385 6082 | /// the response should be a 400 ValidationException.
|
6386 - | /// Test ID: RestJsonMalformedLengthStringOverride_case1
|
6083 + | /// Test ID: RestJsonMalformedRangeMinFloatOverride
|
6387 6084 | #[::tokio::test]
|
6388 6085 | #[::tracing_test::traced_test]
|
6389 - | async fn rest_json_malformed_length_string_override_case1_malformed_request() {
|
6086 + | #[should_panic]
|
6087 + | async fn rest_json_malformed_range_min_float_override_malformed_request() {
|
6390 6088 | {
|
6391 6089 | #[allow(unused_mut)]
|
6392 6090 | let mut http_request = ::http_1x::Request::builder()
|
6393 - | .uri("/MalformedLengthOverride")
|
6091 + | .uri("/MalformedRangeOverride")
|
6394 6092 | .method("POST")
|
6395 6093 | .header("content-type", "application/json")
|
6396 6094 | .body(::aws_smithy_http_server::body::boxed(
|
6397 6095 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6398 6096 | &::aws_smithy_protocol_test::decode_body_data(
|
6399 - | "{ \"string\" : \"abcdefg\" }".as_bytes(),
|
6097 + | "{ \"minFloat\" : 4.3 }".as_bytes(),
|
6400 6098 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6401 6099 | ),
|
6402 6100 | )),
|
6403 6101 | ))
|
6404 6102 | .unwrap();
|
6405 6103 | #[allow(unused_mut)]
|
6406 6104 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6407 6105 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6408 6106 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6409 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6107 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6410 6108 | let sender = sender.clone();
|
6411 6109 | async move {
|
6412 - | 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> };
|
6110 + | 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> };
|
6413 6111 | sender.send(()).await.expect("receiver dropped early");
|
6414 6112 | result
|
6415 6113 | }
|
6416 6114 | })
|
6417 6115 | .build_unchecked();
|
6418 6116 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6419 6117 | .await
|
6420 6118 | .expect("unable to make an HTTP request");
|
6421 6119 | ::pretty_assertions::assert_eq!(
|
6422 6120 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6423 6121 | http_response.status()
|
6424 6122 | );
|
6425 6123 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6426 6124 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6427 6125 | http_response.headers(),
|
6428 6126 | expected_headers,
|
6429 6127 | ));
|
6430 6128 | use ::http_body_util::BodyExt;
|
6431 6129 | let body = http_response
|
6432 6130 | .into_body()
|
6433 6131 | .collect()
|
6434 6132 | .await
|
6435 6133 | .expect("unable to collect body")
|
6436 6134 | .to_bytes();
|
6437 6135 | ::aws_smithy_protocol_test::assert_ok(
|
6438 - | ::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"))
|
6136 + | ::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"))
|
6439 6137 | );
|
6440 6138 | }
|
6441 6139 | }
|
6442 6140 |
|
6443 - | /// When a string member does not fit within length bounds,
|
6141 + | /// When a float member does not fit within range bounds,
|
6444 6142 | /// the response should be a 400 ValidationException.
|
6445 - | /// Test ID: RestJsonMalformedLengthStringOverride_case2
|
6143 + | /// Test ID: RestJsonMalformedRangeMaxFloatOverride
|
6446 6144 | #[::tokio::test]
|
6447 6145 | #[::tracing_test::traced_test]
|
6448 - | async fn rest_json_malformed_length_string_override_case2_malformed_request() {
|
6146 + | #[should_panic]
|
6147 + | async fn rest_json_malformed_range_max_float_override_malformed_request() {
|
6449 6148 | {
|
6450 6149 | #[allow(unused_mut)]
|
6451 6150 | let mut http_request = ::http_1x::Request::builder()
|
6452 - | .uri("/MalformedLengthOverride")
|
6151 + | .uri("/MalformedRangeOverride")
|
6453 6152 | .method("POST")
|
6454 6153 | .header("content-type", "application/json")
|
6455 6154 | .body(::aws_smithy_http_server::body::boxed(
|
6456 6155 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6457 6156 | &::aws_smithy_protocol_test::decode_body_data(
|
6458 - | "{ \"string\" : \"👍👍👍\" }".as_bytes(),
|
6157 + | "{ \"maxFloat\" : 6.7 }".as_bytes(),
|
6459 6158 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6460 6159 | ),
|
6461 6160 | )),
|
6462 6161 | ))
|
6463 6162 | .unwrap();
|
6464 6163 | #[allow(unused_mut)]
|
6465 6164 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6466 6165 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6467 6166 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6468 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6167 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6469 6168 | let sender = sender.clone();
|
6470 6169 | async move {
|
6471 - | 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> };
|
6170 + | 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> };
|
6472 6171 | sender.send(()).await.expect("receiver dropped early");
|
6473 6172 | result
|
6474 6173 | }
|
6475 6174 | })
|
6476 6175 | .build_unchecked();
|
6477 6176 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6478 6177 | .await
|
6479 6178 | .expect("unable to make an HTTP request");
|
6480 6179 | ::pretty_assertions::assert_eq!(
|
6481 6180 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6482 6181 | http_response.status()
|
6483 6182 | );
|
6484 6183 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6485 6184 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6486 6185 | http_response.headers(),
|
6487 6186 | expected_headers,
|
6488 6187 | ));
|
6489 6188 | use ::http_body_util::BodyExt;
|
6490 6189 | let body = http_response
|
6491 6190 | .into_body()
|
6492 6191 | .collect()
|
6493 6192 | .await
|
6494 6193 | .expect("unable to collect body")
|
6495 6194 | .to_bytes();
|
6496 6195 | ::aws_smithy_protocol_test::assert_ok(
|
6497 - | ::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"))
|
6196 + | ::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"))
|
6498 6197 | );
|
6499 6198 | }
|
6500 6199 | }
|
6501 6200 |
|
6502 - | /// When a string member does not fit within length bounds,
|
6201 + | /// When a short member does not fit within range bounds,
|
6503 6202 | /// the response should be a 400 ValidationException.
|
6504 - | /// Test ID: RestJsonMalformedLengthMinStringOverride
|
6203 + | /// Test ID: RestJsonMalformedRangeShortOverride_case0
|
6505 6204 | #[::tokio::test]
|
6506 6205 | #[::tracing_test::traced_test]
|
6507 - | async fn rest_json_malformed_length_min_string_override_malformed_request() {
|
6206 + | async fn rest_json_malformed_range_short_override_case0_malformed_request() {
|
6508 6207 | {
|
6509 6208 | #[allow(unused_mut)]
|
6510 6209 | let mut http_request = ::http_1x::Request::builder()
|
6511 - | .uri("/MalformedLengthOverride")
|
6210 + | .uri("/MalformedRangeOverride")
|
6512 6211 | .method("POST")
|
6513 6212 | .header("content-type", "application/json")
|
6514 6213 | .body(::aws_smithy_http_server::body::boxed(
|
6515 6214 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6516 6215 | &::aws_smithy_protocol_test::decode_body_data(
|
6517 - | "{ \"minString\" : \"abc\" }".as_bytes(),
|
6216 + | "{ \"short\" : 3 }".as_bytes(),
|
6518 6217 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6519 6218 | ),
|
6520 6219 | )),
|
6521 6220 | ))
|
6522 6221 | .unwrap();
|
6523 6222 | #[allow(unused_mut)]
|
6524 6223 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6525 6224 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6526 6225 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6527 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6226 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6528 6227 | let sender = sender.clone();
|
6529 6228 | async move {
|
6530 - | 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> };
|
6229 + | 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> };
|
6531 6230 | sender.send(()).await.expect("receiver dropped early");
|
6532 6231 | result
|
6533 6232 | }
|
6534 6233 | })
|
6535 6234 | .build_unchecked();
|
6536 6235 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6537 6236 | .await
|
6538 6237 | .expect("unable to make an HTTP request");
|
6539 6238 | ::pretty_assertions::assert_eq!(
|
6540 6239 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6541 6240 | http_response.status()
|
6542 6241 | );
|
6543 6242 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6544 6243 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6545 6244 | http_response.headers(),
|
6546 6245 | expected_headers,
|
6547 6246 | ));
|
6548 6247 | use ::http_body_util::BodyExt;
|
6549 6248 | let body = http_response
|
6550 6249 | .into_body()
|
6551 6250 | .collect()
|
6552 6251 | .await
|
6553 6252 | .expect("unable to collect body")
|
6554 6253 | .to_bytes();
|
6555 6254 | ::aws_smithy_protocol_test::assert_ok(
|
6556 - | ::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"))
|
6255 + | ::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"))
|
6557 6256 | );
|
6558 6257 | }
|
6559 6258 | }
|
6560 6259 |
|
6561 - | /// When a string member does not fit within length bounds,
|
6260 + | /// When a short member does not fit within range bounds,
|
6562 6261 | /// the response should be a 400 ValidationException.
|
6563 - | /// Test ID: RestJsonMalformedLengthMaxStringOverride
|
6262 + | /// Test ID: RestJsonMalformedRangeShortOverride_case1
|
6564 6263 | #[::tokio::test]
|
6565 6264 | #[::tracing_test::traced_test]
|
6566 - | async fn rest_json_malformed_length_max_string_override_malformed_request() {
|
6265 + | async fn rest_json_malformed_range_short_override_case1_malformed_request() {
|
6567 6266 | {
|
6568 6267 | #[allow(unused_mut)]
|
6569 6268 | let mut http_request = ::http_1x::Request::builder()
|
6570 - | .uri("/MalformedLengthOverride")
|
6269 + | .uri("/MalformedRangeOverride")
|
6571 6270 | .method("POST")
|
6572 6271 | .header("content-type", "application/json")
|
6573 6272 | .body(::aws_smithy_http_server::body::boxed(
|
6574 6273 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6575 6274 | &::aws_smithy_protocol_test::decode_body_data(
|
6576 - | "{ \"maxString\" : \"abcdefg\" }".as_bytes(),
|
6275 + | "{ \"short\" : 7 }".as_bytes(),
|
6577 6276 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6578 6277 | ),
|
6579 6278 | )),
|
6580 6279 | ))
|
6581 6280 | .unwrap();
|
6582 6281 | #[allow(unused_mut)]
|
6583 6282 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6584 6283 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6585 6284 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6586 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6285 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6587 6286 | let sender = sender.clone();
|
6588 6287 | async move {
|
6589 - | 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> };
|
6288 + | 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> };
|
6590 6289 | sender.send(()).await.expect("receiver dropped early");
|
6591 6290 | result
|
6592 6291 | }
|
6593 6292 | })
|
6594 6293 | .build_unchecked();
|
6595 6294 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6596 6295 | .await
|
6597 6296 | .expect("unable to make an HTTP request");
|
6598 6297 | ::pretty_assertions::assert_eq!(
|
6599 6298 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6600 6299 | http_response.status()
|
6601 6300 | );
|
6602 6301 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6603 6302 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6604 6303 | http_response.headers(),
|
6605 6304 | expected_headers,
|
6606 6305 | ));
|
6607 6306 | use ::http_body_util::BodyExt;
|
6608 6307 | let body = http_response
|
6609 6308 | .into_body()
|
6610 6309 | .collect()
|
6611 6310 | .await
|
6612 6311 | .expect("unable to collect body")
|
6613 6312 | .to_bytes();
|
6614 6313 | ::aws_smithy_protocol_test::assert_ok(
|
6615 - | ::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"))
|
6314 + | ::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"))
|
6616 6315 | );
|
6617 6316 | }
|
6618 6317 | }
|
6619 6318 |
|
6620 - | /// When a list member does not fit within length bounds,
|
6319 + | /// When a short member does not fit within range bounds,
|
6621 6320 | /// the response should be a 400 ValidationException.
|
6622 - | /// Test ID: RestJsonMalformedLengthListOverride_case0
|
6321 + | /// Test ID: RestJsonMalformedRangeMinShortOverride
|
6623 6322 | #[::tokio::test]
|
6624 6323 | #[::tracing_test::traced_test]
|
6625 - | async fn rest_json_malformed_length_list_override_case0_malformed_request() {
|
6324 + | async fn rest_json_malformed_range_min_short_override_malformed_request() {
|
6626 6325 | {
|
6627 6326 | #[allow(unused_mut)]
|
6628 6327 | let mut http_request = ::http_1x::Request::builder()
|
6629 - | .uri("/MalformedLengthOverride")
|
6328 + | .uri("/MalformedRangeOverride")
|
6630 6329 | .method("POST")
|
6631 6330 | .header("content-type", "application/json")
|
6632 6331 | .body(::aws_smithy_http_server::body::boxed(
|
6633 6332 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6634 6333 | &::aws_smithy_protocol_test::decode_body_data(
|
6635 - | "{ \"list\" : [\"abc\", \"def\", \"ghi\"] }".as_bytes(),
|
6334 + | "{ \"minShort\" : 3 }".as_bytes(),
|
6636 6335 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6637 6336 | ),
|
6638 6337 | )),
|
6639 6338 | ))
|
6640 6339 | .unwrap();
|
6641 6340 | #[allow(unused_mut)]
|
6642 6341 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6643 6342 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6644 6343 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6645 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6344 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6646 6345 | let sender = sender.clone();
|
6647 6346 | async move {
|
6648 - | 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> };
|
6347 + | 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> };
|
6649 6348 | sender.send(()).await.expect("receiver dropped early");
|
6650 6349 | result
|
6651 6350 | }
|
6652 6351 | })
|
6653 6352 | .build_unchecked();
|
6654 6353 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6655 6354 | .await
|
6656 6355 | .expect("unable to make an HTTP request");
|
6657 6356 | ::pretty_assertions::assert_eq!(
|
6658 6357 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6659 6358 | http_response.status()
|
6660 6359 | );
|
6661 6360 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6662 6361 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6663 6362 | http_response.headers(),
|
6664 6363 | expected_headers,
|
6665 6364 | ));
|
6666 6365 | use ::http_body_util::BodyExt;
|
6667 6366 | let body = http_response
|
6668 6367 | .into_body()
|
6669 6368 | .collect()
|
6670 6369 | .await
|
6671 6370 | .expect("unable to collect body")
|
6672 6371 | .to_bytes();
|
6673 6372 | ::aws_smithy_protocol_test::assert_ok(
|
6674 - | ::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"))
|
6373 + | ::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"))
|
6675 6374 | );
|
6676 6375 | }
|
6677 6376 | }
|
6678 6377 |
|
6679 - | /// When a list member does not fit within length bounds,
|
6378 + | /// When a short member does not fit within range bounds,
|
6680 6379 | /// the response should be a 400 ValidationException.
|
6681 - | /// Test ID: RestJsonMalformedLengthListOverride_case1
|
6380 + | /// Test ID: RestJsonMalformedRangeMaxShortOverride
|
6682 6381 | #[::tokio::test]
|
6683 6382 | #[::tracing_test::traced_test]
|
6684 - | async fn rest_json_malformed_length_list_override_case1_malformed_request() {
|
6383 + | async fn rest_json_malformed_range_max_short_override_malformed_request() {
|
6685 6384 | {
|
6686 6385 | #[allow(unused_mut)]
|
6687 6386 | let mut http_request = ::http_1x::Request::builder()
|
6688 - | .uri("/MalformedLengthOverride")
|
6387 + | .uri("/MalformedRangeOverride")
|
6689 6388 | .method("POST")
|
6690 6389 | .header("content-type", "application/json")
|
6691 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
6692 - | ::bytes::Bytes::copy_from_slice(
|
6693 - | &::aws_smithy_protocol_test::decode_body_data("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
6694 - | )
|
6695 - | ))).unwrap();
|
6696 - | #[allow(unused_mut)]
|
6697 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6698 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6699 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6700 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6701 - | let sender = sender.clone();
|
6702 - | async move {
|
6703 - | 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> };
|
6390 + | .body(::aws_smithy_http_server::body::boxed(
|
6391 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6392 + | &::aws_smithy_protocol_test::decode_body_data(
|
6393 + | "{ \"maxShort\" : 7 }".as_bytes(),
|
6394 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6395 + | ),
|
6396 + | )),
|
6397 + | ))
|
6398 + | .unwrap();
|
6399 + | #[allow(unused_mut)]
|
6400 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6401 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6402 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6403 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6404 + | let sender = sender.clone();
|
6405 + | async move {
|
6406 + | 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> };
|
6704 6407 | sender.send(()).await.expect("receiver dropped early");
|
6705 6408 | result
|
6706 6409 | }
|
6707 6410 | })
|
6708 6411 | .build_unchecked();
|
6709 6412 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6710 6413 | .await
|
6711 6414 | .expect("unable to make an HTTP request");
|
6712 6415 | ::pretty_assertions::assert_eq!(
|
6713 6416 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6714 6417 | http_response.status()
|
6715 6418 | );
|
6716 6419 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6717 6420 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6718 6421 | http_response.headers(),
|
6719 6422 | expected_headers,
|
6720 6423 | ));
|
6721 6424 | use ::http_body_util::BodyExt;
|
6722 6425 | let body = http_response
|
6723 6426 | .into_body()
|
6724 6427 | .collect()
|
6725 6428 | .await
|
6726 6429 | .expect("unable to collect body")
|
6727 6430 | .to_bytes();
|
6728 6431 | ::aws_smithy_protocol_test::assert_ok(
|
6729 - | ::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"))
|
6432 + | ::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"))
|
6730 6433 | );
|
6731 6434 | }
|
6732 6435 | }
|
6733 6436 |
|
6734 - | /// When a map member does not fit within length bounds,
|
6437 + | /// When a integer member does not fit within range bounds,
|
6735 6438 | /// the response should be a 400 ValidationException.
|
6736 - | /// Test ID: RestJsonMalformedLengthMapOverride_case0
|
6439 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case0
|
6737 6440 | #[::tokio::test]
|
6738 6441 | #[::tracing_test::traced_test]
|
6739 - | async fn rest_json_malformed_length_map_override_case0_malformed_request() {
|
6442 + | async fn rest_json_malformed_range_integer_override_case0_malformed_request() {
|
6740 6443 | {
|
6741 6444 | #[allow(unused_mut)]
|
6742 6445 | let mut http_request = ::http_1x::Request::builder()
|
6743 - | .uri("/MalformedLengthOverride")
|
6446 + | .uri("/MalformedRangeOverride")
|
6744 6447 | .method("POST")
|
6745 6448 | .header("content-type", "application/json")
|
6746 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
6747 - | ::bytes::Bytes::copy_from_slice(
|
6748 - | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
6749 - | )
|
6750 - | ))).unwrap();
|
6449 + | .body(::aws_smithy_http_server::body::boxed(
|
6450 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6451 + | &::aws_smithy_protocol_test::decode_body_data(
|
6452 + | "{ \"integer\" : 3 }".as_bytes(),
|
6453 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6454 + | ),
|
6455 + | )),
|
6456 + | ))
|
6457 + | .unwrap();
|
6751 6458 | #[allow(unused_mut)]
|
6752 6459 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6753 6460 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6754 6461 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6755 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6462 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6756 6463 | let sender = sender.clone();
|
6757 6464 | async move {
|
6758 - | 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> };
|
6465 + | 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> };
|
6759 6466 | sender.send(()).await.expect("receiver dropped early");
|
6760 6467 | result
|
6761 6468 | }
|
6762 6469 | })
|
6763 6470 | .build_unchecked();
|
6764 6471 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6765 6472 | .await
|
6766 6473 | .expect("unable to make an HTTP request");
|
6767 6474 | ::pretty_assertions::assert_eq!(
|
6768 6475 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6769 6476 | http_response.status()
|
6770 6477 | );
|
6771 6478 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6772 6479 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6773 6480 | http_response.headers(),
|
6774 6481 | expected_headers,
|
6775 6482 | ));
|
6776 6483 | use ::http_body_util::BodyExt;
|
6777 6484 | let body = http_response
|
6778 6485 | .into_body()
|
6779 6486 | .collect()
|
6780 6487 | .await
|
6781 6488 | .expect("unable to collect body")
|
6782 6489 | .to_bytes();
|
6783 6490 | ::aws_smithy_protocol_test::assert_ok(
|
6784 - | ::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"))
|
6491 + | ::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"))
|
6785 6492 | );
|
6786 6493 | }
|
6787 6494 | }
|
6788 6495 |
|
6789 - | /// When a map member does not fit within length bounds,
|
6496 + | /// When a integer member does not fit within range bounds,
|
6790 6497 | /// the response should be a 400 ValidationException.
|
6791 - | /// Test ID: RestJsonMalformedLengthMapOverride_case1
|
6498 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case1
|
6792 6499 | #[::tokio::test]
|
6793 6500 | #[::tracing_test::traced_test]
|
6794 - | async fn rest_json_malformed_length_map_override_case1_malformed_request() {
|
6501 + | async fn rest_json_malformed_range_integer_override_case1_malformed_request() {
|
6795 6502 | {
|
6796 6503 | #[allow(unused_mut)]
|
6797 6504 | let mut http_request = ::http_1x::Request::builder()
|
6798 - | .uri("/MalformedLengthOverride")
|
6505 + | .uri("/MalformedRangeOverride")
|
6799 6506 | .method("POST")
|
6800 6507 | .header("content-type", "application/json")
|
6801 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
6802 - | ::bytes::Bytes::copy_from_slice(
|
6803 - | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"],\n \"efg\": [\"abc\", \"def\", \"efg\"], \"fgh\": [\"abc\", \"def\", \"efg\"],\n \"ghi\": [\"abc\", \"def\", \"efg\"] } }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
6804 - | )
|
6805 - | ))).unwrap();
|
6508 + | .body(::aws_smithy_http_server::body::boxed(
|
6509 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6510 + | &::aws_smithy_protocol_test::decode_body_data(
|
6511 + | "{ \"integer\" : 7 }".as_bytes(),
|
6512 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6513 + | ),
|
6514 + | )),
|
6515 + | ))
|
6516 + | .unwrap();
|
6806 6517 | #[allow(unused_mut)]
|
6807 6518 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6808 6519 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6809 6520 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6810 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6521 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6811 6522 | let sender = sender.clone();
|
6812 6523 | async move {
|
6813 - | 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> };
|
6524 + | 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> };
|
6814 6525 | sender.send(()).await.expect("receiver dropped early");
|
6815 6526 | result
|
6816 6527 | }
|
6817 6528 | })
|
6818 6529 | .build_unchecked();
|
6819 6530 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6820 6531 | .await
|
6821 6532 | .expect("unable to make an HTTP request");
|
6822 6533 | ::pretty_assertions::assert_eq!(
|
6823 6534 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6824 6535 | http_response.status()
|
6825 6536 | );
|
6826 6537 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6827 6538 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6828 6539 | http_response.headers(),
|
6829 6540 | expected_headers,
|
6830 6541 | ));
|
6831 6542 | use ::http_body_util::BodyExt;
|
6832 6543 | let body = http_response
|
6833 6544 | .into_body()
|
6834 6545 | .collect()
|
6835 6546 | .await
|
6836 6547 | .expect("unable to collect body")
|
6837 6548 | .to_bytes();
|
6838 6549 | ::aws_smithy_protocol_test::assert_ok(
|
6839 - | ::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"))
|
6840 - | );
|
6841 - | }
|
6842 - | }
|
6843 - | }
|
6844 - |
|
6845 - | ::pin_project_lite::pin_project! {
|
6846 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6847 - | /// [`MalformedLengthInput`](crate::input::MalformedLengthInput) using modelled bindings.
|
6848 - | pub struct MalformedLengthInputFuture {
|
6849 - | 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>>
|
6850 - | }
|
6851 - | }
|
6852 - |
|
6853 - | impl std::future::Future for MalformedLengthInputFuture {
|
6854 - | type Output = Result<
|
6855 - | crate::input::MalformedLengthInput,
|
6856 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6857 - | >;
|
6858 - |
|
6859 - | fn poll(
|
6860 - | self: std::pin::Pin<&mut Self>,
|
6861 - | cx: &mut std::task::Context<'_>,
|
6862 - | ) -> std::task::Poll<Self::Output> {
|
6863 - | let this = self.project();
|
6864 - | this.inner.as_mut().poll(cx)
|
6865 - | }
|
6866 - | }
|
6867 - |
|
6868 - | impl<B>
|
6869 - | ::aws_smithy_http_server::request::FromRequest<
|
6870 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6871 - | B,
|
6872 - | > for crate::input::MalformedLengthInput
|
6873 - | where
|
6874 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6875 - | B: 'static,
|
6876 - |
|
6877 - | B::Data: Send,
|
6878 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6879 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6880 - | {
|
6881 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6882 - | type Future = MalformedLengthInputFuture;
|
6883 - |
|
6884 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
6885 - | let fut = async move {
|
6886 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6887 - | request.headers(),
|
6888 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
6889 - | ) {
|
6890 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6891 - | }
|
6892 - | crate::protocol_serde::shape_malformed_length::de_malformed_length_http_request(request)
|
6893 - | .await
|
6894 - | };
|
6895 - | use ::futures_util::future::TryFutureExt;
|
6896 - | let fut = fut.map_err(
|
6897 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6898 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6899 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6900 - | e,
|
6901 - | )
|
6902 - | },
|
6903 - | );
|
6904 - | MalformedLengthInputFuture {
|
6905 - | inner: Box::pin(fut),
|
6906 - | }
|
6907 - | }
|
6908 - | }
|
6909 - | impl
|
6910 - | ::aws_smithy_http_server::response::IntoResponse<
|
6911 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6912 - | > for crate::output::MalformedLengthOutput
|
6913 - | {
|
6914 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6915 - | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_response(
|
6916 - | self,
|
6917 - | ) {
|
6918 - | Ok(response) => response,
|
6919 - | Err(e) => {
|
6920 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6921 - | ::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))
|
6922 - | }
|
6923 - | }
|
6924 - | }
|
6925 - | }
|
6926 - | impl
|
6927 - | ::aws_smithy_http_server::response::IntoResponse<
|
6928 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6929 - | > for crate::error::MalformedLengthError
|
6930 - | {
|
6931 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6932 - | match crate::protocol_serde::shape_malformed_length::ser_malformed_length_http_error(&self)
|
6933 - | {
|
6934 - | Ok(mut response) => {
|
6935 - | response.extensions_mut().insert(
|
6936 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
6550 + | ::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"))
|
6937 6551 | );
|
6938 - | response
|
6939 - | }
|
6940 - | Err(e) => {
|
6941 - | ::tracing::error!(error = %e, "failed to serialize response");
|
6942 - | ::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))
|
6943 - | }
|
6944 6552 | }
|
6945 6553 | }
|
6946 - | }
|
6947 - |
|
6948 - | #[allow(unreachable_code, unused_variables)]
|
6949 - | #[cfg(test)]
|
6950 - | mod malformed_length_test {
|
6951 6554 |
|
6952 - | /// When a blob member does not fit within length bounds,
|
6555 + | /// When a integer member does not fit within range bounds,
|
6953 6556 | /// the response should be a 400 ValidationException.
|
6954 - | /// Test ID: RestJsonMalformedLengthBlob_case0
|
6557 + | /// Test ID: RestJsonMalformedRangeMinIntegerOverride
|
6955 6558 | #[::tokio::test]
|
6956 6559 | #[::tracing_test::traced_test]
|
6957 - | async fn rest_json_malformed_length_blob_case0_malformed_request() {
|
6560 + | async fn rest_json_malformed_range_min_integer_override_malformed_request() {
|
6958 6561 | {
|
6959 6562 | #[allow(unused_mut)]
|
6960 6563 | let mut http_request = ::http_1x::Request::builder()
|
6961 - | .uri("/MalformedLength")
|
6564 + | .uri("/MalformedRangeOverride")
|
6962 6565 | .method("POST")
|
6963 6566 | .header("content-type", "application/json")
|
6964 6567 | .body(::aws_smithy_http_server::body::boxed(
|
6965 6568 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6966 6569 | &::aws_smithy_protocol_test::decode_body_data(
|
6967 - | "{ \"blob\" : \"YQ==\" }".as_bytes(),
|
6570 + | "{ \"minInteger\" : 3 }".as_bytes(),
|
6968 6571 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6969 6572 | ),
|
6970 6573 | )),
|
6971 6574 | ))
|
6972 6575 | .unwrap();
|
6973 6576 | #[allow(unused_mut)]
|
6974 6577 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6975 6578 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6976 6579 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6977 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6580 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6978 6581 | let sender = sender.clone();
|
6979 6582 | async move {
|
6980 - | 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> };
|
6583 + | 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> };
|
6981 6584 | sender.send(()).await.expect("receiver dropped early");
|
6982 6585 | result
|
6983 6586 | }
|
6984 6587 | })
|
6985 6588 | .build_unchecked();
|
6986 6589 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6987 6590 | .await
|
6988 6591 | .expect("unable to make an HTTP request");
|
6989 6592 | ::pretty_assertions::assert_eq!(
|
6990 6593 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6991 6594 | http_response.status()
|
6992 6595 | );
|
6993 6596 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6994 6597 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6995 6598 | http_response.headers(),
|
6996 6599 | expected_headers,
|
6997 6600 | ));
|
6998 6601 | use ::http_body_util::BodyExt;
|
6999 6602 | let body = http_response
|
7000 6603 | .into_body()
|
7001 6604 | .collect()
|
7002 6605 | .await
|
7003 6606 | .expect("unable to collect body")
|
7004 6607 | .to_bytes();
|
7005 6608 | ::aws_smithy_protocol_test::assert_ok(
|
7006 - | ::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"))
|
6609 + | ::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"))
|
7007 6610 | );
|
7008 6611 | }
|
7009 6612 | }
|
7010 6613 |
|
7011 - | /// When a blob member does not fit within length bounds,
|
6614 + | /// When a integer member does not fit within range bounds,
|
7012 6615 | /// the response should be a 400 ValidationException.
|
7013 - | /// Test ID: RestJsonMalformedLengthBlob_case1
|
6616 + | /// Test ID: RestJsonMalformedRangeMaxIntegerOverride
|
7014 6617 | #[::tokio::test]
|
7015 6618 | #[::tracing_test::traced_test]
|
7016 - | async fn rest_json_malformed_length_blob_case1_malformed_request() {
|
6619 + | async fn rest_json_malformed_range_max_integer_override_malformed_request() {
|
7017 6620 | {
|
7018 6621 | #[allow(unused_mut)]
|
7019 6622 | let mut http_request = ::http_1x::Request::builder()
|
7020 - | .uri("/MalformedLength")
|
6623 + | .uri("/MalformedRangeOverride")
|
7021 6624 | .method("POST")
|
7022 6625 | .header("content-type", "application/json")
|
7023 6626 | .body(::aws_smithy_http_server::body::boxed(
|
7024 6627 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7025 6628 | &::aws_smithy_protocol_test::decode_body_data(
|
7026 - | "{ \"blob\" : \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" }".as_bytes(),
|
6629 + | "{ \"maxInteger\" : 7 }".as_bytes(),
|
7027 6630 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7028 6631 | ),
|
7029 6632 | )),
|
7030 6633 | ))
|
7031 6634 | .unwrap();
|
7032 6635 | #[allow(unused_mut)]
|
7033 6636 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7034 6637 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7035 6638 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7036 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6639 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7037 6640 | let sender = sender.clone();
|
7038 6641 | async move {
|
7039 - | 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> };
|
6642 + | 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> };
|
7040 6643 | sender.send(()).await.expect("receiver dropped early");
|
7041 6644 | result
|
7042 6645 | }
|
7043 6646 | })
|
7044 6647 | .build_unchecked();
|
7045 6648 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7046 6649 | .await
|
7047 6650 | .expect("unable to make an HTTP request");
|
7048 6651 | ::pretty_assertions::assert_eq!(
|
7049 6652 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7050 6653 | http_response.status()
|
7051 6654 | );
|
7052 6655 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7053 6656 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7054 6657 | http_response.headers(),
|
7055 6658 | expected_headers,
|
7056 6659 | ));
|
7057 6660 | use ::http_body_util::BodyExt;
|
7058 6661 | let body = http_response
|
7059 6662 | .into_body()
|
7060 6663 | .collect()
|
7061 6664 | .await
|
7062 6665 | .expect("unable to collect body")
|
7063 6666 | .to_bytes();
|
7064 6667 | ::aws_smithy_protocol_test::assert_ok(
|
7065 - | ::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"))
|
6668 + | ::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"))
|
7066 6669 | );
|
7067 6670 | }
|
7068 6671 | }
|
7069 6672 |
|
7070 - | /// When a string member does not fit within length bounds,
|
6673 + | /// When a long member does not fit within range bounds,
|
7071 6674 | /// the response should be a 400 ValidationException.
|
7072 - | /// Test ID: RestJsonMalformedLengthString_case0
|
6675 + | /// Test ID: RestJsonMalformedRangeLongOverride_case0
|
7073 6676 | #[::tokio::test]
|
7074 6677 | #[::tracing_test::traced_test]
|
7075 - | async fn rest_json_malformed_length_string_case0_malformed_request() {
|
6678 + | async fn rest_json_malformed_range_long_override_case0_malformed_request() {
|
7076 6679 | {
|
7077 6680 | #[allow(unused_mut)]
|
7078 6681 | let mut http_request = ::http_1x::Request::builder()
|
7079 - | .uri("/MalformedLength")
|
6682 + | .uri("/MalformedRangeOverride")
|
7080 6683 | .method("POST")
|
7081 6684 | .header("content-type", "application/json")
|
7082 6685 | .body(::aws_smithy_http_server::body::boxed(
|
7083 6686 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7084 6687 | &::aws_smithy_protocol_test::decode_body_data(
|
7085 - | "{ \"string\" : \"a\" }".as_bytes(),
|
6688 + | "{ \"long\" : 3 }".as_bytes(),
|
7086 6689 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7087 6690 | ),
|
7088 6691 | )),
|
7089 6692 | ))
|
7090 6693 | .unwrap();
|
7091 6694 | #[allow(unused_mut)]
|
7092 6695 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7093 6696 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7094 6697 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7095 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6698 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7096 6699 | let sender = sender.clone();
|
7097 6700 | async move {
|
7098 - | 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> };
|
6701 + | 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> };
|
7099 6702 | sender.send(()).await.expect("receiver dropped early");
|
7100 6703 | result
|
7101 6704 | }
|
7102 6705 | })
|
7103 6706 | .build_unchecked();
|
7104 6707 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7105 6708 | .await
|
7106 6709 | .expect("unable to make an HTTP request");
|
7107 6710 | ::pretty_assertions::assert_eq!(
|
7108 6711 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7109 6712 | http_response.status()
|
7110 6713 | );
|
7111 6714 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7112 6715 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7113 6716 | http_response.headers(),
|
7114 6717 | expected_headers,
|
7115 6718 | ));
|
7116 6719 | use ::http_body_util::BodyExt;
|
7117 6720 | let body = http_response
|
7118 6721 | .into_body()
|
7119 6722 | .collect()
|
7120 6723 | .await
|
7121 6724 | .expect("unable to collect body")
|
7122 6725 | .to_bytes();
|
7123 6726 | ::aws_smithy_protocol_test::assert_ok(
|
7124 - | ::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"))
|
6727 + | ::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"))
|
7125 6728 | );
|
7126 6729 | }
|
7127 6730 | }
|
7128 6731 |
|
7129 - | /// When a string member does not fit within length bounds,
|
6732 + | /// When a long member does not fit within range bounds,
|
7130 6733 | /// the response should be a 400 ValidationException.
|
7131 - | /// Test ID: RestJsonMalformedLengthString_case1
|
6734 + | /// Test ID: RestJsonMalformedRangeLongOverride_case1
|
7132 6735 | #[::tokio::test]
|
7133 6736 | #[::tracing_test::traced_test]
|
7134 - | async fn rest_json_malformed_length_string_case1_malformed_request() {
|
6737 + | async fn rest_json_malformed_range_long_override_case1_malformed_request() {
|
7135 6738 | {
|
7136 6739 | #[allow(unused_mut)]
|
7137 6740 | let mut http_request = ::http_1x::Request::builder()
|
7138 - | .uri("/MalformedLength")
|
6741 + | .uri("/MalformedRangeOverride")
|
7139 6742 | .method("POST")
|
7140 6743 | .header("content-type", "application/json")
|
7141 6744 | .body(::aws_smithy_http_server::body::boxed(
|
7142 6745 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7143 6746 | &::aws_smithy_protocol_test::decode_body_data(
|
7144 - | "{ \"string\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
6747 + | "{ \"long\" : 7 }".as_bytes(),
|
7145 6748 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7146 6749 | ),
|
7147 6750 | )),
|
7148 6751 | ))
|
7149 6752 | .unwrap();
|
7150 6753 | #[allow(unused_mut)]
|
7151 6754 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7152 6755 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7153 6756 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7154 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6757 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7155 6758 | let sender = sender.clone();
|
7156 6759 | async move {
|
7157 - | 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> };
|
6760 + | 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> };
|
7158 6761 | sender.send(()).await.expect("receiver dropped early");
|
7159 6762 | result
|
7160 6763 | }
|
7161 6764 | })
|
7162 6765 | .build_unchecked();
|
7163 6766 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7164 6767 | .await
|
7165 6768 | .expect("unable to make an HTTP request");
|
7166 6769 | ::pretty_assertions::assert_eq!(
|
7167 6770 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7168 6771 | http_response.status()
|
7169 6772 | );
|
7170 6773 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7171 6774 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7172 6775 | http_response.headers(),
|
7173 6776 | expected_headers,
|
7174 6777 | ));
|
7175 6778 | use ::http_body_util::BodyExt;
|
7176 6779 | let body = http_response
|
7177 6780 | .into_body()
|
7178 6781 | .collect()
|
7179 6782 | .await
|
7180 6783 | .expect("unable to collect body")
|
7181 6784 | .to_bytes();
|
7182 6785 | ::aws_smithy_protocol_test::assert_ok(
|
7183 - | ::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"))
|
6786 + | ::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"))
|
7184 6787 | );
|
7185 6788 | }
|
7186 6789 | }
|
7187 6790 |
|
7188 - | /// When a string member does not fit within length bounds,
|
6791 + | /// When a long member does not fit within range bounds,
|
7189 6792 | /// the response should be a 400 ValidationException.
|
7190 - | /// Test ID: RestJsonMalformedLengthString_case2
|
6793 + | /// Test ID: RestJsonMalformedRangeMinLongOverride
|
7191 6794 | #[::tokio::test]
|
7192 6795 | #[::tracing_test::traced_test]
|
7193 - | async fn rest_json_malformed_length_string_case2_malformed_request() {
|
6796 + | async fn rest_json_malformed_range_min_long_override_malformed_request() {
|
7194 6797 | {
|
7195 6798 | #[allow(unused_mut)]
|
7196 6799 | let mut http_request = ::http_1x::Request::builder()
|
7197 - | .uri("/MalformedLength")
|
6800 + | .uri("/MalformedRangeOverride")
|
7198 6801 | .method("POST")
|
7199 6802 | .header("content-type", "application/json")
|
7200 6803 | .body(::aws_smithy_http_server::body::boxed(
|
7201 6804 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7202 6805 | &::aws_smithy_protocol_test::decode_body_data(
|
7203 - | "{ \"string\" : \"👍\" }".as_bytes(),
|
6806 + | "{ \"minLong\" : 3 }".as_bytes(),
|
7204 6807 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7205 6808 | ),
|
7206 6809 | )),
|
7207 6810 | ))
|
7208 6811 | .unwrap();
|
7209 6812 | #[allow(unused_mut)]
|
7210 6813 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7211 6814 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7212 6815 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7213 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6816 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7214 6817 | let sender = sender.clone();
|
7215 6818 | async move {
|
7216 - | 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> };
|
6819 + | 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> };
|
7217 6820 | sender.send(()).await.expect("receiver dropped early");
|
7218 6821 | result
|
7219 6822 | }
|
7220 6823 | })
|
7221 6824 | .build_unchecked();
|
7222 6825 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7223 6826 | .await
|
7224 6827 | .expect("unable to make an HTTP request");
|
7225 6828 | ::pretty_assertions::assert_eq!(
|
7226 6829 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7227 6830 | http_response.status()
|
7228 6831 | );
|
7229 6832 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7230 6833 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7231 6834 | http_response.headers(),
|
7232 6835 | expected_headers,
|
7233 6836 | ));
|
7234 6837 | use ::http_body_util::BodyExt;
|
7235 6838 | let body = http_response
|
7236 6839 | .into_body()
|
7237 6840 | .collect()
|
7238 6841 | .await
|
7239 6842 | .expect("unable to collect body")
|
7240 6843 | .to_bytes();
|
7241 6844 | ::aws_smithy_protocol_test::assert_ok(
|
7242 - | ::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"))
|
6845 + | ::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"))
|
7243 6846 | );
|
7244 6847 | }
|
7245 6848 | }
|
7246 6849 |
|
7247 - | /// When a string member does not fit within length bounds,
|
6850 + | /// When a long member does not fit within range bounds,
|
7248 6851 | /// the response should be a 400 ValidationException.
|
7249 - | /// Test ID: RestJsonMalformedLengthMinString
|
6852 + | /// Test ID: RestJsonMalformedRangeMaxLongOverride
|
7250 6853 | #[::tokio::test]
|
7251 6854 | #[::tracing_test::traced_test]
|
7252 - | async fn rest_json_malformed_length_min_string_malformed_request() {
|
6855 + | async fn rest_json_malformed_range_max_long_override_malformed_request() {
|
7253 6856 | {
|
7254 6857 | #[allow(unused_mut)]
|
7255 6858 | let mut http_request = ::http_1x::Request::builder()
|
7256 - | .uri("/MalformedLength")
|
6859 + | .uri("/MalformedRangeOverride")
|
7257 6860 | .method("POST")
|
7258 6861 | .header("content-type", "application/json")
|
7259 6862 | .body(::aws_smithy_http_server::body::boxed(
|
7260 6863 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7261 6864 | &::aws_smithy_protocol_test::decode_body_data(
|
7262 - | "{ \"minString\" : \"a\" }".as_bytes(),
|
6865 + | "{ \"maxLong\" : 7 }".as_bytes(),
|
7263 6866 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7264 6867 | ),
|
7265 6868 | )),
|
7266 6869 | ))
|
7267 6870 | .unwrap();
|
7268 6871 | #[allow(unused_mut)]
|
7269 6872 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7270 6873 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7271 6874 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7272 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6875 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7273 6876 | let sender = sender.clone();
|
7274 6877 | async move {
|
7275 - | 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> };
|
6878 + | 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> };
|
7276 6879 | sender.send(()).await.expect("receiver dropped early");
|
7277 6880 | result
|
7278 6881 | }
|
7279 6882 | })
|
7280 6883 | .build_unchecked();
|
7281 6884 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7282 6885 | .await
|
7283 6886 | .expect("unable to make an HTTP request");
|
7284 6887 | ::pretty_assertions::assert_eq!(
|
7285 6888 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7286 6889 | http_response.status()
|
7287 6890 | );
|
7288 6891 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7289 6892 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7290 6893 | http_response.headers(),
|
7291 6894 | expected_headers,
|
7292 6895 | ));
|
7293 6896 | use ::http_body_util::BodyExt;
|
7294 6897 | let body = http_response
|
7295 6898 | .into_body()
|
7296 6899 | .collect()
|
7297 6900 | .await
|
7298 6901 | .expect("unable to collect body")
|
7299 6902 | .to_bytes();
|
7300 6903 | ::aws_smithy_protocol_test::assert_ok(
|
7301 - | ::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"))
|
6904 + | ::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"))
|
7302 6905 | );
|
7303 6906 | }
|
7304 6907 | }
|
6908 + | }
|
7305 6909 |
|
7306 - | /// When a string member does not fit within length bounds,
|
6910 + | ::pin_project_lite::pin_project! {
|
6911 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
6912 + | /// [`MalformedRequiredInput`](crate::input::MalformedRequiredInput) using modelled bindings.
|
6913 + | pub struct MalformedRequiredInputFuture {
|
6914 + | 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>>
|
6915 + | }
|
6916 + | }
|
6917 + |
|
6918 + | impl std::future::Future for MalformedRequiredInputFuture {
|
6919 + | type Output = Result<
|
6920 + | crate::input::MalformedRequiredInput,
|
6921 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
6922 + | >;
|
6923 + |
|
6924 + | fn poll(
|
6925 + | self: std::pin::Pin<&mut Self>,
|
6926 + | cx: &mut std::task::Context<'_>,
|
6927 + | ) -> std::task::Poll<Self::Output> {
|
6928 + | let this = self.project();
|
6929 + | this.inner.as_mut().poll(cx)
|
6930 + | }
|
6931 + | }
|
6932 + |
|
6933 + | impl<B>
|
6934 + | ::aws_smithy_http_server::request::FromRequest<
|
6935 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6936 + | B,
|
6937 + | > for crate::input::MalformedRequiredInput
|
6938 + | where
|
6939 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
6940 + | B: 'static,
|
6941 + |
|
6942 + | B::Data: Send,
|
6943 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
6944 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
6945 + | {
|
6946 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
6947 + | type Future = MalformedRequiredInputFuture;
|
6948 + |
|
6949 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
6950 + | let fut = async move {
|
6951 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
6952 + | request.headers(),
|
6953 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
6954 + | ) {
|
6955 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
6956 + | }
|
6957 + | crate::protocol_serde::shape_malformed_required::de_malformed_required_http_request(
|
6958 + | request,
|
6959 + | )
|
6960 + | .await
|
6961 + | };
|
6962 + | use ::futures_util::future::TryFutureExt;
|
6963 + | let fut = fut.map_err(
|
6964 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
6965 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
6966 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
6967 + | e,
|
6968 + | )
|
6969 + | },
|
6970 + | );
|
6971 + | MalformedRequiredInputFuture {
|
6972 + | inner: Box::pin(fut),
|
6973 + | }
|
6974 + | }
|
6975 + | }
|
6976 + | impl
|
6977 + | ::aws_smithy_http_server::response::IntoResponse<
|
6978 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6979 + | > for crate::output::MalformedRequiredOutput
|
6980 + | {
|
6981 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6982 + | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_response(
|
6983 + | self,
|
6984 + | ) {
|
6985 + | Ok(response) => response,
|
6986 + | Err(e) => {
|
6987 + | ::tracing::error!(error = %e, "failed to serialize response");
|
6988 + | ::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))
|
6989 + | }
|
6990 + | }
|
6991 + | }
|
6992 + | }
|
6993 + | impl
|
6994 + | ::aws_smithy_http_server::response::IntoResponse<
|
6995 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6996 + | > for crate::error::MalformedRequiredError
|
6997 + | {
|
6998 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
6999 + | match crate::protocol_serde::shape_malformed_required::ser_malformed_required_http_error(
|
7000 + | &self,
|
7001 + | ) {
|
7002 + | Ok(mut response) => {
|
7003 + | response.extensions_mut().insert(
|
7004 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
7005 + | );
|
7006 + | response
|
7007 + | }
|
7008 + | Err(e) => {
|
7009 + | ::tracing::error!(error = %e, "failed to serialize response");
|
7010 + | ::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))
|
7011 + | }
|
7012 + | }
|
7013 + | }
|
7014 + | }
|
7015 + |
|
7016 + | #[allow(unreachable_code, unused_variables)]
|
7017 + | #[cfg(test)]
|
7018 + | mod malformed_required_test {
|
7019 + |
|
7020 + | /// When a required member is not set in the message body,
|
7307 7021 | /// the response should be a 400 ValidationException.
|
7308 - | /// Test ID: RestJsonMalformedLengthMaxString
|
7022 + | /// Test ID: RestJsonMalformedRequiredBodyUnset
|
7309 7023 | #[::tokio::test]
|
7310 7024 | #[::tracing_test::traced_test]
|
7311 - | async fn rest_json_malformed_length_max_string_malformed_request() {
|
7025 + | async fn rest_json_malformed_required_body_unset_malformed_request() {
|
7312 7026 | {
|
7313 7027 | #[allow(unused_mut)]
|
7314 7028 | let mut http_request = ::http_1x::Request::builder()
|
7315 - | .uri("/MalformedLength")
|
7029 + | .uri("/MalformedRequired")
|
7316 7030 | .method("POST")
|
7317 7031 | .header("content-type", "application/json")
|
7032 + | .header("string-in-headers", "abc")
|
7318 7033 | .body(::aws_smithy_http_server::body::boxed(
|
7319 7034 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7320 7035 | &::aws_smithy_protocol_test::decode_body_data(
|
7321 - | "{ \"maxString\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
7036 + | "{ }".as_bytes(),
|
7322 7037 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7323 7038 | ),
|
7324 7039 | )),
|
7325 7040 | ))
|
7326 7041 | .unwrap();
|
7042 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
7327 7043 | #[allow(unused_mut)]
|
7328 7044 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7329 7045 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7330 7046 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7331 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7047 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
7332 7048 | let sender = sender.clone();
|
7333 7049 | async move {
|
7334 - | 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> };
|
7050 + | 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> };
|
7335 7051 | sender.send(()).await.expect("receiver dropped early");
|
7336 7052 | result
|
7337 7053 | }
|
7338 7054 | })
|
7339 7055 | .build_unchecked();
|
7340 7056 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7341 7057 | .await
|
7342 7058 | .expect("unable to make an HTTP request");
|
7343 7059 | ::pretty_assertions::assert_eq!(
|
7344 7060 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7345 7061 | http_response.status()
|
7346 7062 | );
|
7347 7063 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7348 7064 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7349 7065 | http_response.headers(),
|
7350 7066 | expected_headers,
|
7351 7067 | ));
|
7352 7068 | use ::http_body_util::BodyExt;
|
7353 7069 | let body = http_response
|
7354 7070 | .into_body()
|
7355 7071 | .collect()
|
7356 7072 | .await
|
7357 7073 | .expect("unable to collect body")
|
7358 7074 | .to_bytes();
|
7359 7075 | ::aws_smithy_protocol_test::assert_ok(
|
7360 - | ::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"))
|
7076 + | ::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"))
|
7361 7077 | );
|
7362 7078 | }
|
7363 7079 | }
|
7364 7080 |
|
7365 - | /// When a list member does not fit within length bounds,
|
7081 + | /// When a required member is set to null in the message body,
|
7366 7082 | /// the response should be a 400 ValidationException.
|
7367 - | /// Test ID: RestJsonMalformedLengthList_case0
|
7083 + | /// Test ID: RestJsonMalformedRequiredBodyExplicitNull
|
7368 7084 | #[::tokio::test]
|
7369 7085 | #[::tracing_test::traced_test]
|
7370 - | async fn rest_json_malformed_length_list_case0_malformed_request() {
|
7086 + | async fn rest_json_malformed_required_body_explicit_null_malformed_request() {
|
7371 7087 | {
|
7372 7088 | #[allow(unused_mut)]
|
7373 7089 | let mut http_request = ::http_1x::Request::builder()
|
7374 - | .uri("/MalformedLength")
|
7090 + | .uri("/MalformedRequired")
|
7375 7091 | .method("POST")
|
7376 7092 | .header("content-type", "application/json")
|
7093 + | .header("string-in-headers", "abc")
|
7377 7094 | .body(::aws_smithy_http_server::body::boxed(
|
7378 7095 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7379 7096 | &::aws_smithy_protocol_test::decode_body_data(
|
7380 - | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
7097 + | "{ \"string\": null }".as_bytes(),
|
7381 7098 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7382 7099 | ),
|
7383 7100 | )),
|
7384 7101 | ))
|
7385 7102 | .unwrap();
|
7103 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
7386 7104 | #[allow(unused_mut)]
|
7387 7105 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7388 7106 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7389 7107 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7390 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7391 - | let sender = sender.clone();
|
7392 - | async move {
|
7393 - | 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> };
|
7394 - | sender.send(()).await.expect("receiver dropped early");
|
7395 - | result
|
7396 - | }
|
7397 - | })
|
7398 - | .build_unchecked();
|
7399 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7400 - | .await
|
7401 - | .expect("unable to make an HTTP request");
|
7402 - | ::pretty_assertions::assert_eq!(
|
7403 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7404 - | http_response.status()
|
7405 - | );
|
7406 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7407 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7408 - | http_response.headers(),
|
7409 - | expected_headers,
|
7410 - | ));
|
7411 - | use ::http_body_util::BodyExt;
|
7412 - | let body = http_response
|
7413 - | .into_body()
|
7414 - | .collect()
|
7415 - | .await
|
7416 - | .expect("unable to collect body")
|
7417 - | .to_bytes();
|
7418 - | ::aws_smithy_protocol_test::assert_ok(
|
7419 - | ::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"))
|
7420 - | );
|
7421 - | }
|
7422 - | }
|
7423 - |
|
7424 - | /// When a list member does not fit within length bounds,
|
7425 - | /// the response should be a 400 ValidationException.
|
7426 - | /// Test ID: RestJsonMalformedLengthList_case1
|
7427 - | #[::tokio::test]
|
7428 - | #[::tracing_test::traced_test]
|
7429 - | async fn rest_json_malformed_length_list_case1_malformed_request() {
|
7430 - | {
|
7431 - | #[allow(unused_mut)]
|
7432 - | let mut http_request = ::http_1x::Request::builder()
|
7433 - | .uri("/MalformedLength")
|
7434 - | .method("POST")
|
7435 - | .header("content-type", "application/json")
|
7436 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7437 - | ::bytes::Bytes::copy_from_slice(
|
7438 - | &::aws_smithy_protocol_test::decode_body_data("{ \"list\" : [\"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\", \"abc\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7439 - | )
|
7440 - | ))).unwrap();
|
7441 - | #[allow(unused_mut)]
|
7442 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7443 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7444 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7445 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7108 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
7446 7109 | let sender = sender.clone();
|
7447 7110 | async move {
|
7448 - | 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> };
|
7111 + | 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> };
|
7449 7112 | sender.send(()).await.expect("receiver dropped early");
|
7450 7113 | result
|
7451 7114 | }
|
7452 7115 | })
|
7453 7116 | .build_unchecked();
|
7454 7117 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7455 7118 | .await
|
7456 7119 | .expect("unable to make an HTTP request");
|
7457 7120 | ::pretty_assertions::assert_eq!(
|
7458 7121 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7459 7122 | http_response.status()
|
7460 7123 | );
|
7461 7124 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7462 7125 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7463 7126 | http_response.headers(),
|
7464 7127 | expected_headers,
|
7465 7128 | ));
|
7466 7129 | use ::http_body_util::BodyExt;
|
7467 7130 | let body = http_response
|
7468 7131 | .into_body()
|
7469 7132 | .collect()
|
7470 7133 | .await
|
7471 7134 | .expect("unable to collect body")
|
7472 7135 | .to_bytes();
|
7473 7136 | ::aws_smithy_protocol_test::assert_ok(
|
7474 - | ::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"))
|
7137 + | ::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"))
|
7475 7138 | );
|
7476 7139 | }
|
7477 7140 | }
|
7478 7141 |
|
7479 - | /// When a list member's value does not fit within length bounds,
|
7142 + | /// When a required member is not set in headers,
|
7480 7143 | /// the response should be a 400 ValidationException.
|
7481 - | /// Test ID: RestJsonMalformedLengthListValue_case0
|
7144 + | /// Test ID: RestJsonMalformedRequiredHeaderUnset
|
7482 7145 | #[::tokio::test]
|
7483 7146 | #[::tracing_test::traced_test]
|
7484 - | async fn rest_json_malformed_length_list_value_case0_malformed_request() {
|
7147 + | async fn rest_json_malformed_required_header_unset_malformed_request() {
|
7485 7148 | {
|
7486 7149 | #[allow(unused_mut)]
|
7487 7150 | let mut http_request = ::http_1x::Request::builder()
|
7488 - | .uri("/MalformedLength")
|
7151 + | .uri("/MalformedRequired")
|
7489 7152 | .method("POST")
|
7490 7153 | .header("content-type", "application/json")
|
7491 7154 | .body(::aws_smithy_http_server::body::boxed(
|
7492 7155 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7493 7156 | &::aws_smithy_protocol_test::decode_body_data(
|
7494 - | "{ \"list\" : [\"a\", \"abc\"] }".as_bytes(),
|
7157 + | "{ \"string\": \"abc\" }".as_bytes(),
|
7495 7158 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7496 7159 | ),
|
7497 7160 | )),
|
7498 7161 | ))
|
7499 7162 | .unwrap();
|
7163 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
7500 7164 | #[allow(unused_mut)]
|
7501 7165 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7502 7166 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7503 7167 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7504 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7168 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
7505 7169 | let sender = sender.clone();
|
7506 7170 | async move {
|
7507 - | 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> };
|
7171 + | 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> };
|
7508 7172 | sender.send(()).await.expect("receiver dropped early");
|
7509 7173 | result
|
7510 7174 | }
|
7511 7175 | })
|
7512 7176 | .build_unchecked();
|
7513 7177 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7514 7178 | .await
|
7515 7179 | .expect("unable to make an HTTP request");
|
7516 7180 | ::pretty_assertions::assert_eq!(
|
7517 7181 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7518 7182 | http_response.status()
|
7519 7183 | );
|
7520 7184 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7521 7185 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7522 7186 | http_response.headers(),
|
7523 7187 | expected_headers,
|
7524 7188 | ));
|
7525 7189 | use ::http_body_util::BodyExt;
|
7526 7190 | let body = http_response
|
7527 7191 | .into_body()
|
7528 7192 | .collect()
|
7529 7193 | .await
|
7530 7194 | .expect("unable to collect body")
|
7531 7195 | .to_bytes();
|
7532 7196 | ::aws_smithy_protocol_test::assert_ok(
|
7533 - | ::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"))
|
7197 + | ::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"))
|
7534 7198 | );
|
7535 7199 | }
|
7536 7200 | }
|
7201 + | }
|
7537 7202 |
|
7538 - | /// When a list member's value does not fit within length bounds,
|
7539 - | /// the response should be a 400 ValidationException.
|
7540 - | /// Test ID: RestJsonMalformedLengthListValue_case1
|
7541 - | #[::tokio::test]
|
7542 - | #[::tracing_test::traced_test]
|
7543 - | async fn rest_json_malformed_length_list_value_case1_malformed_request() {
|
7544 - | {
|
7545 - | #[allow(unused_mut)]
|
7546 - | let mut http_request = ::http_1x::Request::builder()
|
7547 - | .uri("/MalformedLength")
|
7548 - | .method("POST")
|
7549 - | .header("content-type", "application/json")
|
7550 - | .body(::aws_smithy_http_server::body::boxed(
|
7203 + | ::pin_project_lite::pin_project! {
|
7204 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
7205 + | /// [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) using modelled bindings.
|
7206 + | pub struct MalformedUniqueItemsInputFuture {
|
7207 + | 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>>
|
7208 + | }
|
7209 + | }
|
7210 + |
|
7211 + | impl std::future::Future for MalformedUniqueItemsInputFuture {
|
7212 + | type Output = Result<
|
7213 + | crate::input::MalformedUniqueItemsInput,
|
7214 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
7215 + | >;
|
7216 + |
|
7217 + | fn poll(
|
7218 + | self: std::pin::Pin<&mut Self>,
|
7219 + | cx: &mut std::task::Context<'_>,
|
7220 + | ) -> std::task::Poll<Self::Output> {
|
7221 + | let this = self.project();
|
7222 + | this.inner.as_mut().poll(cx)
|
7223 + | }
|
7224 + | }
|
7225 + |
|
7226 + | impl<B>
|
7227 + | ::aws_smithy_http_server::request::FromRequest<
|
7228 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7229 + | B,
|
7230 + | > for crate::input::MalformedUniqueItemsInput
|
7231 + | where
|
7232 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
7233 + | B: 'static,
|
7234 + |
|
7235 + | B::Data: Send,
|
7236 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
7237 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
7238 + | {
|
7239 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
7240 + | type Future = MalformedUniqueItemsInputFuture;
|
7241 + |
|
7242 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
7243 + | let fut = async move {
|
7244 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
7245 + | request.headers(),
|
7246 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
7247 + | ) {
|
7248 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7249 + | }
|
7250 + | crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items_http_request(request)
|
7251 + | .await
|
7252 + | };
|
7253 + | use ::futures_util::future::TryFutureExt;
|
7254 + | let fut = fut.map_err(
|
7255 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
7256 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
7257 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
7258 + | e,
|
7259 + | )
|
7260 + | },
|
7261 + | );
|
7262 + | MalformedUniqueItemsInputFuture {
|
7263 + | inner: Box::pin(fut),
|
7264 + | }
|
7265 + | }
|
7266 + | }
|
7267 + | impl
|
7268 + | ::aws_smithy_http_server::response::IntoResponse<
|
7269 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7270 + | > for crate::output::MalformedUniqueItemsOutput
|
7271 + | {
|
7272 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7273 + | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_response(self) {
|
7274 + | Ok(response) => response,
|
7275 + | Err(e) => {
|
7276 + | ::tracing::error!(error = %e, "failed to serialize response");
|
7277 + | ::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))
|
7278 + | }
|
7279 + | }
|
7280 + | }
|
7281 + | }
|
7282 + | impl
|
7283 + | ::aws_smithy_http_server::response::IntoResponse<
|
7284 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7285 + | > for crate::error::MalformedUniqueItemsError
|
7286 + | {
|
7287 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
7288 + | match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_error(&self) {
|
7289 + | Ok(mut response) => {
|
7290 + | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
7291 + | response
|
7292 + | },
|
7293 + | Err(e) => {
|
7294 + | ::tracing::error!(error = %e, "failed to serialize response");
|
7295 + | ::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))
|
7296 + | }
|
7297 + | }
|
7298 + | }
|
7299 + | }
|
7300 + |
|
7301 + | #[allow(unreachable_code, unused_variables)]
|
7302 + | #[cfg(test)]
|
7303 + | mod malformed_unique_items_test {
|
7304 + |
|
7305 + | /// When a blob list contains non-unique values,
|
7306 + | /// the response should be a 400 ValidationException.
|
7307 + | /// Test ID: RestJsonMalformedUniqueItemsBlobList
|
7308 + | #[::tokio::test]
|
7309 + | #[::tracing_test::traced_test]
|
7310 + | #[should_panic]
|
7311 + | async fn rest_json_malformed_unique_items_blob_list_malformed_request() {
|
7312 + | {
|
7313 + | #[allow(unused_mut)]
|
7314 + | let mut http_request = ::http_1x::Request::builder()
|
7315 + | .uri("/MalformedUniqueItems")
|
7316 + | .method("POST")
|
7317 + | .header("content-type", "application/json")
|
7318 + | .body(::aws_smithy_http_server::body::boxed(
|
7551 7319 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7552 7320 | &::aws_smithy_protocol_test::decode_body_data(
|
7553 - | "{ \"list\" : [\"abcdefghijklmnopqrstuvwxyz\", \"abc\"] }".as_bytes(),
|
7321 + | "{ \"blobList\" : [\"YQ==\", \"YQ==\"] }".as_bytes(),
|
7554 7322 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7555 7323 | ),
|
7556 7324 | )),
|
7557 7325 | ))
|
7558 7326 | .unwrap();
|
7559 7327 | #[allow(unused_mut)]
|
7560 7328 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7561 7329 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7562 7330 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7563 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7331 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7564 7332 | let sender = sender.clone();
|
7565 7333 | async move {
|
7566 - | 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> };
|
7334 + | 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> };
|
7567 7335 | sender.send(()).await.expect("receiver dropped early");
|
7568 7336 | result
|
7569 7337 | }
|
7570 7338 | })
|
7571 7339 | .build_unchecked();
|
7572 7340 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7573 7341 | .await
|
7574 7342 | .expect("unable to make an HTTP request");
|
7575 7343 | ::pretty_assertions::assert_eq!(
|
7576 7344 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7577 7345 | http_response.status()
|
7578 7346 | );
|
7579 7347 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7580 7348 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7581 7349 | http_response.headers(),
|
7582 7350 | expected_headers,
|
7583 7351 | ));
|
7584 7352 | use ::http_body_util::BodyExt;
|
7585 7353 | let body = http_response
|
7586 7354 | .into_body()
|
7587 7355 | .collect()
|
7588 7356 | .await
|
7589 7357 | .expect("unable to collect body")
|
7590 7358 | .to_bytes();
|
7591 7359 | ::aws_smithy_protocol_test::assert_ok(
|
7592 - | ::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"))
|
7360 + | ::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"))
|
7593 7361 | );
|
7594 7362 | }
|
7595 7363 | }
|
7596 7364 |
|
7597 - | /// When a map member does not fit within length bounds,
|
7365 + | /// When a boolean list contains non-unique values,
|
7598 7366 | /// the response should be a 400 ValidationException.
|
7599 - | /// Test ID: RestJsonMalformedLengthMap_case0
|
7367 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case0
|
7600 7368 | #[::tokio::test]
|
7601 7369 | #[::tracing_test::traced_test]
|
7602 - | async fn rest_json_malformed_length_map_case0_malformed_request() {
|
7370 + | #[should_panic]
|
7371 + | async fn rest_json_malformed_unique_items_boolean_list_case0_malformed_request() {
|
7603 7372 | {
|
7604 7373 | #[allow(unused_mut)]
|
7605 7374 | let mut http_request = ::http_1x::Request::builder()
|
7606 - | .uri("/MalformedLength")
|
7375 + | .uri("/MalformedUniqueItems")
|
7607 7376 | .method("POST")
|
7608 7377 | .header("content-type", "application/json")
|
7609 7378 | .body(::aws_smithy_http_server::body::boxed(
|
7610 7379 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7611 7380 | &::aws_smithy_protocol_test::decode_body_data(
|
7612 - | "{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"]} }".as_bytes(),
|
7381 + | "{ \"booleanList\" : [true, true] }".as_bytes(),
|
7613 7382 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7614 7383 | ),
|
7615 7384 | )),
|
7616 7385 | ))
|
7617 7386 | .unwrap();
|
7618 7387 | #[allow(unused_mut)]
|
7619 7388 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7620 7389 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7621 7390 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7622 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7391 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7623 7392 | let sender = sender.clone();
|
7624 7393 | async move {
|
7625 - | 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> };
|
7394 + | 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> };
|
7626 7395 | sender.send(()).await.expect("receiver dropped early");
|
7627 7396 | result
|
7628 7397 | }
|
7629 7398 | })
|
7630 7399 | .build_unchecked();
|
7631 7400 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7632 7401 | .await
|
7633 7402 | .expect("unable to make an HTTP request");
|
7634 7403 | ::pretty_assertions::assert_eq!(
|
7635 7404 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7636 7405 | http_response.status()
|
7637 7406 | );
|
7638 7407 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7639 7408 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7640 7409 | http_response.headers(),
|
7641 7410 | expected_headers,
|
7642 7411 | ));
|
7643 7412 | use ::http_body_util::BodyExt;
|
7644 7413 | let body = http_response
|
7645 7414 | .into_body()
|
7646 7415 | .collect()
|
7647 7416 | .await
|
7648 7417 | .expect("unable to collect body")
|
7649 7418 | .to_bytes();
|
7650 7419 | ::aws_smithy_protocol_test::assert_ok(
|
7651 - | ::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"))
|
7420 + | ::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"))
|
7652 7421 | );
|
7653 7422 | }
|
7654 7423 | }
|
7655 7424 |
|
7656 - | /// When a map member does not fit within length bounds,
|
7425 + | /// When a boolean list contains non-unique values,
|
7657 7426 | /// the response should be a 400 ValidationException.
|
7658 - | /// Test ID: RestJsonMalformedLengthMap_case1
|
7427 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case1
|
7659 7428 | #[::tokio::test]
|
7660 7429 | #[::tracing_test::traced_test]
|
7661 - | async fn rest_json_malformed_length_map_case1_malformed_request() {
|
7430 + | #[should_panic]
|
7431 + | async fn rest_json_malformed_unique_items_boolean_list_case1_malformed_request() {
|
7662 7432 | {
|
7663 7433 | #[allow(unused_mut)]
|
7664 7434 | let mut http_request = ::http_1x::Request::builder()
|
7665 - | .uri("/MalformedLength")
|
7435 + | .uri("/MalformedUniqueItems")
|
7666 7436 | .method("POST")
|
7667 7437 | .header("content-type", "application/json")
|
7668 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7669 - | ::bytes::Bytes::copy_from_slice(
|
7670 - | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"], \"def\": [\"abc\", \"def\", \"efg\"],\n \"efg\": [\"abc\", \"def\", \"efg\"], \"fgh\": [\"abc\", \"def\", \"efg\"],\n \"ghi\": [\"abc\", \"def\", \"efg\"], \"jkl\": [\"abc\", \"def\", \"efg\"],\n \"klm\": [\"abc\", \"def\", \"efg\"], \"lmn\": [\"abc\", \"def\", \"efg\"] } }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7671 - | )
|
7672 - | ))).unwrap();
|
7438 + | .body(::aws_smithy_http_server::body::boxed(
|
7439 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7440 + | &::aws_smithy_protocol_test::decode_body_data(
|
7441 + | "{ \"booleanList\" : [false, false] }".as_bytes(),
|
7442 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7443 + | ),
|
7444 + | )),
|
7445 + | ))
|
7446 + | .unwrap();
|
7673 7447 | #[allow(unused_mut)]
|
7674 7448 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7675 7449 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7676 7450 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7677 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7451 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7678 7452 | let sender = sender.clone();
|
7679 7453 | async move {
|
7680 - | 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> };
|
7454 + | 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> };
|
7681 7455 | sender.send(()).await.expect("receiver dropped early");
|
7682 7456 | result
|
7683 7457 | }
|
7684 7458 | })
|
7685 7459 | .build_unchecked();
|
7686 7460 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7687 7461 | .await
|
7688 7462 | .expect("unable to make an HTTP request");
|
7689 7463 | ::pretty_assertions::assert_eq!(
|
7690 7464 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7691 7465 | http_response.status()
|
7692 7466 | );
|
7693 7467 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7694 7468 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7695 7469 | http_response.headers(),
|
7696 7470 | expected_headers,
|
7697 7471 | ));
|
7698 7472 | use ::http_body_util::BodyExt;
|
7699 7473 | let body = http_response
|
7700 7474 | .into_body()
|
7701 7475 | .collect()
|
7702 7476 | .await
|
7703 7477 | .expect("unable to collect body")
|
7704 7478 | .to_bytes();
|
7705 7479 | ::aws_smithy_protocol_test::assert_ok(
|
7706 - | ::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"))
|
7480 + | ::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"))
|
7707 7481 | );
|
7708 7482 | }
|
7709 7483 | }
|
7710 7484 |
|
7711 - | /// When a map member's key does not fit within length bounds,
|
7485 + | /// When a string list contains non-unique values,
|
7712 7486 | /// the response should be a 400 ValidationException.
|
7713 - | /// Test ID: RestJsonMalformedLengthMapKey_case0
|
7487 + | /// Test ID: RestJsonMalformedUniqueItemsStringList
|
7714 7488 | #[::tokio::test]
|
7715 7489 | #[::tracing_test::traced_test]
|
7716 - | async fn rest_json_malformed_length_map_key_case0_malformed_request() {
|
7490 + | #[should_panic]
|
7491 + | async fn rest_json_malformed_unique_items_string_list_malformed_request() {
|
7717 7492 | {
|
7718 7493 | #[allow(unused_mut)]
|
7719 7494 | let mut http_request = ::http_1x::Request::builder()
|
7720 - | .uri("/MalformedLength")
|
7495 + | .uri("/MalformedUniqueItems")
|
7721 7496 | .method("POST")
|
7722 7497 | .header("content-type", "application/json")
|
7723 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7724 - | ::bytes::Bytes::copy_from_slice(
|
7725 - | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"a\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7726 - | )
|
7727 - | ))).unwrap();
|
7498 + | .body(::aws_smithy_http_server::body::boxed(
|
7499 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7500 + | &::aws_smithy_protocol_test::decode_body_data(
|
7501 + | "{ \"stringList\" : [\"abc\", \"abc\"] }".as_bytes(),
|
7502 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7503 + | ),
|
7504 + | )),
|
7505 + | ))
|
7506 + | .unwrap();
|
7728 7507 | #[allow(unused_mut)]
|
7729 7508 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7730 7509 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7731 7510 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7732 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7511 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7733 7512 | let sender = sender.clone();
|
7734 7513 | async move {
|
7735 - | 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> };
|
7514 + | 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> };
|
7736 7515 | sender.send(()).await.expect("receiver dropped early");
|
7737 7516 | result
|
7738 7517 | }
|
7739 7518 | })
|
7740 7519 | .build_unchecked();
|
7741 7520 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7742 7521 | .await
|
7743 7522 | .expect("unable to make an HTTP request");
|
7744 7523 | ::pretty_assertions::assert_eq!(
|
7745 7524 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7746 7525 | http_response.status()
|
7747 7526 | );
|
7748 7527 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7749 7528 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7750 7529 | http_response.headers(),
|
7751 7530 | expected_headers,
|
7752 7531 | ));
|
7753 7532 | use ::http_body_util::BodyExt;
|
7754 7533 | let body = http_response
|
7755 7534 | .into_body()
|
7756 7535 | .collect()
|
7757 7536 | .await
|
7758 7537 | .expect("unable to collect body")
|
7759 7538 | .to_bytes();
|
7760 7539 | ::aws_smithy_protocol_test::assert_ok(
|
7761 - | ::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"))
|
7540 + | ::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"))
|
7762 7541 | );
|
7763 7542 | }
|
7764 7543 | }
|
7765 7544 |
|
7766 - | /// When a map member's key does not fit within length bounds,
|
7545 + | /// When a byte list contains non-unique values,
|
7767 7546 | /// the response should be a 400 ValidationException.
|
7768 - | /// Test ID: RestJsonMalformedLengthMapKey_case1
|
7547 + | /// Test ID: RestJsonMalformedUniqueItemsByteList
|
7769 7548 | #[::tokio::test]
|
7770 7549 | #[::tracing_test::traced_test]
|
7771 - | async fn rest_json_malformed_length_map_key_case1_malformed_request() {
|
7550 + | #[should_panic]
|
7551 + | async fn rest_json_malformed_unique_items_byte_list_malformed_request() {
|
7772 7552 | {
|
7773 7553 | #[allow(unused_mut)]
|
7774 7554 | let mut http_request = ::http_1x::Request::builder()
|
7775 - | .uri("/MalformedLength")
|
7555 + | .uri("/MalformedUniqueItems")
|
7776 7556 | .method("POST")
|
7777 7557 | .header("content-type", "application/json")
|
7778 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7779 - | ::bytes::Bytes::copy_from_slice(
|
7780 - | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abcdefghijklmnopqrstuvwxyz\": [\"abc\", \"def\", \"efg\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7781 - | )
|
7782 - | ))).unwrap();
|
7558 + | .body(::aws_smithy_http_server::body::boxed(
|
7559 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7560 + | &::aws_smithy_protocol_test::decode_body_data(
|
7561 + | "{ \"byteList\" : [1, 1] }".as_bytes(),
|
7562 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7563 + | ),
|
7564 + | )),
|
7565 + | ))
|
7566 + | .unwrap();
|
7783 7567 | #[allow(unused_mut)]
|
7784 7568 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7785 7569 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7786 7570 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7787 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7571 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7788 7572 | let sender = sender.clone();
|
7789 7573 | async move {
|
7790 - | 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> };
|
7574 + | 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> };
|
7791 7575 | sender.send(()).await.expect("receiver dropped early");
|
7792 7576 | result
|
7793 7577 | }
|
7794 7578 | })
|
7795 7579 | .build_unchecked();
|
7796 7580 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7797 7581 | .await
|
7798 7582 | .expect("unable to make an HTTP request");
|
7799 7583 | ::pretty_assertions::assert_eq!(
|
7800 7584 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7801 7585 | http_response.status()
|
7802 7586 | );
|
7803 7587 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7804 7588 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7805 7589 | http_response.headers(),
|
7806 7590 | expected_headers,
|
7807 7591 | ));
|
7808 7592 | use ::http_body_util::BodyExt;
|
7809 7593 | let body = http_response
|
7810 7594 | .into_body()
|
7811 7595 | .collect()
|
7812 7596 | .await
|
7813 7597 | .expect("unable to collect body")
|
7814 7598 | .to_bytes();
|
7815 7599 | ::aws_smithy_protocol_test::assert_ok(
|
7816 - | ::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"))
|
7600 + | ::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"))
|
7817 7601 | );
|
7818 7602 | }
|
7819 7603 | }
|
7820 7604 |
|
7821 - | /// When a map member's value does not fit within length bounds,
|
7605 + | /// When a short list contains non-unique values,
|
7822 7606 | /// the response should be a 400 ValidationException.
|
7823 - | /// Test ID: RestJsonMalformedLengthMapValue_case0
|
7607 + | /// Test ID: RestJsonMalformedUniqueItemsShortList
|
7824 7608 | #[::tokio::test]
|
7825 7609 | #[::tracing_test::traced_test]
|
7826 - | async fn rest_json_malformed_length_map_value_case0_malformed_request() {
|
7610 + | #[should_panic]
|
7611 + | async fn rest_json_malformed_unique_items_short_list_malformed_request() {
|
7827 7612 | {
|
7828 7613 | #[allow(unused_mut)]
|
7829 7614 | let mut http_request = ::http_1x::Request::builder()
|
7830 - | .uri("/MalformedLength")
|
7615 + | .uri("/MalformedUniqueItems")
|
7831 7616 | .method("POST")
|
7832 7617 | .header("content-type", "application/json")
|
7833 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7834 - | ::bytes::Bytes::copy_from_slice(
|
7835 - | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\"], \"bcd\": [\"abc\", \"def\", \"efg\"], \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7836 - | )
|
7837 - | ))).unwrap();
|
7618 + | .body(::aws_smithy_http_server::body::boxed(
|
7619 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7620 + | &::aws_smithy_protocol_test::decode_body_data(
|
7621 + | "{ \"shortList\" : [2, 2] }".as_bytes(),
|
7622 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7623 + | ),
|
7624 + | )),
|
7625 + | ))
|
7626 + | .unwrap();
|
7838 7627 | #[allow(unused_mut)]
|
7839 7628 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7840 7629 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7841 7630 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7842 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7631 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7843 7632 | let sender = sender.clone();
|
7844 7633 | async move {
|
7845 - | 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> };
|
7634 + | 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> };
|
7846 7635 | sender.send(()).await.expect("receiver dropped early");
|
7847 7636 | result
|
7848 7637 | }
|
7849 7638 | })
|
7850 7639 | .build_unchecked();
|
7851 7640 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7852 7641 | .await
|
7853 7642 | .expect("unable to make an HTTP request");
|
7854 7643 | ::pretty_assertions::assert_eq!(
|
7855 7644 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7856 7645 | http_response.status()
|
7857 7646 | );
|
7858 7647 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7859 7648 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7860 7649 | http_response.headers(),
|
7861 7650 | expected_headers,
|
7862 7651 | ));
|
7863 7652 | use ::http_body_util::BodyExt;
|
7864 7653 | let body = http_response
|
7865 7654 | .into_body()
|
7866 7655 | .collect()
|
7867 7656 | .await
|
7868 7657 | .expect("unable to collect body")
|
7869 7658 | .to_bytes();
|
7870 7659 | ::aws_smithy_protocol_test::assert_ok(
|
7871 - | ::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"))
|
7660 + | ::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"))
|
7872 7661 | );
|
7873 7662 | }
|
7874 7663 | }
|
7875 7664 |
|
7876 - | /// When a map member's value does not fit within length bounds,
|
7665 + | /// When an integer list contains non-unique values,
|
7877 7666 | /// the response should be a 400 ValidationException.
|
7878 - | /// Test ID: RestJsonMalformedLengthMapValue_case1
|
7667 + | /// Test ID: RestJsonMalformedUniqueItemsIntegerList
|
7879 7668 | #[::tokio::test]
|
7880 7669 | #[::tracing_test::traced_test]
|
7881 - | async fn rest_json_malformed_length_map_value_case1_malformed_request() {
|
7670 + | #[should_panic]
|
7671 + | async fn rest_json_malformed_unique_items_integer_list_malformed_request() {
|
7882 7672 | {
|
7883 7673 | #[allow(unused_mut)]
|
7884 7674 | let mut http_request = ::http_1x::Request::builder()
|
7885 - | .uri("/MalformedLength")
|
7675 + | .uri("/MalformedUniqueItems")
|
7886 7676 | .method("POST")
|
7887 7677 | .header("content-type", "application/json")
|
7888 - | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7889 - | ::bytes::Bytes::copy_from_slice(
|
7890 - | &::aws_smithy_protocol_test::decode_body_data("{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\", \"efg\", \"fgh\", \"def\"],\n \"bcd\": [\"abc\", \"def\", \"efg\"],\n \"cde\": [\"abc\", \"def\", \"efg\"]} }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7891 - | )
|
7892 - | ))).unwrap();
|
7678 + | .body(::aws_smithy_http_server::body::boxed(
|
7679 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7680 + | &::aws_smithy_protocol_test::decode_body_data(
|
7681 + | "{ \"integerList\" : [3, 3] }".as_bytes(),
|
7682 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7683 + | ),
|
7684 + | )),
|
7685 + | ))
|
7686 + | .unwrap();
|
7893 7687 | #[allow(unused_mut)]
|
7894 7688 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7895 7689 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7896 7690 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7897 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7691 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7898 7692 | let sender = sender.clone();
|
7899 7693 | async move {
|
7900 - | 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> };
|
7694 + | 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> };
|
7901 7695 | sender.send(()).await.expect("receiver dropped early");
|
7902 7696 | result
|
7903 7697 | }
|
7904 7698 | })
|
7905 7699 | .build_unchecked();
|
7906 7700 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7907 7701 | .await
|
7908 7702 | .expect("unable to make an HTTP request");
|
7909 7703 | ::pretty_assertions::assert_eq!(
|
7910 7704 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7911 7705 | http_response.status()
|
7912 7706 | );
|
7913 7707 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7914 7708 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7915 7709 | http_response.headers(),
|
7916 7710 | expected_headers,
|
7917 7711 | ));
|
7918 7712 | use ::http_body_util::BodyExt;
|
7919 7713 | let body = http_response
|
7920 7714 | .into_body()
|
7921 7715 | .collect()
|
7922 7716 | .await
|
7923 7717 | .expect("unable to collect body")
|
7924 7718 | .to_bytes();
|
7925 7719 | ::aws_smithy_protocol_test::assert_ok(
|
7926 - | ::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"))
|
7927 - | );
|
7928 - | }
|
7929 - | }
|
7930 - | }
|
7931 - |
|
7932 - | ::pin_project_lite::pin_project! {
|
7933 - | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
7934 - | /// [`MalformedEnumInput`](crate::input::MalformedEnumInput) using modelled bindings.
|
7935 - | pub struct MalformedEnumInputFuture {
|
7936 - | 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>>
|
7937 - | }
|
7938 - | }
|
7939 - |
|
7940 - | impl std::future::Future for MalformedEnumInputFuture {
|
7941 - | type Output = Result<
|
7942 - | crate::input::MalformedEnumInput,
|
7943 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
7944 - | >;
|
7945 - |
|
7946 - | fn poll(
|
7947 - | self: std::pin::Pin<&mut Self>,
|
7948 - | cx: &mut std::task::Context<'_>,
|
7949 - | ) -> std::task::Poll<Self::Output> {
|
7950 - | let this = self.project();
|
7951 - | this.inner.as_mut().poll(cx)
|
7952 - | }
|
7953 - | }
|
7954 - |
|
7955 - | impl<B>
|
7956 - | ::aws_smithy_http_server::request::FromRequest<
|
7957 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7958 - | B,
|
7959 - | > for crate::input::MalformedEnumInput
|
7960 - | where
|
7961 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
7962 - | B: 'static,
|
7963 - |
|
7964 - | B::Data: Send,
|
7965 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
7966 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
7967 - | {
|
7968 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
7969 - | type Future = MalformedEnumInputFuture;
|
7970 - |
|
7971 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
7972 - | let fut = async move {
|
7973 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
7974 - | request.headers(),
|
7975 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
7976 - | ) {
|
7977 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
7978 - | }
|
7979 - | crate::protocol_serde::shape_malformed_enum::de_malformed_enum_http_request(request)
|
7980 - | .await
|
7981 - | };
|
7982 - | use ::futures_util::future::TryFutureExt;
|
7983 - | let fut = fut.map_err(
|
7984 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
7985 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
7986 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
7987 - | e,
|
7988 - | )
|
7989 - | },
|
7990 - | );
|
7991 - | MalformedEnumInputFuture {
|
7992 - | inner: Box::pin(fut),
|
7993 - | }
|
7994 - | }
|
7995 - | }
|
7996 - | impl
|
7997 - | ::aws_smithy_http_server::response::IntoResponse<
|
7998 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
7999 - | > for crate::output::MalformedEnumOutput
|
8000 - | {
|
8001 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
8002 - | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_response(self) {
|
8003 - | Ok(response) => response,
|
8004 - | Err(e) => {
|
8005 - | ::tracing::error!(error = %e, "failed to serialize response");
|
8006 - | ::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))
|
8007 - | }
|
8008 - | }
|
8009 - | }
|
8010 - | }
|
8011 - | impl
|
8012 - | ::aws_smithy_http_server::response::IntoResponse<
|
8013 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
8014 - | > for crate::error::MalformedEnumError
|
8015 - | {
|
8016 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
8017 - | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_error(&self) {
|
8018 - | Ok(mut response) => {
|
8019 - | response.extensions_mut().insert(
|
8020 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
7720 + | ::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"))
|
8021 7721 | );
|
8022 - | response
|
8023 - | }
|
8024 - | Err(e) => {
|
8025 - | ::tracing::error!(error = %e, "failed to serialize response");
|
8026 - | ::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))
|
8027 - | }
|
8028 7722 | }
|
8029 7723 | }
|
8030 - | }
|
8031 - |
|
8032 - | #[allow(unreachable_code, unused_variables)]
|
8033 - | #[cfg(test)]
|
8034 - | mod malformed_enum_test {
|
8035 7724 |
|
8036 - | /// When a string member does not contain a valid enum value,
|
8037 - | /// the response should be a 400 ValidationException. Internal-only
|
8038 - | /// enum values are excluded from the response message.
|
8039 - | /// Test ID: RestJsonMalformedEnumString_case0
|
7725 + | /// When an integer list contains non-unique values,
|
7726 + | /// the response should be a 400 ValidationException.
|
7727 + | /// Test ID: RestJsonMalformedUniqueItemsLongList
|
8040 7728 | #[::tokio::test]
|
8041 7729 | #[::tracing_test::traced_test]
|
8042 7730 | #[should_panic]
|
8043 - | async fn rest_json_malformed_enum_string_case0_malformed_request() {
|
7731 + | async fn rest_json_malformed_unique_items_long_list_malformed_request() {
|
8044 7732 | {
|
8045 7733 | #[allow(unused_mut)]
|
8046 7734 | let mut http_request = ::http_1x::Request::builder()
|
8047 - | .uri("/MalformedEnum")
|
7735 + | .uri("/MalformedUniqueItems")
|
8048 7736 | .method("POST")
|
8049 7737 | .header("content-type", "application/json")
|
8050 7738 | .body(::aws_smithy_http_server::body::boxed(
|
8051 7739 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8052 7740 | &::aws_smithy_protocol_test::decode_body_data(
|
8053 - | "{ \"string\" : \"ABC\" }".as_bytes(),
|
7741 + | "{ \"longList\" : [4, 4] }".as_bytes(),
|
8054 7742 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8055 7743 | ),
|
8056 7744 | )),
|
8057 7745 | ))
|
8058 7746 | .unwrap();
|
8059 7747 | #[allow(unused_mut)]
|
8060 7748 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8061 7749 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8062 7750 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8063 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7751 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8064 7752 | let sender = sender.clone();
|
8065 7753 | async move {
|
8066 - | 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> };
|
7754 + | 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> };
|
8067 7755 | sender.send(()).await.expect("receiver dropped early");
|
8068 7756 | result
|
8069 7757 | }
|
8070 7758 | })
|
8071 7759 | .build_unchecked();
|
8072 7760 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8073 7761 | .await
|
8074 7762 | .expect("unable to make an HTTP request");
|
8075 7763 | ::pretty_assertions::assert_eq!(
|
8076 7764 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8077 7765 | http_response.status()
|
8078 7766 | );
|
8079 7767 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8080 7768 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8081 7769 | http_response.headers(),
|
8082 7770 | expected_headers,
|
8083 7771 | ));
|
8084 7772 | use ::http_body_util::BodyExt;
|
8085 7773 | let body = http_response
|
8086 7774 | .into_body()
|
8087 7775 | .collect()
|
8088 7776 | .await
|
8089 7777 | .expect("unable to collect body")
|
8090 7778 | .to_bytes();
|
8091 7779 | ::aws_smithy_protocol_test::assert_ok(
|
8092 - | ::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"))
|
7780 + | ::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"))
|
8093 7781 | );
|
8094 7782 | }
|
8095 7783 | }
|
8096 7784 |
|
8097 - | /// When a string member does not contain a valid enum value,
|
8098 - | /// the response should be a 400 ValidationException. Internal-only
|
8099 - | /// enum values are excluded from the response message.
|
8100 - | /// Test ID: RestJsonMalformedEnumString_case1
|
7785 + | /// When a timestamp list contains non-unique values,
|
7786 + | /// the response should be a 400 ValidationException.
|
7787 + | /// Test ID: RestJsonMalformedUniqueItemsTimestampList
|
8101 7788 | #[::tokio::test]
|
8102 7789 | #[::tracing_test::traced_test]
|
8103 7790 | #[should_panic]
|
8104 - | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
7791 + | async fn rest_json_malformed_unique_items_timestamp_list_malformed_request() {
|
8105 7792 | {
|
8106 7793 | #[allow(unused_mut)]
|
8107 7794 | let mut http_request = ::http_1x::Request::builder()
|
8108 - | .uri("/MalformedEnum")
|
7795 + | .uri("/MalformedUniqueItems")
|
8109 7796 | .method("POST")
|
8110 7797 | .header("content-type", "application/json")
|
8111 7798 | .body(::aws_smithy_http_server::body::boxed(
|
8112 7799 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8113 7800 | &::aws_smithy_protocol_test::decode_body_data(
|
8114 - | "{ \"string\" : \"XYZ\" }".as_bytes(),
|
7801 + | "{ \"timestampList\" : [1676660607, 1676660607] }".as_bytes(),
|
8115 7802 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8116 7803 | ),
|
8117 7804 | )),
|
8118 7805 | ))
|
8119 7806 | .unwrap();
|
8120 7807 | #[allow(unused_mut)]
|
8121 7808 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8122 7809 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8123 7810 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8124 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7811 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8125 7812 | let sender = sender.clone();
|
8126 7813 | async move {
|
8127 - | 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> };
|
7814 + | 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> };
|
8128 7815 | sender.send(()).await.expect("receiver dropped early");
|
8129 7816 | result
|
8130 7817 | }
|
8131 7818 | })
|
8132 7819 | .build_unchecked();
|
8133 7820 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8134 7821 | .await
|
8135 7822 | .expect("unable to make an HTTP request");
|
8136 7823 | ::pretty_assertions::assert_eq!(
|
8137 7824 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8138 7825 | http_response.status()
|
8139 7826 | );
|
8140 7827 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8141 7828 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8142 7829 | http_response.headers(),
|
8143 7830 | expected_headers,
|
8144 7831 | ));
|
8145 7832 | use ::http_body_util::BodyExt;
|
8146 7833 | let body = http_response
|
8147 7834 | .into_body()
|
8148 7835 | .collect()
|
8149 7836 | .await
|
8150 7837 | .expect("unable to collect body")
|
8151 7838 | .to_bytes();
|
8152 7839 | ::aws_smithy_protocol_test::assert_ok(
|
8153 - | ::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"))
|
7840 + | ::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"))
|
8154 7841 | );
|
8155 7842 | }
|
8156 7843 | }
|
8157 7844 |
|
8158 - | /// When a string member does not contain a valid enum value,
|
8159 - | /// the response should be a 400 ValidationException. Internal-only
|
8160 - | /// enum values are excluded from the response message.
|
8161 - | /// Test ID: RestJsonMalformedEnumTraitString_case0
|
7845 + | /// When a date-time timestamp list contains non-unique values,
|
7846 + | /// the response should be a 400 ValidationException.
|
7847 + | /// Test ID: RestJsonMalformedUniqueItemsDateTimeList
|
8162 7848 | #[::tokio::test]
|
8163 7849 | #[::tracing_test::traced_test]
|
8164 7850 | #[should_panic]
|
8165 - | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
7851 + | async fn rest_json_malformed_unique_items_date_time_list_malformed_request() {
|
8166 7852 | {
|
8167 7853 | #[allow(unused_mut)]
|
8168 7854 | let mut http_request = ::http_1x::Request::builder()
|
8169 - | .uri("/MalformedEnum")
|
7855 + | .uri("/MalformedUniqueItems")
|
8170 7856 | .method("POST")
|
8171 7857 | .header("content-type", "application/json")
|
8172 - | .body(::aws_smithy_http_server::body::boxed(
|
8173 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8174 - | &::aws_smithy_protocol_test::decode_body_data(
|
8175 - | "{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes(),
|
8176 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8177 - | ),
|
8178 - | )),
|
8179 - | ))
|
8180 - | .unwrap();
|
7858 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7859 + | ::bytes::Bytes::copy_from_slice(
|
7860 + | &::aws_smithy_protocol_test::decode_body_data("{ \"dateTimeList\" : [\"1985-04-12T23:20:50.52Z\", \"1985-04-12T23:20:50.52Z\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7861 + | )
|
7862 + | ))).unwrap();
|
8181 7863 | #[allow(unused_mut)]
|
8182 7864 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8183 7865 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8184 7866 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8185 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7867 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8186 7868 | let sender = sender.clone();
|
8187 7869 | async move {
|
8188 - | 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> };
|
7870 + | 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> };
|
8189 7871 | sender.send(()).await.expect("receiver dropped early");
|
8190 7872 | result
|
8191 7873 | }
|
8192 7874 | })
|
8193 7875 | .build_unchecked();
|
8194 7876 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8195 7877 | .await
|
8196 7878 | .expect("unable to make an HTTP request");
|
8197 7879 | ::pretty_assertions::assert_eq!(
|
8198 7880 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8199 7881 | http_response.status()
|
8200 7882 | );
|
8201 7883 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8202 7884 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8203 7885 | http_response.headers(),
|
8204 7886 | expected_headers,
|
8205 7887 | ));
|
8206 7888 | use ::http_body_util::BodyExt;
|
8207 7889 | let body = http_response
|
8208 7890 | .into_body()
|
8209 7891 | .collect()
|
8210 7892 | .await
|
8211 7893 | .expect("unable to collect body")
|
8212 7894 | .to_bytes();
|
8213 7895 | ::aws_smithy_protocol_test::assert_ok(
|
8214 - | ::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"))
|
7896 + | ::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"))
|
8215 7897 | );
|
8216 7898 | }
|
8217 7899 | }
|
8218 7900 |
|
8219 - | /// When a string member does not contain a valid enum value,
|
8220 - | /// the response should be a 400 ValidationException. Internal-only
|
8221 - | /// enum values are excluded from the response message.
|
8222 - | /// Test ID: RestJsonMalformedEnumTraitString_case1
|
7901 + | /// When a http-date timestamp list contains non-unique values,
|
7902 + | /// the response should be a 400 ValidationException.
|
7903 + | /// Test ID: RestJsonMalformedUniqueItemsHttpDateList_case0
|
8223 7904 | #[::tokio::test]
|
8224 7905 | #[::tracing_test::traced_test]
|
8225 7906 | #[should_panic]
|
8226 - | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
7907 + | async fn rest_json_malformed_unique_items_http_date_list_case0_malformed_request() {
|
8227 7908 | {
|
8228 7909 | #[allow(unused_mut)]
|
8229 7910 | let mut http_request = ::http_1x::Request::builder()
|
8230 - | .uri("/MalformedEnum")
|
7911 + | .uri("/MalformedUniqueItems")
|
8231 7912 | .method("POST")
|
8232 7913 | .header("content-type", "application/json")
|
8233 - | .body(::aws_smithy_http_server::body::boxed(
|
8234 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8235 - | &::aws_smithy_protocol_test::decode_body_data(
|
8236 - | "{ \"stringWithEnumTrait\" : \"XYZ\" }".as_bytes(),
|
8237 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8238 - | ),
|
8239 - | )),
|
8240 - | ))
|
8241 - | .unwrap();
|
7914 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
7915 + | ::bytes::Bytes::copy_from_slice(
|
7916 + | &::aws_smithy_protocol_test::decode_body_data("{ \"httpDateList\" : [\"Tue, 29 Apr 2014 18:30:38 GMT\", \"Tue, 29 Apr 2014 18:30:38 GMT\"] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
7917 + | )
|
7918 + | ))).unwrap();
|
8242 7919 | #[allow(unused_mut)]
|
8243 7920 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8244 7921 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8245 7922 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8246 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7923 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8247 7924 | let sender = sender.clone();
|
8248 7925 | async move {
|
8249 - | 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> };
|
7926 + | 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> };
|
8250 7927 | sender.send(()).await.expect("receiver dropped early");
|
8251 7928 | result
|
8252 7929 | }
|
8253 7930 | })
|
8254 7931 | .build_unchecked();
|
8255 7932 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8256 7933 | .await
|
8257 7934 | .expect("unable to make an HTTP request");
|
8258 7935 | ::pretty_assertions::assert_eq!(
|
8259 7936 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8260 7937 | http_response.status()
|
8261 7938 | );
|
8262 7939 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8263 7940 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8264 7941 | http_response.headers(),
|
8265 7942 | expected_headers,
|
8266 7943 | ));
|
8267 7944 | use ::http_body_util::BodyExt;
|
8268 7945 | let body = http_response
|
8269 7946 | .into_body()
|
8270 7947 | .collect()
|
8271 7948 | .await
|
8272 7949 | .expect("unable to collect body")
|
8273 7950 | .to_bytes();
|
8274 7951 | ::aws_smithy_protocol_test::assert_ok(
|
8275 - | ::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"))
|
7952 + | ::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"))
|
8276 7953 | );
|
8277 7954 | }
|
8278 7955 | }
|
8279 7956 |
|
8280 - | /// When a list member value does not contain a valid enum value,
|
8281 - | /// the response should be a 400 ValidationException. Internal-only
|
8282 - | /// enum values are excluded from the response message.
|
8283 - | /// Test ID: RestJsonMalformedEnumList_case0
|
7957 + | /// When an enum list contains non-unique values,
|
7958 + | /// the response should be a 400 ValidationException.
|
7959 + | /// Test ID: RestJsonMalformedUniqueItemsEnumList
|
8284 7960 | #[::tokio::test]
|
8285 7961 | #[::tracing_test::traced_test]
|
8286 7962 | #[should_panic]
|
8287 - | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
7963 + | async fn rest_json_malformed_unique_items_enum_list_malformed_request() {
|
8288 7964 | {
|
8289 7965 | #[allow(unused_mut)]
|
8290 7966 | let mut http_request = ::http_1x::Request::builder()
|
8291 - | .uri("/MalformedEnum")
|
7967 + | .uri("/MalformedUniqueItems")
|
8292 7968 | .method("POST")
|
8293 7969 | .header("content-type", "application/json")
|
8294 7970 | .body(::aws_smithy_http_server::body::boxed(
|
8295 7971 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8296 7972 | &::aws_smithy_protocol_test::decode_body_data(
|
8297 - | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
7973 + | "{ \"enumList\" : [\"Foo\", \"Foo\"] }".as_bytes(),
|
8298 7974 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8299 7975 | ),
|
8300 7976 | )),
|
8301 7977 | ))
|
8302 7978 | .unwrap();
|
8303 7979 | #[allow(unused_mut)]
|
8304 7980 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8305 7981 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8306 7982 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8307 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7983 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8308 7984 | let sender = sender.clone();
|
8309 7985 | async move {
|
8310 - | 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> };
|
7986 + | 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> };
|
8311 7987 | sender.send(()).await.expect("receiver dropped early");
|
8312 7988 | result
|
8313 7989 | }
|
8314 7990 | })
|
8315 7991 | .build_unchecked();
|
8316 7992 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8317 7993 | .await
|
8318 7994 | .expect("unable to make an HTTP request");
|
8319 7995 | ::pretty_assertions::assert_eq!(
|
8320 7996 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8321 7997 | http_response.status()
|
8322 7998 | );
|
8323 7999 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8324 8000 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8325 8001 | http_response.headers(),
|
8326 8002 | expected_headers,
|
8327 8003 | ));
|
8328 8004 | use ::http_body_util::BodyExt;
|
8329 8005 | let body = http_response
|
8330 8006 | .into_body()
|
8331 8007 | .collect()
|
8332 8008 | .await
|
8333 8009 | .expect("unable to collect body")
|
8334 8010 | .to_bytes();
|
8335 8011 | ::aws_smithy_protocol_test::assert_ok(
|
8336 - | ::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"))
|
8012 + | ::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"))
|
8337 8013 | );
|
8338 8014 | }
|
8339 8015 | }
|
8340 8016 |
|
8341 - | /// When a list member value does not contain a valid enum value,
|
8342 - | /// the response should be a 400 ValidationException. Internal-only
|
8343 - | /// enum values are excluded from the response message.
|
8344 - | /// Test ID: RestJsonMalformedEnumList_case1
|
8017 + | /// When an intEnum list contains non-unique values,
|
8018 + | /// the response should be a 400 ValidationException.
|
8019 + | /// Test ID: RestJsonMalformedUniqueItemsIntEnumList
|
8345 8020 | #[::tokio::test]
|
8346 8021 | #[::tracing_test::traced_test]
|
8347 8022 | #[should_panic]
|
8348 - | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
8023 + | async fn rest_json_malformed_unique_items_int_enum_list_malformed_request() {
|
8349 8024 | {
|
8350 8025 | #[allow(unused_mut)]
|
8351 8026 | let mut http_request = ::http_1x::Request::builder()
|
8352 - | .uri("/MalformedEnum")
|
8027 + | .uri("/MalformedUniqueItems")
|
8353 8028 | .method("POST")
|
8354 8029 | .header("content-type", "application/json")
|
8355 8030 | .body(::aws_smithy_http_server::body::boxed(
|
8356 8031 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8357 8032 | &::aws_smithy_protocol_test::decode_body_data(
|
8358 - | "{ \"list\" : [\"XYZ\"] }".as_bytes(),
|
8033 + | "{ \"intEnumList\" : [3, 3] }".as_bytes(),
|
8359 8034 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8360 8035 | ),
|
8361 8036 | )),
|
8362 8037 | ))
|
8363 8038 | .unwrap();
|
8364 8039 | #[allow(unused_mut)]
|
8365 8040 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8366 8041 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8367 8042 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8368 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8043 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8369 8044 | let sender = sender.clone();
|
8370 8045 | async move {
|
8371 - | 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> };
|
8046 + | 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> };
|
8372 8047 | sender.send(()).await.expect("receiver dropped early");
|
8373 8048 | result
|
8374 8049 | }
|
8375 8050 | })
|
8376 8051 | .build_unchecked();
|
8377 8052 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8378 8053 | .await
|
8379 8054 | .expect("unable to make an HTTP request");
|
8380 8055 | ::pretty_assertions::assert_eq!(
|
8381 8056 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8382 8057 | http_response.status()
|
8383 8058 | );
|
8384 8059 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8385 8060 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8386 8061 | http_response.headers(),
|
8387 8062 | expected_headers,
|
8388 8063 | ));
|
8389 8064 | use ::http_body_util::BodyExt;
|
8390 8065 | let body = http_response
|
8391 8066 | .into_body()
|
8392 8067 | .collect()
|
8393 8068 | .await
|
8394 8069 | .expect("unable to collect body")
|
8395 8070 | .to_bytes();
|
8396 8071 | ::aws_smithy_protocol_test::assert_ok(
|
8397 - | ::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"))
|
8072 + | ::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"))
|
8398 8073 | );
|
8399 8074 | }
|
8400 8075 | }
|
8401 8076 |
|
8402 - | /// When a map member's key does not contain a valid enum value,
|
8403 - | /// the response should be a 400 ValidationException. Internal-only
|
8404 - | /// enum values are excluded from the response message.
|
8405 - | /// Test ID: RestJsonMalformedEnumMapKey_case0
|
8077 + | /// When an list of lists contains non-unique values,
|
8078 + | /// the response should be a 400 ValidationException.
|
8079 + | /// Test ID: RestJsonMalformedUniqueItemsListList
|
8406 8080 | #[::tokio::test]
|
8407 8081 | #[::tracing_test::traced_test]
|
8408 8082 | #[should_panic]
|
8409 - | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
8083 + | async fn rest_json_malformed_unique_items_list_list_malformed_request() {
|
8410 8084 | {
|
8411 8085 | #[allow(unused_mut)]
|
8412 8086 | let mut http_request = ::http_1x::Request::builder()
|
8413 - | .uri("/MalformedEnum")
|
8087 + | .uri("/MalformedUniqueItems")
|
8414 8088 | .method("POST")
|
8415 8089 | .header("content-type", "application/json")
|
8416 8090 | .body(::aws_smithy_http_server::body::boxed(
|
8417 8091 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8418 8092 | &::aws_smithy_protocol_test::decode_body_data(
|
8419 - | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
8093 + | "{ \"listList\" : [[\"foo\",\"bar\"], [\"foo\",\"bar\"]] }".as_bytes(),
|
8420 8094 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8421 8095 | ),
|
8422 8096 | )),
|
8423 8097 | ))
|
8424 8098 | .unwrap();
|
8425 8099 | #[allow(unused_mut)]
|
8426 8100 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8427 8101 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8428 8102 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8429 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8103 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8430 8104 | let sender = sender.clone();
|
8431 8105 | async move {
|
8432 - | 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> };
|
8106 + | 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> };
|
8433 8107 | sender.send(()).await.expect("receiver dropped early");
|
8434 8108 | result
|
8435 8109 | }
|
8436 8110 | })
|
8437 8111 | .build_unchecked();
|
8438 8112 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8439 8113 | .await
|
8440 8114 | .expect("unable to make an HTTP request");
|
8441 8115 | ::pretty_assertions::assert_eq!(
|
8442 8116 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8443 8117 | http_response.status()
|
8444 8118 | );
|
8445 8119 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8446 8120 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8447 8121 | http_response.headers(),
|
8448 8122 | expected_headers,
|
8449 8123 | ));
|
8450 8124 | use ::http_body_util::BodyExt;
|
8451 8125 | let body = http_response
|
8452 8126 | .into_body()
|
8453 8127 | .collect()
|
8454 8128 | .await
|
8455 8129 | .expect("unable to collect body")
|
8456 8130 | .to_bytes();
|
8457 8131 | ::aws_smithy_protocol_test::assert_ok(
|
8458 - | ::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"))
|
8132 + | ::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"))
|
8459 8133 | );
|
8460 8134 | }
|
8461 8135 | }
|
8462 8136 |
|
8463 - | /// When a map member's key does not contain a valid enum value,
|
8464 - | /// the response should be a 400 ValidationException. Internal-only
|
8465 - | /// enum values are excluded from the response message.
|
8466 - | /// Test ID: RestJsonMalformedEnumMapKey_case1
|
8137 + | /// When an list of structures contains non-unique values,
|
8138 + | /// the response should be a 400 ValidationException.
|
8139 + | /// Test ID: RestJsonMalformedUniqueItemsStructureList
|
8467 8140 | #[::tokio::test]
|
8468 8141 | #[::tracing_test::traced_test]
|
8469 8142 | #[should_panic]
|
8470 - | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
8143 + | async fn rest_json_malformed_unique_items_structure_list_malformed_request() {
|
8471 8144 | {
|
8472 8145 | #[allow(unused_mut)]
|
8473 8146 | let mut http_request = ::http_1x::Request::builder()
|
8474 - | .uri("/MalformedEnum")
|
8147 + | .uri("/MalformedUniqueItems")
|
8475 8148 | .method("POST")
|
8476 8149 | .header("content-type", "application/json")
|
8477 8150 | .body(::aws_smithy_http_server::body::boxed(
|
8478 8151 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8479 8152 | &::aws_smithy_protocol_test::decode_body_data(
|
8480 - | "{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes(),
|
8153 + | "{ \"structureList\" : [{\"hi\": \"hello\"}, {\"hi\": \"hello\"}] }"
|
8154 + | .as_bytes(),
|
8481 8155 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8482 8156 | ),
|
8483 8157 | )),
|
8484 8158 | ))
|
8485 8159 | .unwrap();
|
8486 8160 | #[allow(unused_mut)]
|
8487 8161 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8488 8162 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8489 8163 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8490 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8164 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8491 8165 | let sender = sender.clone();
|
8492 8166 | async move {
|
8493 - | 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> };
|
8167 + | 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> };
|
8494 8168 | sender.send(()).await.expect("receiver dropped early");
|
8495 8169 | result
|
8496 8170 | }
|
8497 8171 | })
|
8498 8172 | .build_unchecked();
|
8499 8173 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8500 8174 | .await
|
8501 8175 | .expect("unable to make an HTTP request");
|
8502 8176 | ::pretty_assertions::assert_eq!(
|
8503 8177 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8504 8178 | http_response.status()
|
8505 8179 | );
|
8506 8180 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8507 8181 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8508 8182 | http_response.headers(),
|
8509 8183 | expected_headers,
|
8510 8184 | ));
|
8511 8185 | use ::http_body_util::BodyExt;
|
8512 8186 | let body = http_response
|
8513 8187 | .into_body()
|
8514 8188 | .collect()
|
8515 8189 | .await
|
8516 8190 | .expect("unable to collect body")
|
8517 8191 | .to_bytes();
|
8518 8192 | ::aws_smithy_protocol_test::assert_ok(
|
8519 - | ::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"))
|
8193 + | ::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"))
|
8520 8194 | );
|
8521 8195 | }
|
8522 8196 | }
|
8523 8197 |
|
8524 - | /// When a map member's value does not contain a valid enum value,
|
8525 - | /// the response should be a 400 ValidationException. Internal-only
|
8526 - | /// enum values are excluded from the response message.
|
8527 - | /// Test ID: RestJsonMalformedEnumMapValue_case0
|
8198 + | /// When a list of structures does not contain required keys,
|
8199 + | /// the response should be a 400 ValidationException and not
|
8200 + | /// a 500 error.
|
8201 + | /// Test ID: RestJsonMalformedUniqueItemsStructureMissingKeyList
|
8528 8202 | #[::tokio::test]
|
8529 8203 | #[::tracing_test::traced_test]
|
8530 - | #[should_panic]
|
8531 - | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
8204 + | async fn rest_json_malformed_unique_items_structure_missing_key_list_malformed_request() {
|
8532 8205 | {
|
8533 8206 | #[allow(unused_mut)]
|
8534 8207 | let mut http_request = ::http_1x::Request::builder()
|
8535 - | .uri("/MalformedEnum")
|
8208 + | .uri("/MalformedUniqueItems")
|
8536 8209 | .method("POST")
|
8537 8210 | .header("content-type", "application/json")
|
8538 8211 | .body(::aws_smithy_http_server::body::boxed(
|
8539 8212 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8540 8213 | &::aws_smithy_protocol_test::decode_body_data(
|
8541 - | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
8214 + | "{ \"structureListWithNoKey\" : [{\"hi2\": \"bar\"}] }".as_bytes(),
|
8542 8215 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8543 8216 | ),
|
8544 8217 | )),
|
8545 8218 | ))
|
8546 8219 | .unwrap();
|
8547 8220 | #[allow(unused_mut)]
|
8548 8221 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8549 8222 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8550 8223 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8551 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8224 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8552 8225 | let sender = sender.clone();
|
8553 8226 | async move {
|
8554 - | 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> };
|
8227 + | 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> };
|
8555 8228 | sender.send(()).await.expect("receiver dropped early");
|
8556 8229 | result
|
8557 8230 | }
|
8558 8231 | })
|
8559 8232 | .build_unchecked();
|
8560 8233 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8561 8234 | .await
|
8562 8235 | .expect("unable to make an HTTP request");
|
8563 8236 | ::pretty_assertions::assert_eq!(
|
8564 8237 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8565 8238 | http_response.status()
|
8566 8239 | );
|
8567 8240 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8568 8241 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8569 8242 | http_response.headers(),
|
8570 8243 | expected_headers,
|
8571 8244 | ));
|
8572 8245 | use ::http_body_util::BodyExt;
|
8573 8246 | let body = http_response
|
8574 8247 | .into_body()
|
8575 8248 | .collect()
|
8576 8249 | .await
|
8577 8250 | .expect("unable to collect body")
|
8578 8251 | .to_bytes();
|
8579 8252 | ::aws_smithy_protocol_test::assert_ok(
|
8580 - | ::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"))
|
8253 + | ::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"))
|
8581 8254 | );
|
8582 8255 | }
|
8583 8256 | }
|
8584 8257 |
|
8585 - | /// When a map member's value does not contain a valid enum value,
|
8586 - | /// the response should be a 400 ValidationException. Internal-only
|
8587 - | /// enum values are excluded from the response message.
|
8588 - | /// Test ID: RestJsonMalformedEnumMapValue_case1
|
8258 + | /// When an list of unions contains non-unique values,
|
8259 + | /// the response should be a 400 ValidationException.
|
8260 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case0
|
8589 8261 | #[::tokio::test]
|
8590 8262 | #[::tracing_test::traced_test]
|
8591 8263 | #[should_panic]
|
8592 - | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
8264 + | async fn rest_json_malformed_unique_items_union_list_case0_malformed_request() {
|
8593 8265 | {
|
8594 8266 | #[allow(unused_mut)]
|
8595 8267 | let mut http_request = ::http_1x::Request::builder()
|
8596 - | .uri("/MalformedEnum")
|
8268 + | .uri("/MalformedUniqueItems")
|
8597 8269 | .method("POST")
|
8598 8270 | .header("content-type", "application/json")
|
8599 8271 | .body(::aws_smithy_http_server::body::boxed(
|
8600 8272 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8601 8273 | &::aws_smithy_protocol_test::decode_body_data(
|
8602 - | "{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes(),
|
8274 + | "{ \"unionList\" : [{\"string\": \"foo\"}, {\"string\": \"foo\"}] }"
|
8275 + | .as_bytes(),
|
8603 8276 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8604 8277 | ),
|
8605 8278 | )),
|
8606 8279 | ))
|
8607 8280 | .unwrap();
|
8608 8281 | #[allow(unused_mut)]
|
8609 8282 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8610 8283 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8611 8284 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8612 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8285 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8613 8286 | let sender = sender.clone();
|
8614 8287 | async move {
|
8615 - | 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> };
|
8288 + | 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> };
|
8616 8289 | sender.send(()).await.expect("receiver dropped early");
|
8617 8290 | result
|
8618 8291 | }
|
8619 8292 | })
|
8620 8293 | .build_unchecked();
|
8621 8294 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8622 8295 | .await
|
8623 8296 | .expect("unable to make an HTTP request");
|
8624 8297 | ::pretty_assertions::assert_eq!(
|
8625 8298 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8626 8299 | http_response.status()
|
8627 8300 | );
|
8628 8301 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8629 8302 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8630 8303 | http_response.headers(),
|
8631 8304 | expected_headers,
|
8632 8305 | ));
|
8633 8306 | use ::http_body_util::BodyExt;
|
8634 8307 | let body = http_response
|
8635 8308 | .into_body()
|
8636 8309 | .collect()
|
8637 8310 | .await
|
8638 8311 | .expect("unable to collect body")
|
8639 8312 | .to_bytes();
|
8640 8313 | ::aws_smithy_protocol_test::assert_ok(
|
8641 - | ::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"))
|
8314 + | ::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"))
|
8642 8315 | );
|
8643 8316 | }
|
8644 8317 | }
|
8645 8318 |
|
8646 - | /// When a union member's value does not contain a valid enum value,
|
8647 - | /// the response should be a 400 ValidationException. Internal-only
|
8648 - | /// enum values are excluded from the response message.
|
8649 - | /// Test ID: RestJsonMalformedEnumUnion_case0
|
8319 + | /// When an list of unions contains non-unique values,
|
8320 + | /// the response should be a 400 ValidationException.
|
8321 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case1
|
8650 8322 | #[::tokio::test]
|
8651 8323 | #[::tracing_test::traced_test]
|
8652 8324 | #[should_panic]
|
8653 - | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
8325 + | async fn rest_json_malformed_unique_items_union_list_case1_malformed_request() {
|
8654 8326 | {
|
8655 8327 | #[allow(unused_mut)]
|
8656 8328 | let mut http_request = ::http_1x::Request::builder()
|
8657 - | .uri("/MalformedEnum")
|
8329 + | .uri("/MalformedUniqueItems")
|
8658 8330 | .method("POST")
|
8659 8331 | .header("content-type", "application/json")
|
8660 8332 | .body(::aws_smithy_http_server::body::boxed(
|
8661 8333 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8662 8334 | &::aws_smithy_protocol_test::decode_body_data(
|
8663 - | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
8335 + | "{ \"unionList\" : [{\"integer\": 1}, {\"integer\": 1}] }".as_bytes(),
|
8664 8336 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8665 8337 | ),
|
8666 8338 | )),
|
8667 8339 | ))
|
8668 8340 | .unwrap();
|
8669 8341 | #[allow(unused_mut)]
|
8670 8342 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8671 8343 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8672 8344 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8673 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8345 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8674 8346 | let sender = sender.clone();
|
8675 8347 | async move {
|
8676 - | 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> };
|
8348 + | 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> };
|
8677 8349 | sender.send(()).await.expect("receiver dropped early");
|
8678 8350 | result
|
8679 8351 | }
|
8680 8352 | })
|
8681 8353 | .build_unchecked();
|
8682 8354 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8683 8355 | .await
|
8684 8356 | .expect("unable to make an HTTP request");
|
8685 8357 | ::pretty_assertions::assert_eq!(
|
8686 8358 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8687 8359 | http_response.status()
|
8688 8360 | );
|
8689 8361 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8690 8362 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8691 8363 | http_response.headers(),
|
8692 8364 | expected_headers,
|
8693 8365 | ));
|
8694 8366 | use ::http_body_util::BodyExt;
|
8695 8367 | let body = http_response
|
8696 8368 | .into_body()
|
8697 8369 | .collect()
|
8698 8370 | .await
|
8699 8371 | .expect("unable to collect body")
|
8700 8372 | .to_bytes();
|
8701 8373 | ::aws_smithy_protocol_test::assert_ok(
|
8702 - | ::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"))
|
8374 + | ::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"))
|
8703 8375 | );
|
8704 8376 | }
|
8705 8377 | }
|
8378 + | }
|
8706 8379 |
|
8707 - | /// When a union member's value does not contain a valid enum value,
|
8708 - | /// the response should be a 400 ValidationException. Internal-only
|
8709 - | /// enum values are excluded from the response message.
|
8710 - | /// Test ID: RestJsonMalformedEnumUnion_case1
|
8380 + | ::pin_project_lite::pin_project! {
|
8381 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
8382 + | /// [`RecursiveStructuresInput`](crate::input::RecursiveStructuresInput) using modelled bindings.
|
8383 + | pub struct RecursiveStructuresInputFuture {
|
8384 + | 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>>
|
8385 + | }
|
8386 + | }
|
8387 + |
|
8388 + | impl std::future::Future for RecursiveStructuresInputFuture {
|
8389 + | type Output = Result<
|
8390 + | crate::input::RecursiveStructuresInput,
|
8391 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
8392 + | >;
|
8393 + |
|
8394 + | fn poll(
|
8395 + | self: std::pin::Pin<&mut Self>,
|
8396 + | cx: &mut std::task::Context<'_>,
|
8397 + | ) -> std::task::Poll<Self::Output> {
|
8398 + | let this = self.project();
|
8399 + | this.inner.as_mut().poll(cx)
|
8400 + | }
|
8401 + | }
|
8402 + |
|
8403 + | impl<B>
|
8404 + | ::aws_smithy_http_server::request::FromRequest<
|
8405 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
8406 + | B,
|
8407 + | > for crate::input::RecursiveStructuresInput
|
8408 + | where
|
8409 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
8410 + | B: 'static,
|
8411 + |
|
8412 + | B::Data: Send,
|
8413 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
8414 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
8415 + | {
|
8416 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
8417 + | type Future = RecursiveStructuresInputFuture;
|
8418 + |
|
8419 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
8420 + | let fut = async move {
|
8421 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
8422 + | request.headers(),
|
8423 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
8424 + | ) {
|
8425 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
8426 + | }
|
8427 + | crate::protocol_serde::shape_recursive_structures::de_recursive_structures_http_request(
|
8428 + | request,
|
8429 + | )
|
8430 + | .await
|
8431 + | };
|
8432 + | use ::futures_util::future::TryFutureExt;
|
8433 + | let fut = fut.map_err(
|
8434 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
8435 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
8436 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
8437 + | e,
|
8438 + | )
|
8439 + | },
|
8440 + | );
|
8441 + | RecursiveStructuresInputFuture {
|
8442 + | inner: Box::pin(fut),
|
8443 + | }
|
8444 + | }
|
8445 + | }
|
8446 + | impl
|
8447 + | ::aws_smithy_http_server::response::IntoResponse<
|
8448 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
8449 + | > for crate::output::RecursiveStructuresOutput
|
8450 + | {
|
8451 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
8452 + | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_response(self) {
|
8453 + | Ok(response) => response,
|
8454 + | Err(e) => {
|
8455 + | ::tracing::error!(error = %e, "failed to serialize response");
|
8456 + | ::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))
|
8457 + | }
|
8458 + | }
|
8459 + | }
|
8460 + | }
|
8461 + | impl
|
8462 + | ::aws_smithy_http_server::response::IntoResponse<
|
8463 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
8464 + | > for crate::error::RecursiveStructuresError
|
8465 + | {
|
8466 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
8467 + | match crate::protocol_serde::shape_recursive_structures::ser_recursive_structures_http_error(
|
8468 + | &self,
|
8469 + | ) {
|
8470 + | Ok(mut response) => {
|
8471 + | response.extensions_mut().insert(
|
8472 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
8473 + | );
|
8474 + | response
|
8475 + | }
|
8476 + | Err(e) => {
|
8477 + | ::tracing::error!(error = %e, "failed to serialize response");
|
8478 + | ::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))
|
8479 + | }
|
8480 + | }
|
8481 + | }
|
8482 + | }
|
8483 + |
|
8484 + | #[allow(unreachable_code, unused_variables)]
|
8485 + | #[cfg(test)]
|
8486 + | mod recursive_structures_test {
|
8487 + |
|
8488 + | /// Validation should work with recursive structures.
|
8489 + | /// Test ID: RestJsonRecursiveStructuresValidate
|
8711 8490 | #[::tokio::test]
|
8712 8491 | #[::tracing_test::traced_test]
|
8713 - | #[should_panic]
|
8714 - | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
8492 + | async fn rest_json_recursive_structures_validate_request() {
|
8493 + | #[allow(unused_mut)]
|
8494 + | let mut http_request = ::http_1x::Request::builder()
|
8495 + | .uri("/RecursiveStructures")
|
8496 + | .method("POST")
|
8497 + | .header("content-type", "application/json")
|
8498 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
8499 + | ::bytes::Bytes::copy_from_slice(
|
8500 + | &::aws_smithy_protocol_test::decode_body_data("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"abc\" }\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
8501 + | )
|
8502 + | ))).unwrap();
|
8503 + | #[allow(unused_mut)]
|
8504 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8505 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8506 + | let service = crate::service::RestJsonValidation::builder::<
|
8507 + | ::aws_smithy_http_server::body::BoxBody,
|
8508 + | _,
|
8509 + | _,
|
8510 + | _,
|
8511 + | >(config)
|
8512 + | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
8513 + | let sender = sender.clone();
|
8514 + | async move {
|
8515 + | let result = {
|
8516 + | let expected = crate::input::RecursiveStructuresInput {
|
8517 + | union: ::std::option::Option::Some(crate::model::RecursiveUnionOne::Union(
|
8518 + | ::std::boxed::Box::new(crate::model::RecursiveUnionTwo::Union(
|
8519 + | crate::model::RecursiveUnionOne::String(
|
8520 + | "abc"
|
8521 + | .parse::<crate::model::RecursiveEnumString>()
|
8522 + | .expect("static value validated to member"),
|
8523 + | ),
|
8524 + | )),
|
8525 + | )),
|
8526 + | };
|
8527 + | ::pretty_assertions::assert_eq!(input, expected);
|
8528 + | let output = crate::output::RecursiveStructuresOutput {};
|
8529 + | Ok(output)
|
8530 + | };
|
8531 + | sender.send(()).await.expect("receiver dropped early");
|
8532 + | result
|
8533 + | }
|
8534 + | })
|
8535 + | .build_unchecked();
|
8536 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8537 + | .await
|
8538 + | .expect("unable to make an HTTP request");
|
8539 + | assert!(
|
8540 + | receiver.recv().await.is_some(),
|
8541 + | "we expected operation handler to be invoked but it was not entered"
|
8542 + | );
|
8543 + | }
|
8544 + |
|
8545 + | /// When a value deeply nested in a recursive structure does not meet constraints,
|
8546 + | /// a 400 ValidationException is returned.
|
8547 + | /// Test ID: RestJsonMalformedRecursiveStructures
|
8548 + | #[::tokio::test]
|
8549 + | #[::tracing_test::traced_test]
|
8550 + | async fn rest_json_malformed_recursive_structures_malformed_request() {
|
8715 8551 | {
|
8716 8552 | #[allow(unused_mut)]
|
8717 8553 | let mut http_request = ::http_1x::Request::builder()
|
8718 - | .uri("/MalformedEnum")
|
8554 + | .uri("/RecursiveStructures")
|
8555 + | .method("POST")
|
8556 + | .header("content-type", "application/json")
|
8557 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
8558 + | ::bytes::Bytes::copy_from_slice(
|
8559 + | &::aws_smithy_protocol_test::decode_body_data("{ \"union\" : {\n \"union\" : {\n \"union\" : { \"string\" : \"XYZ\" }\n }\n }\n}".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
8560 + | )
|
8561 + | ))).unwrap();
|
8562 + | #[allow(unused_mut)]
|
8563 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8564 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8565 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8566 + | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
8567 + | let sender = sender.clone();
|
8568 + | async move {
|
8569 + | 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> };
|
8570 + | sender.send(()).await.expect("receiver dropped early");
|
8571 + | result
|
8572 + | }
|
8573 + | })
|
8574 + | .build_unchecked();
|
8575 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8576 + | .await
|
8577 + | .expect("unable to make an HTTP request");
|
8578 + | ::pretty_assertions::assert_eq!(
|
8579 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8580 + | http_response.status()
|
8581 + | );
|
8582 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8583 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8584 + | http_response.headers(),
|
8585 + | expected_headers,
|
8586 + | ));
|
8587 + | use ::http_body_util::BodyExt;
|
8588 + | let body = http_response
|
8589 + | .into_body()
|
8590 + | .collect()
|
8591 + | .await
|
8592 + | .expect("unable to collect body")
|
8593 + | .to_bytes();
|
8594 + | ::aws_smithy_protocol_test::assert_ok(
|
8595 + | ::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"))
|
8596 + | );
|
8597 + | }
|
8598 + | }
|
8599 + | }
|
8600 + |
|
8601 + | ::pin_project_lite::pin_project! {
|
8602 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
8603 + | /// [`SensitiveValidationInput`](crate::input::SensitiveValidationInput) using modelled bindings.
|
8604 + | pub struct SensitiveValidationInputFuture {
|
8605 + | 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>>
|
8606 + | }
|
8607 + | }
|
8608 + |
|
8609 + | impl std::future::Future for SensitiveValidationInputFuture {
|
8610 + | type Output = Result<
|
8611 + | crate::input::SensitiveValidationInput,
|
8612 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
8613 + | >;
|
8614 + |
|
8615 + | fn poll(
|
8616 + | self: std::pin::Pin<&mut Self>,
|
8617 + | cx: &mut std::task::Context<'_>,
|
8618 + | ) -> std::task::Poll<Self::Output> {
|
8619 + | let this = self.project();
|
8620 + | this.inner.as_mut().poll(cx)
|
8621 + | }
|
8622 + | }
|
8623 + |
|
8624 + | impl<B>
|
8625 + | ::aws_smithy_http_server::request::FromRequest<
|
8626 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
8627 + | B,
|
8628 + | > for crate::input::SensitiveValidationInput
|
8629 + | where
|
8630 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
8631 + | B: 'static,
|
8632 + |
|
8633 + | B::Data: Send,
|
8634 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
8635 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
8636 + | {
|
8637 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
8638 + | type Future = SensitiveValidationInputFuture;
|
8639 + |
|
8640 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
8641 + | let fut = async move {
|
8642 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
8643 + | request.headers(),
|
8644 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
8645 + | ) {
|
8646 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
8647 + | }
|
8648 + | crate::protocol_serde::shape_sensitive_validation::de_sensitive_validation_http_request(
|
8649 + | request,
|
8650 + | )
|
8651 + | .await
|
8652 + | };
|
8653 + | use ::futures_util::future::TryFutureExt;
|
8654 + | let fut = fut.map_err(
|
8655 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
8656 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
8657 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
8658 + | e,
|
8659 + | )
|
8660 + | },
|
8661 + | );
|
8662 + | SensitiveValidationInputFuture {
|
8663 + | inner: Box::pin(fut),
|
8664 + | }
|
8665 + | }
|
8666 + | }
|
8667 + | impl
|
8668 + | ::aws_smithy_http_server::response::IntoResponse<
|
8669 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
8670 + | > for crate::output::SensitiveValidationOutput
|
8671 + | {
|
8672 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
8673 + | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_response(self) {
|
8674 + | Ok(response) => response,
|
8675 + | Err(e) => {
|
8676 + | ::tracing::error!(error = %e, "failed to serialize response");
|
8677 + | ::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))
|
8678 + | }
|
8679 + | }
|
8680 + | }
|
8681 + | }
|
8682 + | impl
|
8683 + | ::aws_smithy_http_server::response::IntoResponse<
|
8684 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
8685 + | > for crate::error::SensitiveValidationError
|
8686 + | {
|
8687 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
8688 + | match crate::protocol_serde::shape_sensitive_validation::ser_sensitive_validation_http_error(
|
8689 + | &self,
|
8690 + | ) {
|
8691 + | Ok(mut response) => {
|
8692 + | response.extensions_mut().insert(
|
8693 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
8694 + | );
|
8695 + | response
|
8696 + | }
|
8697 + | Err(e) => {
|
8698 + | ::tracing::error!(error = %e, "failed to serialize response");
|
8699 + | ::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))
|
8700 + | }
|
8701 + | }
|
8702 + | }
|
8703 + | }
|
8704 + |
|
8705 + | #[allow(unreachable_code, unused_variables)]
|
8706 + | #[cfg(test)]
|
8707 + | mod sensitive_validation_test {
|
8708 + |
|
8709 + | /// When a sensitive member fails validation, the resultant
|
8710 + | /// ValidationException will omit the value of the input.
|
8711 + | /// Test ID: RestJsonMalformedPatternSensitiveString
|
8712 + | #[::tokio::test]
|
8713 + | #[::tracing_test::traced_test]
|
8714 + | async fn rest_json_malformed_pattern_sensitive_string_malformed_request() {
|
8715 + | {
|
8716 + | #[allow(unused_mut)]
|
8717 + | let mut http_request = ::http_1x::Request::builder()
|
8718 + | .uri("/SensitiveValidation")
|
8719 8719 | .method("POST")
|
8720 8720 | .header("content-type", "application/json")
|
8721 8721 | .body(::aws_smithy_http_server::body::boxed(
|
8722 8722 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8723 8723 | &::aws_smithy_protocol_test::decode_body_data(
|
8724 - | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|
8724 + | "{ \"string\" : \"ABC\" }".as_bytes(),
|
8725 8725 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8726 8726 | ),
|
8727 8727 | )),
|
8728 8728 | ))
|
8729 8729 | .unwrap();
|
8730 8730 | #[allow(unused_mut)]
|
8731 8731 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8732 8732 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8733 8733 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8734 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8734 + | .sensitive_validation(move |input: crate::input::SensitiveValidationInput| {
|
8735 8735 | let sender = sender.clone();
|
8736 8736 | async move {
|
8737 - | 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> };
|
8737 + | 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> };
|
8738 8738 | sender.send(()).await.expect("receiver dropped early");
|
8739 8739 | result
|
8740 8740 | }
|
8741 8741 | })
|
8742 8742 | .build_unchecked();
|
8743 8743 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8744 8744 | .await
|
8745 8745 | .expect("unable to make an HTTP request");
|
8746 8746 | ::pretty_assertions::assert_eq!(
|
8747 8747 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8748 8748 | http_response.status()
|
8749 8749 | );
|
8750 8750 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8751 8751 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8752 8752 | http_response.headers(),
|
8753 8753 | expected_headers,
|
8754 8754 | ));
|
8755 8755 | use ::http_body_util::BodyExt;
|
8756 8756 | let body = http_response
|
8757 8757 | .into_body()
|
8758 8758 | .collect()
|
8759 8759 | .await
|
8760 8760 | .expect("unable to collect body")
|
8761 8761 | .to_bytes();
|
8762 8762 | ::aws_smithy_protocol_test::assert_ok(
|
8763 - | ::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"))
|
8763 + | ::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"))
|
8764 8764 | );
|
8765 8765 | }
|
8766 8766 | }
|
8767 8767 | }
|