101 101 | #[allow(unreachable_code, unused_variables)]
|
102 102 | #[cfg(test)]
|
103 103 | mod malformed_enum_test {
|
104 104 |
|
105 105 | /// When a string member does not contain a valid enum value,
|
106 106 | /// the response should be a 400 ValidationException. Internal-only
|
107 107 | /// enum values are excluded from the response message.
|
108 108 | /// Test ID: RestJsonMalformedEnumString_case0
|
109 109 | #[::tokio::test]
|
110 110 | #[::tracing_test::traced_test]
|
111 - | #[should_panic]
|
112 111 | async fn rest_json_malformed_enum_string_case0_malformed_request() {
|
113 112 | {
|
114 113 | #[allow(unused_mut)]
|
115 114 | let mut http_request = ::http::Request::builder()
|
116 115 | .uri("/MalformedEnum")
|
117 116 | .method("POST")
|
118 117 | .header("content-type", "application/json")
|
119 118 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
120 119 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
121 120 | "{ \"string\" : \"ABC\" }".as_bytes(),
|
122 121 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
123 122 | )),
|
124 123 | ))
|
125 124 | .unwrap();
|
126 125 | #[allow(unused_mut)]
|
127 126 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
128 127 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
129 128 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
130 129 | .malformed_enum(
|
131 130 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
132 131 | // since `send()` only borrows it.
|
133 132 | #[allow(unused_assignments)]
|
134 133 | move |input: crate::input::MalformedEnumInput| {
|
135 134 | let sender = sender.clone();
|
136 135 | async move {
|
137 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> };
|
138 137 | sender.send(()).await.expect("receiver dropped early");
|
139 138 | result
|
140 139 | }
|
141 140 | }
|
142 141 | )
|
143 142 | .build_unchecked();
|
144 143 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
145 144 | .await
|
146 145 | .expect("unable to make an HTTP request");
|
147 146 | ::pretty_assertions::assert_eq!(
|
148 147 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
149 148 | http_response.status()
|
150 149 | );
|
151 150 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
152 151 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
153 152 | http_response.headers(),
|
154 153 | expected_headers,
|
155 154 | ));
|
156 155 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
157 156 | .await
|
158 157 | .expect("unable to extract body to bytes");
|
159 158 | ::aws_smithy_protocol_test::assert_ok(
|
160 159 | ::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"))
|
161 160 | );
|
162 161 | }
|
163 162 | }
|
164 163 |
|
165 164 | /// When a string member does not contain a valid enum value,
|
166 165 | /// the response should be a 400 ValidationException. Internal-only
|
167 166 | /// enum values are excluded from the response message.
|
168 167 | /// Test ID: RestJsonMalformedEnumString_case1
|
169 168 | #[::tokio::test]
|
170 169 | #[::tracing_test::traced_test]
|
171 - | #[should_panic]
|
172 170 | async fn rest_json_malformed_enum_string_case1_malformed_request() {
|
173 171 | {
|
174 172 | #[allow(unused_mut)]
|
175 173 | let mut http_request = ::http::Request::builder()
|
176 174 | .uri("/MalformedEnum")
|
177 175 | .method("POST")
|
178 176 | .header("content-type", "application/json")
|
179 177 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
180 178 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
181 179 | "{ \"string\" : \"XYZ\" }".as_bytes(),
|
182 180 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
183 181 | )),
|
184 182 | ))
|
185 183 | .unwrap();
|
186 184 | #[allow(unused_mut)]
|
187 185 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
188 186 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
189 187 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
190 188 | .malformed_enum(
|
191 189 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
192 190 | // since `send()` only borrows it.
|
193 191 | #[allow(unused_assignments)]
|
194 192 | move |input: crate::input::MalformedEnumInput| {
|
195 193 | let sender = sender.clone();
|
196 194 | async move {
|
197 195 | 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 196 | sender.send(()).await.expect("receiver dropped early");
|
199 197 | result
|
200 198 | }
|
201 199 | }
|
202 200 | )
|
203 201 | .build_unchecked();
|
204 202 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
205 203 | .await
|
206 204 | .expect("unable to make an HTTP request");
|
207 205 | ::pretty_assertions::assert_eq!(
|
208 206 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
209 207 | http_response.status()
|
210 208 | );
|
211 209 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
212 210 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
213 211 | http_response.headers(),
|
214 212 | expected_headers,
|
215 213 | ));
|
216 214 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
217 215 | .await
|
218 216 | .expect("unable to extract body to bytes");
|
219 217 | ::aws_smithy_protocol_test::assert_ok(
|
220 218 | ::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"))
|
221 219 | );
|
222 220 | }
|
223 221 | }
|
224 222 |
|
225 223 | /// When a string member does not contain a valid enum value,
|
226 224 | /// the response should be a 400 ValidationException. Internal-only
|
227 225 | /// enum values are excluded from the response message.
|
228 226 | /// Test ID: RestJsonMalformedEnumTraitString_case0
|
229 227 | #[::tokio::test]
|
230 228 | #[::tracing_test::traced_test]
|
231 - | #[should_panic]
|
232 229 | async fn rest_json_malformed_enum_trait_string_case0_malformed_request() {
|
233 230 | {
|
234 231 | #[allow(unused_mut)]
|
235 232 | let mut http_request = ::http::Request::builder()
|
236 233 | .uri("/MalformedEnum")
|
237 234 | .method("POST")
|
238 235 | .header("content-type", "application/json")
|
239 236 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
240 237 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
241 238 | "{ \"stringWithEnumTrait\" : \"ABC\" }".as_bytes(),
|
242 239 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
243 240 | )),
|
244 241 | ))
|
245 242 | .unwrap();
|
246 243 | #[allow(unused_mut)]
|
247 244 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
248 245 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
249 246 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
250 247 | .malformed_enum(
|
251 248 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
252 249 | // since `send()` only borrows it.
|
253 250 | #[allow(unused_assignments)]
|
254 251 | move |input: crate::input::MalformedEnumInput| {
|
255 252 | let sender = sender.clone();
|
256 253 | async move {
|
257 254 | 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> };
|
258 255 | sender.send(()).await.expect("receiver dropped early");
|
259 256 | result
|
260 257 | }
|
261 258 | }
|
262 259 | )
|
263 260 | .build_unchecked();
|
264 261 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
265 262 | .await
|
266 263 | .expect("unable to make an HTTP request");
|
267 264 | ::pretty_assertions::assert_eq!(
|
268 265 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
269 266 | http_response.status()
|
270 267 | );
|
271 268 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
272 269 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
273 270 | http_response.headers(),
|
274 271 | expected_headers,
|
275 272 | ));
|
276 273 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
277 274 | .await
|
278 275 | .expect("unable to extract body to bytes");
|
279 276 | ::aws_smithy_protocol_test::assert_ok(
|
280 277 | ::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"))
|
281 278 | );
|
282 279 | }
|
283 280 | }
|
284 281 |
|
285 282 | /// When a string member does not contain a valid enum value,
|
286 283 | /// the response should be a 400 ValidationException. Internal-only
|
287 284 | /// enum values are excluded from the response message.
|
288 285 | /// Test ID: RestJsonMalformedEnumTraitString_case1
|
289 286 | #[::tokio::test]
|
290 287 | #[::tracing_test::traced_test]
|
291 - | #[should_panic]
|
292 288 | async fn rest_json_malformed_enum_trait_string_case1_malformed_request() {
|
293 289 | {
|
294 290 | #[allow(unused_mut)]
|
295 291 | let mut http_request = ::http::Request::builder()
|
296 292 | .uri("/MalformedEnum")
|
297 293 | .method("POST")
|
298 294 | .header("content-type", "application/json")
|
299 295 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
300 296 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
301 297 | "{ \"stringWithEnumTrait\" : \"XYZ\" }".as_bytes(),
|
302 298 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
303 299 | )),
|
304 300 | ))
|
305 301 | .unwrap();
|
306 302 | #[allow(unused_mut)]
|
307 303 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
308 304 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
309 305 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
310 306 | .malformed_enum(
|
311 307 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
312 308 | // since `send()` only borrows it.
|
313 309 | #[allow(unused_assignments)]
|
314 310 | move |input: crate::input::MalformedEnumInput| {
|
315 311 | let sender = sender.clone();
|
316 312 | async move {
|
317 313 | 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> };
|
318 314 | sender.send(()).await.expect("receiver dropped early");
|
319 315 | result
|
320 316 | }
|
321 317 | }
|
322 318 | )
|
323 319 | .build_unchecked();
|
324 320 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
325 321 | .await
|
326 322 | .expect("unable to make an HTTP request");
|
327 323 | ::pretty_assertions::assert_eq!(
|
328 324 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
329 325 | http_response.status()
|
330 326 | );
|
331 327 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
332 328 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
333 329 | http_response.headers(),
|
334 330 | expected_headers,
|
335 331 | ));
|
336 332 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
337 333 | .await
|
338 334 | .expect("unable to extract body to bytes");
|
339 335 | ::aws_smithy_protocol_test::assert_ok(
|
340 336 | ::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"))
|
341 337 | );
|
342 338 | }
|
343 339 | }
|
344 340 |
|
345 341 | /// When a list member value does not contain a valid enum value,
|
346 342 | /// the response should be a 400 ValidationException. Internal-only
|
347 343 | /// enum values are excluded from the response message.
|
348 344 | /// Test ID: RestJsonMalformedEnumList_case0
|
349 345 | #[::tokio::test]
|
350 346 | #[::tracing_test::traced_test]
|
351 - | #[should_panic]
|
352 347 | async fn rest_json_malformed_enum_list_case0_malformed_request() {
|
353 348 | {
|
354 349 | #[allow(unused_mut)]
|
355 350 | let mut http_request = ::http::Request::builder()
|
356 351 | .uri("/MalformedEnum")
|
357 352 | .method("POST")
|
358 353 | .header("content-type", "application/json")
|
359 354 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
360 355 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
361 356 | "{ \"list\" : [\"ABC\"] }".as_bytes(),
|
362 357 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
363 358 | )),
|
364 359 | ))
|
365 360 | .unwrap();
|
366 361 | #[allow(unused_mut)]
|
367 362 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
368 363 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
369 364 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
370 365 | .malformed_enum(
|
371 366 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
372 367 | // since `send()` only borrows it.
|
373 368 | #[allow(unused_assignments)]
|
374 369 | move |input: crate::input::MalformedEnumInput| {
|
375 370 | let sender = sender.clone();
|
376 371 | async move {
|
377 372 | 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> };
|
378 373 | sender.send(()).await.expect("receiver dropped early");
|
379 374 | result
|
380 375 | }
|
381 376 | }
|
382 377 | )
|
383 378 | .build_unchecked();
|
384 379 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
385 380 | .await
|
386 381 | .expect("unable to make an HTTP request");
|
387 382 | ::pretty_assertions::assert_eq!(
|
388 383 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
389 384 | http_response.status()
|
390 385 | );
|
391 386 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
392 387 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
393 388 | http_response.headers(),
|
394 389 | expected_headers,
|
395 390 | ));
|
396 391 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
397 392 | .await
|
398 393 | .expect("unable to extract body to bytes");
|
399 394 | ::aws_smithy_protocol_test::assert_ok(
|
400 395 | ::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"))
|
401 396 | );
|
402 397 | }
|
403 398 | }
|
404 399 |
|
405 400 | /// When a list member value does not contain a valid enum value,
|
406 401 | /// the response should be a 400 ValidationException. Internal-only
|
407 402 | /// enum values are excluded from the response message.
|
408 403 | /// Test ID: RestJsonMalformedEnumList_case1
|
409 404 | #[::tokio::test]
|
410 405 | #[::tracing_test::traced_test]
|
411 - | #[should_panic]
|
412 406 | async fn rest_json_malformed_enum_list_case1_malformed_request() {
|
413 407 | {
|
414 408 | #[allow(unused_mut)]
|
415 409 | let mut http_request = ::http::Request::builder()
|
416 410 | .uri("/MalformedEnum")
|
417 411 | .method("POST")
|
418 412 | .header("content-type", "application/json")
|
419 413 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
420 414 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
421 415 | "{ \"list\" : [\"XYZ\"] }".as_bytes(),
|
422 416 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
423 417 | )),
|
424 418 | ))
|
425 419 | .unwrap();
|
426 420 | #[allow(unused_mut)]
|
427 421 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
428 422 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
429 423 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
430 424 | .malformed_enum(
|
431 425 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
432 426 | // since `send()` only borrows it.
|
433 427 | #[allow(unused_assignments)]
|
434 428 | move |input: crate::input::MalformedEnumInput| {
|
435 429 | let sender = sender.clone();
|
436 430 | async move {
|
437 431 | 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> };
|
438 432 | sender.send(()).await.expect("receiver dropped early");
|
439 433 | result
|
440 434 | }
|
441 435 | }
|
442 436 | )
|
443 437 | .build_unchecked();
|
444 438 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
445 439 | .await
|
446 440 | .expect("unable to make an HTTP request");
|
447 441 | ::pretty_assertions::assert_eq!(
|
448 442 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
449 443 | http_response.status()
|
450 444 | );
|
451 445 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
452 446 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
453 447 | http_response.headers(),
|
454 448 | expected_headers,
|
455 449 | ));
|
456 450 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
457 451 | .await
|
458 452 | .expect("unable to extract body to bytes");
|
459 453 | ::aws_smithy_protocol_test::assert_ok(
|
460 454 | ::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"))
|
461 455 | );
|
462 456 | }
|
463 457 | }
|
464 458 |
|
465 459 | /// When a map member's key does not contain a valid enum value,
|
466 460 | /// the response should be a 400 ValidationException. Internal-only
|
467 461 | /// enum values are excluded from the response message.
|
468 462 | /// Test ID: RestJsonMalformedEnumMapKey_case0
|
469 463 | #[::tokio::test]
|
470 464 | #[::tracing_test::traced_test]
|
471 - | #[should_panic]
|
472 465 | async fn rest_json_malformed_enum_map_key_case0_malformed_request() {
|
473 466 | {
|
474 467 | #[allow(unused_mut)]
|
475 468 | let mut http_request = ::http::Request::builder()
|
476 469 | .uri("/MalformedEnum")
|
477 470 | .method("POST")
|
478 471 | .header("content-type", "application/json")
|
479 472 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
480 473 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
481 474 | "{ \"map\" : { \"ABC\" : \"abc\" } }".as_bytes(),
|
482 475 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
483 476 | )),
|
484 477 | ))
|
485 478 | .unwrap();
|
486 479 | #[allow(unused_mut)]
|
487 480 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
488 481 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
489 482 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
490 483 | .malformed_enum(
|
491 484 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
492 485 | // since `send()` only borrows it.
|
493 486 | #[allow(unused_assignments)]
|
494 487 | move |input: crate::input::MalformedEnumInput| {
|
495 488 | let sender = sender.clone();
|
496 489 | async move {
|
497 490 | 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> };
|
498 491 | sender.send(()).await.expect("receiver dropped early");
|
499 492 | result
|
500 493 | }
|
501 494 | }
|
502 495 | )
|
503 496 | .build_unchecked();
|
504 497 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
505 498 | .await
|
506 499 | .expect("unable to make an HTTP request");
|
507 500 | ::pretty_assertions::assert_eq!(
|
508 501 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
509 502 | http_response.status()
|
510 503 | );
|
511 504 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
512 505 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
513 506 | http_response.headers(),
|
514 507 | expected_headers,
|
515 508 | ));
|
516 509 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
517 510 | .await
|
518 511 | .expect("unable to extract body to bytes");
|
519 512 | ::aws_smithy_protocol_test::assert_ok(
|
520 513 | ::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"))
|
521 514 | );
|
522 515 | }
|
523 516 | }
|
524 517 |
|
525 518 | /// When a map member's key does not contain a valid enum value,
|
526 519 | /// the response should be a 400 ValidationException. Internal-only
|
527 520 | /// enum values are excluded from the response message.
|
528 521 | /// Test ID: RestJsonMalformedEnumMapKey_case1
|
529 522 | #[::tokio::test]
|
530 523 | #[::tracing_test::traced_test]
|
531 - | #[should_panic]
|
532 524 | async fn rest_json_malformed_enum_map_key_case1_malformed_request() {
|
533 525 | {
|
534 526 | #[allow(unused_mut)]
|
535 527 | let mut http_request = ::http::Request::builder()
|
536 528 | .uri("/MalformedEnum")
|
537 529 | .method("POST")
|
538 530 | .header("content-type", "application/json")
|
539 531 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
540 532 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
541 533 | "{ \"map\" : { \"XYZ\" : \"abc\" } }".as_bytes(),
|
542 534 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
543 535 | )),
|
544 536 | ))
|
545 537 | .unwrap();
|
546 538 | #[allow(unused_mut)]
|
547 539 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
548 540 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
549 541 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
550 542 | .malformed_enum(
|
551 543 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
552 544 | // since `send()` only borrows it.
|
553 545 | #[allow(unused_assignments)]
|
554 546 | move |input: crate::input::MalformedEnumInput| {
|
555 547 | let sender = sender.clone();
|
556 548 | async move {
|
557 549 | 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> };
|
558 550 | sender.send(()).await.expect("receiver dropped early");
|
559 551 | result
|
560 552 | }
|
561 553 | }
|
562 554 | )
|
563 555 | .build_unchecked();
|
564 556 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
565 557 | .await
|
566 558 | .expect("unable to make an HTTP request");
|
567 559 | ::pretty_assertions::assert_eq!(
|
568 560 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
569 561 | http_response.status()
|
570 562 | );
|
571 563 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
572 564 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
573 565 | http_response.headers(),
|
574 566 | expected_headers,
|
575 567 | ));
|
576 568 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
577 569 | .await
|
578 570 | .expect("unable to extract body to bytes");
|
579 571 | ::aws_smithy_protocol_test::assert_ok(
|
580 572 | ::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"))
|
581 573 | );
|
582 574 | }
|
583 575 | }
|
584 576 |
|
585 577 | /// When a map member's value does not contain a valid enum value,
|
586 578 | /// the response should be a 400 ValidationException. Internal-only
|
587 579 | /// enum values are excluded from the response message.
|
588 580 | /// Test ID: RestJsonMalformedEnumMapValue_case0
|
589 581 | #[::tokio::test]
|
590 582 | #[::tracing_test::traced_test]
|
591 - | #[should_panic]
|
592 583 | async fn rest_json_malformed_enum_map_value_case0_malformed_request() {
|
593 584 | {
|
594 585 | #[allow(unused_mut)]
|
595 586 | let mut http_request = ::http::Request::builder()
|
596 587 | .uri("/MalformedEnum")
|
597 588 | .method("POST")
|
598 589 | .header("content-type", "application/json")
|
599 590 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
600 591 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
601 592 | "{ \"map\" : { \"abc\": \"ABC\" } }".as_bytes(),
|
602 593 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
603 594 | )),
|
604 595 | ))
|
605 596 | .unwrap();
|
606 597 | #[allow(unused_mut)]
|
607 598 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
608 599 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
609 600 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
610 601 | .malformed_enum(
|
611 602 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
612 603 | // since `send()` only borrows it.
|
613 604 | #[allow(unused_assignments)]
|
614 605 | move |input: crate::input::MalformedEnumInput| {
|
615 606 | let sender = sender.clone();
|
616 607 | async move {
|
617 608 | 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> };
|
618 609 | sender.send(()).await.expect("receiver dropped early");
|
619 610 | result
|
620 611 | }
|
621 612 | }
|
622 613 | )
|
623 614 | .build_unchecked();
|
624 615 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
625 616 | .await
|
626 617 | .expect("unable to make an HTTP request");
|
627 618 | ::pretty_assertions::assert_eq!(
|
628 619 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
629 620 | http_response.status()
|
630 621 | );
|
631 622 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
632 623 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
633 624 | http_response.headers(),
|
634 625 | expected_headers,
|
635 626 | ));
|
636 627 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
637 628 | .await
|
638 629 | .expect("unable to extract body to bytes");
|
639 630 | ::aws_smithy_protocol_test::assert_ok(
|
640 631 | ::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"))
|
641 632 | );
|
642 633 | }
|
643 634 | }
|
644 635 |
|
645 636 | /// When a map member's value does not contain a valid enum value,
|
646 637 | /// the response should be a 400 ValidationException. Internal-only
|
647 638 | /// enum values are excluded from the response message.
|
648 639 | /// Test ID: RestJsonMalformedEnumMapValue_case1
|
649 640 | #[::tokio::test]
|
650 641 | #[::tracing_test::traced_test]
|
651 - | #[should_panic]
|
652 642 | async fn rest_json_malformed_enum_map_value_case1_malformed_request() {
|
653 643 | {
|
654 644 | #[allow(unused_mut)]
|
655 645 | let mut http_request = ::http::Request::builder()
|
656 646 | .uri("/MalformedEnum")
|
657 647 | .method("POST")
|
658 648 | .header("content-type", "application/json")
|
659 649 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
660 650 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
661 651 | "{ \"map\" : { \"abc\": \"XYZ\" } }".as_bytes(),
|
662 652 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
663 653 | )),
|
664 654 | ))
|
665 655 | .unwrap();
|
666 656 | #[allow(unused_mut)]
|
667 657 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
668 658 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
669 659 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
670 660 | .malformed_enum(
|
671 661 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
672 662 | // since `send()` only borrows it.
|
673 663 | #[allow(unused_assignments)]
|
674 664 | move |input: crate::input::MalformedEnumInput| {
|
675 665 | let sender = sender.clone();
|
676 666 | async move {
|
677 667 | 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> };
|
678 668 | sender.send(()).await.expect("receiver dropped early");
|
679 669 | result
|
680 670 | }
|
681 671 | }
|
682 672 | )
|
683 673 | .build_unchecked();
|
684 674 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
685 675 | .await
|
686 676 | .expect("unable to make an HTTP request");
|
687 677 | ::pretty_assertions::assert_eq!(
|
688 678 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
689 679 | http_response.status()
|
690 680 | );
|
691 681 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
692 682 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
693 683 | http_response.headers(),
|
694 684 | expected_headers,
|
695 685 | ));
|
696 686 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
697 687 | .await
|
698 688 | .expect("unable to extract body to bytes");
|
699 689 | ::aws_smithy_protocol_test::assert_ok(
|
700 690 | ::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"))
|
701 691 | );
|
702 692 | }
|
703 693 | }
|
704 694 |
|
705 695 | /// When a union member's value does not contain a valid enum value,
|
706 696 | /// the response should be a 400 ValidationException. Internal-only
|
707 697 | /// enum values are excluded from the response message.
|
708 698 | /// Test ID: RestJsonMalformedEnumUnion_case0
|
709 699 | #[::tokio::test]
|
710 700 | #[::tracing_test::traced_test]
|
711 - | #[should_panic]
|
712 701 | async fn rest_json_malformed_enum_union_case0_malformed_request() {
|
713 702 | {
|
714 703 | #[allow(unused_mut)]
|
715 704 | let mut http_request = ::http::Request::builder()
|
716 705 | .uri("/MalformedEnum")
|
717 706 | .method("POST")
|
718 707 | .header("content-type", "application/json")
|
719 708 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
720 709 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
721 710 | "{ \"union\" : { \"first\": \"ABC\" } }".as_bytes(),
|
722 711 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
723 712 | )),
|
724 713 | ))
|
725 714 | .unwrap();
|
726 715 | #[allow(unused_mut)]
|
727 716 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
728 717 | let config = crate::service::RestJsonValidationConfig::builder().build();
|
729 718 | let service = crate::service::RestJsonValidation::builder::<::hyper::body::Body, _, _, _>(config)
|
730 719 | .malformed_enum(
|
731 720 | // Rust 1.94+ flags the moved `sender` as "value captured is never read"
|
732 721 | // since `send()` only borrows it.
|
733 722 | #[allow(unused_assignments)]
|
734 723 | move |input: crate::input::MalformedEnumInput| {
|
735 724 | let sender = sender.clone();
|
736 725 | async move {
|
737 726 | 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> };
|
738 727 | sender.send(()).await.expect("receiver dropped early");
|
739 728 | result
|
740 729 | }
|
741 730 | }
|
742 731 | )
|
743 732 | .build_unchecked();
|
744 733 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
745 734 | .await
|
746 735 | .expect("unable to make an HTTP request");
|
747 736 | ::pretty_assertions::assert_eq!(
|
748 737 | ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
749 738 | http_response.status()
|
750 739 | );
|
751 740 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
752 741 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
753 742 | http_response.headers(),
|
754 743 | expected_headers,
|
755 744 | ));
|
756 745 | let body = ::hyper::body::to_bytes(http_response.into_body())
|
757 746 | .await
|
758 747 | .expect("unable to extract body to bytes");
|
759 748 | ::aws_smithy_protocol_test::assert_ok(
|
760 749 | ::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"))
|
761 750 | );
|
762 751 | }
|
763 752 | }
|
764 753 |
|
765 754 | /// When a union member's value does not contain a valid enum value,
|
766 755 | /// the response should be a 400 ValidationException. Internal-only
|
767 756 | /// enum values are excluded from the response message.
|
768 757 | /// Test ID: RestJsonMalformedEnumUnion_case1
|
769 758 | #[::tokio::test]
|
770 759 | #[::tracing_test::traced_test]
|
771 - | #[should_panic]
|
772 760 | async fn rest_json_malformed_enum_union_case1_malformed_request() {
|
773 761 | {
|
774 762 | #[allow(unused_mut)]
|
775 763 | let mut http_request = ::http::Request::builder()
|
776 764 | .uri("/MalformedEnum")
|
777 765 | .method("POST")
|
778 766 | .header("content-type", "application/json")
|
779 767 | .body(::aws_smithy_legacy_http_server::body::Body::from(
|
780 768 | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
781 769 | "{ \"union\" : { \"first\": \"XYZ\" } }".as_bytes(),
|