Commit 9a9015a7 authored by vieira's avatar vieira Committed by Brian May

Fixed tests after adding support for iproute2

parent d7d24f95
...@@ -21,8 +21,9 @@ def test__maskbits(): ...@@ -21,8 +21,9 @@ def test__maskbits():
sshuttle.server._maskbits(netmask) sshuttle.server._maskbits(netmask)
@patch('sshuttle.server.which', side_effect=lambda x: x == 'netstat')
@patch('sshuttle.server.ssubprocess.Popen') @patch('sshuttle.server.ssubprocess.Popen')
def test__listroutes(mock_popen): def test_listroutes_netstat(mock_popen, mock_which):
mock_pobj = Mock() mock_pobj = Mock()
mock_pobj.stdout = io.BytesIO(b""" mock_pobj.stdout = io.BytesIO(b"""
Kernel IP routing table Kernel IP routing table
...@@ -33,30 +34,20 @@ Destination Gateway Genmask Flags MSS Window irtt Iface ...@@ -33,30 +34,20 @@ Destination Gateway Genmask Flags MSS Window irtt Iface
mock_pobj.wait.return_value = 0 mock_pobj.wait.return_value = 0
mock_popen.return_value = mock_pobj mock_popen.return_value = mock_pobj
routes = sshuttle.server._list_routes() routes = sshuttle.server.list_routes()
env = { assert list(routes) == [
'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) (socket.AF_INET, '192.168.1.0', 24)
] ]
@patch('sshuttle.server.which', side_effect=lambda x: x == 'ip')
@patch('sshuttle.server.ssubprocess.Popen') @patch('sshuttle.server.ssubprocess.Popen')
def test_listroutes(mock_popen): def test_listroutes_iproute(mock_popen, mock_which):
mock_pobj = Mock() mock_pobj = Mock()
mock_pobj.stdout = io.BytesIO(b""" mock_pobj.stdout = io.BytesIO(b"""
Kernel IP routing table default via 192.168.1.1 dev wlan0 proto static
Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.1
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_pobj.wait.return_value = 0
mock_popen.return_value = mock_pobj mock_popen.return_value = mock_pobj
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment