Files
Pulse/scripts/tests/agent_installer_test_support.py
pulse-triage[bot] f1beea2e84 Exercise credential-file handoffs through the real installer parser
Replace documentation assertions tied to the previous one-line parser with an inert exact-source parser fixture. Copied agent and PBS recipes must preserve the supplied private path and profile without putting its contents in argv or output. Keep the downstream private-reader assertion and add controls that reject dropped or rewritten paths and a missing isolation boundary. This reconciles both returned smoke-shard failures without reverting the empty-path refusal.

Contract-Neutral: test-only handoff proof preserves the existing credential, trust, profile and lifecycle contracts
Change-source: pulse-maintainer
2026-11-04 01:42:15 +00:00

35 lines
1.3 KiB
Python

"""Inert documented-command fixture using the real agent argument parser."""
from pathlib import Path
INSTALLER = Path(__file__).resolve().parents[2] / "scripts/install.sh"
def credential_path_parser_fixture():
# Keep the actual source through argument parsing, but never include the
# subsequent saved-state, credential-reader or installation operations.
prefix, boundary, _ = INSTALLER.read_text().partition(
'if [[ "$RETARGET_ONLY" == "true" && -z "$PULSE_URL" ]]; then'
)
if not boundary:
raise AssertionError("agent parser boundary missing; refusing to build fixture")
return '#!/usr/bin/env bash\nDOCS_INSTALLER_ARGS=("$@")\n' + prefix + r'''
python3 - "$TOKEN_FILE_PATH" "${DOCS_INSTALLER_ARGS[@]}" <<'PY'
import json, os, stat, sys
from pathlib import Path
parsed_path = sys.argv[1]
args = sys.argv[2:]
assert args.count('--token-file') == 1
assert parsed_path == args[args.index('--token-file') + 1], "token path changed during parsing"
path = Path(parsed_path)
assert stat.S_IMODE(path.stat().st_mode) == 0o600
assert path.read_text().strip() == os.environ['EXPECTED_TOKEN']
assert '--token' not in args
assert os.environ['EXPECTED_TOKEN'] not in ' '.join(args)
Path(os.environ['INSTALL_RECEIPT']).write_text(json.dumps(args))
PY
}
main "$@"
'''