mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-13 09:48:10 +03:00
Improve TUN routing readability
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -85,6 +85,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
|
||||
Path(arguments[2]).name.startswith(tempfile.gettempprefix())
|
||||
)
|
||||
self.assertEqual(Path(arguments[2]).suffix, '.sh')
|
||||
|
||||
scripts.append(Path(arguments[2]).read_text(encoding='utf-8'))
|
||||
return process
|
||||
|
||||
@@ -103,6 +104,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
|
||||
self.host.applyDNS('1.1.1.1')
|
||||
|
||||
self.assertEqual(self.host.index, 77)
|
||||
|
||||
self.assertIn('ip tuntap add dev utun101 mode tun user 1000', scripts[0])
|
||||
self.assertIn('ip link set dev utun101 mtu 1500', scripts[0])
|
||||
self.assertIn('ip -6 addr add fd00::1/64 dev utun101', scripts[0])
|
||||
@@ -142,6 +144,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
|
||||
)
|
||||
|
||||
directory = Path(self.host._directory.name)
|
||||
|
||||
self.assertIs(self.host._process, process)
|
||||
self.assertEqual(len(list(directory.glob('*.sh'))), 1)
|
||||
self.assertTrue((directory / 'cancelled').exists())
|
||||
@@ -180,8 +183,10 @@ class SingTUNLinuxHostTest(unittest.TestCase):
|
||||
root = Path(directory).resolve()
|
||||
net = root / 'net'
|
||||
binDirectory = root / 'bin'
|
||||
|
||||
net.mkdir()
|
||||
binDirectory.mkdir()
|
||||
|
||||
ip = binDirectory / 'ip'
|
||||
|
||||
# This fixture only creates/removes files under its temporary
|
||||
@@ -217,6 +222,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
|
||||
|
||||
def launch(arguments, **kwargs):
|
||||
self.assertEqual(arguments[:2], ['pkexec', 'bash'])
|
||||
|
||||
script = Path(arguments[-1])
|
||||
text = script.read_text(encoding='utf-8')
|
||||
text = text.replace('/sys/class/net', net.as_posix())
|
||||
@@ -239,6 +245,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
|
||||
FAKE_CANCEL=(script.parent / 'cancelled').as_posix(),
|
||||
FAKE_SCRIPT=script.as_posix(),
|
||||
)
|
||||
|
||||
return realPopen([bash, str(script)], env=environment, **kwargs)
|
||||
|
||||
with mock.patch.object(
|
||||
@@ -254,6 +261,7 @@ class SingTUNLinuxHostTest(unittest.TestCase):
|
||||
):
|
||||
if failure == 'none':
|
||||
self.host.prepare()
|
||||
|
||||
self.assertEqual(self.host.index, 77)
|
||||
else:
|
||||
with self.assertRaisesRegex(
|
||||
|
||||
Reference in New Issue
Block a user