Prepare Assignment 8 secure delivery and rollback
Add the locked pricing service, trusted-agent pipeline, Ansible deployments, security gates, recovery runbooks, prerequisite evidence, and preparation manual. Prepared with Codex assistance. Vincent explicitly authorized this local commit and will handle the push. Assessed releases and recovery exercises remain pending.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
reports=${REPORTS_DIR:-build/delivery/reports}
|
||||
mkdir -p "$reports"
|
||||
reports=$(cd "$reports" && pwd)
|
||||
test_dir=$(mktemp -d)
|
||||
trap 'rm -rf "$test_dir"' EXIT
|
||||
python3 -m venv "$test_dir/venv"
|
||||
test_python="$test_dir/venv/bin/python"
|
||||
"$test_python" -m pip install -r delivery/app/requirements.txt
|
||||
cp delivery/app/app.py delivery/app/test_app.py "$test_dir/"
|
||||
if [ "${TEST_FAILURE:-false}" = true ]; then
|
||||
cat > "$test_dir/test_gate_fixture.py" <<'PY'
|
||||
import unittest
|
||||
from app import app
|
||||
|
||||
class ControlledWrongPrice(unittest.TestCase):
|
||||
def test_deliberately_wrong_expected_price(self):
|
||||
response = app.test_client().get('/price?quantity=3')
|
||||
self.assertEqual(response.json['total'], -1, 'Controlled test must block delivery')
|
||||
PY
|
||||
fi
|
||||
cd "$test_dir"
|
||||
"$test_python" -B - "$reports" <<'PY'
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
started = datetime.now(timezone.utc).isoformat()
|
||||
result = subprocess.run([sys.executable, '-B', '-m', 'unittest', '-v'], text=True, capture_output=True)
|
||||
output = result.stdout + result.stderr
|
||||
print(output, end='')
|
||||
reports = Path(sys.argv[1])
|
||||
(reports / 'unit-tests.txt').write_text(output)
|
||||
(reports / 'unit-tests.json').write_text(json.dumps({
|
||||
'started': started, 'completed': datetime.now(timezone.utc).isoformat(),
|
||||
'exit_code': result.returncode,
|
||||
'result': 'passed' if result.returncode == 0 else 'blocked',
|
||||
}, indent=2))
|
||||
raise SystemExit(result.returncode)
|
||||
PY
|
||||
Reference in New Issue
Block a user