Skip to content

Commit 698490f

Browse files
authored
Storage/Enable Test Cases(Resolve Issue #5524) (#5532)
* Enable Test Cases * Fix Customer provided key
1 parent b063cde commit 698490f

5 files changed

Lines changed: 60 additions & 32 deletions

File tree

sdk/storage/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "cpp",
44
"TagPrefix": "cpp/storage",
5-
"Tag": "cpp/storage_48454df579"
5+
"Tag": "cpp/storage_3d44001e6b"
66
}

sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ namespace Azure { namespace Storage { namespace Test {
616616
}
617617
}
618618

619-
TEST_F(BlobContainerClientTest, CustomerProvidedKey_LIVEONLY_)
619+
TEST_F(BlobContainerClientTest, CustomerProvidedKey)
620620
{
621621
auto sourceContainerClient = *m_blobContainerClient;
622622

@@ -629,6 +629,7 @@ namespace Azure { namespace Storage { namespace Test {
629629
key.Algorithm = Blobs::Models::EncryptionAlgorithmType::Aes256;
630630
return key;
631631
};
632+
auto redactedKeyHash = Core::Convert::Base64Decode("REDACTED");
632633

633634
Blobs::BlobClientOptions options;
634635
options.CustomerProvidedKey = getRandomCustomerProvidedKey();
@@ -665,14 +666,16 @@ namespace Azure { namespace Storage { namespace Test {
665666
auto blobContentInfo = appendBlob.Create().Value;
666667
EXPECT_TRUE(blobContentInfo.IsServerEncrypted);
667668
EXPECT_TRUE(blobContentInfo.EncryptionKeySha256.HasValue());
668-
EXPECT_EQ(
669-
blobContentInfo.EncryptionKeySha256.Value(), options.CustomerProvidedKey.Value().KeyHash);
669+
EXPECT_TRUE(
670+
blobContentInfo.EncryptionKeySha256.Value() == options.CustomerProvidedKey.Value().KeyHash
671+
|| blobContentInfo.EncryptionKeySha256.Value() == redactedKeyHash);
670672
auto blobItem = GetBlobItem(appendBlobName);
671673
EXPECT_TRUE(blobItem.Details.IsServerEncrypted);
672674
EXPECT_TRUE(blobItem.Details.EncryptionKeySha256.HasValue());
673-
EXPECT_EQ(
674-
blobItem.Details.EncryptionKeySha256.Value(),
675-
options.CustomerProvidedKey.Value().KeyHash);
675+
EXPECT_TRUE(
676+
blobItem.Details.EncryptionKeySha256.Value()
677+
== options.CustomerProvidedKey.Value().KeyHash
678+
|| blobItem.Details.EncryptionKeySha256.Value() == redactedKeyHash);
676679

677680
bodyStream.Rewind();
678681
EXPECT_NO_THROW(appendBlob.AppendBlock(bodyStream));
@@ -682,9 +685,10 @@ namespace Azure { namespace Storage { namespace Test {
682685
auto setMetadataRes = appendBlob.SetMetadata({});
683686
EXPECT_TRUE(setMetadataRes.Value.IsServerEncrypted);
684687
ASSERT_TRUE(setMetadataRes.Value.EncryptionKeySha256.HasValue());
685-
EXPECT_EQ(
686-
setMetadataRes.Value.EncryptionKeySha256.Value(),
687-
options.CustomerProvidedKey.Value().KeyHash);
688+
EXPECT_TRUE(
689+
setMetadataRes.Value.EncryptionKeySha256.Value()
690+
== options.CustomerProvidedKey.Value().KeyHash
691+
|| setMetadataRes.Value.EncryptionKeySha256.Value() == redactedKeyHash);
688692
EXPECT_NO_THROW(appendBlob.CreateSnapshot());
689693

690694
auto appendBlobClientWithoutEncryptionKey
@@ -712,8 +716,9 @@ namespace Azure { namespace Storage { namespace Test {
712716
auto blobContentInfo = pageBlob.Create(0).Value;
713717
EXPECT_TRUE(blobContentInfo.IsServerEncrypted);
714718
EXPECT_TRUE(blobContentInfo.EncryptionKeySha256.HasValue());
715-
EXPECT_EQ(
716-
blobContentInfo.EncryptionKeySha256.Value(), options.CustomerProvidedKey.Value().KeyHash);
719+
EXPECT_TRUE(
720+
blobContentInfo.EncryptionKeySha256.Value() == options.CustomerProvidedKey.Value().KeyHash
721+
|| blobContentInfo.EncryptionKeySha256.Value() == redactedKeyHash);
717722
bodyStream.Rewind();
718723
EXPECT_NO_THROW(pageBlob.Resize(blobContent.size()));
719724
EXPECT_NO_THROW(pageBlob.UploadPages(0, bodyStream));

sdk/storage/azure-storage-files-datalake/test/ut/datalake_file_system_client_test.cpp

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ namespace Azure { namespace Storage { namespace Test {
322322
}
323323
}
324324

325-
TEST_F(DataLakeFileSystemClientTest, CustomerProvidedKey_LIVEONLY_)
325+
TEST_F(DataLakeFileSystemClientTest, CustomerProvidedKey)
326326
{
327327
auto getRandomCustomerProvidedKey = [&]() {
328328
Files::DataLake::EncryptionKey key;
@@ -343,6 +343,7 @@ namespace Azure { namespace Storage { namespace Test {
343343
auto fileSystemClientWithCPK
344344
= GetFileSystemClientForTest(m_fileSystemName, clientOptionsWithCPK);
345345
auto fileSystemClientWithoutCPK = GetFileSystemClientForTest(m_fileSystemName);
346+
auto redactedKeyHash = Core::Convert::Base64Decode("REDACTED");
346347

347348
// fileSystem works
348349
{
@@ -358,7 +359,9 @@ namespace Azure { namespace Storage { namespace Test {
358359
auto newFileClient = std::make_shared<Files::DataLake::DataLakeFileClient>(
359360
fileSystemClientWithCPK.RenameFile(filename1, filename2).Value);
360361
auto properties = newFileClient->GetProperties().Value;
361-
EXPECT_EQ(customerProvidedKey.KeyHash, properties.EncryptionKeySha256.Value());
362+
EXPECT_TRUE(
363+
properties.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
364+
|| properties.EncryptionKeySha256.Value() == redactedKeyHash);
362365
auto newFileClientWithoutEncryptionKey
363366
= std::make_shared<Files::DataLake::DataLakeFileClient>(
364367
fileSystemClientWithoutCPK.GetFileClient(filename2));
@@ -381,7 +384,9 @@ namespace Azure { namespace Storage { namespace Test {
381384
fileSystemClientWithCPK.RenameDirectory(oldDirectoryName, newDirectoryName).Value);
382385
properties = newDirectoryClient->GetProperties().Value;
383386
EXPECT_TRUE(properties.EncryptionKeySha256.HasValue());
384-
EXPECT_EQ(customerProvidedKey.KeyHash, properties.EncryptionKeySha256.Value());
387+
EXPECT_TRUE(
388+
properties.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
389+
|| properties.EncryptionKeySha256.Value() == redactedKeyHash);
385390
auto newDirectoryClientWithoutEncryptionKey
386391
= std::make_shared<Files::DataLake::DataLakeDirectoryClient>(
387392
fileSystemClientWithoutCPK.GetDirectoryClient(newDirectoryName));
@@ -391,7 +396,9 @@ namespace Azure { namespace Storage { namespace Test {
391396

392397
auto createResult = fileSystemClientWithCPK.GetFileClient(filename4).Create().Value;
393398
EXPECT_TRUE(createResult.EncryptionKeySha256.HasValue());
394-
EXPECT_EQ(customerProvidedKey.KeyHash, createResult.EncryptionKeySha256.Value());
399+
EXPECT_TRUE(
400+
createResult.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
401+
|| createResult.EncryptionKeySha256.Value() == redactedKeyHash);
395402
}
396403

397404
// path works
@@ -410,8 +417,9 @@ namespace Azure { namespace Storage { namespace Test {
410417
EXPECT_NO_THROW(pathClientWithCPK->SetMetadata(RandomMetadata()));
411418
auto properties = pathClientWithCPK->GetProperties().Value;
412419
EXPECT_TRUE(properties.EncryptionKeySha256.HasValue());
413-
EXPECT_EQ(customerProvidedKey.KeyHash, properties.EncryptionKeySha256.Value());
414-
420+
EXPECT_TRUE(
421+
properties.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
422+
|| properties.EncryptionKeySha256.Value() == redactedKeyHash);
415423
EXPECT_THROW(pathClientWithoutCPK->SetMetadata(RandomMetadata()), StorageException);
416424
EXPECT_THROW(pathClientWithoutCPK->GetProperties(), StorageException);
417425
EXPECT_NO_THROW(pathClientWithoutCPK->GetAccessControlList());
@@ -422,7 +430,9 @@ namespace Azure { namespace Storage { namespace Test {
422430
auto createResult
423431
= pathClient2WithCPK->Create(Files::DataLake::Models::PathResourceType::File).Value;
424432
EXPECT_TRUE(createResult.EncryptionKeySha256.HasValue());
425-
EXPECT_EQ(customerProvidedKey.KeyHash, createResult.EncryptionKeySha256.Value());
433+
EXPECT_TRUE(
434+
createResult.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
435+
|| createResult.EncryptionKeySha256.Value() == redactedKeyHash);
426436
}
427437

428438
// file works
@@ -456,13 +466,17 @@ namespace Azure { namespace Storage { namespace Test {
456466
EXPECT_NO_THROW(fileClientWithCPK->SetMetadata(RandomMetadata()));
457467
auto properties = fileClientWithCPK->GetProperties().Value;
458468
EXPECT_TRUE(properties.EncryptionKeySha256.HasValue());
459-
EXPECT_EQ(customerProvidedKey.KeyHash, properties.EncryptionKeySha256.Value());
469+
EXPECT_TRUE(
470+
properties.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
471+
|| properties.EncryptionKeySha256.Value() == redactedKeyHash);
460472
EXPECT_THROW(fileClientWithoutCPK->Flush(buffer.size()), StorageException);
461473
EXPECT_THROW(fileClientWithoutCPK->Download(), StorageException);
462474

463475
auto createResult = fileClient2WithCPK->Create().Value;
464476
EXPECT_TRUE(createResult.EncryptionKeySha256.HasValue());
465-
EXPECT_EQ(customerProvidedKey.KeyHash, createResult.EncryptionKeySha256.Value());
477+
EXPECT_TRUE(
478+
createResult.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
479+
|| createResult.EncryptionKeySha256.Value() == redactedKeyHash);
466480
}
467481
// directory works
468482
{
@@ -489,15 +503,20 @@ namespace Azure { namespace Storage { namespace Test {
489503
directoryClientWithCPK->GetFileClient(fileName1));
490504
EXPECT_NO_THROW(fileClientWithCPK->Create());
491505
auto subdirectoryProperties = subdirectoryClientWithCPK->GetProperties().Value;
492-
EXPECT_EQ(customerProvidedKey.KeyHash, subdirectoryProperties.EncryptionKeySha256.Value());
506+
EXPECT_TRUE(
507+
subdirectoryProperties.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
508+
|| subdirectoryProperties.EncryptionKeySha256.Value() == redactedKeyHash);
493509
auto fileProperties = fileClientWithCPK->GetProperties();
494-
EXPECT_EQ(customerProvidedKey.KeyHash, fileProperties.Value.EncryptionKeySha256.Value());
495-
510+
EXPECT_TRUE(
511+
fileProperties.Value.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
512+
|| fileProperties.Value.EncryptionKeySha256.Value() == redactedKeyHash);
496513
// rename file
497514
auto newFileClient
498515
= directoryClientWithCPK->RenameFile(fileName1, directoryName + "/" + fileName2).Value;
499516
auto newFileProperties = newFileClient.GetProperties().Value;
500-
EXPECT_EQ(customerProvidedKey.KeyHash, newFileProperties.EncryptionKeySha256.Value());
517+
EXPECT_TRUE(
518+
newFileProperties.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
519+
|| newFileProperties.EncryptionKeySha256.Value() == redactedKeyHash);
501520
auto newFileClientWithoutCPK = std::make_shared<Files::DataLake::DataLakeFileClient>(
502521
fileSystemClientWithoutCPK.GetFileClient(directoryName + "/" + fileName2));
503522
EXPECT_THROW(newFileClientWithoutCPK->GetProperties(), StorageException);
@@ -509,7 +528,9 @@ namespace Azure { namespace Storage { namespace Test {
509528
->RenameSubdirectory(subdirectoryName1, directoryName + "/" + subdirectoryName2)
510529
.Value;
511530
auto newSubdirectoryProperties = newSubdirectoryClientWithCPK.GetProperties().Value;
512-
EXPECT_EQ(customerProvidedKey.KeyHash, newSubdirectoryProperties.EncryptionKeySha256.Value());
531+
EXPECT_TRUE(
532+
newSubdirectoryProperties.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
533+
|| newSubdirectoryProperties.EncryptionKeySha256.Value() == redactedKeyHash);
513534
auto newsubdirectoryClientWithoutCPK
514535
= std::make_shared<Files::DataLake::DataLakeDirectoryClient>(
515536
fileSystemClientWithoutCPK.GetDirectoryClient(
@@ -522,7 +543,9 @@ namespace Azure { namespace Storage { namespace Test {
522543
fileSystemClientWithCPK.GetDirectoryClient(directoryName2));
523544
auto createResult = directoryClient2WithCPK->Create().Value;
524545
EXPECT_TRUE(createResult.EncryptionKeySha256.HasValue());
525-
EXPECT_EQ(customerProvidedKey.KeyHash, createResult.EncryptionKeySha256.Value());
546+
EXPECT_TRUE(
547+
createResult.EncryptionKeySha256.Value() == customerProvidedKey.KeyHash
548+
|| createResult.EncryptionKeySha256.Value() == redactedKeyHash);
526549
}
527550
}
528551

sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace Azure { namespace Storage { namespace Test {
120120
}
121121
}
122122

123-
TEST_F(FileShareDirectoryClientTest, RenameFile_LIVEONLY_)
123+
TEST_F(FileShareDirectoryClientTest, RenameFile)
124124
{
125125
const std::string baseName = RandomString();
126126
const std::string baseDirectoryName = baseName + "1";
@@ -285,7 +285,7 @@ namespace Azure { namespace Storage { namespace Test {
285285
}
286286
}
287287

288-
TEST_F(FileShareDirectoryClientTest, RenameSubdirectory_LIVEONLY_)
288+
TEST_F(FileShareDirectoryClientTest, RenameSubdirectory)
289289
{
290290
const std::string baseName = RandomString();
291291
const std::string baseDirectoryName = baseName + "1";
@@ -999,7 +999,7 @@ namespace Azure { namespace Storage { namespace Test {
999999
testTrailingDot(false);
10001000
}
10011001

1002-
TEST_F(FileShareDirectoryClientTest, RenameAllowTrailingDot_LIVEONLY_)
1002+
TEST_F(FileShareDirectoryClientTest, RenameAllowTrailingDot)
10031003
{
10041004
const std::string directoryNameWithTrailingDot = RandomString() + ".";
10051005
const std::string connectionString = StandardStorageConnectionString();
@@ -1099,7 +1099,7 @@ namespace Azure { namespace Storage { namespace Test {
10991099
testTrailingDot(false, false);
11001100
}
11011101

1102-
TEST_F(FileShareDirectoryClientTest, DISABLED_OAuth)
1102+
TEST_F(FileShareDirectoryClientTest, OAuth_PLAYBACKONLY_)
11031103
{
11041104
const std::string directoryName = RandomString();
11051105

sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ namespace Azure { namespace Storage { namespace Test {
901901
}
902902
}
903903

904-
TEST_F(FileShareFileClientTest, DISABLED_GetRangeListDiffWithRename)
904+
TEST_F(FileShareFileClientTest, GetRangeListDiffWithRename)
905905
{
906906
size_t rangeSize = 128;
907907
std::vector<uint8_t> rangeContent = RandomBuffer(rangeSize);

0 commit comments

Comments
 (0)