#!/usr/bin/env bash # Interactive test: accept all prompts (safety gate + hardening + signing skip) # Verifies: all settings applied, re-audit exits 0 set -o errexit set -o nounset set -o pipefail IFS=$'\n\t' SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=helpers.sh source "${SCRIPT_DIR}/helpers.sh" main() { trap cleanup EXIT printf 'Test: Full interactive apply (accept all)\n' >&2 start_session # Safety review gate — answer yes wait_for "reviewed this script" send "y" Enter # Proceed with hardening — answer yes wait_for "Proceed with hardening" send "y" Enter # Accept each setting prompt by sending "y" + Enter repeatedly. # v0.2.0 adds more prompts (pre-commit hook, gitignore, core.symlinks), # so we need enough iterations to get through all of them. local pane_content for _ in $(seq 1 50); do sleep 0.3 pane_content="$(tmux capture-pane -t "$TMUX_SESSION" -p 2>/dev/null || true)" if printf '%s' "$pane_content" | grep -qF "Signing key options"; then break fi if printf '%s' "$pane_content" | grep -qF "Hardening complete"; then break fi send "y" Enter done # Signing wizard — skip wait_for "Signing key options" 20 send "s" Enter # Wait for completion sleep 2 capture_output >/dev/null 2>&1 || true # Verify: re-run audit — signing won't pass (skipped) but git config should if git config --global --get transfer.fsckObjects | grep -q true; then pass "Full accept: git config settings applied (signing skipped as expected)" else fail "Full accept: settings not applied" exit 1 fi } main