-
Notifications
You must be signed in to change notification settings - Fork 50
Return auth error when auth type is set #1223
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dd7ec28
Surface errors on specified auth type
renaudhartert-db 879125e
Clean-up
renaudhartert-db 0be50b0
Changelogs
renaudhartert-db 44bb109
Fix test
renaudhartert-db 3546674
Simplify
renaudhartert-db 2491051
Update tests
renaudhartert-db 7b19846
Small simplification
renaudhartert-db 5c8e893
Fix test
renaudhartert-db 47aa5e5
Add comment
renaudhartert-db 2441754
Address comments
renaudhartert-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,49 @@ | ||
package config_test | ||
package config | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/databricks/databricks-sdk-go" | ||
"github.com/databricks/databricks-sdk-go/config" | ||
"github.com/databricks/databricks-sdk-go/internal/env" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestErrCannotConfigureAuth(t *testing.T) { | ||
env.CleanupEnvironment(t) | ||
w := databricks.Must(databricks.NewWorkspaceClient()) | ||
_, err := w.CurrentUser.Me(context.Background()) | ||
assert.True(t, errors.Is(err, config.ErrCannotConfigureAuth)) | ||
func TestDefaultCredentials_Configure(t *testing.T) { | ||
testCases := []struct { | ||
desc string | ||
authType string | ||
wantErr string | ||
}{ | ||
{ | ||
desc: "unknown auth type", | ||
authType: "unknown-auth-type-1337", | ||
wantErr: "auth type \"unknown-auth-type-1337\" not found", | ||
}, | ||
{ | ||
desc: "not valid auth", | ||
authType: "", | ||
wantErr: "cannot configure default credentials", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
ctx := context.Background() | ||
cfg := &Config{ | ||
AuthType: tc.authType, | ||
resolved: true, // avoid calling EnsureResolved | ||
} | ||
|
||
dc := DefaultCredentials{} | ||
got, gotErr := dc.Configure(ctx, cfg) | ||
|
||
if got != nil { | ||
t.Errorf("DefaultCredentials.Configure: got %v, want nil", got) | ||
} | ||
if gotErr == nil { | ||
t.Errorf("DefaultCredentials.Configure: got error %v, want non-nil", gotErr) | ||
} | ||
if !strings.Contains(gotErr.Error(), tc.wantErr) { | ||
t.Errorf("DefaultCredentials.Configure: got error %v, want error containing %q", gotErr, tc.wantErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.