From ae6cf24f776e5d281d039641dc6b90bc0c3742bb Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 20 Jul 2021 17:49:24 -0400 Subject: [PATCH 1/4] renaming to New... --- sdk/azcore/policy_anonymous_credential.go | 2 +- sdk/azcore/policy_anonymous_credential_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/azcore/policy_anonymous_credential.go b/sdk/azcore/policy_anonymous_credential.go index 90f407bd24ca..fd1fd8314516 100644 --- a/sdk/azcore/policy_anonymous_credential.go +++ b/sdk/azcore/policy_anonymous_credential.go @@ -15,6 +15,6 @@ func anonCredPolicyFunc(req *Request) (*Response, error) { // AnonymousCredential is for use with HTTP(S) requests that read public resource // or for use with Shared Access Signatures (SAS). -func AnonymousCredential() Credential { +func NewAnonymousCredential() Credential { return credentialFunc(anonCredAuthPolicyFunc) } diff --git a/sdk/azcore/policy_anonymous_credential_test.go b/sdk/azcore/policy_anonymous_credential_test.go index c2d1882ae47b..39b32d00d77d 100644 --- a/sdk/azcore/policy_anonymous_credential_test.go +++ b/sdk/azcore/policy_anonymous_credential_test.go @@ -18,7 +18,7 @@ func TestAnonymousCredential(t *testing.T) { srv, close := mock.NewServer() defer close() srv.SetResponse(mock.WithStatusCode(http.StatusOK)) - pl := NewPipeline(srv, AnonymousCredential().AuthenticationPolicy(AuthenticationPolicyOptions{})) + pl := NewPipeline(srv, NewAnonymousCredential().AuthenticationPolicy(AuthenticationPolicyOptions{})) req, err := NewRequest(context.Background(), http.MethodGet, srv.URL()) if err != nil { t.Fatalf("unexpected error: %v", err) From e5c6517b2867e432c244d6885dc5c8807ed05b05 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 21 Jul 2021 10:41:13 -0400 Subject: [PATCH 2/4] fixing lint --- sdk/azcore/request_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/azcore/request_test.go b/sdk/azcore/request_test.go index 5c5d8004a42e..f4fc75acdcc4 100644 --- a/sdk/azcore/request_test.go +++ b/sdk/azcore/request_test.go @@ -471,12 +471,15 @@ func TestRequestSetBodyContentLengthHeader(t *testing.T) { if err != nil { t.Fatal(err) } - buff := make([]byte, 768, 768) + buff := make([]byte, 768) const buffLen = 768 for i := 0; i < buffLen; i++ { buff[i] = 1 } - req.SetBody(NopCloser(bytes.NewReader(buff)), "application/octet-stream") + err = req.SetBody(NopCloser(bytes.NewReader(buff)), "application/octet-stream") + if err != nil { + t.Fatal(err) + } if req.Header.Get(headerContentLength) != strconv.FormatInt(buffLen, 10) { t.Fatalf("expected content-length %d, got %s", buffLen, req.Header.Get(headerContentLength)) } From 7efdec4071bb232accbd9f70d66a9431c5d2650c Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 21 Jul 2021 10:41:44 -0400 Subject: [PATCH 3/4] catalinas comments --- sdk/azcore/policy_anonymous_credential.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/azcore/policy_anonymous_credential.go b/sdk/azcore/policy_anonymous_credential.go index fd1fd8314516..1de43bb3e120 100644 --- a/sdk/azcore/policy_anonymous_credential.go +++ b/sdk/azcore/policy_anonymous_credential.go @@ -13,7 +13,7 @@ func anonCredPolicyFunc(req *Request) (*Response, error) { return req.Next() } -// AnonymousCredential is for use with HTTP(S) requests that read public resource +// NewAnonymousCredential is for use with HTTP(S) requests that read public resource // or for use with Shared Access Signatures (SAS). func NewAnonymousCredential() Credential { return credentialFunc(anonCredAuthPolicyFunc) From a75b9a4c7a6fca18ba959704e50c2f33cad2d841 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 21 Jul 2021 11:21:45 -0400 Subject: [PATCH 4/4] fixing a bad merge --- sdk/azcore/credential.go | 10 +++++----- sdk/azcore/policy_anonymous_credential.go | 2 +- sdk/azcore/policy_anonymous_credential_test.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/azcore/credential.go b/sdk/azcore/credential.go index ba760e6f8b25..12c904bb4555 100644 --- a/sdk/azcore/credential.go +++ b/sdk/azcore/credential.go @@ -10,8 +10,8 @@ import ( "time" ) -// AuthenticationPolicyOptions contains various options used to create a credential policy. -type AuthenticationPolicyOptions struct { +// AuthenticationOptions contains various options used to create a credential policy. +type AuthenticationOptions struct { // Options contains the TokenRequestOptions that includes a scopes field which contains // the list of OAuth2 authentication scopes used when requesting a token. // This field is ignored for other forms of authentication (e.g. shared key). @@ -21,15 +21,15 @@ type AuthenticationPolicyOptions struct { // Credential represents any credential type. type Credential interface { // AuthenticationPolicy returns a policy that requests the credential and applies it to the HTTP request. - AuthenticationPolicy(options AuthenticationPolicyOptions) Policy + AuthenticationPolicy(options AuthenticationOptions) Policy } // credentialFunc is a type that implements the Credential interface. // Use this type when implementing a stateless credential as a first-class function. -type credentialFunc func(options AuthenticationPolicyOptions) Policy +type credentialFunc func(options AuthenticationOptions) Policy // AuthenticationPolicy implements the Credential interface on credentialFunc. -func (cf credentialFunc) AuthenticationPolicy(options AuthenticationPolicyOptions) Policy { +func (cf credentialFunc) AuthenticationPolicy(options AuthenticationOptions) Policy { return cf(options) } diff --git a/sdk/azcore/policy_anonymous_credential.go b/sdk/azcore/policy_anonymous_credential.go index 1de43bb3e120..5c53c3cc0320 100644 --- a/sdk/azcore/policy_anonymous_credential.go +++ b/sdk/azcore/policy_anonymous_credential.go @@ -5,7 +5,7 @@ package azcore -func anonCredAuthPolicyFunc(AuthenticationPolicyOptions) Policy { +func anonCredAuthPolicyFunc(AuthenticationOptions) Policy { return PolicyFunc(anonCredPolicyFunc) } diff --git a/sdk/azcore/policy_anonymous_credential_test.go b/sdk/azcore/policy_anonymous_credential_test.go index 39b32d00d77d..b584391e201b 100644 --- a/sdk/azcore/policy_anonymous_credential_test.go +++ b/sdk/azcore/policy_anonymous_credential_test.go @@ -18,7 +18,7 @@ func TestAnonymousCredential(t *testing.T) { srv, close := mock.NewServer() defer close() srv.SetResponse(mock.WithStatusCode(http.StatusOK)) - pl := NewPipeline(srv, NewAnonymousCredential().AuthenticationPolicy(AuthenticationPolicyOptions{})) + pl := NewPipeline(srv, NewAnonymousCredential().AuthenticationPolicy(AuthenticationOptions{})) req, err := NewRequest(context.Background(), http.MethodGet, srv.URL()) if err != nil { t.Fatalf("unexpected error: %v", err)