package deploy import ( "path/filepath" "runtime" "strings" "testing" ) func TestSanitizeDesktopFilename(t *testing.T) { if got := sanitizeDesktopFilename(`..\..\etc\passwd`); got != "etc/passwd" && got != `etc\passwd` { // Join uses OS separator; at minimum no .. if strings.Contains(got, "..") { t.Fatalf("traversal leaked: %q", got) } } if got := sanitizeDesktopFilename("report.pdf"); got != "report.pdf" { t.Fatalf("got %q", got) } } func TestResolveRemotePathDesktopPrefix(t *testing.T) { p, err := ResolveRemotePath("@desktop/notes.txt") if err != nil { t.Fatal(err) } if !strings.HasSuffix(p, "notes.txt") { t.Fatalf("path %q should end with notes.txt", p) } if !strings.Contains(strings.ToLower(p), "desktop") && runtime.GOOS != "windows" { // Linux may use XDG path without "Desktop" in rare setups — allow if under home home, _ := filepath.Abs(".") _ = home } } func TestUserDesktopDir(t *testing.T) { dir, err := UserDesktopDir() if err != nil { t.Fatal(err) } if dir == "" { t.Fatal("empty desktop") } }