1 changed files with 43 additions and 43 deletions
|
|
@ -35,21 +35,21 @@ PASSED=0
|
||||||
# Logging helpers
|
# Logging helpers
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
log_info() {
|
tr_info() {
|
||||||
echo "[INFO] $*"
|
echo "[INFO] $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
log_pass() {
|
tr_pass() {
|
||||||
echo "[PASS] $*"
|
echo "[PASS] $*"
|
||||||
((PASSED++)) || true
|
((PASSED++)) || true
|
||||||
}
|
}
|
||||||
|
|
||||||
log_fail() {
|
tr_fail() {
|
||||||
echo "[FAIL] $*"
|
echo "[FAIL] $*"
|
||||||
((FAILED++)) || true
|
((FAILED++)) || true
|
||||||
}
|
}
|
||||||
|
|
||||||
log_section() {
|
tr_section() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== $* ==="
|
echo "=== $* ==="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -80,113 +80,113 @@ extract_caddyfile() {
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
check_forgejo_routing() {
|
check_forgejo_routing() {
|
||||||
log_section "Validating Forgejo routing"
|
tr_section "Validating Forgejo routing"
|
||||||
|
|
||||||
# Check handle block for /forge/*
|
# Check handle block for /forge/*
|
||||||
if echo "$CADDYFILE" | grep -q "handle /forge/\*"; then
|
if echo "$CADDYFILE" | grep -q "handle /forge/\*"; then
|
||||||
log_pass "Forgejo handle block (handle /forge/*)"
|
tr_pass "Forgejo handle block (handle /forge/*)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Forgejo handle block (handle /forge/*)"
|
tr_fail "Missing Forgejo handle block (handle /forge/*)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check reverse_proxy to Forgejo on port 3000
|
# Check reverse_proxy to Forgejo on port 3000
|
||||||
if echo "$CADDYFILE" | grep -q "reverse_proxy 127.0.0.1:3000"; then
|
if echo "$CADDYFILE" | grep -q "reverse_proxy 127.0.0.1:3000"; then
|
||||||
log_pass "Forgejo reverse_proxy configured (127.0.0.1:3000)"
|
tr_pass "Forgejo reverse_proxy configured (127.0.0.1:3000)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Forgejo reverse_proxy (127.0.0.1:3000)"
|
tr_fail "Missing Forgejo reverse_proxy (127.0.0.1:3000)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_woodpecker_routing() {
|
check_woodpecker_routing() {
|
||||||
log_section "Validating Woodpecker routing"
|
tr_section "Validating Woodpecker routing"
|
||||||
|
|
||||||
# Check handle block for /ci/*
|
# Check handle block for /ci/*
|
||||||
if echo "$CADDYFILE" | grep -q "handle /ci/\*"; then
|
if echo "$CADDYFILE" | grep -q "handle /ci/\*"; then
|
||||||
log_pass "Woodpecker handle block (handle /ci/*)"
|
tr_pass "Woodpecker handle block (handle /ci/*)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Woodpecker handle block (handle /ci/*)"
|
tr_fail "Missing Woodpecker handle block (handle /ci/*)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check reverse_proxy to Woodpecker on port 8000
|
# Check reverse_proxy to Woodpecker on port 8000
|
||||||
if echo "$CADDYFILE" | grep -q "reverse_proxy 127.0.0.1:8000"; then
|
if echo "$CADDYFILE" | grep -q "reverse_proxy 127.0.0.1:8000"; then
|
||||||
log_pass "Woodpecker reverse_proxy configured (127.0.0.1:8000)"
|
tr_pass "Woodpecker reverse_proxy configured (127.0.0.1:8000)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Woodpecker reverse_proxy (127.0.0.1:8000)"
|
tr_fail "Missing Woodpecker reverse_proxy (127.0.0.1:8000)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_staging_routing() {
|
check_staging_routing() {
|
||||||
log_section "Validating Staging routing"
|
tr_section "Validating Staging routing"
|
||||||
|
|
||||||
# Check handle block for /staging/*
|
# Check handle block for /staging/*
|
||||||
if echo "$CADDYFILE" | grep -q "handle /staging/\*"; then
|
if echo "$CADDYFILE" | grep -q "handle /staging/\*"; then
|
||||||
log_pass "Staging handle block (handle /staging/*)"
|
tr_pass "Staging handle block (handle /staging/*)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Staging handle block (handle /staging/*)"
|
tr_fail "Missing Staging handle block (handle /staging/*)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for nomadService discovery (dynamic port)
|
# Check for nomadService discovery (dynamic port)
|
||||||
if echo "$CADDYFILE" | grep -q "nomadService"; then
|
if echo "$CADDYFILE" | grep -q "nomadService"; then
|
||||||
log_pass "Staging uses Nomad service discovery"
|
tr_pass "Staging uses Nomad service discovery"
|
||||||
else
|
else
|
||||||
log_fail "Missing Nomad service discovery for staging"
|
tr_fail "Missing Nomad service discovery for staging"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_chat_routing() {
|
check_chat_routing() {
|
||||||
log_section "Validating Chat routing"
|
tr_section "Validating Chat routing"
|
||||||
|
|
||||||
# Check login endpoint
|
# Check login endpoint
|
||||||
if echo "$CADDYFILE" | grep -q "handle /chat/login"; then
|
if echo "$CADDYFILE" | grep -q "handle /chat/login"; then
|
||||||
log_pass "Chat login handle block (handle /chat/login)"
|
tr_pass "Chat login handle block (handle /chat/login)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Chat login handle block (handle /chat/login)"
|
tr_fail "Missing Chat login handle block (handle /chat/login)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check OAuth callback endpoint
|
# Check OAuth callback endpoint
|
||||||
if echo "$CADDYFILE" | grep -q "handle /chat/oauth/callback"; then
|
if echo "$CADDYFILE" | grep -q "handle /chat/oauth/callback"; then
|
||||||
log_pass "Chat OAuth callback handle block (handle /chat/oauth/callback)"
|
tr_pass "Chat OAuth callback handle block (handle /chat/oauth/callback)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Chat OAuth callback handle block (handle /chat/oauth/callback)"
|
tr_fail "Missing Chat OAuth callback handle block (handle /chat/oauth/callback)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check catch-all for /chat/*
|
# Check catch-all for /chat/*
|
||||||
if echo "$CADDYFILE" | grep -q "handle /chat/\*"; then
|
if echo "$CADDYFILE" | grep -q "handle /chat/\*"; then
|
||||||
log_pass "Chat catch-all handle block (handle /chat/*)"
|
tr_pass "Chat catch-all handle block (handle /chat/*)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Chat catch-all handle block (handle /chat/*)"
|
tr_fail "Missing Chat catch-all handle block (handle /chat/*)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check reverse_proxy to Chat on port 8080
|
# Check reverse_proxy to Chat on port 8080
|
||||||
if echo "$CADDYFILE" | grep -q "reverse_proxy 127.0.0.1:8080"; then
|
if echo "$CADDYFILE" | grep -q "reverse_proxy 127.0.0.1:8080"; then
|
||||||
log_pass "Chat reverse_proxy configured (127.0.0.1:8080)"
|
tr_pass "Chat reverse_proxy configured (127.0.0.1:8080)"
|
||||||
else
|
else
|
||||||
log_fail "Missing Chat reverse_proxy (127.0.0.1:8080)"
|
tr_fail "Missing Chat reverse_proxy (127.0.0.1:8080)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check forward_auth block for /chat/*
|
# Check forward_auth block for /chat/*
|
||||||
if echo "$CADDYFILE" | grep -A10 "handle /chat/\*" | grep -q "forward_auth"; then
|
if echo "$CADDYFILE" | grep -A10 "handle /chat/\*" | grep -q "forward_auth"; then
|
||||||
log_pass "forward_auth block configured for /chat/*"
|
tr_pass "forward_auth block configured for /chat/*"
|
||||||
else
|
else
|
||||||
log_fail "Missing forward_auth block for /chat/*"
|
tr_fail "Missing forward_auth block for /chat/*"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check forward_auth URI
|
# Check forward_auth URI
|
||||||
if echo "$CADDYFILE" | grep -q "uri /chat/auth/verify"; then
|
if echo "$CADDYFILE" | grep -q "uri /chat/auth/verify"; then
|
||||||
log_pass "forward_auth URI configured (/chat/auth/verify)"
|
tr_pass "forward_auth URI configured (/chat/auth/verify)"
|
||||||
else
|
else
|
||||||
log_fail "Missing forward_auth URI (/chat/auth/verify)"
|
tr_fail "Missing forward_auth URI (/chat/auth/verify)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_root_redirect() {
|
check_root_redirect() {
|
||||||
log_section "Validating root redirect"
|
tr_section "Validating root redirect"
|
||||||
|
|
||||||
# Check root redirect to /forge/
|
# Check root redirect to /forge/
|
||||||
if echo "$CADDYFILE" | grep -q "redir /forge/ 302"; then
|
if echo "$CADDYFILE" | grep -q "redir /forge/ 302"; then
|
||||||
log_pass "Root redirect to /forge/ configured (302)"
|
tr_pass "Root redirect to /forge/ configured (302)"
|
||||||
else
|
else
|
||||||
log_fail "Missing root redirect to /forge/"
|
tr_fail "Missing root redirect to /forge/"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,17 +195,17 @@ check_root_redirect() {
|
||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
log_info "Extracting Caddyfile template from $EDGE_TEMPLATE"
|
tr_info "Extracting Caddyfile template from $EDGE_TEMPLATE"
|
||||||
|
|
||||||
# Extract Caddyfile
|
# Extract Caddyfile
|
||||||
CADDYFILE=$(extract_caddyfile "$EDGE_TEMPLATE")
|
CADDYFILE=$(extract_caddyfile "$EDGE_TEMPLATE")
|
||||||
|
|
||||||
if [ -z "$CADDYFILE" ]; then
|
if [ -z "$CADDYFILE" ]; then
|
||||||
log_fail "Could not extract Caddyfile template"
|
tr_fail "Could not extract Caddyfile template"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_pass "Caddyfile template extracted successfully"
|
tr_pass "Caddyfile template extracted successfully"
|
||||||
|
|
||||||
# Run all validation checks
|
# Run all validation checks
|
||||||
check_forgejo_routing
|
check_forgejo_routing
|
||||||
|
|
@ -215,16 +215,16 @@ main() {
|
||||||
check_root_redirect
|
check_root_redirect
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
log_section "Test Summary"
|
tr_section "Test Summary"
|
||||||
log_info "Passed: $PASSED"
|
tr_info "Passed: $PASSED"
|
||||||
log_info "Failed: $FAILED"
|
tr_info "Failed: $FAILED"
|
||||||
|
|
||||||
if [ "$FAILED" -gt 0 ]; then
|
if [ "$FAILED" -gt 0 ]; then
|
||||||
log_fail "Some checks failed"
|
tr_fail "Some checks failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_pass "All routing blocks validated!"
|
tr_pass "All routing blocks validated!"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue