diff options
| author | Your Name <you@example.com> | 2026-05-21 17:25:37 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-21 17:25:37 +0530 |
| commit | 06ab6574026f5454306c86e500db0dbf937358d6 (patch) | |
| tree | 4451662b69b923188982bd3064ef3f67f6c5b97d /tests/integration | |
| parent | 5ba120b7ae769dc1ef7330b36437c2d607b0ed64 (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')
| -rw-r--r-- | tests/integration/api.mjs | 6 | ||||
| -rw-r--r-- | tests/integration/helpers/network.mjs | 2 |
2 files changed, 4 insertions, 4 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`); | |||
| 16 | console.log('Test 3: GET / returns portal HTML'); | 16 | console.log('Test 3: GET / returns portal HTML'); |
| 17 | const body3 = curlBody(`http://${IP}/`); | 17 | const body3 = curlBody(`http://${IP}/`); |
| 18 | assert(body3 && body3.includes('TollGate'), 'Portal HTML contains "TollGate"'); | 18 | assert(body3 && body3.includes('TollGate'), 'Portal HTML contains "TollGate"'); |
| 19 | assert(body3 && body3.includes('Grant Free Access'), 'Portal has Grant Access button'); | 19 | assert(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 |
| 22 | console.log('\nTest 4: Captive detection URIs'); | 22 | console.log('\nTest 4: Captive detection URIs'); |
| 23 | for (const uri of ['/generate_204', '/hotspot-detect.html', '/canonical.html', '/success.txt', '/ncsi.txt', '/connecttest.txt', '/wpad.dat', '/redirect']) { | 23 | for (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 |
| 29 | console.log('\nTest 7: GET /whoami'); | 29 | console.log('\nTest 7: GET /whoami'); |
| 30 | const body7 = curlBody(`http://${IP}/whoami`); | 30 | const body7 = curlBody(`http://${IP}/whoami`); |
| 31 | assert(body7 && body7.startsWith('mac='), '/whoami returns mac=...'); | 31 | assert(body7 && body7.includes('mac='), '/whoami returns mac=...'); |
| 32 | 32 | ||
| 33 | // Test 8: /usage returns no session | 33 | // Test 8: /usage returns no session |
| 34 | console.log('\nTest 8: GET /usage'); | 34 | 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) { | |||
| 57 | const ip = getPortalIP(); | 57 | const ip = getPortalIP(); |
| 58 | try { | 58 | try { |
| 59 | const result = execSync( | 59 | const result = execSync( |
| 60 | `dig +short +timeout=5 ${domain} @{ip} 2>&1`, | 60 | `dig +short +timeout=5 ${domain} @${ip} 2>&1`, |
| 61 | { encoding: 'utf8', timeout: 10000 } | 61 | { encoding: 'utf8', timeout: 10000 } |
| 62 | ).trim(); | 62 | ).trim(); |
| 63 | return result === ip; | 63 | return result === ip; |