| @@ 623-658 (lines=36) @@ | ||
| 620 | ||
| 621 | self.assertEqual(response.findtext('scan/results/result'), None) |
|
| 622 | ||
| 623 | def test_get_scan_pop_max_res(self): |
|
| 624 | daemon = DummyWrapper( |
|
| 625 | [ |
|
| 626 | Result('host-detail', value='Some Host Detail'), |
|
| 627 | Result('host-detail', value='Some Host Detail1'), |
|
| 628 | Result('host-detail', value='Some Host Detail2'), |
|
| 629 | ] |
|
| 630 | ) |
|
| 631 | fs = FakeStream() |
|
| 632 | daemon.handle_command( |
|
| 633 | '<start_scan target="localhost" ports="80, 443">' |
|
| 634 | '<scanner_params /></start_scan>', |
|
| 635 | fs, |
|
| 636 | ) |
|
| 637 | response = fs.get_response() |
|
| 638 | ||
| 639 | scan_id = response.findtext('id') |
|
| 640 | time.sleep(1) |
|
| 641 | ||
| 642 | fs = FakeStream() |
|
| 643 | daemon.handle_command( |
|
| 644 | '<get_scans scan_id="%s" pop_results="1" max_results="1"/>' |
|
| 645 | % scan_id, |
|
| 646 | fs, |
|
| 647 | ) |
|
| 648 | response = fs.get_response() |
|
| 649 | ||
| 650 | self.assertEqual(len(response.findall('scan/results/result')), 1) |
|
| 651 | ||
| 652 | fs = FakeStream() |
|
| 653 | daemon.handle_command( |
|
| 654 | '<get_scans scan_id="%s" pop_results="1"/>' % scan_id, fs |
|
| 655 | ) |
|
| 656 | response = fs.get_response() |
|
| 657 | ||
| 658 | self.assertEqual(len(response.findall('scan/results/result')), 2) |
|
| 659 | ||
| 660 | def test_billon_laughs(self): |
|
| 661 | # pylint: disable=line-too-long |
|
| @@ 586-621 (lines=36) @@ | ||
| 583 | ||
| 584 | self.assertEqual(response.get('status'), '200') |
|
| 585 | ||
| 586 | def test_get_scan_pop(self): |
|
| 587 | daemon = DummyWrapper([Result('host-detail', value='Some Host Detail')]) |
|
| 588 | fs = FakeStream() |
|
| 589 | ||
| 590 | daemon.handle_command( |
|
| 591 | '<start_scan target="localhost" ports="80, 443">' |
|
| 592 | '<scanner_params /></start_scan>', |
|
| 593 | fs, |
|
| 594 | ) |
|
| 595 | response = fs.get_response() |
|
| 596 | ||
| 597 | scan_id = response.findtext('id') |
|
| 598 | time.sleep(1) |
|
| 599 | ||
| 600 | fs = FakeStream() |
|
| 601 | daemon.handle_command('<get_scans scan_id="%s"/>' % scan_id, fs) |
|
| 602 | response = fs.get_response() |
|
| 603 | ||
| 604 | self.assertEqual( |
|
| 605 | response.findtext('scan/results/result'), 'Some Host Detail' |
|
| 606 | ) |
|
| 607 | fs = FakeStream() |
|
| 608 | daemon.handle_command( |
|
| 609 | '<get_scans scan_id="%s" pop_results="1"/>' % scan_id, fs |
|
| 610 | ) |
|
| 611 | response = fs.get_response() |
|
| 612 | ||
| 613 | self.assertEqual( |
|
| 614 | response.findtext('scan/results/result'), 'Some Host Detail' |
|
| 615 | ) |
|
| 616 | ||
| 617 | fs = FakeStream() |
|
| 618 | daemon.handle_command('<get_scans details="0" pop_results="1"/>', fs) |
|
| 619 | response = fs.get_response() |
|
| 620 | ||
| 621 | self.assertEqual(response.findtext('scan/results/result'), None) |
|
| 622 | ||
| 623 | def test_get_scan_pop_max_res(self): |
|
| 624 | daemon = DummyWrapper( |
|