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
6 changes: 3 additions & 3 deletions sdk/storage/azfile/directory/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/azfile/file/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/azfile/internal/base/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -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://<account>.file.core.windows.net.
Audience *string
Audience string

pipelineOptions *runtime.PipelineOptions
}
Expand Down Expand Up @@ -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"
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azfile/service/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/azfile/share/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down