From abc2ec2943969587aa2efd6dfb86f8330f002322 Mon Sep 17 00:00:00 2001 From: JinmingHu Date: Mon, 11 Jan 2021 14:34:29 +0800 Subject: [PATCH] remove Base64EncodeText (#1307) --- sdk/storage/azure-storage-blobs/src/block_blob_client.cpp | 4 ++-- .../test/blob_container_client_test.cpp | 6 +++--- .../azure-storage-blobs/test/block_blob_client_test.cpp | 4 ++-- sdk/storage/azure-storage-common/CHANGELOG.md | 2 +- .../inc/azure/storage/common/crypt.hpp | 7 ------- sdk/storage/azure-storage-common/test/test_base.hpp | 6 ++++++ .../src/datalake_utilities.cpp | 5 ++++- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp index 4b38d2f21..066b422cb 100644 --- a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp @@ -139,7 +139,7 @@ namespace Azure { namespace Storage { namespace Blobs { constexpr std::size_t BlockIdLength = 64; std::string blockId = std::to_string(id); blockId = std::string(BlockIdLength - blockId.length(), '0') + blockId; - return Internal::Base64EncodeText(blockId); + return Azure::Core::Base64Encode(std::vector(blockId.begin(), blockId.end())); }; auto uploadBlockFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) { @@ -220,7 +220,7 @@ namespace Azure { namespace Storage { namespace Blobs { constexpr std::size_t BlockIdLength = 64; std::string blockId = std::to_string(id); blockId = std::string(BlockIdLength - blockId.length(), '0') + blockId; - return Internal::Base64EncodeText(blockId); + return Azure::Core::Base64Encode(std::vector(blockId.begin(), blockId.end())); }; auto uploadBlockFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) { diff --git a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp b/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp index 82524a62d..9aa579951 100644 --- a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp @@ -544,8 +544,8 @@ namespace Azure { namespace Storage { namespace Test { auto blockBlob = containerClient.GetBlockBlobClient(blockBlobName); bodyStream.Rewind(); EXPECT_NO_THROW(blockBlob.Upload(&bodyStream)); - std::string blockId1 = Internal::Base64EncodeText("1"); - std::string blockId2 = Internal::Base64EncodeText("2"); + std::string blockId1 = Base64EncodeText("1"); + std::string blockId2 = Base64EncodeText("2"); bodyStream.Rewind(); EXPECT_NO_THROW(blockBlob.StageBlock(blockId1, &bodyStream)); EXPECT_NO_THROW(blockBlob.StageBlockFromUri(blockId2, copySourceBlob.GetUrl() + GetSas())); @@ -1045,7 +1045,7 @@ namespace Azure { namespace Storage { namespace Test { } { - std::string blockId = Internal::Base64EncodeText("1"); + std::string blockId = Base64EncodeText("1"); std::vector blockIds = {blockId}; content.Rewind(); blockBlobClient.StageBlock(blockId, &content); diff --git a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp index 2d1ddc331..218de2339 100644 --- a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp @@ -269,8 +269,8 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(BlockBlobClientTest, StageBlock) { - const std::string blockId1 = Azure::Storage::Internal::Base64EncodeText("0"); - const std::string blockId2 = Azure::Storage::Internal::Base64EncodeText("1"); + const std::string blockId1 = Base64EncodeText("0"); + const std::string blockId2 = Base64EncodeText("1"); auto blockBlobClient = Azure::Storage::Blobs::BlockBlobClient::CreateFromConnectionString( StandardStorageConnectionString(), m_containerName, RandomString()); std::vector block1Content; diff --git a/sdk/storage/azure-storage-common/CHANGELOG.md b/sdk/storage/azure-storage-common/CHANGELOG.md index 749c8c4e8..e6e24146e 100644 --- a/sdk/storage/azure-storage-common/CHANGELOG.md +++ b/sdk/storage/azure-storage-common/CHANGELOG.md @@ -16,7 +16,7 @@ - All date time related strings are now changed to `Azure::Core::DateTime` type. - Move version strings into `Details` namespace. - Move `Base64Encode` and `Base64Decode` from the `Azure::Storage` namespace to `Azure::Core`. -- Rename the string accepting overload of `Base64Encode` to `Base64EncodeText` and make it internal by moving it to the `Azure::Storage::Internal` namespace. +- Remove the string accepting overload of `Base64Encode`. ## 12.0.0-beta.5 (2020-11-13) diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp index 29b20c1f0..d2dace420 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp @@ -11,13 +11,6 @@ namespace Azure { namespace Storage { - namespace Internal { - inline std::string Base64EncodeText(const std::string& text) - { - return Azure::Core::Base64Encode(std::vector(text.begin(), text.end())); - } - } // namespace Internal - class Md5 { public: Md5(); diff --git a/sdk/storage/azure-storage-common/test/test_base.hpp b/sdk/storage/azure-storage-common/test/test_base.hpp index 693eaa360..4b03847cc 100644 --- a/sdk/storage/azure-storage-common/test/test_base.hpp +++ b/sdk/storage/azure-storage-common/test/test_base.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -83,4 +84,9 @@ namespace Azure { namespace Storage { namespace Test { bool IsValidTime(const Azure::Core::DateTime& datetime); + inline std::string Base64EncodeText(const std::string& text) + { + return Azure::Core::Base64Encode(std::vector(text.begin(), text.end())); + } + }}} // namespace Azure::Storage::Test diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp index 6fcda534e..8706a983b 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp @@ -39,7 +39,10 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam std::string result; for (const auto& pair : dataLakePropertiesMap) { - result.append(pair.first + "=" + Internal::Base64EncodeText(pair.second) + ","); + result.append( + pair.first + "=" + + Azure::Core::Base64Encode(std::vector(pair.second.begin(), pair.second.end())) + + ","); } if (!result.empty()) {