| @@ 551-575 (lines=25) @@ | ||
| 548 | scan_id = response.findtext('id') |
|
| 549 | print(scan_id) |
|
| 550 | finished = False |
|
| 551 | while not finished: |
|
| 552 | fs = FakeStream() |
|
| 553 | daemon.handle_command( |
|
| 554 | '<get_scans scan_id="%s" details="1"/>' % scan_id, fs |
|
| 555 | ) |
|
| 556 | response = fs.get_response() |
|
| 557 | ||
| 558 | scans = response.findall('scan') |
|
| 559 | self.assertEqual(1, len(scans)) |
|
| 560 | ||
| 561 | scan = scans[0] |
|
| 562 | status = scan.get('status') |
|
| 563 | ||
| 564 | if status == "init" or status == "running": |
|
| 565 | self.assertEqual('0', scan.get('end_time')) |
|
| 566 | time.sleep(0.010) |
|
| 567 | else: |
|
| 568 | finished = True |
|
| 569 | ||
| 570 | fs = FakeStream() |
|
| 571 | ||
| 572 | daemon.handle_command( |
|
| 573 | '<get_scans scan_id="%s" details="1"/>' % scan_id, fs |
|
| 574 | ) |
|
| 575 | response = fs.get_response() |
|
| 576 | ||
| 577 | self.assertEqual( |
|
| 578 | response.findtext('scan/results/result'), 'something went wrong' |
|
| @@ 498-521 (lines=24) @@ | ||
| 495 | ||
| 496 | finished = False |
|
| 497 | ||
| 498 | while not finished: |
|
| 499 | fs = FakeStream() |
|
| 500 | daemon.handle_command( |
|
| 501 | '<get_scans scan_id="%s" details="1"/>' % scan_id, fs |
|
| 502 | ) |
|
| 503 | response = fs.get_response() |
|
| 504 | ||
| 505 | scans = response.findall('scan') |
|
| 506 | self.assertEqual(1, len(scans)) |
|
| 507 | ||
| 508 | scan = scans[0] |
|
| 509 | status = scan.get('status') |
|
| 510 | ||
| 511 | if status == "init" or status == "running": |
|
| 512 | self.assertEqual('0', scan.get('end_time')) |
|
| 513 | time.sleep(0.010) |
|
| 514 | else: |
|
| 515 | finished = True |
|
| 516 | ||
| 517 | fs = FakeStream() |
|
| 518 | daemon.handle_command( |
|
| 519 | '<get_scans scan_id="%s" details="1"/>' % scan_id, fs |
|
| 520 | ) |
|
| 521 | response = fs.get_response() |
|
| 522 | ||
| 523 | self.assertEqual(len(list(daemon.scan_collection.ids_iterator())), 1) |
|
| 524 | ||