| @@ 197-221 (lines=25) @@ | ||
| 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(self, mock_create_process): |
|
| 199 | daemon = DummyWrapper([]) |
|
| 200 | cmd = StartScan(daemon) |
|
| 201 | ||
| 202 | # No error |
|
| 203 | request = et.fromstring( |
|
| 204 | '<start_scan>' |
|
| 205 | '<targets>' |
|
| 206 | '<target>' |
|
| 207 | '<hosts>localhost</hosts>' |
|
| 208 | '<ports>80, 443</ports>' |
|
| 209 | '</target>' |
|
| 210 | '</targets>' |
|
| 211 | '<scanner_params />' |
|
| 212 | '<vt_selection>' |
|
| 213 | '<vt_single id="1234">' |
|
| 214 | '<vt_value id="ABC">200</vt_value>' |
|
| 215 | '</vt_single>' |
|
| 216 | '</vt_selection>' |
|
| 217 | '</start_scan>' |
|
| 218 | ) |
|
| 219 | response = et.fromstring(cmd.handle_xml(request)) |
|
| 220 | scan_id = response.findtext('id') |
|
| 221 | ||
| 222 | self.assertEqual( |
|
| 223 | daemon.get_scan_vts(scan_id), |
|
| 224 | {'1234': {'ABC': '200'}, 'vt_groups': []}, |
|
| @@ 250-271 (lines=22) @@ | ||
| 247 | with self.assertRaises(OspdError): |
|
| 248 | cmd.handle_xml(request) |
|
| 249 | ||
| 250 | @patch("ospd.command.command.create_process") |
|
| 251 | def test_scan_with_vts_and_param_with_vt_group_filter( |
|
| 252 | self, mock_create_process |
|
| 253 | ): |
|
| 254 | daemon = DummyWrapper([]) |
|
| 255 | cmd = StartScan(daemon) |
|
| 256 | ||
| 257 | # No error |
|
| 258 | request = et.fromstring( |
|
| 259 | '<start_scan>' |
|
| 260 | '<targets>' |
|
| 261 | '<target>' |
|
| 262 | '<hosts>localhost</hosts>' |
|
| 263 | '<ports>80, 443</ports>' |
|
| 264 | '</target>' |
|
| 265 | '</targets>' |
|
| 266 | '<scanner_params />' |
|
| 267 | '<vt_selection>' |
|
| 268 | '<vt_group filter="a"/>' |
|
| 269 | '</vt_selection>' |
|
| 270 | '</start_scan>' |
|
| 271 | ) |
|
| 272 | response = et.fromstring(cmd.handle_xml(request)) |
|
| 273 | scan_id = response.findtext('id') |
|
| 274 | ||