prole/tests/test_network_scan_fix.sh
chrisfu caa2685fc2 Fix installer path portability (avoid hardcoded /Users paths)
- Rewrite stale foreign home prefixes when loading env defaults (macOS <-> Linux)

- Write /Users/chrisfu-relative values to env.sh; sanitize prole.cfg paths to use ${HOME}

- Remove remaining /Users/chrisfu defaults from helper scripts and OpenTofu kubeconfig path

- Make installer tests more reliable by forcing repo root to front of sys.path

Co-authored-by: Junie <junie@jetbrains.com>
2026-03-09 16:55:49 -07:00

91 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
echo "========================================"
echo " Network Scan Fix Verification"
echo "========================================"
echo ""
# Test 1: Scan directory creation
echo "1. Testing scan directory creation..."
python3 << 'PYTEST'
from pathlib import Path
prole_home = Path.home() / ".prole"
scan_dir = prole_home / "scan"
scan_dir.mkdir(parents=True, exist_ok=True)
if scan_dir.exists() and scan_dir.is_dir():
print(" ✓ Scan directory created")
else:
print(" ✗ Failed to create scan directory")
exit(1)
PYTEST
if [ $? -ne 0 ]; then exit 1; fi
# Test 2: Scan directory is writable
echo "2. Testing scan directory is writable..."
python3 << 'PYTEST'
from pathlib import Path
scan_dir = Path.home() / ".prole" / "scan"
test_file = scan_dir / "test.txt"
try:
test_file.write_text("test")
test_file.unlink()
print(" ✓ Scan directory is writable")
except Exception as e:
print(f" ✗ Scan directory not writable: {e}")
exit(1)
PYTEST
if [ $? -ne 0 ]; then exit 1; fi
# Test 3: prole-agent binary exists
echo "3. Testing prole-agent binary..."
if [ -x "prole-net/prole-agent" ]; then
echo " ✓ prole-agent binary exists and is executable"
else
echo " ✗ prole-agent binary missing or not executable"
exit 1
fi
# Test 4: prole-agent can run from scan directory
echo "4. Testing prole-agent runs from writable directory..."
PROLE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
mkdir -p /tmp/scan-test
cd /tmp/scan-test
"$PROLE_ROOT/prole-net/prole-agent" 2>&1 &
SCAN_PID=$!
sleep 2
if ps -p $SCAN_PID > /dev/null 2>&1; then
echo " ✓ prole-agent runs successfully"
kill $SCAN_PID 2>/dev/null
wait 2>/dev/null
else
echo " ✗ prole-agent failed to start"
exit 1
fi
cd "$PROLE_ROOT"
# Test 5: Code uses scan directory
echo "5. Testing code uses scan directory..."
if grep -q "scan_dir = prole_home / \"scan\"" install.py && \
grep -q "cwd=str(scan_dir)" install.py; then
echo " ✓ Code properly uses scan directory"
else
echo " ✗ Code not updated to use scan directory"
exit 1
fi
# Cleanup test directories
rm -rf ~/.prole/scan 2>/dev/null
echo ""
echo "========================================"
echo " ✓ All Network Scan Fix Tests Passed"
echo "========================================"
echo ""
echo "Network scan will now work correctly:"
echo " • From source: Uses writable cwd"
echo " • From package: Uses ~/.prole/scan"
echo ""
echo "Scan directory: ~/.prole/scan"
echo "Purpose: Writable working directory for prole-agent"
echo ""