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 35124b6c236..ca11650b076 100644 --- a/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,20 +63,20 @@ using namespace Aws::Utils; namespace { - static Aws::String BASE_CREATE_BUCKET_TEST_NAME = "createbuckettest"; - static Aws::String BASE_DNS_UNFRIENDLY_TEST_NAME = "dns.unfriendly"; - static Aws::String BASE_LOCATION_BUCKET_TEST_NAME = "locbuckettest"; - static Aws::String BASE_OBJECTS_BUCKET_NAME = "objecttest"; - static Aws::String BASE_OBJECTS_DEFAULT_CTOR_BUCKET_NAME = "ctortest"; - static Aws::String BASE_PUT_OBJECTS_BUCKET_NAME = "putobjecttest"; - static Aws::String BASE_PUT_WEIRD_CHARSETS_OBJECTS_BUCKET_NAME = "charsetstest"; - static Aws::String BASE_PUT_OBJECTS_PRESIGNED_URLS_BUCKET_NAME = "presignedtest"; - static Aws::String BASE_PUT_MULTIPART_BUCKET_NAME = "multiparttest"; - static Aws::String BASE_ERRORS_TESTING_BUCKET = "errorstest"; - static Aws::String BASE_EVENT_STREAM_TEST_BUCKET_NAME = "eventstream"; - static Aws::String BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME = "largeeventstream"; - static Aws::String BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME = "errorsinevent"; - static Aws::String BASE_CHECKSUMS_BUCKET_NAME = "checksums-crt"; + static std::string BASE_CREATE_BUCKET_TEST_NAME = "createbuckettest"; + static std::string BASE_DNS_UNFRIENDLY_TEST_NAME = "dns.unfriendly"; + static std::string BASE_LOCATION_BUCKET_TEST_NAME = "locbuckettest"; + static std::string BASE_OBJECTS_BUCKET_NAME = "objecttest"; + static std::string BASE_OBJECTS_DEFAULT_CTOR_BUCKET_NAME = "ctortest"; + static std::string BASE_PUT_OBJECTS_BUCKET_NAME = "putobjecttest"; + static std::string BASE_PUT_WEIRD_CHARSETS_OBJECTS_BUCKET_NAME = "charsetstest"; + static std::string BASE_PUT_OBJECTS_PRESIGNED_URLS_BUCKET_NAME = "presignedtest"; + static std::string BASE_PUT_MULTIPART_BUCKET_NAME = "multiparttest"; + static std::string BASE_ERRORS_TESTING_BUCKET = "errorstest"; + static std::string BASE_EVENT_STREAM_TEST_BUCKET_NAME = "eventstream"; + 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 const char* ALLOCATION_TAG = "BucketAndObjectOperationTest"; static const char* TEST_OBJ_KEY = "TestObjectKey"; static const char* TEST_NOT_MODIFIED_OBJ_KEY = "TestNotModifiedObjectKey"; @@ -85,7 +85,7 @@ namespace //windows won't let you hard code unicode strings in a source file and assign them to a char*. Every other compiler does and I need to test this. //to get around this, this string is url encoded version of "TestUnicode中国Key". At test time, we'll convert it to the unicode string static const char* URLENCODED_UNICODE_KEY = "TestUnicode%E4%B8%AD%E5%9B%BDKey"; - static const char* URIESCAPE_KEY = "Esc a=pe+Me$"; + static const char* URIESCAPE_KEY = "Esc ape+Me$"; static const char* TEST_BUCKET_TAG = "IntegrationTestResource"; static const int TIMEOUT_MAX = 20; @@ -161,7 +161,6 @@ namespace DeleteBucket(CalculateBucketName(BASE_EVENT_STREAM_TEST_BUCKET_NAME.c_str())); 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())); Client = nullptr; oregonClient = nullptr; @@ -234,7 +233,7 @@ namespace uploadPart1Request.SetContentLength(static_cast(partStream->tellg())); partStream->seekg(startingPoint); - return Client->UploadPartCallable(uploadPart1Request); + return Client->SubmitCallable(&S3CrtClient::UploadPart, uploadPart1Request); } static void VerifyUploadPartOutcome(UploadPartOutcome& outcome, const ByteBuffer& md5OfStream) @@ -369,7 +368,6 @@ namespace static Aws::String PreparePresignedUrlTest() { Aws::String fullBucketName = CalculateBucketName(BASE_PUT_OBJECTS_PRESIGNED_URLS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -422,7 +420,6 @@ namespace static void CleanUpPresignedUrlTest() { Aws::String fullBucketName = CalculateBucketName(BASE_PUT_OBJECTS_PRESIGNED_URLS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); Aws::String presignedUrlDelete = Client->GeneratePresignedUrl(fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_DELETE); std::shared_ptr deleteRequest = CreateHttpRequest(presignedUrlDelete, HttpMethod::HTTP_DELETE, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod); std::shared_ptr deleteResponse = m_HttpClient->MakeRequest(deleteRequest); @@ -439,7 +436,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestBucketOperationsErrorWithMissingRequiredFields) { Aws::String fullBucketName = CalculateBucketName(BASE_CREATE_BUCKET_TEST_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); HeadBucketRequest headBucketRequest; HeadBucketOutcome headBucketOutcome = Client->HeadBucket(headBucketRequest); ASSERT_FALSE(headBucketOutcome.IsSuccess()); @@ -453,8 +449,8 @@ namespace TEST_F(BucketAndObjectOperationTest, TestBucketCreationAndListing) { - const Aws::String fullBucketName = CalculateBucketName(BASE_CREATE_BUCKET_TEST_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); + Aws::String fullBucketName = CalculateBucketName(BASE_CREATE_BUCKET_TEST_NAME.c_str()); + CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -492,7 +488,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestBucketLocation) { Aws::String fullBucketName = CalculateBucketName(BASE_LOCATION_BUCKET_TEST_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); CreateBucketConfiguration bucketConfiguration; @@ -521,8 +516,8 @@ namespace // S3 CRT Client could not handle these special characters in key name right now. TEST_F(BucketAndObjectOperationTest, TestPutWithSpecialCharactersInKeyName) { - const Aws::String fullBucketName = CalculateBucketName(BASE_PUT_OBJECTS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); + Aws::String fullBucketName = CalculateBucketName(BASE_PUT_OBJECTS_BUCKET_NAME.c_str()); + CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -547,8 +542,8 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperations) { - const Aws::String fullBucketName = CalculateBucketName(BASE_OBJECTS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); + Aws::String fullBucketName = CalculateBucketName(BASE_OBJECTS_BUCKET_NAME.c_str()); + CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -691,8 +686,8 @@ namespace TEST_F(BucketAndObjectOperationTest, TestKeysWithCrazyCharacterSets) { - const Aws::String fullBucketName = CalculateBucketName(BASE_PUT_WEIRD_CHARSETS_OBJECTS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); + Aws::String fullBucketName = CalculateBucketName(BASE_PUT_WEIRD_CHARSETS_OBJECTS_BUCKET_NAME.c_str()); + CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -758,7 +753,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperationsWithPresignedUrls) { Aws::String fullBucketName = PreparePresignedUrlTest(); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); Aws::String presignedUrlPut = Client->GeneratePresignedUrl(fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT); std::shared_ptr putRequest = CreateHttpRequest(presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod); DoPresignedUrlTest(fullBucketName, putRequest); @@ -768,7 +762,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperationsWithPresignedUrlsAndCustomizedHeaders) { Aws::String fullBucketName = PreparePresignedUrlTest(); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); Aws::Http::HeaderValueCollection collections; collections.emplace("TestKey1", "TestVal1"); collections.emplace("TestKey2", "TestVal2"); @@ -786,7 +779,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperationsWithPresignedUrlsWithSSES3) { Aws::String fullBucketName = PreparePresignedUrlTest(); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); Aws::String presignedUrlPut = Client->GeneratePresignedUrlWithSSES3(fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT); std::shared_ptr putRequest = CreateHttpRequest(presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod); putRequest->SetHeaderValue(Aws::S3Crt::SSEHeaders::SERVER_SIDE_ENCRYPTION, @@ -798,7 +790,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperationsWithPresignedUrlsWithSSES3AndCustomizedHeaders) { Aws::String fullBucketName = PreparePresignedUrlTest(); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); Aws::Http::HeaderValueCollection collections; collections.emplace("TestKey1", "TestVal1"); collections.emplace("TestKey2", "TestVal2"); @@ -818,7 +809,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperationsWithPresignedUrlsWithSSEKMS) { Aws::String fullBucketName = PreparePresignedUrlTest(); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); Aws::String presignedUrlPut = Client->GeneratePresignedUrlWithSSEKMS(fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT); //Using default KMS key in this AWS account std::shared_ptr putRequest = CreateHttpRequest(presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod); putRequest->SetHeaderValue(Aws::S3Crt::SSEHeaders::SERVER_SIDE_ENCRYPTION, @@ -831,7 +821,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperationsWithPresignedUrlsWithSSEKMSAndCustomizedHeaders) { Aws::String fullBucketName = PreparePresignedUrlTest(); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); Aws::Http::HeaderValueCollection collections; collections.emplace("TestKey1", "TestVal1"); collections.emplace("TestKey2", "TestVal2"); @@ -850,8 +839,8 @@ namespace TEST_F(BucketAndObjectOperationTest, TestThatErrorsParse) { - const Aws::String fullBucketName = CalculateBucketName(BASE_ERRORS_TESTING_BUCKET.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); + Aws::String fullBucketName = CalculateBucketName(BASE_ERRORS_TESTING_BUCKET.c_str()); + ListObjectsRequest listObjectsRequest; listObjectsRequest.SetBucket("abcdedoikengi"); @@ -882,7 +871,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestNotModifiedIsSuccess) { Aws::String fullBucketName = CalculateBucketName(BASE_PUT_OBJECTS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -918,7 +906,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestVirtualAddressingWithUnfriendlyBucketName) { Aws::String fullBucketName = CalculateBucketName(BASE_DNS_UNFRIENDLY_TEST_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -952,7 +939,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestCopyingFromKeysWithUnicodeCharacters) { Aws::String fullBucketName = CalculateBucketName(BASE_CREATE_BUCKET_TEST_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -987,7 +973,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestObjectOperationWithEventStream) { Aws::String fullBucketName = CalculateBucketName(BASE_EVENT_STREAM_TEST_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -1067,7 +1052,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestSelectObjectOperationWithEventStreamFailWithRetry) { Aws::String fullBucketName = CalculateBucketName(BASE_EVENT_STREAM_TEST_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -1143,7 +1127,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestEventStreamWithLargeFile) { Aws::String fullBucketName = CalculateBucketName(BASE_EVENT_STREAM_LARGE_FILE_TEST_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -1249,7 +1232,6 @@ namespace TEST_F(BucketAndObjectOperationTest, TestErrorsInEventStream) { Aws::String fullBucketName = CalculateBucketName(BASE_EVENT_STREAM_ERRORS_IN_EVENT_TEST_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -1319,8 +1301,8 @@ namespace TEST_F(BucketAndObjectOperationTest, TestEmptyBody) { - const Aws::String fullBucketName = CalculateBucketName(BASE_PUT_OBJECTS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); + Aws::String fullBucketName = CalculateBucketName(BASE_PUT_OBJECTS_BUCKET_NAME.c_str()); + CreateBucketRequest createBucketRequest; createBucketRequest.SetBucket(fullBucketName); createBucketRequest.SetACL(BucketCannedACL::private_); @@ -1359,158 +1341,4 @@ namespace AWS_ASSERT_SUCCESS(Client->GetObject(getObjectRequest)); } - - TEST_F(BucketAndObjectOperationTest, LocalHostCrtError) { - 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.endpointOverride = "localhost"; - - Client = Aws::MakeShared(ALLOCATION_TAG, - Aws::Auth::AWSCredentials{"", ""}, - s3ClientConfig, - Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never); - - //Make a request for one of out public doc pages - GetObjectRequest getObjectRequest; - getObjectRequest.SetBucket("aws-sdk-cpp-docs"); - getObjectRequest.SetKey("cpp/api/LATEST/index.html"); - - GetObjectOutcome outcome = Client->GetObject(getObjectRequest); - - ASSERT_FALSE(outcome.IsSuccess()); - ASSERT_EQ(outcome.GetError().GetErrorType(), Aws::S3Crt::S3CrtErrors::NETWORK_CONNECTION); - } - - TEST_F(BucketAndObjectOperationTest, MissingCertificate) { - Aws::S3Crt::ClientConfiguration s3ClientConfig; - s3ClientConfig.region = Aws::Region::US_EAST_1; - s3ClientConfig.caFile = "/some-non-existing-certificate/cert.crt"; - s3ClientConfig.verifySSL = true; - - S3CrtClient crtClient = S3CrtClient(Aws::Auth::AWSCredentials{"", ""}, - s3ClientConfig, - Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never); - - GetObjectRequest getObjectRequest; - getObjectRequest.SetBucket("aws-sdk-cpp-docs"); - getObjectRequest.SetKey("cpp/api/LATEST/index.html"); - - auto result = crtClient.GetObject(getObjectRequest); - ASSERT_FALSE(result.IsSuccess()); - ASSERT_EQ((Aws::Client::CoreErrors) result.GetError().GetErrorType(), Aws::Client::CoreErrors::NOT_INITIALIZED); - } - - TEST_F(BucketAndObjectOperationTest, PutObjectChecksum) { - struct ChecksumTestCase { - std::function chucksumRequestMutator; - HttpResponseCode responseCode; - String body; - }; - - const String fullBucketName = CalculateBucketName(BASE_CHECKSUMS_BUCKET_NAME.c_str()); - SCOPED_TRACE(Aws::String("FullBucketName ") + fullBucketName); - CreateBucketRequest createBucketRequest; - createBucketRequest.SetBucket(fullBucketName); - createBucketRequest.SetACL(BucketCannedACL::private_); - CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest); - AWS_ASSERT_SUCCESS(createBucketOutcome); - - Vector testCases{ - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::CRC32).WithChecksumCRC32("Just runnin' scared each place we go"); - }, - HttpResponseCode::BAD_REQUEST, - "Just runnin' scared each place we go" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::SHA1).WithChecksumSHA1("So afraid that he might show"); - }, - HttpResponseCode::BAD_REQUEST, - "So afraid that he might show" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::SHA256).WithChecksumSHA256("Yeah, runnin' scared, what would I do"); - }, - HttpResponseCode::BAD_REQUEST, - "Yeah, runnin' scared, what would I do" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::CRC32C).WithChecksumCRC32C("If he came back and wanted you?"); - }, - HttpResponseCode::BAD_REQUEST, - "If he came back and wanted you?" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithContentMD5("Just runnin' scared, feelin' low"); - }, - HttpResponseCode::BAD_REQUEST, - "Just runnin' scared, feelin' low", - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::CRC32) - .WithChecksumCRC32(HashingUtils::Base64Encode(HashingUtils::CalculateCRC32("Runnin' scared, you love him so"))); - }, - HttpResponseCode::OK, - "Runnin' scared, you love him so" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::SHA1) - .WithChecksumSHA1(HashingUtils::Base64Encode(HashingUtils::CalculateSHA1("Just runnin' scared, afraid to lose"))); - }, - HttpResponseCode::OK, - "Just runnin' scared, afraid to lose" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::SHA256) - .WithChecksumSHA256(HashingUtils::Base64Encode(HashingUtils::CalculateSHA256("If he came back, which one would you choose?"))); - }, - HttpResponseCode::OK, - "If he came back, which one would you choose?" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithChecksumAlgorithm(ChecksumAlgorithm::CRC32C) - .WithChecksumCRC32C(HashingUtils::Base64Encode(HashingUtils::CalculateCRC32C("Then all at once he was standing there"))); - }, - HttpResponseCode::OK, - "Then all at once he was standing there" - }, - { - [](PutObjectRequest request) -> PutObjectRequest { - return request.WithContentMD5(HashingUtils::Base64Encode(HashingUtils::CalculateMD5("So sure of himself, his head in the air"))); - }, - HttpResponseCode::OK, - "So sure of himself, his head in the air" - } - }; - - for (const auto&testCase: testCases) { - auto request = testCase.chucksumRequestMutator(PutObjectRequest() - .WithBucket(fullBucketName) - .WithKey("RunningScared")); - std::shared_ptr body = Aws::MakeShared(ALLOCATION_TAG, - testCase.body, - std::ios_base::in | std::ios_base::binary); - request.SetBody(body); - const auto response = Client->PutObject(request); - if (!response.IsSuccess()) { - ASSERT_EQ(testCase.responseCode, response.GetError().GetResponseCode()); - } else { - ASSERT_EQ(testCase.responseCode, HttpResponseCode::OK); - ASSERT_TRUE(response.IsSuccess()); - } - } - } } diff --git a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp index 87267521fbc..42c120bbf79 100644 --- a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp @@ -614,7 +614,7 @@ namespace ASSERT_NE(S3Errors::VALIDATION, getObjectOutcome.GetError().GetErrorType()); Aws::StringStream ss; ss << "https://" << expectedEndpoint << "/fakeObjectKey"; - if (ss.str() != TestingMonitoringMetrics::s_lastUriString) { + if (ss.str() != TestingMonitoringMetrics::s_lastUriString.c_str()) { std::cout << "Error"; } ASSERT_STREQ(ss.str().c_str(), TestingMonitoringMetrics::s_lastUriString.c_str()); diff --git a/tests/testing-resources/include/aws/testing/mocks/monitoring/TestingMonitoring.h b/tests/testing-resources/include/aws/testing/mocks/monitoring/TestingMonitoring.h index 2bded16cca8..0902b72d632 100644 --- a/tests/testing-resources/include/aws/testing/mocks/monitoring/TestingMonitoring.h +++ b/tests/testing-resources/include/aws/testing/mocks/monitoring/TestingMonitoring.h @@ -18,21 +18,22 @@ struct TestingMonitoringMetrics static bool s_enablePayload; }; - static Aws::String s_lastUriString; - static Aws::String s_lastSigningRegion; - static Aws::String s_lastSigningServiceName; - static Aws::String s_lastPayload; - static Aws::Map s_lastRequestHeaders; + // Note: these must be std:: to avoid memory issues because they are used outside InitAPI {...} ShutdownAPI. + static std::string s_lastUriString; + static std::string s_lastSigningRegion; + static std::string s_lastSigningServiceName; + static std::string s_lastPayload; + static std::map s_lastRequestHeaders; }; bool TestingMonitoringMetrics::Config::s_enablePayload; std::mutex s_lastMutex; -Aws::String TestingMonitoringMetrics::s_lastUriString; -Aws::String TestingMonitoringMetrics::s_lastSigningRegion; -Aws::String TestingMonitoringMetrics::s_lastSigningServiceName; -Aws::String TestingMonitoringMetrics::s_lastPayload; -Aws::Map TestingMonitoringMetrics::s_lastRequestHeaders; +std::string TestingMonitoringMetrics::s_lastUriString; +std::string TestingMonitoringMetrics::s_lastSigningRegion; +std::string TestingMonitoringMetrics::s_lastSigningServiceName; +std::string TestingMonitoringMetrics::s_lastPayload; +std::map TestingMonitoringMetrics::s_lastRequestHeaders; class TestingMonitoring : public Aws::Monitoring::MonitoringInterface { @@ -82,8 +83,6 @@ class TestingMonitoring : public Aws::Monitoring::MonitoringInterface AWS_UNREFERENCED_PARAM(serviceName); AWS_UNREFERENCED_PARAM(requestName); AWS_UNREFERENCED_PARAM(context); - std::unique_lock locker(s_lastMutex); - TestingMonitoringMetrics::s_lastUriString = request->GetUri().GetURIString().c_str(); TestingMonitoringMetrics::s_lastSigningRegion = request->GetSigningRegion().c_str(); Aws::Vector authComponents = request->HasAwsAuthorization() ? @@ -156,7 +155,6 @@ class TestingMonitoringManager private: static void Init() { - std::unique_lock locker(s_lastMutex); TestingMonitoringMetrics::Config::s_enablePayload = false; TestingMonitoringMetrics::s_lastUriString = "";