test: Edge-Case-Dateien + Tests (leer/gross/verschluesselt/Sonderzeichen)

/testdata/edge/: empty.txt, leer.bin (0 Byte), Name mit Umlauten+Leerzeichen+
Klammern, Unicode/Emoji/RTL-Inhalt, Datei ohne Endung, passwortgeschuetztes
PDF (pikepdf) + ZIP, riesig.dat (26 MB > MAX_BIN_SIZE). TestFileEdgeCases prueft
graceful Handling (kein Crash, 'Datei zu gross', PDF-Lesefehler sauber gemeldet).
gen_edge.py + upload_ocis.sh erweitert. 76 Tests gruen.
This commit is contained in:
Stefan Lohmaier
2026-06-19 08:05:25 +02:00
parent 1b50e1ef6e
commit 85f5e26384
4 changed files with 84 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import os, zipfile, subprocess, pikepdf
D="/tmp/mcptest-files-edge"; os.makedirs(D,exist_ok=True)
def p(f): return os.path.join(D,f)
# 1. leere Dateien
open(p("empty.txt"),"w").close()
open(p("leer.bin"),"wb").close()
# 2. Umlaute + Leerzeichen + Klammern im Namen
open(p("Ärger Übersicht (Größe).txt"),"w").write("Datei mit Umlauten und Leerzeichen im Namen.\n")
# 3. Inhalt mit Sonderzeichen/Emoji/RTL
open(p("unicode.txt"),"w").write("Emoji 😀🎉, RTL مرحبا, Tab\tNull-ish, Zeilen\n\n\n")
# 4. keine Extension
open(p("README_NOEXT"),"w").write("Datei ohne Dateiendung.\n")
# 5. passwortgeschuetztes PDF
pikepdf.open("/tmp/mcptest-files/document.pdf").save(p("geschuetzt.pdf"), encryption=pikepdf.Encryption(user="geheim",owner="geheim"))
# 6. passwortgeschuetztes ZIP
subprocess.run(["zip","-q","-j","-P","geheim",p("geheim.zip"),"/tmp/mcptest-files/notes.txt"],check=True)
# 7. uebergrosse Datei (26 MB > MAX_BIN_SIZE 25 MB)
with open(p("riesig.dat"),"wb") as f: f.seek(26_000_000-1); f.write(b"\0")
print("Edge-Cases:")
for f in sorted(os.listdir(D)): print(f" {os.path.getsize(p(f)):>9} {f}")
+10
View File
@@ -9,3 +9,13 @@ curl -s -o /dev/null -u "$AUTH" -X MKCOL "$BASE/testdata/" || true
for d in images audio video documents text archives; do curl -s -o /dev/null -u "$AUTH" -X MKCOL "$BASE/testdata/$d/" || true; done
for f in /tmp/mcptest-files/*; do n=$(basename "$f"); curl -s -o /dev/null -u "$AUTH" -T "$f" "$BASE/testdata/$(sub "$n")/$n"; done
echo "Upload fertig."
# Edge-Cases (/tmp/mcptest-files-edge -> /testdata/edge/, URL-encoded)
if [ -d /tmp/mcptest-files-edge ]; then
curl -s -o /dev/null -u "$AUTH" -X MKCOL "$BASE/testdata/edge/" || true
python3 - "$OCIS_PW" <<'PYEOF'
import os,sys,subprocess,urllib.parse
pw=sys.argv[1]; B="http://127.0.0.1:9200/remote.php/dav/files/mcptest/testdata/edge"
for f in sorted(os.listdir("/tmp/mcptest-files-edge")):
subprocess.run(["curl","-s","-o","/dev/null","-u",f"mcptest:{pw}","-T",f"/tmp/mcptest-files-edge/{f}",f"{B}/{urllib.parse.quote(f)}"])
PYEOF
fi