Files
Aether/tests/install_source_trust_test.sh
T
elky 579f2c7cc1 feat(security): harden gateway boundaries and usage policies
Consolidate subscription usage policy enforcement, privacy-safe persistence, and gateway security hardening into one reviewable change.

Includes bounded HTTP and execution envelopes, header and protocol guards, DNS and relay validation, authentication and secret projection hardening, secure backup/install paths, and regression coverage.
2026-09-04 03:45:52 +08:00

37 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd -P)"
TEST_ROOT="$(mktemp -d)"
trap 'rm -rf -- "${TEST_ROOT}"' EXIT
fail_test() {
echo "FAIL: $*" >&2
exit 1
}
mkdir -p "${TEST_ROOT}/bin" "${TEST_ROOT}/frontend"
printf '#!/bin/sh\nexit 0\n' >"${TEST_ROOT}/bin/aether-gateway"
chmod +x "${TEST_ROOT}/bin/aether-gateway"
definitions="$({
awk '/^current_script_dir\(\)/ { emit=1 } emit { print } emit && /^}/ { emit=0 }' "${REPO_ROOT}/install.sh"
awk '/^local_bundle_dir\(\)/ { emit=1 } emit { print } emit && /^}/ { emit=0 }' "${REPO_ROOT}/install.sh"
})"
if printf '%s\ncd -- %q\nif local_bundle_dir; then exit 9; fi\n' \
"${definitions}" "${TEST_ROOT}" | bash; then
:
else
status=$?
[[ "${status}" -ne 9 ]] || fail_test "stdin execution trusted a bundle from the current directory"
fail_test "stdin trust regression fixture failed unexpectedly with status ${status}"
fi
# shellcheck source=../install.sh
source "${REPO_ROOT}/install.sh"
[[ "$(current_script_dir)" == "${REPO_ROOT}" ]] \
|| fail_test "a real installer file no longer resolves its adjacent bundle directory"
echo "PASS: installer source-directory trust boundary"