Repository: Azure/azure-sdk-for-go
Pull request #17576 (2022-04-13 19:58:56)

Rename LoginEndpoint to ActiveDirectoryAuthorityHost
Suggested by @schaabs, seems reasonable to me. "LoginEndpoint" suggests the value could be the URL for token requests when actually we want the base URL. "ActiveDirectoryAuthorityHost" clarifies that we want only the host of an Active Directory (not necessarily _Azure_ Active Directory) instance; "Authority" jives with the environment variable we also read this value from, `AZURE_AUTHORITY_HOST`.


Patch:
diff --git a/sdk/azcore/CHANGELOG.md b/sdk/azcore/CHANGELOG.md
index 5d46dbb297..51865de07b 100644
--- a/sdk/azcore/CHANGELOG.md
+++ b/sdk/azcore/CHANGELOG.md
@@ -1,10 +1,11 @@
 # Release History
 
-## 0.23.2 (Unreleased)
+## 0.24.0 (Unreleased)
 
 ### Features Added
 
 ### Breaking Changes
+* Renamed `cloud.Configuration.LoginEndpoint` to `.ActiveDirectoryAuthorityHost`
 
 ### Bugs Fixed
 
diff --git a/sdk/azcore/cloud/cloud.go b/sdk/azcore/cloud/cloud.go
index cdbec21b27..232792ca4c 100644
--- a/sdk/azcore/cloud/cloud.go
+++ b/sdk/azcore/cloud/cloud.go
@@ -9,15 +9,15 @@ package cloud
 var (
 	// AzureChina contains configuration for Azure China.
 	AzureChina = Configuration{
-		LoginEndpoint: "https://login.chinacloudapi.cn/", Services: map[ServiceName]ServiceConfiguration{},
+		ActiveDirectoryAuthorityHost: "https://login.chinacloudapi.cn/", Services: map[ServiceName]ServiceConfiguration{},
 	}
 	// AzureGovernment contains configuration for Azure Government.
 	AzureGovernment = Configuration{
-		LoginEndpoint: "https://login.microsoftonline.us/", Services: map[ServiceName]ServiceConfiguration{},
+		ActiveDirectoryAuthorityHost: "https://login.microsoftonline.us/", Services: map[ServiceName]ServiceConfiguration{},
 	}
 	// AzurePublicCloud contains configuration for Azure Public Cloud.
 	AzurePublicCloud = Configuration{
-		LoginEndpoint: "https://login.microsoftonline.com/", Services: map[ServiceName]ServiceConfiguration{},
+		ActiveDirectoryAuthorityHost: "https://login.microsoftonline.com/", Services: map[ServiceName]ServiceConfiguration{},
 	}
 )
 
@@ -37,8 +37,8 @@ type ServiceConfiguration struct {
 
 // Configuration configures a cloud.
 type Configuration struct {
-	// LoginEndpoint is the base URL of the cloud's Azure Active Directory.
-	LoginEndpoint string
+	// ActiveDirectoryAuthorityHost is the base URL of the cloud's Azure Active Directory.
+	ActiveDirectoryAuthorityHost string
 	// Services contains configuration for the cloud's services.
 	Services map[ServiceName]ServiceConfiguration
 }
diff --git a/sdk/azcore/cloud/doc.go b/sdk/azcore/cloud/doc.go
index 11f3ef9826..9c43600f32 100644
--- a/sdk/azcore/cloud/doc.go
+++ b/sdk/azcore/cloud/doc.go
@@ -30,7 +30,7 @@ Applications deployed to a private cloud such as Azure Stack create a Configurat
 appropriate values:
 
 	c = cloud.Configuration{
-		LoginEndpoint: "https://...",
+		ActiveDirectoryAuthorityHost: "https://...",
 		Services: map[cloud.ServiceName]cloud.ServiceConfiguration{
 			cloud.ResourceManager: {
 				Audience: "...",
diff --git a/sdk/azcore/internal/shared/constants.go b/sdk/azcore/internal/shared/constants.go
index 2b13c78349..e994e9f8a2 100644
--- a/sdk/azcore/internal/shared/constants.go
+++ b/sdk/azcore/internal/shared/constants.go
@@ -30,5 +30,5 @@ const (
 	Module = "azcore"
 
 	// Version is the semantic version (see http://semver.org) of this module.
-	Version = "v0.23.2"
+	Version = "v0.24.0"
 )
diff --git a/sdk/azidentity/azidentity.go b/sdk/azidentity/azidentity.go
index d7915f8051..341601bdd9 100644
--- a/sdk/azidentity/azidentity.go
+++ b/sdk/azidentity/azidentity.go
@@ -33,16 +33,16 @@ const (
 )
 
 // setAuthorityHost initializes the authority host for credentials. Precedence is:
-// 1. cloud.Configuration.LoginEndpoint value set by user
+// 1. cloud.Configuration.ActiveDirectoryAuthorityHost value set by user
 // 2. value of AZURE_AUTHORITY_HOST
 // 3. default: Azure Public Cloud
 func setAuthorityHost(cc cloud.Configuration) (string, error) {
-	host := cc.LoginEndpoint
+	host := cc.ActiveDirectoryAuthorityHost
 	if host == "" {
 		if len(cc.Services) > 0 {
-			return "", errors.New("missing LoginEndpoint for specified cloud")
+			return "", errors.New("missing ActiveDirectoryAuthorityHost for specified cloud")
 		}
-		host = cloud.AzurePublicCloud.LoginEndpoint
+		host = cloud.AzurePublicCloud.ActiveDirectoryAuthorityHost
 		if envAuthorityHost := os.Getenv(azureAuthorityHost); envAuthorityHost != "" {
 			host = envAuthorityHost
 		}
diff --git a/sdk/azidentity/go.mod b/sdk/azidentity/go.mod
index 6cb9905b7c..0a4e0f691e 100644
--- a/sdk/azidentity/go.mod
+++ b/sdk/azidentity/go.mod
@@ -2,6 +2,8 @@ module github.com/Azure/azure-sdk-for-go/sdk/azidentity
 
 go 1.18
 
+replace github.com/Azure/azure-sdk-for-go/sdk/azcore => ../azcore
+
 require (
 	github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0
 	github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1
diff --git a/sdk/azidentity/go.sum b/sdk/azidentity/go.sum
index 6932c57d58..d1886ec525 100644
--- a/sdk/azidentity/go.sum
+++ b/sdk/azidentity/go.sum
@@ -1,5 +1,3 @@
-github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 h1:D7l5jspkc4kwBYRWoZE4DQnu6LVpLwDsMZjBKS4wZLQ=
-github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0/go.mod h1:w5pDIZuawUmY3Bj4tVx3Xb8KS96ToB0j315w9rqpAg0=
 github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo=
 github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I=
 github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c=


Test patch:
diff --git a/sdk/azcore/arm/runtime/policy_register_rp_test.go b/sdk/azcore/arm/runtime/policy_register_rp_test.go
index 1ec4526261..43b47802d1 100644
--- a/sdk/azcore/arm/runtime/policy_register_rp_test.go
+++ b/sdk/azcore/arm/runtime/policy_register_rp_test.go
@@ -389,7 +389,7 @@ func TestRPRegistrationPolicyAudience(t *testing.T) {
 
 	audience := "audience"
 	conf := cloud.Configuration{
-		LoginEndpoint: srv.URL(),
+		ActiveDirectoryAuthorityHost: srv.URL(),
 		Services: map[cloud.ServiceName]cloud.ServiceConfiguration{
 			cloud.ResourceManager: {Audience: audience, Endpoint: srv.URL()},
 		},
diff --git a/sdk/azidentity/azidentity_test.go b/sdk/azidentity/azidentity_test.go
index 327e89f4e1..e936ba15ad 100644
--- a/sdk/azidentity/azidentity_test.go
+++ b/sdk/azidentity/azidentity_test.go
@@ -162,7 +162,7 @@ func Test_WellKnownHosts(t *testing.T) {
 			t.Fatal(err)
 		}
 		if !strings.HasPrefix(host, "https://login.") {
-			t.Fatal("unexpected LoginEndpoint: " + host)
+			t.Fatal("unexpected ActiveDirectoryAuthorityHost: " + host)
 		}
 	}
 }
@@ -180,7 +180,7 @@ func Test_SetEnvAuthorityHost(t *testing.T) {
 
 func Test_CustomAuthorityHost(t *testing.T) {
 	setEnvironmentVariables(t, map[string]string{azureAuthorityHost: testHost + "/not"})
-	authorityHost, err := setAuthorityHost(cloud.Configuration{LoginEndpoint: testHost})
+	authorityHost, err := setAuthorityHost(cloud.Configuration{ActiveDirectoryAuthorityHost: testHost})
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -196,7 +196,7 @@ func Test_DefaultAuthorityHost(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	if authorityHost != cloud.AzurePublicCloud.LoginEndpoint {
+	if authorityHost != cloud.AzurePublicCloud.ActiveDirectoryAuthorityHost {
 		t.Fatal("unexpected default host: " + authorityHost)
 	}
 }
@@ -231,7 +231,7 @@ func Test_GetTokenRequiresScopes(t *testing.T) {
 
 func Test_NonHTTPSAuthorityHost(t *testing.T) {
 	setEnvironmentVariables(t, map[string]string{azureAuthorityHost: ""})
-	authorityHost, err := setAuthorityHost(cloud.Configuration{LoginEndpoint: "http://localhost"})
+	authorityHost, err := setAuthorityHost(cloud.Configuration{ActiveDirectoryAuthorityHost: "http://localhost"})
 	if err == nil {
 		t.Fatal("Expected an error but did not receive one.")
 	}
diff --git a/sdk/azidentity/client_certificate_credential_test.go b/sdk/azidentity/client_certificate_credential_test.go
index f9d0d082ba..3b0b3ed680 100644
--- a/sdk/azidentity/client_certificate_credential_test.go
+++ b/sdk/azidentity/client_certificate_credential_test.go
@@ -161,7 +161,7 @@ func TestClientCertificateCredential_NoPrivateKey(t *testing.T) {
 	defer close()
 	srv.AppendResponse(mock.WithBody([]byte(accessTokenRespSuccess)))
 	options := ClientCertificateCredentialOptions{}
-	options.Cloud.LoginEndpoint = srv.URL()
+	options.Cloud.ActiveDirectoryAuthorityHost = srv.URL()
 	options.Transport = srv
 	var key crypto.PrivateKey
 	_, err := NewClientCertificateCredential(fakeTenantID, fakeClientID, test.certs, key, &options)
diff --git a/sdk/internal/perf/recording_test.go b/sdk/internal/perf/recording_test.go
index ec4aca857f..26c317d1ef 100644
--- a/sdk/internal/perf/recording_test.go
+++ b/sdk/internal/perf/recording_test.go
@@ -5,6 +5,7 @@ package perf
 
 import (
 	"net/http"
+	"regexp"
 	"testing"
 
 	"github.com/stretchr/testify/require"
@@ -22,7 +23,9 @@ func TestRecordingHTTPClient_Do(t *testing.T) {
 
 	resp, err := client.Do(req)
 	require.NoError(t, err)
-	require.Contains(t, resp.Request.URL.String(), "https://www.bing.com")
+	matched, err := regexp.MatchString(`https://www\d*\.bing\.com`, resp.Request.URL.String())
+	require.NoError(t, err)
+	require.True(t, matched)
 
 	proxyTransportsSuite[t.Name()].SetMode("record")
 	req, err = http.NewRequest("POST", "https://www.bing.com", nil)