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

rename Options to OAuthOptions #415

Merged
merged 1 commit into from
Jul 1, 2019
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
8 changes: 4 additions & 4 deletions autorest/adal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ type MultiTenantOAuthConfig interface {
AuxiliaryTenants() []*OAuthConfig
}

// Options contains optional OAuthConfig creation arguments.
type Options struct {
// OAuthOptions contains optional OAuthConfig creation arguments.
type OAuthOptions struct {
APIVersion string
}

func (c Options) apiVersion() string {
func (c OAuthOptions) apiVersion() string {
if c.APIVersion != "" {
return fmt.Sprintf("?api-version=%s", c.APIVersion)
}
Expand All @@ -114,7 +114,7 @@ func (c Options) apiVersion() string {

// NewMultiTenantOAuthConfig creates an object that support multitenant OAuth configuration.
// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/authenticate-multi-tenant for more information.
func NewMultiTenantOAuthConfig(activeDirectoryEndpoint, primaryTenantID string, auxiliaryTenantIDs []string, options Options) (MultiTenantOAuthConfig, error) {
func NewMultiTenantOAuthConfig(activeDirectoryEndpoint, primaryTenantID string, auxiliaryTenantIDs []string, options OAuthOptions) (MultiTenantOAuthConfig, error) {
if len(auxiliaryTenantIDs) == 0 || len(auxiliaryTenantIDs) > 3 {
return nil, errors.New("must specify one to three auxiliary tenants")
}
Expand Down
6 changes: 3 additions & 3 deletions autorest/adal/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestNewOAuthConfigWithAPIVersionNotNil(t *testing.T) {
}

func TestNewMultiTenantOAuthConfig(t *testing.T) {
cfg, err := NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, TestAuxTenantIDs, Options{})
cfg, err := NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, TestAuxTenantIDs, OAuthOptions{})
if err != nil {
t.Fatalf("autorest/adal: unexpected error while creating multitenant config: %v", err)
}
Expand All @@ -115,11 +115,11 @@ func TestNewMultiTenantOAuthConfig(t *testing.T) {
}

func TestNewMultiTenantOAuthConfigFail(t *testing.T) {
_, err := NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, nil, Options{})
_, err := NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, nil, OAuthOptions{})
if err == nil {
t.Fatal("autorest/adal: expected non-nil error")
}
_, err = NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, []string{"one", "two", "three", "four"}, Options{})
_, err = NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, []string{"one", "two", "three", "four"}, OAuthOptions{})
if err == nil {
t.Fatal("autorest/adal: expected non-nil error")
}
Expand Down
2 changes: 1 addition & 1 deletion autorest/adal/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ func TestMarshalInnerToken(t *testing.T) {
}

func TestNewMultiTenantServicePrincipalToken(t *testing.T) {
cfg, err := NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, TestAuxTenantIDs, Options{})
cfg, err := NewMultiTenantOAuthConfig(TestActiveDirectoryEndpoint, TestTenantID, TestAuxTenantIDs, OAuthOptions{})
if err != nil {
t.Fatalf("autorest/adal: unexpected error while creating multitenant config: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion autorest/azure/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func (ccc ClientCredentialsConfig) ServicePrincipalToken() (*adal.ServicePrincip

// MultiTenantServicePrincipalToken creates a MultiTenantServicePrincipalToken from client credentials.
func (ccc ClientCredentialsConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error) {
oauthConfig, err := adal.NewMultiTenantOAuthConfig(ccc.AADEndpoint, ccc.TenantID, ccc.AuxTenants, adal.Options{})
oauthConfig, err := adal.NewMultiTenantOAuthConfig(ccc.AADEndpoint, ccc.TenantID, ccc.AuxTenants, adal.OAuthOptions{})
if err != nil {
return nil, err
}
Expand Down