-
Notifications
You must be signed in to change notification settings - Fork 179
auth describe: try both verification endpoints before reporting failure #5512
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
6 commits
Select commit
Hold shift + click to select a range
036d8ca
auth describe: try both verification endpoints before reporting failure
simonfaltum 5d3fa86
auth describe: treat permission-denied as proof of authentication
simonfaltum 3a11376
auth describe: drop the 403-implies-authenticated heuristic
simonfaltum a2473db
auth describe: fold verification fallback tests into a table
simonfaltum 047fba4
Merge branch 'main' into simonfaltum/describe-try-both
simonfaltum 91c0959
Merge branch 'main' into simonfaltum/describe-try-both
simonfaltum 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
3 changes: 3 additions & 0 deletions
3
acceptance/cmd/auth/describe/account-host-with-workspace-id/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
acceptance/cmd/auth/describe/account-host-with-workspace-id/output.txt
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| === Describe falls back to the account endpoint when the workspace check fails | ||
|
|
||
| >>> [CLI] auth describe --profile acct-with-ws | ||
| Host: [DATABRICKS_URL] | ||
| Account ID: acct-123 | ||
| Authenticated with: pat | ||
| ----- | ||
| Current configuration: | ||
| ✓ host: [DATABRICKS_URL] (from DATABRICKS_HOST environment variable) | ||
| ✓ account_id: acct-123 (from [TEST_TMP_DIR]/home/.databrickscfg config file) | ||
| ✓ workspace_id: [NUMID] (from [TEST_TMP_DIR]/home/.databrickscfg config file) | ||
| ✓ token: ******** (from DATABRICKS_TOKEN environment variable) | ||
| ✓ profile: acct-with-ws (from --profile flag) | ||
| ✓ databricks_cli_path: [CLI] | ||
| ✓ auth_type: pat | ||
| ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) | ||
| ✓ cloud: AWS | ||
| ✓ discovery_url: [DATABRICKS_URL]/oidc/.well-known/oauth-authorization-server |
15 changes: 15 additions & 0 deletions
15
acceptance/cmd/auth/describe/account-host-with-workspace-id/script
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| sethome "./home" | ||
|
|
||
| # Older logins wrote account console profiles with both account_id and | ||
| # workspace_id, which resolves to a workspace client even though the host only | ||
| # serves account APIs (https://github.com/databricks/cli/issues/5479). | ||
| cat > "./home/.databrickscfg" <<EOF | ||
| [acct-with-ws] | ||
| host = $DATABRICKS_HOST | ||
| token = $DATABRICKS_TOKEN | ||
| account_id = acct-123 | ||
| workspace_id = 900800700600 | ||
| EOF | ||
|
|
||
| title "Describe falls back to the account endpoint when the workspace check fails\n" | ||
| trace $CLI auth describe --profile acct-with-ws |
14 changes: 14 additions & 0 deletions
14
acceptance/cmd/auth/describe/account-host-with-workspace-id/test.toml
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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| Ignore = [ | ||
| "home" | ||
| ] | ||
|
|
||
| # Simulate an account console host: it cannot serve workspace APIs, so the | ||
| # workspace-side verification call fails even though the credentials are valid. | ||
| [[Server]] | ||
| Pattern = "GET /api/2.0/preview/scim/v2/Me" | ||
| Response.Body = 'Unable to load OAuth Config' | ||
| Response.StatusCode = 400 | ||
|
|
||
| [[Server]] | ||
| Pattern = "GET /api/2.0/accounts/acct-123/workspaces" | ||
| Response.Body = '[]' |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Could we somehow remove duplication from these tests? Maybe a table driven if it's easy to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a2473db: folded the five fallback tests into one table-driven test (TestGetAuthStatusVerificationFallback). A zero status in the test server now means "this endpoint must not be called", which absorbs the no-account-id case into the table. Note the file also shrank in the meantime: the 403-as-success commit was dropped from the PR, so the three tests for it are gone.