diff --git a/sdk/storage/azfile/directory/client_test.go b/sdk/storage/azfile/directory/client_test.go index 6f952fe7aae2..c2b7dc12df25 100644 --- a/sdk/storage/azfile/directory/client_test.go +++ b/sdk/storage/azfile/directory/client_test.go @@ -2287,7 +2287,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirectoryClientDefaultAudience() { options := &directory.ClientOptions{ FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), - Audience: to.Ptr("https://storage.azure.com/"), + Audience: "https://storage.azure.com/", } testcommon.SetClientOptions(d.T(), &options.ClientOptions) dirClientAudience, err := directory.NewClient(dirURL, cred, options) @@ -2322,7 +2322,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirectoryClientCustomAudience() { options := &directory.ClientOptions{ FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(d.T(), &options.ClientOptions) dirClientAudience, err := directory.NewClient(dirURL, cred, options) @@ -2357,7 +2357,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirectoryAudienceNegative() { options := &directory.ClientOptions{ FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), - Audience: to.Ptr("https://badaudience.file.core.windows.net"), + Audience: "https://badaudience.file.core.windows.net", } testcommon.SetClientOptions(d.T(), &options.ClientOptions) dirClientAudience, err := directory.NewClient(dirURL, cred, options) diff --git a/sdk/storage/azfile/file/client_test.go b/sdk/storage/azfile/file/client_test.go index f7aa36c5ab7a..c98c4d04ef6b 100644 --- a/sdk/storage/azfile/file/client_test.go +++ b/sdk/storage/azfile/file/client_test.go @@ -4543,7 +4543,7 @@ func (f *FileRecordedTestsSuite) TestFileClientDefaultAudience() { options := &file.ClientOptions{ FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), - Audience: to.Ptr("https://storage.azure.com/"), + Audience: "https://storage.azure.com/", } testcommon.SetClientOptions(f.T(), &options.ClientOptions) fileClientAudience, err := file.NewClient(fileURL, cred, options) @@ -4578,7 +4578,7 @@ func (f *FileRecordedTestsSuite) TestFileClientCustomAudience() { options := &file.ClientOptions{ FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(f.T(), &options.ClientOptions) fileClientAudience, err := file.NewClient(fileURL, cred, options) @@ -4613,7 +4613,7 @@ func (f *FileRecordedTestsSuite) TestFileClientAudienceNegative() { options := &file.ClientOptions{ FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), - Audience: to.Ptr("https://badaudience.file.core.windows.net"), + Audience: "https://badaudience.file.core.windows.net", } testcommon.SetClientOptions(f.T(), &options.ClientOptions) fileClientAudience, err := file.NewClient(fileURL, cred, options) diff --git a/sdk/storage/azfile/internal/base/clients.go b/sdk/storage/azfile/internal/base/clients.go index 8d081a73c4b9..e39baf006011 100644 --- a/sdk/storage/azfile/internal/base/clients.go +++ b/sdk/storage/azfile/internal/base/clients.go @@ -32,7 +32,7 @@ type ClientOptions struct { // Audience to use when requesting tokens for Azure Active Directory authentication. // Only has an effect when credential is of type TokenCredential. The value could be // https://storage.azure.com/ (default) or https://.file.core.windows.net. - Audience *string + Audience string pipelineOptions *runtime.PipelineOptions } @@ -64,10 +64,10 @@ func SetPipelineOptions(clOpts *ClientOptions, plOpts *runtime.PipelineOptions) } func GetAudience(clOpts *ClientOptions) string { - if clOpts == nil || clOpts.Audience == nil { + if clOpts == nil || len(strings.TrimSpace(clOpts.Audience)) == 0 { return shared.TokenScope } else { - return strings.TrimRight(*clOpts.Audience, "/") + "/.default" + return strings.TrimRight(clOpts.Audience, "/") + "/.default" } } diff --git a/sdk/storage/azfile/service/client_test.go b/sdk/storage/azfile/service/client_test.go index 7a6c0c2b3481..0d83e8556f30 100644 --- a/sdk/storage/azfile/service/client_test.go +++ b/sdk/storage/azfile/service/client_test.go @@ -650,7 +650,7 @@ func (s *ServiceRecordedTestsSuite) TestServiceClientCustomAudience() { // create service client using token credential options := &service.ClientOptions{ FileRequestIntent: to.Ptr(service.ShareTokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) svcClientAudience, err := service.NewClient("https://"+accountName+".file.core.windows.net/", cred, options) diff --git a/sdk/storage/azfile/share/client_test.go b/sdk/storage/azfile/share/client_test.go index b75107dff41f..a5dc7fb74d4e 100644 --- a/sdk/storage/azfile/share/client_test.go +++ b/sdk/storage/azfile/share/client_test.go @@ -1647,7 +1647,7 @@ func (s *ShareRecordedTestsSuite) TestShareClientDefaultAudience() { options := &share.ClientOptions{ FileRequestIntent: to.Ptr(share.TokenIntentBackup), - Audience: to.Ptr("https://storage.azure.com/"), + Audience: "https://storage.azure.com/", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) @@ -1684,7 +1684,7 @@ func (s *ShareRecordedTestsSuite) TestShareClientCustomAudience() { options := &share.ClientOptions{ FileRequestIntent: to.Ptr(share.TokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) @@ -1721,7 +1721,7 @@ func (s *ShareRecordedTestsSuite) TestShareClientAudienceNegative() { options := &share.ClientOptions{ FileRequestIntent: to.Ptr(share.TokenIntentBackup), - Audience: to.Ptr("https://badaudience.file.core.windows.net"), + Audience: "https://badaudience.file.core.windows.net", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options)