Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Dev workspace
[dev]
host = https://dev.cloud.databricks.com
token = dev-token

; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
5 changes: 5 additions & 0 deletions acceptance/cmd/auth/logout/default-profile/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions acceptance/cmd/auth/logout/default-profile/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

=== Initial config
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
host = https://default.cloud.databricks.com
token = default-token

; Dev workspace
[dev]
host = https://dev.cloud.databricks.com
token = dev-token

=== Delete the DEFAULT profile
>>> [CLI] auth logout --profile DEFAULT --force --delete
Successfully logged out of and deleted profile "DEFAULT".

=== Backup file should exist
OK: Backup file exists

=== Config after logout — empty DEFAULT with comment should remain at top
; Dev workspace
[dev]
host = https://dev.cloud.databricks.com
token = dev-token

; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says that it should remain at the top, but it was moved to the bottom.

27 changes: 27 additions & 0 deletions acceptance/cmd/auth/logout/default-profile/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
sethome "./home"

cat > "./home/.databrickscfg" <<'EOF'
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
host = https://default.cloud.databricks.com
token = default-token

; Dev workspace
[dev]
host = https://dev.cloud.databricks.com
token = dev-token
EOF

title "Initial config\n"
cat "./home/.databrickscfg"

title "Delete the DEFAULT profile"
trace $CLI auth logout --profile DEFAULT --force --delete

title "Backup file should exist\n"
assert_backup_exists

title "Config after logout — empty DEFAULT with comment should remain at top\n"
cat "./home/.databrickscfg"

cp "./home/.databrickscfg" "./out.databrickscfg"
1 change: 1 addition & 0 deletions acceptance/cmd/auth/logout/default-profile/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions acceptance/cmd/auth/logout/error-cases/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions acceptance/cmd/auth/logout/error-cases/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

=== Logout of non-existent profileError: profile "nonexistent" not found. Available profiles: dev

Exit code: 1

=== Logout without --profile in non-interactive modeError: the command is being run in a non-interactive environment, please specify a profile to log out of using --profile

Exit code: 1
16 changes: 16 additions & 0 deletions acceptance/cmd/auth/logout/error-cases/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sethome "./home"

cat > "./home/.databrickscfg" <<'EOF'
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]

[dev]
host = https://dev.cloud.databricks.com
token = dev-token
EOF

title "Logout of non-existent profile"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use \n on title to break error to newline for both cases.

errcode $CLI auth logout --profile nonexistent --force

title "Logout without --profile in non-interactive mode"
errcode $CLI auth logout --force
1 change: 1 addition & 0 deletions acceptance/cmd/auth/logout/error-cases/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
5 changes: 5 additions & 0 deletions acceptance/cmd/auth/logout/last-non-default/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions acceptance/cmd/auth/logout/last-non-default/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

=== Initial config
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]

; The only non-default profile
[only-profile]
host = https://only.cloud.databricks.com
token = only-token

=== Delete the only non-default profile
>>> [CLI] auth logout --profile only-profile --force --delete
Successfully logged out of and deleted profile "only-profile".

=== Backup file should exist
OK: Backup file exists

=== Config after logout — DEFAULT section with comment should remain
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
25 changes: 25 additions & 0 deletions acceptance/cmd/auth/logout/last-non-default/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
sethome "./home"

cat > "./home/.databrickscfg" <<'EOF'
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]

; The only non-default profile
[only-profile]
host = https://only.cloud.databricks.com
token = only-token
EOF

title "Initial config\n"
cat "./home/.databrickscfg"

title "Delete the only non-default profile"
trace $CLI auth logout --profile only-profile --force --delete

title "Backup file should exist\n"
assert_backup_exists

title "Config after logout — DEFAULT section with comment should remain\n"
cat "./home/.databrickscfg"

cp "./home/.databrickscfg" "./out.databrickscfg"
1 change: 1 addition & 0 deletions acceptance/cmd/auth/logout/last-non-default/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
host = https://default.cloud.databricks.com

; Second workspace — beta
[beta]
host = https://beta.cloud.databricks.com
token = beta-token
5 changes: 5 additions & 0 deletions acceptance/cmd/auth/logout/ordering-preserved/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions acceptance/cmd/auth/logout/ordering-preserved/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

=== Initial config
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
host = https://default.cloud.databricks.com

; First workspace — alpha
[alpha]
host = https://alpha.cloud.databricks.com
token = alpha-token
cluster_id = alpha-cluster

; Second workspace — beta
[beta]
host = https://beta.cloud.databricks.com
token = beta-token

; Third workspace — gamma
[gamma]
host = https://gamma.cloud.databricks.com
token = gamma-token
warehouse_id = gamma-warehouse

=== Delete first non-default profile (alpha)
>>> [CLI] auth logout --profile alpha --force --delete
Successfully logged out of and deleted profile "alpha".

=== Backup file should exist
OK: Backup file exists

=== Config after deleting alpha
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
host = https://default.cloud.databricks.com

; Second workspace — beta
[beta]
host = https://beta.cloud.databricks.com
token = beta-token

; Third workspace — gamma
[gamma]
host = https://gamma.cloud.databricks.com
token = gamma-token
warehouse_id = gamma-warehouse

=== Delete last profile (gamma)
>>> [CLI] auth logout --profile gamma --force --delete
Successfully logged out of and deleted profile "gamma".

=== Config after deleting gamma
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
host = https://default.cloud.databricks.com

; Second workspace — beta
[beta]
host = https://beta.cloud.databricks.com
token = beta-token
44 changes: 44 additions & 0 deletions acceptance/cmd/auth/logout/ordering-preserved/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
sethome "./home"

cat > "./home/.databrickscfg" <<'EOF'
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
[DEFAULT]
host = https://default.cloud.databricks.com

; First workspace — alpha
[alpha]
host = https://alpha.cloud.databricks.com
token = alpha-token
cluster_id = alpha-cluster

; Second workspace — beta
[beta]
host = https://beta.cloud.databricks.com
token = beta-token

; Third workspace — gamma
[gamma]
host = https://gamma.cloud.databricks.com
token = gamma-token
warehouse_id = gamma-warehouse
EOF

title "Initial config\n"
cat "./home/.databrickscfg"

title "Delete first non-default profile (alpha)"
trace $CLI auth logout --profile alpha --force --delete

title "Backup file should exist\n"
assert_backup_exists

title "Config after deleting alpha\n"
cat "./home/.databrickscfg"

title "Delete last profile (gamma)"
trace $CLI auth logout --profile gamma --force --delete

title "Config after deleting gamma\n"
cat "./home/.databrickscfg"

cp "./home/.databrickscfg" "./out.databrickscfg"
1 change: 1 addition & 0 deletions acceptance/cmd/auth/logout/ordering-preserved/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

7 changes: 7 additions & 0 deletions acceptance/cmd/auth/logout/script.prepare
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
assert_backup_exists() {
if [ -f "./home/.databrickscfg.bak" ]; then
echo "OK: Backup file exists"
else
echo "ERROR: Backup file does not exist"
fi
}
3 changes: 3 additions & 0 deletions acceptance/cmd/auth/logout/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Ignore = [
"home"
]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions acceptance/cmd/auth/logout/token-only-shared-host/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

=== Token cache before logout
{
"tokens": {
"dev": {
"access_token": "dev-cached-token",
"token_type": "Bearer"
},
"https://shared.cloud.databricks.com": {
"access_token": "shared-host-token",
"token_type": "Bearer"
},
"staging": {
"access_token": "staging-cached-token",
"token_type": "Bearer"
}
},
"version": 1
}

=== Logout dev without --delete
>>> [CLI] auth logout --profile dev --force
Successfully logged out of profile "dev". To remove the profile from the config file, use --delete.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dev profile is not a u2m profile. If nothing changed, why do we say logout was successful?

Copy link
Collaborator Author

@mihaimitrea-db mihaimitrea-db Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this cmd not be able to logout off M2M profiles?

The logout has been successful since there is no token with the key "dev" in the cache anymore. The profile should not be deleted because the --delete flag was not used right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "logout" mean? I think removing the token from the cache.

The profile here is not an m2m profile but a PAT profile (with the token inlined).

IMO, we only operate on u2m profiles to be symmetric with login.

cc @simonfaltum

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super clear on how M2M profiles work - if they don't store a token in the cache, then obviously we can't "log out" and we should display that correctly.
If we have the --delete flag it should still be possible to remove the profile after they confirm they want to ?


=== Config after logout — both profiles should still exist
[DEFAULT]

[dev]
host = https://shared.cloud.databricks.com
token = dev-token

[staging]
host = https://shared.cloud.databricks.com
token = staging-token

=== Token cache after logout — dev removed, host preserved (shared with staging)
{
"tokens": {
"https://shared.cloud.databricks.com": {
"access_token": "shared-host-token",
"expiry": "0001-01-01T00:00:00Z",
"token_type": "Bearer"
},
"staging": {
"access_token": "staging-cached-token",
"expiry": "0001-01-01T00:00:00Z",
"token_type": "Bearer"
}
},
"version": 1
}
Loading