Fix: read WG server IP and subnet from live API instead of hardcoding 10.0.0.x
Unit Tests / test (push) Successful in 7m30s
Unit Tests / test (push) Successful in 7m30s
test_wg_connect_and_ping_server and the connected_peer fixture hardcoded 10.0.0.1 / 10.0.0.0/24 as the server VPN address. This breaks when the server uses a different subnet (e.g. pic1 uses 10.0.1.1/24). Now both read 'address' from /api/wireguard/status at session start and pass the live server_ip / server_network through wg_server_info and connected_peer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,8 +7,9 @@ pytestmark = pytest.mark.wg
|
||||
def test_wg_connect_and_ping_server(connected_peer):
|
||||
"""Scenario 25+26: create peer, connect, ping server VPN IP."""
|
||||
iface = connected_peer['iface']
|
||||
server_ip = connected_peer.get('server_ip', '10.0.0.1')
|
||||
assert iface.up, "WireGuard interface should be up"
|
||||
assert iface.is_connected('10.0.0.1'), "Server VPN IP 10.0.0.1 should be reachable via WireGuard"
|
||||
assert iface.is_connected(server_ip), f"Server VPN IP {server_ip} should be reachable via WireGuard"
|
||||
|
||||
|
||||
def test_wg_peer_has_assigned_ip(connected_peer):
|
||||
@@ -21,8 +22,9 @@ def test_wg_peer_has_assigned_ip(connected_peer):
|
||||
def test_wg_disconnect_removes_route(connected_peer):
|
||||
"""Scenario 29: after disconnect, VPN IP is not reachable."""
|
||||
iface = connected_peer['iface']
|
||||
server_ip = connected_peer.get('server_ip', '10.0.0.1')
|
||||
iface.bring_down()
|
||||
result = subprocess.run(['ping', '-c', '1', '-W', '2', '10.0.0.1'],
|
||||
result = subprocess.run(['ping', '-c', '1', '-W', '2', server_ip],
|
||||
capture_output=True, timeout=5)
|
||||
# After disconnect, ping should fail
|
||||
assert result.returncode != 0, "VPN IP should not be reachable after disconnect"
|
||||
|
||||
Reference in New Issue
Block a user