diff --git a/cmd/root/auth_test.go b/cmd/root/auth_test.go index 6e03e5687e..b6ea9dd5ae 100644 --- a/cmd/root/auth_test.go +++ b/cmd/root/auth_test.go @@ -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{}) @@ -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{}) @@ -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") @@ -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") @@ -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") diff --git a/cmd/root/bundle_test.go b/cmd/root/bundle_test.go index 4cf63a59b2..8c021fe77f 100644 --- a/cmd/root/bundle_test.go +++ b/cmd/root/bundle_test.go @@ -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")