Skip to content
Merged
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
12 changes: 10 additions & 2 deletions cmd/root/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func TestAccountClientOrPrompt(t *testing.T) {
0o755)
require.NoError(t, err)
t.Setenv("DATABRICKS_CONFIG_FILE", configFile)
t.Setenv("PATH", "/nothing")
// Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution.
t.Setenv("PATH", "")

t.Run("Prompt if nothing is specified", func(t *testing.T) {
expectPrompts(t, accountPromptFn, &config.Config{})
Expand Down Expand Up @@ -157,7 +158,8 @@ func TestWorkspaceClientOrPrompt(t *testing.T) {
0o755)
require.NoError(t, err)
t.Setenv("DATABRICKS_CONFIG_FILE", configFile)
t.Setenv("PATH", "/nothing")
// Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution.
t.Setenv("PATH", "")

t.Run("Prompt if nothing is specified", func(t *testing.T) {
expectPrompts(t, workspacePromptFn, &config.Config{})
Expand Down Expand Up @@ -248,6 +250,8 @@ func TestMustAccountClientErrorsWithNoDatabricksCfg(t *testing.T) {

func TestMustAnyClientCanCreateWorkspaceClient(t *testing.T) {
testutil.CleanupEnvironment(t)
// Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution.
t.Setenv("PATH", "")

dir := t.TempDir()
configFile := filepath.Join(dir, ".databrickscfg")
Expand Down Expand Up @@ -276,6 +280,8 @@ func TestMustAnyClientCanCreateWorkspaceClient(t *testing.T) {

func TestMustAnyClientCanCreateAccountClient(t *testing.T) {
testutil.CleanupEnvironment(t)
// Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution.
t.Setenv("PATH", "")

dir := t.TempDir()
configFile := filepath.Join(dir, ".databrickscfg")
Expand Down Expand Up @@ -305,6 +311,8 @@ func TestMustAnyClientCanCreateAccountClient(t *testing.T) {

func TestMustAnyClientWithEmptyDatabricksCfg(t *testing.T) {
testutil.CleanupEnvironment(t)
// Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution.
t.Setenv("PATH", "")

dir := t.TempDir()
configFile := filepath.Join(dir, ".databrickscfg")
Expand Down
8 changes: 8 additions & 0 deletions cmd/root/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ workspace:

func TestBundleConfigureDefault(t *testing.T) {
testutil.CleanupEnvironment(t)
// Restrict PATH to system directories to prevent the SDK from invoking
// external tools (e.g. az) during auth resolution.
// Bundle loading requires a shell so PATH cannot be fully cleared.
if runtime.GOOS == "windows" {
t.Setenv("PATH", `C:\Windows\System32`)
} else {
t.Setenv("PATH", "/usr/bin:/bin")
}

cmd := emptyCommand(t)
diags := setupWithHost(t, cmd, "https://x.com")
Expand Down
Loading