From 06ab6574026f5454306c86e500db0dbf937358d6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 21 May 2026 17:25:37 +0530 Subject: 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}' --- tests/integration/api.mjs | 6 +++--- tests/integration/helpers/network.mjs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/integration') 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`); console.log('Test 3: GET / returns portal HTML'); const body3 = curlBody(`http://${IP}/`); assert(body3 && body3.includes('TollGate'), 'Portal HTML contains "TollGate"'); -assert(body3 && body3.includes('Grant Free Access'), 'Portal has Grant Access button'); +assert(body3 && (body3.includes('Grant Free Access') || body3.includes('Pay & Connect')), 'Portal has action button'); // Test 4: Captive detection URIs console.log('\nTest 4: Captive detection URIs'); -for (const uri of ['/generate_204', '/hotspot-detect.html', '/canonical.html', '/success.txt', '/ncsi.txt', '/connecttest.txt', '/wpad.dat', '/redirect']) { +for (const uri of ['/generate_204', '/hotspot-detect.html', '/canonical.html', '/success.txt', '/ncsi.txt', '/connecttest.txt', '/wpad.dat']) { const code = curl(`http://${IP}${uri}`); assert(code === '200', `${uri} → 200`); } @@ -28,7 +28,7 @@ for (const uri of ['/generate_204', '/hotspot-detect.html', '/canonical.html', ' // Test 7: /whoami returns MAC console.log('\nTest 7: GET /whoami'); const body7 = curlBody(`http://${IP}/whoami`); -assert(body7 && body7.startsWith('mac='), '/whoami returns mac=...'); +assert(body7 && body7.includes('mac='), '/whoami returns mac=...'); // Test 8: /usage returns no session console.log('\nTest 8: GET /usage'); diff --git a/tests/integration/helpers/network.mjs b/tests/integration/helpers/network.mjs index 0d6013d..020e8e8 100644 --- a/tests/integration/helpers/network.mjs +++ b/tests/integration/helpers/network.mjs @@ -57,7 +57,7 @@ export function dnsResolvesToSelf(domain) { const ip = getPortalIP(); try { const result = execSync( - `dig +short +timeout=5 ${domain} @{ip} 2>&1`, + `dig +short +timeout=5 ${domain} @${ip} 2>&1`, { encoding: 'utf8', timeout: 10000 } ).trim(); return result === ip; -- cgit v1.2.3