예제 #1
0
    def test__run_scan(self, mock_nmap_factory):
        mock_nmap = MagicMock()
        mock_nmap_factory.return_value = mock_nmap

        mock_nmap.run.return_value = 0
        mock_nmap.stdout = MOCK_SCAN_RESULT

        now = datetime(2015, 11, 4)
        res = [r for r in _run_scan(['1.1.1.1', '2.2.2.2'], now)]
        self.assertEquals(res, [
            {
                'observation_type': 'scan_observation_v1',
                'time': now.isoformat(),
                'source': '192.168.1.42',
                'ports': '',
                'info_type': 'services',
                'result': '',
            },
            {
                'observation_type': 'scan_observation_v1',
                'time': now.isoformat(),
                'source': '192.168.1.1',
                'ports': '22/closed, 80/open, 443/open',
                'info_type': 'services',
                'result': '',
            },
        ])
예제 #2
0
파일: test_nmapper.py 프로젝트: obsrvbl/ona
    def test__run_scan(self, mock_nmap_factory):
        mock_nmap = MagicMock()
        mock_nmap_factory.return_value = mock_nmap

        mock_nmap.run.return_value = 0
        mock_nmap.stdout = MOCK_SCAN_RESULT

        now = datetime(2015, 11, 4)
        res = [r for r in _run_scan(['1.1.1.1', '2.2.2.2'], now)]
        self.assertEquals(res, [
            {
                'observation_type': 'scan_observation_v1',
                'time': now.isoformat(),
                'source': '192.168.1.42',
                'ports': '',
                'info_type': 'services',
                'result': '',
            },
            {
                'observation_type': 'scan_observation_v1',
                'time': now.isoformat(),
                'source': '192.168.1.1',
                'ports': '22/closed, 80/open, 443/open',
                'info_type': 'services',
                'result': '',
            },
        ])
예제 #3
0
    def test__run_scan__bad_parse(self, mock_nmap_factory):
        mock_nmap = MagicMock()
        mock_nmap_factory.return_value = mock_nmap

        mock_nmap.run.return_value = 0
        mock_nmap.stdout = 'foo'
        now = datetime(2015, 11, 4)

        self.assertIsNone(_run_scan(['1.1.1.1', '2.2.2.2'], now))
예제 #4
0
    def test__run_scan__bad_parse(self, mock_nmap_factory):
        mock_nmap = MagicMock()
        mock_nmap_factory.return_value = mock_nmap

        mock_nmap.run.return_value = 0
        mock_nmap.stdout = 'foo'
        now = datetime(2015, 11, 4)

        res = [r for r in _run_scan(['1.1.1.1', '2.2.2.2'], now)]
        self.assertEquals(res, [])
예제 #5
0
파일: test_nmapper.py 프로젝트: obsrvbl/ona
    def test__run_scan__bad_parse(self, mock_nmap_factory):
        mock_nmap = MagicMock()
        mock_nmap_factory.return_value = mock_nmap

        mock_nmap.run.return_value = 0
        mock_nmap.stdout = 'foo'
        now = datetime(2015, 11, 4)

        res = [r for r in _run_scan(['1.1.1.1', '2.2.2.2'], now)]
        self.assertEquals(res, [])