| @@ 328-353 (lines=26) @@ | ||
| 325 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 326 | ) |
|
| 327 | ||
| 328 | def test_get_vts_filter_negative(self): |
|
| 329 | daemon = DummyWrapper([]) |
|
| 330 | daemon.add_vt( |
|
| 331 | '1.2.3.4', |
|
| 332 | 'A vulnerability test', |
|
| 333 | vt_params="a", |
|
| 334 | vt_modification_time='19000202', |
|
| 335 | ) |
|
| 336 | ||
| 337 | response = secET.fromstring( |
|
| 338 | daemon.handle_command( |
|
| 339 | '<get_vts filter="modification_time<19000203"></get_vts>' |
|
| 340 | ) |
|
| 341 | ) |
|
| 342 | self.assertEqual(response.get('status'), '200') |
|
| 343 | ||
| 344 | vts = response.find('vts') |
|
| 345 | ||
| 346 | vt = vts.find('vt') |
|
| 347 | self.assertIsNotNone(vt) |
|
| 348 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 349 | ||
| 350 | modification_time = response.findall('vts/vt/modification_time') |
|
| 351 | self.assertEqual( |
|
| 352 | '<modification_time>19000202</modification_time>', |
|
| 353 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 354 | ) |
|
| 355 | ||
| 356 | def test_get_vtss_multiple_vts(self): |
|
| @@ 300-325 (lines=26) @@ | ||
| 297 | vt = vts.find('vt') |
|
| 298 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 299 | ||
| 300 | def test_get_vts_filter_positive(self): |
|
| 301 | daemon = DummyWrapper([]) |
|
| 302 | daemon.add_vt( |
|
| 303 | '1.2.3.4', |
|
| 304 | 'A vulnerability test', |
|
| 305 | vt_params="a", |
|
| 306 | vt_modification_time='19000202', |
|
| 307 | ) |
|
| 308 | ||
| 309 | response = secET.fromstring( |
|
| 310 | daemon.handle_command( |
|
| 311 | '<get_vts filter="modification_time>19000201"></get_vts>' |
|
| 312 | ) |
|
| 313 | ) |
|
| 314 | ||
| 315 | self.assertEqual(response.get('status'), '200') |
|
| 316 | vts = response.find('vts') |
|
| 317 | ||
| 318 | vt = vts.find('vt') |
|
| 319 | self.assertIsNotNone(vt) |
|
| 320 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 321 | ||
| 322 | modification_time = response.findall('vts/vt/modification_time') |
|
| 323 | self.assertEqual( |
|
| 324 | '<modification_time>19000202</modification_time>', |
|
| 325 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 326 | ) |
|
| 327 | ||
| 328 | def test_get_vts_filter_negative(self): |
|