390 390 | #[allow(unreachable_code, unused_variables)]
|
391 391 | #[cfg(test)]
|
392 392 | mod get_object_test {
|
393 393 |
|
394 394 | /// https://github.com/awslabs/aws-sdk-rust/issues/818
|
395 395 | /// Test ID: GetObjectIfModifiedSince
|
396 396 | #[::tokio::test]
|
397 397 | #[::tracing_test::traced_test]
|
398 398 | async fn get_object_if_modified_since_request() {
|
399 399 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
400 - | let config_builder = crate::config::Config::builder().with_test_defaults().endpoint_url("https://example.com");
|
400 + | let config_builder = crate::config::Config::builder()
|
401 + | .with_test_defaults()
|
402 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
403 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
404 + | .allow_no_auth()
|
405 + | .endpoint_url("https://example.com");
|
401 406 | let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
|
402 407 | let mut config_builder = config_builder;
|
403 408 | config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
|
404 409 |
|
405 410 | let config = config_builder.http_client(http_client).build();
|
406 411 | let client = crate::Client::from_conf(config);
|
407 412 | let result = client
|
408 413 | .get_object()
|
409 414 | .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
|
410 415 | .set_key(::std::option::Option::Some("object.txt".to_owned()))
|
411 416 | .set_if_modified_since(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(
|
412 417 | 1626452453, 0.123_f64,
|
413 418 | )))
|
414 419 | .send()
|
415 420 | .await;
|
416 421 | let _ = dbg!(result);
|
417 422 | let http_request = request_receiver.expect_request();
|
418 423 | let expected_headers = [("if-modified-since", "Fri, 16 Jul 2021 16:20:53 GMT")];
|
419 424 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
420 425 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
421 426 | ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
|
422 427 | ::pretty_assertions::assert_eq!(uri.path(), "/object.txt", "path was incorrect");
|
423 428 | }
|
424 429 |
|
425 430 | /// S3 clients should not remove dot segments from request paths.
|
426 431 | ///
|
427 432 | /// Test ID: S3PreservesLeadingDotSegmentInUriLabel
|
428 433 | #[::tokio::test]
|
429 434 | #[::tracing_test::traced_test]
|
430 435 | async fn s3_preserves_leading_dot_segment_in_uri_label_request() {
|
431 436 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
432 437 | let config_builder = crate::config::Config::builder()
|
433 438 | .with_test_defaults()
|
439 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
440 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
441 + | .allow_no_auth()
|
434 442 | .endpoint_url("https://s3.us-west-2.amazonaws.com");
|
435 443 |
|
436 444 | let mut config_builder = config_builder;
|
437 445 | config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
|
438 446 |
|
439 447 | let config = config_builder.http_client(http_client).build();
|
440 448 | let client = crate::Client::from_conf(config);
|
441 449 | let result = client
|
442 450 | .get_object()
|
443 451 | .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
|
444 452 | .set_key(::std::option::Option::Some("../key.txt".to_owned()))
|
445 453 | .send()
|
446 454 | .await;
|
447 455 | let _ = dbg!(result);
|
448 456 | let http_request = request_receiver.expect_request();
|
449 457 | let body = http_request.body().bytes().expect("body should be strict");
|
450 458 | // No body.
|
451 459 | ::pretty_assertions::assert_eq!(&body, &::bytes::Bytes::new());
|
452 460 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
453 461 | ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
|
454 462 | ::pretty_assertions::assert_eq!(uri.path(), "/../key.txt", "path was incorrect");
|
455 463 | ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
|
456 464 | }
|
457 465 |
|
458 466 | /// S3 clients should not remove dot segments from request paths.
|
459 467 | ///
|
460 468 | /// Test ID: S3PreservesEmbeddedDotSegmentInUriLabel
|
461 469 | #[::tokio::test]
|
462 470 | #[::tracing_test::traced_test]
|
463 471 | async fn s3_preserves_embedded_dot_segment_in_uri_label_request() {
|
464 472 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
465 473 | let config_builder = crate::config::Config::builder()
|
466 474 | .with_test_defaults()
|
475 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
476 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
477 + | .allow_no_auth()
|
467 478 | .endpoint_url("https://s3.us-west-2.amazonaws.com");
|
468 479 |
|
469 480 | let mut config_builder = config_builder;
|
470 481 | config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
|
471 482 |
|
472 483 | let config = config_builder.http_client(http_client).build();
|
473 484 | let client = crate::Client::from_conf(config);
|
474 485 | let result = client
|
475 486 | .get_object()
|
476 487 | .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
|
477 488 | .set_key(::std::option::Option::Some("foo/../key.txt".to_owned()))
|
478 489 | .send()
|
479 490 | .await;
|
480 491 | let _ = dbg!(result);
|
481 492 | let http_request = request_receiver.expect_request();
|
482 493 | let body = http_request.body().bytes().expect("body should be strict");
|
483 494 | // No body.
|
484 495 | ::pretty_assertions::assert_eq!(&body, &::bytes::Bytes::new());
|
485 496 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
486 497 | ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
|
487 498 | ::pretty_assertions::assert_eq!(uri.path(), "/foo/../key.txt", "path was incorrect");
|
488 499 | ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
|
489 500 | }
|
490 501 | }
|
491 502 |
|
492 503 | /// Error type for the `GetObjectError` operation.
|
493 504 | #[non_exhaustive]
|
494 505 | #[derive(::std::fmt::Debug)]
|
495 506 | pub enum GetObjectError {
|
496 507 | /// <p>Object is archived and inaccessible until restored.</p>
|