1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-12 14:01:17 +00:00

Test case update

This commit is contained in:
Tw93
2025-11-15 13:40:43 +08:00
parent cccc41990e
commit f7dff3b798
7 changed files with 32 additions and 133 deletions

View File

@@ -97,49 +97,3 @@ setup() {
fi
[ "$status" -ne 0 ]
}
@test "whitelist rejects paths with spaces" {
# Paths with spaces should be rejected by the new stricter validation
mkdir -p "$HOME/.config/mole"
echo "$HOME/.cache/invalid path" > "$WHITELIST_PATH"
# Load whitelist - path with space should be rejected
warnings=$(HOME="$HOME" bash --noprofile --norc -c "
source '$PROJECT_ROOT/bin/clean.sh'
load_whitelist_file 2>&1 | grep -c 'Invalid path format' || echo 0
")
[ "$warnings" -ge 1 ]
}
@test "whitelist rejects paths with consecutive slashes" {
mkdir -p "$HOME/.config/mole"
echo "$HOME/.cache//invalid" > "$WHITELIST_PATH"
warnings=$(HOME="$HOME" bash --noprofile --norc -c "
source '$PROJECT_ROOT/bin/clean.sh'
load_whitelist_file 2>&1 | grep -c 'Consecutive slashes' || echo 0
")
[ "$warnings" -ge 1 ]
}
@test "whitelist rejects system protected paths" {
mkdir -p "$HOME/.config/mole"
echo "/System/Library/test" > "$WHITELIST_PATH"
warnings=$(HOME="$HOME" bash --noprofile --norc -c "
source '$PROJECT_ROOT/bin/clean.sh'
load_whitelist_file 2>&1 | grep -c 'Protected system path' || echo 0
")
[ "$warnings" -ge 1 ]
}
@test "whitelist accepts valid paths with wildcards at end" {
mkdir -p "$HOME/.config/mole"
echo "$HOME/.cache/test/*" > "$WHITELIST_PATH"
# Should be accepted without warnings
HOME="$HOME" bash --noprofile --norc -c "
source '$PROJECT_ROOT/bin/clean.sh'
load_whitelist_file
" 2>&1 | grep -q "Invalid path format" && exit 1 || exit 0
}