Skip to content

Commit 66871b3

Browse files
Add acceptance tests for auth logout
Cover four scenarios: profile ordering and comments are preserved after deletion, deleting the last non-default profile leaves an empty DEFAULT section, deleting the DEFAULT profile itself clears its keys and restores the default comment, and error paths for non-existent profiles and missing --profile in non-interactive mode.
1 parent 44753d5 commit 66871b3

21 files changed

Lines changed: 277 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
; Dev workspace
2+
[dev]
3+
host = https://dev.cloud.databricks.com
4+
token = dev-token
5+
6+
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
7+
[DEFAULT]

acceptance/cmd/auth/logout/default-profile/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
=== Initial config
3+
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
4+
[DEFAULT]
5+
host = https://default.cloud.databricks.com
6+
token = default-token
7+
8+
; Dev workspace
9+
[dev]
10+
host = https://dev.cloud.databricks.com
11+
token = dev-token
12+
13+
=== Delete the DEFAULT profile
14+
>>> [CLI] auth logout --profile DEFAULT --force
15+
Successfully logged out of profile "DEFAULT".
16+
17+
=== Backup file should exist
18+
OK: Backup file exists
19+
20+
=== Config after logout — empty DEFAULT with comment should remain at top
21+
; Dev workspace
22+
[dev]
23+
host = https://dev.cloud.databricks.com
24+
token = dev-token
25+
26+
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
27+
[DEFAULT]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
sethome "./home"
2+
3+
cat > "./home/.databrickscfg" <<'EOF'
4+
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
5+
[DEFAULT]
6+
host = https://default.cloud.databricks.com
7+
token = default-token
8+
9+
; Dev workspace
10+
[dev]
11+
host = https://dev.cloud.databricks.com
12+
token = dev-token
13+
EOF
14+
15+
title "Initial config\n"
16+
cat "./home/.databrickscfg"
17+
18+
title "Delete the DEFAULT profile"
19+
trace $CLI auth logout --profile DEFAULT --force
20+
21+
title "Backup file should exist\n"
22+
assert_backup_exists
23+
24+
title "Config after logout — empty DEFAULT with comment should remain at top\n"
25+
cat "./home/.databrickscfg"
26+
27+
cp "./home/.databrickscfg" "./out.databrickscfg"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

acceptance/cmd/auth/logout/error-cases/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
=== Logout of non-existent profileError: profile "nonexistent" not found. Available profiles: [dev]
3+
4+
Exit code: 1
5+
6+
=== 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
7+
8+
Exit code: 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
sethome "./home"
2+
3+
cat > "./home/.databrickscfg" <<'EOF'
4+
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
5+
[DEFAULT]
6+
7+
[dev]
8+
host = https://dev.cloud.databricks.com
9+
token = dev-token
10+
EOF
11+
12+
title "Logout of non-existent profile"
13+
errcode $CLI auth logout --profile nonexistent --force
14+
15+
title "Logout without --profile in non-interactive mode"
16+
errcode $CLI auth logout --force
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified.
2+
[DEFAULT]

0 commit comments

Comments
 (0)