Files
Oxicloud/tests/common/wipe-storage.sh
T
Edouard Vanbelle 595273277b test(e2e): webdav + nextcloud full e2e test coverage
add a full coverage of Webdav and Nextcloud
    purpose: prepare move to Drives and ensure no regression at all

    test scenarios are in docs/plan/BASELINE_TESTS_NC_WEBDAV.md

    current existing bugs identified via these tests:

      ┌──────────┬─────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
      │   Bug    │ Surface │                                            Pin location                                            │
      ├──────────┼─────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
      │ G4/G5/K5 │ NC      │ AlreadyExists → 500 instead of 412 (handle_move + trashbin restore)                                │
      ├──────────┼─────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
      │ G9       │ NC      │ Folder DELETE not row-recursive — orphan descendants stay live                                     │
      ├──────────┼─────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
      │ M5/M7    │ Native  │ resolve_path_for_user mismatch — PUT writes, GET reads via lenient lookup, MOVE/DELETE can't find  │
      │          │         │ via strict                                                                                         │
      ├──────────┼─────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
      │ M8       │ Native  │ COPY discards destination filename — collides with source                                          │
      ├──────────┼─────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
      │ N2       │ Native  │ LOCK creates the token, mutators don't check it — class-2 advertisement is aspirational            │
      └──────────┴─────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘
2026-06-13 19:01:40 +02:00

48 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Shared helper: wipe a test-storage directory.
#
# Source this file (don't execute it):
#
# source "$COMMON/wipe-storage.sh"
# wipe_storage "$OXICLOUD_STORAGE_PATH"
#
# The path must end in `tests/<name>/storage` (lowercase alphanumeric
# `<name>`). Anything else is rejected — defends against a typo'd or
# unexpanded env var feeding the wrong path to `rm -rf`. Examples that
# pass:
#
# /home/dev/oxicloud/tests/api/storage
# /home/dev/oxicloud/tests/webdav/storage
# /home/dev/oxicloud/tests/e2e/storage
#
# Examples that the sanity check rejects (each would refuse the wipe):
#
# / — no tests/<x>/storage suffix
# $HOME — same
# tests/api — missing /storage
# /tests/storage — missing the <name> segment
#
# Postgres state is wiped by `spawn-db.sh` (`docker compose down -v`);
# this helper is the filesystem equivalent.
wipe_storage() {
local path="$1"
if [[ -z "$path" ]]; then
echo "[wipe_storage] ERROR: missing path arg" >&2
return 1
fi
# Sanity check: must end in tests/<name>/storage where <name> is
# lowercase alphanumeric. Stops `rm -rf` from ever running against
# an unexpected expansion of a callerʼs path.
if [[ ! "$path" =~ /tests/[a-z0-9]+/storage$ ]]; then
echo "[wipe_storage] ERROR: '$path' does not match .../tests/<name>/storage — refusing to wipe" >&2
return 1
fi
echo "[wipe_storage] Wipe $path to ensure clean startup"
rm -rf "$path"
mkdir -p "$path"
}