refactor: route WebDAV through storage backend
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"chfs-ng/internal/auth"
|
||||
"chfs-ng/internal/storage"
|
||||
"github.com/emersion/go-webdav"
|
||||
)
|
||||
|
||||
@@ -35,3 +36,22 @@ func TestWebDAVAuthFSCheckTree(t *testing.T) {
|
||||
t.Fatalf("public file should be deletable: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebDAVStorageFSCopyAndMove(t *testing.T) {
|
||||
root1 := t.TempDir()
|
||||
root2 := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(root1, "a.txt"), []byte("one"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := storage.NewMulti([]string{root1, root2})
|
||||
fs := &webdavStorageFS{store: m}
|
||||
if _, err := fs.Copy(context.Background(), "/"+m.Names[0]+"/a.txt", "/"+m.Names[0]+"/b.txt", &webdav.CopyOptions{}); err != nil {
|
||||
t.Fatalf("copy: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(root1, "b.txt")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := fs.Move(context.Background(), "/"+m.Names[0]+"/b.txt", "/"+m.Names[1]+"/b.txt", &webdav.MoveOptions{}); err == nil {
|
||||
t.Fatal("expected cross-root move rejection")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user