first commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import io
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from librenet_scanner.privileged_helper import run_supervised
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class Cancellation0419Tests(unittest.TestCase):
|
||||
def test_privileged_helper_stop_protocol_reaps_root_child(self):
|
||||
start = time.monotonic()
|
||||
code = run_supervised(
|
||||
[sys.executable, "-c", "import time; time.sleep(30)"],
|
||||
input_stream=io.StringIO("STOP\n"),
|
||||
)
|
||||
self.assertEqual(code, 130)
|
||||
self.assertLess(time.monotonic() - start, 3.0)
|
||||
|
||||
def test_scan_processes_have_a_dedicated_process_group_and_stop_channel(self):
|
||||
source = (ROOT / "src/librenet_scanner/scanner.py").read_text(encoding="utf-8")
|
||||
self.assertIn("start_new_session=True", source)
|
||||
self.assertIn('proc.stdin.write("STOP\\n")', source)
|
||||
self.assertIn("self._kill_process_group(proc, signal.SIGTERM)", source)
|
||||
|
||||
def test_stop_button_reports_real_shutdown(self):
|
||||
source = (ROOT / "src/librenet_scanner/ui.py").read_text(encoding="utf-8")
|
||||
self.assertIn('self.activity_label.setText("Arrêt du scan en cours…")', source)
|
||||
self.assertIn("self.stop_btn.setEnabled(False)", source)
|
||||
|
||||
|
||||
class EngineStatus0419Tests(unittest.TestCase):
|
||||
def test_discovery_and_port_engines_are_named_separately(self):
|
||||
source = (ROOT / "src/librenet_scanner/scanner.py").read_text(encoding="utf-8")
|
||||
self.assertIn("découverte rapide Nmap/ARP", source)
|
||||
self.assertIn("ports Naabu SYN (Admin)", source)
|
||||
self.assertIn("ports Nmap SYN (Admin)", source)
|
||||
self.assertIn("REPLI Naabu", source)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user