fix(monitor): preserve literal daemon script arguments

This commit is contained in:
2026-10-30 10:58:28 -03:00
parent d96cbae382
commit 26ef4ba6d6
4 changed files with 23 additions and 20 deletions
+15 -6
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env bats
@test "persistence invokes renamed scripts with spaces and XML text literally" {
check_daemon_path() {
local installer="$1" action="$2" label="$3"
local entrypoint
for entrypoint in unleash unleash-standalone.sh; do
local folder="$BATS_TEST_TMPDIR/$entrypoint/Tool Folder & <profile> \"quoted\""
@@ -21,19 +22,27 @@
[ "$#" -eq 2 ] && [ "$1" = -p ] && [ "$2" = "$expected" ] || return 97
command mkdir "$@"
}
install_persist_launchdaemon "$2"
' "$script" "$definitions" "$target"
"$3" "$2"
' "$script" "$definitions" "$target" "$installer"
[ "$status" -eq 0 ]
run python3 - "$target/Library/LaunchDaemons/com.unleash.heal.plist" "$script" <<'PY'
run python3 - "$target/Library/LaunchDaemons/$label.plist" "$script" "$action" <<'PY'
import plistlib,subprocess,sys
with open(sys.argv[1],'rb') as source:
data=plistlib.load(source)
expected=['/bin/bash',sys.argv[2],'heal']
expected=['/bin/bash',sys.argv[2],sys.argv[3]]
assert data['ProgramArguments']==expected, data['ProgramArguments']
result=subprocess.run(expected,capture_output=True,text=True,timeout=5)
assert result.returncode==0, result.stderr
assert result.stdout=='ACTION=heal\n', result.stdout
assert result.stdout=='ACTION='+sys.argv[3]+'\n', result.stdout
PY
[ "$status" -eq 0 ]
done
}
@test "persistence invokes renamed scripts with spaces and XML text literally" {
check_daemon_path install_persist_launchdaemon heal com.unleash.heal
}
@test "monitor invokes renamed scripts with spaces and XML text literally" {
check_daemon_path install_monitor_launchdaemon monitor com.unleash.monitor
}