From 8071741815f0b0938701e80a63e80b0ec94b2778 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 17 May 2026 17:18:43 +0530 Subject: refactor: reorganize test suite, add integration tests for NAT filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move integration tests (api, network, phase2, smoke) to tests/integration/ - Move Playwright specs (captive-portal, interop-happy-path) to tests/e2e/ - Move playwright.config.mjs to tests/e2e/ - Fix hardcoded IP fallbacks: 192.168.4.1 → 10.192.45.1 - Add test-reset-auth.mjs: reset→pay→allow→revoke→block cycle - Add test-session-expiry.mjs: pay→wait 65s→verify blocked (slow test) - Add test-dns-firewall.mjs: DNS hijack/forward + per-client NAT filter - Update Makefile with test-unit, test-integration, test-e2e, test-all targets - Update package.json scripts for new paths - Fix Playwright video: retain-on-failure instead of always-on - Update AGENTS.md: per-client NAT filter description - Update CHECKLIST.md: mark completed items, add Board B identity - Board B nsec: 9af47906... → SSID TollGate-b96d80, AP IP 10.185.47.1 - 186 unit tests passing --- tests/network.mjs | 66 ------------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 tests/network.mjs (limited to 'tests/network.mjs') diff --git a/tests/network.mjs b/tests/network.mjs deleted file mode 100644 index 2d302ef..0000000 --- a/tests/network.mjs +++ /dev/null @@ -1,66 +0,0 @@ -import { execSync } from 'child_process'; - -const IP = process.env.TOLLGATE_IP || '192.168.4.1'; -let passed = 0, failed = 0; - -function assert(condition, test) { - if (condition) { console.log(` ✓ ${test}`); passed++; } - else { console.log(` ✗ ${test}`); failed++; } -} - -function run(cmd) { - try { return execSync(cmd, { encoding: 'utf8', timeout: 15000 }); } - catch { return null; } -} - -console.log(`\n=== Network Tests (target: ${IP}) ===\n`); - -// Test 1: AP visible in scan -console.log('Test 1: AP visible in scan'); -const scan = run('nmcli -t -f SSID dev wifi list 2>/dev/null'); -assert(scan && scan.includes('TollGate'), 'TollGate SSID visible in WiFi scan'); - -// Test 2: DHCP lease -console.log('\nTest 2: DHCP lease / connectivity'); -const ip_show = run(`ip addr show | grep "inet ${IP.split('.').slice(0,3).join('.')}"`); -assert(ip_show !== null, `Has IP in ${IP.split('.').slice(0,3).join('.')}.* subnet`); - -// Test 5: DNS hijack -console.log('\nTest 5: DNS hijack before auth'); -const ns1 = run(`nslookup random-test.example.com ${IP} 2>/dev/null`); -assert(ns1 && ns1.includes(IP), 'DNS resolves arbitrary domain to AP IP'); - -// Test 6: No internet -console.log('\nTest 6: No internet before auth'); -const ping1 = run('ping -c 1 -W 3 1.1.1.1 2>/dev/null'); -assert(ping1 === null || ping1.includes('100% packet loss'), 'Internet blocked before auth'); - -// Grant access for further tests -console.log('\nGranting access...'); -run(`curl -s http://${IP}/grant_access`); - -import { execSync as exec } from 'child_process'; -await new Promise(r => setTimeout(r, 2000)); - -// Test 10: DNS forward -console.log('Test 10: DNS forward after auth'); -const ns2 = run(`nslookup google.com ${IP} 2>/dev/null`); -assert(ns2 && !ns2.includes(IP) && ns2.includes('Address'), 'DNS resolves to real IPs'); - -// Test 11: Internet -console.log('\nTest 11: Internet after auth'); -const ping2 = run('ping -c 2 -W 3 8.8.8.8'); -assert(ping2 && !ping2.includes('100% packet loss'), 'ping succeeds after auth'); - -// Reset -console.log('\nResetting auth...'); -run(`curl -s http://${IP}/reset_authentication`); -await new Promise(r => setTimeout(r, 2000)); - -// Test 14 -console.log('Test 14: Internet blocked after reset'); -const ping3 = run('ping -c 1 -W 3 8.8.8.8 2>/dev/null'); -assert(ping3 === null || ping3.includes('100% packet loss'), 'Internet blocked after reset'); - -console.log(`\n=== Results: ${passed} passed, ${failed} failed ===\n`); -process.exit(failed > 0 ? 1 : 0); -- cgit v1.2.3