1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 16:45:07 +00:00

Harden test mode against auth and uninstall side effects

This commit is contained in:
Tw93
2026-03-15 12:19:50 +08:00
parent 7a0b4cf07e
commit 30c1a95731
4 changed files with 101 additions and 34 deletions

View File

@@ -108,6 +108,11 @@ request_sudo_access() {
return 0
fi
# Tests must never trigger real password or Touch ID prompts.
if [[ "${MOLE_TEST_MODE:-0}" == "1" || "${MOLE_TEST_NO_AUTH:-0}" == "1" ]]; then
return 1
fi
# Detect if running in TTY environment
local tty_path="/dev/tty"
local is_gui_mode=false
@@ -299,6 +304,11 @@ ensure_sudo_session() {
return 0
fi
if [[ "${MOLE_TEST_MODE:-0}" == "1" || "${MOLE_TEST_NO_AUTH:-0}" == "1" ]]; then
MOLE_SUDO_ESTABLISHED="false"
return 1
fi
# Stop old keepalive if exists
if [[ -n "$MOLE_SUDO_KEEPALIVE_PID" ]]; then
_stop_sudo_keepalive "$MOLE_SUDO_KEEPALIVE_PID"