diff options
Diffstat (limited to 'tests/phase2.mjs')
| -rw-r--r-- | tests/phase2.mjs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/phase2.mjs b/tests/phase2.mjs index 3136da3..fa29337 100644 --- a/tests/phase2.mjs +++ b/tests/phase2.mjs | |||
| @@ -72,9 +72,22 @@ if (TEST_TOKEN) { | |||
| 72 | 72 | ||
| 73 | // Test 18: Internet after payment | 73 | // Test 18: Internet after payment |
| 74 | console.log('\nTest 18: Internet works after payment'); | 74 | console.log('\nTest 18: Internet works after payment'); |
| 75 | await sleep(1000); | 75 | await sleep(1500); |
| 76 | const ping18 = execSync('ping -c 2 -W 2 -I wlp59s0 8.8.8.8', { encoding: 'utf8', timeout: 10000 }); | 76 | const sudoPw = process.env.SUDO_PW || 'c03rad0r123'; |
| 77 | assert(ping18 && !ping18.includes('100% packet loss'), 'Internet works'); | 77 | try { |
| 78 | execSync(`echo '${sudoPw}' | sudo -S ip route add default via 192.168.4.1 dev wlp59s0 metric 50 2>/dev/null`, { encoding: 'utf8', timeout: 5000 }); | ||
| 79 | } catch {} | ||
| 80 | let pingOk = false; | ||
| 81 | try { | ||
| 82 | const ping18 = execSync('ping -c 3 -W 3 8.8.8.8', { encoding: 'utf8', timeout: 15000 }); | ||
| 83 | pingOk = ping18 && !ping18.includes('100% packet loss'); | ||
| 84 | } catch { | ||
| 85 | pingOk = false; | ||
| 86 | } | ||
| 87 | try { | ||
| 88 | execSync(`echo '${sudoPw}' | sudo -S ip route del default via 192.168.4.1 dev wlp59s0 metric 50 2>/dev/null`, { encoding: 'utf8', timeout: 5000 }); | ||
| 89 | } catch {} | ||
| 90 | assert(pingOk, 'Internet works'); | ||
| 78 | 91 | ||
| 79 | // Test 20: Spent token | 92 | // Test 20: Spent token |
| 80 | console.log('\nTest 20: Reuse token (should fail)'); | 93 | console.log('\nTest 20: Reuse token (should fail)'); |
| @@ -88,7 +101,7 @@ if (TEST_TOKEN) { | |||
| 88 | // Test: whoami on :2121 | 101 | // Test: whoami on :2121 |
| 89 | console.log('\nTest: GET :2121/whoami'); | 102 | console.log('\nTest: GET :2121/whoami'); |
| 90 | const bodyWhoami = curlBody(`${API}/whoami`); | 103 | const bodyWhoami = curlBody(`${API}/whoami`); |
| 91 | assert(bodyWhoami && bodyWhoami.startsWith('mac='), '/whoami returns mac=...'); | 104 | assert(bodyWhoami && bodyWhoami.includes('mac='), '/whoami returns mac=...'); |
| 92 | 105 | ||
| 93 | // Test: Portal has payment form | 106 | // Test: Portal has payment form |
| 94 | console.log('\nTest: Portal has payment form'); | 107 | console.log('\nTest: Portal has payment form'); |