@@ -160,19 +160,19 @@ namespace
160160 config.proxyPort = PROXY_PORT;
161161 }
162162
163- Client = Aws::MakeShared<S3Client>(ALLOCATION_TAG,
164- Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG), config,
163+ Client = Aws::MakeShared<S3Client>(ALLOCATION_TAG,
164+ Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG), config,
165165 AWSAuthV4Signer::PayloadSigningPolicy::Never /* signPayloads*/ , true /* useVirtualAddressing*/ );
166166 config.region = Aws::Region::US_WEST_2;
167167 config.useDualStack = true ;
168- oregonClient = Aws::MakeShared<S3Client>(ALLOCATION_TAG,
169- Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG), config,
168+ oregonClient = Aws::MakeShared<S3Client>(ALLOCATION_TAG,
169+ Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG), config,
170170 AWSAuthV4Signer::PayloadSigningPolicy::Never /* signPayloads*/ , true /* useVirtualAddressing*/ );
171171 m_HttpClient = Aws::Http::CreateHttpClient (config);
172172
173173 config.retryStrategy = Aws::MakeShared<RetryFiveTimesRetryStrategy>(ALLOCATION_TAG);
174- retryClient = Aws::MakeShared<S3Client>(ALLOCATION_TAG,
175- Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG), config,
174+ retryClient = Aws::MakeShared<S3Client>(ALLOCATION_TAG,
175+ Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG), config,
176176 AWSAuthV4Signer::PayloadSigningPolicy::Never /* signPayloads*/ , true /* useVirtualAddressing*/ );
177177 }
178178
@@ -413,7 +413,7 @@ namespace
413413 std::shared_ptr<HttpRequest> deleteRequest = CreateHttpRequest (presignedUrlDelete, HttpMethod::HTTP_DELETE, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
414414 std::shared_ptr<HttpResponse> deleteResponse = m_HttpClient->MakeRequest (deleteRequest);
415415 ASSERT_EQ (HttpResponseCode::NO_CONTENT, deleteResponse->GetResponseCode ());
416- WaitForBucketToEmpty (fullBucketName);
416+ WaitForBucketToEmpty (fullBucketName);
417417 }
418418
419419 void DoTestObjectOperationsWithPresignedUrlsWithSSEC (bool withCustomizedHeaders)
@@ -424,7 +424,7 @@ namespace
424424 objectStream->flush ();
425425
426426 ByteBuffer sseKey (32 );
427- for (int i = 0 ; i < 32 ; i++)
427+ for (int i = 0 ; i < 32 ; i++)
428428 {
429429 sseKey[i] = ' a' ;
430430 }
@@ -436,14 +436,14 @@ namespace
436436 collections.emplace (" TestKey2" , " TestVal2" );
437437 presignedUrlPut = Client->GeneratePresignedUrlWithSSEC (fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT, collections, HashingUtils::Base64Encode (sseKey));
438438 }
439- else
439+ else
440440 {
441441 presignedUrlPut = Client->GeneratePresignedUrlWithSSEC (fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT, HashingUtils::Base64Encode (sseKey));
442442 }
443443
444444 std::shared_ptr<HttpRequest> putRequest = CreateHttpRequest (presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
445445 putRequest->AddContentBody (objectStream);
446- putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM,
446+ putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM,
447447 Aws::S3::Model::ServerSideEncryptionMapper::GetNameForServerSideEncryption (Aws::S3::Model::ServerSideEncryption::AES256));
448448 putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY, HashingUtils::Base64Encode (sseKey));
449449 Aws::String strBuffer (reinterpret_cast <char *>(sseKey.GetUnderlyingData ()), sseKey.GetLength ());
@@ -453,7 +453,7 @@ namespace
453453 ASSERT_NE (presignedUrlPut.find (" testkey1" ), std::string::npos);
454454 ASSERT_NE (presignedUrlPut.find (" testkey2" ), std::string::npos);
455455 putRequest->SetHeaderValue (" TestKey1" , " TestVal1" );
456- putRequest->SetHeaderValue (" TestKey2" , " TestVal2" );
456+ putRequest->SetHeaderValue (" TestKey2" , " TestVal2" );
457457 }
458458
459459 Aws::StringStream intConverter;
@@ -469,7 +469,7 @@ namespace
469469 // Test GetObject with SSEC Presigned Url
470470 Aws::String presignedUrlGet = Client->GeneratePresignedUrlWithSSEC (fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_GET, HashingUtils::Base64Encode (sseKey));
471471 std::shared_ptr<HttpRequest> getRequest = CreateHttpRequest (presignedUrlGet, HttpMethod::HTTP_GET, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
472- getRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM,
472+ getRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM,
473473 Aws::S3::Model::ServerSideEncryptionMapper::GetNameForServerSideEncryption (Aws::S3::Model::ServerSideEncryption::AES256));
474474 getRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY, HashingUtils::Base64Encode (sseKey));
475475 getRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5, HashingUtils::Base64Encode (HashingUtils::CalculateMD5 (strBuffer)));
@@ -560,7 +560,7 @@ namespace
560560 auto && getOutcome = getCallable.get ();
561561 Client->EnableRequestProcessing ();
562562
563- ASSERT_FALSE (getOutcome.IsSuccess ());
563+ ASSERT_FALSE (getOutcome.IsSuccess ());
564564 }
565565
566566 TEST_F (BucketAndObjectOperationTest, TestBucketOperationsErrorWithMissingRequiredFields)
@@ -704,6 +704,21 @@ namespace
704704 ASSERT_STREQ (ss.str ().c_str (), putObjectOutcome.GetResult ().GetETag ().c_str ());
705705
706706 ASSERT_TRUE (WaitForObjectToPropagate (fullBucketName, TEST_OBJ_KEY));
707+ GetObjectRequest getObjectAsyncRequest;
708+ getObjectAsyncRequest.WithBucket (fullBucketName).WithKey (TEST_OBJ_KEY);
709+ Aws::Utils::Threading::Semaphore sem (0 , 1 );
710+ auto getObjectCallback = [&](const S3Client *client, const GetObjectRequest &request,
711+ GetObjectOutcome outcome, const std::shared_ptr<const AsyncCallerContext> &) {
712+ ASSERT_TRUE (client);
713+ ASSERT_TRUE (outcome.IsSuccess ());
714+ ss.str (" " );
715+ ss << outcome.GetResult ().GetBody ().rdbuf ();
716+ ASSERT_STREQ (" Test Object" , ss.str ().c_str ());
717+ ASSERT_STREQ (" TestObjectKey" , request.GetKey ().c_str ());
718+ sem.ReleaseAll ();
719+ };
720+ Client->GetObjectAsync (getObjectAsyncRequest, getObjectCallback, nullptr );
721+ sem.WaitOne ();
707722
708723 GetObjectRequest getObjectRequest;
709724 getObjectRequest.SetBucket (fullBucketName);
@@ -836,7 +851,7 @@ namespace
836851 Aws::String fullBucketName = PreparePresignedUrlTest ();
837852 Aws::String presignedUrlPut = Client->GeneratePresignedUrlWithSSES3 (fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT);
838853 std::shared_ptr<HttpRequest> putRequest = CreateHttpRequest (presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
839- putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
854+ putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
840855 Aws::S3::Model::ServerSideEncryptionMapper::GetNameForServerSideEncryption (Aws::S3::Model::ServerSideEncryption::AES256));
841856 DoPresignedUrlTest (fullBucketName, putRequest);
842857 CleanUpPresignedUrlTest ();
@@ -851,7 +866,7 @@ namespace
851866
852867 Aws::String presignedUrlPut = Client->GeneratePresignedUrlWithSSES3 (fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT, collections);
853868 std::shared_ptr<HttpRequest> putRequest = CreateHttpRequest (presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
854- putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
869+ putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
855870 Aws::S3::Model::ServerSideEncryptionMapper::GetNameForServerSideEncryption (Aws::S3::Model::ServerSideEncryption::AES256));
856871 ASSERT_NE (presignedUrlPut.find (" testkey1" ), std::string::npos);
857872 ASSERT_NE (presignedUrlPut.find (" testkey2" ), std::string::npos);
@@ -866,12 +881,12 @@ namespace
866881 Aws::String fullBucketName = PreparePresignedUrlTest ();
867882 Aws::String presignedUrlPut = Client->GeneratePresignedUrlWithSSEKMS (fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT); // Using default KMS key in this AWS account
868883 std::shared_ptr<HttpRequest> putRequest = CreateHttpRequest (presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
869- putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
884+ putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
870885 Aws::S3::Model::ServerSideEncryptionMapper::GetNameForServerSideEncryption (Aws::S3::Model::ServerSideEncryption::aws_kms));
871886 DoPresignedUrlTest (fullBucketName, putRequest);
872887 CleanUpPresignedUrlTest ();
873888 }
874-
889+
875890
876891 TEST_F (BucketAndObjectOperationTest, TestObjectOperationsWithPresignedUrlsWithSSEKMSAndCustomizedHeaders)
877892 {
@@ -882,7 +897,7 @@ namespace
882897
883898 Aws::String presignedUrlPut = Client->GeneratePresignedUrlWithSSEKMS (fullBucketName, TEST_OBJ_KEY, HttpMethod::HTTP_PUT, collections); // Using default KMS key in this AWS account
884899 std::shared_ptr<HttpRequest> putRequest = CreateHttpRequest (presignedUrlPut, HttpMethod::HTTP_PUT, Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
885- putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
900+ putRequest->SetHeaderValue (Aws::S3::SSEHeaders::SERVER_SIDE_ENCRYPTION,
886901 Aws::S3::Model::ServerSideEncryptionMapper::GetNameForServerSideEncryption (Aws::S3::Model::ServerSideEncryption::aws_kms));
887902 ASSERT_NE (presignedUrlPut.find (" testkey1" ), std::string::npos);
888903 ASSERT_NE (presignedUrlPut.find (" testkey2" ), std::string::npos);
@@ -1035,7 +1050,7 @@ namespace
10351050 getObjectRequest2.SetBucket (fullBucketName);
10361051 getObjectRequest2.SetKey (multipartKeyName);
10371052 getObjectRequest2.SetResponseStreamFactory (
1038- [=](){
1053+ [=](){
10391054 // NOTE: If using an FStream in order to download a file from S3 to a physical file, then we need to specify
10401055 // the filemode "std::ios_base::out | std::ios_base::in | std::ios_base::trunc" --
10411056 // If the file transfer fails, then the error stream from the httpRequest is written to the file instead of the
@@ -1046,7 +1061,7 @@ namespace
10461061 // The 'truncate' is required to ensure that if the file download IS successful, then it can be written to the
10471062 // FStream (if ::trunc is not specified, then the FStream.write fails for some unknown reason)
10481063
1049- return Aws::New<Aws::FStream>(ALLOCATION_TAG, TestFileName.c_str (), std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
1064+ return Aws::New<Aws::FStream>(ALLOCATION_TAG, TestFileName.c_str (), std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
10501065 }
10511066 );
10521067
@@ -1263,7 +1278,7 @@ namespace
12631278
12641279 PutObjectRequest putObjectRequest;
12651280 putObjectRequest.SetBucket (fullBucketName);
1266-
1281+
12671282 std::shared_ptr<Aws::IOStream> objectStream = Aws::MakeShared<Aws::StringStream>(ALLOCATION_TAG);
12681283 *objectStream << " Name,Number\n Alice,1\n Bob,2" ;
12691284 Aws::String firstColumn = " Name\n Alice\n Bob\n " ;
@@ -1277,13 +1292,13 @@ namespace
12771292
12781293 PutObjectOutcome putObjectOutcome = Client->PutObject (putObjectRequest);
12791294 ASSERT_TRUE (putObjectOutcome.IsSuccess ());
1280-
1295+
12811296 ASSERT_TRUE (WaitForObjectToPropagate (fullBucketName, TEST_EVENT_STREAM_OBJ_KEY));
12821297
12831298 SelectObjectContentRequest selectObjectContentRequest;
12841299 selectObjectContentRequest.SetBucket (fullBucketName);
12851300 selectObjectContentRequest.SetKey (TEST_EVENT_STREAM_OBJ_KEY);
1286-
1301+
12871302 selectObjectContentRequest.SetExpressionType (ExpressionType::SQL);
12881303
12891304 selectObjectContentRequest.SetExpression (" select s._1 from S3Object s" );
@@ -1339,7 +1354,7 @@ namespace
13391354
13401355 PutObjectRequest putObjectRequest;
13411356 putObjectRequest.SetBucket (fullBucketName);
1342-
1357+
13431358 std::shared_ptr<Aws::IOStream> objectStream = Aws::MakeShared<Aws::StringStream>(ALLOCATION_TAG);
13441359 *objectStream << " Name,Number\n Alice,1\n Bob,2" ;
13451360 Aws::String firstColumn = " Name\n Alice\n Bob\n " ;
@@ -1353,13 +1368,13 @@ namespace
13531368
13541369 PutObjectOutcome putObjectOutcome = Client->PutObject (putObjectRequest);
13551370 ASSERT_TRUE (putObjectOutcome.IsSuccess ());
1356-
1371+
13571372 ASSERT_TRUE (WaitForObjectToPropagate (fullBucketName, TEST_EVENT_STREAM_OBJ_KEY));
13581373
13591374 SelectObjectContentRequest selectObjectContentRequest;
13601375 selectObjectContentRequest.SetBucket (fullBucketName);
13611376 selectObjectContentRequest.SetKey (" ANonExistenceKey" );
1362-
1377+
13631378 selectObjectContentRequest.SetExpressionType (ExpressionType::SQL);
13641379
13651380 selectObjectContentRequest.SetExpression (" select s._1 from S3Object s" );
@@ -1412,7 +1427,7 @@ namespace
14121427
14131428 PutObjectRequest putObjectRequest;
14141429 putObjectRequest.SetBucket (fullBucketName);
1415-
1430+
14161431 std::shared_ptr<Aws::IOStream> objectStream = Aws::MakeShared<Aws::StringStream>(ALLOCATION_TAG);
14171432 *objectStream << " Name,Number\n " ;
14181433 for (int i = 0 ; i < 1000000 ; i++)
@@ -1429,7 +1444,7 @@ namespace
14291444
14301445 PutObjectOutcome putObjectOutcome = Client->PutObject (putObjectRequest);
14311446 ASSERT_TRUE (putObjectOutcome.IsSuccess ());
1432-
1447+
14331448 ASSERT_TRUE (WaitForObjectToPropagate (fullBucketName, TEST_EVENT_STREAM_OBJ_KEY));
14341449
14351450 SelectObjectContentRequest selectObjectContentRequest;
@@ -1479,7 +1494,7 @@ namespace
14791494 SelectObjectContentRequest selectObjectContentRequest;
14801495 selectObjectContentRequest.SetBucket (" adskflaklfakl" );
14811496 selectObjectContentRequest.SetKey (TEST_EVENT_STREAM_OBJ_KEY);
1482-
1497+
14831498 selectObjectContentRequest.SetExpressionType (ExpressionType::SQL);
14841499
14851500 selectObjectContentRequest.SetExpression (" select s._1 from S3Object s" );
0 commit comments