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
2 changes: 1 addition & 1 deletion api/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func defaultProfilePath() string {
// a user lookup (which can be very slow on large AD environments)
home, err := os.UserHomeDir()
if err == nil && home != "" {
return home
return filepath.Join(home, profileDir)
}

home = os.TempDir()
Expand Down
14 changes: 14 additions & 0 deletions api/profile/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package profile_test
import (
"os"
"path/filepath"
"runtime"
"testing"

"github.com/gravitational/trace"
Expand Down Expand Up @@ -102,3 +103,16 @@ func TestAppPath(t *testing.T) {
expected := filepath.Join(dir, "keys", "proxy", "testuser-app", "example.com", "banana-x509.pem")
require.Equal(t, expected, p.AppCertPath("banana"))
}

func TestProfilePath(t *testing.T) {
switch runtime.GOOS {
case "darwin", "linux":
default:
t.Skip("this test only runs on Unix")
}
dir := t.TempDir()
t.Setenv("HOME", dir)

require.Equal(t, "/foo/bar", profile.FullProfilePath("/foo/bar"))
require.Equal(t, filepath.Join(dir, ".tsh"), profile.FullProfilePath(""))
}