azureblob: Port to new SDK
This commit switches from using the old Azure go modules github.com/Azure/azure-pipeline-go/pipeline github.com/Azure/azure-storage-blob-go/azblob github.com/Azure/go-autorest/autorest/adal To the new SDK github.com/Azure/azure-sdk-for-go/ This stops rclone using deprecated code and enables the full range of authentication with Azure. See #6132 and #5284
This commit is contained in:
parent
60e4cb6f6f
commit
a131da2c35
8 changed files with 968 additions and 820 deletions
|
@ -1,13 +1,11 @@
|
|||
// Test AzureBlob filesystem interface
|
||||
|
||||
//go:build !plan9 && !solaris && !js
|
||||
// +build !plan9,!solaris,!js
|
||||
//go:build !plan9 && !solaris && !js && go1.18
|
||||
// +build !plan9,!solaris,!js,go1.18
|
||||
|
||||
package azureblob
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
|
@ -18,10 +16,12 @@ import (
|
|||
// TestIntegration runs integration tests against the remote
|
||||
func TestIntegration(t *testing.T) {
|
||||
fstests.Run(t, &fstests.Opt{
|
||||
RemoteName: "TestAzureBlob:",
|
||||
NilObject: (*Object)(nil),
|
||||
TiersToTest: []string{"Hot", "Cool"},
|
||||
ChunkedUpload: fstests.ChunkedUploadConfig{},
|
||||
RemoteName: "TestAzureBlob:",
|
||||
NilObject: (*Object)(nil),
|
||||
TiersToTest: []string{"Hot", "Cool"},
|
||||
ChunkedUpload: fstests.ChunkedUploadConfig{
|
||||
MinChunkSize: defaultChunkSize,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -33,44 +33,6 @@ var (
|
|||
_ fstests.SetUploadChunkSizer = (*Fs)(nil)
|
||||
)
|
||||
|
||||
// TestServicePrincipalFileSuccess checks that, given a proper JSON file, we can create a token.
|
||||
func TestServicePrincipalFileSuccess(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
credentials := `
|
||||
{
|
||||
"appId": "my application (client) ID",
|
||||
"password": "my secret",
|
||||
"tenant": "my active directory tenant ID"
|
||||
}
|
||||
`
|
||||
var spCredentials servicePrincipalCredentials
|
||||
jerr := json.Unmarshal([]byte(credentials), &spCredentials)
|
||||
assert.Nil(t, jerr)
|
||||
|
||||
tokenRefresher, err := newServicePrincipalTokenRefresher(ctx, spCredentials)
|
||||
if assert.NoError(t, err) {
|
||||
assert.NotNil(t, tokenRefresher)
|
||||
}
|
||||
}
|
||||
|
||||
// TestServicePrincipalFileFailure checks that, given a JSON file with a missing secret, it returns an error.
|
||||
func TestServicePrincipalFileFailure(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
credentials := `
|
||||
{
|
||||
"appId": "my application (client) ID",
|
||||
"tenant": "my active directory tenant ID"
|
||||
}
|
||||
`
|
||||
var spCredentials servicePrincipalCredentials
|
||||
jerr := json.Unmarshal([]byte(credentials), &spCredentials)
|
||||
assert.Nil(t, jerr)
|
||||
|
||||
_, err := newServicePrincipalTokenRefresher(ctx, spCredentials)
|
||||
assert.Error(t, err)
|
||||
assert.EqualError(t, err, "error creating service principal token: parameter 'secret' cannot be empty")
|
||||
}
|
||||
|
||||
func TestValidateAccessTier(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
accessTier string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue