Esempio n. 1
0
    def test_blocked_scan(self):
        """
        Checks whether scanner does not hang if packets are dropped.
        """

        self.listening_thread.start()
        self._start_port_blocker()
        results = scan.scan(self.endpoints)
        self._check_results(results)
Esempio n. 2
0
    def test_no_endpoints_scan(self):
        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint.
        """

        result = scan.scan([])
        self.assertEqual(len(result), 0)
    def test_blocked_scan(self):

        """
        Checks whether scanner does not hang if packets are dropped.
        """

        self.listening_thread.start()
        self._start_port_blocker()
        results = scan.scan(self.endpoints)
        self._check_results(results)
Esempio n. 4
0
    def test_normal_scan(self):
        """
        A normal use case.

        Checks whether the scan mechanism works as expected.
        """

        self.listening_thread.start()
        results = scan.scan(self.endpoints)
        self._check_results(results)
Esempio n. 5
0
    def test_single_closed_endpoint_scan(self):
        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint that is closed.
        """

        result = scan.scan([('127.0.0.1', self._invalid_ports[0])])
        self.assertEqual(len(result), 1)
        self._check_results(result)
    def test_normal_scan(self):

        """
        A normal use case.

        Checks whether the scan mechanism works as expected.
        """

        self.listening_thread.start()
        results = scan.scan(self.endpoints)
        self._check_results(results)
    def test_no_endpoints_scan(self):

        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint.
        """

        result = scan.scan([])
        self.assertEqual(len(result), 0)
    def test_single_closed_endpoint_scan(self):

        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint that is closed.
        """

        result = scan.scan([('127.0.0.1', self._invalid_ports[0])])
        self.assertEqual(len(result), 1)
        self._check_results(result)
Esempio n. 9
0
    def test_normal_scan_with_multiple_endpoints(self):
        """
        A normal use case.

        Checks whether the scan mechanism works as expected.
        """

        endpoints = self.endpoints * _MAGIC_NUMBER_ENDPOINTS_MULTIPLIER
        random.shuffle(endpoints)
        self.listening_thread.start()
        results = scan.scan(endpoints)
        self._check_results(results)
Esempio n. 10
0
    def test_all_closed_blocked_scan(self):
        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        only blocked endpoints.
        """

        self.listening_thread.start()
        self._start_port_blocker()
        results = scan.scan(self.endpoints)
        self._check_results(results)
Esempio n. 11
0
    def test_single_blocked_endpoint_scan(self):
        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint that is initially blocked.
        """

        self._start_port_blocker([self._invalid_ports[0]])
        result = scan.scan([('127.0.0.1', self._invalid_ports[0])])
        self.assertEqual(len(result), 1)
        self._check_results(result)
Esempio n. 12
0
    def test_single_open_endpoint_scan(self):
        """"
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint that is open.
        """

        self.listening_thread.start()
        result = scan.scan([('127.0.0.1', self._free_ports[0])])
        self.assertEqual(len(result), 1)
        self._check_results(result)
    def test_normal_scan_with_multiple_endpoints(self):

        """
        A normal use case.

        Checks whether the scan mechanism works as expected.
        """

        endpoints = self.endpoints * _MAGIC_NUMBER_ENDPOINTS_MULTIPLIER
        random.shuffle(endpoints)
        self.listening_thread.start()
        results = scan.scan(endpoints)
        self._check_results(results)
    def test_all_closed_blocked_scan(self):

        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        only blocked endpoints.
        """

        self.listening_thread.start()
        self._start_port_blocker()
        results = scan.scan(self.endpoints)
        self._check_results(results)
    def test_single_blocked_endpoint_scan(self):

        """
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint that is initially blocked.
        """

        self._start_port_blocker([self._invalid_ports[0]])
        result = scan.scan([('127.0.0.1', self._invalid_ports[0])])
        self.assertEqual(len(result), 1)
        self._check_results(result)
    def test_single_open_endpoint_scan(self):

        """"
        An edge case.

        Checks whether the scan mechanism works correctly with
        a single endpoint that is open.
        """

        self.listening_thread.start()
        result = scan.scan([('127.0.0.1', self._free_ports[0])])
        self.assertEqual(len(result), 1)
        self._check_results(result)
Esempio n. 17
0
    def test_fully_dropped_endpoint_scan(self):
        """
        An edge case.

        Checks whether the scan mechanism works correctly
        if packets on the target endpoint are endlessly dropped.
        """

        port = self._invalid_ports[0]
        _iptables_block(port)
        # This may take a while (depends on the operating system)...
        try:
            result = scan.scan([('127.0.0.1', self._invalid_ports[0])])
            self.assertEqual(len(result), 1)
            self._check_results(result)
        finally:
            _iptables_unblock(port)
    def test_fully_dropped_endpoint_scan(self):

        """
        An edge case.

        Checks whether the scan mechanism works correctly
        if packets on the target endpoint are endlessly dropped.
        """

        port = self._invalid_ports[0]
        _iptables_block(port)
        # This may take a while (depends on the operating system)...
        try:
            result = scan.scan([('127.0.0.1', self._invalid_ports[0])])
            self.assertEqual(len(result), 1)
            self._check_results(result)
        finally:
            _iptables_unblock(port)
 def _is_alive(host):
     address, port = host['host'], host['port']
     results = scan.scan([(address, port)])
     return results[address, port]
Esempio n. 20
0
 def _is_alive(host):
     address, port = host['host'], host['port']
     results = scan.scan([(address, port)])
     return results[address, port]