diff --git a/sdk/storage/assets.json b/sdk/storage/assets.json index 12d8d6aa02..bc0ad29f3d 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_17c4a656fc" + "Tag": "cpp/storage_b920de0000" } diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp index 82f04974e2..7983b64d8a 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp @@ -170,7 +170,7 @@ namespace Azure { namespace Storage { namespace Test { } } - TEST_F(BlobSasTest, ServiceContainerSasPermissions_LIVEONLY_) + TEST_F(BlobSasTest, ServiceContainerSasPermissions) { auto sasStartsOn = std::chrono::system_clock::now() - std::chrono::minutes(5); auto sasExpiresOn = std::chrono::system_clock::now() + std::chrono::minutes(60); @@ -184,7 +184,8 @@ namespace Azure { namespace Storage { namespace Test { auto blobServiceClient = Blobs::BlobServiceClient( m_blobServiceClient->GetUrl(), std::make_shared( - AadTenantId(), AadClientId(), AadClientSecret())); + AadTenantId(), AadClientId(), AadClientSecret(), GetTokenCredentialOptions()), + InitStorageClientOptions()); userDelegationKey = blobServiceClient.GetUserDelegationKey(sasExpiresOn).Value; } @@ -279,7 +280,7 @@ namespace Azure { namespace Storage { namespace Test { } } - TEST_F(BlobSasTest, ServiceBlobSasPermissions_LIVEONLY_) + TEST_F(BlobSasTest, ServiceBlobSasPermissions) { auto sasStartsOn = std::chrono::system_clock::now() - std::chrono::minutes(5); auto sasExpiresOn = std::chrono::system_clock::now() + std::chrono::minutes(60); @@ -293,7 +294,8 @@ namespace Azure { namespace Storage { namespace Test { auto blobServiceClient = Blobs::BlobServiceClient( m_blobServiceClient->GetUrl(), std::make_shared( - AadTenantId(), AadClientId(), AadClientSecret())); + AadTenantId(), AadClientId(), AadClientSecret(), GetTokenCredentialOptions()), + InitStorageClientOptions()); userDelegationKey = blobServiceClient.GetUserDelegationKey(sasExpiresOn).Value; } diff --git a/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp index 26dea522ca..9dc0e49197 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp @@ -438,7 +438,7 @@ namespace Azure { namespace Storage { namespace Test { containerClient.DeleteIfExists(); } - TEST_F(BlobServiceClientTest, UserDelegationKey_LIVEONLY_) + TEST_F(BlobServiceClientTest, UserDelegationKey) { auto serviceClient = *m_blobServiceClient; @@ -446,7 +446,7 @@ namespace Azure { namespace Storage { namespace Test { std::shared_ptr credential = std::make_shared( - AadTenantId(), AadClientId(), AadClientSecret()); + AadTenantId(), AadClientId(), AadClientSecret(), GetTokenCredentialOptions()); Blobs::BlobClientOptions options; InitStorageClientOptions(options); diff --git a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp index c6636ea999..2d5b954859 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp @@ -76,28 +76,48 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(BlockBlobClientTest, SoftDelete) { - const std::string blobName = m_blobName; - auto blobClient = *m_blockBlobClient; - - std::vector emptyContent; - auto blobContent = Azure::Core::IO::MemoryBodyStream(emptyContent.data(), emptyContent.size()); - blobClient.Upload(blobContent); + auto clientOptions = InitStorageClientOptions(); + auto blobContainerClient + = Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString( + AdlsGen2ConnectionString(), LowercaseRandomString(), clientOptions); + blobContainerClient.CreateIfNotExists(); + auto blobName = RandomString(); + auto blobClient = blobContainerClient.GetBlockBlobClient(blobName); + + blobClient.UploadFrom(nullptr, 0); + + auto getBlobItem = [&]() { + Blobs::ListBlobsOptions options; + options.Prefix = blobName; + options.Include = Blobs::Models::ListBlobsIncludeFlags::Deleted; + for (auto page = blobContainerClient.ListBlobs(options); page.HasPage(); + page.MoveToNextPage()) + { + for (auto& blob : page.Blobs) + { + if (blob.Name == blobName) + { + return std::move(blob); + } + } + } + std::abort(); + }; - auto blobItem = GetBlobItem(blobName); + auto blobItem = getBlobItem(); EXPECT_FALSE(blobItem.IsDeleted); EXPECT_FALSE(blobItem.Details.DeletedOn.HasValue()); EXPECT_FALSE(blobItem.Details.RemainingRetentionDays.HasValue()); blobClient.Delete(); - /* - // Soft delete doesn't work in storage account with versioning enabled. - blobItem = GetBlobItem(blobName, Blobs::Models::ListBlobsIncludeFlags::Deleted); + blobItem = getBlobItem(); EXPECT_TRUE(blobItem.IsDeleted); ASSERT_TRUE(blobItem.Details.DeletedOn.HasValue()); EXPECT_TRUE(IsValidTime(blobItem.Details.DeletedOn.Value())); EXPECT_TRUE(blobItem.Details.RemainingRetentionDays.HasValue()); - */ + + blobContainerClient.Delete(); } TEST_F(BlockBlobClientTest, SmallUploadDownload) @@ -798,7 +818,7 @@ namespace Azure { namespace Storage { namespace Test { blobItem.Details.RehydratePriority.Value(), Blobs::Models::RehydratePriority::Standard); } - TEST_F(BlockBlobClientTest, DISABLED_SetTierCold) + TEST_F(BlockBlobClientTest, SetTierCold) { m_blockBlobClient->SetAccessTier(Blobs::Models::AccessTier::Cold); auto properties = m_blockBlobClient->GetProperties().Value; diff --git a/sdk/storage/azure-storage-blobs/test/ut/connection_reuse_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/connection_reuse_test.cpp index 790fd9c205..de5f766142 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/connection_reuse_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/connection_reuse_test.cpp @@ -7,7 +7,7 @@ namespace Azure { namespace Storage { namespace Test { // If connection is reused, the requests with the same connection should hit the same sever. So // this test verifies whether a series of requests hit the same server. - TEST_F(BlockBlobClientTest, IsConnectionReused_LIVEONLY_) + TEST_F(BlockBlobClientTest, IsConnectionReused) { const std::string containerName = LowercaseRandomString(); const std::string blobName = LowercaseRandomString(); diff --git a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp index d2b759af30..6350f5e65c 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp @@ -344,16 +344,37 @@ namespace Azure { namespace Storage { namespace Test { options2.TransactionalContentHash.Value().Value = contentMd5; EXPECT_NO_THROW(pageBlobClient2.UploadPagesFromUri( 0, pageBlobClient.GetUrl() + GetSas(), sourceRange, options2)); - options2.TransactionalContentHash.Value().Algorithm = HashAlgorithm::Crc64; - options2.TransactionalContentHash.Value().Value - = Azure::Core::Convert::Base64Decode(DummyCrc64); - // EXPECT_THROW( - // pageBlobClient2.UploadPagesFromUri( - // 0, pageBlobClient.GetUrl() + GetSas(), sourceRange, options2), - // StorageException); - options2.TransactionalContentHash.Value().Value = contentCrc64; + } + + TEST_F(PageBlobClientTest, DISABLED_UploadPagesFromUriCrc64AccessCondition) + { + auto pageBlobClient = *m_pageBlobClient; + + std::vector blobContent = RandomBuffer(static_cast(4_KB)); + const std::vector contentCrc64 + = Azure::Storage::Crc64Hash().Final(blobContent.data(), blobContent.size()); + + pageBlobClient.Create(blobContent.size()); + auto contentStream = Azure::Core::IO::MemoryBodyStream(blobContent.data(), blobContent.size()); + pageBlobClient.UploadPages(0, contentStream); + + auto pageBlobClient2 = GetPageBlobClientTestForTest(RandomString()); + pageBlobClient2.Create(blobContent.size()); + + Blobs::UploadPagesFromUriOptions options; + Azure::Core::Http::HttpRange sourceRange; + sourceRange.Offset = 0; + sourceRange.Length = blobContent.size(); + options.TransactionalContentHash = ContentHash(); + options.TransactionalContentHash.Value().Algorithm = HashAlgorithm::Crc64; + options.TransactionalContentHash.Value().Value = Azure::Core::Convert::Base64Decode(DummyCrc64); + EXPECT_THROW( + pageBlobClient2.UploadPagesFromUri( + 0, pageBlobClient.GetUrl() + GetSas(), sourceRange, options), + StorageException); + options.TransactionalContentHash.Value().Value = contentCrc64; EXPECT_NO_THROW(pageBlobClient2.UploadPagesFromUri( - 0, pageBlobClient.GetUrl() + GetSas(), sourceRange, options2)); + 0, pageBlobClient.GetUrl() + GetSas(), sourceRange, options)); } TEST_F(PageBlobClientTest, CreateIfNotExists) diff --git a/sdk/storage/azure-storage-common/test/ut/bearer_token_test.cpp b/sdk/storage/azure-storage-common/test/ut/bearer_token_test.cpp index 8288ef2852..adf026af6a 100644 --- a/sdk/storage/azure-storage-common/test/ut/bearer_token_test.cpp +++ b/sdk/storage/azure-storage-common/test/ut/bearer_token_test.cpp @@ -5,16 +5,13 @@ namespace Azure { namespace Storage { namespace Test { - TEST_F(StorageTest, ClientSecretCredentialWorks_LIVEONLY_) + TEST_F(StorageTest, ClientSecretCredentialWorks) { const std::string containerName = LowercaseRandomString(); auto containerClient = Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString( StandardStorageConnectionString(), containerName); auto credential = std::make_shared( - AadTenantId(), - AadClientId(), - AadClientSecret(), - InitStorageClientOptions()); + AadTenantId(), AadClientId(), AadClientSecret(), GetTokenCredentialOptions()); containerClient = Blobs::BlobContainerClient( containerClient.GetUrl(), credential, InitStorageClientOptions());