diff options
| author | Your Name <you@example.com> | 2026-05-17 17:18:43 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-17 17:18:43 +0530 |
| commit | 8071741815f0b0938701e80a63e80b0ec94b2778 (patch) | |
| tree | 2a1511480e0b58f4efb144aa9d10c9fba5eed034 /tests/integration/smoke.mjs | |
| parent | 0c2c67b463d6a90aaa0bb69bf3c91dba1d9ec3ec (diff) | |
refactor: reorganize test suite, add integration tests for NAT filter
- 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
Diffstat (limited to 'tests/integration/smoke.mjs')
| -rw-r--r-- | tests/integration/smoke.mjs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/integration/smoke.mjs b/tests/integration/smoke.mjs new file mode 100644 index 0000000..f89eeac --- /dev/null +++ b/tests/integration/smoke.mjs | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | import { execSync } from 'child_process'; | ||
| 2 | |||
| 3 | const PORT = process.argv[2] || '/dev/ttyACM0'; | ||
| 4 | const IP = process.env.TOLLGATE_IP || '10.192.45.1'; | ||
| 5 | const SSID = process.env.AP_SSID || 'TollGate'; | ||
| 6 | |||
| 7 | console.log(`\n=== Smoke Test (30s) ===`); | ||
| 8 | console.log(`Port: ${PORT}, Portal IP: ${IP}, SSID: ${SSID}\n`); | ||
| 9 | |||
| 10 | let passed = 0, failed = 0; | ||
| 11 | function assert(cond, msg) { | ||
| 12 | if (cond) { console.log(` ✓ ${msg}`); passed++; } | ||
| 13 | else { console.log(` ✗ ${msg}`); failed++; } | ||
| 14 | } | ||
| 15 | |||
| 16 | function run(cmd) { | ||
| 17 | try { return execSync(cmd, { encoding: 'utf8', timeout: 10000 }); } | ||
| 18 | catch { return null; } | ||
| 19 | } | ||
| 20 | |||
| 21 | // 1. Check AP visible | ||
| 22 | const scan = run('nmcli -t -f SSID dev wifi list 2>/dev/null'); | ||
| 23 | assert(scan && scan.includes(SSID), `SSID "${SSID}" visible`); | ||
| 24 | |||
| 25 | // 2. Check we can reach portal | ||
| 26 | const portal = run(`curl -s --connect-timeout 5 http://${IP}/`); | ||
| 27 | assert(portal && portal.includes('TollGate'), 'Portal HTML loads'); | ||
| 28 | |||
| 29 | // 3. Grant access | ||
| 30 | const grant = run(`curl -s http://${IP}/grant_access`); | ||
| 31 | assert(grant && grant.includes('granted'), 'Grant access works'); | ||
| 32 | |||
| 33 | // Wait for DNS | ||
| 34 | const sleep = ms => new Promise(r => setTimeout(r, ms)); | ||
| 35 | await sleep(2000); | ||
| 36 | |||
| 37 | // 4. Internet works | ||
| 38 | const ping = run('ping -c 1 -W 3 -I wlp59s0 1.1.1.1 2>/dev/null'); | ||
| 39 | assert(ping && !ping.includes('100% packet loss'), 'Internet works after grant'); | ||
| 40 | |||
| 41 | // 5. Reset | ||
| 42 | const reset = run(`curl -s http://${IP}/reset_authentication`); | ||
| 43 | assert(reset && reset.includes('reset'), 'Reset auth works'); | ||
| 44 | |||
| 45 | await sleep(2000); | ||
| 46 | |||
| 47 | // 6. Internet blocked | ||
| 48 | const ping2 = run('ping -c 1 -W 3 -I wlp59s0 1.1.1.1 2>/dev/null'); | ||
| 49 | assert(!ping2 || ping2.includes('100% packet loss'), 'Internet blocked after reset'); | ||
| 50 | |||
| 51 | console.log(`\n=== Smoke: ${passed} passed, ${failed} failed ===\n`); | ||
| 52 | process.exit(failed > 0 ? 1 : 0); | ||