mirror of
https://github.com/gravitational/teleport
synced 2024-10-20 01:03:40 +00:00
parent
7922af1567
commit
bfe8d77428
|
@ -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()
|
||||
|
|
|
@ -20,6 +20,7 @@ package profile_test
|
|||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/gravitational/trace"
|
||||
|
@ -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(""))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue