fix: re-authenticate per iteration in test-all-features.sh
Session tokens get invalidated when backend restarts. Moving auth inside the iteration loop ensures each iteration gets a fresh session. Also fix grep -c arithmetic syntax error for nostr-provider check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
16b389dda1
commit
0cecc06d16
@ -77,20 +77,20 @@ echo "# Target: ${TARGET}"
|
|||||||
echo "# Iterations: ${ITERATIONS}"
|
echo "# Iterations: ${ITERATIONS}"
|
||||||
echo "# Started: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
echo "# Started: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
|
||||||
# ── Auth ──────────────────────────────────────────────────────────────────
|
|
||||||
session_header=$(get_session)
|
|
||||||
SESSION=$(echo "$session_header" | sed -n 's/.*session=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]')
|
|
||||||
CSRF=$(echo "$session_header" | sed -n 's/.*csrf_token=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]')
|
|
||||||
|
|
||||||
if [[ -z "$SESSION" ]]; then
|
|
||||||
echo "BAIL OUT! Cannot authenticate to ${TARGET}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for i in $(seq 1 "$ITERATIONS"); do
|
for i in $(seq 1 "$ITERATIONS"); do
|
||||||
echo ""
|
echo ""
|
||||||
echo "# ── Iteration ${i}/${ITERATIONS} [$(date +%H:%M:%S)] ──"
|
echo "# ── Iteration ${i}/${ITERATIONS} [$(date +%H:%M:%S)] ──"
|
||||||
|
|
||||||
|
# Re-authenticate each iteration to handle backend restarts
|
||||||
|
session_header=$(get_session)
|
||||||
|
SESSION=$(echo "$session_header" | sed -n 's/.*session=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]')
|
||||||
|
CSRF=$(echo "$session_header" | sed -n 's/.*csrf_token=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]')
|
||||||
|
|
||||||
|
if [[ -z "$SESSION" ]]; then
|
||||||
|
tap_fail "auth-${i}" "Cannot authenticate"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# ── System Health ─────────────────────────────────────────────────────
|
# ── System Health ─────────────────────────────────────────────────────
|
||||||
health=$(curl -s --max-time 5 "http://${TARGET}/health" 2>/dev/null || echo "fail")
|
health=$(curl -s --max-time 5 "http://${TARGET}/health" 2>/dev/null || echo "fail")
|
||||||
if [[ "$health" == "OK" ]]; then tap_ok "health-${i}"; else tap_fail "health-${i}" "$health"; fi
|
if [[ "$health" == "OK" ]]; then tap_ok "health-${i}"; else tap_fail "health-${i}" "$health"; fi
|
||||||
@ -153,7 +153,9 @@ for i in $(seq 1 "$ITERATIONS"); do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ── NIP-07 ────────────────────────────────────────────────────────────
|
# ── NIP-07 ────────────────────────────────────────────────────────────
|
||||||
provider=$(curl -s --connect-timeout 5 "http://${TARGET}/app/mempool/" 2>/dev/null | grep -c "nostr-provider" || echo "0")
|
provider=$(curl -s --connect-timeout 5 "http://${TARGET}/app/mempool/" 2>/dev/null | grep -c "nostr-provider" 2>/dev/null || true)
|
||||||
|
provider=$(echo "$provider" | tr -d '[:space:]')
|
||||||
|
[[ -z "$provider" ]] && provider=0
|
||||||
if [[ "$provider" -gt 0 ]]; then
|
if [[ "$provider" -gt 0 ]]; then
|
||||||
tap_ok "nip07-provider-${i}"
|
tap_ok "nip07-provider-${i}"
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user