mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-08 09:04:29 +01:00
Fixed tests after adding support for iproute2
This commit is contained in:
parent
d7d24f956b
commit
9a9015a75e
@ -21,36 +21,9 @@ def test__maskbits():
|
||||
sshuttle.server._maskbits(netmask)
|
||||
|
||||
|
||||
@patch('sshuttle.server.which', side_effect=lambda x: x == 'netstat')
|
||||
@patch('sshuttle.server.ssubprocess.Popen')
|
||||
def test__listroutes(mock_popen):
|
||||
mock_pobj = Mock()
|
||||
mock_pobj.stdout = io.BytesIO(b"""
|
||||
Kernel IP routing table
|
||||
Destination Gateway Genmask Flags MSS Window irtt Iface
|
||||
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
|
||||
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
|
||||
""")
|
||||
mock_pobj.wait.return_value = 0
|
||||
mock_popen.return_value = mock_pobj
|
||||
|
||||
routes = sshuttle.server._list_routes()
|
||||
|
||||
env = {
|
||||
'PATH': os.environ['PATH'],
|
||||
'LC_ALL': "C",
|
||||
}
|
||||
assert mock_popen.mock_calls == [
|
||||
call(['netstat', '-rn'], stdout=-1, env=env),
|
||||
call().wait()
|
||||
]
|
||||
assert routes == [
|
||||
(socket.AF_INET, '0.0.0.0', 0),
|
||||
(socket.AF_INET, '192.168.1.0', 24)
|
||||
]
|
||||
|
||||
|
||||
@patch('sshuttle.server.ssubprocess.Popen')
|
||||
def test_listroutes(mock_popen):
|
||||
def test_listroutes_netstat(mock_popen, mock_which):
|
||||
mock_pobj = Mock()
|
||||
mock_pobj.stdout = io.BytesIO(b"""
|
||||
Kernel IP routing table
|
||||
@ -66,3 +39,21 @@ Destination Gateway Genmask Flags MSS Window irtt Iface
|
||||
assert list(routes) == [
|
||||
(socket.AF_INET, '192.168.1.0', 24)
|
||||
]
|
||||
|
||||
|
||||
@patch('sshuttle.server.which', side_effect=lambda x: x == 'ip')
|
||||
@patch('sshuttle.server.ssubprocess.Popen')
|
||||
def test_listroutes_iproute(mock_popen, mock_which):
|
||||
mock_pobj = Mock()
|
||||
mock_pobj.stdout = io.BytesIO(b"""
|
||||
default via 192.168.1.1 dev wlan0 proto static
|
||||
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.1
|
||||
""")
|
||||
mock_pobj.wait.return_value = 0
|
||||
mock_popen.return_value = mock_pobj
|
||||
|
||||
routes = sshuttle.server.list_routes()
|
||||
|
||||
assert list(routes) == [
|
||||
(socket.AF_INET, '192.168.1.0', 24)
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user