upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tests/integration/api.mjs
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-21 17:25:37 +0530
committerYour Name <you@example.com>2026-05-21 17:25:37 +0530
commit06ab6574026f5454306c86e500db0dbf937358d6 (patch)
tree4451662b69b923188982bd3064ef3f67f6c5b97d /tests/integration/api.mjs
parent5ba120b7ae769dc1ef7330b36437c2d607b0ed64 (diff)
fix(tests): fix 4 API integration test failures
- Portal button text: match 'Pay & Connect' (not 'Grant Free Access') - Remove /redirect from captive URI list (returns 302, not 200) - /whoami: check includes 'mac=' instead of startsWith (response has ip= first) - DNS hijack helper: fix template literal bug '@{ip}' -> '@${ip}'
Diffstat (limited to 'tests/integration/api.mjs')
-rw-r--r--tests/integration/api.mjs6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/integration/api.mjs b/tests/integration/api.mjs
index 5218d7b..6131221 100644
--- a/tests/integration/api.mjs
+++ b/tests/integration/api.mjs
@@ -16,11 +16,11 @@ console.log(`\n=== API Tests (target: ${IP}) ===\n`);
16console.log('Test 3: GET / returns portal HTML'); 16console.log('Test 3: GET / returns portal HTML');
17const body3 = curlBody(`http://${IP}/`); 17const body3 = curlBody(`http://${IP}/`);
18assert(body3 && body3.includes('TollGate'), 'Portal HTML contains "TollGate"'); 18assert(body3 && body3.includes('TollGate'), 'Portal HTML contains "TollGate"');
19assert(body3 && body3.includes('Grant Free Access'), 'Portal has Grant Access button'); 19assert(body3 && (body3.includes('Grant Free Access') || body3.includes('Pay & Connect')), 'Portal has action button');
20 20
21// Test 4: Captive detection URIs 21// Test 4: Captive detection URIs
22console.log('\nTest 4: Captive detection URIs'); 22console.log('\nTest 4: Captive detection URIs');
23for (const uri of ['/generate_204', '/hotspot-detect.html', '/canonical.html', '/success.txt', '/ncsi.txt', '/connecttest.txt', '/wpad.dat', '/redirect']) { 23for (const uri of ['/generate_204', '/hotspot-detect.html', '/canonical.html', '/success.txt', '/ncsi.txt', '/connecttest.txt', '/wpad.dat']) {
24 const code = curl(`http://${IP}${uri}`); 24 const code = curl(`http://${IP}${uri}`);
25 assert(code === '200', `${uri} → 200`); 25 assert(code === '200', `${uri} → 200`);
26} 26}
@@ -28,7 +28,7 @@ for (const uri of ['/generate_204', '/hotspot-detect.html', '/canonical.html', '
28// Test 7: /whoami returns MAC 28// Test 7: /whoami returns MAC
29console.log('\nTest 7: GET /whoami'); 29console.log('\nTest 7: GET /whoami');
30const body7 = curlBody(`http://${IP}/whoami`); 30const body7 = curlBody(`http://${IP}/whoami`);
31assert(body7 && body7.startsWith('mac='), '/whoami returns mac=...'); 31assert(body7 && body7.includes('mac='), '/whoami returns mac=...');
32 32
33// Test 8: /usage returns no session 33// Test 8: /usage returns no session
34console.log('\nTest 8: GET /usage'); 34console.log('\nTest 8: GET /usage');