|
@@ 156-180 (lines=25) @@
|
| 153 |
|
with self.assertRaises(OspdError): |
| 154 |
|
cmd.handle_xml(request) |
| 155 |
|
|
| 156 |
|
@patch("ospd.command.command.create_process") |
| 157 |
|
def test_scan_with_vts_and_param(self, mock_create_process): |
| 158 |
|
daemon = DummyWrapper([]) |
| 159 |
|
cmd = StartScan(daemon) |
| 160 |
|
|
| 161 |
|
# No error |
| 162 |
|
request = et.fromstring( |
| 163 |
|
'<start_scan target="localhost" ports="80, 443">' |
| 164 |
|
'<scanner_params />' |
| 165 |
|
'<vt_selection>' |
| 166 |
|
'<vt_single id="1234">' |
| 167 |
|
'<vt_value id="ABC">200</vt_value>' |
| 168 |
|
'</vt_single>' |
| 169 |
|
'</vt_selection>' |
| 170 |
|
'</start_scan>' |
| 171 |
|
) |
| 172 |
|
response = et.fromstring(cmd.handle_xml(request)) |
| 173 |
|
scan_id = response.findtext('id') |
| 174 |
|
|
| 175 |
|
self.assertEqual( |
| 176 |
|
daemon.get_scan_vts(scan_id), |
| 177 |
|
{'1234': {'ABC': '200'}, 'vt_groups': []}, |
| 178 |
|
) |
| 179 |
|
|
| 180 |
|
assert_called(mock_create_process) |
| 181 |
|
|
| 182 |
|
def test_scan_with_vts_and_param_missing_vt_group_filter(self): |
| 183 |
|
daemon = DummyWrapper([]) |
|
@@ 197-218 (lines=22) @@
|
| 194 |
|
with self.assertRaises(OspdError): |
| 195 |
|
cmd.handle_xml(request) |
| 196 |
|
|
| 197 |
|
@patch("ospd.command.command.create_process") |
| 198 |
|
def test_scan_with_vts_and_param_with_vt_group_filter( |
| 199 |
|
self, mock_create_process |
| 200 |
|
): |
| 201 |
|
daemon = DummyWrapper([]) |
| 202 |
|
cmd = StartScan(daemon) |
| 203 |
|
|
| 204 |
|
# No error |
| 205 |
|
request = et.fromstring( |
| 206 |
|
'<start_scan target="localhost" ports="80, 443">' |
| 207 |
|
'<scanner_params />' |
| 208 |
|
'<vt_selection>' |
| 209 |
|
'<vt_group filter="a"/>' |
| 210 |
|
'</vt_selection>' |
| 211 |
|
'</start_scan>' |
| 212 |
|
) |
| 213 |
|
response = et.fromstring(cmd.handle_xml(request)) |
| 214 |
|
scan_id = response.findtext('id') |
| 215 |
|
|
| 216 |
|
self.assertEqual(daemon.get_scan_vts(scan_id), {'vt_groups': ['a']}) |
| 217 |
|
|
| 218 |
|
assert_called(mock_create_process) |
| 219 |
|
|
| 220 |
|
def test_scan_multi_target_parallel_with_error(self): |
| 221 |
|
daemon = DummyWrapper([]) |