213 213 | let params = crate::config::endpoint::Params::builder().build().map_err(|err| {
|
214 214 | ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
|
215 215 | })?;
|
216 216 | cfg.interceptor_state()
|
217 217 | .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
|
218 218 | ::std::result::Result::Ok(())
|
219 219 | }
|
220 220 | }
|
221 221 | #[allow(unreachable_code, unused_variables)]
|
222 222 | #[cfg(test)]
|
223 - | mod greeting_with_errors_request_test {
|
223 + | mod greeting_with_errors_test {
|
224 + |
|
224 225 | /// Ensures that operations with errors successfully know how
|
225 226 | /// to deserialize a successful response. As of January 2021,
|
226 227 | /// server implementations are expected to respond with a
|
227 228 | /// JSON object regardless of if the output parameters are
|
228 229 | /// empty.
|
229 230 | /// Test ID: RestJsonGreetingWithErrors
|
230 231 | #[::tokio::test]
|
231 - | #[allow(unused_mut)]
|
232 + | #[::tracing_test::traced_test]
|
232 233 | async fn rest_json_greeting_with_errors_response() {
|
233 234 | let expected_output = crate::operation::greeting_with_errors::GreetingWithErrorsOutput::builder()
|
234 235 | .set_greeting(::std::option::Option::Some("Hello".to_owned()))
|
235 236 | .build();
|
236 237 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
237 238 | ::http::response::Builder::new()
|
238 239 | .header("X-Greeting", "Hello")
|
239 240 | .status(200)
|
240 241 | .body(::aws_smithy_types::body::SdkBody::from("{}"))
|
241 242 | .unwrap(),
|
242 243 | )
|
243 244 | .unwrap();
|
244 245 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
245 246 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
246 247 |
|
247 248 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
248 249 | let config = op.config().expect("the operation has config");
|
249 250 | let de = config
|
250 251 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
251 252 | .expect("the config must have a deserializer");
|
252 253 |
|
253 254 | let parsed = de.deserialize_streaming(&mut http_response);
|
254 255 | let parsed = parsed.unwrap_or_else(|| {
|
255 256 | let http_response =
|
256 257 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
257 258 | de.deserialize_nonstreaming(&http_response)
|
258 259 | });
|
259 260 | let parsed = parsed
|
260 261 | .expect("should be successful response")
|
261 262 | .downcast::<crate::operation::greeting_with_errors::GreetingWithErrorsOutput>()
|
262 263 | .unwrap();
|
263 264 | ::pretty_assertions::assert_eq!(parsed.greeting, expected_output.greeting, "Unexpected value for `greeting`");
|
264 265 | }
|
265 266 | /// This test is similar to RestJsonGreetingWithErrors, but it
|
266 267 | /// ensures that clients can gracefully deal with a server
|
267 268 | /// omitting a response payload.
|
268 269 | /// Test ID: RestJsonGreetingWithErrorsNoPayload
|
269 270 | #[::tokio::test]
|
270 - | #[allow(unused_mut)]
|
271 + | #[::tracing_test::traced_test]
|
271 272 | async fn rest_json_greeting_with_errors_no_payload_response() {
|
272 273 | let expected_output = crate::operation::greeting_with_errors::GreetingWithErrorsOutput::builder()
|
273 274 | .set_greeting(::std::option::Option::Some("Hello".to_owned()))
|
274 275 | .build();
|
275 276 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
276 277 | ::http::response::Builder::new()
|
277 278 | .header("X-Greeting", "Hello")
|
278 279 | .status(200)
|
279 280 | .body(::aws_smithy_types::body::SdkBody::from(""))
|
280 281 | .unwrap(),
|
281 282 | )
|
282 283 | .unwrap();
|
283 284 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
284 285 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
285 286 |
|
286 287 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
287 288 | let config = op.config().expect("the operation has config");
|
288 289 | let de = config
|
289 290 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
290 291 | .expect("the config must have a deserializer");
|
291 292 |
|
292 293 | let parsed = de.deserialize_streaming(&mut http_response);
|
293 294 | let parsed = parsed.unwrap_or_else(|| {
|
294 295 | let http_response =
|
295 296 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
296 297 | de.deserialize_nonstreaming(&http_response)
|
297 298 | });
|
298 299 | let parsed = parsed
|
299 300 | .expect("should be successful response")
|
300 301 | .downcast::<crate::operation::greeting_with_errors::GreetingWithErrorsOutput>()
|
301 302 | .unwrap();
|
302 303 | ::pretty_assertions::assert_eq!(parsed.greeting, expected_output.greeting, "Unexpected value for `greeting`");
|
303 304 | }
|
304 305 | /// Parses simple JSON errors
|
305 306 | /// Test ID: RestJsonInvalidGreetingError
|
306 307 | #[::tokio::test]
|
307 - | #[allow(unused_mut)]
|
308 + | #[::tracing_test::traced_test]
|
308 309 | async fn rest_json_invalid_greeting_error_response() {
|
309 310 | let expected_output = crate::types::error::InvalidGreeting::builder()
|
310 311 | .set_message(::std::option::Option::Some("Hi".to_owned()))
|
311 312 | .build();
|
312 313 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
313 314 | ::http::response::Builder::new()
|
314 315 | .header("Content-Type", "application/json")
|
315 316 | .header("X-Amzn-Errortype", "InvalidGreeting")
|
316 317 | .status(400)
|
317 318 | .body(::aws_smithy_types::body::SdkBody::from("{\n \"Message\": \"Hi\"\n}"))
|
318 319 | .unwrap(),
|
319 320 | )
|
320 321 | .unwrap();
|
321 322 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
322 323 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
323 324 |
|
324 325 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
325 326 | let config = op.config().expect("the operation has config");
|
326 327 | let de = config
|
327 328 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
328 329 | .expect("the config must have a deserializer");
|
329 330 |
|
330 331 | let parsed = de.deserialize_streaming(&mut http_response);
|
331 332 | let parsed = parsed.unwrap_or_else(|| {
|
332 333 | let http_response =
|
333 334 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
334 335 | de.deserialize_nonstreaming(&http_response)
|
335 336 | });
|
336 337 | let parsed = parsed.expect_err("should be error response");
|
337 338 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
338 339 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
339 340 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::InvalidGreeting(parsed) = parsed {
|
340 341 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
341 342 | } else {
|
342 343 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
343 344 | }
|
344 345 | }
|
345 346 | /// Serializes a complex error with no message member
|
346 347 | /// Test ID: RestJsonComplexErrorWithNoMessage
|
347 348 | #[::tokio::test]
|
348 - | #[allow(unused_mut)]
|
349 + | #[::tracing_test::traced_test]
|
349 350 | async fn rest_json_complex_error_with_no_message_response() {
|
350 351 | let expected_output = crate::types::error::ComplexError::builder()
|
351 352 | .set_header(::std::option::Option::Some("Header".to_owned()))
|
352 353 | .set_top_level(::std::option::Option::Some("Top level".to_owned()))
|
353 354 | .set_nested(::std::option::Option::Some(
|
354 355 | crate::types::ComplexNestedErrorData::builder()
|
355 356 | .set_foo(::std::option::Option::Some("bar".to_owned()))
|
356 357 | .build(),
|
357 358 | ))
|
358 359 | .build();
|
359 360 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
360 361 | ::http::response::Builder::new()
|
361 362 | .header("Content-Type", "application/json")
|
362 363 | .header("X-Amzn-Errortype", "ComplexError")
|
363 364 | .header("X-Header", "Header")
|
364 365 | .status(403)
|
365 366 | .body(::aws_smithy_types::body::SdkBody::from(
|
366 367 | "{\n \"TopLevel\": \"Top level\",\n \"Nested\": {\n \"Fooooo\": \"bar\"\n }\n}",
|
367 368 | ))
|
368 369 | .unwrap(),
|
369 370 | )
|
370 371 | .unwrap();
|
371 372 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
372 373 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
373 374 |
|
374 375 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
375 376 | let config = op.config().expect("the operation has config");
|
376 377 | let de = config
|
377 378 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
378 379 | .expect("the config must have a deserializer");
|
379 380 |
|
380 381 | let parsed = de.deserialize_streaming(&mut http_response);
|
381 382 | let parsed = parsed.unwrap_or_else(|| {
|
382 383 | let http_response =
|
383 384 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
384 385 | de.deserialize_nonstreaming(&http_response)
|
385 386 | });
|
386 387 | let parsed = parsed.expect_err("should be error response");
|
387 388 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
388 389 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
389 390 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::ComplexError(parsed) = parsed {
|
390 391 | ::pretty_assertions::assert_eq!(parsed.header, expected_output.header, "Unexpected value for `header`");
|
391 392 | ::pretty_assertions::assert_eq!(parsed.top_level, expected_output.top_level, "Unexpected value for `top_level`");
|
392 393 | ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
|
393 394 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
394 395 | } else {
|
395 396 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
396 397 | }
|
397 398 | }
|
398 399 | /// Test ID: RestJsonEmptyComplexErrorWithNoMessage
|
399 400 | #[::tokio::test]
|
400 - | #[allow(unused_mut)]
|
401 + | #[::tracing_test::traced_test]
|
401 402 | async fn rest_json_empty_complex_error_with_no_message_response() {
|
402 403 | let expected_output = crate::types::error::ComplexError::builder().build();
|
403 404 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
404 405 | ::http::response::Builder::new()
|
405 406 | .header("Content-Type", "application/json")
|
406 407 | .header("X-Amzn-Errortype", "ComplexError")
|
407 408 | .status(403)
|
408 409 | .body(::aws_smithy_types::body::SdkBody::from("{}"))
|
409 410 | .unwrap(),
|
410 411 | )
|
411 412 | .unwrap();
|
412 413 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
413 414 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
414 415 |
|
415 416 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
416 417 | let config = op.config().expect("the operation has config");
|
417 418 | let de = config
|
418 419 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
419 420 | .expect("the config must have a deserializer");
|
420 421 |
|
421 422 | let parsed = de.deserialize_streaming(&mut http_response);
|
422 423 | let parsed = parsed.unwrap_or_else(|| {
|
423 424 | let http_response =
|
424 425 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
425 426 | de.deserialize_nonstreaming(&http_response)
|
426 427 | });
|
427 428 | let parsed = parsed.expect_err("should be error response");
|
428 429 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
429 430 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
430 431 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::ComplexError(parsed) = parsed {
|
431 432 | ::pretty_assertions::assert_eq!(parsed.header, expected_output.header, "Unexpected value for `header`");
|
432 433 | ::pretty_assertions::assert_eq!(parsed.top_level, expected_output.top_level, "Unexpected value for `top_level`");
|
433 434 | ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
|
434 435 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
435 436 | } else {
|
436 437 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
437 438 | }
|
438 439 | }
|
439 440 | /// Serializes the X-Amzn-ErrorType header. For an example service, see Amazon EKS.
|
440 441 | /// Test ID: RestJsonFooErrorUsingXAmznErrorType
|
441 442 | #[::tokio::test]
|
442 - | #[allow(unused_mut)]
|
443 + | #[::tracing_test::traced_test]
|
443 444 | async fn rest_json_foo_error_using_x_amzn_error_type_response() {
|
444 445 | let expected_output = crate::types::error::FooError::builder().build();
|
445 446 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
446 447 | ::http::response::Builder::new()
|
447 448 | .header("X-Amzn-Errortype", "FooError")
|
448 449 | .status(500)
|
449 450 | .body(::aws_smithy_types::body::SdkBody::from(vec![]))
|
450 451 | .unwrap(),
|
451 452 | )
|
452 453 | .unwrap();
|
453 454 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
454 455 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
455 456 |
|
456 457 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
457 458 | let config = op.config().expect("the operation has config");
|
458 459 | let de = config
|
459 460 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
460 461 | .expect("the config must have a deserializer");
|
461 462 |
|
462 463 | let parsed = de.deserialize_streaming(&mut http_response);
|
463 464 | let parsed = parsed.unwrap_or_else(|| {
|
464 465 | let http_response =
|
465 466 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
466 467 | de.deserialize_nonstreaming(&http_response)
|
467 468 | });
|
468 469 | let parsed = parsed.expect_err("should be error response");
|
469 470 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
470 471 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
471 472 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
472 473 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
473 474 | } else {
|
474 475 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
475 476 | }
|
476 477 | }
|
477 478 | /// Some X-Amzn-Errortype headers contain URLs. Clients need to split the URL on ':' and take only the first half of the string. For example, 'ValidationException:http://internal.amazon.com/coral/com.amazon.coral.validate/'
|
478 479 | /// is to be interpreted as 'ValidationException'.
|
479 480 | ///
|
480 481 | /// For an example service see Amazon Polly.
|
481 482 | /// Test ID: RestJsonFooErrorUsingXAmznErrorTypeWithUri
|
482 483 | #[::tokio::test]
|
483 - | #[allow(unused_mut)]
|
484 + | #[::tracing_test::traced_test]
|
484 485 | async fn rest_json_foo_error_using_x_amzn_error_type_with_uri_response() {
|
485 486 | let expected_output = crate::types::error::FooError::builder().build();
|
486 487 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
487 488 | ::http::response::Builder::new()
|
488 489 | .header("X-Amzn-Errortype", "FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/")
|
489 490 | .status(500)
|
490 491 | .body(::aws_smithy_types::body::SdkBody::from(vec![]))
|
491 492 | .unwrap(),
|
492 493 | )
|
493 494 | .unwrap();
|
494 495 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
495 496 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
496 497 |
|
497 498 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
498 499 | let config = op.config().expect("the operation has config");
|
499 500 | let de = config
|
500 501 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
501 502 | .expect("the config must have a deserializer");
|
502 503 |
|
503 504 | let parsed = de.deserialize_streaming(&mut http_response);
|
504 505 | let parsed = parsed.unwrap_or_else(|| {
|
505 506 | let http_response =
|
506 507 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
507 508 | de.deserialize_nonstreaming(&http_response)
|
508 509 | });
|
509 510 | let parsed = parsed.expect_err("should be error response");
|
510 511 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
511 512 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
512 513 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
513 514 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
514 515 | } else {
|
515 516 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
516 517 | }
|
517 518 | }
|
518 519 | /// X-Amzn-Errortype might contain a URL and a namespace. Client should extract only the shape name. This is a pathalogical case that might not actually happen in any deployed AWS service.
|
519 520 | /// Test ID: RestJsonFooErrorUsingXAmznErrorTypeWithUriAndNamespace
|
520 521 | #[::tokio::test]
|
521 - | #[allow(unused_mut)]
|
522 + | #[::tracing_test::traced_test]
|
522 523 | async fn rest_json_foo_error_using_x_amzn_error_type_with_uri_and_namespace_response() {
|
523 524 | let expected_output = crate::types::error::FooError::builder().build();
|
524 525 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
525 526 | ::http::response::Builder::new()
|
526 527 | .header(
|
527 528 | "X-Amzn-Errortype",
|
528 529 | "aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/",
|
529 530 | )
|
530 531 | .status(500)
|
531 532 | .body(::aws_smithy_types::body::SdkBody::from(vec![]))
|
532 533 | .unwrap(),
|
533 534 | )
|
534 535 | .unwrap();
|
535 536 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
536 537 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
537 538 |
|
538 539 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
539 540 | let config = op.config().expect("the operation has config");
|
540 541 | let de = config
|
541 542 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
542 543 | .expect("the config must have a deserializer");
|
543 544 |
|
544 545 | let parsed = de.deserialize_streaming(&mut http_response);
|
545 546 | let parsed = parsed.unwrap_or_else(|| {
|
546 547 | let http_response =
|
547 548 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
548 549 | de.deserialize_nonstreaming(&http_response)
|
549 550 | });
|
550 551 | let parsed = parsed.expect_err("should be error response");
|
551 552 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
552 553 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
553 554 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
554 555 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
555 556 | } else {
|
556 557 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
557 558 | }
|
558 559 | }
|
559 560 | /// This example uses the 'code' property in the output rather than X-Amzn-Errortype. Some services do this though it's preferable to send the X-Amzn-Errortype. Client implementations must first check for the X-Amzn-Errortype and then check for a top-level 'code' property.
|
560 561 | ///
|
561 562 | /// For example service see Amazon S3 Glacier.
|
562 563 | /// Test ID: RestJsonFooErrorUsingCode
|
563 564 | #[::tokio::test]
|
564 - | #[allow(unused_mut)]
|
565 + | #[::tracing_test::traced_test]
|
565 566 | async fn rest_json_foo_error_using_code_response() {
|
566 567 | let expected_output = crate::types::error::FooError::builder().build();
|
567 568 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
568 569 | ::http::response::Builder::new()
|
569 570 | .header("Content-Type", "application/json")
|
570 571 | .status(500)
|
571 572 | .body(::aws_smithy_types::body::SdkBody::from("{\n \"code\": \"FooError\"\n}"))
|
572 573 | .unwrap(),
|
573 574 | )
|
574 575 | .unwrap();
|
575 576 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
576 577 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
577 578 |
|
578 579 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
579 580 | let config = op.config().expect("the operation has config");
|
580 581 | let de = config
|
581 582 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
582 583 | .expect("the config must have a deserializer");
|
583 584 |
|
584 585 | let parsed = de.deserialize_streaming(&mut http_response);
|
585 586 | let parsed = parsed.unwrap_or_else(|| {
|
586 587 | let http_response =
|
587 588 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
588 589 | de.deserialize_nonstreaming(&http_response)
|
589 590 | });
|
590 591 | let parsed = parsed.expect_err("should be error response");
|
591 592 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
592 593 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
593 594 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
594 595 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
595 596 | } else {
|
596 597 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
597 598 | }
|
598 599 | }
|
599 600 | /// Some services serialize errors using code, and it might contain a namespace. Clients should just take the last part of the string after '#'.
|
600 601 | /// Test ID: RestJsonFooErrorUsingCodeAndNamespace
|
601 602 | #[::tokio::test]
|
602 - | #[allow(unused_mut)]
|
603 + | #[::tracing_test::traced_test]
|
603 604 | async fn rest_json_foo_error_using_code_and_namespace_response() {
|
604 605 | let expected_output = crate::types::error::FooError::builder().build();
|
605 606 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
606 607 | ::http::response::Builder::new()
|
607 608 | .header("Content-Type", "application/json")
|
608 609 | .status(500)
|
609 610 | .body(::aws_smithy_types::body::SdkBody::from(
|
610 611 | "{\n \"code\": \"aws.protocoltests.restjson#FooError\"\n}",
|
611 612 | ))
|
612 613 | .unwrap(),
|
613 614 | )
|
614 615 | .unwrap();
|
615 616 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
616 617 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
617 618 |
|
618 619 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
619 620 | let config = op.config().expect("the operation has config");
|
620 621 | let de = config
|
621 622 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
622 623 | .expect("the config must have a deserializer");
|
623 624 |
|
624 625 | let parsed = de.deserialize_streaming(&mut http_response);
|
625 626 | let parsed = parsed.unwrap_or_else(|| {
|
626 627 | let http_response =
|
627 628 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
628 629 | de.deserialize_nonstreaming(&http_response)
|
629 630 | });
|
630 631 | let parsed = parsed.expect_err("should be error response");
|
631 632 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
632 633 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
633 634 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
634 635 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
635 636 | } else {
|
636 637 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
637 638 | }
|
638 639 | }
|
639 640 | /// Some services serialize errors using code, and it might contain a namespace. It also might contain a URI. Clients should just take the last part of the string after '#' and before ":". This is a pathalogical case that might not occur in any deployed AWS service.
|
640 641 | /// Test ID: RestJsonFooErrorUsingCodeUriAndNamespace
|
641 642 | #[::tokio::test]
|
642 - | #[allow(unused_mut)]
|
643 + | #[::tracing_test::traced_test]
|
643 644 | async fn rest_json_foo_error_using_code_uri_and_namespace_response() {
|
644 645 | let expected_output = crate::types::error::FooError::builder().build();
|
645 646 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
646 647 | ::http::response::Builder::new()
|
647 648 | .header("Content-Type", "application/json")
|
648 649 | .status(500)
|
649 650 | .body(::aws_smithy_types::body::SdkBody::from(
|
650 651 | "{\n \"code\": \"aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/\"\n}",
|
651 652 | ))
|
652 653 | .unwrap(),
|
653 654 | )
|
654 655 | .unwrap();
|
655 656 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
656 657 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
657 658 |
|
658 659 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
659 660 | let config = op.config().expect("the operation has config");
|
660 661 | let de = config
|
661 662 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
662 663 | .expect("the config must have a deserializer");
|
663 664 |
|
664 665 | let parsed = de.deserialize_streaming(&mut http_response);
|
665 666 | let parsed = parsed.unwrap_or_else(|| {
|
666 667 | let http_response =
|
667 668 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
668 669 | de.deserialize_nonstreaming(&http_response)
|
669 670 | });
|
670 671 | let parsed = parsed.expect_err("should be error response");
|
671 672 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
672 673 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
673 674 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
674 675 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
675 676 | } else {
|
676 677 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
677 678 | }
|
678 679 | }
|
679 680 | /// Some services serialize errors using __type.
|
680 681 | /// Test ID: RestJsonFooErrorWithDunderType
|
681 682 | #[::tokio::test]
|
682 - | #[allow(unused_mut)]
|
683 + | #[::tracing_test::traced_test]
|
683 684 | async fn rest_json_foo_error_with_dunder_type_response() {
|
684 685 | let expected_output = crate::types::error::FooError::builder().build();
|
685 686 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
686 687 | ::http::response::Builder::new()
|
687 688 | .header("Content-Type", "application/json")
|
688 689 | .status(500)
|
689 690 | .body(::aws_smithy_types::body::SdkBody::from("{\n \"__type\": \"FooError\"\n}"))
|
690 691 | .unwrap(),
|
691 692 | )
|
692 693 | .unwrap();
|
693 694 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
694 695 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
695 696 |
|
696 697 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
697 698 | let config = op.config().expect("the operation has config");
|
698 699 | let de = config
|
699 700 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
700 701 | .expect("the config must have a deserializer");
|
701 702 |
|
702 703 | let parsed = de.deserialize_streaming(&mut http_response);
|
703 704 | let parsed = parsed.unwrap_or_else(|| {
|
704 705 | let http_response =
|
705 706 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
706 707 | de.deserialize_nonstreaming(&http_response)
|
707 708 | });
|
708 709 | let parsed = parsed.expect_err("should be error response");
|
709 710 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
710 711 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
711 712 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
712 713 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
713 714 | } else {
|
714 715 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
715 716 | }
|
716 717 | }
|
717 718 | /// Some services serialize errors using __type, and it might contain a namespace. Clients should just take the last part of the string after '#'.
|
718 719 | /// Test ID: RestJsonFooErrorWithDunderTypeAndNamespace
|
719 720 | #[::tokio::test]
|
720 - | #[allow(unused_mut)]
|
721 + | #[::tracing_test::traced_test]
|
721 722 | async fn rest_json_foo_error_with_dunder_type_and_namespace_response() {
|
722 723 | let expected_output = crate::types::error::FooError::builder().build();
|
723 724 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
724 725 | ::http::response::Builder::new()
|
725 726 | .header("Content-Type", "application/json")
|
726 727 | .status(500)
|
727 728 | .body(::aws_smithy_types::body::SdkBody::from(
|
728 729 | "{\n \"__type\": \"aws.protocoltests.restjson#FooError\"\n}",
|
729 730 | ))
|
730 731 | .unwrap(),
|
731 732 | )
|
732 733 | .unwrap();
|
733 734 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
734 735 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
735 736 |
|
736 737 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
737 738 | let config = op.config().expect("the operation has config");
|
738 739 | let de = config
|
739 740 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
740 741 | .expect("the config must have a deserializer");
|
741 742 |
|
742 743 | let parsed = de.deserialize_streaming(&mut http_response);
|
743 744 | let parsed = parsed.unwrap_or_else(|| {
|
744 745 | let http_response =
|
745 746 | http_response.map(|body| ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(body.bytes().unwrap())));
|
746 747 | de.deserialize_nonstreaming(&http_response)
|
747 748 | });
|
748 749 | let parsed = parsed.expect_err("should be error response");
|
749 750 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
750 751 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
751 752 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::FooError(parsed) = parsed {
|
752 753 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
753 754 | } else {
|
754 755 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
755 756 | }
|
756 757 | }
|
757 758 | /// Some services serialize errors using __type, and it might contain a namespace. It also might contain a URI. Clients should just take the last part of the string after '#' and before ":". This is a pathalogical case that might not occur in any deployed AWS service.
|
758 759 | /// Test ID: RestJsonFooErrorWithDunderTypeUriAndNamespace
|
759 760 | #[::tokio::test]
|
760 - | #[allow(unused_mut)]
|
761 + | #[::tracing_test::traced_test]
|
761 762 | async fn rest_json_foo_error_with_dunder_type_uri_and_namespace_response() {
|
762 763 | let expected_output = crate::types::error::FooError::builder().build();
|
763 764 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
764 765 | ::http::response::Builder::new()
|
765 766 | .header("Content-Type", "application/json")
|
766 767 | .status(500)
|
767 768 | .body(::aws_smithy_types::body::SdkBody::from(
|
768 769 | "{\n \"__type\": \"aws.protocoltests.restjson#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/\"\n}",
|
769 770 | ))
|
770 771 | .unwrap(),
|