mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 20:07:04 +01:00
Two files under the cap. test_security_hardening.sh (423) keeps its filename -- shell-tests.yml runs the suite by name -- and its five sections move into three sourced libs. They are top-level blocks, not functions, so each is wrapped and called in the original order; the counters and LIVE_SECTION stay in the entry, which sourcing shares. Verified by diffing a full run against the same suite from a detached worktree at HEAD: byte-identical output, same exit status, still 18/1/5 on this host. The one failure is pre-existing. Linting a lib alone turns a bare LIVE_SECTION=1 into SC2034, since its only reader is test_result in the entry. A live_section() setter makes the write a real reference, so no suppression was needed. The mutation-driver split was already in the tree from the previous session and did not run: the operators had moved to _session_autopsy_mutations.py but the driver still named Mutation without importing it, so mypy and pylint both reported undefined-variable. Restored the import; the script now reports all 12 tests killed. block_compulsive_opening.sh (705) is deliberately untouched and now says so in the contract. install_all copies the running script to /usr/local/bin, so an entry sourcing lib/ would resolve SCRIPT_DIR there, find nothing, and leave beeper, signal-desktop and discord unlaunchable with a failing pacman hook. Splitting it means teaching the installer to copy the libs -- a refactor, not a line-count split. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
120 lines
4.0 KiB
Bash
Executable File
120 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Security hardening tests: compulsive-opening block + screen locker.
|
|
# Sourced by test_security_hardening.sh; inherits its strict mode,
|
|
# colors, counters (PASS/FAIL/SKIP), LIVE_SECTION and test_result().
|
|
|
|
sec_tests_compulsive_block() {
|
|
# ==================================================================
|
|
# COMPULSIVE BLOCK TESTS
|
|
# ==================================================================
|
|
echo "--- COMPULSIVE OPENING BLOCK ---"
|
|
|
|
compulsive_file="$REPO_DIR/scripts/periodic_background/digital_wellbeing/block_compulsive_opening.sh"
|
|
|
|
# Test 17: Auto-close timer configuration exists
|
|
if [[ -f "$compulsive_file" ]]; then
|
|
if grep -q "AUTO_CLOSE_TIMEOUT_MINUTES" "$compulsive_file"; then
|
|
test_result "Auto-close timer configuration exists" "pass"
|
|
else
|
|
test_result "Auto-close timer configuration exists" "fail" "Variable not found"
|
|
fi
|
|
else
|
|
test_result "Auto-close timer configuration exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 18: launch_with_timer function exists
|
|
if [[ -f "$compulsive_file" ]]; then
|
|
if grep -q "launch_with_timer" "$compulsive_file"; then
|
|
test_result "launch_with_timer function exists" "pass"
|
|
else
|
|
test_result "launch_with_timer function exists" "fail" "Function not found"
|
|
fi
|
|
else
|
|
test_result "launch_with_timer function exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 19: Compulsive block wrappers installed
|
|
wrappers_ok=true
|
|
for app in beeper signal-desktop discord; do
|
|
if [[ -f "/usr/bin/$app" ]]; then
|
|
if grep -q "block-compulsive-opening" "/usr/bin/$app" 2>/dev/null; then
|
|
: # OK
|
|
else
|
|
wrappers_ok=false
|
|
fi
|
|
fi
|
|
done
|
|
if [[ "$wrappers_ok" == true ]]; then
|
|
test_result "Compulsive block wrappers installed" "pass"
|
|
else
|
|
test_result "Compulsive block wrappers installed" "fail" "Some wrappers missing or incorrect"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
sec_tests_screen_locker() {
|
|
# ==================================================================
|
|
# SCREEN LOCKER TESTS
|
|
# ==================================================================
|
|
echo "--- SCREEN LOCKER ---"
|
|
|
|
screen_locker="$HOME/testsAndMisc/python_pkg/screen_locker/screen_lock.py"
|
|
|
|
# Test 20: Screen locker exists
|
|
if [[ -f "$screen_locker" ]]; then
|
|
test_result "Screen locker script exists" "pass"
|
|
else
|
|
test_result "Screen locker script exists" "skip" "Not found at expected location"
|
|
fi
|
|
|
|
# Test 21: Running option removed
|
|
if [[ -f "$screen_locker" ]]; then
|
|
# Check that there's no "Running" button in ask_workout_type
|
|
if grep -A 20 "def ask_workout_type" "$screen_locker" | grep -q '"Running"'; then
|
|
test_result "Running workout option removed" "fail" "Still present in ask_workout_type"
|
|
else
|
|
test_result "Running workout option removed" "pass"
|
|
fi
|
|
else
|
|
test_result "Running workout option removed" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 22: Table tennis minimum sets validation
|
|
if [[ -f "$screen_locker" ]]; then
|
|
if grep -q "MIN_TABLE_TENNIS_SETS" "$screen_locker"; then
|
|
test_result "Table tennis minimum sets validation exists" "pass"
|
|
else
|
|
test_result "Table tennis minimum sets validation exists" "fail" "Constant not found"
|
|
fi
|
|
else
|
|
test_result "Table tennis minimum sets validation exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 23: Table tennis verification question
|
|
if [[ -f "$screen_locker" ]]; then
|
|
if grep -q "ask_table_tennis_verification" "$screen_locker"; then
|
|
test_result "Table tennis verification question exists" "pass"
|
|
else
|
|
test_result "Table tennis verification question exists" "fail" "Function not found"
|
|
fi
|
|
else
|
|
test_result "Table tennis verification question exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 24: 60 second submit delay for table tennis
|
|
if [[ -f "$screen_locker" ]]; then
|
|
if grep -q "TABLE_TENNIS_SUBMIT_DELAY = 60" "$screen_locker"; then
|
|
test_result "Table tennis 60-second submit delay" "pass"
|
|
else
|
|
test_result "Table tennis 60-second submit delay" "fail" "Constant not set to 60"
|
|
fi
|
|
else
|
|
test_result "Table tennis 60-second submit delay" "skip" "Script not found"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
}
|