chore: usuń nieużywane skrypty i przełącz na Python

Usunięte nieużywane skrypty:
- functional_test.sh
- verify_extension_code.sh
- verify_extension_working.sh
- test_verify.sh (zastąpiony przez test_verify.py)

Tylko 2 skrypty są faktycznie używane przez Dockerfile:
- test_start_extension.sh (runtime stage)
- test_verify.py (verify stage)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jacek Wielemborek 2025-10-25 20:46:56 +02:00
parent c5cc840aef
commit ce0f345a2b
5 changed files with 3 additions and 419 deletions

View File

@ -61,8 +61,8 @@ CMD ["/app/test_start_extension.sh"]
FROM runtime AS verify FROM runtime AS verify
# Copy verification script # Copy verification script
COPY scripts/test_verify.sh /app/test_verify.sh COPY scripts/test_verify.py /app/test_verify.py
RUN chmod +x /app/test_verify.sh RUN chmod +x /app/test_verify.py
# Run verification and exit with proper exit code # Run verification and exit with proper exit code
CMD ["/app/test_verify.sh"] CMD ["python3", "/app/test_verify.py"]

View File

@ -1,134 +0,0 @@
#!/bin/bash
#
# functional_test.sh - DEFINITIVE test of extension operation
#
# This script performs an ACTUAL functional test:
# 1. Starts Firefox with extension (via web-ext run)
# 2. Loads test page containing third-party requests
# 3. Checks if extension intercepted requests
#
# This is the only reliable way to verify in Docker/headless environment,
# because console.error from background page doesn't reach web-ext stdout.
#
set -e
echo "========================================"
echo " FUNCTIONAL TEST: Rentgen Extension"
echo "========================================"
echo ""
# Start Xvfb
echo "[1/5] Starting Xvfb..."
Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 &
XVFB_PID=$!
export DISPLAY=:99
sleep 2
echo "✓ Xvfb PID: $XVFB_PID"
# Start Firefox with extension
echo ""
echo "[2/5] Starting Firefox with extension..."
timeout 60s npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log &
WEBEXT_PID=$!
echo "✓ web-ext PID: $WEBEXT_PID"
# Wait for extension to install
echo ""
echo "[3/5] Waiting for extension installation..."
INSTALLED=false
for i in {1..30}; do
if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then
echo "✓ Extension installed!"
INSTALLED=true
break
fi
sleep 1
done
if [ "$INSTALLED" = false ]; then
echo "✗ Extension failed to install within 30s"
exit 1
fi
# Get debugger port
PORT=$(grep -oP "start-debugger-server \K[0-9]+" /tmp/web-ext.log | head -1)
echo "✓ Firefox debugger port: $PORT"
# Give extension time to initialize
sleep 3
# Check for JavaScript errors
echo ""
echo "[4/5] Checking for JavaScript errors..."
if grep -i "JavaScript error.*background.js\|SyntaxError\|ReferenceError" /tmp/web-ext.log 2>/dev/null | grep -v "BackupService\|RSLoader"; then
echo "✗✗✗ FOUND ERRORS IN EXTENSION CODE!"
exit 1
else
echo "✓ No syntax errors in background.js"
fi
# Functional test: Load a test page with third-party resources
echo ""
echo "[5/5] FUNCTIONAL TEST: Loading test page..."
echo "Attempting to load example.com (which has third-party requests)..."
# Use firefox-bin to load a page in the running Firefox instance
# This will trigger webRequest listeners if extension is working
timeout 10s bash -c "
# Try to use Firefox remote debugging to navigate
# Simple test: just verify Firefox is responsive
if ps -p $WEBEXT_PID > /dev/null; then
echo '✓ Firefox process still running'
else
echo '✗ Firefox process terminated'
exit 1
fi
" || true
# Final verification: Check logs for any evidence of extension activity
echo ""
echo "Checking for extension activity in logs..."
# Look for webRequest related logs or extension activity
if grep -E "webRequest|rentgen|Watching.*for changes" /tmp/web-ext.log 2>/dev/null | tail -5; then
echo ""
echo "✓ Extension is active (watching for changes)"
else
echo "⚠ Did not find extension activity logs"
fi
# Final verdict
echo ""
echo "========================================"
echo " TEST RESULTS"
echo "========================================"
echo "✓ Extension installed correctly"
echo "✓ Firefox running with extension"
echo "✓ No JavaScript errors in background.js"
echo "✓ Extension monitoring changes (active)"
echo ""
echo "⚠ LIMITATION: console.error from background"
echo " page doesn't appear in web-ext logs"
echo " (this is a normal Firefox limitation)"
echo ""
echo "ASSUMPTION: Extension works if:"
echo " - Installed without errors"
echo " - No JS errors in logs"
echo " - Firefox remains running"
echo "========================================"
# Keep Firefox running for a moment
sleep 5
echo ""
echo "Test completed. Firefox will run for 60s..."
echo "Press Ctrl+C to stop."
# Wait for web-ext to finish or timeout
wait $WEBEXT_PID || true
# Cleanup
kill $XVFB_PID 2>/dev/null || true
exit 0

View File

@ -1,119 +0,0 @@
#!/bin/bash
#
# test_verify.sh - Verifies extension and exits (doesn't wait forever)
#
# This script is a test version of test_start_extension.sh that:
# - Starts Firefox with the extension
# - Verifies extension loaded without errors
# - EXITS after verification (instead of waiting forever)
#
# Used for automated tests in CI/Docker.
#
set -e
echo "Starting Xvfb on display :99..."
Xvfb :99 -screen 0 1024x768x24 >/dev/null 2>&1 &
XVFB_PID=$!
sleep 2
echo "Xvfb started with PID: $XVFB_PID"
echo "Starting web-ext run with verbose logging..."
echo "========================================"
# Run web-ext with verbose logging and capture output
npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log &
WEBEXT_PID=$!
# Wait for extension installation confirmation
echo "Waiting for extension to install..."
INSTALLED=false
for i in {1..30}; do
if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then
echo "========================================"
echo "✓ SUCCESS: Extension installed!"
echo "✓ Firefox is running in headless mode"
echo "✓ Extension: rentgen@internet-czas-dzialac.pl"
INSTALLED=true
break
fi
sleep 1
done
if [ "$INSTALLED" = false ]; then
echo "✗ Extension failed to install within 30s"
kill $WEBEXT_PID 2>/dev/null || true
kill $XVFB_PID 2>/dev/null || true
exit 1
fi
# Give extension time to initialize
sleep 3
# CRITICAL: Check for JavaScript errors
echo ""
echo "Checking for JavaScript errors in extension code..."
# Filter out unrelated Firefox errors (BackupService, RSLoader, etc.)
if grep -i "JavaScript error.*background.js\|SyntaxError.*background\|ReferenceError.*background" /tmp/web-ext.log 2>/dev/null | grep -v "BackupService\|RSLoader"; then
echo ""
echo "========================================"
echo "✗✗✗ CRITICAL ERROR ✗✗✗"
echo "========================================"
echo "Found JavaScript errors in background.js!"
echo "Extension installed but CODE DID NOT EXECUTE!"
echo ""
echo "Errors:"
grep -i "JavaScript error.*background.js\|SyntaxError.*background\|ReferenceError.*background" /tmp/web-ext.log 2>/dev/null | head -10
echo "========================================"
# Cleanup
kill $WEBEXT_PID 2>/dev/null || true
kill $XVFB_PID 2>/dev/null || true
exit 1
fi
echo "✓ NO JavaScript errors in background.js"
# FUNCTIONAL TEST: Verify extension actually executes code
# Strategy: Check badge text (extension sets badge when intercepting requests)
# This is non-invasive - badge is part of normal operation
echo ""
echo "Functional test: Verifying extension code execution..."
# Get debugger port
PORT=$(grep -oP "start-debugger-server \K[0-9]+" /tmp/web-ext.log | head -1)
if [ -n "$PORT" ]; then
echo "✓ Firefox debugger port: $PORT"
# Simple connectivity test
if timeout 2 bash -c "echo > /dev/tcp/127.0.0.1/$PORT" 2>/dev/null; then
echo "✓ Remote debugging protocol accessible"
echo "✓ Extension code VERIFIED executing"
echo ""
echo "NOTE: Verified by:"
echo " - Extension installed without errors"
echo " - Background page loaded (debugger accessible)"
echo " - No JavaScript errors detected"
else
echo "⚠ Remote debugging not accessible (but extension installed OK)"
fi
else
echo "⚠ Could not find debugger port (but extension installed OK)"
fi
echo ""
echo "✓ Process info:"
ps aux | grep -E "(firefox|Xvfb)" | grep -v grep | head -3
echo "========================================"
echo "Extension is VERIFIED working!"
echo "========================================"
# Cleanup
kill $WEBEXT_PID 2>/dev/null || true
kill $XVFB_PID 2>/dev/null || true
echo "Test completed successfully."
exit 0

View File

@ -1,99 +0,0 @@
#!/bin/bash
#
# verify_extension_code.sh - Verifies that extension code actually executed
#
# Problem: console.error from background page doesn't reach web-ext stdout (Firefox limitation)
# Solution: Use Firefox Remote Debugging Protocol to check extension state
#
# This script:
# 1. Connects to Firefox Remote Debugging Protocol
# 2. Executes JavaScript in background page context
# 3. Checks if Memory object exists (proof that init() executed)
#
set -e
echo "=========================================="
echo "Verifying extension code execution..."
echo "=========================================="
# Wait for web-ext.log to have debugger port
echo "Waiting for Firefox debugger port..."
for i in {1..30}; do
if [ -f /tmp/web-ext.log ]; then
PORT=$(grep -oP "start-debugger-server \K[0-9]+" /tmp/web-ext.log | head -1)
if [ -n "$PORT" ]; then
echo "✓ Found debugger port: $PORT"
break
fi
fi
sleep 1
done
if [ -z "$PORT" ]; then
echo "✗ ERROR: Could not find debugger port in logs"
echo "Extension may not load correctly"
exit 1
fi
# Give extension time to initialize
sleep 3
# Try to connect to debugger and check if Memory object exists
echo ""
echo "Attempting to connect to Remote Debugging Protocol..."
# Use netcat to send raw RDP commands
# RDP uses JSON-RPC like protocol
# We need to:
# 1. Connect to port
# 2. Send listAddons request to find our extension
# 3. Execute code in background context
# Simple test: check if port is open
if timeout 2 bash -c "echo > /dev/tcp/127.0.0.1/$PORT" 2>/dev/null; then
echo "✓ Debugger port $PORT is open"
else
echo "✗ Cannot connect to port $PORT"
exit 1
fi
# Check if we can find evidence in logs that extension is working
echo ""
echo "Checking web-ext logs..."
# Check if extension was installed successfully
if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log; then
echo "✓ Extension installed: rentgen@internet-czas-dzialac.pl"
else
echo "✗ No confirmation of extension installation"
exit 1
fi
# Check if there are any JavaScript errors from extension
if grep -i "JavaScript error.*rentgen\|JavaScript error.*background.js" /tmp/web-ext.log 2>/dev/null; then
echo "✗ FOUND JAVASCRIPT ERRORS IN EXTENSION!"
grep -i "JavaScript error.*rentgen\|JavaScript error.*background.js" /tmp/web-ext.log | head -5
exit 1
else
echo "✓ No JavaScript errors from extension in logs"
fi
# Final verdict: if extension installed without errors, assume it's working
# Console.error from background pages doesn't appear in web-ext logs (Firefox limitation)
# Functional testing would require triggering actual HTTP requests
echo ""
echo "=========================================="
echo "✓✓✓ VERIFICATION COMPLETED SUCCESSFULLY ✓✓✓"
echo "=========================================="
echo "Extension was installed and no errors detected"
echo ""
echo "NOTE: console.error from background page doesn't appear in logs"
echo " (this is a Firefox limitation, not an extension bug)"
echo ""
echo "To DEFINITIVELY verify operation:"
echo " 1. Use Remote Debugging Protocol to query Memory object"
echo " 2. Or load a test page and check if requests are intercepted"
echo "=========================================="
exit 0

View File

@ -1,64 +0,0 @@
#!/bin/bash
#
# verify_extension_working.sh - Verifies that extension actually intercepts requests
#
# Test performs HTTP request inside Firefox and checks if extension intercepted it
# via Badge API (domain counter on extension icon)
#
set -e
echo "Starting Firefox with extension..."
Xvfb :99 -screen 0 1024x768x24 &
XVFB_PID=$!
export DISPLAY=:99
sleep 2
# Start Firefox with extension and remote debugging
npx web-ext run --verbose 2>&1 | tee /tmp/web-ext.log &
WEBEXT_PID=$!
# Wait for extension installation
echo "Waiting for extension installation..."
for i in {1..30}; do
if grep -q "Installed /app as a temporary add-on" /tmp/web-ext.log 2>/dev/null; then
echo "✓ Extension installed"
break
fi
sleep 1
done
# Wait a bit more for extension code to execute
sleep 3
# Try to trigger a request that extension should intercept
# We'll use Firefox to load a simple webpage
echo ""
echo "Testing if extension intercepts requests..."
echo "Attempting to load example.com in Firefox..."
# Use Firefox's remote debugging protocol to open a URL
# This should trigger webRequest listeners if extension is working
timeout 10s bash -c '
# Wait for devtools server port from logs
PORT=$(grep -oP "start-debugger-server \K[0-9]+" /tmp/web-ext.log | head -1)
if [ -n "$PORT" ]; then
echo "Debugger port: $PORT"
# Extension should intercept this request
firefox -P /tmp/firefox-profile* "http://example.com" 2>/dev/null &
sleep 5
fi
' || true
# Check logs for evidence of request interception
echo ""
echo "Checking logs..."
if grep -i "example.com" /tmp/web-ext.log 2>/dev/null; then
echo "✓✓✓ SUCCESS: Request to example.com was detected!"
echo "✓✓✓ Extension IS ACTUALLY intercepting requests!"
exit 0
else
echo "✗✗✗ NO EVIDENCE that extension intercepts requests"
echo "Extension may be installed but CODE may not be executing"
exit 1
fi