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 - | )
|
52 - | .await
|
49 + | crate::protocol_serde::shape_malformed_enum::de_malformed_enum_http_request(request)
|
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) {
|
75 - | Ok(response) => response,
|
76 - | Err(e) => {
|
77 - | ::tracing::error!(error = %e, "failed to serialize response");
|
78 - | ::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 - | }
|
80 - | }
|
72 + | match crate::protocol_serde::shape_malformed_enum::ser_malformed_enum_http_response(self) {
|
73 + | Ok(response) => response,
|
74 + | Err(e) => {
|
75 + | ::tracing::error!(error = %e, "failed to serialize response");
|
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))
|
77 + | }
|
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"))
|
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"))
|
165 163 | );
|
166 164 | }
|
167 165 | }
|
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 166 |
|
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()),
|
263 - | );
|
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 - | }
|
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
|
171 + | #[::tokio::test]
|
172 + | #[::tracing_test::traced_test]
|
173 + | #[should_panic]
|
174 + | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
175 + | {
|
176 + | #[allow(unused_mut)]
|
177 + | let mut http_request = ::http_1x::Request::builder()
|
178 + | .uri("/MalformedEnum")
|
179 + | .method("POST")
|
180 + | .header("content-type", "application/json")
|
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"),
|
186 + | ),
|
187 + | )),
|
188 + | ))
|
189 + | .unwrap();
|
190 + | #[allow(unused_mut)]
|
191 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
192 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
193 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
194 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
195 + | let sender = sender.clone();
|
196 + | async move {
|
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> };
|
198 + | sender.send(()).await.expect("receiver dropped early");
|
199 + | result
|
200 + | }
|
201 + | })
|
202 + | .build_unchecked();
|
203 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
204 + | .await
|
205 + | .expect("unable to make an HTTP request");
|
206 + | ::pretty_assertions::assert_eq!(
|
207 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
208 + | http_response.status()
|
209 + | );
|
210 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
211 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
212 + | http_response.headers(),
|
213 + | expected_headers,
|
214 + | ));
|
215 + | use ::http_body_util::BodyExt;
|
216 + | let body = http_response
|
217 + | .into_body()
|
218 + | .collect()
|
219 + | .await
|
220 + | .expect("unable to collect body")
|
221 + | .to_bytes();
|
222 + | ::aws_smithy_protocol_test::assert_ok(
|
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"))
|
224 + | );
|
270 225 | }
|
271 226 | }
|
272 - | }
|
273 227 |
|
274 - | #[allow(unreachable_code, unused_variables)]
|
275 - | #[cfg(test)]
|
276 - | mod recursive_structures_test {
|
277 - |
|
278 - | /// Validation should work with recursive structures.
|
279 - | /// Test ID: RestJsonRecursiveStructuresValidate
|
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
|
280 232 | #[::tokio::test]
|
281 233 | #[::tracing_test::traced_test]
|
282 - | async fn rest_json_recursive_structures_validate_request() {
|
283 - | #[allow(unused_mut)]
|
284 - | let mut http_request = ::http_1x::Request::builder()
|
285 - | .uri("/RecursiveStructures")
|
286 - | .method("POST")
|
287 - | .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"),
|
313 - | ),
|
314 - | )),
|
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() {
|
234 + | #[should_panic]
|
235 + | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
341 236 | {
|
342 237 | #[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();
|
238 + | let mut http_request = ::http_1x::Request::builder()
|
239 + | .uri("/MalformedEnum")
|
240 + | .method("POST")
|
241 + | .header("content-type", "application/json")
|
242 + | .body(::aws_smithy_http_server::body::boxed(
|
243 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
244 + | &::aws_smithy_protocol_test::decode_body_data(
|
245 + | "{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes(),
|
246 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
247 + | ),
|
248 + | )),
|
249 + | ))
|
250 + | .unwrap();
|
352 251 | #[allow(unused_mut)]
|
353 252 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
354 253 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
355 254 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
356 - | .recursive_structures(move |input: crate::input::RecursiveStructuresInput| {
|
255 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
357 256 | let sender = sender.clone();
|
358 257 | 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> };
|
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> };
|
360 259 | sender.send(()).await.expect("receiver dropped early");
|
361 260 | result
|
362 261 | }
|
363 262 | })
|
364 263 | .build_unchecked();
|
365 264 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
366 265 | .await
|
367 266 | .expect("unable to make an HTTP request");
|
368 267 | ::pretty_assertions::assert_eq!(
|
369 268 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
370 269 | http_response.status()
|
371 270 | );
|
372 271 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
373 272 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
374 273 | http_response.headers(),
|
375 274 | expected_headers,
|
376 275 | ));
|
377 276 | use ::http_body_util::BodyExt;
|
378 277 | let body = http_response
|
379 278 | .into_body()
|
380 279 | .collect()
|
381 280 | .await
|
382 281 | .expect("unable to collect body")
|
383 282 | .to_bytes();
|
384 283 | ::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"))
|
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"))
|
386 285 | );
|
387 286 | }
|
388 287 | }
|
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 - |
|
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 288 |
|
493 - | /// When a blob list contains non-unique values,
|
494 - | /// the response should be a 400 ValidationException.
|
495 - | /// Test ID: RestJsonMalformedUniqueItemsBlobList
|
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
|
496 293 | #[::tokio::test]
|
497 294 | #[::tracing_test::traced_test]
|
498 295 | #[should_panic]
|
499 - | async fn rest_json_malformed_unique_items_blob_list_malformed_request() {
|
296 + | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
500 297 | {
|
501 298 | #[allow(unused_mut)]
|
502 299 | let mut http_request = ::http_1x::Request::builder()
|
503 - | .uri("/MalformedUniqueItems")
|
300 + | .uri("/MalformedEnum")
|
504 301 | .method("POST")
|
505 302 | .header("content-type", "application/json")
|
506 303 | .body(::aws_smithy_http_server::body::boxed(
|
507 304 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
508 305 | &::aws_smithy_protocol_test::decode_body_data(
|
509 - | "{ \"blobList\" : [\"YQ==\", \"YQ==\"] }".as_bytes(),
|
306 + | "{ \"stringWithEnumTrait\" : \"XYZ\" }".as_bytes(),
|
510 307 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
511 308 | ),
|
512 309 | )),
|
513 310 | ))
|
514 311 | .unwrap();
|
515 312 | #[allow(unused_mut)]
|
516 313 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
517 314 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
518 315 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
519 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
316 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
520 317 | let sender = sender.clone();
|
521 318 | 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> };
|
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> };
|
523 320 | sender.send(()).await.expect("receiver dropped early");
|
524 321 | result
|
525 322 | }
|
526 323 | })
|
527 324 | .build_unchecked();
|
528 325 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
529 326 | .await
|
530 327 | .expect("unable to make an HTTP request");
|
531 328 | ::pretty_assertions::assert_eq!(
|
532 329 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
533 330 | http_response.status()
|
534 331 | );
|
535 332 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
536 333 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
537 334 | http_response.headers(),
|
538 335 | expected_headers,
|
539 336 | ));
|
540 337 | use ::http_body_util::BodyExt;
|
541 338 | let body = http_response
|
542 339 | .into_body()
|
543 340 | .collect()
|
544 341 | .await
|
545 342 | .expect("unable to collect body")
|
546 343 | .to_bytes();
|
547 344 | ::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"))
|
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"))
|
549 346 | );
|
550 347 | }
|
551 348 | }
|
552 349 |
|
553 - | /// When a boolean list contains non-unique values,
|
554 - | /// the response should be a 400 ValidationException.
|
555 - | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case0
|
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
|
556 354 | #[::tokio::test]
|
557 355 | #[::tracing_test::traced_test]
|
558 356 | #[should_panic]
|
559 - | async fn rest_json_malformed_unique_items_boolean_list_case0_malformed_request() {
|
357 + | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
560 358 | {
|
561 359 | #[allow(unused_mut)]
|
562 360 | let mut http_request = ::http_1x::Request::builder()
|
563 - | .uri("/MalformedUniqueItems")
|
361 + | .uri("/MalformedEnum")
|
564 362 | .method("POST")
|
565 363 | .header("content-type", "application/json")
|
566 364 | .body(::aws_smithy_http_server::body::boxed(
|
567 365 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
568 366 | &::aws_smithy_protocol_test::decode_body_data(
|
569 - | "{ \"booleanList\" : [true, true] }".as_bytes(),
|
367 + | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
570 368 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
571 369 | ),
|
572 370 | )),
|
573 371 | ))
|
574 372 | .unwrap();
|
575 373 | #[allow(unused_mut)]
|
576 374 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
577 375 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
578 376 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
579 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
377 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
580 378 | let sender = sender.clone();
|
581 379 | 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> };
|
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> };
|
583 381 | sender.send(()).await.expect("receiver dropped early");
|
584 382 | result
|
585 383 | }
|
586 384 | })
|
587 385 | .build_unchecked();
|
588 386 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
589 387 | .await
|
590 388 | .expect("unable to make an HTTP request");
|
591 389 | ::pretty_assertions::assert_eq!(
|
592 390 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
593 391 | http_response.status()
|
594 392 | );
|
595 393 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
596 394 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
597 395 | http_response.headers(),
|
598 396 | expected_headers,
|
599 397 | ));
|
600 398 | use ::http_body_util::BodyExt;
|
601 399 | let body = http_response
|
602 400 | .into_body()
|
603 401 | .collect()
|
604 402 | .await
|
605 403 | .expect("unable to collect body")
|
606 404 | .to_bytes();
|
607 405 | ::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"))
|
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"))
|
609 407 | );
|
610 408 | }
|
611 409 | }
|
612 410 |
|
613 - | /// When a boolean list contains non-unique values,
|
614 - | /// the response should be a 400 ValidationException.
|
615 - | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case1
|
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
|
616 415 | #[::tokio::test]
|
617 416 | #[::tracing_test::traced_test]
|
618 417 | #[should_panic]
|
619 - | async fn rest_json_malformed_unique_items_boolean_list_case1_malformed_request() {
|
418 + | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
620 419 | {
|
621 420 | #[allow(unused_mut)]
|
622 421 | let mut http_request = ::http_1x::Request::builder()
|
623 - | .uri("/MalformedUniqueItems")
|
422 + | .uri("/MalformedEnum")
|
624 423 | .method("POST")
|
625 424 | .header("content-type", "application/json")
|
626 425 | .body(::aws_smithy_http_server::body::boxed(
|
627 426 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
628 427 | &::aws_smithy_protocol_test::decode_body_data(
|
629 - | "{ \"booleanList\" : [false, false] }".as_bytes(),
|
428 + | "{ \"list\" : [\"XYZ\"] }".as_bytes(),
|
630 429 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
631 430 | ),
|
632 431 | )),
|
633 432 | ))
|
634 433 | .unwrap();
|
635 434 | #[allow(unused_mut)]
|
636 435 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
637 436 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
638 437 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
639 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
438 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
640 439 | let sender = sender.clone();
|
641 440 | 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> };
|
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> };
|
643 442 | sender.send(()).await.expect("receiver dropped early");
|
644 443 | result
|
645 444 | }
|
646 445 | })
|
647 446 | .build_unchecked();
|
648 447 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
649 448 | .await
|
650 449 | .expect("unable to make an HTTP request");
|
651 450 | ::pretty_assertions::assert_eq!(
|
652 451 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
653 452 | http_response.status()
|
654 453 | );
|
655 454 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
656 455 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
657 456 | http_response.headers(),
|
658 457 | expected_headers,
|
659 458 | ));
|
660 459 | use ::http_body_util::BodyExt;
|
661 460 | let body = http_response
|
662 461 | .into_body()
|
663 462 | .collect()
|
664 463 | .await
|
665 464 | .expect("unable to collect body")
|
666 465 | .to_bytes();
|
667 466 | ::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"))
|
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"))
|
669 468 | );
|
670 469 | }
|
671 470 | }
|
672 471 |
|
673 - | /// When a string list contains non-unique values,
|
674 - | /// the response should be a 400 ValidationException.
|
675 - | /// Test ID: RestJsonMalformedUniqueItemsStringList
|
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
|
676 476 | #[::tokio::test]
|
677 477 | #[::tracing_test::traced_test]
|
678 478 | #[should_panic]
|
679 - | async fn rest_json_malformed_unique_items_string_list_malformed_request() {
|
479 + | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
680 480 | {
|
681 481 | #[allow(unused_mut)]
|
682 482 | let mut http_request = ::http_1x::Request::builder()
|
683 - | .uri("/MalformedUniqueItems")
|
483 + | .uri("/MalformedEnum")
|
684 484 | .method("POST")
|
685 485 | .header("content-type", "application/json")
|
686 486 | .body(::aws_smithy_http_server::body::boxed(
|
687 487 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
688 488 | &::aws_smithy_protocol_test::decode_body_data(
|
689 - | "{ \"stringList\" : [\"abc\", \"abc\"] }".as_bytes(),
|
489 + | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
690 490 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
691 491 | ),
|
692 492 | )),
|
693 493 | ))
|
694 494 | .unwrap();
|
695 495 | #[allow(unused_mut)]
|
696 496 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
697 497 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
698 498 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
699 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
499 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
700 500 | let sender = sender.clone();
|
701 501 | 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> };
|
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> };
|
703 503 | sender.send(()).await.expect("receiver dropped early");
|
704 504 | result
|
705 505 | }
|
706 506 | })
|
707 507 | .build_unchecked();
|
708 508 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
709 509 | .await
|
710 510 | .expect("unable to make an HTTP request");
|
711 511 | ::pretty_assertions::assert_eq!(
|
712 512 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
713 513 | http_response.status()
|
714 514 | );
|
715 515 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
716 516 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
717 517 | http_response.headers(),
|
718 518 | expected_headers,
|
719 519 | ));
|
720 520 | use ::http_body_util::BodyExt;
|
721 521 | let body = http_response
|
722 522 | .into_body()
|
723 523 | .collect()
|
724 524 | .await
|
725 525 | .expect("unable to collect body")
|
726 526 | .to_bytes();
|
727 527 | ::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"))
|
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"))
|
729 529 | );
|
730 530 | }
|
731 531 | }
|
732 532 |
|
733 - | /// When a byte list contains non-unique values,
|
734 - | /// the response should be a 400 ValidationException.
|
735 - | /// Test ID: RestJsonMalformedUniqueItemsByteList
|
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
|
736 537 | #[::tokio::test]
|
737 538 | #[::tracing_test::traced_test]
|
738 539 | #[should_panic]
|
739 - | async fn rest_json_malformed_unique_items_byte_list_malformed_request() {
|
540 + | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
740 541 | {
|
741 542 | #[allow(unused_mut)]
|
742 543 | let mut http_request = ::http_1x::Request::builder()
|
743 - | .uri("/MalformedUniqueItems")
|
544 + | .uri("/MalformedEnum")
|
744 545 | .method("POST")
|
745 546 | .header("content-type", "application/json")
|
746 547 | .body(::aws_smithy_http_server::body::boxed(
|
747 548 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
748 549 | &::aws_smithy_protocol_test::decode_body_data(
|
749 - | "{ \"byteList\" : [1, 1] }".as_bytes(),
|
550 + | "{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes(),
|
750 551 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
751 552 | ),
|
752 553 | )),
|
753 554 | ))
|
754 555 | .unwrap();
|
755 556 | #[allow(unused_mut)]
|
756 557 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
757 558 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
758 559 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
759 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
560 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
760 561 | let sender = sender.clone();
|
761 562 | 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> };
|
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> };
|
763 564 | sender.send(()).await.expect("receiver dropped early");
|
764 565 | result
|
765 566 | }
|
766 567 | })
|
767 568 | .build_unchecked();
|
768 569 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
769 570 | .await
|
770 571 | .expect("unable to make an HTTP request");
|
771 572 | ::pretty_assertions::assert_eq!(
|
772 573 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
773 574 | http_response.status()
|
774 575 | );
|
775 576 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
776 577 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
777 578 | http_response.headers(),
|
778 579 | expected_headers,
|
779 580 | ));
|
780 581 | use ::http_body_util::BodyExt;
|
781 582 | let body = http_response
|
782 583 | .into_body()
|
783 584 | .collect()
|
784 585 | .await
|
785 586 | .expect("unable to collect body")
|
786 587 | .to_bytes();
|
787 588 | ::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"))
|
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"))
|
789 590 | );
|
790 591 | }
|
791 592 | }
|
792 593 |
|
793 - | /// When a short list contains non-unique values,
|
794 - | /// the response should be a 400 ValidationException.
|
795 - | /// Test ID: RestJsonMalformedUniqueItemsShortList
|
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
|
796 598 | #[::tokio::test]
|
797 599 | #[::tracing_test::traced_test]
|
798 600 | #[should_panic]
|
799 - | async fn rest_json_malformed_unique_items_short_list_malformed_request() {
|
601 + | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
800 602 | {
|
801 603 | #[allow(unused_mut)]
|
802 604 | let mut http_request = ::http_1x::Request::builder()
|
803 - | .uri("/MalformedUniqueItems")
|
605 + | .uri("/MalformedEnum")
|
804 606 | .method("POST")
|
805 607 | .header("content-type", "application/json")
|
806 608 | .body(::aws_smithy_http_server::body::boxed(
|
807 609 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
808 610 | &::aws_smithy_protocol_test::decode_body_data(
|
809 - | "{ \"shortList\" : [2, 2] }".as_bytes(),
|
611 + | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
810 612 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
811 613 | ),
|
812 614 | )),
|
813 615 | ))
|
814 616 | .unwrap();
|
815 617 | #[allow(unused_mut)]
|
816 618 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
817 619 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
818 620 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
819 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
621 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
820 622 | let sender = sender.clone();
|
821 623 | 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> };
|
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> };
|
823 625 | sender.send(()).await.expect("receiver dropped early");
|
824 626 | result
|
825 627 | }
|
826 628 | })
|
827 629 | .build_unchecked();
|
828 630 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
829 631 | .await
|
830 632 | .expect("unable to make an HTTP request");
|
831 633 | ::pretty_assertions::assert_eq!(
|
832 634 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
833 635 | http_response.status()
|
834 636 | );
|
835 637 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
836 638 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
837 639 | http_response.headers(),
|
838 640 | expected_headers,
|
839 641 | ));
|
840 642 | use ::http_body_util::BodyExt;
|
841 643 | let body = http_response
|
842 644 | .into_body()
|
843 645 | .collect()
|
844 646 | .await
|
845 647 | .expect("unable to collect body")
|
846 648 | .to_bytes();
|
847 649 | ::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"))
|
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"))
|
849 651 | );
|
850 652 | }
|
851 653 | }
|
852 654 |
|
853 - | /// When an integer list contains non-unique values,
|
854 - | /// the response should be a 400 ValidationException.
|
855 - | /// Test ID: RestJsonMalformedUniqueItemsIntegerList
|
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
|
856 659 | #[::tokio::test]
|
857 660 | #[::tracing_test::traced_test]
|
858 661 | #[should_panic]
|
859 - | async fn rest_json_malformed_unique_items_integer_list_malformed_request() {
|
662 + | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
860 663 | {
|
861 664 | #[allow(unused_mut)]
|
862 665 | let mut http_request = ::http_1x::Request::builder()
|
863 - | .uri("/MalformedUniqueItems")
|
666 + | .uri("/MalformedEnum")
|
864 667 | .method("POST")
|
865 668 | .header("content-type", "application/json")
|
866 669 | .body(::aws_smithy_http_server::body::boxed(
|
867 670 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
868 671 | &::aws_smithy_protocol_test::decode_body_data(
|
869 - | "{ \"integerList\" : [3, 3] }".as_bytes(),
|
672 + | "{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes(),
|
870 673 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
871 674 | ),
|
872 675 | )),
|
873 676 | ))
|
874 677 | .unwrap();
|
875 678 | #[allow(unused_mut)]
|
876 679 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
877 680 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
878 681 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
879 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
682 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
880 683 | let sender = sender.clone();
|
881 684 | 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> };
|
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> };
|
883 686 | sender.send(()).await.expect("receiver dropped early");
|
884 687 | result
|
885 688 | }
|
886 689 | })
|
887 690 | .build_unchecked();
|
888 691 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
889 692 | .await
|
890 693 | .expect("unable to make an HTTP request");
|
891 694 | ::pretty_assertions::assert_eq!(
|
892 695 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
893 696 | http_response.status()
|
894 697 | );
|
895 698 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
896 699 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
897 700 | http_response.headers(),
|
898 701 | expected_headers,
|
899 702 | ));
|
900 703 | use ::http_body_util::BodyExt;
|
901 704 | let body = http_response
|
902 705 | .into_body()
|
903 706 | .collect()
|
904 707 | .await
|
905 708 | .expect("unable to collect body")
|
906 709 | .to_bytes();
|
907 710 | ::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"))
|
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"))
|
909 712 | );
|
910 713 | }
|
911 714 | }
|
912 715 |
|
913 - | /// When an integer list contains non-unique values,
|
914 - | /// the response should be a 400 ValidationException.
|
915 - | /// Test ID: RestJsonMalformedUniqueItemsLongList
|
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
|
916 720 | #[::tokio::test]
|
917 721 | #[::tracing_test::traced_test]
|
918 722 | #[should_panic]
|
919 - | async fn rest_json_malformed_unique_items_long_list_malformed_request() {
|
723 + | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
920 724 | {
|
921 725 | #[allow(unused_mut)]
|
922 726 | let mut http_request = ::http_1x::Request::builder()
|
923 - | .uri("/MalformedUniqueItems")
|
727 + | .uri("/MalformedEnum")
|
924 728 | .method("POST")
|
925 729 | .header("content-type", "application/json")
|
926 730 | .body(::aws_smithy_http_server::body::boxed(
|
927 731 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
928 732 | &::aws_smithy_protocol_test::decode_body_data(
|
929 - | "{ \"longList\" : [4, 4] }".as_bytes(),
|
733 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
930 734 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
931 735 | ),
|
932 736 | )),
|
933 737 | ))
|
934 738 | .unwrap();
|
935 739 | #[allow(unused_mut)]
|
936 740 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
937 741 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
938 742 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
939 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
743 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
940 744 | let sender = sender.clone();
|
941 745 | 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> };
|
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> };
|
943 747 | sender.send(()).await.expect("receiver dropped early");
|
944 748 | result
|
945 749 | }
|
946 750 | })
|
947 751 | .build_unchecked();
|
948 752 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
949 753 | .await
|
950 754 | .expect("unable to make an HTTP request");
|
951 755 | ::pretty_assertions::assert_eq!(
|
952 756 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
953 757 | http_response.status()
|
954 758 | );
|
955 759 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
956 760 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
957 761 | http_response.headers(),
|
958 762 | expected_headers,
|
959 763 | ));
|
960 764 | use ::http_body_util::BodyExt;
|
961 765 | let body = http_response
|
962 766 | .into_body()
|
963 767 | .collect()
|
964 768 | .await
|
965 769 | .expect("unable to collect body")
|
966 770 | .to_bytes();
|
967 771 | ::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"))
|
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"))
|
969 773 | );
|
970 774 | }
|
971 775 | }
|
972 776 |
|
973 - | /// When a timestamp list contains non-unique values,
|
974 - | /// the response should be a 400 ValidationException.
|
975 - | /// Test ID: RestJsonMalformedUniqueItemsTimestampList
|
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
|
976 781 | #[::tokio::test]
|
977 782 | #[::tracing_test::traced_test]
|
978 783 | #[should_panic]
|
979 - | async fn rest_json_malformed_unique_items_timestamp_list_malformed_request() {
|
784 + | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
980 785 | {
|
981 786 | #[allow(unused_mut)]
|
982 787 | let mut http_request = ::http_1x::Request::builder()
|
983 - | .uri("/MalformedUniqueItems")
|
788 + | .uri("/MalformedEnum")
|
984 789 | .method("POST")
|
985 790 | .header("content-type", "application/json")
|
986 791 | .body(::aws_smithy_http_server::body::boxed(
|
987 792 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
988 793 | &::aws_smithy_protocol_test::decode_body_data(
|
989 - | "{ \"timestampList\" : [1676660607, 1676660607] }".as_bytes(),
|
794 + | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|
990 795 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
991 796 | ),
|
992 797 | )),
|
993 798 | ))
|
994 799 | .unwrap();
|
995 800 | #[allow(unused_mut)]
|
996 801 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
997 802 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
998 803 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
999 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
804 + | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
1000 805 | let sender = sender.clone();
|
1001 806 | 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> };
|
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> };
|
1003 808 | sender.send(()).await.expect("receiver dropped early");
|
1004 809 | result
|
1005 810 | }
|
1006 811 | })
|
1007 812 | .build_unchecked();
|
1008 813 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1009 814 | .await
|
1010 815 | .expect("unable to make an HTTP request");
|
1011 816 | ::pretty_assertions::assert_eq!(
|
1012 817 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1013 818 | http_response.status()
|
1014 819 | );
|
1015 820 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1016 821 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1017 822 | http_response.headers(),
|
1018 823 | expected_headers,
|
1019 824 | ));
|
1020 825 | use ::http_body_util::BodyExt;
|
1021 826 | let body = http_response
|
1022 827 | .into_body()
|
1023 828 | .collect()
|
1024 829 | .await
|
1025 830 | .expect("unable to collect body")
|
1026 831 | .to_bytes();
|
1027 832 | ::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"))
|
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"))
|
1029 834 | );
|
1030 835 | }
|
1031 836 | }
|
837 + | }
|
1032 838 |
|
1033 - | /// When a date-time 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,
|
1034 947 | /// the response should be a 400 ValidationException.
|
1035 - | /// Test ID: RestJsonMalformedUniqueItemsDateTimeList
|
948 + | /// Test ID: RestJsonMalformedLengthBlob_case0
|
1036 949 | #[::tokio::test]
|
1037 950 | #[::tracing_test::traced_test]
|
1038 - | #[should_panic]
|
1039 - | async fn rest_json_malformed_unique_items_date_time_list_malformed_request() {
|
951 + | async fn rest_json_malformed_length_blob_case0_malformed_request() {
|
1040 952 | {
|
1041 953 | #[allow(unused_mut)]
|
1042 - | let mut http_request = ::http_1x::Request::builder()
|
1043 - | .uri("/MalformedUniqueItems")
|
1044 - | .method("POST")
|
1045 - | .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();
|
954 + | let mut http_request = ::http_1x::Request::builder()
|
955 + | .uri("/MalformedLength")
|
956 + | .method("POST")
|
957 + | .header("content-type", "application/json")
|
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();
|
1051 967 | #[allow(unused_mut)]
|
1052 968 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1053 969 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1054 970 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1055 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
971 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1056 972 | let sender = sender.clone();
|
1057 973 | 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> };
|
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> };
|
1059 975 | sender.send(()).await.expect("receiver dropped early");
|
1060 976 | result
|
1061 977 | }
|
1062 978 | })
|
1063 979 | .build_unchecked();
|
1064 980 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1065 981 | .await
|
1066 982 | .expect("unable to make an HTTP request");
|
1067 983 | ::pretty_assertions::assert_eq!(
|
1068 984 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1069 985 | http_response.status()
|
1070 986 | );
|
1071 987 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1072 988 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1073 989 | http_response.headers(),
|
1074 990 | expected_headers,
|
1075 991 | ));
|
1076 992 | use ::http_body_util::BodyExt;
|
1077 993 | let body = http_response
|
1078 994 | .into_body()
|
1079 995 | .collect()
|
1080 996 | .await
|
1081 997 | .expect("unable to collect body")
|
1082 998 | .to_bytes();
|
1083 999 | ::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"))
|
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"))
|
1085 1001 | );
|
1086 1002 | }
|
1087 1003 | }
|
1088 1004 |
|
1089 - | /// When a http-date timestamp list contains non-unique values,
|
1005 + | /// When a blob member does not fit within length bounds,
|
1090 1006 | /// the response should be a 400 ValidationException.
|
1091 - | /// Test ID: RestJsonMalformedUniqueItemsHttpDateList_case0
|
1007 + | /// Test ID: RestJsonMalformedLengthBlob_case1
|
1092 1008 | #[::tokio::test]
|
1093 1009 | #[::tracing_test::traced_test]
|
1094 - | #[should_panic]
|
1095 - | async fn rest_json_malformed_unique_items_http_date_list_case0_malformed_request() {
|
1010 + | async fn rest_json_malformed_length_blob_case1_malformed_request() {
|
1096 1011 | {
|
1097 1012 | #[allow(unused_mut)]
|
1098 - | let mut http_request = ::http_1x::Request::builder()
|
1099 - | .uri("/MalformedUniqueItems")
|
1100 - | .method("POST")
|
1101 - | .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();
|
1107 - | #[allow(unused_mut)]
|
1108 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1109 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1110 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1111 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1112 - | let sender = sender.clone();
|
1113 - | 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> };
|
1115 - | sender.send(()).await.expect("receiver dropped early");
|
1116 - | result
|
1117 - | }
|
1118 - | })
|
1013 + | let mut http_request = ::http_1x::Request::builder()
|
1014 + | .uri("/MalformedLength")
|
1015 + | .method("POST")
|
1016 + | .header("content-type", "application/json")
|
1017 + | .body(::aws_smithy_http_server::body::boxed(
|
1018 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1019 + | &::aws_smithy_protocol_test::decode_body_data(
|
1020 + | "{ \"blob\" : \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" }".as_bytes(),
|
1021 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1022 + | ),
|
1023 + | )),
|
1024 + | ))
|
1025 + | .unwrap();
|
1026 + | #[allow(unused_mut)]
|
1027 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1028 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1029 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1030 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1031 + | let sender = sender.clone();
|
1032 + | async move {
|
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> };
|
1034 + | sender.send(()).await.expect("receiver dropped early");
|
1035 + | result
|
1036 + | }
|
1037 + | })
|
1119 1038 | .build_unchecked();
|
1120 1039 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1121 1040 | .await
|
1122 1041 | .expect("unable to make an HTTP request");
|
1123 1042 | ::pretty_assertions::assert_eq!(
|
1124 1043 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1125 1044 | http_response.status()
|
1126 1045 | );
|
1127 1046 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1128 1047 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1129 1048 | http_response.headers(),
|
1130 1049 | expected_headers,
|
1131 1050 | ));
|
1132 1051 | use ::http_body_util::BodyExt;
|
1133 1052 | let body = http_response
|
1134 1053 | .into_body()
|
1135 1054 | .collect()
|
1136 1055 | .await
|
1137 1056 | .expect("unable to collect body")
|
1138 1057 | .to_bytes();
|
1139 1058 | ::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"))
|
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"))
|
1141 1060 | );
|
1142 1061 | }
|
1143 1062 | }
|
1144 1063 |
|
1145 - | /// When an enum list contains non-unique values,
|
1064 + | /// When a string member does not fit within length bounds,
|
1146 1065 | /// the response should be a 400 ValidationException.
|
1147 - | /// Test ID: RestJsonMalformedUniqueItemsEnumList
|
1066 + | /// Test ID: RestJsonMalformedLengthString_case0
|
1148 1067 | #[::tokio::test]
|
1149 1068 | #[::tracing_test::traced_test]
|
1150 - | #[should_panic]
|
1151 - | async fn rest_json_malformed_unique_items_enum_list_malformed_request() {
|
1069 + | async fn rest_json_malformed_length_string_case0_malformed_request() {
|
1152 1070 | {
|
1153 1071 | #[allow(unused_mut)]
|
1154 1072 | let mut http_request = ::http_1x::Request::builder()
|
1155 - | .uri("/MalformedUniqueItems")
|
1073 + | .uri("/MalformedLength")
|
1156 1074 | .method("POST")
|
1157 1075 | .header("content-type", "application/json")
|
1158 1076 | .body(::aws_smithy_http_server::body::boxed(
|
1159 1077 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1160 1078 | &::aws_smithy_protocol_test::decode_body_data(
|
1161 - | "{ \"enumList\" : [\"Foo\", \"Foo\"] }".as_bytes(),
|
1079 + | "{ \"string\" : \"a\" }".as_bytes(),
|
1162 1080 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1163 1081 | ),
|
1164 1082 | )),
|
1165 1083 | ))
|
1166 1084 | .unwrap();
|
1167 1085 | #[allow(unused_mut)]
|
1168 1086 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1169 1087 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1170 1088 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1171 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1089 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1172 1090 | let sender = sender.clone();
|
1173 1091 | 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> };
|
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> };
|
1175 1093 | sender.send(()).await.expect("receiver dropped early");
|
1176 1094 | result
|
1177 1095 | }
|
1178 1096 | })
|
1179 1097 | .build_unchecked();
|
1180 1098 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1181 1099 | .await
|
1182 1100 | .expect("unable to make an HTTP request");
|
1183 1101 | ::pretty_assertions::assert_eq!(
|
1184 1102 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1185 1103 | http_response.status()
|
1186 1104 | );
|
1187 1105 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1188 1106 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1189 1107 | http_response.headers(),
|
1190 1108 | expected_headers,
|
1191 1109 | ));
|
1192 1110 | use ::http_body_util::BodyExt;
|
1193 1111 | let body = http_response
|
1194 1112 | .into_body()
|
1195 1113 | .collect()
|
1196 1114 | .await
|
1197 1115 | .expect("unable to collect body")
|
1198 1116 | .to_bytes();
|
1199 1117 | ::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"))
|
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"))
|
1201 1119 | );
|
1202 1120 | }
|
1203 1121 | }
|
1204 1122 |
|
1205 - | /// When an intEnum list contains non-unique values,
|
1123 + | /// When a string member does not fit within length bounds,
|
1206 1124 | /// the response should be a 400 ValidationException.
|
1207 - | /// Test ID: RestJsonMalformedUniqueItemsIntEnumList
|
1125 + | /// Test ID: RestJsonMalformedLengthString_case1
|
1208 1126 | #[::tokio::test]
|
1209 1127 | #[::tracing_test::traced_test]
|
1210 - | #[should_panic]
|
1211 - | async fn rest_json_malformed_unique_items_int_enum_list_malformed_request() {
|
1128 + | async fn rest_json_malformed_length_string_case1_malformed_request() {
|
1212 1129 | {
|
1213 1130 | #[allow(unused_mut)]
|
1214 1131 | let mut http_request = ::http_1x::Request::builder()
|
1215 - | .uri("/MalformedUniqueItems")
|
1132 + | .uri("/MalformedLength")
|
1216 1133 | .method("POST")
|
1217 1134 | .header("content-type", "application/json")
|
1218 1135 | .body(::aws_smithy_http_server::body::boxed(
|
1219 1136 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1220 1137 | &::aws_smithy_protocol_test::decode_body_data(
|
1221 - | "{ \"intEnumList\" : [3, 3] }".as_bytes(),
|
1138 + | "{ \"string\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
1222 1139 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1223 1140 | ),
|
1224 1141 | )),
|
1225 1142 | ))
|
1226 1143 | .unwrap();
|
1227 1144 | #[allow(unused_mut)]
|
1228 1145 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1229 1146 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1230 1147 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1231 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1148 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1232 1149 | let sender = sender.clone();
|
1233 1150 | 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> };
|
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> };
|
1235 1152 | sender.send(()).await.expect("receiver dropped early");
|
1236 1153 | result
|
1237 1154 | }
|
1238 1155 | })
|
1239 1156 | .build_unchecked();
|
1240 1157 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1241 1158 | .await
|
1242 1159 | .expect("unable to make an HTTP request");
|
1243 1160 | ::pretty_assertions::assert_eq!(
|
1244 1161 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1245 1162 | http_response.status()
|
1246 1163 | );
|
1247 1164 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1248 1165 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1249 1166 | http_response.headers(),
|
1250 1167 | expected_headers,
|
1251 1168 | ));
|
1252 1169 | use ::http_body_util::BodyExt;
|
1253 1170 | let body = http_response
|
1254 1171 | .into_body()
|
1255 1172 | .collect()
|
1256 1173 | .await
|
1257 1174 | .expect("unable to collect body")
|
1258 1175 | .to_bytes();
|
1259 1176 | ::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"))
|
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"))
|
1261 1178 | );
|
1262 1179 | }
|
1263 1180 | }
|
1264 1181 |
|
1265 - | /// When an list of lists contains non-unique values,
|
1182 + | /// When a string member does not fit within length bounds,
|
1266 1183 | /// the response should be a 400 ValidationException.
|
1267 - | /// Test ID: RestJsonMalformedUniqueItemsListList
|
1184 + | /// Test ID: RestJsonMalformedLengthString_case2
|
1268 1185 | #[::tokio::test]
|
1269 1186 | #[::tracing_test::traced_test]
|
1270 - | #[should_panic]
|
1271 - | async fn rest_json_malformed_unique_items_list_list_malformed_request() {
|
1187 + | async fn rest_json_malformed_length_string_case2_malformed_request() {
|
1272 1188 | {
|
1273 1189 | #[allow(unused_mut)]
|
1274 1190 | let mut http_request = ::http_1x::Request::builder()
|
1275 - | .uri("/MalformedUniqueItems")
|
1191 + | .uri("/MalformedLength")
|
1276 1192 | .method("POST")
|
1277 1193 | .header("content-type", "application/json")
|
1278 1194 | .body(::aws_smithy_http_server::body::boxed(
|
1279 1195 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1280 1196 | &::aws_smithy_protocol_test::decode_body_data(
|
1281 - | "{ \"listList\" : [[\"foo\",\"bar\"], [\"foo\",\"bar\"]] }".as_bytes(),
|
1197 + | "{ \"string\" : \"👍\" }".as_bytes(),
|
1282 1198 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1283 1199 | ),
|
1284 1200 | )),
|
1285 1201 | ))
|
1286 1202 | .unwrap();
|
1287 1203 | #[allow(unused_mut)]
|
1288 1204 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1289 1205 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1290 1206 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1291 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1207 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1292 1208 | let sender = sender.clone();
|
1293 1209 | 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> };
|
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> };
|
1295 1211 | sender.send(()).await.expect("receiver dropped early");
|
1296 1212 | result
|
1297 1213 | }
|
1298 1214 | })
|
1299 1215 | .build_unchecked();
|
1300 1216 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1301 1217 | .await
|
1302 1218 | .expect("unable to make an HTTP request");
|
1303 1219 | ::pretty_assertions::assert_eq!(
|
1304 1220 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1305 1221 | http_response.status()
|
1306 1222 | );
|
1307 1223 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1308 1224 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1309 1225 | http_response.headers(),
|
1310 1226 | expected_headers,
|
1311 1227 | ));
|
1312 1228 | use ::http_body_util::BodyExt;
|
1313 1229 | let body = http_response
|
1314 1230 | .into_body()
|
1315 1231 | .collect()
|
1316 1232 | .await
|
1317 1233 | .expect("unable to collect body")
|
1318 1234 | .to_bytes();
|
1319 1235 | ::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"))
|
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"))
|
1321 1237 | );
|
1322 1238 | }
|
1323 1239 | }
|
1324 1240 |
|
1325 - | /// When an list of structures contains non-unique values,
|
1241 + | /// When a string member does not fit within length bounds,
|
1326 1242 | /// the response should be a 400 ValidationException.
|
1327 - | /// Test ID: RestJsonMalformedUniqueItemsStructureList
|
1243 + | /// Test ID: RestJsonMalformedLengthMinString
|
1328 1244 | #[::tokio::test]
|
1329 1245 | #[::tracing_test::traced_test]
|
1330 - | #[should_panic]
|
1331 - | async fn rest_json_malformed_unique_items_structure_list_malformed_request() {
|
1246 + | async fn rest_json_malformed_length_min_string_malformed_request() {
|
1332 1247 | {
|
1333 1248 | #[allow(unused_mut)]
|
1334 1249 | let mut http_request = ::http_1x::Request::builder()
|
1335 - | .uri("/MalformedUniqueItems")
|
1250 + | .uri("/MalformedLength")
|
1336 1251 | .method("POST")
|
1337 1252 | .header("content-type", "application/json")
|
1338 1253 | .body(::aws_smithy_http_server::body::boxed(
|
1339 1254 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1340 1255 | &::aws_smithy_protocol_test::decode_body_data(
|
1341 - | "{ \"structureList\" : [{\"hi\": \"hello\"}, {\"hi\": \"hello\"}] }"
|
1342 - | .as_bytes(),
|
1256 + | "{ \"minString\" : \"a\" }".as_bytes(),
|
1343 1257 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1344 1258 | ),
|
1345 1259 | )),
|
1346 1260 | ))
|
1347 1261 | .unwrap();
|
1348 1262 | #[allow(unused_mut)]
|
1349 1263 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1350 1264 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1351 1265 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1352 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1266 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1353 1267 | let sender = sender.clone();
|
1354 1268 | 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> };
|
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> };
|
1356 1270 | sender.send(()).await.expect("receiver dropped early");
|
1357 1271 | result
|
1358 1272 | }
|
1359 1273 | })
|
1360 1274 | .build_unchecked();
|
1361 1275 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1362 1276 | .await
|
1363 1277 | .expect("unable to make an HTTP request");
|
1364 1278 | ::pretty_assertions::assert_eq!(
|
1365 1279 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1366 1280 | http_response.status()
|
1367 1281 | );
|
1368 1282 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1369 1283 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1370 1284 | http_response.headers(),
|
1371 1285 | expected_headers,
|
1372 1286 | ));
|
1373 1287 | use ::http_body_util::BodyExt;
|
1374 1288 | let body = http_response
|
1375 1289 | .into_body()
|
1376 1290 | .collect()
|
1377 1291 | .await
|
1378 1292 | .expect("unable to collect body")
|
1379 1293 | .to_bytes();
|
1380 1294 | ::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"))
|
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"))
|
1382 1296 | );
|
1383 1297 | }
|
1384 1298 | }
|
1385 1299 |
|
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
|
1300 + | /// When a string member does not fit within length bounds,
|
1301 + | /// the response should be a 400 ValidationException.
|
1302 + | /// Test ID: RestJsonMalformedLengthMaxString
|
1390 1303 | #[::tokio::test]
|
1391 1304 | #[::tracing_test::traced_test]
|
1392 - | async fn rest_json_malformed_unique_items_structure_missing_key_list_malformed_request() {
|
1305 + | async fn rest_json_malformed_length_max_string_malformed_request() {
|
1393 1306 | {
|
1394 1307 | #[allow(unused_mut)]
|
1395 1308 | let mut http_request = ::http_1x::Request::builder()
|
1396 - | .uri("/MalformedUniqueItems")
|
1309 + | .uri("/MalformedLength")
|
1397 1310 | .method("POST")
|
1398 1311 | .header("content-type", "application/json")
|
1399 1312 | .body(::aws_smithy_http_server::body::boxed(
|
1400 1313 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1401 1314 | &::aws_smithy_protocol_test::decode_body_data(
|
1402 - | "{ \"structureListWithNoKey\" : [{\"hi2\": \"bar\"}] }".as_bytes(),
|
1315 + | "{ \"maxString\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
1403 1316 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1404 1317 | ),
|
1405 1318 | )),
|
1406 1319 | ))
|
1407 1320 | .unwrap();
|
1408 1321 | #[allow(unused_mut)]
|
1409 1322 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1410 1323 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1411 1324 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1412 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1325 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1413 1326 | let sender = sender.clone();
|
1414 1327 | 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> };
|
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> };
|
1416 1329 | sender.send(()).await.expect("receiver dropped early");
|
1417 1330 | result
|
1418 1331 | }
|
1419 1332 | })
|
1420 1333 | .build_unchecked();
|
1421 1334 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1422 1335 | .await
|
1423 1336 | .expect("unable to make an HTTP request");
|
1424 1337 | ::pretty_assertions::assert_eq!(
|
1425 1338 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1426 1339 | http_response.status()
|
1427 1340 | );
|
1428 1341 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1429 1342 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1430 1343 | http_response.headers(),
|
1431 1344 | expected_headers,
|
1432 1345 | ));
|
1433 1346 | use ::http_body_util::BodyExt;
|
1434 1347 | let body = http_response
|
1435 1348 | .into_body()
|
1436 1349 | .collect()
|
1437 1350 | .await
|
1438 1351 | .expect("unable to collect body")
|
1439 1352 | .to_bytes();
|
1440 1353 | ::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"))
|
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"))
|
1442 1355 | );
|
1443 1356 | }
|
1444 1357 | }
|
1445 1358 |
|
1446 - | /// When an list of unions contains non-unique values,
|
1359 + | /// When a list member does not fit within length bounds,
|
1447 1360 | /// the response should be a 400 ValidationException.
|
1448 - | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case0
|
1361 + | /// Test ID: RestJsonMalformedLengthList_case0
|
1449 1362 | #[::tokio::test]
|
1450 1363 | #[::tracing_test::traced_test]
|
1451 - | #[should_panic]
|
1452 - | async fn rest_json_malformed_unique_items_union_list_case0_malformed_request() {
|
1364 + | async fn rest_json_malformed_length_list_case0_malformed_request() {
|
1453 1365 | {
|
1454 1366 | #[allow(unused_mut)]
|
1455 1367 | let mut http_request = ::http_1x::Request::builder()
|
1456 - | .uri("/MalformedUniqueItems")
|
1368 + | .uri("/MalformedLength")
|
1457 1369 | .method("POST")
|
1458 1370 | .header("content-type", "application/json")
|
1459 1371 | .body(::aws_smithy_http_server::body::boxed(
|
1460 1372 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1461 1373 | &::aws_smithy_protocol_test::decode_body_data(
|
1462 - | "{ \"unionList\" : [{\"string\": \"foo\"}, {\"string\": \"foo\"}] }"
|
1463 - | .as_bytes(),
|
1374 + | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
1464 1375 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1465 1376 | ),
|
1466 1377 | )),
|
1467 1378 | ))
|
1468 1379 | .unwrap();
|
1469 1380 | #[allow(unused_mut)]
|
1470 1381 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1471 1382 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1472 1383 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1473 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1384 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1474 1385 | let sender = sender.clone();
|
1475 1386 | 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> };
|
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> };
|
1477 1388 | sender.send(()).await.expect("receiver dropped early");
|
1478 1389 | result
|
1479 1390 | }
|
1480 1391 | })
|
1481 1392 | .build_unchecked();
|
1482 1393 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1483 1394 | .await
|
1484 1395 | .expect("unable to make an HTTP request");
|
1485 1396 | ::pretty_assertions::assert_eq!(
|
1486 1397 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1487 1398 | http_response.status()
|
1488 1399 | );
|
1489 1400 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1490 1401 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1491 1402 | http_response.headers(),
|
1492 1403 | expected_headers,
|
1493 1404 | ));
|
1494 1405 | use ::http_body_util::BodyExt;
|
1495 1406 | let body = http_response
|
1496 1407 | .into_body()
|
1497 1408 | .collect()
|
1498 1409 | .await
|
1499 1410 | .expect("unable to collect body")
|
1500 1411 | .to_bytes();
|
1501 1412 | ::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"))
|
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"))
|
1503 1414 | );
|
1504 1415 | }
|
1505 1416 | }
|
1506 1417 |
|
1507 - | /// When an list of unions contains non-unique values,
|
1418 + | /// When a list member does not fit within length bounds,
|
1508 1419 | /// the response should be a 400 ValidationException.
|
1509 - | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case1
|
1420 + | /// Test ID: RestJsonMalformedLengthList_case1
|
1510 1421 | #[::tokio::test]
|
1511 1422 | #[::tracing_test::traced_test]
|
1512 - | #[should_panic]
|
1513 - | async fn rest_json_malformed_unique_items_union_list_case1_malformed_request() {
|
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"))
|
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)
|
1449 + | .await
|
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()
|
1454 + | );
|
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"))
|
1469 + | );
|
1470 + | }
|
1471 + | }
|
1472 + |
|
1473 + | /// When a list member's value does not fit within length bounds,
|
1474 + | /// the response should be a 400 ValidationException.
|
1475 + | /// Test ID: RestJsonMalformedLengthListValue_case0
|
1476 + | #[::tokio::test]
|
1477 + | #[::tracing_test::traced_test]
|
1478 + | async fn rest_json_malformed_length_list_value_case0_malformed_request() {
|
1514 1479 | {
|
1515 1480 | #[allow(unused_mut)]
|
1516 1481 | let mut http_request = ::http_1x::Request::builder()
|
1517 - | .uri("/MalformedUniqueItems")
|
1482 + | .uri("/MalformedLength")
|
1518 1483 | .method("POST")
|
1519 1484 | .header("content-type", "application/json")
|
1520 1485 | .body(::aws_smithy_http_server::body::boxed(
|
1521 1486 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1522 1487 | &::aws_smithy_protocol_test::decode_body_data(
|
1523 - | "{ \"unionList\" : [{\"integer\": 1}, {\"integer\": 1}] }".as_bytes(),
|
1488 + | "{ \"list\" : [\"a\", \"abc\"] }".as_bytes(),
|
1524 1489 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1525 1490 | ),
|
1526 1491 | )),
|
1527 1492 | ))
|
1528 1493 | .unwrap();
|
1529 1494 | #[allow(unused_mut)]
|
1530 1495 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1531 1496 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1532 1497 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1533 - | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
1498 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1534 1499 | let sender = sender.clone();
|
1535 1500 | 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> };
|
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> };
|
1537 1502 | sender.send(()).await.expect("receiver dropped early");
|
1538 1503 | result
|
1539 1504 | }
|
1540 1505 | })
|
1541 1506 | .build_unchecked();
|
1542 1507 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1543 1508 | .await
|
1544 1509 | .expect("unable to make an HTTP request");
|
1545 1510 | ::pretty_assertions::assert_eq!(
|
1546 1511 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1547 1512 | http_response.status()
|
1548 1513 | );
|
1549 1514 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1550 1515 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1551 1516 | http_response.headers(),
|
1552 1517 | expected_headers,
|
1553 1518 | ));
|
1554 1519 | use ::http_body_util::BodyExt;
|
1555 1520 | let body = http_response
|
1556 1521 | .into_body()
|
1557 1522 | .collect()
|
1558 1523 | .await
|
1559 1524 | .expect("unable to collect body")
|
1560 1525 | .to_bytes();
|
1561 1526 | ::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"))
|
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"))
|
1563 1528 | );
|
1564 1529 | }
|
1565 1530 | }
|
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 1531 |
|
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,
|
1617 - | )
|
1618 - | .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 - | },
|
1628 - | );
|
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()),
|
1663 - | );
|
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 - | }
|
1671 - | }
|
1672 - | }
|
1673 - |
|
1674 - | #[allow(unreachable_code, unused_variables)]
|
1675 - | #[cfg(test)]
|
1676 - | mod malformed_required_test {
|
1677 - |
|
1678 - | /// When a required member is not set in the message body,
|
1532 + | /// When a list member's value does not fit within length bounds,
|
1679 1533 | /// the response should be a 400 ValidationException.
|
1680 - | /// Test ID: RestJsonMalformedRequiredBodyUnset
|
1534 + | /// Test ID: RestJsonMalformedLengthListValue_case1
|
1681 1535 | #[::tokio::test]
|
1682 1536 | #[::tracing_test::traced_test]
|
1683 - | async fn rest_json_malformed_required_body_unset_malformed_request() {
|
1537 + | async fn rest_json_malformed_length_list_value_case1_malformed_request() {
|
1684 1538 | {
|
1685 1539 | #[allow(unused_mut)]
|
1686 1540 | let mut http_request = ::http_1x::Request::builder()
|
1687 - | .uri("/MalformedRequired")
|
1541 + | .uri("/MalformedLength")
|
1688 1542 | .method("POST")
|
1689 1543 | .header("content-type", "application/json")
|
1690 - | .header("string-in-headers", "abc")
|
1691 1544 | .body(::aws_smithy_http_server::body::boxed(
|
1692 1545 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1693 1546 | &::aws_smithy_protocol_test::decode_body_data(
|
1694 - | "{ }".as_bytes(),
|
1547 + | "{ \"list\" : [\"abcdefghijklmnopqrstuvwxyz\", \"abc\"] }".as_bytes(),
|
1695 1548 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1696 1549 | ),
|
1697 1550 | )),
|
1698 1551 | ))
|
1699 1552 | .unwrap();
|
1700 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1701 1553 | #[allow(unused_mut)]
|
1702 1554 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1703 1555 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1704 1556 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1705 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1557 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1706 1558 | let sender = sender.clone();
|
1707 1559 | 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> };
|
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> };
|
1709 1561 | sender.send(()).await.expect("receiver dropped early");
|
1710 1562 | result
|
1711 1563 | }
|
1712 1564 | })
|
1713 1565 | .build_unchecked();
|
1714 1566 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1715 1567 | .await
|
1716 1568 | .expect("unable to make an HTTP request");
|
1717 1569 | ::pretty_assertions::assert_eq!(
|
1718 1570 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1719 1571 | http_response.status()
|
1720 1572 | );
|
1721 1573 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1722 1574 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1723 1575 | http_response.headers(),
|
1724 1576 | expected_headers,
|
1725 1577 | ));
|
1726 1578 | use ::http_body_util::BodyExt;
|
1727 1579 | let body = http_response
|
1728 1580 | .into_body()
|
1729 1581 | .collect()
|
1730 1582 | .await
|
1731 1583 | .expect("unable to collect body")
|
1732 1584 | .to_bytes();
|
1733 1585 | ::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"))
|
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"))
|
1735 1587 | );
|
1736 1588 | }
|
1737 1589 | }
|
1738 1590 |
|
1739 - | /// When a required member is set to null in the message body,
|
1591 + | /// When a map member does not fit within length bounds,
|
1740 1592 | /// the response should be a 400 ValidationException.
|
1741 - | /// Test ID: RestJsonMalformedRequiredBodyExplicitNull
|
1593 + | /// Test ID: RestJsonMalformedLengthMap_case0
|
1742 1594 | #[::tokio::test]
|
1743 1595 | #[::tracing_test::traced_test]
|
1744 - | async fn rest_json_malformed_required_body_explicit_null_malformed_request() {
|
1596 + | async fn rest_json_malformed_length_map_case0_malformed_request() {
|
1745 1597 | {
|
1746 1598 | #[allow(unused_mut)]
|
1747 1599 | let mut http_request = ::http_1x::Request::builder()
|
1748 - | .uri("/MalformedRequired")
|
1600 + | .uri("/MalformedLength")
|
1749 1601 | .method("POST")
|
1750 1602 | .header("content-type", "application/json")
|
1751 - | .header("string-in-headers", "abc")
|
1752 1603 | .body(::aws_smithy_http_server::body::boxed(
|
1753 1604 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1754 1605 | &::aws_smithy_protocol_test::decode_body_data(
|
1755 - | "{ \"string\": null }".as_bytes(),
|
1606 + | "{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"]} }".as_bytes(),
|
1756 1607 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1757 1608 | ),
|
1758 1609 | )),
|
1759 1610 | ))
|
1760 1611 | .unwrap();
|
1761 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1762 1612 | #[allow(unused_mut)]
|
1763 1613 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1764 1614 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1765 1615 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1766 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1616 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1767 1617 | let sender = sender.clone();
|
1768 1618 | 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> };
|
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> };
|
1770 1620 | sender.send(()).await.expect("receiver dropped early");
|
1771 1621 | result
|
1772 1622 | }
|
1773 1623 | })
|
1774 1624 | .build_unchecked();
|
1775 1625 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1776 1626 | .await
|
1777 1627 | .expect("unable to make an HTTP request");
|
1778 1628 | ::pretty_assertions::assert_eq!(
|
1779 1629 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1780 1630 | http_response.status()
|
1781 1631 | );
|
1782 1632 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1783 1633 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1784 1634 | http_response.headers(),
|
1785 1635 | expected_headers,
|
1786 1636 | ));
|
1787 1637 | use ::http_body_util::BodyExt;
|
1788 1638 | let body = http_response
|
1789 1639 | .into_body()
|
1790 1640 | .collect()
|
1791 1641 | .await
|
1792 1642 | .expect("unable to collect body")
|
1793 1643 | .to_bytes();
|
1794 1644 | ::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"))
|
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"))
|
1796 1646 | );
|
1797 1647 | }
|
1798 1648 | }
|
1799 1649 |
|
1800 - | /// When a required member is not set in headers,
|
1650 + | /// When a map member does not fit within length bounds,
|
1801 1651 | /// the response should be a 400 ValidationException.
|
1802 - | /// Test ID: RestJsonMalformedRequiredHeaderUnset
|
1652 + | /// Test ID: RestJsonMalformedLengthMap_case1
|
1803 1653 | #[::tokio::test]
|
1804 1654 | #[::tracing_test::traced_test]
|
1805 - | async fn rest_json_malformed_required_header_unset_malformed_request() {
|
1655 + | async fn rest_json_malformed_length_map_case1_malformed_request() {
|
1806 1656 | {
|
1807 1657 | #[allow(unused_mut)]
|
1808 - | let mut http_request = ::http_1x::Request::builder()
|
1809 - | .uri("/MalformedRequired")
|
1810 - | .method("POST")
|
1811 - | .header("content-type", "application/json")
|
1812 - | .body(::aws_smithy_http_server::body::boxed(
|
1813 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
1814 - | &::aws_smithy_protocol_test::decode_body_data(
|
1815 - | "{ \"string\": \"abc\" }".as_bytes(),
|
1816 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
1817 - | ),
|
1818 - | )),
|
1819 - | ))
|
1820 - | .unwrap();
|
1821 - | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
1658 + | let mut http_request = ::http_1x::Request::builder()
|
1659 + | .uri("/MalformedLength")
|
1660 + | .method("POST")
|
1661 + | .header("content-type", "application/json")
|
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();
|
1822 1667 | #[allow(unused_mut)]
|
1823 1668 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1824 1669 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1825 1670 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1826 - | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
1671 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1827 1672 | let sender = sender.clone();
|
1828 1673 | 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> };
|
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> };
|
1830 1675 | sender.send(()).await.expect("receiver dropped early");
|
1831 1676 | result
|
1832 1677 | }
|
1833 1678 | })
|
1834 1679 | .build_unchecked();
|
1835 1680 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1836 1681 | .await
|
1837 1682 | .expect("unable to make an HTTP request");
|
1838 1683 | ::pretty_assertions::assert_eq!(
|
1839 1684 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
1840 1685 | http_response.status()
|
1841 1686 | );
|
1842 1687 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
1843 1688 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
1844 1689 | http_response.headers(),
|
1845 1690 | expected_headers,
|
1846 1691 | ));
|
1847 1692 | use ::http_body_util::BodyExt;
|
1848 1693 | let body = http_response
|
1849 1694 | .into_body()
|
1850 1695 | .collect()
|
1851 1696 | .await
|
1852 1697 | .expect("unable to collect body")
|
1853 1698 | .to_bytes();
|
1854 1699 | ::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"))
|
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"))
|
1856 1701 | );
|
1857 1702 | }
|
1858 1703 | }
|
1859 - | }
|
1860 - |
|
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 1704 |
|
1963 - | /// When a byte member does not fit within range bounds,
|
1705 + | /// When a map member's key does not fit within length bounds,
|
1964 1706 | /// the response should be a 400 ValidationException.
|
1965 - | /// Test ID: RestJsonMalformedRangeByteOverride_case0
|
1707 + | /// Test ID: RestJsonMalformedLengthMapKey_case0
|
1966 1708 | #[::tokio::test]
|
1967 1709 | #[::tracing_test::traced_test]
|
1968 - | async fn rest_json_malformed_range_byte_override_case0_malformed_request() {
|
1710 + | async fn rest_json_malformed_length_map_key_case0_malformed_request() {
|
1969 1711 | {
|
1970 1712 | #[allow(unused_mut)]
|
1971 - | let mut http_request = ::http_1x::Request::builder()
|
1972 - | .uri("/MalformedRangeOverride")
|
1973 - | .method("POST")
|
1974 - | .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();
|
1984 - | #[allow(unused_mut)]
|
1985 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1986 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1713 + | let mut http_request = ::http_1x::Request::builder()
|
1714 + | .uri("/MalformedLength")
|
1715 + | .method("POST")
|
1716 + | .header("content-type", "application/json")
|
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();
|
1722 + | #[allow(unused_mut)]
|
1723 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
1724 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
1987 1725 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
1988 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1726 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
1989 1727 | let sender = sender.clone();
|
1990 1728 | 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> };
|
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> };
|
1992 1730 | sender.send(()).await.expect("receiver dropped early");
|
1993 1731 | result
|
1994 1732 | }
|
1995 1733 | })
|
1996 1734 | .build_unchecked();
|
1997 1735 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
1998 1736 | .await
|
1999 1737 | .expect("unable to make an HTTP request");
|
2000 1738 | ::pretty_assertions::assert_eq!(
|
2001 1739 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2002 1740 | http_response.status()
|
2003 1741 | );
|
2004 1742 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2005 1743 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2006 1744 | http_response.headers(),
|
2007 1745 | expected_headers,
|
2008 1746 | ));
|
2009 1747 | use ::http_body_util::BodyExt;
|
2010 1748 | let body = http_response
|
2011 1749 | .into_body()
|
2012 1750 | .collect()
|
2013 1751 | .await
|
2014 1752 | .expect("unable to collect body")
|
2015 1753 | .to_bytes();
|
2016 1754 | ::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"))
|
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"))
|
2018 1756 | );
|
2019 1757 | }
|
2020 1758 | }
|
2021 1759 |
|
2022 - | /// When a byte member does not fit within range bounds,
|
1760 + | /// When a map member's key does not fit within length bounds,
|
2023 1761 | /// the response should be a 400 ValidationException.
|
2024 - | /// Test ID: RestJsonMalformedRangeByteOverride_case1
|
1762 + | /// Test ID: RestJsonMalformedLengthMapKey_case1
|
2025 1763 | #[::tokio::test]
|
2026 1764 | #[::tracing_test::traced_test]
|
2027 - | async fn rest_json_malformed_range_byte_override_case1_malformed_request() {
|
1765 + | async fn rest_json_malformed_length_map_key_case1_malformed_request() {
|
2028 1766 | {
|
2029 1767 | #[allow(unused_mut)]
|
2030 - | let mut http_request = ::http_1x::Request::builder()
|
2031 - | .uri("/MalformedRangeOverride")
|
2032 - | .method("POST")
|
2033 - | .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();
|
1768 + | let mut http_request = ::http_1x::Request::builder()
|
1769 + | .uri("/MalformedLength")
|
1770 + | .method("POST")
|
1771 + | .header("content-type", "application/json")
|
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();
|
2043 1777 | #[allow(unused_mut)]
|
2044 1778 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2045 1779 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2046 1780 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2047 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1781 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
2048 1782 | let sender = sender.clone();
|
2049 1783 | 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> };
|
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> };
|
2051 1785 | sender.send(()).await.expect("receiver dropped early");
|
2052 1786 | result
|
2053 1787 | }
|
2054 1788 | })
|
2055 1789 | .build_unchecked();
|
2056 1790 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2057 1791 | .await
|
2058 1792 | .expect("unable to make an HTTP request");
|
2059 1793 | ::pretty_assertions::assert_eq!(
|
2060 1794 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2061 1795 | http_response.status()
|
2062 1796 | );
|
2063 1797 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2064 1798 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2065 1799 | http_response.headers(),
|
2066 1800 | expected_headers,
|
2067 1801 | ));
|
2068 1802 | use ::http_body_util::BodyExt;
|
2069 1803 | let body = http_response
|
2070 1804 | .into_body()
|
2071 1805 | .collect()
|
2072 1806 | .await
|
2073 1807 | .expect("unable to collect body")
|
2074 1808 | .to_bytes();
|
2075 1809 | ::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"))
|
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"))
|
2077 1811 | );
|
2078 1812 | }
|
2079 1813 | }
|
2080 1814 |
|
2081 - | /// When a byte member does not fit within range bounds,
|
1815 + | /// When a map member's value does not fit within length bounds,
|
2082 1816 | /// the response should be a 400 ValidationException.
|
2083 - | /// Test ID: RestJsonMalformedRangeMinByteOverride
|
1817 + | /// Test ID: RestJsonMalformedLengthMapValue_case0
|
2084 1818 | #[::tokio::test]
|
2085 1819 | #[::tracing_test::traced_test]
|
2086 - | async fn rest_json_malformed_range_min_byte_override_malformed_request() {
|
1820 + | async fn rest_json_malformed_length_map_value_case0_malformed_request() {
|
2087 1821 | {
|
2088 1822 | #[allow(unused_mut)]
|
2089 - | let mut http_request = ::http_1x::Request::builder()
|
2090 - | .uri("/MalformedRangeOverride")
|
2091 - | .method("POST")
|
2092 - | .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();
|
1823 + | let mut http_request = ::http_1x::Request::builder()
|
1824 + | .uri("/MalformedLength")
|
1825 + | .method("POST")
|
1826 + | .header("content-type", "application/json")
|
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();
|
2102 1832 | #[allow(unused_mut)]
|
2103 1833 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2104 1834 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2105 1835 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2106 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1836 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
2107 1837 | let sender = sender.clone();
|
2108 1838 | 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> };
|
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> };
|
2110 1840 | sender.send(()).await.expect("receiver dropped early");
|
2111 1841 | result
|
2112 1842 | }
|
2113 1843 | })
|
2114 1844 | .build_unchecked();
|
2115 1845 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2116 1846 | .await
|
2117 1847 | .expect("unable to make an HTTP request");
|
2118 1848 | ::pretty_assertions::assert_eq!(
|
2119 1849 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2120 1850 | http_response.status()
|
2121 1851 | );
|
2122 1852 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2123 1853 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2124 1854 | http_response.headers(),
|
2125 1855 | expected_headers,
|
2126 1856 | ));
|
2127 1857 | use ::http_body_util::BodyExt;
|
2128 1858 | let body = http_response
|
2129 1859 | .into_body()
|
2130 1860 | .collect()
|
2131 1861 | .await
|
2132 1862 | .expect("unable to collect body")
|
2133 1863 | .to_bytes();
|
2134 1864 | ::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"))
|
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"))
|
2136 1866 | );
|
2137 1867 | }
|
2138 1868 | }
|
2139 1869 |
|
2140 - | /// When a byte member does not fit within range bounds,
|
1870 + | /// When a map member's value does not fit within length bounds,
|
2141 1871 | /// the response should be a 400 ValidationException.
|
2142 - | /// Test ID: RestJsonMalformedRangeMaxByteOverride
|
1872 + | /// Test ID: RestJsonMalformedLengthMapValue_case1
|
2143 1873 | #[::tokio::test]
|
2144 1874 | #[::tracing_test::traced_test]
|
2145 - | async fn rest_json_malformed_range_max_byte_override_malformed_request() {
|
1875 + | async fn rest_json_malformed_length_map_value_case1_malformed_request() {
|
2146 1876 | {
|
2147 1877 | #[allow(unused_mut)]
|
2148 - | let mut http_request = ::http_1x::Request::builder()
|
2149 - | .uri("/MalformedRangeOverride")
|
2150 - | .method("POST")
|
2151 - | .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();
|
1878 + | let mut http_request = ::http_1x::Request::builder()
|
1879 + | .uri("/MalformedLength")
|
1880 + | .method("POST")
|
1881 + | .header("content-type", "application/json")
|
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();
|
2161 1887 | #[allow(unused_mut)]
|
2162 1888 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2163 1889 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2164 1890 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2165 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
1891 + | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
2166 1892 | let sender = sender.clone();
|
2167 1893 | 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> };
|
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> };
|
2169 1895 | sender.send(()).await.expect("receiver dropped early");
|
2170 1896 | result
|
2171 1897 | }
|
2172 1898 | })
|
2173 1899 | .build_unchecked();
|
2174 1900 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2175 1901 | .await
|
2176 1902 | .expect("unable to make an HTTP request");
|
2177 1903 | ::pretty_assertions::assert_eq!(
|
2178 1904 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2179 1905 | http_response.status()
|
2180 1906 | );
|
2181 1907 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2182 1908 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2183 1909 | http_response.headers(),
|
2184 1910 | expected_headers,
|
2185 1911 | ));
|
2186 1912 | use ::http_body_util::BodyExt;
|
2187 1913 | let body = http_response
|
2188 1914 | .into_body()
|
2189 1915 | .collect()
|
2190 1916 | .await
|
2191 1917 | .expect("unable to collect body")
|
2192 1918 | .to_bytes();
|
2193 1919 | ::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"))
|
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"))
|
2195 1921 | );
|
2196 1922 | }
|
2197 1923 | }
|
1924 + | }
|
2198 1925 |
|
2199 - | /// When a float member does not fit within range bounds,
|
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,
|
2200 2029 | /// the response should be a 400 ValidationException.
|
2201 - | /// Test ID: RestJsonMalformedRangeFloatOverride_case0
|
2030 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case0
|
2202 2031 | #[::tokio::test]
|
2203 2032 | #[::tracing_test::traced_test]
|
2204 - | #[should_panic]
|
2205 - | async fn rest_json_malformed_range_float_override_case0_malformed_request() {
|
2033 + | async fn rest_json_malformed_length_blob_override_case0_malformed_request() {
|
2206 2034 | {
|
2207 2035 | #[allow(unused_mut)]
|
2208 2036 | let mut http_request = ::http_1x::Request::builder()
|
2209 - | .uri("/MalformedRangeOverride")
|
2037 + | .uri("/MalformedLengthOverride")
|
2210 2038 | .method("POST")
|
2211 2039 | .header("content-type", "application/json")
|
2212 2040 | .body(::aws_smithy_http_server::body::boxed(
|
2213 2041 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2214 2042 | &::aws_smithy_protocol_test::decode_body_data(
|
2215 - | "{ \"float\" : 4.3 }".as_bytes(),
|
2043 + | "{ \"blob\" : \"YWJj\" }".as_bytes(),
|
2216 2044 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2217 2045 | ),
|
2218 2046 | )),
|
2219 2047 | ))
|
2220 2048 | .unwrap();
|
2221 2049 | #[allow(unused_mut)]
|
2222 2050 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2223 2051 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2224 2052 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2225 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2053 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2226 2054 | let sender = sender.clone();
|
2227 2055 | 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> };
|
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> };
|
2229 2057 | sender.send(()).await.expect("receiver dropped early");
|
2230 2058 | result
|
2231 2059 | }
|
2232 2060 | })
|
2233 2061 | .build_unchecked();
|
2234 2062 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2235 2063 | .await
|
2236 2064 | .expect("unable to make an HTTP request");
|
2237 2065 | ::pretty_assertions::assert_eq!(
|
2238 2066 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2239 2067 | http_response.status()
|
2240 2068 | );
|
2241 2069 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2242 2070 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2243 2071 | http_response.headers(),
|
2244 2072 | expected_headers,
|
2245 2073 | ));
|
2246 2074 | use ::http_body_util::BodyExt;
|
2247 2075 | let body = http_response
|
2248 2076 | .into_body()
|
2249 2077 | .collect()
|
2250 2078 | .await
|
2251 2079 | .expect("unable to collect body")
|
2252 2080 | .to_bytes();
|
2253 2081 | ::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"))
|
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"))
|
2255 2083 | );
|
2256 2084 | }
|
2257 2085 | }
|
2258 2086 |
|
2259 - | /// When a float member does not fit within range bounds,
|
2087 + | /// When a blob member does not fit within length bounds,
|
2260 2088 | /// the response should be a 400 ValidationException.
|
2261 - | /// Test ID: RestJsonMalformedRangeFloatOverride_case1
|
2089 + | /// Test ID: RestJsonMalformedLengthBlobOverride_case1
|
2262 2090 | #[::tokio::test]
|
2263 2091 | #[::tracing_test::traced_test]
|
2264 - | #[should_panic]
|
2265 - | async fn rest_json_malformed_range_float_override_case1_malformed_request() {
|
2092 + | async fn rest_json_malformed_length_blob_override_case1_malformed_request() {
|
2266 2093 | {
|
2267 2094 | #[allow(unused_mut)]
|
2268 2095 | let mut http_request = ::http_1x::Request::builder()
|
2269 - | .uri("/MalformedRangeOverride")
|
2096 + | .uri("/MalformedLengthOverride")
|
2270 2097 | .method("POST")
|
2271 2098 | .header("content-type", "application/json")
|
2272 2099 | .body(::aws_smithy_http_server::body::boxed(
|
2273 2100 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2274 2101 | &::aws_smithy_protocol_test::decode_body_data(
|
2275 - | "{ \"float\" : 6.7 }".as_bytes(),
|
2102 + | "{ \"blob\" : \"YWJjZGVmZw==\" }".as_bytes(),
|
2276 2103 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2277 2104 | ),
|
2278 2105 | )),
|
2279 2106 | ))
|
2280 2107 | .unwrap();
|
2281 2108 | #[allow(unused_mut)]
|
2282 2109 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2283 2110 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2284 2111 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2285 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2112 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2286 2113 | let sender = sender.clone();
|
2287 2114 | 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> };
|
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> };
|
2289 2116 | sender.send(()).await.expect("receiver dropped early");
|
2290 2117 | result
|
2291 2118 | }
|
2292 2119 | })
|
2293 2120 | .build_unchecked();
|
2294 2121 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2295 2122 | .await
|
2296 2123 | .expect("unable to make an HTTP request");
|
2297 2124 | ::pretty_assertions::assert_eq!(
|
2298 2125 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2299 2126 | http_response.status()
|
2300 2127 | );
|
2301 2128 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2302 2129 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2303 2130 | http_response.headers(),
|
2304 2131 | expected_headers,
|
2305 2132 | ));
|
2306 2133 | use ::http_body_util::BodyExt;
|
2307 2134 | let body = http_response
|
2308 2135 | .into_body()
|
2309 2136 | .collect()
|
2310 2137 | .await
|
2311 2138 | .expect("unable to collect body")
|
2312 2139 | .to_bytes();
|
2313 2140 | ::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"))
|
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"))
|
2315 2142 | );
|
2316 2143 | }
|
2317 2144 | }
|
2318 2145 |
|
2319 - | /// When a float member does not fit within range bounds,
|
2146 + | /// When a string member does not fit within length bounds,
|
2320 2147 | /// the response should be a 400 ValidationException.
|
2321 - | /// Test ID: RestJsonMalformedRangeMinFloatOverride
|
2148 + | /// Test ID: RestJsonMalformedLengthStringOverride_case0
|
2322 2149 | #[::tokio::test]
|
2323 2150 | #[::tracing_test::traced_test]
|
2324 - | #[should_panic]
|
2325 - | async fn rest_json_malformed_range_min_float_override_malformed_request() {
|
2151 + | async fn rest_json_malformed_length_string_override_case0_malformed_request() {
|
2326 2152 | {
|
2327 2153 | #[allow(unused_mut)]
|
2328 2154 | let mut http_request = ::http_1x::Request::builder()
|
2329 - | .uri("/MalformedRangeOverride")
|
2155 + | .uri("/MalformedLengthOverride")
|
2330 2156 | .method("POST")
|
2331 2157 | .header("content-type", "application/json")
|
2332 2158 | .body(::aws_smithy_http_server::body::boxed(
|
2333 2159 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2334 2160 | &::aws_smithy_protocol_test::decode_body_data(
|
2335 - | "{ \"minFloat\" : 4.3 }".as_bytes(),
|
2161 + | "{ \"string\" : \"abc\" }".as_bytes(),
|
2336 2162 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2337 2163 | ),
|
2338 2164 | )),
|
2339 2165 | ))
|
2340 2166 | .unwrap();
|
2341 2167 | #[allow(unused_mut)]
|
2342 2168 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2343 2169 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2344 2170 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2345 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2171 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2346 2172 | let sender = sender.clone();
|
2347 2173 | 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> };
|
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> };
|
2349 2175 | sender.send(()).await.expect("receiver dropped early");
|
2350 2176 | result
|
2351 2177 | }
|
2352 2178 | })
|
2353 2179 | .build_unchecked();
|
2354 2180 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2355 2181 | .await
|
2356 2182 | .expect("unable to make an HTTP request");
|
2357 2183 | ::pretty_assertions::assert_eq!(
|
2358 2184 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2359 2185 | http_response.status()
|
2360 2186 | );
|
2361 2187 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2362 2188 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2363 2189 | http_response.headers(),
|
2364 2190 | expected_headers,
|
2365 2191 | ));
|
2366 2192 | use ::http_body_util::BodyExt;
|
2367 2193 | let body = http_response
|
2368 2194 | .into_body()
|
2369 2195 | .collect()
|
2370 2196 | .await
|
2371 2197 | .expect("unable to collect body")
|
2372 2198 | .to_bytes();
|
2373 2199 | ::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"))
|
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"))
|
2375 2201 | );
|
2376 2202 | }
|
2377 2203 | }
|
2378 2204 |
|
2379 - | /// When a float member does not fit within range bounds,
|
2205 + | /// When a string member does not fit within length bounds,
|
2380 2206 | /// the response should be a 400 ValidationException.
|
2381 - | /// Test ID: RestJsonMalformedRangeMaxFloatOverride
|
2207 + | /// Test ID: RestJsonMalformedLengthStringOverride_case1
|
2382 2208 | #[::tokio::test]
|
2383 2209 | #[::tracing_test::traced_test]
|
2384 - | #[should_panic]
|
2385 - | async fn rest_json_malformed_range_max_float_override_malformed_request() {
|
2210 + | async fn rest_json_malformed_length_string_override_case1_malformed_request() {
|
2386 2211 | {
|
2387 2212 | #[allow(unused_mut)]
|
2388 2213 | let mut http_request = ::http_1x::Request::builder()
|
2389 - | .uri("/MalformedRangeOverride")
|
2214 + | .uri("/MalformedLengthOverride")
|
2390 2215 | .method("POST")
|
2391 2216 | .header("content-type", "application/json")
|
2392 2217 | .body(::aws_smithy_http_server::body::boxed(
|
2393 2218 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2394 2219 | &::aws_smithy_protocol_test::decode_body_data(
|
2395 - | "{ \"maxFloat\" : 6.7 }".as_bytes(),
|
2220 + | "{ \"string\" : \"abcdefg\" }".as_bytes(),
|
2396 2221 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2397 2222 | ),
|
2398 2223 | )),
|
2399 2224 | ))
|
2400 2225 | .unwrap();
|
2401 2226 | #[allow(unused_mut)]
|
2402 2227 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2403 2228 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2404 2229 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2405 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2230 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2406 2231 | let sender = sender.clone();
|
2407 2232 | 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> };
|
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> };
|
2409 2234 | sender.send(()).await.expect("receiver dropped early");
|
2410 2235 | result
|
2411 2236 | }
|
2412 2237 | })
|
2413 2238 | .build_unchecked();
|
2414 2239 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2415 2240 | .await
|
2416 2241 | .expect("unable to make an HTTP request");
|
2417 2242 | ::pretty_assertions::assert_eq!(
|
2418 2243 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2419 2244 | http_response.status()
|
2420 2245 | );
|
2421 2246 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2422 2247 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2423 2248 | http_response.headers(),
|
2424 2249 | expected_headers,
|
2425 2250 | ));
|
2426 2251 | use ::http_body_util::BodyExt;
|
2427 2252 | let body = http_response
|
2428 2253 | .into_body()
|
2429 2254 | .collect()
|
2430 2255 | .await
|
2431 2256 | .expect("unable to collect body")
|
2432 2257 | .to_bytes();
|
2433 2258 | ::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"))
|
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"))
|
2435 2260 | );
|
2436 2261 | }
|
2437 2262 | }
|
2438 2263 |
|
2439 - | /// When a short member does not fit within range bounds,
|
2264 + | /// When a string member does not fit within length bounds,
|
2440 2265 | /// the response should be a 400 ValidationException.
|
2441 - | /// Test ID: RestJsonMalformedRangeShortOverride_case0
|
2266 + | /// Test ID: RestJsonMalformedLengthStringOverride_case2
|
2442 2267 | #[::tokio::test]
|
2443 2268 | #[::tracing_test::traced_test]
|
2444 - | async fn rest_json_malformed_range_short_override_case0_malformed_request() {
|
2269 + | async fn rest_json_malformed_length_string_override_case2_malformed_request() {
|
2445 2270 | {
|
2446 2271 | #[allow(unused_mut)]
|
2447 2272 | let mut http_request = ::http_1x::Request::builder()
|
2448 - | .uri("/MalformedRangeOverride")
|
2273 + | .uri("/MalformedLengthOverride")
|
2449 2274 | .method("POST")
|
2450 2275 | .header("content-type", "application/json")
|
2451 2276 | .body(::aws_smithy_http_server::body::boxed(
|
2452 2277 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2453 2278 | &::aws_smithy_protocol_test::decode_body_data(
|
2454 - | "{ \"short\" : 3 }".as_bytes(),
|
2279 + | "{ \"string\" : \"👍👍👍\" }".as_bytes(),
|
2455 2280 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2456 2281 | ),
|
2457 2282 | )),
|
2458 2283 | ))
|
2459 2284 | .unwrap();
|
2460 2285 | #[allow(unused_mut)]
|
2461 2286 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2462 2287 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2463 2288 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2464 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2289 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2465 2290 | let sender = sender.clone();
|
2466 2291 | 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> };
|
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> };
|
2468 2293 | sender.send(()).await.expect("receiver dropped early");
|
2469 2294 | result
|
2470 2295 | }
|
2471 2296 | })
|
2472 2297 | .build_unchecked();
|
2473 2298 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2474 2299 | .await
|
2475 2300 | .expect("unable to make an HTTP request");
|
2476 2301 | ::pretty_assertions::assert_eq!(
|
2477 2302 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2478 2303 | http_response.status()
|
2479 2304 | );
|
2480 2305 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2481 2306 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2482 2307 | http_response.headers(),
|
2483 2308 | expected_headers,
|
2484 2309 | ));
|
2485 2310 | use ::http_body_util::BodyExt;
|
2486 2311 | let body = http_response
|
2487 2312 | .into_body()
|
2488 2313 | .collect()
|
2489 2314 | .await
|
2490 2315 | .expect("unable to collect body")
|
2491 2316 | .to_bytes();
|
2492 2317 | ::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"))
|
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"))
|
2494 2319 | );
|
2495 2320 | }
|
2496 2321 | }
|
2497 2322 |
|
2498 - | /// When a short member does not fit within range bounds,
|
2323 + | /// When a string member does not fit within length bounds,
|
2499 2324 | /// the response should be a 400 ValidationException.
|
2500 - | /// Test ID: RestJsonMalformedRangeShortOverride_case1
|
2325 + | /// Test ID: RestJsonMalformedLengthMinStringOverride
|
2501 2326 | #[::tokio::test]
|
2502 2327 | #[::tracing_test::traced_test]
|
2503 - | async fn rest_json_malformed_range_short_override_case1_malformed_request() {
|
2328 + | async fn rest_json_malformed_length_min_string_override_malformed_request() {
|
2504 2329 | {
|
2505 2330 | #[allow(unused_mut)]
|
2506 2331 | let mut http_request = ::http_1x::Request::builder()
|
2507 - | .uri("/MalformedRangeOverride")
|
2332 + | .uri("/MalformedLengthOverride")
|
2508 2333 | .method("POST")
|
2509 2334 | .header("content-type", "application/json")
|
2510 2335 | .body(::aws_smithy_http_server::body::boxed(
|
2511 2336 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2512 2337 | &::aws_smithy_protocol_test::decode_body_data(
|
2513 - | "{ \"short\" : 7 }".as_bytes(),
|
2338 + | "{ \"minString\" : \"abc\" }".as_bytes(),
|
2514 2339 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2515 2340 | ),
|
2516 2341 | )),
|
2517 2342 | ))
|
2518 2343 | .unwrap();
|
2519 2344 | #[allow(unused_mut)]
|
2520 2345 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2521 2346 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2522 2347 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2523 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2348 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2524 2349 | let sender = sender.clone();
|
2525 2350 | 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> };
|
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> };
|
2527 2352 | sender.send(()).await.expect("receiver dropped early");
|
2528 2353 | result
|
2529 2354 | }
|
2530 2355 | })
|
2531 2356 | .build_unchecked();
|
2532 2357 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2533 2358 | .await
|
2534 2359 | .expect("unable to make an HTTP request");
|
2535 2360 | ::pretty_assertions::assert_eq!(
|
2536 2361 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2537 2362 | http_response.status()
|
2538 2363 | );
|
2539 2364 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2540 2365 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2541 2366 | http_response.headers(),
|
2542 2367 | expected_headers,
|
2543 2368 | ));
|
2544 2369 | use ::http_body_util::BodyExt;
|
2545 2370 | let body = http_response
|
2546 2371 | .into_body()
|
2547 2372 | .collect()
|
2548 2373 | .await
|
2549 2374 | .expect("unable to collect body")
|
2550 2375 | .to_bytes();
|
2551 2376 | ::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"))
|
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"))
|
2553 2378 | );
|
2554 2379 | }
|
2555 2380 | }
|
2556 2381 |
|
2557 - | /// When a short member does not fit within range bounds,
|
2382 + | /// When a string member does not fit within length bounds,
|
2558 2383 | /// the response should be a 400 ValidationException.
|
2559 - | /// Test ID: RestJsonMalformedRangeMinShortOverride
|
2384 + | /// Test ID: RestJsonMalformedLengthMaxStringOverride
|
2560 2385 | #[::tokio::test]
|
2561 2386 | #[::tracing_test::traced_test]
|
2562 - | async fn rest_json_malformed_range_min_short_override_malformed_request() {
|
2387 + | async fn rest_json_malformed_length_max_string_override_malformed_request() {
|
2563 2388 | {
|
2564 2389 | #[allow(unused_mut)]
|
2565 2390 | let mut http_request = ::http_1x::Request::builder()
|
2566 - | .uri("/MalformedRangeOverride")
|
2391 + | .uri("/MalformedLengthOverride")
|
2567 2392 | .method("POST")
|
2568 2393 | .header("content-type", "application/json")
|
2569 2394 | .body(::aws_smithy_http_server::body::boxed(
|
2570 2395 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2571 2396 | &::aws_smithy_protocol_test::decode_body_data(
|
2572 - | "{ \"minShort\" : 3 }".as_bytes(),
|
2397 + | "{ \"maxString\" : \"abcdefg\" }".as_bytes(),
|
2573 2398 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2574 2399 | ),
|
2575 2400 | )),
|
2576 2401 | ))
|
2577 2402 | .unwrap();
|
2578 2403 | #[allow(unused_mut)]
|
2579 2404 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2580 2405 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2581 2406 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2582 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2407 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2583 2408 | let sender = sender.clone();
|
2584 2409 | 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> };
|
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> };
|
2586 2411 | sender.send(()).await.expect("receiver dropped early");
|
2587 2412 | result
|
2588 2413 | }
|
2589 2414 | })
|
2590 2415 | .build_unchecked();
|
2591 2416 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2592 2417 | .await
|
2593 2418 | .expect("unable to make an HTTP request");
|
2594 2419 | ::pretty_assertions::assert_eq!(
|
2595 2420 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2596 2421 | http_response.status()
|
2597 2422 | );
|
2598 2423 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2599 2424 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2600 2425 | http_response.headers(),
|
2601 2426 | expected_headers,
|
2602 2427 | ));
|
2603 2428 | use ::http_body_util::BodyExt;
|
2604 2429 | let body = http_response
|
2605 2430 | .into_body()
|
2606 2431 | .collect()
|
2607 2432 | .await
|
2608 2433 | .expect("unable to collect body")
|
2609 2434 | .to_bytes();
|
2610 2435 | ::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"))
|
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"))
|
2612 2437 | );
|
2613 2438 | }
|
2614 2439 | }
|
2615 2440 |
|
2616 - | /// When a short member does not fit within range bounds,
|
2441 + | /// When a list member does not fit within length bounds,
|
2617 2442 | /// the response should be a 400 ValidationException.
|
2618 - | /// Test ID: RestJsonMalformedRangeMaxShortOverride
|
2443 + | /// Test ID: RestJsonMalformedLengthListOverride_case0
|
2619 2444 | #[::tokio::test]
|
2620 2445 | #[::tracing_test::traced_test]
|
2621 - | async fn rest_json_malformed_range_max_short_override_malformed_request() {
|
2446 + | async fn rest_json_malformed_length_list_override_case0_malformed_request() {
|
2622 2447 | {
|
2623 2448 | #[allow(unused_mut)]
|
2624 2449 | let mut http_request = ::http_1x::Request::builder()
|
2625 - | .uri("/MalformedRangeOverride")
|
2450 + | .uri("/MalformedLengthOverride")
|
2626 2451 | .method("POST")
|
2627 2452 | .header("content-type", "application/json")
|
2628 2453 | .body(::aws_smithy_http_server::body::boxed(
|
2629 2454 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2630 2455 | &::aws_smithy_protocol_test::decode_body_data(
|
2631 - | "{ \"maxShort\" : 7 }".as_bytes(),
|
2456 + | "{ \"list\" : [\"abc\", \"def\", \"ghi\"] }".as_bytes(),
|
2632 2457 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2633 2458 | ),
|
2634 2459 | )),
|
2635 2460 | ))
|
2636 2461 | .unwrap();
|
2637 2462 | #[allow(unused_mut)]
|
2638 2463 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2639 2464 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2640 2465 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2641 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2466 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2642 2467 | let sender = sender.clone();
|
2643 2468 | 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> };
|
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> };
|
2645 2470 | sender.send(()).await.expect("receiver dropped early");
|
2646 2471 | result
|
2647 2472 | }
|
2648 2473 | })
|
2649 2474 | .build_unchecked();
|
2650 2475 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2651 2476 | .await
|
2652 2477 | .expect("unable to make an HTTP request");
|
2653 2478 | ::pretty_assertions::assert_eq!(
|
2654 2479 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2655 2480 | http_response.status()
|
2656 2481 | );
|
2657 2482 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2658 2483 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2659 2484 | http_response.headers(),
|
2660 2485 | expected_headers,
|
2661 2486 | ));
|
2662 2487 | use ::http_body_util::BodyExt;
|
2663 2488 | let body = http_response
|
2664 2489 | .into_body()
|
2665 2490 | .collect()
|
2666 2491 | .await
|
2667 2492 | .expect("unable to collect body")
|
2668 2493 | .to_bytes();
|
2669 2494 | ::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"))
|
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"))
|
2671 2496 | );
|
2672 2497 | }
|
2673 2498 | }
|
2674 2499 |
|
2675 - | /// When a integer member does not fit within range bounds,
|
2500 + | /// When a list member does not fit within length bounds,
|
2676 2501 | /// the response should be a 400 ValidationException.
|
2677 - | /// Test ID: RestJsonMalformedRangeIntegerOverride_case0
|
2502 + | /// Test ID: RestJsonMalformedLengthListOverride_case1
|
2678 2503 | #[::tokio::test]
|
2679 2504 | #[::tracing_test::traced_test]
|
2680 - | async fn rest_json_malformed_range_integer_override_case0_malformed_request() {
|
2505 + | async fn rest_json_malformed_length_list_override_case1_malformed_request() {
|
2681 2506 | {
|
2682 2507 | #[allow(unused_mut)]
|
2683 - | let mut http_request = ::http_1x::Request::builder()
|
2684 - | .uri("/MalformedRangeOverride")
|
2685 - | .method("POST")
|
2686 - | .header("content-type", "application/json")
|
2687 - | .body(::aws_smithy_http_server::body::boxed(
|
2688 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2689 - | &::aws_smithy_protocol_test::decode_body_data(
|
2690 - | "{ \"integer\" : 3 }".as_bytes(),
|
2691 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2692 - | ),
|
2693 - | )),
|
2694 - | ))
|
2695 - | .unwrap();
|
2508 + | let mut http_request = ::http_1x::Request::builder()
|
2509 + | .uri("/MalformedLengthOverride")
|
2510 + | .method("POST")
|
2511 + | .header("content-type", "application/json")
|
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();
|
2696 2517 | #[allow(unused_mut)]
|
2697 2518 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2698 2519 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2699 2520 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2700 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2521 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2701 2522 | let sender = sender.clone();
|
2702 2523 | 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> };
|
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> };
|
2704 2525 | sender.send(()).await.expect("receiver dropped early");
|
2705 2526 | result
|
2706 2527 | }
|
2707 2528 | })
|
2708 2529 | .build_unchecked();
|
2709 2530 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2710 2531 | .await
|
2711 2532 | .expect("unable to make an HTTP request");
|
2712 2533 | ::pretty_assertions::assert_eq!(
|
2713 2534 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2714 2535 | http_response.status()
|
2715 2536 | );
|
2716 2537 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2717 2538 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2718 2539 | http_response.headers(),
|
2719 2540 | expected_headers,
|
2720 2541 | ));
|
2721 2542 | use ::http_body_util::BodyExt;
|
2722 2543 | let body = http_response
|
2723 2544 | .into_body()
|
2724 2545 | .collect()
|
2725 2546 | .await
|
2726 2547 | .expect("unable to collect body")
|
2727 2548 | .to_bytes();
|
2728 2549 | ::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"))
|
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"))
|
2730 2551 | );
|
2731 2552 | }
|
2732 2553 | }
|
2733 2554 |
|
2734 - | /// When a integer member does not fit within range bounds,
|
2555 + | /// When a map member does not fit within length bounds,
|
2735 2556 | /// the response should be a 400 ValidationException.
|
2736 - | /// Test ID: RestJsonMalformedRangeIntegerOverride_case1
|
2557 + | /// Test ID: RestJsonMalformedLengthMapOverride_case0
|
2737 2558 | #[::tokio::test]
|
2738 2559 | #[::tracing_test::traced_test]
|
2739 - | async fn rest_json_malformed_range_integer_override_case1_malformed_request() {
|
2560 + | async fn rest_json_malformed_length_map_override_case0_malformed_request() {
|
2740 2561 | {
|
2741 2562 | #[allow(unused_mut)]
|
2742 - | let mut http_request = ::http_1x::Request::builder()
|
2743 - | .uri("/MalformedRangeOverride")
|
2744 - | .method("POST")
|
2745 - | .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();
|
2563 + | let mut http_request = ::http_1x::Request::builder()
|
2564 + | .uri("/MalformedLengthOverride")
|
2565 + | .method("POST")
|
2566 + | .header("content-type", "application/json")
|
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();
|
2755 2572 | #[allow(unused_mut)]
|
2756 2573 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2757 2574 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2758 2575 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2759 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2576 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2760 2577 | let sender = sender.clone();
|
2761 2578 | 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> };
|
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> };
|
2763 2580 | sender.send(()).await.expect("receiver dropped early");
|
2764 2581 | result
|
2765 2582 | }
|
2766 2583 | })
|
2767 2584 | .build_unchecked();
|
2768 2585 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2769 2586 | .await
|
2770 2587 | .expect("unable to make an HTTP request");
|
2771 2588 | ::pretty_assertions::assert_eq!(
|
2772 2589 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2773 2590 | http_response.status()
|
2774 2591 | );
|
2775 2592 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2776 2593 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2777 2594 | http_response.headers(),
|
2778 2595 | expected_headers,
|
2779 2596 | ));
|
2780 2597 | use ::http_body_util::BodyExt;
|
2781 2598 | let body = http_response
|
2782 2599 | .into_body()
|
2783 2600 | .collect()
|
2784 2601 | .await
|
2785 2602 | .expect("unable to collect body")
|
2786 2603 | .to_bytes();
|
2787 2604 | ::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"))
|
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"))
|
2789 2606 | );
|
2790 2607 | }
|
2791 2608 | }
|
2792 2609 |
|
2793 - | /// When a integer member does not fit within range bounds,
|
2610 + | /// When a map member does not fit within length bounds,
|
2794 2611 | /// the response should be a 400 ValidationException.
|
2795 - | /// Test ID: RestJsonMalformedRangeMinIntegerOverride
|
2612 + | /// Test ID: RestJsonMalformedLengthMapOverride_case1
|
2796 2613 | #[::tokio::test]
|
2797 2614 | #[::tracing_test::traced_test]
|
2798 - | async fn rest_json_malformed_range_min_integer_override_malformed_request() {
|
2615 + | async fn rest_json_malformed_length_map_override_case1_malformed_request() {
|
2799 2616 | {
|
2800 2617 | #[allow(unused_mut)]
|
2801 - | let mut http_request = ::http_1x::Request::builder()
|
2802 - | .uri("/MalformedRangeOverride")
|
2803 - | .method("POST")
|
2804 - | .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();
|
2618 + | let mut http_request = ::http_1x::Request::builder()
|
2619 + | .uri("/MalformedLengthOverride")
|
2620 + | .method("POST")
|
2621 + | .header("content-type", "application/json")
|
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();
|
2814 2627 | #[allow(unused_mut)]
|
2815 2628 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2816 2629 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2817 2630 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2818 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2631 + | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
2819 2632 | let sender = sender.clone();
|
2820 2633 | 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> };
|
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> };
|
2822 2635 | sender.send(()).await.expect("receiver dropped early");
|
2823 2636 | result
|
2824 2637 | }
|
2825 2638 | })
|
2826 2639 | .build_unchecked();
|
2827 2640 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2828 2641 | .await
|
2829 2642 | .expect("unable to make an HTTP request");
|
2830 2643 | ::pretty_assertions::assert_eq!(
|
2831 2644 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2832 2645 | http_response.status()
|
2833 2646 | );
|
2834 2647 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2835 2648 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2836 2649 | http_response.headers(),
|
2837 2650 | expected_headers,
|
2838 2651 | ));
|
2839 2652 | use ::http_body_util::BodyExt;
|
2840 2653 | let body = http_response
|
2841 2654 | .into_body()
|
2842 2655 | .collect()
|
2843 2656 | .await
|
2844 2657 | .expect("unable to collect body")
|
2845 2658 | .to_bytes();
|
2846 2659 | ::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"))
|
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"))
|
2848 2661 | );
|
2849 2662 | }
|
2850 2663 | }
|
2664 + | }
|
2851 2665 |
|
2852 - | /// When a integer member does not fit within range bounds,
|
2853 - | /// the response should be a 400 ValidationException.
|
2854 - | /// Test ID: RestJsonMalformedRangeMaxIntegerOverride
|
2855 - | #[::tokio::test]
|
2856 - | #[::tracing_test::traced_test]
|
2857 - | async fn rest_json_malformed_range_max_integer_override_malformed_request() {
|
2858 - | {
|
2859 - | #[allow(unused_mut)]
|
2860 - | let mut http_request = ::http_1x::Request::builder()
|
2861 - | .uri("/MalformedRangeOverride")
|
2862 - | .method("POST")
|
2863 - | .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();
|
2873 - | #[allow(unused_mut)]
|
2874 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2875 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2876 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2877 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2878 - | let sender = sender.clone();
|
2879 - | 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> };
|
2881 - | sender.send(()).await.expect("receiver dropped early");
|
2882 - | result
|
2883 - | }
|
2884 - | })
|
2885 - | .build_unchecked();
|
2886 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2887 - | .await
|
2888 - | .expect("unable to make an HTTP request");
|
2889 - | ::pretty_assertions::assert_eq!(
|
2890 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2891 - | http_response.status()
|
2892 - | );
|
2893 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2894 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2895 - | http_response.headers(),
|
2896 - | expected_headers,
|
2897 - | ));
|
2898 - | use ::http_body_util::BodyExt;
|
2899 - | let body = http_response
|
2900 - | .into_body()
|
2901 - | .collect()
|
2902 - | .await
|
2903 - | .expect("unable to collect body")
|
2904 - | .to_bytes();
|
2905 - | ::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"))
|
2907 - | );
|
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>>
|
2671 + | }
|
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)
|
2714 + | .await
|
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 + | },
|
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))
|
2759 + | }
|
2908 2760 | }
|
2909 2761 | }
|
2762 + | }
|
2910 2763 |
|
2911 - | /// 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,
|
2912 2769 | /// the response should be a 400 ValidationException.
|
2913 - | /// Test ID: RestJsonMalformedRangeLongOverride_case0
|
2770 + | /// Test ID: RestJsonMalformedLengthQueryStringNoValue
|
2914 2771 | #[::tokio::test]
|
2915 2772 | #[::tracing_test::traced_test]
|
2916 - | async fn rest_json_malformed_range_long_override_case0_malformed_request() {
|
2773 + | async fn rest_json_malformed_length_query_string_no_value_malformed_request() {
|
2917 2774 | {
|
2918 2775 | #[allow(unused_mut)]
|
2919 2776 | let mut http_request = ::http_1x::Request::builder()
|
2920 - | .uri("/MalformedRangeOverride")
|
2777 + | .uri("/MalformedLengthQueryString")
|
2921 2778 | .method("POST")
|
2922 - | .header("content-type", "application/json")
|
2923 2779 | .body(::aws_smithy_http_server::body::boxed(
|
2924 2780 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2925 2781 | &::aws_smithy_protocol_test::decode_body_data(
|
2926 - | "{ \"long\" : 3 }".as_bytes(),
|
2782 + | "{}".as_bytes(),
|
2927 2783 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2928 2784 | ),
|
2929 2785 | )),
|
2930 2786 | ))
|
2931 2787 | .unwrap();
|
2788 + | *http_request.uri_mut() = "/MalformedLengthQueryString?string".parse().unwrap();
|
2932 2789 | #[allow(unused_mut)]
|
2933 2790 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2934 2791 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2935 2792 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2936 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2793 + | .malformed_length_query_string(move |input: crate::input::MalformedLengthQueryStringInput| {
|
2937 2794 | let sender = sender.clone();
|
2938 2795 | 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> };
|
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> };
|
2940 2797 | sender.send(()).await.expect("receiver dropped early");
|
2941 2798 | result
|
2942 2799 | }
|
2943 2800 | })
|
2944 2801 | .build_unchecked();
|
2945 2802 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
2946 2803 | .await
|
2947 2804 | .expect("unable to make an HTTP request");
|
2948 2805 | ::pretty_assertions::assert_eq!(
|
2949 2806 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
2950 2807 | http_response.status()
|
2951 2808 | );
|
2952 2809 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
2953 2810 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
2954 2811 | http_response.headers(),
|
2955 2812 | expected_headers,
|
2956 2813 | ));
|
2957 2814 | use ::http_body_util::BodyExt;
|
2958 2815 | let body = http_response
|
2959 2816 | .into_body()
|
2960 2817 | .collect()
|
2961 2818 | .await
|
2962 2819 | .expect("unable to collect body")
|
2963 2820 | .to_bytes();
|
2964 2821 | ::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"))
|
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"))
|
2966 2823 | );
|
2967 2824 | }
|
2968 2825 | }
|
2826 + | }
|
2969 2827 |
|
2970 - | /// When a long member does not fit within range bounds,
|
2828 + | ::pin_project_lite::pin_project! {
|
2829 + | /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
|
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>>
|
2833 + | }
|
2834 + | }
|
2835 + |
|
2836 + | impl std::future::Future for MalformedPatternInputFuture {
|
2837 + | type Output = Result<
|
2838 + | crate::input::MalformedPatternInput,
|
2839 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
2840 + | >;
|
2841 + |
|
2842 + | fn poll(
|
2843 + | self: std::pin::Pin<&mut Self>,
|
2844 + | cx: &mut std::task::Context<'_>,
|
2845 + | ) -> std::task::Poll<Self::Output> {
|
2846 + | let this = self.project();
|
2847 + | this.inner.as_mut().poll(cx)
|
2848 + | }
|
2849 + | }
|
2850 + |
|
2851 + | impl<B>
|
2852 + | ::aws_smithy_http_server::request::FromRequest<
|
2853 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2854 + | B,
|
2855 + | > for crate::input::MalformedPatternInput
|
2856 + | where
|
2857 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
2858 + | B: 'static,
|
2859 + |
|
2860 + | B::Data: Send,
|
2861 + | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
2862 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
2863 + | {
|
2864 + | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
2865 + | type Future = MalformedPatternInputFuture;
|
2866 + |
|
2867 + | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
2868 + | let fut = async move {
|
2869 + | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
2870 + | request.headers(),
|
2871 + | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
2872 + | ) {
|
2873 + | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
2874 + | }
|
2875 + | crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern_http_request(
|
2876 + | request,
|
2877 + | )
|
2878 + | .await
|
2879 + | };
|
2880 + | use ::futures_util::future::TryFutureExt;
|
2881 + | let fut = fut.map_err(
|
2882 + | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
2883 + | ::tracing::debug!(error = %e, "failed to deserialize request");
|
2884 + | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
2885 + | e,
|
2886 + | )
|
2887 + | },
|
2888 + | );
|
2889 + | MalformedPatternInputFuture {
|
2890 + | inner: Box::pin(fut),
|
2891 + | }
|
2892 + | }
|
2893 + | }
|
2894 + | impl
|
2895 + | ::aws_smithy_http_server::response::IntoResponse<
|
2896 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2897 + | > for crate::output::MalformedPatternOutput
|
2898 + | {
|
2899 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2900 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_response(
|
2901 + | self,
|
2902 + | ) {
|
2903 + | Ok(response) => response,
|
2904 + | Err(e) => {
|
2905 + | ::tracing::error!(error = %e, "failed to serialize response");
|
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))
|
2907 + | }
|
2908 + | }
|
2909 + | }
|
2910 + | }
|
2911 + | impl
|
2912 + | ::aws_smithy_http_server::response::IntoResponse<
|
2913 + | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
2914 + | > for crate::error::MalformedPatternError
|
2915 + | {
|
2916 + | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
2917 + | match crate::protocol_serde::shape_malformed_pattern::ser_malformed_pattern_http_error(
|
2918 + | &self,
|
2919 + | ) {
|
2920 + | Ok(mut response) => {
|
2921 + | response.extensions_mut().insert(
|
2922 + | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
2923 + | );
|
2924 + | response
|
2925 + | }
|
2926 + | Err(e) => {
|
2927 + | ::tracing::error!(error = %e, "failed to serialize response");
|
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))
|
2929 + | }
|
2930 + | }
|
2931 + | }
|
2932 + | }
|
2933 + |
|
2934 + | #[allow(unreachable_code, unused_variables)]
|
2935 + | #[cfg(test)]
|
2936 + | mod malformed_pattern_test {
|
2937 + |
|
2938 + | /// When a string member does not match the specified pattern,
|
2971 2939 | /// the response should be a 400 ValidationException.
|
2972 - | /// Test ID: RestJsonMalformedRangeLongOverride_case1
|
2940 + | /// Test ID: RestJsonMalformedPatternString_case0
|
2973 2941 | #[::tokio::test]
|
2974 2942 | #[::tracing_test::traced_test]
|
2975 - | async fn rest_json_malformed_range_long_override_case1_malformed_request() {
|
2943 + | async fn rest_json_malformed_pattern_string_case0_malformed_request() {
|
2976 2944 | {
|
2977 2945 | #[allow(unused_mut)]
|
2978 2946 | let mut http_request = ::http_1x::Request::builder()
|
2979 - | .uri("/MalformedRangeOverride")
|
2947 + | .uri("/MalformedPattern")
|
2980 2948 | .method("POST")
|
2981 2949 | .header("content-type", "application/json")
|
2982 2950 | .body(::aws_smithy_http_server::body::boxed(
|
2983 2951 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
2984 2952 | &::aws_smithy_protocol_test::decode_body_data(
|
2985 - | "{ \"long\" : 7 }".as_bytes(),
|
2953 + | "{ \"string\" : \"ABC\" }".as_bytes(),
|
2986 2954 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
2987 2955 | ),
|
2988 2956 | )),
|
2989 2957 | ))
|
2990 2958 | .unwrap();
|
2991 2959 | #[allow(unused_mut)]
|
2992 2960 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
2993 2961 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
2994 2962 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
2995 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
2963 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
2996 2964 | let sender = sender.clone();
|
2997 2965 | 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> };
|
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> };
|
2999 2967 | sender.send(()).await.expect("receiver dropped early");
|
3000 2968 | result
|
3001 2969 | }
|
3002 2970 | })
|
3003 2971 | .build_unchecked();
|
3004 2972 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3005 2973 | .await
|
3006 2974 | .expect("unable to make an HTTP request");
|
3007 2975 | ::pretty_assertions::assert_eq!(
|
3008 2976 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3009 2977 | http_response.status()
|
3010 2978 | );
|
3011 2979 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3012 2980 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3013 2981 | http_response.headers(),
|
3014 2982 | expected_headers,
|
3015 2983 | ));
|
3016 2984 | use ::http_body_util::BodyExt;
|
3017 2985 | let body = http_response
|
3018 2986 | .into_body()
|
3019 2987 | .collect()
|
3020 2988 | .await
|
3021 2989 | .expect("unable to collect body")
|
3022 2990 | .to_bytes();
|
3023 2991 | ::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"))
|
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"))
|
3025 2993 | );
|
3026 2994 | }
|
3027 2995 | }
|
3028 2996 |
|
3029 - | /// When a long member does not fit within range bounds,
|
2997 + | /// When a string member does not match the specified pattern,
|
3030 2998 | /// the response should be a 400 ValidationException.
|
3031 - | /// Test ID: RestJsonMalformedRangeMinLongOverride
|
2999 + | /// Test ID: RestJsonMalformedPatternString_case1
|
3032 3000 | #[::tokio::test]
|
3033 3001 | #[::tracing_test::traced_test]
|
3034 - | async fn rest_json_malformed_range_min_long_override_malformed_request() {
|
3002 + | async fn rest_json_malformed_pattern_string_case1_malformed_request() {
|
3035 3003 | {
|
3036 3004 | #[allow(unused_mut)]
|
3037 3005 | let mut http_request = ::http_1x::Request::builder()
|
3038 - | .uri("/MalformedRangeOverride")
|
3006 + | .uri("/MalformedPattern")
|
3039 3007 | .method("POST")
|
3040 3008 | .header("content-type", "application/json")
|
3041 3009 | .body(::aws_smithy_http_server::body::boxed(
|
3042 3010 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3043 3011 | &::aws_smithy_protocol_test::decode_body_data(
|
3044 - | "{ \"minLong\" : 3 }".as_bytes(),
|
3012 + | "{ \"string\" : \"xyz\" }".as_bytes(),
|
3045 3013 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3046 3014 | ),
|
3047 3015 | )),
|
3048 3016 | ))
|
3049 3017 | .unwrap();
|
3050 3018 | #[allow(unused_mut)]
|
3051 3019 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3052 3020 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3053 3021 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3054 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
3022 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3055 3023 | let sender = sender.clone();
|
3056 3024 | 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> };
|
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> };
|
3058 3026 | sender.send(()).await.expect("receiver dropped early");
|
3059 3027 | result
|
3060 3028 | }
|
3061 3029 | })
|
3062 3030 | .build_unchecked();
|
3063 3031 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3064 3032 | .await
|
3065 3033 | .expect("unable to make an HTTP request");
|
3066 3034 | ::pretty_assertions::assert_eq!(
|
3067 3035 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3068 3036 | http_response.status()
|
3069 3037 | );
|
3070 3038 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3071 3039 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3072 3040 | http_response.headers(),
|
3073 3041 | expected_headers,
|
3074 3042 | ));
|
3075 3043 | use ::http_body_util::BodyExt;
|
3076 3044 | let body = http_response
|
3077 3045 | .into_body()
|
3078 3046 | .collect()
|
3079 3047 | .await
|
3080 3048 | .expect("unable to collect body")
|
3081 3049 | .to_bytes();
|
3082 3050 | ::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"))
|
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"))
|
3084 3052 | );
|
3085 3053 | }
|
3086 3054 | }
|
3087 3055 |
|
3088 - | /// When a long member does not fit within range bounds,
|
3089 - | /// the response should be a 400 ValidationException.
|
3090 - | /// Test ID: RestJsonMalformedRangeMaxLongOverride
|
3056 + | /// When the specified pattern is susceptible to ReDOS, the service will not
|
3057 + | /// hang indefinitely while evaluating the pattern
|
3058 + | /// Test ID: RestJsonMalformedPatternReDOSString
|
3091 3059 | #[::tokio::test]
|
3092 3060 | #[::tracing_test::traced_test]
|
3093 - | async fn rest_json_malformed_range_max_long_override_malformed_request() {
|
3061 + | #[should_panic]
|
3062 + | async fn rest_json_malformed_pattern_re_dos_string_malformed_request() {
|
3094 3063 | {
|
3095 3064 | #[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();
|
3065 + | let mut http_request = ::http_1x::Request::builder()
|
3066 + | .uri("/MalformedPattern")
|
3067 + | .method("POST")
|
3068 + | .header("content-type", "application/json")
|
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();
|
3109 3074 | #[allow(unused_mut)]
|
3110 3075 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3111 3076 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3112 3077 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3113 - | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
3078 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3114 3079 | let sender = sender.clone();
|
3115 3080 | 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> };
|
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> };
|
3117 3082 | sender.send(()).await.expect("receiver dropped early");
|
3118 3083 | result
|
3119 3084 | }
|
3120 3085 | })
|
3121 3086 | .build_unchecked();
|
3122 3087 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3123 3088 | .await
|
3124 3089 | .expect("unable to make an HTTP request");
|
3125 3090 | ::pretty_assertions::assert_eq!(
|
3126 3091 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3127 3092 | http_response.status()
|
3128 3093 | );
|
3129 3094 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3130 3095 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3131 3096 | http_response.headers(),
|
3132 3097 | expected_headers,
|
3133 3098 | ));
|
3134 3099 | use ::http_body_util::BodyExt;
|
3135 3100 | let body = http_response
|
3136 3101 | .into_body()
|
3137 3102 | .collect()
|
3138 3103 | .await
|
3139 3104 | .expect("unable to collect body")
|
3140 3105 | .to_bytes();
|
3141 3106 | ::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"))
|
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"))
|
3143 3108 | );
|
3144 3109 | }
|
3145 3110 | }
|
3146 - | }
|
3147 - |
|
3148 - | ::pin_project_lite::pin_project! {
|
3149 - | /// 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>>
|
3153 - | }
|
3154 - | }
|
3155 - |
|
3156 - | impl std::future::Future for MalformedRangeInputFuture {
|
3157 - | type Output = Result<
|
3158 - | crate::input::MalformedRangeInput,
|
3159 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
3160 - | >;
|
3161 - |
|
3162 - | fn poll(
|
3163 - | self: std::pin::Pin<&mut Self>,
|
3164 - | cx: &mut std::task::Context<'_>,
|
3165 - | ) -> std::task::Poll<Self::Output> {
|
3166 - | let this = self.project();
|
3167 - | this.inner.as_mut().poll(cx)
|
3168 - | }
|
3169 - | }
|
3170 - |
|
3171 - | impl<B>
|
3172 - | ::aws_smithy_http_server::request::FromRequest<
|
3173 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3174 - | B,
|
3175 - | > for crate::input::MalformedRangeInput
|
3176 - | where
|
3177 - | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
3178 - | B: 'static,
|
3179 - |
|
3180 - | B::Data: Send,
|
3181 - | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
3182 - | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
3183 - | {
|
3184 - | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
3185 - | type Future = MalformedRangeInputFuture;
|
3186 - |
|
3187 - | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
3188 - | let fut = async move {
|
3189 - | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
3190 - | request.headers(),
|
3191 - | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
3192 - | ) {
|
3193 - | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
3194 - | }
|
3195 - | crate::protocol_serde::shape_malformed_range::de_malformed_range_http_request(request)
|
3196 - | .await
|
3197 - | };
|
3198 - | use ::futures_util::future::TryFutureExt;
|
3199 - | let fut = fut.map_err(
|
3200 - | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
3201 - | ::tracing::debug!(error = %e, "failed to deserialize request");
|
3202 - | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
3203 - | e,
|
3204 - | )
|
3205 - | },
|
3206 - | );
|
3207 - | MalformedRangeInputFuture {
|
3208 - | inner: Box::pin(fut),
|
3209 - | }
|
3210 - | }
|
3211 - | }
|
3212 - | impl
|
3213 - | ::aws_smithy_http_server::response::IntoResponse<
|
3214 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3215 - | > for crate::output::MalformedRangeOutput
|
3216 - | {
|
3217 - | 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 - | {
|
3220 - | Ok(response) => response,
|
3221 - | Err(e) => {
|
3222 - | ::tracing::error!(error = %e, "failed to serialize response");
|
3223 - | ::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 - | }
|
3225 - | }
|
3226 - | }
|
3227 - | }
|
3228 - | impl
|
3229 - | ::aws_smithy_http_server::response::IntoResponse<
|
3230 - | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
3231 - | > for crate::error::MalformedRangeError
|
3232 - | {
|
3233 - | fn into_response(self) -> ::aws_smithy_http_server::response::Response {
|
3234 - | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_error(&self) {
|
3235 - | Ok(mut response) => {
|
3236 - | response.extensions_mut().insert(
|
3237 - | ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),
|
3238 - | );
|
3239 - | response
|
3240 - | }
|
3241 - | Err(e) => {
|
3242 - | ::tracing::error!(error = %e, "failed to serialize response");
|
3243 - | ::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 - | }
|
3245 - | }
|
3246 - | }
|
3247 - | }
|
3248 - |
|
3249 - | #[allow(unreachable_code, unused_variables)]
|
3250 - | #[cfg(test)]
|
3251 - | mod malformed_range_test {
|
3252 3111 |
|
3253 - | /// When a byte member does not fit within range bounds,
|
3254 - | /// the response should be a 400 ValidationException.
|
3255 - | /// Test ID: RestJsonMalformedRangeByte_case0
|
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
|
3256 3115 | #[::tokio::test]
|
3257 3116 | #[::tracing_test::traced_test]
|
3258 - | async fn rest_json_malformed_range_byte_case0_malformed_request() {
|
3117 + | async fn rest_json_malformed_pattern_re_dos_string_hotfixed_malformed_request() {
|
3259 3118 | {
|
3260 3119 | #[allow(unused_mut)]
|
3261 - | let mut http_request = ::http_1x::Request::builder()
|
3262 - | .uri("/MalformedRange")
|
3263 - | .method("POST")
|
3264 - | .header("content-type", "application/json")
|
3265 - | .body(::aws_smithy_http_server::body::boxed(
|
3266 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3267 - | &::aws_smithy_protocol_test::decode_body_data(
|
3268 - | "{ \"byte\" : 1 }".as_bytes(),
|
3269 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3270 - | ),
|
3271 - | )),
|
3272 - | ))
|
3273 - | .unwrap();
|
3120 + | let mut http_request = ::http_1x::Request::builder()
|
3121 + | .uri("/MalformedPattern")
|
3122 + | .method("POST")
|
3123 + | .header("content-type", "application/json")
|
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();
|
3274 3129 | #[allow(unused_mut)]
|
3275 3130 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3276 3131 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3277 3132 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3278 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3133 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3279 3134 | let sender = sender.clone();
|
3280 3135 | 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> };
|
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> };
|
3282 3137 | sender.send(()).await.expect("receiver dropped early");
|
3283 3138 | result
|
3284 3139 | }
|
3285 3140 | })
|
3286 3141 | .build_unchecked();
|
3287 3142 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3288 3143 | .await
|
3289 3144 | .expect("unable to make an HTTP request");
|
3290 3145 | ::pretty_assertions::assert_eq!(
|
3291 3146 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3292 3147 | http_response.status()
|
3293 3148 | );
|
3294 3149 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3295 3150 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3296 3151 | http_response.headers(),
|
3297 3152 | expected_headers,
|
3298 3153 | ));
|
3299 3154 | use ::http_body_util::BodyExt;
|
3300 3155 | let body = http_response
|
3301 3156 | .into_body()
|
3302 3157 | .collect()
|
3303 3158 | .await
|
3304 3159 | .expect("unable to collect body")
|
3305 3160 | .to_bytes();
|
3306 3161 | ::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"))
|
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"))
|
3308 3163 | );
|
3309 3164 | }
|
3310 3165 | }
|
3311 3166 |
|
3312 - | /// When a byte member does not fit within range bounds,
|
3167 + | /// When a list member value does not match the specified pattern,
|
3313 3168 | /// the response should be a 400 ValidationException.
|
3314 - | /// Test ID: RestJsonMalformedRangeByte_case1
|
3169 + | /// Test ID: RestJsonMalformedPatternList_case0
|
3315 3170 | #[::tokio::test]
|
3316 3171 | #[::tracing_test::traced_test]
|
3317 - | async fn rest_json_malformed_range_byte_case1_malformed_request() {
|
3172 + | async fn rest_json_malformed_pattern_list_case0_malformed_request() {
|
3318 3173 | {
|
3319 3174 | #[allow(unused_mut)]
|
3320 3175 | let mut http_request = ::http_1x::Request::builder()
|
3321 - | .uri("/MalformedRange")
|
3176 + | .uri("/MalformedPattern")
|
3322 3177 | .method("POST")
|
3323 3178 | .header("content-type", "application/json")
|
3324 3179 | .body(::aws_smithy_http_server::body::boxed(
|
3325 3180 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3326 3181 | &::aws_smithy_protocol_test::decode_body_data(
|
3327 - | "{ \"byte\" : 9 }".as_bytes(),
|
3182 + | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
3328 3183 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3329 3184 | ),
|
3330 3185 | )),
|
3331 3186 | ))
|
3332 3187 | .unwrap();
|
3333 3188 | #[allow(unused_mut)]
|
3334 3189 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3335 3190 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3336 3191 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3337 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3192 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3338 3193 | let sender = sender.clone();
|
3339 3194 | 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> };
|
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> };
|
3341 3196 | sender.send(()).await.expect("receiver dropped early");
|
3342 3197 | result
|
3343 3198 | }
|
3344 3199 | })
|
3345 3200 | .build_unchecked();
|
3346 3201 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3347 3202 | .await
|
3348 3203 | .expect("unable to make an HTTP request");
|
3349 3204 | ::pretty_assertions::assert_eq!(
|
3350 3205 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3351 3206 | http_response.status()
|
3352 3207 | );
|
3353 3208 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3354 3209 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3355 3210 | http_response.headers(),
|
3356 3211 | expected_headers,
|
3357 3212 | ));
|
3358 3213 | use ::http_body_util::BodyExt;
|
3359 3214 | let body = http_response
|
3360 3215 | .into_body()
|
3361 3216 | .collect()
|
3362 3217 | .await
|
3363 3218 | .expect("unable to collect body")
|
3364 3219 | .to_bytes();
|
3365 3220 | ::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"))
|
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"))
|
3367 3222 | );
|
3368 3223 | }
|
3369 3224 | }
|
3370 3225 |
|
3371 - | /// When a byte member does not fit within range bounds,
|
3226 + | /// When a list member value does not match the specified pattern,
|
3372 3227 | /// the response should be a 400 ValidationException.
|
3373 - | /// Test ID: RestJsonMalformedRangeMinByte
|
3228 + | /// Test ID: RestJsonMalformedPatternList_case1
|
3374 3229 | #[::tokio::test]
|
3375 3230 | #[::tracing_test::traced_test]
|
3376 - | async fn rest_json_malformed_range_min_byte_malformed_request() {
|
3231 + | async fn rest_json_malformed_pattern_list_case1_malformed_request() {
|
3377 3232 | {
|
3378 3233 | #[allow(unused_mut)]
|
3379 3234 | let mut http_request = ::http_1x::Request::builder()
|
3380 - | .uri("/MalformedRange")
|
3235 + | .uri("/MalformedPattern")
|
3381 3236 | .method("POST")
|
3382 3237 | .header("content-type", "application/json")
|
3383 3238 | .body(::aws_smithy_http_server::body::boxed(
|
3384 3239 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3385 3240 | &::aws_smithy_protocol_test::decode_body_data(
|
3386 - | "{ \"minByte\" : 1 }".as_bytes(),
|
3241 + | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
3387 3242 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3388 3243 | ),
|
3389 3244 | )),
|
3390 3245 | ))
|
3391 3246 | .unwrap();
|
3392 3247 | #[allow(unused_mut)]
|
3393 3248 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3394 3249 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3395 3250 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3396 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3251 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3397 3252 | let sender = sender.clone();
|
3398 3253 | 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> };
|
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> };
|
3400 3255 | sender.send(()).await.expect("receiver dropped early");
|
3401 3256 | result
|
3402 3257 | }
|
3403 3258 | })
|
3404 3259 | .build_unchecked();
|
3405 3260 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3406 3261 | .await
|
3407 3262 | .expect("unable to make an HTTP request");
|
3408 3263 | ::pretty_assertions::assert_eq!(
|
3409 3264 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3410 3265 | http_response.status()
|
3411 3266 | );
|
3412 3267 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3413 3268 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3414 3269 | http_response.headers(),
|
3415 3270 | expected_headers,
|
3416 3271 | ));
|
3417 3272 | use ::http_body_util::BodyExt;
|
3418 3273 | let body = http_response
|
3419 3274 | .into_body()
|
3420 3275 | .collect()
|
3421 3276 | .await
|
3422 3277 | .expect("unable to collect body")
|
3423 3278 | .to_bytes();
|
3424 3279 | ::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"))
|
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"))
|
3426 3281 | );
|
3427 3282 | }
|
3428 3283 | }
|
3429 3284 |
|
3430 - | /// When a byte member does not fit within range bounds,
|
3285 + | /// When a map member's key does not match the specified pattern,
|
3431 3286 | /// the response should be a 400 ValidationException.
|
3432 - | /// Test ID: RestJsonMalformedRangeMaxByte
|
3287 + | /// Test ID: RestJsonMalformedPatternMapKey_case0
|
3433 3288 | #[::tokio::test]
|
3434 3289 | #[::tracing_test::traced_test]
|
3435 - | async fn rest_json_malformed_range_max_byte_malformed_request() {
|
3290 + | async fn rest_json_malformed_pattern_map_key_case0_malformed_request() {
|
3436 3291 | {
|
3437 3292 | #[allow(unused_mut)]
|
3438 3293 | let mut http_request = ::http_1x::Request::builder()
|
3439 - | .uri("/MalformedRange")
|
3294 + | .uri("/MalformedPattern")
|
3440 3295 | .method("POST")
|
3441 3296 | .header("content-type", "application/json")
|
3442 3297 | .body(::aws_smithy_http_server::body::boxed(
|
3443 3298 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3444 3299 | &::aws_smithy_protocol_test::decode_body_data(
|
3445 - | "{ \"maxByte\" : 9 }".as_bytes(),
|
3300 + | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
3446 3301 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3447 3302 | ),
|
3448 3303 | )),
|
3449 3304 | ))
|
3450 3305 | .unwrap();
|
3451 3306 | #[allow(unused_mut)]
|
3452 3307 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3453 3308 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3454 3309 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3455 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3310 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3456 3311 | let sender = sender.clone();
|
3457 3312 | 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> };
|
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> };
|
3459 3314 | sender.send(()).await.expect("receiver dropped early");
|
3460 3315 | result
|
3461 3316 | }
|
3462 3317 | })
|
3463 3318 | .build_unchecked();
|
3464 3319 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3465 3320 | .await
|
3466 3321 | .expect("unable to make an HTTP request");
|
3467 3322 | ::pretty_assertions::assert_eq!(
|
3468 3323 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3469 3324 | http_response.status()
|
3470 3325 | );
|
3471 3326 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3472 3327 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3473 3328 | http_response.headers(),
|
3474 3329 | expected_headers,
|
3475 3330 | ));
|
3476 3331 | use ::http_body_util::BodyExt;
|
3477 3332 | let body = http_response
|
3478 3333 | .into_body()
|
3479 3334 | .collect()
|
3480 3335 | .await
|
3481 3336 | .expect("unable to collect body")
|
3482 3337 | .to_bytes();
|
3483 3338 | ::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"))
|
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"))
|
3485 3340 | );
|
3486 3341 | }
|
3487 3342 | }
|
3488 3343 |
|
3489 - | /// When a float member does not fit within range bounds,
|
3344 + | /// When a map member's key does not match the specified pattern,
|
3490 3345 | /// the response should be a 400 ValidationException.
|
3491 - | /// Test ID: RestJsonMalformedRangeFloat_case0
|
3346 + | /// Test ID: RestJsonMalformedPatternMapKey_case1
|
3492 3347 | #[::tokio::test]
|
3493 3348 | #[::tracing_test::traced_test]
|
3494 - | #[should_panic]
|
3495 - | async fn rest_json_malformed_range_float_case0_malformed_request() {
|
3349 + | async fn rest_json_malformed_pattern_map_key_case1_malformed_request() {
|
3496 3350 | {
|
3497 3351 | #[allow(unused_mut)]
|
3498 3352 | let mut http_request = ::http_1x::Request::builder()
|
3499 - | .uri("/MalformedRange")
|
3353 + | .uri("/MalformedPattern")
|
3500 3354 | .method("POST")
|
3501 3355 | .header("content-type", "application/json")
|
3502 3356 | .body(::aws_smithy_http_server::body::boxed(
|
3503 3357 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3504 3358 | &::aws_smithy_protocol_test::decode_body_data(
|
3505 - | "{ \"float\" : 2.1 }".as_bytes(),
|
3359 + | "{ \"map\" : { \"xyz\" : \"abc\" } }".as_bytes(),
|
3506 3360 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3507 3361 | ),
|
3508 3362 | )),
|
3509 3363 | ))
|
3510 3364 | .unwrap();
|
3511 3365 | #[allow(unused_mut)]
|
3512 3366 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3513 3367 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3514 3368 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3515 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3369 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3516 3370 | let sender = sender.clone();
|
3517 3371 | 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> };
|
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> };
|
3519 3373 | sender.send(()).await.expect("receiver dropped early");
|
3520 3374 | result
|
3521 3375 | }
|
3522 3376 | })
|
3523 3377 | .build_unchecked();
|
3524 3378 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3525 3379 | .await
|
3526 3380 | .expect("unable to make an HTTP request");
|
3527 3381 | ::pretty_assertions::assert_eq!(
|
3528 3382 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3529 3383 | http_response.status()
|
3530 3384 | );
|
3531 3385 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3532 3386 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3533 3387 | http_response.headers(),
|
3534 3388 | expected_headers,
|
3535 3389 | ));
|
3536 3390 | use ::http_body_util::BodyExt;
|
3537 3391 | let body = http_response
|
3538 3392 | .into_body()
|
3539 3393 | .collect()
|
3540 3394 | .await
|
3541 3395 | .expect("unable to collect body")
|
3542 3396 | .to_bytes();
|
3543 3397 | ::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"))
|
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"))
|
3545 3399 | );
|
3546 3400 | }
|
3547 3401 | }
|
3548 3402 |
|
3549 - | /// When a float member does not fit within range bounds,
|
3403 + | /// When a map member's value does not match the specified pattern,
|
3550 3404 | /// the response should be a 400 ValidationException.
|
3551 - | /// Test ID: RestJsonMalformedRangeFloat_case1
|
3405 + | /// Test ID: RestJsonMalformedPatternMapValue_case0
|
3552 3406 | #[::tokio::test]
|
3553 3407 | #[::tracing_test::traced_test]
|
3554 - | #[should_panic]
|
3555 - | async fn rest_json_malformed_range_float_case1_malformed_request() {
|
3408 + | async fn rest_json_malformed_pattern_map_value_case0_malformed_request() {
|
3556 3409 | {
|
3557 3410 | #[allow(unused_mut)]
|
3558 3411 | let mut http_request = ::http_1x::Request::builder()
|
3559 - | .uri("/MalformedRange")
|
3412 + | .uri("/MalformedPattern")
|
3560 3413 | .method("POST")
|
3561 3414 | .header("content-type", "application/json")
|
3562 3415 | .body(::aws_smithy_http_server::body::boxed(
|
3563 3416 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3564 3417 | &::aws_smithy_protocol_test::decode_body_data(
|
3565 - | "{ \"float\" : 8.9 }".as_bytes(),
|
3418 + | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
3566 3419 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3567 3420 | ),
|
3568 3421 | )),
|
3569 3422 | ))
|
3570 3423 | .unwrap();
|
3571 3424 | #[allow(unused_mut)]
|
3572 3425 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3573 3426 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3574 3427 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3575 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3428 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3576 3429 | let sender = sender.clone();
|
3577 3430 | 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> };
|
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> };
|
3579 3432 | sender.send(()).await.expect("receiver dropped early");
|
3580 3433 | result
|
3581 3434 | }
|
3582 3435 | })
|
3583 3436 | .build_unchecked();
|
3584 3437 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3585 3438 | .await
|
3586 3439 | .expect("unable to make an HTTP request");
|
3587 3440 | ::pretty_assertions::assert_eq!(
|
3588 3441 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3589 3442 | http_response.status()
|
3590 3443 | );
|
3591 3444 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3592 3445 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3593 3446 | http_response.headers(),
|
3594 3447 | expected_headers,
|
3595 3448 | ));
|
3596 3449 | use ::http_body_util::BodyExt;
|
3597 3450 | let body = http_response
|
3598 3451 | .into_body()
|
3599 3452 | .collect()
|
3600 3453 | .await
|
3601 3454 | .expect("unable to collect body")
|
3602 3455 | .to_bytes();
|
3603 3456 | ::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"))
|
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"))
|
3605 3458 | );
|
3606 3459 | }
|
3607 3460 | }
|
3608 3461 |
|
3609 - | /// When a float member does not fit within range bounds,
|
3462 + | /// When a map member's value does not match the specified pattern,
|
3610 3463 | /// the response should be a 400 ValidationException.
|
3611 - | /// Test ID: RestJsonMalformedRangeMinFloat
|
3464 + | /// Test ID: RestJsonMalformedPatternMapValue_case1
|
3612 3465 | #[::tokio::test]
|
3613 3466 | #[::tracing_test::traced_test]
|
3614 - | #[should_panic]
|
3615 - | async fn rest_json_malformed_range_min_float_malformed_request() {
|
3467 + | async fn rest_json_malformed_pattern_map_value_case1_malformed_request() {
|
3616 3468 | {
|
3617 3469 | #[allow(unused_mut)]
|
3618 3470 | let mut http_request = ::http_1x::Request::builder()
|
3619 - | .uri("/MalformedRange")
|
3471 + | .uri("/MalformedPattern")
|
3620 3472 | .method("POST")
|
3621 3473 | .header("content-type", "application/json")
|
3622 3474 | .body(::aws_smithy_http_server::body::boxed(
|
3623 3475 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3624 3476 | &::aws_smithy_protocol_test::decode_body_data(
|
3625 - | "{ \"minFloat\" : 2.1 }".as_bytes(),
|
3477 + | "{ \"map\" : { \"abc\": \"xyz\" } }".as_bytes(),
|
3626 3478 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3627 3479 | ),
|
3628 3480 | )),
|
3629 3481 | ))
|
3630 3482 | .unwrap();
|
3631 3483 | #[allow(unused_mut)]
|
3632 3484 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3633 3485 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3634 3486 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3635 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3487 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3636 3488 | let sender = sender.clone();
|
3637 3489 | 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> };
|
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> };
|
3639 3491 | sender.send(()).await.expect("receiver dropped early");
|
3640 3492 | result
|
3641 3493 | }
|
3642 3494 | })
|
3643 3495 | .build_unchecked();
|
3644 3496 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3645 3497 | .await
|
3646 3498 | .expect("unable to make an HTTP request");
|
3647 3499 | ::pretty_assertions::assert_eq!(
|
3648 3500 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3649 3501 | http_response.status()
|
3650 3502 | );
|
3651 3503 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3652 3504 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3653 3505 | http_response.headers(),
|
3654 3506 | expected_headers,
|
3655 3507 | ));
|
3656 3508 | use ::http_body_util::BodyExt;
|
3657 3509 | let body = http_response
|
3658 3510 | .into_body()
|
3659 3511 | .collect()
|
3660 3512 | .await
|
3661 3513 | .expect("unable to collect body")
|
3662 3514 | .to_bytes();
|
3663 3515 | ::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"))
|
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"))
|
3665 3517 | );
|
3666 3518 | }
|
3667 3519 | }
|
3668 3520 |
|
3669 - | /// When a float member does not fit within range bounds,
|
3521 + | /// When a union member's value does not match the specified pattern,
|
3670 3522 | /// the response should be a 400 ValidationException.
|
3671 - | /// Test ID: RestJsonMalformedRangeMaxFloat
|
3523 + | /// Test ID: RestJsonMalformedPatternUnion_case0
|
3672 3524 | #[::tokio::test]
|
3673 3525 | #[::tracing_test::traced_test]
|
3674 - | #[should_panic]
|
3675 - | async fn rest_json_malformed_range_max_float_malformed_request() {
|
3526 + | async fn rest_json_malformed_pattern_union_case0_malformed_request() {
|
3676 3527 | {
|
3677 3528 | #[allow(unused_mut)]
|
3678 3529 | let mut http_request = ::http_1x::Request::builder()
|
3679 - | .uri("/MalformedRange")
|
3530 + | .uri("/MalformedPattern")
|
3680 3531 | .method("POST")
|
3681 3532 | .header("content-type", "application/json")
|
3682 3533 | .body(::aws_smithy_http_server::body::boxed(
|
3683 3534 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3684 3535 | &::aws_smithy_protocol_test::decode_body_data(
|
3685 - | "{ \"maxFloat\" : 8.9 }".as_bytes(),
|
3536 + | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
3686 3537 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3687 3538 | ),
|
3688 3539 | )),
|
3689 3540 | ))
|
3690 3541 | .unwrap();
|
3691 3542 | #[allow(unused_mut)]
|
3692 3543 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3693 3544 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3694 3545 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3695 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3546 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3696 3547 | let sender = sender.clone();
|
3697 3548 | 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> };
|
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> };
|
3699 3550 | sender.send(()).await.expect("receiver dropped early");
|
3700 3551 | result
|
3701 3552 | }
|
3702 3553 | })
|
3703 3554 | .build_unchecked();
|
3704 3555 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3705 3556 | .await
|
3706 3557 | .expect("unable to make an HTTP request");
|
3707 3558 | ::pretty_assertions::assert_eq!(
|
3708 3559 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3709 3560 | http_response.status()
|
3710 3561 | );
|
3711 3562 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3712 3563 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3713 3564 | http_response.headers(),
|
3714 3565 | expected_headers,
|
3715 3566 | ));
|
3716 3567 | use ::http_body_util::BodyExt;
|
3717 3568 | let body = http_response
|
3718 3569 | .into_body()
|
3719 3570 | .collect()
|
3720 3571 | .await
|
3721 3572 | .expect("unable to collect body")
|
3722 3573 | .to_bytes();
|
3723 3574 | ::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"))
|
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"))
|
3725 3576 | );
|
3726 3577 | }
|
3727 3578 | }
|
3728 3579 |
|
3729 - | /// When a short member does not fit within range bounds,
|
3580 + | /// When a union member's value does not match the specified pattern,
|
3730 3581 | /// the response should be a 400 ValidationException.
|
3731 - | /// Test ID: RestJsonMalformedRangeShort_case0
|
3582 + | /// Test ID: RestJsonMalformedPatternUnion_case1
|
3732 3583 | #[::tokio::test]
|
3733 3584 | #[::tracing_test::traced_test]
|
3734 - | async fn rest_json_malformed_range_short_case0_malformed_request() {
|
3585 + | async fn rest_json_malformed_pattern_union_case1_malformed_request() {
|
3735 3586 | {
|
3736 3587 | #[allow(unused_mut)]
|
3737 3588 | let mut http_request = ::http_1x::Request::builder()
|
3738 - | .uri("/MalformedRange")
|
3589 + | .uri("/MalformedPattern")
|
3739 3590 | .method("POST")
|
3740 3591 | .header("content-type", "application/json")
|
3741 3592 | .body(::aws_smithy_http_server::body::boxed(
|
3742 3593 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3743 3594 | &::aws_smithy_protocol_test::decode_body_data(
|
3744 - | "{ \"short\" : 1 }".as_bytes(),
|
3595 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
3745 3596 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3746 3597 | ),
|
3747 3598 | )),
|
3748 3599 | ))
|
3749 3600 | .unwrap();
|
3750 3601 | #[allow(unused_mut)]
|
3751 3602 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3752 3603 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3753 3604 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3754 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3605 + | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
3755 3606 | let sender = sender.clone();
|
3756 3607 | 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> };
|
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> };
|
3758 3609 | sender.send(()).await.expect("receiver dropped early");
|
3759 3610 | result
|
3760 3611 | }
|
3761 3612 | })
|
3762 3613 | .build_unchecked();
|
3763 3614 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3764 3615 | .await
|
3765 3616 | .expect("unable to make an HTTP request");
|
3766 3617 | ::pretty_assertions::assert_eq!(
|
3767 3618 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3768 3619 | http_response.status()
|
3769 3620 | );
|
3770 3621 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3771 3622 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3772 3623 | http_response.headers(),
|
3773 3624 | expected_headers,
|
3774 3625 | ));
|
3775 3626 | use ::http_body_util::BodyExt;
|
3776 3627 | let body = http_response
|
3777 3628 | .into_body()
|
3778 3629 | .collect()
|
3779 3630 | .await
|
3780 3631 | .expect("unable to collect body")
|
3781 3632 | .to_bytes();
|
3782 3633 | ::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"))
|
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"))
|
3784 3635 | );
|
3785 3636 | }
|
3786 3637 | }
|
3638 + | }
|
3787 3639 |
|
3788 - | /// When a short 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,
|
3789 3743 | /// the response should be a 400 ValidationException.
|
3790 - | /// Test ID: RestJsonMalformedRangeShort_case1
|
3744 + | /// Test ID: RestJsonMalformedPatternStringOverride_case0
|
3791 3745 | #[::tokio::test]
|
3792 3746 | #[::tracing_test::traced_test]
|
3793 - | async fn rest_json_malformed_range_short_case1_malformed_request() {
|
3747 + | async fn rest_json_malformed_pattern_string_override_case0_malformed_request() {
|
3794 3748 | {
|
3795 3749 | #[allow(unused_mut)]
|
3796 3750 | let mut http_request = ::http_1x::Request::builder()
|
3797 - | .uri("/MalformedRange")
|
3751 + | .uri("/MalformedPatternOverride")
|
3798 3752 | .method("POST")
|
3799 3753 | .header("content-type", "application/json")
|
3800 3754 | .body(::aws_smithy_http_server::body::boxed(
|
3801 3755 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3802 3756 | &::aws_smithy_protocol_test::decode_body_data(
|
3803 - | "{ \"short\" : 9 }".as_bytes(),
|
3757 + | "{ \"string\" : \"abc\" }".as_bytes(),
|
3804 3758 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3805 3759 | ),
|
3806 3760 | )),
|
3807 3761 | ))
|
3808 3762 | .unwrap();
|
3809 3763 | #[allow(unused_mut)]
|
3810 3764 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3811 3765 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3812 3766 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3813 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3767 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3814 3768 | let sender = sender.clone();
|
3815 3769 | 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> };
|
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> };
|
3817 3771 | sender.send(()).await.expect("receiver dropped early");
|
3818 3772 | result
|
3819 3773 | }
|
3820 3774 | })
|
3821 3775 | .build_unchecked();
|
3822 3776 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3823 3777 | .await
|
3824 3778 | .expect("unable to make an HTTP request");
|
3825 3779 | ::pretty_assertions::assert_eq!(
|
3826 3780 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3827 3781 | http_response.status()
|
3828 3782 | );
|
3829 3783 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3830 3784 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3831 3785 | http_response.headers(),
|
3832 3786 | expected_headers,
|
3833 3787 | ));
|
3834 3788 | use ::http_body_util::BodyExt;
|
3835 3789 | let body = http_response
|
3836 3790 | .into_body()
|
3837 3791 | .collect()
|
3838 3792 | .await
|
3839 3793 | .expect("unable to collect body")
|
3840 3794 | .to_bytes();
|
3841 3795 | ::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"))
|
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"))
|
3843 3797 | );
|
3844 3798 | }
|
3845 3799 | }
|
3846 3800 |
|
3847 - | /// When a short member does not fit within range bounds,
|
3801 + | /// When a string member does not match the specified pattern,
|
3848 3802 | /// the response should be a 400 ValidationException.
|
3849 - | /// Test ID: RestJsonMalformedRangeMinShort
|
3803 + | /// Test ID: RestJsonMalformedPatternStringOverride_case1
|
3850 3804 | #[::tokio::test]
|
3851 3805 | #[::tracing_test::traced_test]
|
3852 - | async fn rest_json_malformed_range_min_short_malformed_request() {
|
3806 + | async fn rest_json_malformed_pattern_string_override_case1_malformed_request() {
|
3853 3807 | {
|
3854 3808 | #[allow(unused_mut)]
|
3855 3809 | let mut http_request = ::http_1x::Request::builder()
|
3856 - | .uri("/MalformedRange")
|
3810 + | .uri("/MalformedPatternOverride")
|
3857 3811 | .method("POST")
|
3858 3812 | .header("content-type", "application/json")
|
3859 3813 | .body(::aws_smithy_http_server::body::boxed(
|
3860 3814 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3861 3815 | &::aws_smithy_protocol_test::decode_body_data(
|
3862 - | "{ \"minShort\" : 1 }".as_bytes(),
|
3816 + | "{ \"string\" : \"xyz\" }".as_bytes(),
|
3863 3817 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3864 3818 | ),
|
3865 3819 | )),
|
3866 3820 | ))
|
3867 3821 | .unwrap();
|
3868 3822 | #[allow(unused_mut)]
|
3869 3823 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3870 3824 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3871 3825 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3872 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3826 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3873 3827 | let sender = sender.clone();
|
3874 3828 | 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> };
|
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> };
|
3876 3830 | sender.send(()).await.expect("receiver dropped early");
|
3877 3831 | result
|
3878 3832 | }
|
3879 3833 | })
|
3880 3834 | .build_unchecked();
|
3881 3835 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3882 3836 | .await
|
3883 3837 | .expect("unable to make an HTTP request");
|
3884 3838 | ::pretty_assertions::assert_eq!(
|
3885 3839 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3886 3840 | http_response.status()
|
3887 3841 | );
|
3888 3842 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3889 3843 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3890 3844 | http_response.headers(),
|
3891 3845 | expected_headers,
|
3892 3846 | ));
|
3893 3847 | use ::http_body_util::BodyExt;
|
3894 3848 | let body = http_response
|
3895 3849 | .into_body()
|
3896 3850 | .collect()
|
3897 3851 | .await
|
3898 3852 | .expect("unable to collect body")
|
3899 3853 | .to_bytes();
|
3900 3854 | ::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"))
|
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"))
|
3902 3856 | );
|
3903 3857 | }
|
3904 3858 | }
|
3905 3859 |
|
3906 - | /// When a short member does not fit within range bounds,
|
3860 + | /// When a list member value does not match the specified pattern,
|
3907 3861 | /// the response should be a 400 ValidationException.
|
3908 - | /// Test ID: RestJsonMalformedRangeMaxShort
|
3862 + | /// Test ID: RestJsonMalformedPatternListOverride_case0
|
3909 3863 | #[::tokio::test]
|
3910 3864 | #[::tracing_test::traced_test]
|
3911 - | async fn rest_json_malformed_range_max_short_malformed_request() {
|
3865 + | async fn rest_json_malformed_pattern_list_override_case0_malformed_request() {
|
3912 3866 | {
|
3913 3867 | #[allow(unused_mut)]
|
3914 3868 | let mut http_request = ::http_1x::Request::builder()
|
3915 - | .uri("/MalformedRange")
|
3869 + | .uri("/MalformedPatternOverride")
|
3916 3870 | .method("POST")
|
3917 3871 | .header("content-type", "application/json")
|
3918 3872 | .body(::aws_smithy_http_server::body::boxed(
|
3919 3873 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3920 3874 | &::aws_smithy_protocol_test::decode_body_data(
|
3921 - | "{ \"maxShort\" : 9 }".as_bytes(),
|
3875 + | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
3922 3876 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3923 3877 | ),
|
3924 3878 | )),
|
3925 3879 | ))
|
3926 3880 | .unwrap();
|
3927 3881 | #[allow(unused_mut)]
|
3928 3882 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3929 3883 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3930 3884 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3931 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3885 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3932 3886 | let sender = sender.clone();
|
3933 3887 | 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> };
|
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> };
|
3935 3889 | sender.send(()).await.expect("receiver dropped early");
|
3936 3890 | result
|
3937 3891 | }
|
3938 3892 | })
|
3939 3893 | .build_unchecked();
|
3940 3894 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
3941 3895 | .await
|
3942 3896 | .expect("unable to make an HTTP request");
|
3943 3897 | ::pretty_assertions::assert_eq!(
|
3944 3898 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
3945 3899 | http_response.status()
|
3946 3900 | );
|
3947 3901 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
3948 3902 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
3949 3903 | http_response.headers(),
|
3950 3904 | expected_headers,
|
3951 3905 | ));
|
3952 3906 | use ::http_body_util::BodyExt;
|
3953 3907 | let body = http_response
|
3954 3908 | .into_body()
|
3955 3909 | .collect()
|
3956 3910 | .await
|
3957 3911 | .expect("unable to collect body")
|
3958 3912 | .to_bytes();
|
3959 3913 | ::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"))
|
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"))
|
3961 3915 | );
|
3962 3916 | }
|
3963 3917 | }
|
3964 3918 |
|
3965 - | /// When a integer member does not fit within range bounds,
|
3919 + | /// When a list member value does not match the specified pattern,
|
3966 3920 | /// the response should be a 400 ValidationException.
|
3967 - | /// Test ID: RestJsonMalformedRangeInteger_case0
|
3921 + | /// Test ID: RestJsonMalformedPatternListOverride_case1
|
3968 3922 | #[::tokio::test]
|
3969 3923 | #[::tracing_test::traced_test]
|
3970 - | async fn rest_json_malformed_range_integer_case0_malformed_request() {
|
3924 + | async fn rest_json_malformed_pattern_list_override_case1_malformed_request() {
|
3971 3925 | {
|
3972 3926 | #[allow(unused_mut)]
|
3973 3927 | let mut http_request = ::http_1x::Request::builder()
|
3974 - | .uri("/MalformedRange")
|
3928 + | .uri("/MalformedPatternOverride")
|
3975 3929 | .method("POST")
|
3976 3930 | .header("content-type", "application/json")
|
3977 3931 | .body(::aws_smithy_http_server::body::boxed(
|
3978 3932 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
3979 3933 | &::aws_smithy_protocol_test::decode_body_data(
|
3980 - | "{ \"integer\" : 1 }".as_bytes(),
|
3934 + | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
3981 3935 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
3982 3936 | ),
|
3983 3937 | )),
|
3984 3938 | ))
|
3985 3939 | .unwrap();
|
3986 3940 | #[allow(unused_mut)]
|
3987 3941 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
3988 3942 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
3989 3943 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
3990 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
3944 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
3991 3945 | let sender = sender.clone();
|
3992 3946 | 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> };
|
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> };
|
3994 3948 | sender.send(()).await.expect("receiver dropped early");
|
3995 3949 | result
|
3996 3950 | }
|
3997 3951 | })
|
3998 3952 | .build_unchecked();
|
3999 3953 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4000 3954 | .await
|
4001 3955 | .expect("unable to make an HTTP request");
|
4002 3956 | ::pretty_assertions::assert_eq!(
|
4003 3957 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4004 3958 | http_response.status()
|
4005 3959 | );
|
4006 3960 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4007 3961 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4008 3962 | http_response.headers(),
|
4009 3963 | expected_headers,
|
4010 3964 | ));
|
4011 3965 | use ::http_body_util::BodyExt;
|
4012 3966 | let body = http_response
|
4013 3967 | .into_body()
|
4014 3968 | .collect()
|
4015 3969 | .await
|
4016 3970 | .expect("unable to collect body")
|
4017 3971 | .to_bytes();
|
4018 3972 | ::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"))
|
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"))
|
4020 3974 | );
|
4021 3975 | }
|
4022 3976 | }
|
4023 3977 |
|
4024 - | /// When a integer member does not fit within range bounds,
|
3978 + | /// When a map member's key does not match the specified pattern,
|
4025 3979 | /// the response should be a 400 ValidationException.
|
4026 - | /// Test ID: RestJsonMalformedRangeInteger_case1
|
3980 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case0
|
4027 3981 | #[::tokio::test]
|
4028 3982 | #[::tracing_test::traced_test]
|
4029 - | async fn rest_json_malformed_range_integer_case1_malformed_request() {
|
3983 + | async fn rest_json_malformed_pattern_map_key_override_case0_malformed_request() {
|
4030 3984 | {
|
4031 3985 | #[allow(unused_mut)]
|
4032 3986 | let mut http_request = ::http_1x::Request::builder()
|
4033 - | .uri("/MalformedRange")
|
3987 + | .uri("/MalformedPatternOverride")
|
4034 3988 | .method("POST")
|
4035 3989 | .header("content-type", "application/json")
|
4036 3990 | .body(::aws_smithy_http_server::body::boxed(
|
4037 3991 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4038 3992 | &::aws_smithy_protocol_test::decode_body_data(
|
4039 - | "{ \"integer\" : 9 }".as_bytes(),
|
3993 + | "{ \"map\" : { \"abc\" : \"ghi\" } }".as_bytes(),
|
4040 3994 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4041 3995 | ),
|
4042 3996 | )),
|
4043 3997 | ))
|
4044 3998 | .unwrap();
|
4045 3999 | #[allow(unused_mut)]
|
4046 4000 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4047 4001 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4048 4002 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4049 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4003 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4050 4004 | let sender = sender.clone();
|
4051 4005 | 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> };
|
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> };
|
4053 4007 | sender.send(()).await.expect("receiver dropped early");
|
4054 4008 | result
|
4055 4009 | }
|
4056 4010 | })
|
4057 4011 | .build_unchecked();
|
4058 4012 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4059 4013 | .await
|
4060 4014 | .expect("unable to make an HTTP request");
|
4061 4015 | ::pretty_assertions::assert_eq!(
|
4062 4016 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4063 4017 | http_response.status()
|
4064 4018 | );
|
4065 4019 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4066 4020 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4067 4021 | http_response.headers(),
|
4068 4022 | expected_headers,
|
4069 4023 | ));
|
4070 4024 | use ::http_body_util::BodyExt;
|
4071 4025 | let body = http_response
|
4072 4026 | .into_body()
|
4073 4027 | .collect()
|
4074 4028 | .await
|
4075 4029 | .expect("unable to collect body")
|
4076 4030 | .to_bytes();
|
4077 4031 | ::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"))
|
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"))
|
4079 4033 | );
|
4080 4034 | }
|
4081 4035 | }
|
4082 4036 |
|
4083 - | /// When a integer member does not fit within range bounds,
|
4037 + | /// When a map member's key does not match the specified pattern,
|
4084 4038 | /// the response should be a 400 ValidationException.
|
4085 - | /// Test ID: RestJsonMalformedRangeMinInteger
|
4039 + | /// Test ID: RestJsonMalformedPatternMapKeyOverride_case1
|
4086 4040 | #[::tokio::test]
|
4087 4041 | #[::tracing_test::traced_test]
|
4088 - | async fn rest_json_malformed_range_min_integer_malformed_request() {
|
4042 + | async fn rest_json_malformed_pattern_map_key_override_case1_malformed_request() {
|
4089 4043 | {
|
4090 4044 | #[allow(unused_mut)]
|
4091 4045 | let mut http_request = ::http_1x::Request::builder()
|
4092 - | .uri("/MalformedRange")
|
4046 + | .uri("/MalformedPatternOverride")
|
4093 4047 | .method("POST")
|
4094 4048 | .header("content-type", "application/json")
|
4095 4049 | .body(::aws_smithy_http_server::body::boxed(
|
4096 4050 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4097 4051 | &::aws_smithy_protocol_test::decode_body_data(
|
4098 - | "{ \"minInteger\" : 1 }".as_bytes(),
|
4052 + | "{ \"map\" : { \"xyz\" : \"ghi\" } }".as_bytes(),
|
4099 4053 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4100 4054 | ),
|
4101 4055 | )),
|
4102 4056 | ))
|
4103 4057 | .unwrap();
|
4104 4058 | #[allow(unused_mut)]
|
4105 4059 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4106 4060 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4107 4061 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4108 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4062 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4109 4063 | let sender = sender.clone();
|
4110 4064 | 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> };
|
4112 - | sender.send(()).await.expect("receiver dropped early");
|
4113 - | result
|
4114 - | }
|
4115 - | })
|
4116 - | .build_unchecked();
|
4117 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4118 - | .await
|
4119 - | .expect("unable to make an HTTP request");
|
4120 - | ::pretty_assertions::assert_eq!(
|
4121 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4122 - | http_response.status()
|
4123 - | );
|
4124 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4125 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4126 - | http_response.headers(),
|
4127 - | expected_headers,
|
4128 - | ));
|
4129 - | use ::http_body_util::BodyExt;
|
4130 - | let body = http_response
|
4131 - | .into_body()
|
4132 - | .collect()
|
4133 - | .await
|
4134 - | .expect("unable to collect body")
|
4135 - | .to_bytes();
|
4136 - | ::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"))
|
4138 - | );
|
4139 - | }
|
4140 - | }
|
4141 - |
|
4142 - | /// When a integer member does not fit within range bounds,
|
4143 - | /// the response should be a 400 ValidationException.
|
4144 - | /// Test ID: RestJsonMalformedRangeMaxInteger
|
4145 - | #[::tokio::test]
|
4146 - | #[::tracing_test::traced_test]
|
4147 - | async fn rest_json_malformed_range_max_integer_malformed_request() {
|
4148 - | {
|
4149 - | #[allow(unused_mut)]
|
4150 - | let mut http_request = ::http_1x::Request::builder()
|
4151 - | .uri("/MalformedRange")
|
4152 - | .method("POST")
|
4153 - | .header("content-type", "application/json")
|
4154 - | .body(::aws_smithy_http_server::body::boxed(
|
4155 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4156 - | &::aws_smithy_protocol_test::decode_body_data(
|
4157 - | "{ \"maxInteger\" : 9 }".as_bytes(),
|
4158 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4159 - | ),
|
4160 - | )),
|
4161 - | ))
|
4162 - | .unwrap();
|
4163 - | #[allow(unused_mut)]
|
4164 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4165 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4166 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4167 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4168 - | let sender = sender.clone();
|
4169 - | 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> };
|
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> };
|
4171 4066 | sender.send(()).await.expect("receiver dropped early");
|
4172 4067 | result
|
4173 4068 | }
|
4174 4069 | })
|
4175 4070 | .build_unchecked();
|
4176 4071 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4177 4072 | .await
|
4178 4073 | .expect("unable to make an HTTP request");
|
4179 4074 | ::pretty_assertions::assert_eq!(
|
4180 4075 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4181 4076 | http_response.status()
|
4182 4077 | );
|
4183 4078 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4184 4079 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4185 4080 | http_response.headers(),
|
4186 4081 | expected_headers,
|
4187 4082 | ));
|
4188 4083 | use ::http_body_util::BodyExt;
|
4189 4084 | let body = http_response
|
4190 4085 | .into_body()
|
4191 4086 | .collect()
|
4192 4087 | .await
|
4193 4088 | .expect("unable to collect body")
|
4194 4089 | .to_bytes();
|
4195 4090 | ::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"))
|
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"))
|
4197 4092 | );
|
4198 4093 | }
|
4199 4094 | }
|
4200 4095 |
|
4201 - | /// When a long member does not fit within range bounds,
|
4096 + | /// When a map member's value does not match the specified pattern,
|
4202 4097 | /// the response should be a 400 ValidationException.
|
4203 - | /// Test ID: RestJsonMalformedRangeLong_case0
|
4098 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case0
|
4204 4099 | #[::tokio::test]
|
4205 4100 | #[::tracing_test::traced_test]
|
4206 - | async fn rest_json_malformed_range_long_case0_malformed_request() {
|
4101 + | async fn rest_json_malformed_pattern_map_value_override_case0_malformed_request() {
|
4207 4102 | {
|
4208 4103 | #[allow(unused_mut)]
|
4209 4104 | let mut http_request = ::http_1x::Request::builder()
|
4210 - | .uri("/MalformedRange")
|
4105 + | .uri("/MalformedPatternOverride")
|
4211 4106 | .method("POST")
|
4212 4107 | .header("content-type", "application/json")
|
4213 4108 | .body(::aws_smithy_http_server::body::boxed(
|
4214 4109 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4215 4110 | &::aws_smithy_protocol_test::decode_body_data(
|
4216 - | "{ \"long\" : 1 }".as_bytes(),
|
4111 + | "{ \"map\" : { \"ghi\": \"abc\" } }".as_bytes(),
|
4217 4112 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4218 4113 | ),
|
4219 4114 | )),
|
4220 4115 | ))
|
4221 4116 | .unwrap();
|
4222 4117 | #[allow(unused_mut)]
|
4223 4118 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4224 4119 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4225 4120 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4226 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4121 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4227 4122 | let sender = sender.clone();
|
4228 4123 | 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> };
|
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> };
|
4230 4125 | sender.send(()).await.expect("receiver dropped early");
|
4231 4126 | result
|
4232 4127 | }
|
4233 4128 | })
|
4234 4129 | .build_unchecked();
|
4235 4130 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4236 4131 | .await
|
4237 4132 | .expect("unable to make an HTTP request");
|
4238 4133 | ::pretty_assertions::assert_eq!(
|
4239 4134 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4240 4135 | http_response.status()
|
4241 4136 | );
|
4242 4137 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4243 4138 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4244 4139 | http_response.headers(),
|
4245 4140 | expected_headers,
|
4246 4141 | ));
|
4247 4142 | use ::http_body_util::BodyExt;
|
4248 4143 | let body = http_response
|
4249 4144 | .into_body()
|
4250 4145 | .collect()
|
4251 4146 | .await
|
4252 4147 | .expect("unable to collect body")
|
4253 4148 | .to_bytes();
|
4254 4149 | ::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"))
|
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"))
|
4256 4151 | );
|
4257 4152 | }
|
4258 4153 | }
|
4259 4154 |
|
4260 - | /// When a long member does not fit within range bounds,
|
4155 + | /// When a map member's value does not match the specified pattern,
|
4261 4156 | /// the response should be a 400 ValidationException.
|
4262 - | /// Test ID: RestJsonMalformedRangeLong_case1
|
4157 + | /// Test ID: RestJsonMalformedPatternMapValueOverride_case1
|
4263 4158 | #[::tokio::test]
|
4264 4159 | #[::tracing_test::traced_test]
|
4265 - | async fn rest_json_malformed_range_long_case1_malformed_request() {
|
4160 + | async fn rest_json_malformed_pattern_map_value_override_case1_malformed_request() {
|
4266 4161 | {
|
4267 4162 | #[allow(unused_mut)]
|
4268 4163 | let mut http_request = ::http_1x::Request::builder()
|
4269 - | .uri("/MalformedRange")
|
4164 + | .uri("/MalformedPatternOverride")
|
4270 4165 | .method("POST")
|
4271 4166 | .header("content-type", "application/json")
|
4272 4167 | .body(::aws_smithy_http_server::body::boxed(
|
4273 4168 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4274 4169 | &::aws_smithy_protocol_test::decode_body_data(
|
4275 - | "{ \"long\" : 9 }".as_bytes(),
|
4170 + | "{ \"map\" : { \"ghi\": \"xyz\" } }".as_bytes(),
|
4276 4171 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4277 4172 | ),
|
4278 4173 | )),
|
4279 4174 | ))
|
4280 4175 | .unwrap();
|
4281 4176 | #[allow(unused_mut)]
|
4282 4177 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4283 4178 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4284 4179 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4285 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4180 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4286 4181 | let sender = sender.clone();
|
4287 4182 | 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> };
|
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> };
|
4289 4184 | sender.send(()).await.expect("receiver dropped early");
|
4290 4185 | result
|
4291 4186 | }
|
4292 4187 | })
|
4293 4188 | .build_unchecked();
|
4294 4189 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4295 4190 | .await
|
4296 4191 | .expect("unable to make an HTTP request");
|
4297 4192 | ::pretty_assertions::assert_eq!(
|
4298 4193 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4299 4194 | http_response.status()
|
4300 4195 | );
|
4301 4196 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4302 4197 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4303 4198 | http_response.headers(),
|
4304 4199 | expected_headers,
|
4305 4200 | ));
|
4306 4201 | use ::http_body_util::BodyExt;
|
4307 4202 | let body = http_response
|
4308 4203 | .into_body()
|
4309 4204 | .collect()
|
4310 4205 | .await
|
4311 4206 | .expect("unable to collect body")
|
4312 4207 | .to_bytes();
|
4313 4208 | ::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"))
|
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"))
|
4315 4210 | );
|
4316 4211 | }
|
4317 4212 | }
|
4318 4213 |
|
4319 - | /// When a long member does not fit within range bounds,
|
4214 + | /// When a union member's value does not match the specified pattern,
|
4320 4215 | /// the response should be a 400 ValidationException.
|
4321 - | /// Test ID: RestJsonMalformedRangeMinLong
|
4216 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case0
|
4322 4217 | #[::tokio::test]
|
4323 4218 | #[::tracing_test::traced_test]
|
4324 - | async fn rest_json_malformed_range_min_long_malformed_request() {
|
4219 + | async fn rest_json_malformed_pattern_union_override_case0_malformed_request() {
|
4325 4220 | {
|
4326 4221 | #[allow(unused_mut)]
|
4327 4222 | let mut http_request = ::http_1x::Request::builder()
|
4328 - | .uri("/MalformedRange")
|
4223 + | .uri("/MalformedPatternOverride")
|
4329 4224 | .method("POST")
|
4330 4225 | .header("content-type", "application/json")
|
4331 4226 | .body(::aws_smithy_http_server::body::boxed(
|
4332 4227 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4333 4228 | &::aws_smithy_protocol_test::decode_body_data(
|
4334 - | "{ \"minLong\" : 1 }".as_bytes(),
|
4229 + | "{ \"union\" : { \"first\": \"abc\" } }".as_bytes(),
|
4335 4230 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4336 4231 | ),
|
4337 4232 | )),
|
4338 4233 | ))
|
4339 4234 | .unwrap();
|
4340 4235 | #[allow(unused_mut)]
|
4341 4236 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4342 4237 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4343 4238 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4344 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4239 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4345 4240 | let sender = sender.clone();
|
4346 4241 | 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> };
|
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> };
|
4348 4243 | sender.send(()).await.expect("receiver dropped early");
|
4349 4244 | result
|
4350 4245 | }
|
4351 4246 | })
|
4352 4247 | .build_unchecked();
|
4353 4248 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4354 4249 | .await
|
4355 4250 | .expect("unable to make an HTTP request");
|
4356 4251 | ::pretty_assertions::assert_eq!(
|
4357 4252 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4358 4253 | http_response.status()
|
4359 4254 | );
|
4360 4255 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4361 4256 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4362 4257 | http_response.headers(),
|
4363 4258 | expected_headers,
|
4364 4259 | ));
|
4365 4260 | use ::http_body_util::BodyExt;
|
4366 4261 | let body = http_response
|
4367 4262 | .into_body()
|
4368 4263 | .collect()
|
4369 4264 | .await
|
4370 4265 | .expect("unable to collect body")
|
4371 4266 | .to_bytes();
|
4372 4267 | ::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"))
|
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"))
|
4374 4269 | );
|
4375 4270 | }
|
4376 4271 | }
|
4377 4272 |
|
4378 - | /// When a long member does not fit within range bounds,
|
4273 + | /// When a union member's value does not match the specified pattern,
|
4379 4274 | /// the response should be a 400 ValidationException.
|
4380 - | /// Test ID: RestJsonMalformedRangeMaxLong
|
4275 + | /// Test ID: RestJsonMalformedPatternUnionOverride_case1
|
4381 4276 | #[::tokio::test]
|
4382 4277 | #[::tracing_test::traced_test]
|
4383 - | async fn rest_json_malformed_range_max_long_malformed_request() {
|
4278 + | async fn rest_json_malformed_pattern_union_override_case1_malformed_request() {
|
4384 4279 | {
|
4385 4280 | #[allow(unused_mut)]
|
4386 4281 | let mut http_request = ::http_1x::Request::builder()
|
4387 - | .uri("/MalformedRange")
|
4282 + | .uri("/MalformedPatternOverride")
|
4388 4283 | .method("POST")
|
4389 4284 | .header("content-type", "application/json")
|
4390 4285 | .body(::aws_smithy_http_server::body::boxed(
|
4391 4286 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
4392 4287 | &::aws_smithy_protocol_test::decode_body_data(
|
4393 - | "{ \"maxLong\" : 9 }".as_bytes(),
|
4288 + | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
4394 4289 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
4395 4290 | ),
|
4396 4291 | )),
|
4397 4292 | ))
|
4398 4293 | .unwrap();
|
4399 4294 | #[allow(unused_mut)]
|
4400 4295 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
4401 4296 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
4402 4297 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
4403 - | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
4298 + | .malformed_pattern_override(move |input: crate::input::MalformedPatternOverrideInput| {
|
4404 4299 | let sender = sender.clone();
|
4405 4300 | 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> };
|
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> };
|
4407 4302 | sender.send(()).await.expect("receiver dropped early");
|
4408 4303 | result
|
4409 4304 | }
|
4410 4305 | })
|
4411 4306 | .build_unchecked();
|
4412 4307 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
4413 4308 | .await
|
4414 4309 | .expect("unable to make an HTTP request");
|
4415 4310 | ::pretty_assertions::assert_eq!(
|
4416 4311 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
4417 4312 | http_response.status()
|
4418 4313 | );
|
4419 4314 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
4420 4315 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
4421 4316 | http_response.headers(),
|
4422 4317 | expected_headers,
|
4423 4318 | ));
|
4424 4319 | use ::http_body_util::BodyExt;
|
4425 4320 | let body = http_response
|
4426 4321 | .into_body()
|
4427 4322 | .collect()
|
4428 4323 | .await
|
4429 4324 | .expect("unable to collect body")
|
4430 4325 | .to_bytes();
|
4431 4326 | ::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"))
|
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)
|
4486 - | .await
|
4380 + | crate::protocol_serde::shape_malformed_range::de_malformed_range_http_request(request)
|
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) {
|
4509 - | Ok(response) => response,
|
4510 - | Err(e) => {
|
4511 - | ::tracing::error!(error = %e, "failed to serialize response");
|
4512 - | ::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 - | }
|
4514 - | }
|
4403 + | match crate::protocol_serde::shape_malformed_range::ser_malformed_range_http_response(self)
|
4404 + | {
|
4405 + | Ok(response) => response,
|
4406 + | Err(e) => {
|
4407 + | ::tracing::error!(error = %e, "failed to serialize response");
|
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))
|
4409 + | }
|
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 - |
|
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);
|
5177 - | }
|
5178 - | crate::protocol_serde::shape_malformed_pattern::de_malformed_pattern_http_request(
|
5179 - | request,
|
5180 - | )
|
5181 - | .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 - | },
|
5191 - | );
|
5192 - | MalformedPatternInputFuture {
|
5193 - | inner: Box::pin(fut),
|
5194 - | }
|
5195 - | }
|
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 5031 |
|
5241 - | /// When a string member does not match the specified pattern,
|
5032 + | /// When a short member does not fit within range bounds,
|
5242 5033 | /// the response should be a 400 ValidationException.
|
5243 - | /// Test ID: RestJsonMalformedPatternString_case0
|
5034 + | /// Test ID: RestJsonMalformedRangeMinShort
|
5244 5035 | #[::tokio::test]
|
5245 5036 | #[::tracing_test::traced_test]
|
5246 - | async fn rest_json_malformed_pattern_string_case0_malformed_request() {
|
5037 + | async fn rest_json_malformed_range_min_short_malformed_request() {
|
5247 5038 | {
|
5248 5039 | #[allow(unused_mut)]
|
5249 5040 | let mut http_request = ::http_1x::Request::builder()
|
5250 - | .uri("/MalformedPattern")
|
5041 + | .uri("/MalformedRange")
|
5251 5042 | .method("POST")
|
5252 5043 | .header("content-type", "application/json")
|
5253 5044 | .body(::aws_smithy_http_server::body::boxed(
|
5254 5045 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5255 5046 | &::aws_smithy_protocol_test::decode_body_data(
|
5256 - | "{ \"string\" : \"ABC\" }".as_bytes(),
|
5047 + | "{ \"minShort\" : 1 }".as_bytes(),
|
5257 5048 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5258 5049 | ),
|
5259 5050 | )),
|
5260 5051 | ))
|
5261 5052 | .unwrap();
|
5262 5053 | #[allow(unused_mut)]
|
5263 5054 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5264 5055 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5265 5056 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5266 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5057 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5267 5058 | let sender = sender.clone();
|
5268 5059 | 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> };
|
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> };
|
5270 5061 | sender.send(()).await.expect("receiver dropped early");
|
5271 5062 | result
|
5272 5063 | }
|
5273 5064 | })
|
5274 5065 | .build_unchecked();
|
5275 5066 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5276 5067 | .await
|
5277 5068 | .expect("unable to make an HTTP request");
|
5278 5069 | ::pretty_assertions::assert_eq!(
|
5279 5070 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5280 5071 | http_response.status()
|
5281 5072 | );
|
5282 5073 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5283 5074 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5284 5075 | http_response.headers(),
|
5285 5076 | expected_headers,
|
5286 5077 | ));
|
5287 5078 | use ::http_body_util::BodyExt;
|
5288 5079 | let body = http_response
|
5289 5080 | .into_body()
|
5290 5081 | .collect()
|
5291 5082 | .await
|
5292 5083 | .expect("unable to collect body")
|
5293 5084 | .to_bytes();
|
5294 5085 | ::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"))
|
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"))
|
5296 5087 | );
|
5297 5088 | }
|
5298 5089 | }
|
5299 5090 |
|
5300 - | /// When a string member does not match the specified pattern,
|
5091 + | /// When a short member does not fit within range bounds,
|
5301 5092 | /// the response should be a 400 ValidationException.
|
5302 - | /// Test ID: RestJsonMalformedPatternString_case1
|
5093 + | /// Test ID: RestJsonMalformedRangeMaxShort
|
5303 5094 | #[::tokio::test]
|
5304 5095 | #[::tracing_test::traced_test]
|
5305 - | async fn rest_json_malformed_pattern_string_case1_malformed_request() {
|
5096 + | async fn rest_json_malformed_range_max_short_malformed_request() {
|
5306 5097 | {
|
5307 5098 | #[allow(unused_mut)]
|
5308 5099 | let mut http_request = ::http_1x::Request::builder()
|
5309 - | .uri("/MalformedPattern")
|
5100 + | .uri("/MalformedRange")
|
5310 5101 | .method("POST")
|
5311 5102 | .header("content-type", "application/json")
|
5312 5103 | .body(::aws_smithy_http_server::body::boxed(
|
5313 5104 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5314 5105 | &::aws_smithy_protocol_test::decode_body_data(
|
5315 - | "{ \"string\" : \"xyz\" }".as_bytes(),
|
5106 + | "{ \"maxShort\" : 9 }".as_bytes(),
|
5316 5107 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5317 5108 | ),
|
5318 5109 | )),
|
5319 5110 | ))
|
5320 5111 | .unwrap();
|
5321 5112 | #[allow(unused_mut)]
|
5322 5113 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5323 5114 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5324 5115 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5325 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5116 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5326 5117 | let sender = sender.clone();
|
5327 5118 | 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> };
|
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> };
|
5329 5120 | sender.send(()).await.expect("receiver dropped early");
|
5330 5121 | result
|
5331 5122 | }
|
5332 5123 | })
|
5333 5124 | .build_unchecked();
|
5334 5125 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5335 5126 | .await
|
5336 5127 | .expect("unable to make an HTTP request");
|
5337 5128 | ::pretty_assertions::assert_eq!(
|
5338 5129 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5339 5130 | http_response.status()
|
5340 5131 | );
|
5341 5132 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5342 5133 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5343 5134 | http_response.headers(),
|
5344 5135 | expected_headers,
|
5345 5136 | ));
|
5346 5137 | use ::http_body_util::BodyExt;
|
5347 5138 | let body = http_response
|
5348 5139 | .into_body()
|
5349 5140 | .collect()
|
5350 5141 | .await
|
5351 5142 | .expect("unable to collect body")
|
5352 5143 | .to_bytes();
|
5353 5144 | ::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"))
|
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"))
|
5355 5146 | );
|
5356 5147 | }
|
5357 5148 | }
|
5358 5149 |
|
5359 - | /// When the specified pattern is susceptible to ReDOS, the service will not
|
5360 - | /// hang indefinitely while evaluating the pattern
|
5361 - | /// Test ID: RestJsonMalformedPatternReDOSString
|
5150 + | /// When a integer member does not fit within range bounds,
|
5151 + | /// the response should be a 400 ValidationException.
|
5152 + | /// Test ID: RestJsonMalformedRangeInteger_case0
|
5362 5153 | #[::tokio::test]
|
5363 5154 | #[::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| {
|
5382 - | let sender = sender.clone();
|
5383 - | 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> };
|
5385 - | sender.send(()).await.expect("receiver dropped early");
|
5386 - | result
|
5387 - | }
|
5388 - | })
|
5389 - | .build_unchecked();
|
5390 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5391 - | .await
|
5392 - | .expect("unable to make an HTTP request");
|
5393 - | ::pretty_assertions::assert_eq!(
|
5394 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5395 - | http_response.status()
|
5396 - | );
|
5397 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5398 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5399 - | http_response.headers(),
|
5400 - | expected_headers,
|
5401 - | ));
|
5402 - | use ::http_body_util::BodyExt;
|
5403 - | let body = http_response
|
5404 - | .into_body()
|
5405 - | .collect()
|
5406 - | .await
|
5407 - | .expect("unable to collect body")
|
5408 - | .to_bytes();
|
5409 - | ::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"))
|
5411 - | );
|
5412 - | }
|
5413 - | }
|
5414 - |
|
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
|
5418 - | #[::tokio::test]
|
5419 - | #[::tracing_test::traced_test]
|
5420 - | async fn rest_json_malformed_pattern_re_dos_string_hotfixed_malformed_request() {
|
5421 - | {
|
5422 - | #[allow(unused_mut)]
|
5423 - | let mut http_request = ::http_1x::Request::builder()
|
5424 - | .uri("/MalformedPattern")
|
5425 - | .method("POST")
|
5426 - | .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();
|
5432 - | #[allow(unused_mut)]
|
5433 - | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5434 - | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5435 - | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5436 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5437 - | let sender = sender.clone();
|
5438 - | 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> };
|
5440 - | sender.send(()).await.expect("receiver dropped early");
|
5441 - | result
|
5442 - | }
|
5443 - | })
|
5444 - | .build_unchecked();
|
5445 - | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5446 - | .await
|
5447 - | .expect("unable to make an HTTP request");
|
5448 - | ::pretty_assertions::assert_eq!(
|
5449 - | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5450 - | http_response.status()
|
5451 - | );
|
5452 - | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5453 - | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5454 - | http_response.headers(),
|
5455 - | expected_headers,
|
5456 - | ));
|
5457 - | use ::http_body_util::BodyExt;
|
5458 - | let body = http_response
|
5459 - | .into_body()
|
5460 - | .collect()
|
5461 - | .await
|
5462 - | .expect("unable to collect body")
|
5463 - | .to_bytes();
|
5464 - | ::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"))
|
5466 - | );
|
5467 - | }
|
5468 - | }
|
5469 - |
|
5470 - | /// When a list member value does not match the specified pattern,
|
5471 - | /// the response should be a 400 ValidationException.
|
5472 - | /// Test ID: RestJsonMalformedPatternList_case0
|
5473 - | #[::tokio::test]
|
5474 - | #[::tracing_test::traced_test]
|
5475 - | async fn rest_json_malformed_pattern_list_case0_malformed_request() {
|
5155 + | async fn rest_json_malformed_range_integer_case0_malformed_request() {
|
5476 5156 | {
|
5477 5157 | #[allow(unused_mut)]
|
5478 5158 | let mut http_request = ::http_1x::Request::builder()
|
5479 - | .uri("/MalformedPattern")
|
5159 + | .uri("/MalformedRange")
|
5480 5160 | .method("POST")
|
5481 5161 | .header("content-type", "application/json")
|
5482 5162 | .body(::aws_smithy_http_server::body::boxed(
|
5483 5163 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5484 5164 | &::aws_smithy_protocol_test::decode_body_data(
|
5485 - | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
5165 + | "{ \"integer\" : 1 }".as_bytes(),
|
5486 5166 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5487 5167 | ),
|
5488 5168 | )),
|
5489 5169 | ))
|
5490 5170 | .unwrap();
|
5491 5171 | #[allow(unused_mut)]
|
5492 5172 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5493 5173 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5494 5174 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5495 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5175 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5496 5176 | let sender = sender.clone();
|
5497 5177 | 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> };
|
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> };
|
5499 5179 | sender.send(()).await.expect("receiver dropped early");
|
5500 5180 | result
|
5501 5181 | }
|
5502 5182 | })
|
5503 5183 | .build_unchecked();
|
5504 5184 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5505 5185 | .await
|
5506 5186 | .expect("unable to make an HTTP request");
|
5507 5187 | ::pretty_assertions::assert_eq!(
|
5508 5188 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5509 5189 | http_response.status()
|
5510 5190 | );
|
5511 5191 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5512 5192 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5513 5193 | http_response.headers(),
|
5514 5194 | expected_headers,
|
5515 5195 | ));
|
5516 5196 | use ::http_body_util::BodyExt;
|
5517 5197 | let body = http_response
|
5518 5198 | .into_body()
|
5519 5199 | .collect()
|
5520 5200 | .await
|
5521 5201 | .expect("unable to collect body")
|
5522 5202 | .to_bytes();
|
5523 5203 | ::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"))
|
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"))
|
5525 5205 | );
|
5526 5206 | }
|
5527 5207 | }
|
5528 5208 |
|
5529 - | /// When a list member value does not match the specified pattern,
|
5209 + | /// When a integer member does not fit within range bounds,
|
5530 5210 | /// the response should be a 400 ValidationException.
|
5531 - | /// Test ID: RestJsonMalformedPatternList_case1
|
5211 + | /// Test ID: RestJsonMalformedRangeInteger_case1
|
5532 5212 | #[::tokio::test]
|
5533 5213 | #[::tracing_test::traced_test]
|
5534 - | async fn rest_json_malformed_pattern_list_case1_malformed_request() {
|
5214 + | async fn rest_json_malformed_range_integer_case1_malformed_request() {
|
5535 5215 | {
|
5536 5216 | #[allow(unused_mut)]
|
5537 5217 | let mut http_request = ::http_1x::Request::builder()
|
5538 - | .uri("/MalformedPattern")
|
5218 + | .uri("/MalformedRange")
|
5539 5219 | .method("POST")
|
5540 5220 | .header("content-type", "application/json")
|
5541 5221 | .body(::aws_smithy_http_server::body::boxed(
|
5542 5222 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5543 5223 | &::aws_smithy_protocol_test::decode_body_data(
|
5544 - | "{ \"list\" : [\"xyz\"] }".as_bytes(),
|
5224 + | "{ \"integer\" : 9 }".as_bytes(),
|
5545 5225 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5546 5226 | ),
|
5547 5227 | )),
|
5548 5228 | ))
|
5549 5229 | .unwrap();
|
5550 5230 | #[allow(unused_mut)]
|
5551 5231 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5552 5232 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5553 5233 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5554 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5234 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5555 5235 | let sender = sender.clone();
|
5556 5236 | 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> };
|
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> };
|
5558 5238 | sender.send(()).await.expect("receiver dropped early");
|
5559 5239 | result
|
5560 5240 | }
|
5561 5241 | })
|
5562 5242 | .build_unchecked();
|
5563 5243 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5564 5244 | .await
|
5565 5245 | .expect("unable to make an HTTP request");
|
5566 5246 | ::pretty_assertions::assert_eq!(
|
5567 5247 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5568 5248 | http_response.status()
|
5569 5249 | );
|
5570 5250 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5571 5251 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5572 5252 | http_response.headers(),
|
5573 5253 | expected_headers,
|
5574 5254 | ));
|
5575 5255 | use ::http_body_util::BodyExt;
|
5576 5256 | let body = http_response
|
5577 5257 | .into_body()
|
5578 5258 | .collect()
|
5579 5259 | .await
|
5580 5260 | .expect("unable to collect body")
|
5581 5261 | .to_bytes();
|
5582 5262 | ::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"))
|
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"))
|
5584 5264 | );
|
5585 5265 | }
|
5586 5266 | }
|
5587 5267 |
|
5588 - | /// When a map member's key does not match the specified pattern,
|
5268 + | /// When a integer member does not fit within range bounds,
|
5589 5269 | /// the response should be a 400 ValidationException.
|
5590 - | /// Test ID: RestJsonMalformedPatternMapKey_case0
|
5270 + | /// Test ID: RestJsonMalformedRangeMinInteger
|
5591 5271 | #[::tokio::test]
|
5592 5272 | #[::tracing_test::traced_test]
|
5593 - | async fn rest_json_malformed_pattern_map_key_case0_malformed_request() {
|
5273 + | async fn rest_json_malformed_range_min_integer_malformed_request() {
|
5594 5274 | {
|
5595 5275 | #[allow(unused_mut)]
|
5596 5276 | let mut http_request = ::http_1x::Request::builder()
|
5597 - | .uri("/MalformedPattern")
|
5277 + | .uri("/MalformedRange")
|
5598 5278 | .method("POST")
|
5599 5279 | .header("content-type", "application/json")
|
5600 5280 | .body(::aws_smithy_http_server::body::boxed(
|
5601 5281 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5602 5282 | &::aws_smithy_protocol_test::decode_body_data(
|
5603 - | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
5283 + | "{ \"minInteger\" : 1 }".as_bytes(),
|
5604 5284 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5605 5285 | ),
|
5606 5286 | )),
|
5607 5287 | ))
|
5608 5288 | .unwrap();
|
5609 5289 | #[allow(unused_mut)]
|
5610 5290 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5611 5291 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5612 5292 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5613 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5293 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5614 5294 | let sender = sender.clone();
|
5615 5295 | 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> };
|
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> };
|
5617 5297 | sender.send(()).await.expect("receiver dropped early");
|
5618 5298 | result
|
5619 5299 | }
|
5620 5300 | })
|
5621 5301 | .build_unchecked();
|
5622 5302 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5623 5303 | .await
|
5624 5304 | .expect("unable to make an HTTP request");
|
5625 5305 | ::pretty_assertions::assert_eq!(
|
5626 5306 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5627 5307 | http_response.status()
|
5628 5308 | );
|
5629 5309 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5630 5310 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5631 5311 | http_response.headers(),
|
5632 5312 | expected_headers,
|
5633 5313 | ));
|
5634 5314 | use ::http_body_util::BodyExt;
|
5635 5315 | let body = http_response
|
5636 5316 | .into_body()
|
5637 5317 | .collect()
|
5638 5318 | .await
|
5639 5319 | .expect("unable to collect body")
|
5640 5320 | .to_bytes();
|
5641 5321 | ::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"))
|
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"))
|
5643 5323 | );
|
5644 5324 | }
|
5645 5325 | }
|
5646 5326 |
|
5647 - | /// When a map member's key does not match the specified pattern,
|
5327 + | /// When a integer member does not fit within range bounds,
|
5648 5328 | /// the response should be a 400 ValidationException.
|
5649 - | /// Test ID: RestJsonMalformedPatternMapKey_case1
|
5329 + | /// Test ID: RestJsonMalformedRangeMaxInteger
|
5650 5330 | #[::tokio::test]
|
5651 5331 | #[::tracing_test::traced_test]
|
5652 - | async fn rest_json_malformed_pattern_map_key_case1_malformed_request() {
|
5332 + | async fn rest_json_malformed_range_max_integer_malformed_request() {
|
5653 5333 | {
|
5654 5334 | #[allow(unused_mut)]
|
5655 5335 | let mut http_request = ::http_1x::Request::builder()
|
5656 - | .uri("/MalformedPattern")
|
5336 + | .uri("/MalformedRange")
|
5657 5337 | .method("POST")
|
5658 5338 | .header("content-type", "application/json")
|
5659 5339 | .body(::aws_smithy_http_server::body::boxed(
|
5660 5340 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5661 5341 | &::aws_smithy_protocol_test::decode_body_data(
|
5662 - | "{ \"map\" : { \"xyz\" : \"abc\" } }".as_bytes(),
|
5342 + | "{ \"maxInteger\" : 9 }".as_bytes(),
|
5663 5343 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5664 5344 | ),
|
5665 5345 | )),
|
5666 5346 | ))
|
5667 5347 | .unwrap();
|
5668 5348 | #[allow(unused_mut)]
|
5669 5349 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5670 5350 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5671 5351 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5672 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5352 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5673 5353 | let sender = sender.clone();
|
5674 5354 | 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> };
|
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> };
|
5676 5356 | sender.send(()).await.expect("receiver dropped early");
|
5677 5357 | result
|
5678 5358 | }
|
5679 5359 | })
|
5680 5360 | .build_unchecked();
|
5681 5361 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5682 5362 | .await
|
5683 5363 | .expect("unable to make an HTTP request");
|
5684 5364 | ::pretty_assertions::assert_eq!(
|
5685 5365 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5686 5366 | http_response.status()
|
5687 5367 | );
|
5688 5368 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5689 5369 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5690 5370 | http_response.headers(),
|
5691 5371 | expected_headers,
|
5692 5372 | ));
|
5693 5373 | use ::http_body_util::BodyExt;
|
5694 5374 | let body = http_response
|
5695 5375 | .into_body()
|
5696 5376 | .collect()
|
5697 5377 | .await
|
5698 5378 | .expect("unable to collect body")
|
5699 5379 | .to_bytes();
|
5700 5380 | ::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"))
|
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"))
|
5702 5382 | );
|
5703 5383 | }
|
5704 5384 | }
|
5705 5385 |
|
5706 - | /// When a map member's value does not match the specified pattern,
|
5386 + | /// When a long member does not fit within range bounds,
|
5707 5387 | /// the response should be a 400 ValidationException.
|
5708 - | /// Test ID: RestJsonMalformedPatternMapValue_case0
|
5388 + | /// Test ID: RestJsonMalformedRangeLong_case0
|
5709 5389 | #[::tokio::test]
|
5710 5390 | #[::tracing_test::traced_test]
|
5711 - | async fn rest_json_malformed_pattern_map_value_case0_malformed_request() {
|
5391 + | async fn rest_json_malformed_range_long_case0_malformed_request() {
|
5712 5392 | {
|
5713 5393 | #[allow(unused_mut)]
|
5714 5394 | let mut http_request = ::http_1x::Request::builder()
|
5715 - | .uri("/MalformedPattern")
|
5395 + | .uri("/MalformedRange")
|
5716 5396 | .method("POST")
|
5717 5397 | .header("content-type", "application/json")
|
5718 5398 | .body(::aws_smithy_http_server::body::boxed(
|
5719 5399 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5720 5400 | &::aws_smithy_protocol_test::decode_body_data(
|
5721 - | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
5401 + | "{ \"long\" : 1 }".as_bytes(),
|
5722 5402 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5723 5403 | ),
|
5724 5404 | )),
|
5725 5405 | ))
|
5726 5406 | .unwrap();
|
5727 5407 | #[allow(unused_mut)]
|
5728 5408 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5729 5409 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5730 5410 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5731 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5411 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5732 5412 | let sender = sender.clone();
|
5733 5413 | 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> };
|
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> };
|
5735 5415 | sender.send(()).await.expect("receiver dropped early");
|
5736 5416 | result
|
5737 5417 | }
|
5738 5418 | })
|
5739 5419 | .build_unchecked();
|
5740 5420 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5741 5421 | .await
|
5742 5422 | .expect("unable to make an HTTP request");
|
5743 5423 | ::pretty_assertions::assert_eq!(
|
5744 5424 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5745 5425 | http_response.status()
|
5746 5426 | );
|
5747 5427 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5748 5428 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5749 5429 | http_response.headers(),
|
5750 5430 | expected_headers,
|
5751 5431 | ));
|
5752 5432 | use ::http_body_util::BodyExt;
|
5753 5433 | let body = http_response
|
5754 5434 | .into_body()
|
5755 5435 | .collect()
|
5756 5436 | .await
|
5757 5437 | .expect("unable to collect body")
|
5758 5438 | .to_bytes();
|
5759 5439 | ::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"))
|
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"))
|
5761 5441 | );
|
5762 5442 | }
|
5763 5443 | }
|
5764 5444 |
|
5765 - | /// When a map member's value does not match the specified pattern,
|
5445 + | /// When a long member does not fit within range bounds,
|
5766 5446 | /// the response should be a 400 ValidationException.
|
5767 - | /// Test ID: RestJsonMalformedPatternMapValue_case1
|
5447 + | /// Test ID: RestJsonMalformedRangeLong_case1
|
5768 5448 | #[::tokio::test]
|
5769 5449 | #[::tracing_test::traced_test]
|
5770 - | async fn rest_json_malformed_pattern_map_value_case1_malformed_request() {
|
5450 + | async fn rest_json_malformed_range_long_case1_malformed_request() {
|
5771 5451 | {
|
5772 5452 | #[allow(unused_mut)]
|
5773 5453 | let mut http_request = ::http_1x::Request::builder()
|
5774 - | .uri("/MalformedPattern")
|
5454 + | .uri("/MalformedRange")
|
5775 5455 | .method("POST")
|
5776 5456 | .header("content-type", "application/json")
|
5777 5457 | .body(::aws_smithy_http_server::body::boxed(
|
5778 5458 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5779 5459 | &::aws_smithy_protocol_test::decode_body_data(
|
5780 - | "{ \"map\" : { \"abc\": \"xyz\" } }".as_bytes(),
|
5460 + | "{ \"long\" : 9 }".as_bytes(),
|
5781 5461 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5782 5462 | ),
|
5783 5463 | )),
|
5784 5464 | ))
|
5785 5465 | .unwrap();
|
5786 5466 | #[allow(unused_mut)]
|
5787 5467 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5788 5468 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5789 5469 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5790 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5470 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5791 5471 | let sender = sender.clone();
|
5792 5472 | 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> };
|
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> };
|
5794 5474 | sender.send(()).await.expect("receiver dropped early");
|
5795 5475 | result
|
5796 5476 | }
|
5797 5477 | })
|
5798 5478 | .build_unchecked();
|
5799 5479 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5800 5480 | .await
|
5801 5481 | .expect("unable to make an HTTP request");
|
5802 5482 | ::pretty_assertions::assert_eq!(
|
5803 5483 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5804 5484 | http_response.status()
|
5805 5485 | );
|
5806 5486 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5807 5487 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5808 5488 | http_response.headers(),
|
5809 5489 | expected_headers,
|
5810 5490 | ));
|
5811 5491 | use ::http_body_util::BodyExt;
|
5812 5492 | let body = http_response
|
5813 5493 | .into_body()
|
5814 5494 | .collect()
|
5815 5495 | .await
|
5816 5496 | .expect("unable to collect body")
|
5817 5497 | .to_bytes();
|
5818 5498 | ::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"))
|
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"))
|
5820 5500 | );
|
5821 5501 | }
|
5822 5502 | }
|
5823 5503 |
|
5824 - | /// When a union member's value does not match the specified pattern,
|
5504 + | /// When a long member does not fit within range bounds,
|
5825 5505 | /// the response should be a 400 ValidationException.
|
5826 - | /// Test ID: RestJsonMalformedPatternUnion_case0
|
5506 + | /// Test ID: RestJsonMalformedRangeMinLong
|
5827 5507 | #[::tokio::test]
|
5828 5508 | #[::tracing_test::traced_test]
|
5829 - | async fn rest_json_malformed_pattern_union_case0_malformed_request() {
|
5509 + | async fn rest_json_malformed_range_min_long_malformed_request() {
|
5830 5510 | {
|
5831 5511 | #[allow(unused_mut)]
|
5832 5512 | let mut http_request = ::http_1x::Request::builder()
|
5833 - | .uri("/MalformedPattern")
|
5513 + | .uri("/MalformedRange")
|
5834 5514 | .method("POST")
|
5835 5515 | .header("content-type", "application/json")
|
5836 5516 | .body(::aws_smithy_http_server::body::boxed(
|
5837 5517 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5838 5518 | &::aws_smithy_protocol_test::decode_body_data(
|
5839 - | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
5519 + | "{ \"minLong\" : 1 }".as_bytes(),
|
5840 5520 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5841 5521 | ),
|
5842 5522 | )),
|
5843 5523 | ))
|
5844 5524 | .unwrap();
|
5845 5525 | #[allow(unused_mut)]
|
5846 5526 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5847 5527 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5848 5528 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5849 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5529 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5850 5530 | let sender = sender.clone();
|
5851 5531 | 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> };
|
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> };
|
5853 5533 | sender.send(()).await.expect("receiver dropped early");
|
5854 5534 | result
|
5855 5535 | }
|
5856 5536 | })
|
5857 5537 | .build_unchecked();
|
5858 5538 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5859 5539 | .await
|
5860 5540 | .expect("unable to make an HTTP request");
|
5861 5541 | ::pretty_assertions::assert_eq!(
|
5862 5542 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5863 5543 | http_response.status()
|
5864 5544 | );
|
5865 5545 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5866 5546 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5867 5547 | http_response.headers(),
|
5868 5548 | expected_headers,
|
5869 5549 | ));
|
5870 5550 | use ::http_body_util::BodyExt;
|
5871 5551 | let body = http_response
|
5872 5552 | .into_body()
|
5873 5553 | .collect()
|
5874 5554 | .await
|
5875 5555 | .expect("unable to collect body")
|
5876 5556 | .to_bytes();
|
5877 5557 | ::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"))
|
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"))
|
5879 5559 | );
|
5880 5560 | }
|
5881 5561 | }
|
5882 5562 |
|
5883 - | /// When a union member's value does not match the specified pattern,
|
5563 + | /// When a long member does not fit within range bounds,
|
5884 5564 | /// the response should be a 400 ValidationException.
|
5885 - | /// Test ID: RestJsonMalformedPatternUnion_case1
|
5565 + | /// Test ID: RestJsonMalformedRangeMaxLong
|
5886 5566 | #[::tokio::test]
|
5887 5567 | #[::tracing_test::traced_test]
|
5888 - | async fn rest_json_malformed_pattern_union_case1_malformed_request() {
|
5568 + | async fn rest_json_malformed_range_max_long_malformed_request() {
|
5889 5569 | {
|
5890 5570 | #[allow(unused_mut)]
|
5891 5571 | let mut http_request = ::http_1x::Request::builder()
|
5892 - | .uri("/MalformedPattern")
|
5572 + | .uri("/MalformedRange")
|
5893 5573 | .method("POST")
|
5894 5574 | .header("content-type", "application/json")
|
5895 5575 | .body(::aws_smithy_http_server::body::boxed(
|
5896 5576 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
5897 5577 | &::aws_smithy_protocol_test::decode_body_data(
|
5898 - | "{ \"union\" : { \"first\": \"xyz\" } }".as_bytes(),
|
5578 + | "{ \"maxLong\" : 9 }".as_bytes(),
|
5899 5579 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
5900 5580 | ),
|
5901 5581 | )),
|
5902 5582 | ))
|
5903 5583 | .unwrap();
|
5904 5584 | #[allow(unused_mut)]
|
5905 5585 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
5906 5586 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
5907 5587 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
5908 - | .malformed_pattern(move |input: crate::input::MalformedPatternInput| {
|
5588 + | .malformed_range(move |input: crate::input::MalformedRangeInput| {
|
5909 5589 | let sender = sender.clone();
|
5910 5590 | 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> };
|
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> };
|
5912 5592 | sender.send(()).await.expect("receiver dropped early");
|
5913 5593 | result
|
5914 5594 | }
|
5915 5595 | })
|
5916 5596 | .build_unchecked();
|
5917 5597 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
5918 5598 | .await
|
5919 5599 | .expect("unable to make an HTTP request");
|
5920 5600 | ::pretty_assertions::assert_eq!(
|
5921 5601 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
5922 5602 | http_response.status()
|
5923 5603 | );
|
5924 5604 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
5925 5605 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
5926 5606 | http_response.headers(),
|
5927 5607 | expected_headers,
|
5928 5608 | ));
|
5929 5609 | use ::http_body_util::BodyExt;
|
5930 5610 | let body = http_response
|
5931 5611 | .into_body()
|
5932 5612 | .collect()
|
5933 5613 | .await
|
5934 5614 | .expect("unable to collect body")
|
5935 5615 | .to_bytes();
|
5936 5616 | ::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"))
|
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"))
|
5938 5618 | );
|
5939 5619 | }
|
5940 5620 | }
|
5941 5621 | }
|
5942 5622 |
|
5943 5623 | ::pin_project_lite::pin_project! {
|
5944 5624 | /// 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>>
|
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>>
|
5948 5628 | }
|
5949 5629 | }
|
5950 5630 |
|
5951 - | impl std::future::Future for MalformedLengthQueryStringInputFuture {
|
5631 + | impl std::future::Future for MalformedRangeOverrideInputFuture {
|
5952 5632 | type Output = Result<
|
5953 - | crate::input::MalformedLengthQueryStringInput,
|
5633 + | crate::input::MalformedRangeOverrideInput,
|
5954 5634 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError,
|
5955 5635 | >;
|
5956 5636 |
|
5957 5637 | fn poll(
|
5958 5638 | self: std::pin::Pin<&mut Self>,
|
5959 5639 | cx: &mut std::task::Context<'_>,
|
5960 5640 | ) -> std::task::Poll<Self::Output> {
|
5961 5641 | let this = self.project();
|
5962 5642 | this.inner.as_mut().poll(cx)
|
5963 5643 | }
|
5964 5644 | }
|
5965 5645 |
|
5966 5646 | impl<B>
|
5967 5647 | ::aws_smithy_http_server::request::FromRequest<
|
5968 5648 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
5969 5649 | B,
|
5970 - | > for crate::input::MalformedLengthQueryStringInput
|
5650 + | > for crate::input::MalformedRangeOverrideInput
|
5971 5651 | where
|
5972 5652 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
5973 5653 | B: 'static,
|
5974 5654 |
|
5975 5655 | B::Data: Send,
|
5976 5656 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
5977 5657 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
5978 5658 | {
|
5979 5659 | type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
|
5980 - | type Future = MalformedLengthQueryStringInputFuture;
|
5660 + | type Future = MalformedRangeOverrideInputFuture;
|
5981 5661 |
|
5982 5662 | fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
|
5983 5663 | let fut = async move {
|
5984 5664 | if !::aws_smithy_http_server::protocol::accept_header_classifier(
|
5985 5665 | request.headers(),
|
5986 5666 | &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
|
5987 5667 | ) {
|
5988 5668 | return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
|
5989 5669 | }
|
5990 - | crate::protocol_serde::shape_malformed_length_query_string::de_malformed_length_query_string_http_request(request)
|
5670 + | crate::protocol_serde::shape_malformed_range_override::de_malformed_range_override_http_request(request)
|
5991 5671 | .await
|
5992 5672 | };
|
5993 5673 | use ::futures_util::future::TryFutureExt;
|
5994 5674 | let fut = fut.map_err(
|
5995 5675 | |e: ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
|
5996 5676 | ::tracing::debug!(error = %e, "failed to deserialize request");
|
5997 5677 | ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
|
5998 5678 | e,
|
5999 5679 | )
|
6000 5680 | },
|
6001 5681 | );
|
6002 - | MalformedLengthQueryStringInputFuture {
|
5682 + | MalformedRangeOverrideInputFuture {
|
6003 5683 | inner: Box::pin(fut),
|
6004 5684 | }
|
6005 5685 | }
|
6006 5686 | }
|
6007 5687 | impl
|
6008 5688 | ::aws_smithy_http_server::response::IntoResponse<
|
6009 5689 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6010 - | > for crate::output::MalformedLengthQueryStringOutput
|
5690 + | > for crate::output::MalformedRangeOverrideOutput
|
6011 5691 | {
|
6012 5692 | 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) {
|
5693 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_response(self) {
|
6014 5694 | Ok(response) => response,
|
6015 5695 | Err(e) => {
|
6016 5696 | ::tracing::error!(error = %e, "failed to serialize response");
|
6017 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))
|
6018 5698 | }
|
6019 5699 | }
|
6020 5700 | }
|
6021 5701 | }
|
6022 5702 | impl
|
6023 5703 | ::aws_smithy_http_server::response::IntoResponse<
|
6024 5704 | ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
|
6025 - | > for crate::error::MalformedLengthQueryStringError
|
5705 + | > for crate::error::MalformedRangeOverrideError
|
6026 5706 | {
|
6027 5707 | 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) {
|
5708 + | match crate::protocol_serde::shape_malformed_range_override::ser_malformed_range_override_http_error(&self) {
|
6029 5709 | Ok(mut response) => {
|
6030 5710 | response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
|
6031 5711 | response
|
6032 5712 | },
|
6033 5713 | Err(e) => {
|
6034 5714 | ::tracing::error!(error = %e, "failed to serialize response");
|
6035 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))
|
6036 5716 | }
|
6037 5717 | }
|
6038 5718 | }
|
6039 5719 | }
|
6040 5720 |
|
6041 5721 | #[allow(unreachable_code, unused_variables)]
|
6042 5722 | #[cfg(test)]
|
6043 - | mod malformed_length_query_string_test {
|
5723 + | mod malformed_range_override_test {
|
6044 5724 |
|
6045 - | /// When a required member has no value in the query string,
|
5725 + | /// When a byte member does not fit within range bounds,
|
6046 5726 | /// the response should be a 400 ValidationException.
|
6047 - | /// Test ID: RestJsonMalformedLengthQueryStringNoValue
|
5727 + | /// Test ID: RestJsonMalformedRangeByteOverride_case0
|
6048 5728 | #[::tokio::test]
|
6049 5729 | #[::tracing_test::traced_test]
|
6050 - | async fn rest_json_malformed_length_query_string_no_value_malformed_request() {
|
5730 + | async fn rest_json_malformed_range_byte_override_case0_malformed_request() {
|
6051 5731 | {
|
6052 5732 | #[allow(unused_mut)]
|
6053 5733 | let mut http_request = ::http_1x::Request::builder()
|
6054 - | .uri("/MalformedLengthQueryString")
|
5734 + | .uri("/MalformedRangeOverride")
|
6055 5735 | .method("POST")
|
5736 + | .header("content-type", "application/json")
|
6056 5737 | .body(::aws_smithy_http_server::body::boxed(
|
6057 5738 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6058 5739 | &::aws_smithy_protocol_test::decode_body_data(
|
6059 - | "{}".as_bytes(),
|
5740 + | "{ \"byte\" : 3 }".as_bytes(),
|
6060 5741 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6061 5742 | ),
|
6062 5743 | )),
|
6063 5744 | ))
|
6064 5745 | .unwrap();
|
6065 - | *http_request.uri_mut() = "/MalformedLengthQueryString?string".parse().unwrap();
|
6066 5746 | #[allow(unused_mut)]
|
6067 5747 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6068 5748 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6069 5749 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6070 - | .malformed_length_query_string(move |input: crate::input::MalformedLengthQueryStringInput| {
|
5750 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6071 5751 | let sender = sender.clone();
|
6072 5752 | 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> };
|
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> };
|
6074 5754 | sender.send(()).await.expect("receiver dropped early");
|
6075 5755 | result
|
6076 5756 | }
|
6077 5757 | })
|
6078 5758 | .build_unchecked();
|
6079 5759 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6080 5760 | .await
|
6081 5761 | .expect("unable to make an HTTP request");
|
6082 5762 | ::pretty_assertions::assert_eq!(
|
6083 5763 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6084 5764 | http_response.status()
|
6085 5765 | );
|
6086 5766 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6087 5767 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6088 5768 | http_response.headers(),
|
6089 5769 | expected_headers,
|
6090 5770 | ));
|
6091 5771 | use ::http_body_util::BodyExt;
|
6092 5772 | let body = http_response
|
6093 5773 | .into_body()
|
6094 5774 | .collect()
|
6095 5775 | .await
|
6096 5776 | .expect("unable to collect body")
|
6097 5777 | .to_bytes();
|
6098 5778 | ::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"))
|
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"))
|
6100 5780 | );
|
6101 5781 | }
|
6102 5782 | }
|
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 5783 |
|
6207 - | /// When a blob member does not fit within length bounds,
|
5784 + | /// When a byte member does not fit within range bounds,
|
6208 5785 | /// the response should be a 400 ValidationException.
|
6209 - | /// Test ID: RestJsonMalformedLengthBlobOverride_case0
|
5786 + | /// Test ID: RestJsonMalformedRangeByteOverride_case1
|
6210 5787 | #[::tokio::test]
|
6211 5788 | #[::tracing_test::traced_test]
|
6212 - | async fn rest_json_malformed_length_blob_override_case0_malformed_request() {
|
5789 + | async fn rest_json_malformed_range_byte_override_case1_malformed_request() {
|
6213 5790 | {
|
6214 5791 | #[allow(unused_mut)]
|
6215 5792 | let mut http_request = ::http_1x::Request::builder()
|
6216 - | .uri("/MalformedLengthOverride")
|
5793 + | .uri("/MalformedRangeOverride")
|
6217 5794 | .method("POST")
|
6218 5795 | .header("content-type", "application/json")
|
6219 5796 | .body(::aws_smithy_http_server::body::boxed(
|
6220 5797 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6221 5798 | &::aws_smithy_protocol_test::decode_body_data(
|
6222 - | "{ \"blob\" : \"YWJj\" }".as_bytes(),
|
5799 + | "{ \"byte\" : 7 }".as_bytes(),
|
6223 5800 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6224 5801 | ),
|
6225 5802 | )),
|
6226 5803 | ))
|
6227 5804 | .unwrap();
|
6228 5805 | #[allow(unused_mut)]
|
6229 5806 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6230 5807 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6231 5808 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6232 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5809 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6233 5810 | let sender = sender.clone();
|
6234 5811 | 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> };
|
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> };
|
6236 5813 | sender.send(()).await.expect("receiver dropped early");
|
6237 5814 | result
|
6238 5815 | }
|
6239 5816 | })
|
6240 5817 | .build_unchecked();
|
6241 5818 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6242 5819 | .await
|
6243 5820 | .expect("unable to make an HTTP request");
|
6244 5821 | ::pretty_assertions::assert_eq!(
|
6245 5822 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6246 5823 | http_response.status()
|
6247 5824 | );
|
6248 5825 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6249 5826 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6250 5827 | http_response.headers(),
|
6251 5828 | expected_headers,
|
6252 5829 | ));
|
6253 5830 | use ::http_body_util::BodyExt;
|
6254 5831 | let body = http_response
|
6255 5832 | .into_body()
|
6256 5833 | .collect()
|
6257 5834 | .await
|
6258 5835 | .expect("unable to collect body")
|
6259 5836 | .to_bytes();
|
6260 5837 | ::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"))
|
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"))
|
6262 5839 | );
|
6263 5840 | }
|
6264 5841 | }
|
6265 5842 |
|
6266 - | /// When a blob member does not fit within length bounds,
|
5843 + | /// When a byte member does not fit within range bounds,
|
6267 5844 | /// the response should be a 400 ValidationException.
|
6268 - | /// Test ID: RestJsonMalformedLengthBlobOverride_case1
|
5845 + | /// Test ID: RestJsonMalformedRangeMinByteOverride
|
6269 5846 | #[::tokio::test]
|
6270 5847 | #[::tracing_test::traced_test]
|
6271 - | async fn rest_json_malformed_length_blob_override_case1_malformed_request() {
|
5848 + | async fn rest_json_malformed_range_min_byte_override_malformed_request() {
|
6272 5849 | {
|
6273 5850 | #[allow(unused_mut)]
|
6274 5851 | let mut http_request = ::http_1x::Request::builder()
|
6275 - | .uri("/MalformedLengthOverride")
|
5852 + | .uri("/MalformedRangeOverride")
|
6276 5853 | .method("POST")
|
6277 5854 | .header("content-type", "application/json")
|
6278 5855 | .body(::aws_smithy_http_server::body::boxed(
|
6279 5856 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6280 5857 | &::aws_smithy_protocol_test::decode_body_data(
|
6281 - | "{ \"blob\" : \"YWJjZGVmZw==\" }".as_bytes(),
|
5858 + | "{ \"minByte\" : 3 }".as_bytes(),
|
6282 5859 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6283 5860 | ),
|
6284 5861 | )),
|
6285 5862 | ))
|
6286 5863 | .unwrap();
|
6287 5864 | #[allow(unused_mut)]
|
6288 5865 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6289 5866 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6290 5867 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6291 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5868 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6292 5869 | let sender = sender.clone();
|
6293 5870 | 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> };
|
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> };
|
6295 5872 | sender.send(()).await.expect("receiver dropped early");
|
6296 5873 | result
|
6297 5874 | }
|
6298 5875 | })
|
6299 5876 | .build_unchecked();
|
6300 5877 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6301 5878 | .await
|
6302 5879 | .expect("unable to make an HTTP request");
|
6303 5880 | ::pretty_assertions::assert_eq!(
|
6304 5881 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6305 5882 | http_response.status()
|
6306 5883 | );
|
6307 5884 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6308 5885 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6309 5886 | http_response.headers(),
|
6310 5887 | expected_headers,
|
6311 5888 | ));
|
6312 5889 | use ::http_body_util::BodyExt;
|
6313 5890 | let body = http_response
|
6314 5891 | .into_body()
|
6315 5892 | .collect()
|
6316 5893 | .await
|
6317 5894 | .expect("unable to collect body")
|
6318 5895 | .to_bytes();
|
6319 5896 | ::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"))
|
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"))
|
6321 5898 | );
|
6322 5899 | }
|
6323 5900 | }
|
6324 5901 |
|
6325 - | /// When a string member does not fit within length bounds,
|
5902 + | /// When a byte member does not fit within range bounds,
|
6326 5903 | /// the response should be a 400 ValidationException.
|
6327 - | /// Test ID: RestJsonMalformedLengthStringOverride_case0
|
5904 + | /// Test ID: RestJsonMalformedRangeMaxByteOverride
|
6328 5905 | #[::tokio::test]
|
6329 5906 | #[::tracing_test::traced_test]
|
6330 - | async fn rest_json_malformed_length_string_override_case0_malformed_request() {
|
5907 + | async fn rest_json_malformed_range_max_byte_override_malformed_request() {
|
6331 5908 | {
|
6332 5909 | #[allow(unused_mut)]
|
6333 5910 | let mut http_request = ::http_1x::Request::builder()
|
6334 - | .uri("/MalformedLengthOverride")
|
5911 + | .uri("/MalformedRangeOverride")
|
6335 5912 | .method("POST")
|
6336 5913 | .header("content-type", "application/json")
|
6337 5914 | .body(::aws_smithy_http_server::body::boxed(
|
6338 5915 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6339 5916 | &::aws_smithy_protocol_test::decode_body_data(
|
6340 - | "{ \"string\" : \"abc\" }".as_bytes(),
|
5917 + | "{ \"maxByte\" : 7 }".as_bytes(),
|
6341 5918 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6342 5919 | ),
|
6343 5920 | )),
|
6344 5921 | ))
|
6345 5922 | .unwrap();
|
6346 5923 | #[allow(unused_mut)]
|
6347 5924 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6348 5925 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6349 5926 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6350 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5927 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6351 5928 | let sender = sender.clone();
|
6352 5929 | 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> };
|
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> };
|
6354 5931 | sender.send(()).await.expect("receiver dropped early");
|
6355 5932 | result
|
6356 5933 | }
|
6357 5934 | })
|
6358 5935 | .build_unchecked();
|
6359 5936 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6360 5937 | .await
|
6361 5938 | .expect("unable to make an HTTP request");
|
6362 5939 | ::pretty_assertions::assert_eq!(
|
6363 5940 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6364 5941 | http_response.status()
|
6365 5942 | );
|
6366 5943 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6367 5944 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6368 5945 | http_response.headers(),
|
6369 5946 | expected_headers,
|
6370 5947 | ));
|
6371 5948 | use ::http_body_util::BodyExt;
|
6372 5949 | let body = http_response
|
6373 5950 | .into_body()
|
6374 5951 | .collect()
|
6375 5952 | .await
|
6376 5953 | .expect("unable to collect body")
|
6377 5954 | .to_bytes();
|
6378 5955 | ::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"))
|
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"))
|
6380 5957 | );
|
6381 5958 | }
|
6382 5959 | }
|
6383 5960 |
|
6384 - | /// When a string member does not fit within length bounds,
|
5961 + | /// When a float member does not fit within range bounds,
|
6385 5962 | /// the response should be a 400 ValidationException.
|
6386 - | /// Test ID: RestJsonMalformedLengthStringOverride_case1
|
5963 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case0
|
6387 5964 | #[::tokio::test]
|
6388 5965 | #[::tracing_test::traced_test]
|
6389 - | async fn rest_json_malformed_length_string_override_case1_malformed_request() {
|
5966 + | #[should_panic]
|
5967 + | async fn rest_json_malformed_range_float_override_case0_malformed_request() {
|
6390 5968 | {
|
6391 5969 | #[allow(unused_mut)]
|
6392 5970 | let mut http_request = ::http_1x::Request::builder()
|
6393 - | .uri("/MalformedLengthOverride")
|
5971 + | .uri("/MalformedRangeOverride")
|
6394 5972 | .method("POST")
|
6395 5973 | .header("content-type", "application/json")
|
6396 5974 | .body(::aws_smithy_http_server::body::boxed(
|
6397 5975 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6398 5976 | &::aws_smithy_protocol_test::decode_body_data(
|
6399 - | "{ \"string\" : \"abcdefg\" }".as_bytes(),
|
5977 + | "{ \"float\" : 4.3 }".as_bytes(),
|
6400 5978 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6401 5979 | ),
|
6402 5980 | )),
|
6403 5981 | ))
|
6404 5982 | .unwrap();
|
6405 5983 | #[allow(unused_mut)]
|
6406 5984 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6407 5985 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6408 5986 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6409 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
5987 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6410 5988 | let sender = sender.clone();
|
6411 5989 | 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> };
|
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> };
|
6413 5991 | sender.send(()).await.expect("receiver dropped early");
|
6414 5992 | result
|
6415 5993 | }
|
6416 5994 | })
|
6417 5995 | .build_unchecked();
|
6418 5996 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6419 5997 | .await
|
6420 5998 | .expect("unable to make an HTTP request");
|
6421 5999 | ::pretty_assertions::assert_eq!(
|
6422 6000 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6423 6001 | http_response.status()
|
6424 6002 | );
|
6425 6003 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6426 6004 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6427 6005 | http_response.headers(),
|
6428 6006 | expected_headers,
|
6429 6007 | ));
|
6430 6008 | use ::http_body_util::BodyExt;
|
6431 6009 | let body = http_response
|
6432 6010 | .into_body()
|
6433 6011 | .collect()
|
6434 6012 | .await
|
6435 6013 | .expect("unable to collect body")
|
6436 6014 | .to_bytes();
|
6437 6015 | ::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"))
|
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"))
|
6439 6017 | );
|
6440 6018 | }
|
6441 6019 | }
|
6442 6020 |
|
6443 - | /// When a string member does not fit within length bounds,
|
6021 + | /// When a float member does not fit within range bounds,
|
6444 6022 | /// the response should be a 400 ValidationException.
|
6445 - | /// Test ID: RestJsonMalformedLengthStringOverride_case2
|
6023 + | /// Test ID: RestJsonMalformedRangeFloatOverride_case1
|
6446 6024 | #[::tokio::test]
|
6447 6025 | #[::tracing_test::traced_test]
|
6448 - | async fn rest_json_malformed_length_string_override_case2_malformed_request() {
|
6026 + | #[should_panic]
|
6027 + | async fn rest_json_malformed_range_float_override_case1_malformed_request() {
|
6449 6028 | {
|
6450 6029 | #[allow(unused_mut)]
|
6451 6030 | let mut http_request = ::http_1x::Request::builder()
|
6452 - | .uri("/MalformedLengthOverride")
|
6031 + | .uri("/MalformedRangeOverride")
|
6453 6032 | .method("POST")
|
6454 6033 | .header("content-type", "application/json")
|
6455 6034 | .body(::aws_smithy_http_server::body::boxed(
|
6456 6035 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6457 6036 | &::aws_smithy_protocol_test::decode_body_data(
|
6458 - | "{ \"string\" : \"👍👍👍\" }".as_bytes(),
|
6037 + | "{ \"float\" : 6.7 }".as_bytes(),
|
6459 6038 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6460 6039 | ),
|
6461 6040 | )),
|
6462 6041 | ))
|
6463 6042 | .unwrap();
|
6464 6043 | #[allow(unused_mut)]
|
6465 6044 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6466 6045 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6467 6046 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6468 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6047 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6469 6048 | let sender = sender.clone();
|
6470 6049 | 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> };
|
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> };
|
6472 6051 | sender.send(()).await.expect("receiver dropped early");
|
6473 6052 | result
|
6474 6053 | }
|
6475 6054 | })
|
6476 6055 | .build_unchecked();
|
6477 6056 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6478 6057 | .await
|
6479 6058 | .expect("unable to make an HTTP request");
|
6480 6059 | ::pretty_assertions::assert_eq!(
|
6481 6060 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6482 6061 | http_response.status()
|
6483 6062 | );
|
6484 6063 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6485 6064 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6486 6065 | http_response.headers(),
|
6487 6066 | expected_headers,
|
6488 6067 | ));
|
6489 6068 | use ::http_body_util::BodyExt;
|
6490 6069 | let body = http_response
|
6491 6070 | .into_body()
|
6492 6071 | .collect()
|
6493 6072 | .await
|
6494 6073 | .expect("unable to collect body")
|
6495 6074 | .to_bytes();
|
6496 6075 | ::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"))
|
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"))
|
6498 6077 | );
|
6499 6078 | }
|
6500 6079 | }
|
6501 6080 |
|
6502 - | /// When a string member does not fit within length bounds,
|
6081 + | /// When a float member does not fit within range bounds,
|
6503 6082 | /// the response should be a 400 ValidationException.
|
6504 - | /// Test ID: RestJsonMalformedLengthMinStringOverride
|
6083 + | /// Test ID: RestJsonMalformedRangeMinFloatOverride
|
6505 6084 | #[::tokio::test]
|
6506 6085 | #[::tracing_test::traced_test]
|
6507 - | async fn rest_json_malformed_length_min_string_override_malformed_request() {
|
6086 + | #[should_panic]
|
6087 + | async fn rest_json_malformed_range_min_float_override_malformed_request() {
|
6508 6088 | {
|
6509 6089 | #[allow(unused_mut)]
|
6510 6090 | let mut http_request = ::http_1x::Request::builder()
|
6511 - | .uri("/MalformedLengthOverride")
|
6091 + | .uri("/MalformedRangeOverride")
|
6512 6092 | .method("POST")
|
6513 6093 | .header("content-type", "application/json")
|
6514 6094 | .body(::aws_smithy_http_server::body::boxed(
|
6515 6095 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6516 6096 | &::aws_smithy_protocol_test::decode_body_data(
|
6517 - | "{ \"minString\" : \"abc\" }".as_bytes(),
|
6097 + | "{ \"minFloat\" : 4.3 }".as_bytes(),
|
6518 6098 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6519 6099 | ),
|
6520 6100 | )),
|
6521 6101 | ))
|
6522 6102 | .unwrap();
|
6523 6103 | #[allow(unused_mut)]
|
6524 6104 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6525 6105 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6526 6106 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6527 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6107 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6528 6108 | let sender = sender.clone();
|
6529 6109 | 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> };
|
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> };
|
6531 6111 | sender.send(()).await.expect("receiver dropped early");
|
6532 6112 | result
|
6533 6113 | }
|
6534 6114 | })
|
6535 6115 | .build_unchecked();
|
6536 6116 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6537 6117 | .await
|
6538 6118 | .expect("unable to make an HTTP request");
|
6539 6119 | ::pretty_assertions::assert_eq!(
|
6540 6120 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6541 6121 | http_response.status()
|
6542 6122 | );
|
6543 6123 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6544 6124 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6545 6125 | http_response.headers(),
|
6546 6126 | expected_headers,
|
6547 6127 | ));
|
6548 6128 | use ::http_body_util::BodyExt;
|
6549 6129 | let body = http_response
|
6550 6130 | .into_body()
|
6551 6131 | .collect()
|
6552 6132 | .await
|
6553 6133 | .expect("unable to collect body")
|
6554 6134 | .to_bytes();
|
6555 6135 | ::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"))
|
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"))
|
6557 6137 | );
|
6558 6138 | }
|
6559 6139 | }
|
6560 6140 |
|
6561 - | /// When a string member does not fit within length bounds,
|
6141 + | /// When a float member does not fit within range bounds,
|
6562 6142 | /// the response should be a 400 ValidationException.
|
6563 - | /// Test ID: RestJsonMalformedLengthMaxStringOverride
|
6143 + | /// Test ID: RestJsonMalformedRangeMaxFloatOverride
|
6564 6144 | #[::tokio::test]
|
6565 6145 | #[::tracing_test::traced_test]
|
6566 - | async fn rest_json_malformed_length_max_string_override_malformed_request() {
|
6146 + | #[should_panic]
|
6147 + | async fn rest_json_malformed_range_max_float_override_malformed_request() {
|
6567 6148 | {
|
6568 6149 | #[allow(unused_mut)]
|
6569 6150 | let mut http_request = ::http_1x::Request::builder()
|
6570 - | .uri("/MalformedLengthOverride")
|
6151 + | .uri("/MalformedRangeOverride")
|
6571 6152 | .method("POST")
|
6572 6153 | .header("content-type", "application/json")
|
6573 6154 | .body(::aws_smithy_http_server::body::boxed(
|
6574 6155 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6575 6156 | &::aws_smithy_protocol_test::decode_body_data(
|
6576 - | "{ \"maxString\" : \"abcdefg\" }".as_bytes(),
|
6157 + | "{ \"maxFloat\" : 6.7 }".as_bytes(),
|
6577 6158 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6578 6159 | ),
|
6579 6160 | )),
|
6580 6161 | ))
|
6581 6162 | .unwrap();
|
6582 6163 | #[allow(unused_mut)]
|
6583 6164 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6584 6165 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6585 6166 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6586 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6167 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6587 6168 | let sender = sender.clone();
|
6588 6169 | 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> };
|
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> };
|
6590 6171 | sender.send(()).await.expect("receiver dropped early");
|
6591 6172 | result
|
6592 6173 | }
|
6593 6174 | })
|
6594 6175 | .build_unchecked();
|
6595 6176 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6596 6177 | .await
|
6597 6178 | .expect("unable to make an HTTP request");
|
6598 6179 | ::pretty_assertions::assert_eq!(
|
6599 6180 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6600 6181 | http_response.status()
|
6601 6182 | );
|
6602 6183 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6603 6184 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6604 6185 | http_response.headers(),
|
6605 6186 | expected_headers,
|
6606 6187 | ));
|
6607 6188 | use ::http_body_util::BodyExt;
|
6608 6189 | let body = http_response
|
6609 6190 | .into_body()
|
6610 6191 | .collect()
|
6611 6192 | .await
|
6612 6193 | .expect("unable to collect body")
|
6613 6194 | .to_bytes();
|
6614 6195 | ::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"))
|
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"))
|
6616 6197 | );
|
6617 6198 | }
|
6618 6199 | }
|
6619 6200 |
|
6620 - | /// When a list member does not fit within length bounds,
|
6201 + | /// When a short member does not fit within range bounds,
|
6621 6202 | /// the response should be a 400 ValidationException.
|
6622 - | /// Test ID: RestJsonMalformedLengthListOverride_case0
|
6203 + | /// Test ID: RestJsonMalformedRangeShortOverride_case0
|
6623 6204 | #[::tokio::test]
|
6624 6205 | #[::tracing_test::traced_test]
|
6625 - | async fn rest_json_malformed_length_list_override_case0_malformed_request() {
|
6206 + | async fn rest_json_malformed_range_short_override_case0_malformed_request() {
|
6626 6207 | {
|
6627 6208 | #[allow(unused_mut)]
|
6628 6209 | let mut http_request = ::http_1x::Request::builder()
|
6629 - | .uri("/MalformedLengthOverride")
|
6210 + | .uri("/MalformedRangeOverride")
|
6630 6211 | .method("POST")
|
6631 6212 | .header("content-type", "application/json")
|
6632 6213 | .body(::aws_smithy_http_server::body::boxed(
|
6633 6214 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6634 6215 | &::aws_smithy_protocol_test::decode_body_data(
|
6635 - | "{ \"list\" : [\"abc\", \"def\", \"ghi\"] }".as_bytes(),
|
6216 + | "{ \"short\" : 3 }".as_bytes(),
|
6636 6217 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6637 6218 | ),
|
6638 6219 | )),
|
6639 6220 | ))
|
6640 6221 | .unwrap();
|
6641 6222 | #[allow(unused_mut)]
|
6642 6223 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6643 6224 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6644 6225 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6645 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6226 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6646 6227 | let sender = sender.clone();
|
6647 6228 | 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> };
|
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> };
|
6649 6230 | sender.send(()).await.expect("receiver dropped early");
|
6650 6231 | result
|
6651 6232 | }
|
6652 6233 | })
|
6653 6234 | .build_unchecked();
|
6654 6235 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6655 6236 | .await
|
6656 6237 | .expect("unable to make an HTTP request");
|
6657 6238 | ::pretty_assertions::assert_eq!(
|
6658 6239 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6659 6240 | http_response.status()
|
6660 6241 | );
|
6661 6242 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6662 6243 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6663 6244 | http_response.headers(),
|
6664 6245 | expected_headers,
|
6665 6246 | ));
|
6666 6247 | use ::http_body_util::BodyExt;
|
6667 6248 | let body = http_response
|
6668 6249 | .into_body()
|
6669 6250 | .collect()
|
6670 6251 | .await
|
6671 6252 | .expect("unable to collect body")
|
6672 6253 | .to_bytes();
|
6673 6254 | ::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"))
|
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"))
|
6675 6256 | );
|
6676 6257 | }
|
6677 6258 | }
|
6678 6259 |
|
6679 - | /// When a list member does not fit within length bounds,
|
6260 + | /// When a short member does not fit within range bounds,
|
6680 6261 | /// the response should be a 400 ValidationException.
|
6681 - | /// Test ID: RestJsonMalformedLengthListOverride_case1
|
6262 + | /// Test ID: RestJsonMalformedRangeShortOverride_case1
|
6682 6263 | #[::tokio::test]
|
6683 6264 | #[::tracing_test::traced_test]
|
6684 - | async fn rest_json_malformed_length_list_override_case1_malformed_request() {
|
6265 + | async fn rest_json_malformed_range_short_override_case1_malformed_request() {
|
6685 6266 | {
|
6686 6267 | #[allow(unused_mut)]
|
6687 - | let mut http_request = ::http_1x::Request::builder()
|
6688 - | .uri("/MalformedLengthOverride")
|
6689 - | .method("POST")
|
6690 - | .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| {
|
6268 + | let mut http_request = ::http_1x::Request::builder()
|
6269 + | .uri("/MalformedRangeOverride")
|
6270 + | .method("POST")
|
6271 + | .header("content-type", "application/json")
|
6272 + | .body(::aws_smithy_http_server::body::boxed(
|
6273 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6274 + | &::aws_smithy_protocol_test::decode_body_data(
|
6275 + | "{ \"short\" : 7 }".as_bytes(),
|
6276 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6277 + | ),
|
6278 + | )),
|
6279 + | ))
|
6280 + | .unwrap();
|
6281 + | #[allow(unused_mut)]
|
6282 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6283 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6284 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6285 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6701 6286 | let sender = sender.clone();
|
6702 6287 | 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> };
|
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> };
|
6704 6289 | sender.send(()).await.expect("receiver dropped early");
|
6705 6290 | result
|
6706 6291 | }
|
6707 6292 | })
|
6708 6293 | .build_unchecked();
|
6709 6294 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6710 6295 | .await
|
6711 6296 | .expect("unable to make an HTTP request");
|
6712 6297 | ::pretty_assertions::assert_eq!(
|
6713 6298 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6714 6299 | http_response.status()
|
6715 6300 | );
|
6716 6301 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6717 6302 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6718 6303 | http_response.headers(),
|
6719 6304 | expected_headers,
|
6720 6305 | ));
|
6721 6306 | use ::http_body_util::BodyExt;
|
6722 6307 | let body = http_response
|
6723 6308 | .into_body()
|
6724 6309 | .collect()
|
6725 6310 | .await
|
6726 6311 | .expect("unable to collect body")
|
6727 6312 | .to_bytes();
|
6728 6313 | ::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"))
|
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"))
|
6730 6315 | );
|
6731 6316 | }
|
6732 6317 | }
|
6733 6318 |
|
6734 - | /// When a map member does not fit within length bounds,
|
6319 + | /// When a short member does not fit within range bounds,
|
6735 6320 | /// the response should be a 400 ValidationException.
|
6736 - | /// Test ID: RestJsonMalformedLengthMapOverride_case0
|
6321 + | /// Test ID: RestJsonMalformedRangeMinShortOverride
|
6737 6322 | #[::tokio::test]
|
6738 6323 | #[::tracing_test::traced_test]
|
6739 - | async fn rest_json_malformed_length_map_override_case0_malformed_request() {
|
6324 + | async fn rest_json_malformed_range_min_short_override_malformed_request() {
|
6740 6325 | {
|
6741 6326 | #[allow(unused_mut)]
|
6742 - | let mut http_request = ::http_1x::Request::builder()
|
6743 - | .uri("/MalformedLengthOverride")
|
6744 - | .method("POST")
|
6745 - | .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();
|
6327 + | let mut http_request = ::http_1x::Request::builder()
|
6328 + | .uri("/MalformedRangeOverride")
|
6329 + | .method("POST")
|
6330 + | .header("content-type", "application/json")
|
6331 + | .body(::aws_smithy_http_server::body::boxed(
|
6332 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6333 + | &::aws_smithy_protocol_test::decode_body_data(
|
6334 + | "{ \"minShort\" : 3 }".as_bytes(),
|
6335 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6336 + | ),
|
6337 + | )),
|
6338 + | ))
|
6339 + | .unwrap();
|
6751 6340 | #[allow(unused_mut)]
|
6752 6341 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6753 6342 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6754 6343 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6755 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6344 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6756 6345 | let sender = sender.clone();
|
6757 6346 | 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> };
|
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> };
|
6759 6348 | sender.send(()).await.expect("receiver dropped early");
|
6760 6349 | result
|
6761 6350 | }
|
6762 6351 | })
|
6763 6352 | .build_unchecked();
|
6764 6353 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6765 6354 | .await
|
6766 6355 | .expect("unable to make an HTTP request");
|
6767 6356 | ::pretty_assertions::assert_eq!(
|
6768 6357 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6769 6358 | http_response.status()
|
6770 6359 | );
|
6771 6360 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6772 6361 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6773 6362 | http_response.headers(),
|
6774 6363 | expected_headers,
|
6775 6364 | ));
|
6776 6365 | use ::http_body_util::BodyExt;
|
6777 6366 | let body = http_response
|
6778 6367 | .into_body()
|
6779 6368 | .collect()
|
6780 6369 | .await
|
6781 6370 | .expect("unable to collect body")
|
6782 6371 | .to_bytes();
|
6783 6372 | ::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"))
|
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"))
|
6785 6374 | );
|
6786 6375 | }
|
6787 6376 | }
|
6788 6377 |
|
6789 - | /// When a map member does not fit within length bounds,
|
6378 + | /// When a short member does not fit within range bounds,
|
6790 6379 | /// the response should be a 400 ValidationException.
|
6791 - | /// Test ID: RestJsonMalformedLengthMapOverride_case1
|
6380 + | /// Test ID: RestJsonMalformedRangeMaxShortOverride
|
6792 6381 | #[::tokio::test]
|
6793 6382 | #[::tracing_test::traced_test]
|
6794 - | async fn rest_json_malformed_length_map_override_case1_malformed_request() {
|
6383 + | async fn rest_json_malformed_range_max_short_override_malformed_request() {
|
6795 6384 | {
|
6796 6385 | #[allow(unused_mut)]
|
6797 - | let mut http_request = ::http_1x::Request::builder()
|
6798 - | .uri("/MalformedLengthOverride")
|
6799 - | .method("POST")
|
6800 - | .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();
|
6386 + | let mut http_request = ::http_1x::Request::builder()
|
6387 + | .uri("/MalformedRangeOverride")
|
6388 + | .method("POST")
|
6389 + | .header("content-type", "application/json")
|
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();
|
6806 6399 | #[allow(unused_mut)]
|
6807 6400 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6808 6401 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6809 6402 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6810 - | .malformed_length_override(move |input: crate::input::MalformedLengthOverrideInput| {
|
6403 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6811 6404 | let sender = sender.clone();
|
6812 6405 | 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> };
|
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> };
|
6814 6407 | sender.send(()).await.expect("receiver dropped early");
|
6815 6408 | result
|
6816 6409 | }
|
6817 6410 | })
|
6818 6411 | .build_unchecked();
|
6819 6412 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6820 6413 | .await
|
6821 6414 | .expect("unable to make an HTTP request");
|
6822 6415 | ::pretty_assertions::assert_eq!(
|
6823 6416 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6824 6417 | http_response.status()
|
6825 6418 | );
|
6826 6419 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6827 6420 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6828 6421 | http_response.headers(),
|
6829 6422 | expected_headers,
|
6830 6423 | ));
|
6831 6424 | use ::http_body_util::BodyExt;
|
6832 6425 | let body = http_response
|
6833 6426 | .into_body()
|
6834 6427 | .collect()
|
6835 6428 | .await
|
6836 6429 | .expect("unable to collect body")
|
6837 6430 | .to_bytes();
|
6838 6431 | ::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"))
|
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"))
|
6840 6433 | );
|
6841 6434 | }
|
6842 6435 | }
|
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()),
|
6937 - | );
|
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 - | }
|
6945 - | }
|
6946 - | }
|
6947 - |
|
6948 - | #[allow(unreachable_code, unused_variables)]
|
6949 - | #[cfg(test)]
|
6950 - | mod malformed_length_test {
|
6951 6436 |
|
6952 - | /// When a blob member does not fit within length bounds,
|
6437 + | /// When a integer member does not fit within range bounds,
|
6953 6438 | /// the response should be a 400 ValidationException.
|
6954 - | /// Test ID: RestJsonMalformedLengthBlob_case0
|
6439 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case0
|
6955 6440 | #[::tokio::test]
|
6956 6441 | #[::tracing_test::traced_test]
|
6957 - | async fn rest_json_malformed_length_blob_case0_malformed_request() {
|
6442 + | async fn rest_json_malformed_range_integer_override_case0_malformed_request() {
|
6958 6443 | {
|
6959 6444 | #[allow(unused_mut)]
|
6960 6445 | let mut http_request = ::http_1x::Request::builder()
|
6961 - | .uri("/MalformedLength")
|
6446 + | .uri("/MalformedRangeOverride")
|
6962 6447 | .method("POST")
|
6963 6448 | .header("content-type", "application/json")
|
6964 6449 | .body(::aws_smithy_http_server::body::boxed(
|
6965 6450 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
6966 6451 | &::aws_smithy_protocol_test::decode_body_data(
|
6967 - | "{ \"blob\" : \"YQ==\" }".as_bytes(),
|
6452 + | "{ \"integer\" : 3 }".as_bytes(),
|
6968 6453 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
6969 6454 | ),
|
6970 6455 | )),
|
6971 6456 | ))
|
6972 6457 | .unwrap();
|
6973 6458 | #[allow(unused_mut)]
|
6974 6459 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
6975 6460 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
6976 6461 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
6977 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6462 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
6978 6463 | let sender = sender.clone();
|
6979 6464 | 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> };
|
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> };
|
6981 6466 | sender.send(()).await.expect("receiver dropped early");
|
6982 6467 | result
|
6983 6468 | }
|
6984 6469 | })
|
6985 6470 | .build_unchecked();
|
6986 6471 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
6987 6472 | .await
|
6988 6473 | .expect("unable to make an HTTP request");
|
6989 6474 | ::pretty_assertions::assert_eq!(
|
6990 6475 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
6991 6476 | http_response.status()
|
6992 6477 | );
|
6993 6478 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
6994 6479 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
6995 6480 | http_response.headers(),
|
6996 6481 | expected_headers,
|
6997 6482 | ));
|
6998 6483 | use ::http_body_util::BodyExt;
|
6999 6484 | let body = http_response
|
7000 6485 | .into_body()
|
7001 6486 | .collect()
|
7002 6487 | .await
|
7003 6488 | .expect("unable to collect body")
|
7004 6489 | .to_bytes();
|
7005 6490 | ::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"))
|
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"))
|
7007 6492 | );
|
7008 6493 | }
|
7009 6494 | }
|
7010 6495 |
|
7011 - | /// When a blob member does not fit within length bounds,
|
6496 + | /// When a integer member does not fit within range bounds,
|
7012 6497 | /// the response should be a 400 ValidationException.
|
7013 - | /// Test ID: RestJsonMalformedLengthBlob_case1
|
6498 + | /// Test ID: RestJsonMalformedRangeIntegerOverride_case1
|
7014 6499 | #[::tokio::test]
|
7015 6500 | #[::tracing_test::traced_test]
|
7016 - | async fn rest_json_malformed_length_blob_case1_malformed_request() {
|
6501 + | async fn rest_json_malformed_range_integer_override_case1_malformed_request() {
|
7017 6502 | {
|
7018 6503 | #[allow(unused_mut)]
|
7019 6504 | let mut http_request = ::http_1x::Request::builder()
|
7020 - | .uri("/MalformedLength")
|
6505 + | .uri("/MalformedRangeOverride")
|
7021 6506 | .method("POST")
|
7022 6507 | .header("content-type", "application/json")
|
7023 6508 | .body(::aws_smithy_http_server::body::boxed(
|
7024 6509 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7025 6510 | &::aws_smithy_protocol_test::decode_body_data(
|
7026 - | "{ \"blob\" : \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" }".as_bytes(),
|
6511 + | "{ \"integer\" : 7 }".as_bytes(),
|
7027 6512 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7028 6513 | ),
|
7029 6514 | )),
|
7030 6515 | ))
|
7031 6516 | .unwrap();
|
7032 6517 | #[allow(unused_mut)]
|
7033 6518 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7034 6519 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7035 6520 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7036 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6521 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7037 6522 | let sender = sender.clone();
|
7038 6523 | 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> };
|
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> };
|
7040 6525 | sender.send(()).await.expect("receiver dropped early");
|
7041 6526 | result
|
7042 6527 | }
|
7043 6528 | })
|
7044 6529 | .build_unchecked();
|
7045 6530 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7046 6531 | .await
|
7047 6532 | .expect("unable to make an HTTP request");
|
7048 6533 | ::pretty_assertions::assert_eq!(
|
7049 6534 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7050 6535 | http_response.status()
|
7051 6536 | );
|
7052 6537 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7053 6538 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7054 6539 | http_response.headers(),
|
7055 6540 | expected_headers,
|
7056 6541 | ));
|
7057 6542 | use ::http_body_util::BodyExt;
|
7058 6543 | let body = http_response
|
7059 6544 | .into_body()
|
7060 6545 | .collect()
|
7061 6546 | .await
|
7062 6547 | .expect("unable to collect body")
|
7063 6548 | .to_bytes();
|
7064 6549 | ::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"))
|
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"))
|
7066 6551 | );
|
7067 6552 | }
|
7068 6553 | }
|
7069 6554 |
|
7070 - | /// When a string member does not fit within length bounds,
|
6555 + | /// When a integer member does not fit within range bounds,
|
7071 6556 | /// the response should be a 400 ValidationException.
|
7072 - | /// Test ID: RestJsonMalformedLengthString_case0
|
6557 + | /// Test ID: RestJsonMalformedRangeMinIntegerOverride
|
7073 6558 | #[::tokio::test]
|
7074 6559 | #[::tracing_test::traced_test]
|
7075 - | async fn rest_json_malformed_length_string_case0_malformed_request() {
|
6560 + | async fn rest_json_malformed_range_min_integer_override_malformed_request() {
|
7076 6561 | {
|
7077 6562 | #[allow(unused_mut)]
|
7078 6563 | let mut http_request = ::http_1x::Request::builder()
|
7079 - | .uri("/MalformedLength")
|
6564 + | .uri("/MalformedRangeOverride")
|
7080 6565 | .method("POST")
|
7081 6566 | .header("content-type", "application/json")
|
7082 6567 | .body(::aws_smithy_http_server::body::boxed(
|
7083 6568 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7084 6569 | &::aws_smithy_protocol_test::decode_body_data(
|
7085 - | "{ \"string\" : \"a\" }".as_bytes(),
|
6570 + | "{ \"minInteger\" : 3 }".as_bytes(),
|
7086 6571 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7087 6572 | ),
|
7088 6573 | )),
|
7089 6574 | ))
|
7090 6575 | .unwrap();
|
7091 6576 | #[allow(unused_mut)]
|
7092 6577 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7093 6578 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7094 6579 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7095 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6580 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7096 6581 | let sender = sender.clone();
|
7097 6582 | 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> };
|
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> };
|
7099 6584 | sender.send(()).await.expect("receiver dropped early");
|
7100 6585 | result
|
7101 6586 | }
|
7102 6587 | })
|
7103 6588 | .build_unchecked();
|
7104 6589 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7105 6590 | .await
|
7106 6591 | .expect("unable to make an HTTP request");
|
7107 6592 | ::pretty_assertions::assert_eq!(
|
7108 6593 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7109 6594 | http_response.status()
|
7110 6595 | );
|
7111 6596 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7112 6597 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7113 6598 | http_response.headers(),
|
7114 6599 | expected_headers,
|
7115 6600 | ));
|
7116 6601 | use ::http_body_util::BodyExt;
|
7117 6602 | let body = http_response
|
7118 6603 | .into_body()
|
7119 6604 | .collect()
|
7120 6605 | .await
|
7121 6606 | .expect("unable to collect body")
|
7122 6607 | .to_bytes();
|
7123 6608 | ::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"))
|
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"))
|
7125 6610 | );
|
7126 6611 | }
|
7127 6612 | }
|
7128 6613 |
|
7129 - | /// When a string member does not fit within length bounds,
|
6614 + | /// When a integer member does not fit within range bounds,
|
7130 6615 | /// the response should be a 400 ValidationException.
|
7131 - | /// Test ID: RestJsonMalformedLengthString_case1
|
6616 + | /// Test ID: RestJsonMalformedRangeMaxIntegerOverride
|
7132 6617 | #[::tokio::test]
|
7133 6618 | #[::tracing_test::traced_test]
|
7134 - | async fn rest_json_malformed_length_string_case1_malformed_request() {
|
6619 + | async fn rest_json_malformed_range_max_integer_override_malformed_request() {
|
7135 6620 | {
|
7136 6621 | #[allow(unused_mut)]
|
7137 6622 | let mut http_request = ::http_1x::Request::builder()
|
7138 - | .uri("/MalformedLength")
|
6623 + | .uri("/MalformedRangeOverride")
|
7139 6624 | .method("POST")
|
7140 6625 | .header("content-type", "application/json")
|
7141 6626 | .body(::aws_smithy_http_server::body::boxed(
|
7142 6627 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7143 6628 | &::aws_smithy_protocol_test::decode_body_data(
|
7144 - | "{ \"string\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
6629 + | "{ \"maxInteger\" : 7 }".as_bytes(),
|
7145 6630 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7146 6631 | ),
|
7147 6632 | )),
|
7148 6633 | ))
|
7149 6634 | .unwrap();
|
7150 6635 | #[allow(unused_mut)]
|
7151 6636 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7152 6637 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7153 6638 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7154 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6639 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7155 6640 | let sender = sender.clone();
|
7156 6641 | 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> };
|
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> };
|
7158 6643 | sender.send(()).await.expect("receiver dropped early");
|
7159 6644 | result
|
7160 6645 | }
|
7161 6646 | })
|
7162 6647 | .build_unchecked();
|
7163 6648 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7164 6649 | .await
|
7165 6650 | .expect("unable to make an HTTP request");
|
7166 6651 | ::pretty_assertions::assert_eq!(
|
7167 6652 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7168 6653 | http_response.status()
|
7169 6654 | );
|
7170 6655 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7171 6656 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7172 6657 | http_response.headers(),
|
7173 6658 | expected_headers,
|
7174 6659 | ));
|
7175 6660 | use ::http_body_util::BodyExt;
|
7176 6661 | let body = http_response
|
7177 6662 | .into_body()
|
7178 6663 | .collect()
|
7179 6664 | .await
|
7180 6665 | .expect("unable to collect body")
|
7181 6666 | .to_bytes();
|
7182 6667 | ::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"))
|
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"))
|
7184 6669 | );
|
7185 6670 | }
|
7186 6671 | }
|
7187 6672 |
|
7188 - | /// When a string member does not fit within length bounds,
|
6673 + | /// When a long member does not fit within range bounds,
|
7189 6674 | /// the response should be a 400 ValidationException.
|
7190 - | /// Test ID: RestJsonMalformedLengthString_case2
|
6675 + | /// Test ID: RestJsonMalformedRangeLongOverride_case0
|
7191 6676 | #[::tokio::test]
|
7192 6677 | #[::tracing_test::traced_test]
|
7193 - | async fn rest_json_malformed_length_string_case2_malformed_request() {
|
6678 + | async fn rest_json_malformed_range_long_override_case0_malformed_request() {
|
7194 6679 | {
|
7195 6680 | #[allow(unused_mut)]
|
7196 6681 | let mut http_request = ::http_1x::Request::builder()
|
7197 - | .uri("/MalformedLength")
|
6682 + | .uri("/MalformedRangeOverride")
|
7198 6683 | .method("POST")
|
7199 6684 | .header("content-type", "application/json")
|
7200 6685 | .body(::aws_smithy_http_server::body::boxed(
|
7201 6686 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7202 6687 | &::aws_smithy_protocol_test::decode_body_data(
|
7203 - | "{ \"string\" : \"👍\" }".as_bytes(),
|
6688 + | "{ \"long\" : 3 }".as_bytes(),
|
7204 6689 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7205 6690 | ),
|
7206 6691 | )),
|
7207 6692 | ))
|
7208 6693 | .unwrap();
|
7209 6694 | #[allow(unused_mut)]
|
7210 6695 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7211 6696 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7212 6697 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7213 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6698 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7214 6699 | let sender = sender.clone();
|
7215 6700 | 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> };
|
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> };
|
7217 6702 | sender.send(()).await.expect("receiver dropped early");
|
7218 6703 | result
|
7219 6704 | }
|
7220 6705 | })
|
7221 6706 | .build_unchecked();
|
7222 6707 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7223 6708 | .await
|
7224 6709 | .expect("unable to make an HTTP request");
|
7225 6710 | ::pretty_assertions::assert_eq!(
|
7226 6711 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7227 6712 | http_response.status()
|
7228 6713 | );
|
7229 6714 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7230 6715 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7231 6716 | http_response.headers(),
|
7232 6717 | expected_headers,
|
7233 6718 | ));
|
7234 6719 | use ::http_body_util::BodyExt;
|
7235 6720 | let body = http_response
|
7236 6721 | .into_body()
|
7237 6722 | .collect()
|
7238 6723 | .await
|
7239 6724 | .expect("unable to collect body")
|
7240 6725 | .to_bytes();
|
7241 6726 | ::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"))
|
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"))
|
7243 6728 | );
|
7244 6729 | }
|
7245 6730 | }
|
7246 6731 |
|
7247 - | /// When a string member does not fit within length bounds,
|
6732 + | /// When a long member does not fit within range bounds,
|
7248 6733 | /// the response should be a 400 ValidationException.
|
7249 - | /// Test ID: RestJsonMalformedLengthMinString
|
6734 + | /// Test ID: RestJsonMalformedRangeLongOverride_case1
|
7250 6735 | #[::tokio::test]
|
7251 6736 | #[::tracing_test::traced_test]
|
7252 - | async fn rest_json_malformed_length_min_string_malformed_request() {
|
6737 + | async fn rest_json_malformed_range_long_override_case1_malformed_request() {
|
7253 6738 | {
|
7254 6739 | #[allow(unused_mut)]
|
7255 6740 | let mut http_request = ::http_1x::Request::builder()
|
7256 - | .uri("/MalformedLength")
|
6741 + | .uri("/MalformedRangeOverride")
|
7257 6742 | .method("POST")
|
7258 6743 | .header("content-type", "application/json")
|
7259 6744 | .body(::aws_smithy_http_server::body::boxed(
|
7260 6745 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7261 6746 | &::aws_smithy_protocol_test::decode_body_data(
|
7262 - | "{ \"minString\" : \"a\" }".as_bytes(),
|
6747 + | "{ \"long\" : 7 }".as_bytes(),
|
7263 6748 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7264 6749 | ),
|
7265 6750 | )),
|
7266 6751 | ))
|
7267 6752 | .unwrap();
|
7268 6753 | #[allow(unused_mut)]
|
7269 6754 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7270 6755 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7271 6756 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7272 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6757 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7273 6758 | let sender = sender.clone();
|
7274 6759 | 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> };
|
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> };
|
7276 6761 | sender.send(()).await.expect("receiver dropped early");
|
7277 6762 | result
|
7278 6763 | }
|
7279 6764 | })
|
7280 6765 | .build_unchecked();
|
7281 6766 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7282 6767 | .await
|
7283 6768 | .expect("unable to make an HTTP request");
|
7284 6769 | ::pretty_assertions::assert_eq!(
|
7285 6770 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7286 6771 | http_response.status()
|
7287 6772 | );
|
7288 6773 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7289 6774 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7290 6775 | http_response.headers(),
|
7291 6776 | expected_headers,
|
7292 6777 | ));
|
7293 6778 | use ::http_body_util::BodyExt;
|
7294 6779 | let body = http_response
|
7295 6780 | .into_body()
|
7296 6781 | .collect()
|
7297 6782 | .await
|
7298 6783 | .expect("unable to collect body")
|
7299 6784 | .to_bytes();
|
7300 6785 | ::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"))
|
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"))
|
7302 6787 | );
|
7303 6788 | }
|
7304 6789 | }
|
7305 6790 |
|
7306 - | /// When a string member does not fit within length bounds,
|
6791 + | /// When a long member does not fit within range bounds,
|
7307 6792 | /// the response should be a 400 ValidationException.
|
7308 - | /// Test ID: RestJsonMalformedLengthMaxString
|
6793 + | /// Test ID: RestJsonMalformedRangeMinLongOverride
|
7309 6794 | #[::tokio::test]
|
7310 6795 | #[::tracing_test::traced_test]
|
7311 - | async fn rest_json_malformed_length_max_string_malformed_request() {
|
6796 + | async fn rest_json_malformed_range_min_long_override_malformed_request() {
|
7312 6797 | {
|
7313 6798 | #[allow(unused_mut)]
|
7314 6799 | let mut http_request = ::http_1x::Request::builder()
|
7315 - | .uri("/MalformedLength")
|
6800 + | .uri("/MalformedRangeOverride")
|
7316 6801 | .method("POST")
|
7317 6802 | .header("content-type", "application/json")
|
7318 6803 | .body(::aws_smithy_http_server::body::boxed(
|
7319 6804 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7320 6805 | &::aws_smithy_protocol_test::decode_body_data(
|
7321 - | "{ \"maxString\" : \"abcdefghijklmnopqrstuvwxyz\" }".as_bytes(),
|
6806 + | "{ \"minLong\" : 3 }".as_bytes(),
|
7322 6807 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7323 6808 | ),
|
7324 6809 | )),
|
7325 6810 | ))
|
7326 6811 | .unwrap();
|
7327 6812 | #[allow(unused_mut)]
|
7328 6813 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7329 6814 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7330 6815 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7331 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6816 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7332 6817 | let sender = sender.clone();
|
7333 6818 | 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> };
|
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> };
|
7335 6820 | sender.send(()).await.expect("receiver dropped early");
|
7336 6821 | result
|
7337 6822 | }
|
7338 6823 | })
|
7339 6824 | .build_unchecked();
|
7340 6825 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7341 6826 | .await
|
7342 6827 | .expect("unable to make an HTTP request");
|
7343 6828 | ::pretty_assertions::assert_eq!(
|
7344 6829 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7345 6830 | http_response.status()
|
7346 6831 | );
|
7347 6832 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7348 6833 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7349 6834 | http_response.headers(),
|
7350 6835 | expected_headers,
|
7351 6836 | ));
|
7352 6837 | use ::http_body_util::BodyExt;
|
7353 6838 | let body = http_response
|
7354 6839 | .into_body()
|
7355 6840 | .collect()
|
7356 6841 | .await
|
7357 6842 | .expect("unable to collect body")
|
7358 6843 | .to_bytes();
|
7359 6844 | ::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"))
|
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"))
|
7361 6846 | );
|
7362 6847 | }
|
7363 6848 | }
|
7364 6849 |
|
7365 - | /// When a list member does not fit within length bounds,
|
6850 + | /// When a long member does not fit within range bounds,
|
7366 6851 | /// the response should be a 400 ValidationException.
|
7367 - | /// Test ID: RestJsonMalformedLengthList_case0
|
6852 + | /// Test ID: RestJsonMalformedRangeMaxLongOverride
|
7368 6853 | #[::tokio::test]
|
7369 6854 | #[::tracing_test::traced_test]
|
7370 - | async fn rest_json_malformed_length_list_case0_malformed_request() {
|
6855 + | async fn rest_json_malformed_range_max_long_override_malformed_request() {
|
7371 6856 | {
|
7372 6857 | #[allow(unused_mut)]
|
7373 6858 | let mut http_request = ::http_1x::Request::builder()
|
7374 - | .uri("/MalformedLength")
|
6859 + | .uri("/MalformedRangeOverride")
|
7375 6860 | .method("POST")
|
7376 6861 | .header("content-type", "application/json")
|
7377 6862 | .body(::aws_smithy_http_server::body::boxed(
|
7378 6863 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7379 6864 | &::aws_smithy_protocol_test::decode_body_data(
|
7380 - | "{ \"list\" : [\"abc\"] }".as_bytes(),
|
6865 + | "{ \"maxLong\" : 7 }".as_bytes(),
|
7381 6866 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7382 6867 | ),
|
7383 6868 | )),
|
7384 6869 | ))
|
7385 6870 | .unwrap();
|
7386 6871 | #[allow(unused_mut)]
|
7387 6872 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7388 6873 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7389 6874 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7390 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
6875 + | .malformed_range_override(move |input: crate::input::MalformedRangeOverrideInput| {
|
7391 6876 | let sender = sender.clone();
|
7392 6877 | 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> };
|
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> };
|
7394 6879 | sender.send(()).await.expect("receiver dropped early");
|
7395 6880 | result
|
7396 6881 | }
|
7397 6882 | })
|
7398 6883 | .build_unchecked();
|
7399 6884 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7400 6885 | .await
|
7401 6886 | .expect("unable to make an HTTP request");
|
7402 6887 | ::pretty_assertions::assert_eq!(
|
7403 6888 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7404 6889 | http_response.status()
|
7405 6890 | );
|
7406 6891 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7407 6892 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7408 6893 | http_response.headers(),
|
7409 6894 | expected_headers,
|
7410 6895 | ));
|
7411 6896 | use ::http_body_util::BodyExt;
|
7412 6897 | let body = http_response
|
7413 6898 | .into_body()
|
7414 6899 | .collect()
|
7415 6900 | .await
|
7416 6901 | .expect("unable to collect body")
|
7417 6902 | .to_bytes();
|
7418 6903 | ::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"))
|
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"))
|
7420 6905 | );
|
7421 6906 | }
|
7422 6907 | }
|
6908 + | }
|
7423 6909 |
|
7424 - | /// When a list 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,
|
7425 7021 | /// the response should be a 400 ValidationException.
|
7426 - | /// Test ID: RestJsonMalformedLengthList_case1
|
7022 + | /// Test ID: RestJsonMalformedRequiredBodyUnset
|
7427 7023 | #[::tokio::test]
|
7428 7024 | #[::tracing_test::traced_test]
|
7429 - | async fn rest_json_malformed_length_list_case1_malformed_request() {
|
7025 + | async fn rest_json_malformed_required_body_unset_malformed_request() {
|
7430 7026 | {
|
7431 7027 | #[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();
|
7028 + | let mut http_request = ::http_1x::Request::builder()
|
7029 + | .uri("/MalformedRequired")
|
7030 + | .method("POST")
|
7031 + | .header("content-type", "application/json")
|
7032 + | .header("string-in-headers", "abc")
|
7033 + | .body(::aws_smithy_http_server::body::boxed(
|
7034 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7035 + | &::aws_smithy_protocol_test::decode_body_data(
|
7036 + | "{ }".as_bytes(),
|
7037 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7038 + | ),
|
7039 + | )),
|
7040 + | ))
|
7041 + | .unwrap();
|
7042 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
7441 7043 | #[allow(unused_mut)]
|
7442 7044 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7443 7045 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7444 7046 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7445 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7047 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
7446 7048 | let sender = sender.clone();
|
7447 7049 | 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> };
|
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> };
|
7449 7051 | sender.send(()).await.expect("receiver dropped early");
|
7450 7052 | result
|
7451 7053 | }
|
7452 7054 | })
|
7453 7055 | .build_unchecked();
|
7454 7056 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7455 7057 | .await
|
7456 7058 | .expect("unable to make an HTTP request");
|
7457 7059 | ::pretty_assertions::assert_eq!(
|
7458 7060 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7459 7061 | http_response.status()
|
7460 7062 | );
|
7461 7063 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7462 7064 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7463 7065 | http_response.headers(),
|
7464 7066 | expected_headers,
|
7465 7067 | ));
|
7466 7068 | use ::http_body_util::BodyExt;
|
7467 7069 | let body = http_response
|
7468 7070 | .into_body()
|
7469 7071 | .collect()
|
7470 7072 | .await
|
7471 7073 | .expect("unable to collect body")
|
7472 7074 | .to_bytes();
|
7473 7075 | ::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"))
|
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"))
|
7475 7077 | );
|
7476 7078 | }
|
7477 7079 | }
|
7478 7080 |
|
7479 - | /// When a list member's value does not fit within length bounds,
|
7081 + | /// When a required member is set to null in the message body,
|
7480 7082 | /// the response should be a 400 ValidationException.
|
7481 - | /// Test ID: RestJsonMalformedLengthListValue_case0
|
7083 + | /// Test ID: RestJsonMalformedRequiredBodyExplicitNull
|
7482 7084 | #[::tokio::test]
|
7483 7085 | #[::tracing_test::traced_test]
|
7484 - | async fn rest_json_malformed_length_list_value_case0_malformed_request() {
|
7086 + | async fn rest_json_malformed_required_body_explicit_null_malformed_request() {
|
7485 7087 | {
|
7486 7088 | #[allow(unused_mut)]
|
7487 7089 | let mut http_request = ::http_1x::Request::builder()
|
7488 - | .uri("/MalformedLength")
|
7090 + | .uri("/MalformedRequired")
|
7489 7091 | .method("POST")
|
7490 7092 | .header("content-type", "application/json")
|
7093 + | .header("string-in-headers", "abc")
|
7491 7094 | .body(::aws_smithy_http_server::body::boxed(
|
7492 7095 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7493 7096 | &::aws_smithy_protocol_test::decode_body_data(
|
7494 - | "{ \"list\" : [\"a\", \"abc\"] }".as_bytes(),
|
7097 + | "{ \"string\": null }".as_bytes(),
|
7495 7098 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7496 7099 | ),
|
7497 7100 | )),
|
7498 7101 | ))
|
7499 7102 | .unwrap();
|
7103 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
7500 7104 | #[allow(unused_mut)]
|
7501 7105 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7502 7106 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7503 7107 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7504 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7108 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
7505 7109 | let sender = sender.clone();
|
7506 7110 | 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> };
|
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> };
|
7508 7112 | sender.send(()).await.expect("receiver dropped early");
|
7509 7113 | result
|
7510 7114 | }
|
7511 7115 | })
|
7512 7116 | .build_unchecked();
|
7513 7117 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7514 7118 | .await
|
7515 7119 | .expect("unable to make an HTTP request");
|
7516 7120 | ::pretty_assertions::assert_eq!(
|
7517 7121 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7518 7122 | http_response.status()
|
7519 7123 | );
|
7520 7124 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7521 7125 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7522 7126 | http_response.headers(),
|
7523 7127 | expected_headers,
|
7524 7128 | ));
|
7525 7129 | use ::http_body_util::BodyExt;
|
7526 7130 | let body = http_response
|
7527 7131 | .into_body()
|
7528 7132 | .collect()
|
7529 7133 | .await
|
7530 7134 | .expect("unable to collect body")
|
7531 7135 | .to_bytes();
|
7532 7136 | ::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"))
|
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"))
|
7534 7138 | );
|
7535 7139 | }
|
7536 7140 | }
|
7537 7141 |
|
7538 - | /// When a list member's value does not fit within length bounds,
|
7142 + | /// When a required member is not set in headers,
|
7539 7143 | /// the response should be a 400 ValidationException.
|
7540 - | /// Test ID: RestJsonMalformedLengthListValue_case1
|
7144 + | /// Test ID: RestJsonMalformedRequiredHeaderUnset
|
7541 7145 | #[::tokio::test]
|
7542 7146 | #[::tracing_test::traced_test]
|
7543 - | async fn rest_json_malformed_length_list_value_case1_malformed_request() {
|
7147 + | async fn rest_json_malformed_required_header_unset_malformed_request() {
|
7544 7148 | {
|
7545 7149 | #[allow(unused_mut)]
|
7546 7150 | let mut http_request = ::http_1x::Request::builder()
|
7547 - | .uri("/MalformedLength")
|
7151 + | .uri("/MalformedRequired")
|
7548 7152 | .method("POST")
|
7549 7153 | .header("content-type", "application/json")
|
7550 7154 | .body(::aws_smithy_http_server::body::boxed(
|
7551 7155 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7552 7156 | &::aws_smithy_protocol_test::decode_body_data(
|
7553 - | "{ \"list\" : [\"abcdefghijklmnopqrstuvwxyz\", \"abc\"] }".as_bytes(),
|
7157 + | "{ \"string\": \"abc\" }".as_bytes(),
|
7554 7158 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7555 7159 | ),
|
7556 7160 | )),
|
7557 7161 | ))
|
7558 7162 | .unwrap();
|
7163 + | *http_request.uri_mut() = "/MalformedRequired?stringInQuery=abc".parse().unwrap();
|
7559 7164 | #[allow(unused_mut)]
|
7560 7165 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7561 7166 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7562 7167 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7563 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7168 + | .malformed_required(move |input: crate::input::MalformedRequiredInput| {
|
7564 7169 | let sender = sender.clone();
|
7565 7170 | 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> };
|
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> };
|
7567 7172 | sender.send(()).await.expect("receiver dropped early");
|
7568 7173 | result
|
7569 7174 | }
|
7570 7175 | })
|
7571 7176 | .build_unchecked();
|
7572 7177 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7573 7178 | .await
|
7574 7179 | .expect("unable to make an HTTP request");
|
7575 7180 | ::pretty_assertions::assert_eq!(
|
7576 7181 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7577 7182 | http_response.status()
|
7578 7183 | );
|
7579 7184 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7580 7185 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7581 7186 | http_response.headers(),
|
7582 7187 | expected_headers,
|
7583 7188 | ));
|
7584 7189 | use ::http_body_util::BodyExt;
|
7585 7190 | let body = http_response
|
7586 7191 | .into_body()
|
7587 7192 | .collect()
|
7588 7193 | .await
|
7589 7194 | .expect("unable to collect body")
|
7590 7195 | .to_bytes();
|
7591 7196 | ::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"))
|
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"))
|
7593 7198 | );
|
7594 7199 | }
|
7595 7200 | }
|
7201 + | }
|
7596 7202 |
|
7597 - | /// When a map member does not fit within length bounds,
|
7598 - | /// the response should be a 400 ValidationException.
|
7599 - | /// Test ID: RestJsonMalformedLengthMap_case0
|
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
|
7600 7308 | #[::tokio::test]
|
7601 7309 | #[::tracing_test::traced_test]
|
7602 - | async fn rest_json_malformed_length_map_case0_malformed_request() {
|
7310 + | #[should_panic]
|
7311 + | async fn rest_json_malformed_unique_items_blob_list_malformed_request() {
|
7603 7312 | {
|
7604 7313 | #[allow(unused_mut)]
|
7605 7314 | let mut http_request = ::http_1x::Request::builder()
|
7606 - | .uri("/MalformedLength")
|
7315 + | .uri("/MalformedUniqueItems")
|
7607 7316 | .method("POST")
|
7608 7317 | .header("content-type", "application/json")
|
7609 7318 | .body(::aws_smithy_http_server::body::boxed(
|
7610 7319 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7611 7320 | &::aws_smithy_protocol_test::decode_body_data(
|
7612 - | "{ \"map\" : {\"abc\": [\"def\", \"efg\", \"fgh\"]} }".as_bytes(),
|
7321 + | "{ \"blobList\" : [\"YQ==\", \"YQ==\"] }".as_bytes(),
|
7613 7322 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7614 7323 | ),
|
7615 7324 | )),
|
7616 7325 | ))
|
7617 7326 | .unwrap();
|
7618 7327 | #[allow(unused_mut)]
|
7619 7328 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7620 7329 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7621 7330 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7622 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7331 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7623 7332 | let sender = sender.clone();
|
7624 7333 | 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> };
|
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> };
|
7626 7335 | sender.send(()).await.expect("receiver dropped early");
|
7627 7336 | result
|
7628 7337 | }
|
7629 7338 | })
|
7630 7339 | .build_unchecked();
|
7631 7340 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7632 7341 | .await
|
7633 7342 | .expect("unable to make an HTTP request");
|
7634 7343 | ::pretty_assertions::assert_eq!(
|
7635 7344 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7636 7345 | http_response.status()
|
7637 7346 | );
|
7638 7347 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7639 7348 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7640 7349 | http_response.headers(),
|
7641 7350 | expected_headers,
|
7642 7351 | ));
|
7643 7352 | use ::http_body_util::BodyExt;
|
7644 7353 | let body = http_response
|
7645 7354 | .into_body()
|
7646 7355 | .collect()
|
7647 7356 | .await
|
7648 7357 | .expect("unable to collect body")
|
7649 7358 | .to_bytes();
|
7650 7359 | ::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"))
|
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"))
|
7652 7361 | );
|
7653 7362 | }
|
7654 7363 | }
|
7655 7364 |
|
7656 - | /// When a map member does not fit within length bounds,
|
7365 + | /// When a boolean list contains non-unique values,
|
7657 7366 | /// the response should be a 400 ValidationException.
|
7658 - | /// Test ID: RestJsonMalformedLengthMap_case1
|
7367 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case0
|
7659 7368 | #[::tokio::test]
|
7660 7369 | #[::tracing_test::traced_test]
|
7661 - | async fn rest_json_malformed_length_map_case1_malformed_request() {
|
7370 + | #[should_panic]
|
7371 + | async fn rest_json_malformed_unique_items_boolean_list_case0_malformed_request() {
|
7662 7372 | {
|
7663 7373 | #[allow(unused_mut)]
|
7664 - | let mut http_request = ::http_1x::Request::builder()
|
7665 - | .uri("/MalformedLength")
|
7666 - | .method("POST")
|
7667 - | .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();
|
7374 + | let mut http_request = ::http_1x::Request::builder()
|
7375 + | .uri("/MalformedUniqueItems")
|
7376 + | .method("POST")
|
7377 + | .header("content-type", "application/json")
|
7378 + | .body(::aws_smithy_http_server::body::boxed(
|
7379 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
7380 + | &::aws_smithy_protocol_test::decode_body_data(
|
7381 + | "{ \"booleanList\" : [true, true] }".as_bytes(),
|
7382 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
7383 + | ),
|
7384 + | )),
|
7385 + | ))
|
7386 + | .unwrap();
|
7673 7387 | #[allow(unused_mut)]
|
7674 7388 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7675 7389 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7676 7390 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7677 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7391 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7678 7392 | let sender = sender.clone();
|
7679 7393 | 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> };
|
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> };
|
7681 7395 | sender.send(()).await.expect("receiver dropped early");
|
7682 7396 | result
|
7683 7397 | }
|
7684 7398 | })
|
7685 7399 | .build_unchecked();
|
7686 7400 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7687 7401 | .await
|
7688 7402 | .expect("unable to make an HTTP request");
|
7689 7403 | ::pretty_assertions::assert_eq!(
|
7690 7404 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7691 7405 | http_response.status()
|
7692 7406 | );
|
7693 7407 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7694 7408 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7695 7409 | http_response.headers(),
|
7696 7410 | expected_headers,
|
7697 7411 | ));
|
7698 7412 | use ::http_body_util::BodyExt;
|
7699 7413 | let body = http_response
|
7700 7414 | .into_body()
|
7701 7415 | .collect()
|
7702 7416 | .await
|
7703 7417 | .expect("unable to collect body")
|
7704 7418 | .to_bytes();
|
7705 7419 | ::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"))
|
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"))
|
7707 7421 | );
|
7708 7422 | }
|
7709 7423 | }
|
7710 7424 |
|
7711 - | /// When a map member's key does not fit within length bounds,
|
7425 + | /// When a boolean list contains non-unique values,
|
7712 7426 | /// the response should be a 400 ValidationException.
|
7713 - | /// Test ID: RestJsonMalformedLengthMapKey_case0
|
7427 + | /// Test ID: RestJsonMalformedUniqueItemsBooleanList_case1
|
7714 7428 | #[::tokio::test]
|
7715 7429 | #[::tracing_test::traced_test]
|
7716 - | async fn rest_json_malformed_length_map_key_case0_malformed_request() {
|
7430 + | #[should_panic]
|
7431 + | async fn rest_json_malformed_unique_items_boolean_list_case1_malformed_request() {
|
7717 7432 | {
|
7718 7433 | #[allow(unused_mut)]
|
7719 - | let mut http_request = ::http_1x::Request::builder()
|
7720 - | .uri("/MalformedLength")
|
7721 - | .method("POST")
|
7722 - | .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();
|
7434 + | let mut http_request = ::http_1x::Request::builder()
|
7435 + | .uri("/MalformedUniqueItems")
|
7436 + | .method("POST")
|
7437 + | .header("content-type", "application/json")
|
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();
|
7728 7447 | #[allow(unused_mut)]
|
7729 7448 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7730 7449 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7731 7450 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7732 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7451 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7733 7452 | let sender = sender.clone();
|
7734 7453 | 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> };
|
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> };
|
7736 7455 | sender.send(()).await.expect("receiver dropped early");
|
7737 7456 | result
|
7738 7457 | }
|
7739 7458 | })
|
7740 7459 | .build_unchecked();
|
7741 7460 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7742 7461 | .await
|
7743 7462 | .expect("unable to make an HTTP request");
|
7744 7463 | ::pretty_assertions::assert_eq!(
|
7745 7464 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7746 7465 | http_response.status()
|
7747 7466 | );
|
7748 7467 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7749 7468 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7750 7469 | http_response.headers(),
|
7751 7470 | expected_headers,
|
7752 7471 | ));
|
7753 7472 | use ::http_body_util::BodyExt;
|
7754 7473 | let body = http_response
|
7755 7474 | .into_body()
|
7756 7475 | .collect()
|
7757 7476 | .await
|
7758 7477 | .expect("unable to collect body")
|
7759 7478 | .to_bytes();
|
7760 7479 | ::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"))
|
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"))
|
7762 7481 | );
|
7763 7482 | }
|
7764 7483 | }
|
7765 7484 |
|
7766 - | /// When a map member's key does not fit within length bounds,
|
7485 + | /// When a string list contains non-unique values,
|
7767 7486 | /// the response should be a 400 ValidationException.
|
7768 - | /// Test ID: RestJsonMalformedLengthMapKey_case1
|
7487 + | /// Test ID: RestJsonMalformedUniqueItemsStringList
|
7769 7488 | #[::tokio::test]
|
7770 7489 | #[::tracing_test::traced_test]
|
7771 - | async fn rest_json_malformed_length_map_key_case1_malformed_request() {
|
7490 + | #[should_panic]
|
7491 + | async fn rest_json_malformed_unique_items_string_list_malformed_request() {
|
7772 7492 | {
|
7773 7493 | #[allow(unused_mut)]
|
7774 - | let mut http_request = ::http_1x::Request::builder()
|
7775 - | .uri("/MalformedLength")
|
7776 - | .method("POST")
|
7777 - | .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();
|
7494 + | let mut http_request = ::http_1x::Request::builder()
|
7495 + | .uri("/MalformedUniqueItems")
|
7496 + | .method("POST")
|
7497 + | .header("content-type", "application/json")
|
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();
|
7783 7507 | #[allow(unused_mut)]
|
7784 7508 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7785 7509 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7786 7510 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7787 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7511 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7788 7512 | let sender = sender.clone();
|
7789 7513 | 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> };
|
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> };
|
7791 7515 | sender.send(()).await.expect("receiver dropped early");
|
7792 7516 | result
|
7793 7517 | }
|
7794 7518 | })
|
7795 7519 | .build_unchecked();
|
7796 7520 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7797 7521 | .await
|
7798 7522 | .expect("unable to make an HTTP request");
|
7799 7523 | ::pretty_assertions::assert_eq!(
|
7800 7524 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7801 7525 | http_response.status()
|
7802 7526 | );
|
7803 7527 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7804 7528 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7805 7529 | http_response.headers(),
|
7806 7530 | expected_headers,
|
7807 7531 | ));
|
7808 7532 | use ::http_body_util::BodyExt;
|
7809 7533 | let body = http_response
|
7810 7534 | .into_body()
|
7811 7535 | .collect()
|
7812 7536 | .await
|
7813 7537 | .expect("unable to collect body")
|
7814 7538 | .to_bytes();
|
7815 7539 | ::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"))
|
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"))
|
7817 7541 | );
|
7818 7542 | }
|
7819 7543 | }
|
7820 7544 |
|
7821 - | /// When a map member's value does not fit within length bounds,
|
7545 + | /// When a byte list contains non-unique values,
|
7822 7546 | /// the response should be a 400 ValidationException.
|
7823 - | /// Test ID: RestJsonMalformedLengthMapValue_case0
|
7547 + | /// Test ID: RestJsonMalformedUniqueItemsByteList
|
7824 7548 | #[::tokio::test]
|
7825 7549 | #[::tracing_test::traced_test]
|
7826 - | async fn rest_json_malformed_length_map_value_case0_malformed_request() {
|
7550 + | #[should_panic]
|
7551 + | async fn rest_json_malformed_unique_items_byte_list_malformed_request() {
|
7827 7552 | {
|
7828 7553 | #[allow(unused_mut)]
|
7829 - | let mut http_request = ::http_1x::Request::builder()
|
7830 - | .uri("/MalformedLength")
|
7831 - | .method("POST")
|
7832 - | .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();
|
7554 + | let mut http_request = ::http_1x::Request::builder()
|
7555 + | .uri("/MalformedUniqueItems")
|
7556 + | .method("POST")
|
7557 + | .header("content-type", "application/json")
|
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();
|
7838 7567 | #[allow(unused_mut)]
|
7839 7568 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7840 7569 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7841 7570 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7842 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7571 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7843 7572 | let sender = sender.clone();
|
7844 7573 | 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> };
|
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> };
|
7846 7575 | sender.send(()).await.expect("receiver dropped early");
|
7847 7576 | result
|
7848 7577 | }
|
7849 7578 | })
|
7850 7579 | .build_unchecked();
|
7851 7580 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7852 7581 | .await
|
7853 7582 | .expect("unable to make an HTTP request");
|
7854 7583 | ::pretty_assertions::assert_eq!(
|
7855 7584 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7856 7585 | http_response.status()
|
7857 7586 | );
|
7858 7587 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7859 7588 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7860 7589 | http_response.headers(),
|
7861 7590 | expected_headers,
|
7862 7591 | ));
|
7863 7592 | use ::http_body_util::BodyExt;
|
7864 7593 | let body = http_response
|
7865 7594 | .into_body()
|
7866 7595 | .collect()
|
7867 7596 | .await
|
7868 7597 | .expect("unable to collect body")
|
7869 7598 | .to_bytes();
|
7870 7599 | ::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"))
|
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"))
|
7872 7601 | );
|
7873 7602 | }
|
7874 7603 | }
|
7875 7604 |
|
7876 - | /// When a map member's value does not fit within length bounds,
|
7605 + | /// When a short list contains non-unique values,
|
7877 7606 | /// the response should be a 400 ValidationException.
|
7878 - | /// Test ID: RestJsonMalformedLengthMapValue_case1
|
7607 + | /// Test ID: RestJsonMalformedUniqueItemsShortList
|
7879 7608 | #[::tokio::test]
|
7880 7609 | #[::tracing_test::traced_test]
|
7881 - | async fn rest_json_malformed_length_map_value_case1_malformed_request() {
|
7610 + | #[should_panic]
|
7611 + | async fn rest_json_malformed_unique_items_short_list_malformed_request() {
|
7882 7612 | {
|
7883 7613 | #[allow(unused_mut)]
|
7884 - | let mut http_request = ::http_1x::Request::builder()
|
7885 - | .uri("/MalformedLength")
|
7886 - | .method("POST")
|
7887 - | .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();
|
7614 + | let mut http_request = ::http_1x::Request::builder()
|
7615 + | .uri("/MalformedUniqueItems")
|
7616 + | .method("POST")
|
7617 + | .header("content-type", "application/json")
|
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();
|
7893 7627 | #[allow(unused_mut)]
|
7894 7628 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
7895 7629 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
7896 7630 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
7897 - | .malformed_length(move |input: crate::input::MalformedLengthInput| {
|
7631 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
7898 7632 | let sender = sender.clone();
|
7899 7633 | 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> };
|
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> };
|
7901 7635 | sender.send(()).await.expect("receiver dropped early");
|
7902 7636 | result
|
7903 7637 | }
|
7904 7638 | })
|
7905 7639 | .build_unchecked();
|
7906 7640 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
7907 7641 | .await
|
7908 7642 | .expect("unable to make an HTTP request");
|
7909 7643 | ::pretty_assertions::assert_eq!(
|
7910 7644 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
7911 7645 | http_response.status()
|
7912 7646 | );
|
7913 7647 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
7914 7648 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
7915 7649 | http_response.headers(),
|
7916 7650 | expected_headers,
|
7917 7651 | ));
|
7918 7652 | use ::http_body_util::BodyExt;
|
7919 7653 | let body = http_response
|
7920 7654 | .into_body()
|
7921 7655 | .collect()
|
7922 7656 | .await
|
7923 7657 | .expect("unable to collect body")
|
7924 7658 | .to_bytes();
|
7925 7659 | ::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"))
|
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"))
|
7927 7661 | );
|
7928 7662 | }
|
7929 7663 | }
|
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()),
|
8021 - | );
|
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 - | }
|
8029 - | }
|
8030 - | }
|
8031 - |
|
8032 - | #[allow(unreachable_code, unused_variables)]
|
8033 - | #[cfg(test)]
|
8034 - | mod malformed_enum_test {
|
8035 7664 |
|
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
|
7665 + | /// When an integer list contains non-unique values,
|
7666 + | /// the response should be a 400 ValidationException.
|
7667 + | /// Test ID: RestJsonMalformedUniqueItemsIntegerList
|
8040 7668 | #[::tokio::test]
|
8041 7669 | #[::tracing_test::traced_test]
|
8042 7670 | #[should_panic]
|
8043 - | async fn rest_json_malformed_enum_string_case0_malformed_request() {
|
7671 + | async fn rest_json_malformed_unique_items_integer_list_malformed_request() {
|
8044 7672 | {
|
8045 7673 | #[allow(unused_mut)]
|
8046 7674 | let mut http_request = ::http_1x::Request::builder()
|
8047 - | .uri("/MalformedEnum")
|
7675 + | .uri("/MalformedUniqueItems")
|
8048 7676 | .method("POST")
|
8049 7677 | .header("content-type", "application/json")
|
8050 7678 | .body(::aws_smithy_http_server::body::boxed(
|
8051 7679 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8052 7680 | &::aws_smithy_protocol_test::decode_body_data(
|
8053 - | "{ \"string\" : \"ABC\" }".as_bytes(),
|
7681 + | "{ \"integerList\" : [3, 3] }".as_bytes(),
|
8054 7682 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8055 7683 | ),
|
8056 7684 | )),
|
8057 7685 | ))
|
8058 7686 | .unwrap();
|
8059 7687 | #[allow(unused_mut)]
|
8060 7688 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8061 7689 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8062 7690 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8063 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7691 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8064 7692 | let sender = sender.clone();
|
8065 7693 | 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> };
|
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> };
|
8067 7695 | sender.send(()).await.expect("receiver dropped early");
|
8068 7696 | result
|
8069 7697 | }
|
8070 7698 | })
|
8071 7699 | .build_unchecked();
|
8072 7700 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8073 7701 | .await
|
8074 7702 | .expect("unable to make an HTTP request");
|
8075 7703 | ::pretty_assertions::assert_eq!(
|
8076 7704 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8077 7705 | http_response.status()
|
8078 7706 | );
|
8079 7707 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8080 7708 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8081 7709 | http_response.headers(),
|
8082 7710 | expected_headers,
|
8083 7711 | ));
|
8084 7712 | use ::http_body_util::BodyExt;
|
8085 7713 | let body = http_response
|
8086 7714 | .into_body()
|
8087 7715 | .collect()
|
8088 7716 | .await
|
8089 7717 | .expect("unable to collect body")
|
8090 7718 | .to_bytes();
|
8091 7719 | ::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"))
|
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"))
|
8093 7721 | );
|
8094 7722 | }
|
8095 7723 | }
|
8096 7724 |
|
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
|
7725 + | /// When an integer list contains non-unique values,
|
7726 + | /// the response should be a 400 ValidationException.
|
7727 + | /// Test ID: RestJsonMalformedUniqueItemsLongList
|
8101 7728 | #[::tokio::test]
|
8102 7729 | #[::tracing_test::traced_test]
|
8103 7730 | #[should_panic]
|
8104 - | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
7731 + | async fn rest_json_malformed_unique_items_long_list_malformed_request() {
|
8105 7732 | {
|
8106 7733 | #[allow(unused_mut)]
|
8107 7734 | let mut http_request = ::http_1x::Request::builder()
|
8108 - | .uri("/MalformedEnum")
|
7735 + | .uri("/MalformedUniqueItems")
|
8109 7736 | .method("POST")
|
8110 7737 | .header("content-type", "application/json")
|
8111 7738 | .body(::aws_smithy_http_server::body::boxed(
|
8112 7739 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8113 7740 | &::aws_smithy_protocol_test::decode_body_data(
|
8114 - | "{ \"string\" : \"XYZ\" }".as_bytes(),
|
7741 + | "{ \"longList\" : [4, 4] }".as_bytes(),
|
8115 7742 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8116 7743 | ),
|
8117 7744 | )),
|
8118 7745 | ))
|
8119 7746 | .unwrap();
|
8120 7747 | #[allow(unused_mut)]
|
8121 7748 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8122 7749 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8123 7750 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8124 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7751 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8125 7752 | let sender = sender.clone();
|
8126 7753 | 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> };
|
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> };
|
8128 7755 | sender.send(()).await.expect("receiver dropped early");
|
8129 7756 | result
|
8130 7757 | }
|
8131 7758 | })
|
8132 7759 | .build_unchecked();
|
8133 7760 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8134 7761 | .await
|
8135 7762 | .expect("unable to make an HTTP request");
|
8136 7763 | ::pretty_assertions::assert_eq!(
|
8137 7764 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8138 7765 | http_response.status()
|
8139 7766 | );
|
8140 7767 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8141 7768 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8142 7769 | http_response.headers(),
|
8143 7770 | expected_headers,
|
8144 7771 | ));
|
8145 7772 | use ::http_body_util::BodyExt;
|
8146 7773 | let body = http_response
|
8147 7774 | .into_body()
|
8148 7775 | .collect()
|
8149 7776 | .await
|
8150 7777 | .expect("unable to collect body")
|
8151 7778 | .to_bytes();
|
8152 7779 | ::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"))
|
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"))
|
8154 7781 | );
|
8155 7782 | }
|
8156 7783 | }
|
8157 7784 |
|
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
|
7785 + | /// When a timestamp list contains non-unique values,
|
7786 + | /// the response should be a 400 ValidationException.
|
7787 + | /// Test ID: RestJsonMalformedUniqueItemsTimestampList
|
8162 7788 | #[::tokio::test]
|
8163 7789 | #[::tracing_test::traced_test]
|
8164 7790 | #[should_panic]
|
8165 - | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
7791 + | async fn rest_json_malformed_unique_items_timestamp_list_malformed_request() {
|
8166 7792 | {
|
8167 7793 | #[allow(unused_mut)]
|
8168 7794 | let mut http_request = ::http_1x::Request::builder()
|
8169 - | .uri("/MalformedEnum")
|
7795 + | .uri("/MalformedUniqueItems")
|
8170 7796 | .method("POST")
|
8171 7797 | .header("content-type", "application/json")
|
8172 7798 | .body(::aws_smithy_http_server::body::boxed(
|
8173 7799 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8174 7800 | &::aws_smithy_protocol_test::decode_body_data(
|
8175 - | "{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes(),
|
7801 + | "{ \"timestampList\" : [1676660607, 1676660607] }".as_bytes(),
|
8176 7802 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8177 7803 | ),
|
8178 7804 | )),
|
8179 7805 | ))
|
8180 7806 | .unwrap();
|
8181 7807 | #[allow(unused_mut)]
|
8182 7808 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8183 7809 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8184 7810 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8185 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7811 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8186 7812 | let sender = sender.clone();
|
8187 7813 | 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> };
|
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> };
|
8189 7815 | sender.send(()).await.expect("receiver dropped early");
|
8190 7816 | result
|
8191 7817 | }
|
8192 7818 | })
|
8193 7819 | .build_unchecked();
|
8194 7820 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8195 7821 | .await
|
8196 7822 | .expect("unable to make an HTTP request");
|
8197 7823 | ::pretty_assertions::assert_eq!(
|
8198 7824 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8199 7825 | http_response.status()
|
8200 7826 | );
|
8201 7827 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8202 7828 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8203 7829 | http_response.headers(),
|
8204 7830 | expected_headers,
|
8205 7831 | ));
|
8206 7832 | use ::http_body_util::BodyExt;
|
8207 7833 | let body = http_response
|
8208 7834 | .into_body()
|
8209 7835 | .collect()
|
8210 7836 | .await
|
8211 7837 | .expect("unable to collect body")
|
8212 7838 | .to_bytes();
|
8213 7839 | ::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"))
|
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"))
|
8215 7841 | );
|
8216 7842 | }
|
8217 7843 | }
|
8218 7844 |
|
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
|
7845 + | /// When a date-time timestamp list contains non-unique values,
|
7846 + | /// the response should be a 400 ValidationException.
|
7847 + | /// Test ID: RestJsonMalformedUniqueItemsDateTimeList
|
8223 7848 | #[::tokio::test]
|
8224 7849 | #[::tracing_test::traced_test]
|
8225 7850 | #[should_panic]
|
8226 - | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
7851 + | async fn rest_json_malformed_unique_items_date_time_list_malformed_request() {
|
8227 7852 | {
|
8228 7853 | #[allow(unused_mut)]
|
8229 - | let mut http_request = ::http_1x::Request::builder()
|
8230 - | .uri("/MalformedEnum")
|
8231 - | .method("POST")
|
8232 - | .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();
|
7854 + | let mut http_request = ::http_1x::Request::builder()
|
7855 + | .uri("/MalformedUniqueItems")
|
7856 + | .method("POST")
|
7857 + | .header("content-type", "application/json")
|
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();
|
8242 7863 | #[allow(unused_mut)]
|
8243 7864 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8244 7865 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8245 7866 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8246 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7867 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8247 7868 | let sender = sender.clone();
|
8248 7869 | 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> };
|
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> };
|
8250 7871 | sender.send(()).await.expect("receiver dropped early");
|
8251 7872 | result
|
8252 7873 | }
|
8253 7874 | })
|
8254 7875 | .build_unchecked();
|
8255 7876 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8256 7877 | .await
|
8257 7878 | .expect("unable to make an HTTP request");
|
8258 7879 | ::pretty_assertions::assert_eq!(
|
8259 7880 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8260 7881 | http_response.status()
|
8261 7882 | );
|
8262 7883 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8263 7884 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8264 7885 | http_response.headers(),
|
8265 7886 | expected_headers,
|
8266 7887 | ));
|
8267 7888 | use ::http_body_util::BodyExt;
|
8268 7889 | let body = http_response
|
8269 7890 | .into_body()
|
8270 7891 | .collect()
|
8271 7892 | .await
|
8272 7893 | .expect("unable to collect body")
|
8273 7894 | .to_bytes();
|
8274 7895 | ::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"))
|
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"))
|
8276 7897 | );
|
8277 7898 | }
|
8278 7899 | }
|
8279 7900 |
|
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
|
7901 + | /// When a http-date timestamp list contains non-unique values,
|
7902 + | /// the response should be a 400 ValidationException.
|
7903 + | /// Test ID: RestJsonMalformedUniqueItemsHttpDateList_case0
|
8284 7904 | #[::tokio::test]
|
8285 7905 | #[::tracing_test::traced_test]
|
8286 7906 | #[should_panic]
|
8287 - | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
7907 + | async fn rest_json_malformed_unique_items_http_date_list_case0_malformed_request() {
|
8288 7908 | {
|
8289 7909 | #[allow(unused_mut)]
|
8290 - | let mut http_request = ::http_1x::Request::builder()
|
8291 - | .uri("/MalformedEnum")
|
8292 - | .method("POST")
|
8293 - | .header("content-type", "application/json")
|
8294 - | .body(::aws_smithy_http_server::body::boxed(
|
8295 - | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8296 - | &::aws_smithy_protocol_test::decode_body_data(
|
8297 - | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
8298 - | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8299 - | ),
|
8300 - | )),
|
8301 - | ))
|
8302 - | .unwrap();
|
7910 + | let mut http_request = ::http_1x::Request::builder()
|
7911 + | .uri("/MalformedUniqueItems")
|
7912 + | .method("POST")
|
7913 + | .header("content-type", "application/json")
|
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();
|
8303 7919 | #[allow(unused_mut)]
|
8304 7920 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8305 7921 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8306 7922 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8307 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7923 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8308 7924 | let sender = sender.clone();
|
8309 7925 | 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> };
|
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> };
|
8311 7927 | sender.send(()).await.expect("receiver dropped early");
|
8312 7928 | result
|
8313 7929 | }
|
8314 7930 | })
|
8315 7931 | .build_unchecked();
|
8316 7932 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8317 7933 | .await
|
8318 7934 | .expect("unable to make an HTTP request");
|
8319 7935 | ::pretty_assertions::assert_eq!(
|
8320 7936 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8321 7937 | http_response.status()
|
8322 7938 | );
|
8323 7939 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8324 7940 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8325 7941 | http_response.headers(),
|
8326 7942 | expected_headers,
|
8327 7943 | ));
|
8328 7944 | use ::http_body_util::BodyExt;
|
8329 7945 | let body = http_response
|
8330 7946 | .into_body()
|
8331 7947 | .collect()
|
8332 7948 | .await
|
8333 7949 | .expect("unable to collect body")
|
8334 7950 | .to_bytes();
|
8335 7951 | ::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"))
|
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"))
|
8337 7953 | );
|
8338 7954 | }
|
8339 7955 | }
|
8340 7956 |
|
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
|
7957 + | /// When an enum list contains non-unique values,
|
7958 + | /// the response should be a 400 ValidationException.
|
7959 + | /// Test ID: RestJsonMalformedUniqueItemsEnumList
|
8345 7960 | #[::tokio::test]
|
8346 7961 | #[::tracing_test::traced_test]
|
8347 7962 | #[should_panic]
|
8348 - | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
7963 + | async fn rest_json_malformed_unique_items_enum_list_malformed_request() {
|
8349 7964 | {
|
8350 7965 | #[allow(unused_mut)]
|
8351 7966 | let mut http_request = ::http_1x::Request::builder()
|
8352 - | .uri("/MalformedEnum")
|
7967 + | .uri("/MalformedUniqueItems")
|
8353 7968 | .method("POST")
|
8354 7969 | .header("content-type", "application/json")
|
8355 7970 | .body(::aws_smithy_http_server::body::boxed(
|
8356 7971 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8357 7972 | &::aws_smithy_protocol_test::decode_body_data(
|
8358 - | "{ \"list\" : [\"XYZ\"] }".as_bytes(),
|
7973 + | "{ \"enumList\" : [\"Foo\", \"Foo\"] }".as_bytes(),
|
8359 7974 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8360 7975 | ),
|
8361 7976 | )),
|
8362 7977 | ))
|
8363 7978 | .unwrap();
|
8364 7979 | #[allow(unused_mut)]
|
8365 7980 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8366 7981 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8367 7982 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8368 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
7983 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8369 7984 | let sender = sender.clone();
|
8370 7985 | 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> };
|
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> };
|
8372 7987 | sender.send(()).await.expect("receiver dropped early");
|
8373 7988 | result
|
8374 7989 | }
|
8375 7990 | })
|
8376 7991 | .build_unchecked();
|
8377 7992 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8378 7993 | .await
|
8379 7994 | .expect("unable to make an HTTP request");
|
8380 7995 | ::pretty_assertions::assert_eq!(
|
8381 7996 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8382 7997 | http_response.status()
|
8383 7998 | );
|
8384 7999 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8385 8000 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8386 8001 | http_response.headers(),
|
8387 8002 | expected_headers,
|
8388 8003 | ));
|
8389 8004 | use ::http_body_util::BodyExt;
|
8390 8005 | let body = http_response
|
8391 8006 | .into_body()
|
8392 8007 | .collect()
|
8393 8008 | .await
|
8394 8009 | .expect("unable to collect body")
|
8395 8010 | .to_bytes();
|
8396 8011 | ::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"))
|
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"))
|
8398 8013 | );
|
8399 8014 | }
|
8400 8015 | }
|
8401 8016 |
|
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
|
8017 + | /// When an intEnum list contains non-unique values,
|
8018 + | /// the response should be a 400 ValidationException.
|
8019 + | /// Test ID: RestJsonMalformedUniqueItemsIntEnumList
|
8406 8020 | #[::tokio::test]
|
8407 8021 | #[::tracing_test::traced_test]
|
8408 8022 | #[should_panic]
|
8409 - | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
8023 + | async fn rest_json_malformed_unique_items_int_enum_list_malformed_request() {
|
8410 8024 | {
|
8411 8025 | #[allow(unused_mut)]
|
8412 8026 | let mut http_request = ::http_1x::Request::builder()
|
8413 - | .uri("/MalformedEnum")
|
8027 + | .uri("/MalformedUniqueItems")
|
8414 8028 | .method("POST")
|
8415 8029 | .header("content-type", "application/json")
|
8416 8030 | .body(::aws_smithy_http_server::body::boxed(
|
8417 8031 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8418 8032 | &::aws_smithy_protocol_test::decode_body_data(
|
8419 - | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
8033 + | "{ \"intEnumList\" : [3, 3] }".as_bytes(),
|
8420 8034 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8421 8035 | ),
|
8422 8036 | )),
|
8423 8037 | ))
|
8424 8038 | .unwrap();
|
8425 8039 | #[allow(unused_mut)]
|
8426 8040 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8427 8041 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8428 8042 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8429 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8043 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8430 8044 | let sender = sender.clone();
|
8431 8045 | 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> };
|
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> };
|
8433 8047 | sender.send(()).await.expect("receiver dropped early");
|
8434 8048 | result
|
8435 8049 | }
|
8436 8050 | })
|
8437 8051 | .build_unchecked();
|
8438 8052 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8439 8053 | .await
|
8440 8054 | .expect("unable to make an HTTP request");
|
8441 8055 | ::pretty_assertions::assert_eq!(
|
8442 8056 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8443 8057 | http_response.status()
|
8444 8058 | );
|
8445 8059 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8446 8060 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8447 8061 | http_response.headers(),
|
8448 8062 | expected_headers,
|
8449 8063 | ));
|
8450 8064 | use ::http_body_util::BodyExt;
|
8451 8065 | let body = http_response
|
8452 8066 | .into_body()
|
8453 8067 | .collect()
|
8454 8068 | .await
|
8455 8069 | .expect("unable to collect body")
|
8456 8070 | .to_bytes();
|
8457 8071 | ::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"))
|
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"))
|
8459 8073 | );
|
8460 8074 | }
|
8461 8075 | }
|
8462 8076 |
|
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
|
8077 + | /// When an list of lists contains non-unique values,
|
8078 + | /// the response should be a 400 ValidationException.
|
8079 + | /// Test ID: RestJsonMalformedUniqueItemsListList
|
8467 8080 | #[::tokio::test]
|
8468 8081 | #[::tracing_test::traced_test]
|
8469 8082 | #[should_panic]
|
8470 - | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
8083 + | async fn rest_json_malformed_unique_items_list_list_malformed_request() {
|
8471 8084 | {
|
8472 8085 | #[allow(unused_mut)]
|
8473 8086 | let mut http_request = ::http_1x::Request::builder()
|
8474 - | .uri("/MalformedEnum")
|
8087 + | .uri("/MalformedUniqueItems")
|
8475 8088 | .method("POST")
|
8476 8089 | .header("content-type", "application/json")
|
8477 8090 | .body(::aws_smithy_http_server::body::boxed(
|
8478 8091 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8479 8092 | &::aws_smithy_protocol_test::decode_body_data(
|
8480 - | "{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes(),
|
8093 + | "{ \"listList\" : [[\"foo\",\"bar\"], [\"foo\",\"bar\"]] }".as_bytes(),
|
8481 8094 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8482 8095 | ),
|
8483 8096 | )),
|
8484 8097 | ))
|
8485 8098 | .unwrap();
|
8486 8099 | #[allow(unused_mut)]
|
8487 8100 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8488 8101 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8489 8102 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8490 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8103 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8491 8104 | let sender = sender.clone();
|
8492 8105 | 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> };
|
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> };
|
8494 8107 | sender.send(()).await.expect("receiver dropped early");
|
8495 8108 | result
|
8496 8109 | }
|
8497 8110 | })
|
8498 8111 | .build_unchecked();
|
8499 8112 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8500 8113 | .await
|
8501 8114 | .expect("unable to make an HTTP request");
|
8502 8115 | ::pretty_assertions::assert_eq!(
|
8503 8116 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8504 8117 | http_response.status()
|
8505 8118 | );
|
8506 8119 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8507 8120 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8508 8121 | http_response.headers(),
|
8509 8122 | expected_headers,
|
8510 8123 | ));
|
8511 8124 | use ::http_body_util::BodyExt;
|
8512 8125 | let body = http_response
|
8513 8126 | .into_body()
|
8514 8127 | .collect()
|
8515 8128 | .await
|
8516 8129 | .expect("unable to collect body")
|
8517 8130 | .to_bytes();
|
8518 8131 | ::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"))
|
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"))
|
8520 8133 | );
|
8521 8134 | }
|
8522 8135 | }
|
8523 8136 |
|
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
|
8137 + | /// When an list of structures contains non-unique values,
|
8138 + | /// the response should be a 400 ValidationException.
|
8139 + | /// Test ID: RestJsonMalformedUniqueItemsStructureList
|
8528 8140 | #[::tokio::test]
|
8529 8141 | #[::tracing_test::traced_test]
|
8530 8142 | #[should_panic]
|
8531 - | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
8143 + | async fn rest_json_malformed_unique_items_structure_list_malformed_request() {
|
8532 8144 | {
|
8533 8145 | #[allow(unused_mut)]
|
8534 8146 | let mut http_request = ::http_1x::Request::builder()
|
8535 - | .uri("/MalformedEnum")
|
8147 + | .uri("/MalformedUniqueItems")
|
8536 8148 | .method("POST")
|
8537 8149 | .header("content-type", "application/json")
|
8538 8150 | .body(::aws_smithy_http_server::body::boxed(
|
8539 8151 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8540 8152 | &::aws_smithy_protocol_test::decode_body_data(
|
8541 - | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
8153 + | "{ \"structureList\" : [{\"hi\": \"hello\"}, {\"hi\": \"hello\"}] }"
|
8154 + | .as_bytes(),
|
8542 8155 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8543 8156 | ),
|
8544 8157 | )),
|
8545 8158 | ))
|
8546 8159 | .unwrap();
|
8547 8160 | #[allow(unused_mut)]
|
8548 8161 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8549 8162 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8550 8163 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8551 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8164 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8552 8165 | let sender = sender.clone();
|
8553 8166 | 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> };
|
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> };
|
8555 8168 | sender.send(()).await.expect("receiver dropped early");
|
8556 8169 | result
|
8557 8170 | }
|
8558 8171 | })
|
8559 8172 | .build_unchecked();
|
8560 8173 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8561 8174 | .await
|
8562 8175 | .expect("unable to make an HTTP request");
|
8563 8176 | ::pretty_assertions::assert_eq!(
|
8564 8177 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8565 8178 | http_response.status()
|
8566 8179 | );
|
8567 8180 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8568 8181 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8569 8182 | http_response.headers(),
|
8570 8183 | expected_headers,
|
8571 8184 | ));
|
8572 8185 | use ::http_body_util::BodyExt;
|
8573 8186 | let body = http_response
|
8574 8187 | .into_body()
|
8575 8188 | .collect()
|
8576 8189 | .await
|
8577 8190 | .expect("unable to collect body")
|
8578 8191 | .to_bytes();
|
8579 8192 | ::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"))
|
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"))
|
8581 8194 | );
|
8582 8195 | }
|
8583 8196 | }
|
8584 8197 |
|
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
|
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
|
8589 8202 | #[::tokio::test]
|
8590 8203 | #[::tracing_test::traced_test]
|
8591 - | #[should_panic]
|
8592 - | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
8204 + | async fn rest_json_malformed_unique_items_structure_missing_key_list_malformed_request() {
|
8593 8205 | {
|
8594 8206 | #[allow(unused_mut)]
|
8595 8207 | let mut http_request = ::http_1x::Request::builder()
|
8596 - | .uri("/MalformedEnum")
|
8208 + | .uri("/MalformedUniqueItems")
|
8597 8209 | .method("POST")
|
8598 8210 | .header("content-type", "application/json")
|
8599 8211 | .body(::aws_smithy_http_server::body::boxed(
|
8600 8212 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8601 8213 | &::aws_smithy_protocol_test::decode_body_data(
|
8602 - | "{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes(),
|
8214 + | "{ \"structureListWithNoKey\" : [{\"hi2\": \"bar\"}] }".as_bytes(),
|
8603 8215 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8604 8216 | ),
|
8605 8217 | )),
|
8606 8218 | ))
|
8607 8219 | .unwrap();
|
8608 8220 | #[allow(unused_mut)]
|
8609 8221 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8610 8222 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8611 8223 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8612 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8224 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8613 8225 | let sender = sender.clone();
|
8614 8226 | 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> };
|
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> };
|
8616 8228 | sender.send(()).await.expect("receiver dropped early");
|
8617 8229 | result
|
8618 8230 | }
|
8619 8231 | })
|
8620 8232 | .build_unchecked();
|
8621 8233 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8622 8234 | .await
|
8623 8235 | .expect("unable to make an HTTP request");
|
8624 8236 | ::pretty_assertions::assert_eq!(
|
8625 8237 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8626 8238 | http_response.status()
|
8627 8239 | );
|
8628 8240 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8629 8241 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8630 8242 | http_response.headers(),
|
8631 8243 | expected_headers,
|
8632 8244 | ));
|
8633 8245 | use ::http_body_util::BodyExt;
|
8634 8246 | let body = http_response
|
8635 8247 | .into_body()
|
8636 8248 | .collect()
|
8637 8249 | .await
|
8638 8250 | .expect("unable to collect body")
|
8639 8251 | .to_bytes();
|
8640 8252 | ::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"))
|
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"))
|
8642 8254 | );
|
8643 8255 | }
|
8644 8256 | }
|
8645 8257 |
|
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
|
8258 + | /// When an list of unions contains non-unique values,
|
8259 + | /// the response should be a 400 ValidationException.
|
8260 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case0
|
8650 8261 | #[::tokio::test]
|
8651 8262 | #[::tracing_test::traced_test]
|
8652 8263 | #[should_panic]
|
8653 - | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
8264 + | async fn rest_json_malformed_unique_items_union_list_case0_malformed_request() {
|
8654 8265 | {
|
8655 8266 | #[allow(unused_mut)]
|
8656 8267 | let mut http_request = ::http_1x::Request::builder()
|
8657 - | .uri("/MalformedEnum")
|
8268 + | .uri("/MalformedUniqueItems")
|
8658 8269 | .method("POST")
|
8659 8270 | .header("content-type", "application/json")
|
8660 8271 | .body(::aws_smithy_http_server::body::boxed(
|
8661 8272 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8662 8273 | &::aws_smithy_protocol_test::decode_body_data(
|
8663 - | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
8274 + | "{ \"unionList\" : [{\"string\": \"foo\"}, {\"string\": \"foo\"}] }"
|
8275 + | .as_bytes(),
|
8664 8276 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8665 8277 | ),
|
8666 8278 | )),
|
8667 8279 | ))
|
8668 8280 | .unwrap();
|
8669 8281 | #[allow(unused_mut)]
|
8670 8282 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8671 8283 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8672 8284 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8673 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8285 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8674 8286 | let sender = sender.clone();
|
8675 8287 | 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> };
|
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> };
|
8677 8289 | sender.send(()).await.expect("receiver dropped early");
|
8678 8290 | result
|
8679 8291 | }
|
8680 8292 | })
|
8681 8293 | .build_unchecked();
|
8682 8294 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8683 8295 | .await
|
8684 8296 | .expect("unable to make an HTTP request");
|
8685 8297 | ::pretty_assertions::assert_eq!(
|
8686 8298 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8687 8299 | http_response.status()
|
8688 8300 | );
|
8689 8301 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8690 8302 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8691 8303 | http_response.headers(),
|
8692 8304 | expected_headers,
|
8693 8305 | ));
|
8694 8306 | use ::http_body_util::BodyExt;
|
8695 8307 | let body = http_response
|
8696 8308 | .into_body()
|
8697 8309 | .collect()
|
8698 8310 | .await
|
8699 8311 | .expect("unable to collect body")
|
8700 8312 | .to_bytes();
|
8701 8313 | ::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"))
|
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"))
|
8703 8315 | );
|
8704 8316 | }
|
8705 8317 | }
|
8706 8318 |
|
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
|
8319 + | /// When an list of unions contains non-unique values,
|
8320 + | /// the response should be a 400 ValidationException.
|
8321 + | /// Test ID: RestJsonMalformedUniqueItemsUnionList_case1
|
8711 8322 | #[::tokio::test]
|
8712 8323 | #[::tracing_test::traced_test]
|
8713 8324 | #[should_panic]
|
8714 - | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
8325 + | async fn rest_json_malformed_unique_items_union_list_case1_malformed_request() {
|
8715 8326 | {
|
8716 8327 | #[allow(unused_mut)]
|
8717 8328 | let mut http_request = ::http_1x::Request::builder()
|
8718 - | .uri("/MalformedEnum")
|
8329 + | .uri("/MalformedUniqueItems")
|
8719 8330 | .method("POST")
|
8720 8331 | .header("content-type", "application/json")
|
8721 8332 | .body(::aws_smithy_http_server::body::boxed(
|
8722 8333 | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8723 8334 | &::aws_smithy_protocol_test::decode_body_data(
|
8724 - | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|
8335 + | "{ \"unionList\" : [{\"integer\": 1}, {\"integer\": 1}] }".as_bytes(),
|
8725 8336 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8726 8337 | ),
|
8727 8338 | )),
|
8728 8339 | ))
|
8729 8340 | .unwrap();
|
8730 8341 | #[allow(unused_mut)]
|
8731 8342 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8732 8343 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8733 8344 | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8734 - | .malformed_enum(move |input: crate::input::MalformedEnumInput| {
|
8345 + | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
8735 8346 | let sender = sender.clone();
|
8736 8347 | 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> };
|
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> };
|
8738 8349 | sender.send(()).await.expect("receiver dropped early");
|
8739 8350 | result
|
8740 8351 | }
|
8741 8352 | })
|
8742 8353 | .build_unchecked();
|
8743 8354 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8744 8355 | .await
|
8745 8356 | .expect("unable to make an HTTP request");
|
8746 8357 | ::pretty_assertions::assert_eq!(
|
8747 8358 | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8748 8359 | http_response.status()
|
8749 8360 | );
|
8750 8361 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8751 8362 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8752 8363 | http_response.headers(),
|
8753 8364 | expected_headers,
|
8754 8365 | ));
|
8755 8366 | use ::http_body_util::BodyExt;
|
8756 8367 | let body = http_response
|
8757 8368 | .into_body()
|
8758 8369 | .collect()
|
8759 8370 | .await
|
8760 8371 | .expect("unable to collect body")
|
8761 8372 | .to_bytes();
|
8762 8373 | ::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"))
|
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"))
|
8375 + | );
|
8376 + | }
|
8377 + | }
|
8378 + | }
|
8379 + |
|
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
|
8490 + | #[::tokio::test]
|
8491 + | #[::tracing_test::traced_test]
|
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() {
|
8551 + | {
|
8552 + | #[allow(unused_mut)]
|
8553 + | let mut http_request = ::http_1x::Request::builder()
|
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 + | .method("POST")
|
8720 + | .header("content-type", "application/json")
|
8721 + | .body(::aws_smithy_http_server::body::boxed(
|
8722 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
8723 + | &::aws_smithy_protocol_test::decode_body_data(
|
8724 + | "{ \"string\" : \"ABC\" }".as_bytes(),
|
8725 + | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
8726 + | ),
|
8727 + | )),
|
8728 + | ))
|
8729 + | .unwrap();
|
8730 + | #[allow(unused_mut)]
|
8731 + | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
8732 + | let config = crate::service::RestJsonValidationConfig::builder().build();
|
8733 + | let service = crate::service::RestJsonValidation::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
8734 + | .sensitive_validation(move |input: crate::input::SensitiveValidationInput| {
|
8735 + | let sender = sender.clone();
|
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::SensitiveValidationOutput, crate::error::SensitiveValidationError> };
|
8738 + | sender.send(()).await.expect("receiver dropped early");
|
8739 + | result
|
8740 + | }
|
8741 + | })
|
8742 + | .build_unchecked();
|
8743 + | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
8744 + | .await
|
8745 + | .expect("unable to make an HTTP request");
|
8746 + | ::pretty_assertions::assert_eq!(
|
8747 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
8748 + | http_response.status()
|
8749 + | );
|
8750 + | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
8751 + | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
8752 + | http_response.headers(),
|
8753 + | expected_headers,
|
8754 + | ));
|
8755 + | use ::http_body_util::BodyExt;
|
8756 + | let body = http_response
|
8757 + | .into_body()
|
8758 + | .collect()
|
8759 + | .await
|
8760 + | .expect("unable to collect body")
|
8761 + | .to_bytes();
|
8762 + | ::aws_smithy_protocol_test::assert_ok(
|
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 | }
|