Skip to content

Commit

Permalink
Try copy with static credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdchak committed Oct 5, 2024
1 parent 9a6baf3 commit 6af563d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion mountpoint-s3-client/tests/copy_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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, &copy_key)
.await
Expand Down

0 comments on commit 6af563d

Please sign in to comment.