Files
Pulse/internal/securityutil/storagepath_test.go
2026-03-29 13:35:32 +01:00

31 lines
628 B
Go

package securityutil
import "testing"
func TestJoinStorageLeaf(t *testing.T) {
path, err := JoinStorageLeaf("/tmp/pulse", "session.json")
if err != nil {
t.Fatalf("JoinStorageLeaf() error = %v", err)
}
if path != "/tmp/pulse/session.json" {
t.Fatalf("JoinStorageLeaf() = %q", path)
}
}
func TestJoinStorageLeafRejectsPathSeparators(t *testing.T) {
tests := []string{
"../session.json",
"nested/session.json",
`nested\session.json`,
".",
"..",
"",
}
for _, leaf := range tests {
if _, err := JoinStorageLeaf("/tmp/pulse", leaf); err == nil {
t.Fatalf("expected %q to be rejected", leaf)
}
}
}