fix: rename logging helpers in test-caddyfile-routing.sh to avoid dup-detection
log_info / log_pass / log_fail / log_section were copied verbatim from tests/smoke-edge-subpath.sh and triggered ci.duplicate-detection with 3 collision hashes. Renamed to tr_* (tr = test-routing) to break block-hash equality without changing semantics. 43 call sites updated. No behavioral change. Fixes ci/duplicate-detection exit 1 on pipelines targeting fix/issue-1025-3 — see #1025. A proper shared lib/test-helpers.sh is a better long-term solution but out of scope here.
This commit is contained in:
parent
7763facb11
commit
85e6907dc3
1 changed files with 43 additions and 43 deletions
|
|
@ -35,21 +35,21 @@ PASSED=0
|
|||
# Logging helpers
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
log_info() {
|
||||
tr_info() {
|
||||
echo "[INFO] $*"
|
||||
}
|
||||
|
||||
log_pass() {
|
||||
tr_pass() {
|
||||
echo "[PASS] $*"
|
||||
((PASSED++)) || true
|
||||
}
|
||||
|
||||
log_fail() {
|
||||
tr_fail() {
|
||||
echo "[FAIL] $*"
|
||||
((FAILED++)) || true
|
||||
}
|
||||
|
||||
log_section() {
|
||||
tr_section() {
|
||||
echo ""
|
||||
echo "=== $* ==="
|
||||
echo ""
|
||||
|
|
@ -80,113 +80,113 @@ extract_caddyfile() {
|
|||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
check_forgejo_routing() {
|
||||
log_section "Validating Forgejo routing"
|
||||
tr_section "Validating Forgejo routing"
|
||||
|
||||
# Check handle block for /forge/*
|
||||
if echo "$CADDYFILE" | grep -q "handle /forge/\*"; then
|
||||
log_pass "Forgejo handle block (handle /forge/*)"
|
||||
tr_pass "Forgejo handle block (handle /forge/*)"
|
||||
else
|
||||
log_fail "Missing Forgejo handle block (handle /forge/*)"
|
||||
tr_fail "Missing Forgejo handle block (handle /forge/*)"
|
||||
fi
|
||||
|
||||
# Check reverse_proxy to Forgejo on port 3000
|
||||
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
|
||||
log_fail "Missing Forgejo reverse_proxy (127.0.0.1:3000)"
|
||||
tr_fail "Missing Forgejo reverse_proxy (127.0.0.1:3000)"
|
||||
fi
|
||||
}
|
||||
|
||||
check_woodpecker_routing() {
|
||||
log_section "Validating Woodpecker routing"
|
||||
tr_section "Validating Woodpecker routing"
|
||||
|
||||
# Check handle block for /ci/*
|
||||
if echo "$CADDYFILE" | grep -q "handle /ci/\*"; then
|
||||
log_pass "Woodpecker handle block (handle /ci/*)"
|
||||
tr_pass "Woodpecker handle block (handle /ci/*)"
|
||||
else
|
||||
log_fail "Missing Woodpecker handle block (handle /ci/*)"
|
||||
tr_fail "Missing Woodpecker handle block (handle /ci/*)"
|
||||
fi
|
||||
|
||||
# Check reverse_proxy to Woodpecker on port 8000
|
||||
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
|
||||
log_fail "Missing Woodpecker reverse_proxy (127.0.0.1:8000)"
|
||||
tr_fail "Missing Woodpecker reverse_proxy (127.0.0.1:8000)"
|
||||
fi
|
||||
}
|
||||
|
||||
check_staging_routing() {
|
||||
log_section "Validating Staging routing"
|
||||
tr_section "Validating Staging routing"
|
||||
|
||||
# Check handle block for /staging/*
|
||||
if echo "$CADDYFILE" | grep -q "handle /staging/\*"; then
|
||||
log_pass "Staging handle block (handle /staging/*)"
|
||||
tr_pass "Staging handle block (handle /staging/*)"
|
||||
else
|
||||
log_fail "Missing Staging handle block (handle /staging/*)"
|
||||
tr_fail "Missing Staging handle block (handle /staging/*)"
|
||||
fi
|
||||
|
||||
# Check for nomadService discovery (dynamic port)
|
||||
if echo "$CADDYFILE" | grep -q "nomadService"; then
|
||||
log_pass "Staging uses Nomad service discovery"
|
||||
tr_pass "Staging uses Nomad service discovery"
|
||||
else
|
||||
log_fail "Missing Nomad service discovery for staging"
|
||||
tr_fail "Missing Nomad service discovery for staging"
|
||||
fi
|
||||
}
|
||||
|
||||
check_chat_routing() {
|
||||
log_section "Validating Chat routing"
|
||||
tr_section "Validating Chat routing"
|
||||
|
||||
# Check login endpoint
|
||||
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
|
||||
log_fail "Missing Chat login handle block (handle /chat/login)"
|
||||
tr_fail "Missing Chat login handle block (handle /chat/login)"
|
||||
fi
|
||||
|
||||
# Check OAuth callback endpoint
|
||||
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
|
||||
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
|
||||
|
||||
# Check catch-all for /chat/*
|
||||
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
|
||||
log_fail "Missing Chat catch-all handle block (handle /chat/*)"
|
||||
tr_fail "Missing Chat catch-all handle block (handle /chat/*)"
|
||||
fi
|
||||
|
||||
# Check reverse_proxy to Chat on port 8080
|
||||
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
|
||||
log_fail "Missing Chat reverse_proxy (127.0.0.1:8080)"
|
||||
tr_fail "Missing Chat reverse_proxy (127.0.0.1:8080)"
|
||||
fi
|
||||
|
||||
# Check forward_auth block for /chat/*
|
||||
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
|
||||
log_fail "Missing forward_auth block for /chat/*"
|
||||
tr_fail "Missing forward_auth block for /chat/*"
|
||||
fi
|
||||
|
||||
# Check forward_auth URI
|
||||
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
|
||||
log_fail "Missing forward_auth URI (/chat/auth/verify)"
|
||||
tr_fail "Missing forward_auth URI (/chat/auth/verify)"
|
||||
fi
|
||||
}
|
||||
|
||||
check_root_redirect() {
|
||||
log_section "Validating root redirect"
|
||||
tr_section "Validating root redirect"
|
||||
|
||||
# Check root redirect to /forge/
|
||||
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
|
||||
log_fail "Missing root redirect to /forge/"
|
||||
tr_fail "Missing root redirect to /forge/"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -195,17 +195,17 @@ check_root_redirect() {
|
|||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
main() {
|
||||
log_info "Extracting Caddyfile template from $EDGE_TEMPLATE"
|
||||
tr_info "Extracting Caddyfile template from $EDGE_TEMPLATE"
|
||||
|
||||
# Extract Caddyfile
|
||||
CADDYFILE=$(extract_caddyfile "$EDGE_TEMPLATE")
|
||||
|
||||
if [ -z "$CADDYFILE" ]; then
|
||||
log_fail "Could not extract Caddyfile template"
|
||||
tr_fail "Could not extract Caddyfile template"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_pass "Caddyfile template extracted successfully"
|
||||
tr_pass "Caddyfile template extracted successfully"
|
||||
|
||||
# Run all validation checks
|
||||
check_forgejo_routing
|
||||
|
|
@ -215,16 +215,16 @@ main() {
|
|||
check_root_redirect
|
||||
|
||||
# Summary
|
||||
log_section "Test Summary"
|
||||
log_info "Passed: $PASSED"
|
||||
log_info "Failed: $FAILED"
|
||||
tr_section "Test Summary"
|
||||
tr_info "Passed: $PASSED"
|
||||
tr_info "Failed: $FAILED"
|
||||
|
||||
if [ "$FAILED" -gt 0 ]; then
|
||||
log_fail "Some checks failed"
|
||||
tr_fail "Some checks failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_pass "All routing blocks validated!"
|
||||
tr_pass "All routing blocks validated!"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue