diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp index 3ec9bac71a..c67eec83ab 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp @@ -13,7 +13,14 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Models { - bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs); + bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs) + { + return lhs.Id == rhs.Id && lhs.StartsOn.HasValue() == rhs.StartsOn.HasValue() + && (!lhs.StartsOn.HasValue() || lhs.StartsOn.Value() == rhs.StartsOn.Value()) + && lhs.ExpiresOn.HasValue() == rhs.ExpiresOn.HasValue() + && (!lhs.ExpiresOn.HasValue() || lhs.ExpiresOn.Value() == rhs.ExpiresOn.Value()) + && lhs.Permissions == rhs.Permissions; + } }}}} // namespace Azure::Storage::Blobs::Models diff --git a/sdk/storage/azure-storage-common/test/ut/test_base.cpp b/sdk/storage/azure-storage-common/test/ut/test_base.cpp index eb386923e0..ce64e0653e 100644 --- a/sdk/storage/azure-storage-common/test/ut/test_base.cpp +++ b/sdk/storage/azure-storage-common/test/ut/test_base.cpp @@ -19,19 +19,6 @@ #include #include -namespace Azure { namespace Storage { namespace Blobs { namespace Models { - - bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs) - { - return lhs.Id == rhs.Id && lhs.StartsOn.HasValue() == rhs.StartsOn.HasValue() - && (!lhs.StartsOn.HasValue() || lhs.StartsOn.Value() == rhs.StartsOn.Value()) - && lhs.ExpiresOn.HasValue() == rhs.ExpiresOn.HasValue() - && (!lhs.ExpiresOn.HasValue() || lhs.ExpiresOn.Value() == rhs.ExpiresOn.Value()) - && lhs.Permissions == rhs.Permissions; - } - -}}}} // namespace Azure::Storage::Blobs::Models - namespace Azure { namespace Storage { namespace Test { constexpr static const char* StandardStorageConnectionStringValue = ""; @@ -79,11 +66,52 @@ namespace Azure { namespace Storage { namespace Test { TestBase::TearDown(); } + std::string ParseConnectionStringAndGetAccountName(const std::string& connectionString) + { + std::map connectionStringMap; + + std::string::const_iterator cur = connectionString.begin(); + + while (cur != connectionString.end()) + { + auto key_begin = cur; + auto key_end = std::find(cur, connectionString.end(), '='); + std::string key = std::string(key_begin, key_end); + cur = key_end; + if (cur != connectionString.end()) + { + ++cur; + } + + auto value_begin = cur; + auto value_end = std::find(cur, connectionString.end(), ';'); + std::string value = std::string(value_begin, value_end); + cur = value_end; + if (cur != connectionString.end()) + { + ++cur; + } + + if (!key.empty() || !value.empty()) + { + connectionStringMap[std::move(key)] = std::move(value); + } + } + + auto getWithDefault = [](const std::map& m, + const std::string& key, + const std::string& defaultValue = std::string()) { + auto ite = m.find(key); + return ite == m.end() ? defaultValue : ite->second; + }; + + return getWithDefault(connectionStringMap, "AccountName"); + } + const std::string& StorageTest::StandardStorageAccountName() { const static std::string accountName - = Azure::Storage::_internal::ParseConnectionString(StandardStorageConnectionString()) - .AccountName; + = ParseConnectionStringAndGetAccountName(StandardStorageConnectionString()); return accountName; } @@ -102,8 +130,7 @@ namespace Azure { namespace Storage { namespace Test { const std::string& StorageTest::PremiumFileAccountName() { const static std::string accountName - = Azure::Storage::_internal::ParseConnectionString(PremiumFileConnectionString()) - .AccountName; + = ParseConnectionStringAndGetAccountName(PremiumFileConnectionString()); return accountName; } @@ -122,7 +149,7 @@ namespace Azure { namespace Storage { namespace Test { const std::string& StorageTest::AdlsGen2AccountName() { const static std::string accountName - = Azure::Storage::_internal::ParseConnectionString(AdlsGen2ConnectionString()).AccountName; + = ParseConnectionStringAndGetAccountName(AdlsGen2ConnectionString()); return accountName; } @@ -204,9 +231,9 @@ namespace Azure { namespace Storage { namespace Test { return Azure::Core::_internal::StringExtensions::ToLower(RandomString(size)); } - Storage::Metadata StorageTest::RandomMetadata(size_t size) + Metadata StorageTest::RandomMetadata(size_t size) { - Storage::Metadata result; + Metadata result; for (size_t i = 0; i < size; ++i) { result["meta" + LowercaseRandomString(5)] = RandomString(10); diff --git a/sdk/storage/azure-storage-common/test/ut/test_base.hpp b/sdk/storage/azure-storage-common/test/ut/test_base.hpp index d58c1d1a47..6ce1f98854 100644 --- a/sdk/storage/azure-storage-common/test/ut/test_base.hpp +++ b/sdk/storage/azure-storage-common/test/ut/test_base.hpp @@ -10,9 +10,6 @@ #include #include #include -#include -#include -#include #include #include @@ -25,6 +22,8 @@ namespace Azure { namespace Storage { + using Metadata = Azure::Core::CaseInsensitiveMap; + namespace Test { class StorageTest : public Azure::Core::Test::TestBase { @@ -121,7 +120,7 @@ namespace Azure { namespace Storage { char RandomChar(); std::string RandomString(size_t size = 10); std::string LowercaseRandomString(size_t size = 10); - Storage::Metadata RandomMetadata(size_t size = 5); + Metadata RandomMetadata(size_t size = 5); void RandomBuffer(char* buffer, size_t length); void RandomBuffer(uint8_t* buffer, size_t length) { diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp index e994a20609..22623424c1 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp @@ -11,7 +11,14 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Models { - bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs); + bool operator==(const SignedIdentifier& lhs, const SignedIdentifier& rhs) + { + return lhs.Id == rhs.Id && lhs.StartsOn.HasValue() == rhs.StartsOn.HasValue() + && (!lhs.StartsOn.HasValue() || lhs.StartsOn.Value() == rhs.StartsOn.Value()) + && lhs.ExpiresOn.HasValue() == rhs.ExpiresOn.HasValue() + && (!lhs.ExpiresOn.HasValue() || lhs.ExpiresOn.Value() == rhs.ExpiresOn.Value()) + && lhs.Permissions == rhs.Permissions; + } }}}} // namespace Azure::Storage::Blobs::Models diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp index e28b41b3a9..ad49b34d8d 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp @@ -3,6 +3,8 @@ #include "share_directory_client_test.hpp" +#include + #include #include diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp index 77834a4f3b..85f994fcc2 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp @@ -4,6 +4,8 @@ #include "share_file_client_test.hpp" #include +#include +#include #include #include #include diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp index 829982fe2f..b3fb88a7c9 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_sas_test.cpp @@ -3,6 +3,7 @@ #include "share_client_test.hpp" +#include #include #include diff --git a/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp b/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp index d5987b90b6..900e0c11a0 100644 --- a/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp +++ b/sdk/storage/azure-storage-queues/test/ut/queue_sas_test.cpp @@ -3,6 +3,7 @@ #include "queue_client_test.hpp" +#include #include #include diff --git a/sdk/tables/azure-data-tables/test/ut/CMakeLists.txt b/sdk/tables/azure-data-tables/test/ut/CMakeLists.txt index cfdadaf34b..cd4dc0bd5c 100644 --- a/sdk/tables/azure-data-tables/test/ut/CMakeLists.txt +++ b/sdk/tables/azure-data-tables/test/ut/CMakeLists.txt @@ -40,7 +40,7 @@ create_map_file(azure-data-tables-test azure-data-tables-test.map) # Include shared test headers target_include_directories(azure-data-tables-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../storage/azure-storage-common) -target_link_libraries(azure-data-tables-test PRIVATE azure-data-tables azure-storage-blobs azure-identity azure-core-test-fw gtest gtest_main gmock) +target_link_libraries(azure-data-tables-test PRIVATE azure-data-tables azure-identity azure-core-test-fw gtest gtest_main gmock) # gtest_discover_tests will scan the test from azure-data-tables-test and call add_test # for each test to ctest. This enables `ctest -r` to run specific tests directly.