Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Renamings for AuthPolicies #15103

Merged
merged 2 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions sdk/azcore/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ 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).
Options TokenRequestOptions
TokenRequest TokenRequestOptions
}

// 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
NewAuthenticationPolicy(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) NewAuthenticationPolicy(options AuthenticationOptions) Policy {
return cf(options)
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/azcore/policy_anonymous_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package azcore

func anonCredAuthPolicyFunc(AuthenticationPolicyOptions) Policy {
func anonCredAuthPolicyFunc(AuthenticationOptions) Policy {
return PolicyFunc(anonCredPolicyFunc)
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/azcore/policy_anonymous_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, AnonymousCredential().NewAuthenticationPolicy(AuthenticationOptions{}))
req, err := NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatalf("unexpected error: %v", err)
Expand Down