#!/usr/bin/env bats # Seam: Caddyfile validity. # Each host must have a Caddyfile. Site blocks must reference services by the # hostname convention (*.dankserver.local / *.dankclaw.local) and must proxy to # reachable upstreams. When caddy(1) exists locally we run `caddy validate`; # otherwise we do structural checks. load helpers @test "a Caddyfile exists for dankserver and dankclaw" { [ -f "$REPO_ROOT/dankserver/Caddyfile" ] [ -f "$REPO_ROOT/dankclaw/Caddyfile" ] } @test "Caddyfiles use the .local hostname convention" { grep -qE '\.dankserver\.local' "$REPO_ROOT/dankserver/Caddyfile" grep -qE '\.dankclaw\.local' "$REPO_ROOT/dankclaw/Caddyfile" } @test "Caddyfiles have balanced braces" { for f in "$REPO_ROOT/dankserver/Caddyfile" "$REPO_ROOT/dankclaw/Caddyfile"; do local open close open=$(grep -o '{' "$f" | wc -l) close=$(grep -o '}' "$f" | wc -l) [ "$open" -eq "$close" ] || { echo "$f: unbalanced braces ($open vs $close)"; return 1; } done } @test "caddy validate passes when caddy is available" { if command -v caddy >/dev/null 2>&1; then caddy validate --config "$REPO_ROOT/dankserver/Caddyfile" --adapter caddyfile caddy validate --config "$REPO_ROOT/dankclaw/Caddyfile" --adapter caddyfile else skip "caddy binary not installed locally" fi } @test "homepage basic auth exists in the Caddyfiles" { grep -qiE 'basicauth|basic_auth' "$REPO_ROOT/dankserver/Caddyfile" grep -qiE 'basicauth|basic_auth' "$REPO_ROOT/dankclaw/Caddyfile" }