| @@ 287-312 (lines=26) @@ | ||
| 284 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 285 | ) |
|
| 286 | ||
| 287 | def test_get_vts_filter_negative(self): |
|
| 288 | daemon = DummyWrapper([]) |
|
| 289 | daemon.add_vt( |
|
| 290 | '1.2.3.4', |
|
| 291 | 'A vulnerability test', |
|
| 292 | vt_params="a", |
|
| 293 | vt_modification_time='19000202', |
|
| 294 | ) |
|
| 295 | ||
| 296 | response = secET.fromstring( |
|
| 297 | daemon.handle_command( |
|
| 298 | '<get_vts filter="modification_time<19000203"></get_vts>' |
|
| 299 | ) |
|
| 300 | ) |
|
| 301 | self.assertEqual(response.get('status'), '200') |
|
| 302 | ||
| 303 | vts = response.find('vts') |
|
| 304 | ||
| 305 | vt = vts.find('vt') |
|
| 306 | self.assertIsNotNone(vt) |
|
| 307 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 308 | ||
| 309 | modification_time = response.findall('vts/vt/modification_time') |
|
| 310 | self.assertEqual( |
|
| 311 | '<modification_time>19000202</modification_time>', |
|
| 312 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 313 | ) |
|
| 314 | ||
| 315 | def test_get_vtss_multiple_vts(self): |
|
| @@ 259-284 (lines=26) @@ | ||
| 256 | vt = vts.find('vt') |
|
| 257 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 258 | ||
| 259 | def test_get_vts_filter_positive(self): |
|
| 260 | daemon = DummyWrapper([]) |
|
| 261 | daemon.add_vt( |
|
| 262 | '1.2.3.4', |
|
| 263 | 'A vulnerability test', |
|
| 264 | vt_params="a", |
|
| 265 | vt_modification_time='19000202', |
|
| 266 | ) |
|
| 267 | ||
| 268 | response = secET.fromstring( |
|
| 269 | daemon.handle_command( |
|
| 270 | '<get_vts filter="modification_time>19000201"></get_vts>' |
|
| 271 | ) |
|
| 272 | ) |
|
| 273 | ||
| 274 | self.assertEqual(response.get('status'), '200') |
|
| 275 | vts = response.find('vts') |
|
| 276 | ||
| 277 | vt = vts.find('vt') |
|
| 278 | self.assertIsNotNone(vt) |
|
| 279 | self.assertEqual(vt.get('id'), '1.2.3.4') |
|
| 280 | ||
| 281 | modification_time = response.findall('vts/vt/modification_time') |
|
| 282 | self.assertEqual( |
|
| 283 | '<modification_time>19000202</modification_time>', |
|
| 284 | ET.tostring(modification_time[0]).decode('utf-8'), |
|
| 285 | ) |
|
| 286 | ||
| 287 | def test_get_vts_filter_negative(self): |
|