Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <aws/s3-crt/model/ListObjectsRequest.h>
#include <aws/s3-crt/model/GetBucketLocationRequest.h>
#include <aws/s3-crt/model/SelectObjectContentRequest.h>
#include <aws/s3-crt/model/Tagging.h>
#include <aws/s3-crt/model/PutBucketTaggingRequest.h>
#include <aws/s3-crt/ClientConfiguration.h>
#include <aws/testing/ProxyConfig.h>
#include <aws/testing/platform/PlatformTesting.h>
Expand Down Expand Up @@ -83,6 +85,7 @@ namespace
//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 ape+Me$";
static const char* TEST_BUCKET_TAG = "IntegrationTestResource";

static const int TIMEOUT_MAX = 20;

Expand Down Expand Up @@ -228,6 +231,24 @@ namespace
ASSERT_STREQ(ss.str().c_str(), outcome.GetResult().GetETag().c_str());
}

static void TagTestBucket(const Aws::String& bucketName, const std::shared_ptr<S3CrtClient>& client) {
ASSERT_TRUE(!bucketName.empty());
ASSERT_TRUE(client);

PutBucketTaggingRequest taggingRequest;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add

ASSERT_TRUE(!bucketName.empty());
ASSERT_TRUE(client);

just in case...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah makes sense

taggingRequest.SetBucket(bucketName);
Tag tag;
tag.SetKey(TEST_BUCKET_TAG);
tag.SetValue(TEST_BUCKET_TAG);
Tagging tagging;
tagging.AddTagSet(tag);
taggingRequest.SetTagging(tagging);

auto taggingOutcome = client->PutBucketTagging(taggingRequest);

ASSERT_TRUE(taggingOutcome.IsSuccess());
}

static bool WaitForBucketToPropagate(const Aws::String& bucketName, const std::shared_ptr<S3CrtClient>& client = Client)
{
unsigned timeoutCount = 0;
Expand Down Expand Up @@ -343,6 +364,7 @@ namespace
const CreateBucketResult& createBucketResult = createBucketOutcome.GetResult();
EXPECT_TRUE(!createBucketResult.GetLocation().empty());
EXPECT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);
return fullBucketName;
}

Expand Down Expand Up @@ -426,6 +448,7 @@ namespace
const CreateBucketResult& createBucketResult = createBucketOutcome.GetResult();
ASSERT_FALSE(createBucketResult.GetLocation().empty());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

ListBucketsOutcome listBucketsOutcome = Client->ListBuckets();
ASSERT_TRUE(listBucketsOutcome.IsSuccess());
Expand Down Expand Up @@ -464,6 +487,7 @@ namespace
const CreateBucketResult& createBucketResult = createBucketOutcome.GetResult();
ASSERT_FALSE(createBucketResult.GetLocation().empty());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName, oregonClient));
TagTestBucket(fullBucketName, oregonClient);

GetBucketLocationRequest locationRequest;
locationRequest.SetBucket(fullBucketName);
Expand All @@ -490,8 +514,8 @@ namespace
ASSERT_TRUE(createBucketOutcome.IsSuccess());
const CreateBucketResult& createBucketResult = createBucketOutcome.GetResult();
ASSERT_TRUE(!createBucketResult.GetLocation().empty());

ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand All @@ -516,8 +540,8 @@ namespace
ASSERT_TRUE(createBucketOutcome.IsSuccess());
const CreateBucketResult& createBucketResult = createBucketOutcome.GetResult();
ASSERT_TRUE(!createBucketResult.GetLocation().empty());

ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand Down Expand Up @@ -580,8 +604,8 @@ namespace
ASSERT_TRUE(createBucketOutcome.IsSuccess());
const CreateBucketResult& createBucketResult = createBucketOutcome.GetResult();
ASSERT_TRUE(!createBucketResult.GetLocation().empty());

ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

// S3 CRT Client doesn't support this edge case right now.
//test unicode
Expand Down Expand Up @@ -743,6 +767,7 @@ namespace
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

GetObjectRequest getObjectRequest;
getObjectRequest.SetBucket(fullBucketName);
Expand All @@ -760,6 +785,7 @@ namespace
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand Down Expand Up @@ -794,6 +820,7 @@ namespace
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand Down Expand Up @@ -821,8 +848,8 @@ namespace
createBucketRequest.SetACL(BucketCannedACL::private_);
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());

ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

auto objectStream = Aws::MakeShared<Aws::StringStream>("BucketAndObjectOperationTest");
*objectStream << "Test Japanese & Chinese Unicode keys";
Expand Down Expand Up @@ -856,6 +883,7 @@ namespace
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand Down Expand Up @@ -934,6 +962,7 @@ namespace
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand Down Expand Up @@ -1008,6 +1037,7 @@ namespace
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand Down Expand Up @@ -1112,6 +1142,7 @@ namespace
CreateBucketOutcome createBucketOutcome = Client->CreateBucket(createBucketRequest);
ASSERT_TRUE(createBucketOutcome.IsSuccess());
ASSERT_TRUE(WaitForBucketToPropagate(fullBucketName));
TagTestBucket(fullBucketName, Client);

PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket(fullBucketName);
Expand Down
19 changes: 19 additions & 0 deletions aws-cpp-sdk-s3-encryption-integration-tests/LiveClientTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <aws/s3/model/GetObjectRequest.h>
#include <aws/s3/model/DeleteBucketRequest.h>
#include <aws/s3/model/DeleteObjectRequest.h>
#include <aws/s3/model/PutBucketTaggingRequest.h>
#include <aws/s3/model/Tagging.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/DateTime.h>
Expand Down Expand Up @@ -51,6 +53,8 @@ static const char RANGE_GET_TEST_STRING[] = "test AES CBC, AES CTR, and AES GCM
static const char* OVERFLOW_RANGE_GET_STR = "bytes=38-1000000000";
static const char OVERFLOW_RANGE_GET_TEST_STRING[] = "test AES CBC, AES CTR, and AES GCM modes of operation with the Aws S3 Encryption Client";

static const char* TEST_BUCKET_TAG = "IntegrationTestResource";

class LiveClientTest : public ::testing::Test
{
public:
Expand All @@ -74,6 +78,21 @@ class LiveClientTest : public ::testing::Test
ASSERT_TRUE(createBucketOutcome.IsSuccess());
}

static void TagTestBucket(const Aws::String& bucketName) {
Aws::S3::Model::PutBucketTaggingRequest taggingRequest;
taggingRequest.SetBucket(bucketName);
Aws::S3::Model::Tag tag;
tag.SetKey(TEST_BUCKET_TAG);
tag.SetValue(TEST_BUCKET_TAG);
Aws::S3::Model::Tagging tagging;
tagging.AddTagSet(tag);
taggingRequest.SetTagging(tagging);

auto taggingOutcome = StandardClient->PutBucketTagging(taggingRequest);

ASSERT_TRUE(taggingOutcome.IsSuccess());
}

static void TearDownTestCase()
{
Model::DeleteBucketRequest deleteBucketRequest;
Expand Down
Loading