From a716e094fe4c17f872181cc755e13843f53ead8d Mon Sep 17 00:00:00 2001 From: Gabor Gyimesi Date: Mon, 16 Nov 2020 02:58:01 +0100 Subject: [PATCH] Fix default EndpointSuffix when parsing connection string (#981) --- sdk/storage/azure-storage-common/CMakeLists.txt | 3 ++- .../src/storage_credential.cpp | 2 +- .../test/storage_credential_test.cpp | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 sdk/storage/azure-storage-common/test/storage_credential_test.cpp diff --git a/sdk/storage/azure-storage-common/CMakeLists.txt b/sdk/storage/azure-storage-common/CMakeLists.txt index e1e286b50..e20c8d6d7 100644 --- a/sdk/storage/azure-storage-common/CMakeLists.txt +++ b/sdk/storage/azure-storage-common/CMakeLists.txt @@ -69,6 +69,7 @@ target_sources( PRIVATE test/bearer_token_test.cpp test/crypt_functions_test.cpp + test/storage_credential_test.cpp test/test_base.cpp test/test_base.hpp ) @@ -85,7 +86,7 @@ target_sources( sample/main.cpp sample/samples_common.hpp ) - + target_include_directories(azure-storage-sample PUBLIC sample) generate_documentation(azure-storage-common ${AZ_LIBRARY_VERSION}) diff --git a/sdk/storage/azure-storage-common/src/storage_credential.cpp b/sdk/storage/azure-storage-common/src/storage_credential.cpp index 16ee8988b..95f5f466a 100644 --- a/sdk/storage/azure-storage-common/src/storage_credential.cpp +++ b/sdk/storage/azure-storage-common/src/storage_credential.cpp @@ -51,7 +51,7 @@ namespace Azure { namespace Storage { namespace Details { std::string defaultEndpointsProtocol = getWithDefault(connectionStringMap, "DefaultEndpointsProtocol", "https"); std::string EndpointSuffix - = getWithDefault(connectionStringMap, "EndpointSuffix", ".core.windows.net"); + = getWithDefault(connectionStringMap, "EndpointSuffix", "core.windows.net"); std::string accountName = getWithDefault(connectionStringMap, "AccountName"); std::string endpoint = getWithDefault(connectionStringMap, "BlobEndpoint"); diff --git a/sdk/storage/azure-storage-common/test/storage_credential_test.cpp b/sdk/storage/azure-storage-common/test/storage_credential_test.cpp new file mode 100644 index 000000000..5fc17f622 --- /dev/null +++ b/sdk/storage/azure-storage-common/test/storage_credential_test.cpp @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "azure/storage/common/storage_credential.hpp" +#include "test_base.hpp" + +namespace Azure { namespace Storage { namespace Test { + + TEST(StorageCredentialTest, DefaultHostCorrect) + { + EXPECT_EQ(Azure::Storage::Details::ParseConnectionString( + "DefaultEndpointsProtocol=https;AccountName=testaccount;AccountKey=testkey").BlobServiceUri.GetHost(), "testaccount.blob.core.windows.net"); + } + +}}} // namespace Azure::Storage::Test