feat: add FTP and SFTP upload support
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package ftp
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateRemoteRelativePath(t *testing.T) {
|
||||
valid, err := validateRemoteRelativePath("snapgo/2026/07/image.png")
|
||||
if err != nil {
|
||||
t.Fatalf("valid path rejected: %v", err)
|
||||
}
|
||||
if valid != "snapgo/2026/07/image.png" {
|
||||
t.Fatalf("unexpected normalized path %q", valid)
|
||||
}
|
||||
|
||||
invalid := []string{
|
||||
"",
|
||||
"/absolute/image.png",
|
||||
"~/image.png",
|
||||
"../image.png",
|
||||
"snapgo/../../image.png",
|
||||
"snapgo\\image.png",
|
||||
"snapgo/image.png\nnext",
|
||||
}
|
||||
for _, value := range invalid {
|
||||
if _, err := validateRemoteRelativePath(value); err == nil {
|
||||
t.Errorf("expected %q to be rejected", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProbeRemotePathRejectsTraversalPrefix(t *testing.T) {
|
||||
if _, err := probeRemotePath("../../outside"); err == nil {
|
||||
t.Fatal("expected traversal prefix to fail")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user