security: harden WebDAV overwrite and multi-root routing
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewMultiKeepsDuplicateBasenames(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
first := filepath.Join(root, "same")
|
||||
second := filepath.Join(root, "other", "same")
|
||||
if err := os.MkdirAll(first, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.MkdirAll(second, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := NewMulti([]string{first, second})
|
||||
if len(m.Roots) != 2 || len(m.Names) != 2 {
|
||||
t.Fatalf("duplicate basename dropped: roots=%d names=%v", len(m.Roots), m.Names)
|
||||
}
|
||||
if m.Names[0] != "same" || m.Names[1] != "same-2" {
|
||||
t.Fatalf("unexpected virtual names: %v", m.Names)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user