87bb9fafae
- test_setup.sh: validates installation, package deps, directory creation - test_tor_config.sh: validates Tor hidden service configuration - test_caddy_config.sh: validates Caddy web server configuration - test_generate_bootstrap.sh: validates bootstrap archive generation - run_all.sh: runs all tests with summary All tests pass (47 total assertions across 4 test suites).
37 lines
1.5 KiB
Bash
Executable File
37 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Bootstrap server Caddy configuration tests
|
|
set -euo pipefail
|
|
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
pass() { echo " ✓ $*"; ((PASS++)) || true; }
|
|
fail() { echo " ✗ $*"; ((FAIL++)) || true; }
|
|
|
|
CADDY="/root/tri-bootstrap-server/caddy/Caddyfile.template"
|
|
|
|
# Test 1: Caddyfile.template exists
|
|
echo "=== Test: Caddyfile.template exists ==="
|
|
[ -f "$CADDY" ] && pass "Caddyfile.template exists" || fail "Caddyfile.template missing"
|
|
|
|
# Test 2: Has required Caddy settings
|
|
echo "=== Test: Caddy configuration ==="
|
|
grep -q "email" "$CADDY" && pass "Has email directive" || fail "Missing email directive"
|
|
grep -q "auto_https off" "$CADDY" && pass "Has auto_https off" || fail "Missing auto_https off"
|
|
grep -q "file_server" "$CADDY" && pass "Has file_server" || fail "Missing file_server"
|
|
grep -q "encode gzip" "$CADDY" && pass "Has gzip encoding" || fail "Missing gzip encoding"
|
|
grep -q "download true" "$CADDY" && pass "Has download directive" || fail "Missing download directive"
|
|
|
|
# Test 3: Has Cache-Control headers for bootstrap files
|
|
echo "=== Test: Cache-Control headers ==="
|
|
grep -q "Cache-Control" "$CADDY" && pass "Has Cache-Control headers" || fail "Missing Cache-Control headers"
|
|
|
|
# Test 4: Caddyfile has site block structure
|
|
echo "=== Test: Site block structure ==="
|
|
grep -qE "^\{" "$CADDY" && pass "Has global options block" || fail "Missing global options block"
|
|
grep -qE ":443|:80" "$CADDY" && pass "Has port binding" || fail "Missing port binding"
|
|
|
|
echo ""
|
|
echo "Results: $PASS passed, $FAIL failed"
|
|
[ "$FAIL" -eq 0 ]
|