Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
m7hm7t committed Jun 1, 2024
1 parent 7935cf2 commit ce7fc05
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
4 changes: 2 additions & 2 deletions pkg/storages/azure/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ func ConfigureFolder(prefix string, settings map[string]string) (storage.Folder,
var containerClient *azblob.ContainerClient
if authType == AzureSASTokenAuth {
containerClient, err = getContainerClientWithSASToken(accountName, storageEndpointSuffix, containerName, timeout, accountToken)
} else if authType == AzureAccessKeyAuth {
containerClient, err = getContainerClientWithAccessKey(accountName, storageEndpointSuffix, containerName, timeout, credential)
} else if authType == AzureManagedIdentityAuth {
containerClient, err = getContainerClientWithManagedIndetity(accountName, storageEndpointSuffix, containerName, timeout, clientID)
} else if authType == AzureAccessKeyAuth {
containerClient, err = getContainerClientWithAccessKey(accountName, storageEndpointSuffix, containerName, timeout, credential)
} else {
// No explicitly configured auth method, try the default credential chain
containerClient, err = getContainerClient(accountName, storageEndpointSuffix, containerName, timeout)
Expand Down
28 changes: 0 additions & 28 deletions pkg/storages/azure/folder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/wal-g/wal-g/pkg/storages/storage"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
"github.com/golang/mock/gomock"
)

func TestAzureFolder(t *testing.T) {
Expand Down Expand Up @@ -70,28 +67,3 @@ func TestGetContainerClientWithManagedIdentity(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, containerClient)
}

func TestGetContainerClientWithManagedIdentity2(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockCred := azidentity.NewMockManagedIdentityCredential(ctrl)
mockContainerClient := azblob.NewMockContainerClient(ctrl)

accountName := "testAccount"
storageEndpointSuffix := "core.windows.net"
containerName := "testContainer"
timeout := time.Second * 10
clientID := "testClientID"

mockCred.EXPECT().NewManagedIdentityCredential(gomock.Any()).Return(mockCred, nil)
mockContainerClient.EXPECT().NewContainerClient(gomock.Any(), gomock.Any(), gomock.Any()).Return(mockContainerClient, nil)

containerClient, err := getContainerClientWithManagedIdentity(accountName, storageEndpointSuffix, containerName, timeout, clientID)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if containerClient == nil {
t.Error("Expected ContainerClient, got nil")
}
}

0 comments on commit ce7fc05

Please sign in to comment.