* Update to latest azcore

Fixed logging policy name.
Fixed default telemetry params.
Removed unique request ID policy.
Consolidated pipeline creation for tests.

* update crypto dependency
This commit is contained in:
Joel Hendrix 2020-10-09 11:16:47 -07:00 коммит произвёл GitHub
Родитель d6f77dd1d0
Коммит 49c203edaa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 29 добавлений и 89 удалений

Просмотреть файл

@ -152,10 +152,9 @@ func newDefaultPipeline(o TokenCredentialOptions) azcore.Pipeline {
return azcore.NewPipeline(
o.HTTPClient,
azcore.NewTelemetryPolicy(o.Telemetry),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewTelemetryPolicy(&o.Telemetry),
azcore.NewRetryPolicy(o.Retry),
azcore.NewRequestLogPolicy(nil))
azcore.NewLogPolicy(nil))
}
// newDefaultMSIPipeline creates a pipeline using the specified pipeline options needed
@ -192,8 +191,7 @@ func newDefaultMSIPipeline(o ManagedIdentityCredentialOptions) azcore.Pipeline {
return azcore.NewPipeline(
o.HTTPClient,
azcore.NewTelemetryPolicy(o.Telemetry),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewTelemetryPolicy(&o.Telemetry),
azcore.NewRetryPolicy(&retryOpts),
azcore.NewRequestLogPolicy(nil))
azcore.NewLogPolicy(nil))
}

Просмотреть файл

@ -62,13 +62,7 @@ func TestBearerPolicy_AzureCLICredential(t *testing.T) {
if err != nil {
t.Fatalf("Did not expect an error but received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)

Просмотреть файл

@ -20,6 +20,14 @@ const (
accessTokenRespShortLived = `{"access_token": "` + tokenValue + `", "expires_in": 0}`
)
func defaultTestPipeline(srv azcore.Transport, cred azcore.Credential, scope string) azcore.Pipeline {
return azcore.NewPipeline(
srv,
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewLogPolicy(nil))
}
func TestBearerPolicy_SuccessGetToken(t *testing.T) {
srv, close := mock.NewTLSServer()
defer close()
@ -29,13 +37,7 @@ func TestBearerPolicy_SuccessGetToken(t *testing.T) {
if err != nil {
t.Fatalf("Unable to create credential. Received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)
@ -59,13 +61,7 @@ func TestBearerPolicy_CredentialFailGetToken(t *testing.T) {
if err != nil {
t.Fatalf("Unable to create credential. Received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)
@ -94,13 +90,7 @@ func TestBearerTokenPolicy_TokenExpired(t *testing.T) {
if err != nil {
t.Fatalf("Unable to create credential. Received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)
@ -125,13 +115,7 @@ func TestRetryPolicy_NonRetriable(t *testing.T) {
if err != nil {
t.Fatalf("Unable to create credential. Received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)
@ -151,13 +135,7 @@ func TestRetryPolicy_HTTPRequest(t *testing.T) {
if err != nil {
t.Fatalf("Unable to create credential. Received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)

Просмотреть файл

@ -163,13 +163,7 @@ func TestBearerPolicy_ChainedTokenCredential(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
chainedCred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, chainedCred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)

Просмотреть файл

@ -163,13 +163,7 @@ func TestBearerPolicy_ClientCertificateCredential(t *testing.T) {
if err != nil {
t.Fatalf("Did not expect an error but received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)

Просмотреть файл

@ -267,13 +267,7 @@ func TestBearerPolicy_DeviceCodeCredential(t *testing.T) {
if err != nil {
t.Fatalf("Unable to create credential. Received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{deviceCodeScopes}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, deviceCodeScopes)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)

Просмотреть файл

@ -3,9 +3,9 @@ module github.com/Azure/azure-sdk-for-go/sdk/azidentity
go 1.13
require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.11.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.12.0
github.com/Azure/azure-sdk-for-go/sdk/internal v0.3.0
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.1
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
)

Просмотреть файл

@ -1,5 +1,5 @@
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.11.0 h1:OhkQQEj0+3Kq3ufXVRggYeJ7dPECSjK1JR+wCsdLBfw=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.11.0/go.mod h1:R+GJZ0mj7yxXtTENNLTzwkwro5zWzrEiZOdpIiN7Ypc=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.12.0 h1:weap5lumRwv92BJjxQWroM1XXWpPEU/JSssoljj4EVc=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.12.0/go.mod h1:R+GJZ0mj7yxXtTENNLTzwkwro5zWzrEiZOdpIiN7Ypc=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.3.0 h1:l7b+GcynB+tNmqq4yrQG2mMzp34gNu65CC5iGTKVlOA=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.3.0/go.mod h1:Q+TCQnSr+clUU0JU+xrHZ3slYCxw17AOFdvWFpQXjAY=
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.1 h1:xfQtpQrdXC5By+/gOhE6rLRevCw17TLfjSWzkGkT58Y=
@ -8,8 +8,8 @@ github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7T
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=

Просмотреть файл

@ -273,13 +273,7 @@ func TestBearerPolicy_ManagedIdentityCredential(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{msiScope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, msiScope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)

Просмотреть файл

@ -98,13 +98,7 @@ func TestBearerPolicy_UsernamePasswordCredential(t *testing.T) {
if err != nil {
t.Fatalf("Unable to create credential. Received: %v", err)
}
pipeline := azcore.NewPipeline(
srv,
azcore.NewTelemetryPolicy(azcore.TelemetryOptions{}),
azcore.NewUniqueRequestIDPolicy(),
azcore.NewRetryPolicy(nil),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewRequestLogPolicy(nil))
pipeline := defaultTestPipeline(srv, cred, scope)
req, err := azcore.NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatal(err)