From 71a7cfb0c1ea7657406a796266a6fdfd4e9aff3a Mon Sep 17 00:00:00 2001 From: microzchang <110015819+microzchang@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:14:41 -0800 Subject: [PATCH] Fix Share Client failure #4377 (#4381) * Fix Share Client failure #4377 --- sdk/storage/assets.json | 2 +- .../azure-storage-files-shares/src/rest_client.cpp | 12 +++++++++--- .../azure-storage-files-shares/swagger/README.md | 4 ++++ .../test/ut/share_client_test.cpp | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sdk/storage/assets.json b/sdk/storage/assets.json index dc46939212..bca7a91d0d 100644 --- a/sdk/storage/assets.json +++ b/sdk/storage/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "cpp", "TagPrefix": "cpp/storage", - "Tag": "cpp/storage_925cef0316" + "Tag": "cpp/storage_92d8f38118" } diff --git a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp index 746db51fe0..b09969a7a6 100644 --- a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp @@ -1652,9 +1652,15 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } } } - response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); - response.LastModified = DateTime::Parse( - pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + if (pRawResponse->GetHeaders().count("ETag") != 0) + { + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + } + if (pRawResponse->GetHeaders().count("Last-Modified") != 0) + { + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + } return Response(std::move(response), std::move(pRawResponse)); } Response DirectoryClient::Create( diff --git a/sdk/storage/azure-storage-files-shares/swagger/README.md b/sdk/storage/azure-storage-files-shares/swagger/README.md index d35b2a83fb..a90f9023ae 100644 --- a/sdk/storage/azure-storage-files-shares/swagger/README.md +++ b/sdk/storage/azure-storage-files-shares/swagger/README.md @@ -378,6 +378,10 @@ directive: - from: swagger-document where: $["x-ms-paths"]["/{shareName}?restype=share&comp=stats"].get.responses["200"] transform: > + $.headers["ETag"]["x-ms-client-default"] = ""; + $.headers["ETag"]["x-nullable"] = true; + $.headers["Last-Modified"]["x-ms-client-default"] = ""; + $.headers["Last-Modified"]["x-nullable"] = true; $.schema = { "description": "Stats for the share.", "type": "object", diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp index 101a4af7e5..63475b85b3 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp @@ -529,6 +529,8 @@ namespace Azure { namespace Storage { namespace Test { } } + TEST_F(FileShareClientTest, GetStatistics) { EXPECT_NO_THROW(m_shareClient->GetStatistics()); } + TEST_F(FileShareClientTest, PremiumShare) { auto shareClientOptions = InitStorageClientOptions();