Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions sdk/storage/azblob/appendblob/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendSetImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

abName := testcommon.GenerateBlobName(testName)
abClient := createNewAppendBlob(context.Background(), _require, abName, containerClient)

Expand Down Expand Up @@ -724,6 +726,7 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendDeleteImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

abName := testcommon.GenerateBlobName(testName)
abClient := createNewAppendBlob(context.Background(), _require, abName, containerClient)
Expand Down Expand Up @@ -756,6 +759,7 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendSetLegalHold() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

abName := testcommon.GenerateBlobName(testName)
abClient := createNewAppendBlob(context.Background(), _require, abName, containerClient)
Expand Down Expand Up @@ -2893,7 +2897,11 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlobSetBlobTags() {
_, err = abClient.AppendBlock(context.Background(), streaming.NopCloser(strings.NewReader("Appending block\n")), nil)
_require.Nil(err)

_, err = abClient.SetTags(context.Background(), testcommon.BasicBlobTagsMap, nil)
var tagsMap = map[string]string{
"azure": "blob",
}

_, err = abClient.SetTags(context.Background(), tagsMap, nil)
_require.Nil(err)
time.Sleep(10 * time.Second)

Expand All @@ -2902,9 +2910,9 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlobSetBlobTags() {

blobTagsSet := blobGetTagsResponse.BlobTagSet
_require.NotNil(blobTagsSet)
_require.Len(blobTagsSet, 3)
_require.Len(blobTagsSet, 1)
for _, blobTag := range blobTagsSet {
_require.Equal(testcommon.BasicBlobTagsMap[*blobTag.Key], *blobTag.Value)
_require.Equal(tagsMap[*blobTag.Key], *blobTag.Value)
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azblob/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/storage/azblob",
"Tag": "go/storage/azblob_b92bf5d8e3"
"Tag": "go/storage/azblob_cbcc92f524"
}
4 changes: 4 additions & 0 deletions sdk/storage/azblob/blob/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3439,6 +3439,7 @@ func (s *BlobRecordedTestsSuite) TestSetImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blockBlobName := testcommon.GenerateBlobName(testName)
bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient)
Expand All @@ -3460,6 +3461,7 @@ func (s *BlobRecordedTestsSuite) TestSetImmutabilityPolicy() {

_, err = bbClient.Delete(context.Background(), nil)
_require.NotNil(err)
testcommon.ValidateBlobErrorCode(_require, err, bloberror.BlobImmutableDueToPolicy)

_, err = bbClient.DeleteImmutabilityPolicy(context.Background(), nil)
_require.Nil(err)
Expand All @@ -3476,6 +3478,7 @@ func (s *BlobRecordedTestsSuite) TestDeleteImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blockBlobName := testcommon.GenerateBlobName(testName)
bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient)
Expand Down Expand Up @@ -3508,6 +3511,7 @@ func (s *BlobRecordedTestsSuite) TestSetLegalHold() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blockBlobName := testcommon.GenerateBlobName(testName)
bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient)
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/azblob/blockblob/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ func (s *BlockBlobRecordedTestsSuite) TestUploadBlockWithImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blockBlobName := testcommon.GenerateBlobName(testName)
bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient)
Expand Down Expand Up @@ -594,6 +595,7 @@ func (s *BlockBlobRecordedTestsSuite) TestPutBlockListWithImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blockBlobName := testcommon.GenerateBlobName(testName)
bbClient := testcommon.CreateNewBlockBlob(context.Background(), _require, blockBlobName, containerClient)
Expand Down
5 changes: 5 additions & 0 deletions sdk/storage/azblob/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ stages:
parameters:
ServiceDirectory: 'storage/azblob'
RunLiveTests: true
EnvVars:
AZURE_CLIENT_ID: $(AZBLOB_CLIENT_ID)
AZURE_TENANT_ID: $(AZBLOB_TENANT_ID)
AZURE_CLIENT_SECRET: $(AZBLOB_CLIENT_SECRET)
AZURE_SUBSCRIPTION_ID: $(AZBLOB_SUBSCRIPTION_ID)
1 change: 1 addition & 0 deletions sdk/storage/azblob/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0
github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0
github.com/stretchr/testify v1.7.1
)

Expand Down
4 changes: 4 additions & 0 deletions sdk/storage/azblob/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4Sath
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.0.0 h1:lMW1lD/17LUA5z1XTURo7LcVG2ICBPlyMHjIUrcFZNQ=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0/go.mod h1:c+Lifp3EDEamAkPVzMooRNOK6CZjNSdEnf1A7jsI9u4=
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE=
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
28 changes: 28 additions & 0 deletions sdk/storage/azblob/internal/testcommon/clients_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"context"
"errors"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas"
"strings"
"testing"
Expand Down Expand Up @@ -46,6 +48,8 @@ const (
AccountNameEnvVar = "AZURE_STORAGE_ACCOUNT_NAME"
AccountKeyEnvVar = "AZURE_STORAGE_ACCOUNT_KEY"
DefaultEndpointSuffixEnvVar = "AZURE_STORAGE_ENDPOINT_SUFFIX"
SubscriptionID = "SUBSCRIPTION_ID"
ResourceGroupName = "RESOURCE_GROUP_NAME"
)

const (
Expand Down Expand Up @@ -364,3 +368,27 @@ func GetAccountSAS(permissions sas.AccountPermissions, resourceTypes sas.Account

return sasQueryParams.Encode(), nil
}

func DeleteContainerUsingManagementClient(_require *require.Assertions, accountType TestAccountType, containerName string) {
if recording.GetRecordMode() == recording.PlaybackMode {
return
}

accountName, err := GetRequiredEnv(string(accountType) + AccountNameEnvVar)
_require.NoError(err)

subscriptionID, err := GetRequiredEnv(SubscriptionID)
_require.NoError(err)

resourceGroupName, err := GetRequiredEnv(ResourceGroupName)
_require.NoError(err)

cred, err := azidentity.NewDefaultAzureCredential(nil)
_require.NoError(err)

managementClient, err := armstorage.NewBlobContainersClient(subscriptionID, cred, nil)
_require.NoError(err)

_, err = managementClient.Delete(context.Background(), resourceGroupName, accountName, containerName, nil)
_require.NoError(err)
}
4 changes: 4 additions & 0 deletions sdk/storage/azblob/pageblob/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3288,6 +3288,8 @@ func (s *PageBlobRecordedTestsSuite) TestPageSetImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blobName := testcommon.GenerateBlobName(testName)
pbClient := createNewPageBlob(context.Background(), _require, blobName, containerClient)

Expand Down Expand Up @@ -3324,6 +3326,7 @@ func (s *PageBlobRecordedTestsSuite) TestPageDeleteImmutabilityPolicy() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blobName := testcommon.GenerateBlobName(testName)
pbClient := createNewPageBlob(context.Background(), _require, blobName, containerClient)
Expand Down Expand Up @@ -3356,6 +3359,7 @@ func (s *PageBlobRecordedTestsSuite) TestPageSetLegalHold() {

containerName := testcommon.GenerateContainerName(testName)
containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient)
defer testcommon.DeleteContainerUsingManagementClient(_require, testcommon.TestAccountImmutable, containerName)

blobName := testcommon.GenerateBlobName(testName)
pbClient := createNewPageBlob(context.Background(), _require, blobName, containerClient)
Expand Down