diff --git a/sdk/storage/assets.json b/sdk/storage/assets.json index 373923ce0..03e24a0bf 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_99c5e1edcb" + "Tag": "cpp/storage_fc81ec148a" } diff --git a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md index 2cefb9062..fb29d22ba 100644 --- a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Fixed a bug where `PathItem::EncryptionContext` returned by `DataLakeDirectoryClient::ListPaths` was always null. + ### Other Changes ## 12.10.0-beta.1 (2024-04-17) diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp index d1324883e..3e87324b3 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp @@ -281,6 +281,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { item.ExpiresOn = _detail::Win32FileTimeConverter::Win32FileTimeToDateTime( std::stoll(path.ExpiresOn.Value())); } + item.EncryptionContext = std::move(path.EncryptionContext); pagedResponse.Paths.push_back(std::move(item)); } pagedResponse.m_directoryClient = std::make_shared(*this); diff --git a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp index 076fe2152..cc1e97f53 100644 --- a/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_client_test.cpp @@ -570,11 +570,14 @@ namespace Azure { namespace Storage { namespace Test { } } - TEST_F(DataLakeFileClientTest, CreateWithEncryptionContext_LIVEONLY_) + TEST_F(DataLakeFileClientTest, CreateWithEncryptionContext) { std::string encryptionContext = "encryptionContext"; const std::string fileName = RandomString(); - auto fileClient = m_fileSystemClient->GetFileClient(fileName); + const std::string directoryName = LowercaseRandomString(); + auto directoryClient = m_fileSystemClient->GetDirectoryClient(directoryName); + auto fileClient = directoryClient.GetFileClient(fileName); + directoryClient.Create(); Files::DataLake::CreateFileOptions options; options.EncryptionContext = encryptionContext; // Assert Create @@ -587,14 +590,19 @@ namespace Azure { namespace Storage { namespace Test { auto downloadResult = fileClient.Download(); EXPECT_TRUE(downloadResult.Value.Details.EncryptionContext.HasValue()); EXPECT_EQ(encryptionContext, downloadResult.Value.Details.EncryptionContext.Value()); - // Assert ListPaths - auto paths = m_fileSystemClient->ListPaths(false).Paths; + // Assert DataLakeDirectoryClient::ListPaths + auto paths = directoryClient.ListPaths(false).Paths; + EXPECT_EQ(paths.size(), 1); + EXPECT_TRUE(paths[0].EncryptionContext.HasValue()); + EXPECT_EQ(encryptionContext, paths[0].EncryptionContext.Value()); + + // Assert DataLakeFileSystemClient::ListPaths + paths = m_fileSystemClient->ListPaths(true).Paths; auto iter = std::find_if( - paths.begin(), paths.end(), [&fileName](const Files::DataLake::Models::PathItem& path) { - return path.Name == fileName; + paths.begin(), paths.end(), [](const Files::DataLake::Models::PathItem& path) { + return path.EncryptionContext.HasValue(); }); EXPECT_NE(paths.end(), iter); - EXPECT_TRUE(iter->EncryptionContext.HasValue()); EXPECT_EQ(encryptionContext, iter->EncryptionContext.Value()); }