Test the full command construction of airodump-ng.
(client, mock_app_module, mocker)
| 88 | assert 'already running' in data['message'] |
| 89 | |
| 90 | def test_start_scan_execution(client, mock_app_module, mocker): |
| 91 | """Test the full command construction of airodump-ng.""" |
| 92 | mock_app_module.wifi_process = None |
| 93 | mocker.patch("os.path.exists", return_value=True) |
| 94 | mocker.patch("routes.wifi.get_tool_path", return_value="/usr/bin/airodump-ng") |
| 95 | |
| 96 | mock_popen = mocker.patch("routes.wifi.subprocess.Popen") |
| 97 | mock_proc = MagicMock() |
| 98 | mock_proc.poll.return_value = None |
| 99 | mock_popen.return_value = mock_proc |
| 100 | |
| 101 | payload = {'interface': 'wlan0mon', 'channel': 6, 'band': 'g'} |
| 102 | response = client.post('/wifi/scan/start', json=payload) |
| 103 | |
| 104 | assert response.status_code == 200 |
| 105 | assert response.get_json()['status'] == 'started' |
| 106 | |
| 107 | args, _ = mock_popen.call_args |
| 108 | cmd = args[0] |
| 109 | assert "-c" in cmd and "6" in cmd |
| 110 | assert "wlan0mon" in cmd |
| 111 | |
| 112 | def test_stop_scan(client, mock_app_module): |
| 113 | """Test terminating the scanning process.""" |