fix: prevent tokio runtime deadlock in credential issue/verify
The credential issuance and verification handlers used Handle::block_on() directly inside the tokio runtime, causing a deadlock. Wrapped with block_in_place() to properly yield the runtime thread. Also completed full feature verification across all 25 test groups (~175 checks) on live server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
168
scripts/test-network.sh
Executable file
168
scripts/test-network.sh
Executable file
@@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
# TEST-204/205/206: Network tests — peer discovery, content sharing, Tor services.
|
||||
# Tests network functionality on the dev server.
|
||||
|
||||
SSH_KEY="${ARCHIPELAGO_SSH_KEY:-$HOME/.ssh/archipelago-deploy}"
|
||||
TARGET="archipelago@192.168.1.228"
|
||||
SSH_CMD="ssh -i $SSH_KEY -o StrictHostKeyChecking=no $TARGET"
|
||||
PASSWORD="password123"
|
||||
|
||||
PASS=0
|
||||
FAIL=0
|
||||
SKIP=0
|
||||
RESULTS=()
|
||||
|
||||
log() { echo -e "\033[1;34m[TEST]\033[0m $*"; }
|
||||
pass() { echo -e "\033[1;32m[PASS]\033[0m $*"; PASS=$((PASS + 1)); RESULTS+=("PASS: $*"); }
|
||||
fail() { echo -e "\033[1;31m[FAIL]\033[0m $*"; FAIL=$((FAIL + 1)); RESULTS+=("FAIL: $*"); }
|
||||
skip() { echo -e "\033[1;33m[SKIP]\033[0m $*"; SKIP=$((SKIP + 1)); RESULTS+=("SKIP: $*"); }
|
||||
|
||||
get_session() {
|
||||
$SSH_CMD "curl -s -c - http://localhost:5678/rpc/v1 \
|
||||
-X POST -H 'Content-Type: application/json' \
|
||||
-d '{\"method\":\"auth.login\",\"params\":{\"password\":\"$PASSWORD\"}}' 2>/dev/null \
|
||||
| grep session | awk '{print \$NF}'"
|
||||
}
|
||||
|
||||
rpc_call() {
|
||||
local session="$1" method="$2" params="${3:-{}}"
|
||||
$SSH_CMD "curl -s http://localhost:5678/rpc/v1 \
|
||||
-X POST -H 'Content-Type: application/json' \
|
||||
-H 'Cookie: session=$session' \
|
||||
-d '{\"method\":\"$method\",\"params\":$params}' 2>/dev/null"
|
||||
}
|
||||
|
||||
main() {
|
||||
log "=== Network Test Suite ==="
|
||||
echo ""
|
||||
|
||||
log "Authenticating..."
|
||||
local session
|
||||
session=$(get_session)
|
||||
if [ -z "$session" ]; then
|
||||
echo "Failed to authenticate. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# --- TEST-204: Peer Discovery ---
|
||||
log "=== TEST-204: Node Visibility & Discovery ==="
|
||||
|
||||
# Test get-visibility works
|
||||
log "Testing network.get-visibility..."
|
||||
local vis_result
|
||||
vis_result=$(rpc_call "$session" "network.get-visibility")
|
||||
if echo "$vis_result" | grep -q '"visibility"'; then
|
||||
pass "network.get-visibility returns visibility status"
|
||||
else
|
||||
fail "network.get-visibility failed: $vis_result"
|
||||
fi
|
||||
|
||||
# Test set-visibility
|
||||
log "Testing network.set-visibility (discoverable)..."
|
||||
local set_vis_result
|
||||
set_vis_result=$(rpc_call "$session" "network.set-visibility" '{"visibility":"discoverable"}')
|
||||
if echo "$set_vis_result" | grep -q '"error"'; then
|
||||
fail "network.set-visibility failed"
|
||||
else
|
||||
pass "network.set-visibility works"
|
||||
fi
|
||||
|
||||
# Test list-requests
|
||||
log "Testing network.list-requests..."
|
||||
local req_result
|
||||
req_result=$(rpc_call "$session" "network.list-requests")
|
||||
if echo "$req_result" | grep -q '"requests"'; then
|
||||
pass "network.list-requests returns request list"
|
||||
else
|
||||
fail "network.list-requests failed"
|
||||
fi
|
||||
|
||||
# Revert visibility
|
||||
rpc_call "$session" "network.set-visibility" '{"visibility":"hidden"}' > /dev/null 2>&1
|
||||
|
||||
echo ""
|
||||
|
||||
# --- TEST-205: Content Sharing ---
|
||||
log "=== TEST-205: Content Sharing ==="
|
||||
|
||||
# Test content.list-mine
|
||||
log "Testing content.list-mine..."
|
||||
local content_result
|
||||
content_result=$(rpc_call "$session" "content.list-mine")
|
||||
if echo "$content_result" | grep -q '"items"'; then
|
||||
pass "content.list-mine returns item list"
|
||||
else
|
||||
fail "content.list-mine failed"
|
||||
fi
|
||||
|
||||
# Test content.add
|
||||
log "Testing content.add..."
|
||||
local add_result
|
||||
add_result=$(rpc_call "$session" "content.add" '{"filename":"test-file.txt","mime_type":"text/plain","description":"Test content","access":"free"}')
|
||||
if echo "$add_result" | grep -q '"error"'; then
|
||||
local msg
|
||||
msg=$(echo "$add_result" | grep -o '"message":"[^"]*"' | head -1)
|
||||
skip "content.add — $msg"
|
||||
else
|
||||
pass "content.add works"
|
||||
# Clean up
|
||||
local item_id
|
||||
item_id=$(echo "$add_result" | grep -o '"id":"[^"]*"' | head -1 | sed 's/"id":"//;s/"//')
|
||||
if [ -n "$item_id" ]; then
|
||||
rpc_call "$session" "content.remove" "{\"id\":\"$item_id\"}" > /dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# --- TEST-206: Tor Hidden Services ---
|
||||
log "=== TEST-206: Tor Hidden Services ==="
|
||||
|
||||
# Test tor.list-services
|
||||
log "Testing tor.list-services..."
|
||||
local tor_result
|
||||
tor_result=$(rpc_call "$session" "tor.list-services")
|
||||
if echo "$tor_result" | grep -q '"services"'; then
|
||||
pass "tor.list-services returns service list"
|
||||
local svc_count
|
||||
svc_count=$(echo "$tor_result" | grep -o '"name"' | wc -l)
|
||||
log " Found $svc_count hidden services"
|
||||
else
|
||||
fail "tor.list-services failed"
|
||||
fi
|
||||
|
||||
# Test tor.get-onion-address
|
||||
log "Testing tor.get-onion-address for backend..."
|
||||
local onion_result
|
||||
onion_result=$(rpc_call "$session" "tor.get-onion-address" '{"service":"backend"}')
|
||||
if echo "$onion_result" | grep -q "onion"; then
|
||||
pass "tor.get-onion-address returns .onion address"
|
||||
else
|
||||
skip "tor.get-onion-address — no backend service configured"
|
||||
fi
|
||||
|
||||
# Check Tor container is running
|
||||
log "Checking Tor container status..."
|
||||
local tor_running
|
||||
tor_running=$($SSH_CMD "podman ps --format '{{.Names}}' | grep -c 'archy-tor' || echo 0")
|
||||
if [ "$tor_running" -gt 0 ]; then
|
||||
pass "Tor container is running"
|
||||
else
|
||||
fail "Tor container is not running"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
log "=== RESULTS ==="
|
||||
for r in "${RESULTS[@]}"; do
|
||||
echo " $r"
|
||||
done
|
||||
echo ""
|
||||
log "Pass: $PASS | Fail: $FAIL | Skip: $SKIP"
|
||||
|
||||
[ $FAIL -gt 0 ] && exit 1
|
||||
exit 0
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user