Esempio n. 1
0
    def test_is_http_blocked_returned_true(self, mock_netcat):
        """
        Checks the proper funcitonality of is_http_blocked
        function when the returncode is non-zero integer
        """

        dest_ip = 'mock_destination_ip'
        nc_calls = [call('10.10.10.10',
                         'mock_destination_ip',
                         destination_port='80',
                         source_port=None)]

        mock_netcat.return_value = 1
        self.assertTrue(test_utils.is_http_blocked(self.ip, dest_ip))
        mock_netcat.assert_has_calls(nc_calls)
Esempio n. 2
0
    def present_results_allowed_http(self):
        """Check whether the connection between server and client using
        HTTP protocol is available or not.

        :return: The results for the specific action of the scenario
        """

        if not test_utils.is_http_blocked(self.client_floating_ip,
                                          self.server_ip):
            results.add_to_summary(2, "PASS", "HTTP works")
        else:
            error = ('\033[91mTEST [FAILED] ==> HTTP BLOCKED\033[0m')
            logger.error(error)
            test_utils.capture_ovs_logs(
                self.ovs_logger, self.controller_clients, self.compute_clients,
                error)
            results.add_to_summary(2, "FAIL", "HTTP is blocked")

        return results
Esempio n. 3
0
    def present_results_allowed_port_http(self, testcase_config):
        """Check whether the connection between server and client using
        HTTP protocol and for a specific port is available or not.

        :param testcase_config: The config input of the test case
        :return: The results for the specific action of the scenario
        """

        allowed_port = testcase_config.source_port
        logger.info("Test if HTTP from port %s works" % allowed_port)
        if not test_utils.is_http_blocked(
                self.client_floating_ip, self.server_ip, allowed_port):
            results.add_to_summary(2, "PASS", "HTTP works")
        else:
            error = ('\033[91mTEST [FAILED] ==> HTTP BLOCKED\033[0m')
            logger.error(error)
            test_utils.capture_ovs_logs(
                self.ovs_logger, self.controller_clients, self.compute_clients,
                error)
            results.add_to_summary(2, "FAIL", "HTTP is blocked")

        return results
Esempio n. 4
0
    def present_results_blocked_port_http(self, testcase_config, test='HTTP'):
        """Check whether the connection between server and client using
        HTTP protocol and for a specific port is blocked or not.

        :param testcase_config: The config input of the test case
        :param test: custom test string to print on result summary
        :return: The results for the specific action of the scenario
        """

        allowed_port = testcase_config.source_port
        logger.info("Test if HTTP from port %s doesn't work" % allowed_port)
        if test_utils.is_http_blocked(self.client_floating_ip, self.server_ip,
                                      allowed_port):
            results.add_to_summary(2, "PASS", test + " blocked")
        else:
            error = ('\033[91mTEST [FAILED] ==> HTTP WORKS\033[0m')
            logger.error(error)
            test_utils.capture_ovs_logs(self.ovs_logger,
                                        self.controller_clients,
                                        self.compute_clients, error)
            results.add_to_summary(2, "FAIL", test + " works")

        return results