diff --git a/acceptance/cmd/auth/login/custom-config-file/out.databrickscfg b/acceptance/cmd/auth/login/custom-config-file/out.databrickscfg new file mode 100644 index 0000000000..e228e10bc6 --- /dev/null +++ b/acceptance/cmd/auth/login/custom-config-file/out.databrickscfg @@ -0,0 +1,6 @@ +; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. +[DEFAULT] + +[custom-test] +host = [DATABRICKS_URL] +auth_type = databricks-cli diff --git a/acceptance/cmd/auth/login/custom-config-file/out.test.toml b/acceptance/cmd/auth/login/custom-config-file/out.test.toml new file mode 100644 index 0000000000..d560f1de04 --- /dev/null +++ b/acceptance/cmd/auth/login/custom-config-file/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] diff --git a/acceptance/cmd/auth/login/custom-config-file/output.txt b/acceptance/cmd/auth/login/custom-config-file/output.txt new file mode 100644 index 0000000000..79e67f48b2 --- /dev/null +++ b/acceptance/cmd/auth/login/custom-config-file/output.txt @@ -0,0 +1,21 @@ + +=== Initial custom config file (with old host) +[custom-test] +host = https://old-host.cloud.databricks.com +auth_type = pat +token = old-token-123 + +=== Login with new host (should override old host) +>>> [CLI] auth login --host [DATABRICKS_URL] --profile custom-test +Profile custom-test was successfully saved + +=== Default config file should NOT exist +OK: Default .databrickscfg does not exist + +=== Custom config file after login (old host should be replaced) +; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. +[DEFAULT] + +[custom-test] +host = [DATABRICKS_URL] +auth_type = databricks-cli diff --git a/acceptance/cmd/auth/login/custom-config-file/script b/acceptance/cmd/auth/login/custom-config-file/script new file mode 100644 index 0000000000..8be849974e --- /dev/null +++ b/acceptance/cmd/auth/login/custom-config-file/script @@ -0,0 +1,39 @@ +sethome "./home" + +# Use a fake browser that performs a GET on the authorization URL +# and follows the redirect back to localhost. +export BROWSER="browser.py" + +# Set custom config file location via env var +export DATABRICKS_CONFIG_FILE="./home/custom.databrickscfg" + +# Create an existing custom config file with a DIFFERENT host. +# The login command should use the host from --host argument, NOT from this file. +# If the wrong host (from the config file) were used, the OAuth flow would fail +# because the mock server only responds for $DATABRICKS_HOST. +cat > "./home/custom.databrickscfg" <>> [CLI] auth login [DATABRICKS_URL] --profile override-test +Profile override-test was successfully saved + +=== Profile after login (host should be updated) +; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. +[DEFAULT] + +[override-test] +host = [DATABRICKS_URL] +auth_type = databricks-cli diff --git a/acceptance/cmd/auth/login/host-arg-overrides-profile/script b/acceptance/cmd/auth/login/host-arg-overrides-profile/script new file mode 100644 index 0000000000..8d3cc68ae4 --- /dev/null +++ b/acceptance/cmd/auth/login/host-arg-overrides-profile/script @@ -0,0 +1,25 @@ +sethome "./home" + +# Create an existing profile with a DIFFERENT host +cat > "./home/.databrickscfg" <>> [CLI] auth login --profile existing-profile +Profile existing-profile was successfully saved + +=== Profile after login +; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. +[DEFAULT] + +[existing-profile] +host = [DATABRICKS_URL] +auth_type = databricks-cli diff --git a/acceptance/cmd/auth/login/host-from-profile/script b/acceptance/cmd/auth/login/host-from-profile/script new file mode 100644 index 0000000000..9f44e4a705 --- /dev/null +++ b/acceptance/cmd/auth/login/host-from-profile/script @@ -0,0 +1,24 @@ +sethome "./home" + +# Create an existing profile with a host +cat > "./home/.databrickscfg" <