@@ -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
0 commit comments