From 6af563d27b084db51a0f378a124307f8dd43f631 Mon Sep 17 00:00:00 2001 From: rajdchak Date: Sat, 5 Oct 2024 09:58:05 +0100 Subject: [PATCH] Try copy with static credentials --- mountpoint-s3-client/tests/copy_object.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mountpoint-s3-client/tests/copy_object.rs b/mountpoint-s3-client/tests/copy_object.rs index 2dd21ee48..3d2e0ac38 100644 --- a/mountpoint-s3-client/tests/copy_object.rs +++ b/mountpoint-s3-client/tests/copy_object.rs @@ -3,10 +3,14 @@ pub mod common; use aws_sdk_s3::primitives::ByteStream; use bytes::Bytes; +use common::creds::{get_sdk_default_chain_creds, get_subsession_iam_role}; use common::*; +use mountpoint_s3_client::config::{EndpointConfig, S3ClientAuthConfig, S3ClientConfig}; use mountpoint_s3_client::error::ObjectClientError; use mountpoint_s3_client::S3RequestError; use mountpoint_s3_client::{ObjectClient, S3CrtClient}; +use mountpoint_s3_crt::auth::credentials::{CredentialsProvider, CredentialsProviderStaticOptions}; +use mountpoint_s3_crt::common::allocator::Allocator; #[tokio::test] async fn test_copy_objects() { let sdk_client = get_test_sdk_client().await; @@ -23,10 +27,23 @@ async fn test_copy_objects() { .await .unwrap(); + let credentials = get_sdk_default_chain_creds().await; + + // Build a S3CrtClient that uses a static credentials provider with the creds we just got + let config = CredentialsProviderStaticOptions { + access_key_id: credentials.access_key_id(), + secret_access_key: credentials.secret_access_key(), + session_token: credentials.session_token(), + }; + let provider = CredentialsProvider::new_static(&Allocator::default(), config).unwrap(); + let config = S3ClientConfig::new() + .auth_config(S3ClientAuthConfig::Provider(provider)) + .endpoint_config(EndpointConfig::new(&get_test_region())); + let client = S3CrtClient::new(config).unwrap(); + let copy_prefix = get_unique_test_prefix("test_copy_object_prefix2"); let copy_key = format!("{copy_prefix}/hello2"); - let client: S3CrtClient = get_test_client(); let _result = client .copy_object(&bucket, &key, &bucket, ©_key) .await