Skip to content

Commit

Permalink
feat: Add unit tests for NexposeScanner
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Oct 30, 2023
1 parent 2c720dc commit 3223bf6
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/test_nexpose_scanner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import unittest
from unittest.mock import Mock, patch
from scanners.nexpose_scanner import NexposeScanner

class TestNexposeScanner(unittest.TestCase):
def setUp(self):
self.nexpose_mock = Mock()
self.storage_service_mock = Mock()
self.nexpose_scanner = NexposeScanner()
self.nexpose_scanner.nexpose = self.nexpose_mock
self.nexpose_scanner.storage_service = self.storage_service_mock

def test_start(self):
self.nexpose_scanner.start('test_scan', 'http://test_target')
self.nexpose_mock.start_scan.assert_called_once()

def test_scan(self):
self.nexpose_scanner.scan('test_scan', 'http://test_target')
self.nexpose_mock.start_scan.assert_called_once()

def test_get_scan_status(self):
self.nexpose_scanner.get_scan_status('test_scan')
self.nexpose_mock.get_scan.assert_called_once()

def test_get_scan_results(self):
self.nexpose_scanner.get_scan_results('test_scan')
self.nexpose_mock.download_report.assert_called_once()

def test_is_valid_scan(self):
self.nexpose_scanner.is_valid_scan('test_scan')
self.nexpose_mock.get_scan.assert_called_once()

def test_pause(self):
self.nexpose_scanner.pause('test_scan')
self.nexpose_mock.set_scan_status.assert_called_once_with('pause')

def test_resume(self):
self.nexpose_scanner.resume('test_scan')
self.nexpose_mock.set_scan_status.assert_called_once_with('resume')

def test_stop(self):
self.nexpose_scanner.stop('test_scan')
self.nexpose_mock.set_scan_status.assert_called_once_with('stop')

def test_remove(self):
self.nexpose_scanner.remove('test_scan')
self.nexpose_mock.set_scan_status.assert_called_once_with('remove')

def test_list_scans(self):
self.nexpose_scanner.list_scans()
self.nexpose_mock.get_scans.assert_called_once()

if __name__ == '__main__':
unittest.main()

0 comments on commit 3223bf6

Please sign in to comment.