upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

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