From ad456dfafc18298051bb3e3cbe102470b4960b5b Mon Sep 17 00:00:00 2001 From: sbiscigl Date: Wed, 15 Oct 2025 16:02:50 -0400 Subject: [PATCH] Fix CRT constructor --- .../aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp | 2 +- .../BucketAndObjectOperationTest.cpp | 45 ++++++++++++++++++- .../s3/s3-crt/S3CrtServiceClientSourceInit.vm | 2 +- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/generated/src/aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp b/generated/src/aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp index abef68d748f..940650d5d03 100644 --- a/generated/src/aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp +++ b/generated/src/aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp @@ -283,7 +283,7 @@ S3CrtClient::S3CrtClient(const std::shared_ptr& credenti signPayloads, false), Aws::MakeShared(ALLOCATION_TAG)), - m_clientConfiguration(clientConfiguration, signPayloads), + m_clientConfiguration(clientConfiguration), m_credProvider(credentialsProvider), m_identityProvider(Aws::MakeShared(ALLOCATION_TAG, *this)) { diff --git a/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp index 4879d1a055f..2b383c69931 100644 --- a/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp @@ -84,6 +84,7 @@ namespace static std::string BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME = "largeeventstream"; static std::string BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME = "errorsinevent"; static std::string BASE_CHECKSUMS_BUCKET_NAME = "checksums-crt"; + static std::string BASE_CRT_CREDENTIALS_TEST_BUCKET_NAME = "crt-credentials-test"; static const char* ALLOCATION_TAG = "BucketAndObjectOperationTest"; static const char* TEST_OBJ_KEY = "TestObjectKey"; static const char* TEST_NOT_MODIFIED_OBJ_KEY = "TestNotModifiedObjectKey"; @@ -123,7 +124,8 @@ namespace std::ref(BASE_EVENT_STREAM_TEST_BUCKET_NAME), std::ref(BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME), std::ref(BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME), - std::ref(BASE_CHECKSUMS_BUCKET_NAME) + std::ref(BASE_CHECKSUMS_BUCKET_NAME), + std::ref(BASE_CRT_CREDENTIALS_TEST_BUCKET_NAME) }; for (auto& testBucketName : TEST_BUCKETS) @@ -171,6 +173,7 @@ namespace DeleteBucket(CalculateBucketName(BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME.c_str())); DeleteBucket(CalculateBucketName(BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME.c_str())); DeleteBucket(CalculateBucketName(BASE_CHECKSUMS_BUCKET_NAME.c_str())); + DeleteBucket(CalculateBucketName(BASE_CRT_CREDENTIALS_TEST_BUCKET_NAME.c_str())); Client = nullptr; oregonClient = nullptr; @@ -1565,6 +1568,46 @@ namespace AWS_EXPECT_SUCCESS(response); } + TEST_F(BucketAndObjectOperationTest, ExplicitCredentialsProviderShouldWork) { + const Aws::String fullBucketName = CalculateBucketName(BASE_CHECKSUMS_BUCKET_NAME.c_str()); + const Aws::String testKey = "test-key.txt"; + SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); + CreateBucketRequest createBucketRequest; + createBucketRequest.SetBucket(fullBucketName); + createBucketRequest.SetACL(BucketCannedACL::private_); + CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest); + AWS_ASSERT_SUCCESS(createBucketOutcome); + + Aws::S3Crt::ClientConfiguration s3ClientConfig; + s3ClientConfig.region = Aws::Region::US_EAST_1; + s3ClientConfig.scheme = Scheme::HTTPS; + s3ClientConfig.executor = Aws::MakeShared(ALLOCATION_TAG, 4); + s3ClientConfig.throughputTargetGbps = 2.0; + s3ClientConfig.partSize = 5 * 1024 * 1024; + s3ClientConfig.contentLengthConfiguration = Aws::S3Crt::S3CrtClientConfiguration::CONTENT_LENGTH_CONFIGURATION::SKIP_CONTENT_LENGTH; + + // Assume that something in the default credentials provider chain works + const auto credsProvder = Aws::MakeShared(ALLOCATION_TAG); + S3CrtClient client{credsProvder, s3ClientConfig}; + + auto request = PutObjectRequest{}.WithBucket(fullBucketName) + .WithKey(testKey); + + // create 30 MiB test body + auto data = Aws::MakeShared(ALLOCATION_TAG); + *data << Aws::String(30 * 1024 * 1024, '*'); + request.SetBody(data); + + const auto putObjectOutcome = client.PutObject(request); + AWS_EXPECT_SUCCESS(putObjectOutcome); + + const auto headObjectResponse = client.HeadObject(HeadObjectRequest{}.WithBucket(fullBucketName) + .WithKey(testKey)); + AWS_EXPECT_SUCCESS(headObjectResponse); + const int THIRTY_MiB{31457280}; + EXPECT_EQ(THIRTY_MiB, headObjectResponse.GetResult().GetContentLength()); + } + class TestMonitoring: public Aws::Monitoring::MonitoringInterface { mutable std::shared_ptr> m_sequence; diff --git a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/s3-crt/S3CrtServiceClientSourceInit.vm b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/s3-crt/S3CrtServiceClientSourceInit.vm index faece3b4014..35a36e5cfac 100644 --- a/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/s3-crt/S3CrtServiceClientSourceInit.vm +++ b/tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/s3-crt/S3CrtServiceClientSourceInit.vm @@ -177,7 +177,7 @@ ${className}::${className}(const std::shared_ptr& creden false), Aws::MakeShared<${metadata.classNamePrefix}ErrorMarshaller>(ALLOCATION_TAG)), #if($serviceModel.endpointRules) - m_clientConfiguration(clientConfiguration${signPayloadsParam}), + m_clientConfiguration(clientConfiguration), ${credentialsProviderMember}, #else ${credentialsProviderMember}${virtualAddressingInit}${USEast1RegionalEndpointInitString},