Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def present_results_ssh(self):
        """Check whether the connection between server and client using
        SSH protocol is blocked or not.

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

        logger.info("Test SSH")
        if test_utils.is_ssh_blocked(self.client_floating_ip, self.server_ip):
            results.add_to_summary(2, "PASS", "SSH Blocked")
        else:
            error = ('\033[91mTEST [FAILED] ==> SSH NOT 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", "SSH Works")

        return results
Ejemplo n.º 3
0
    def test_capture_ovs_logs(self,
                              mock_ovs_log,
                              mock_strftime):
        """
        Checks the proper functionality of capture_ovs_logs
        function
        """

        log_calls = [call('controller_clients',
                          'compute_clients',
                          'error',
                          'date_time')]

        mock_strftime.return_value = 'date_time'
        test_utils.capture_ovs_logs(mock_ovs_log,
                                    'controller_clients',
                                    'compute_clients',
                                    'error')

        mock_strftime.assert_called_once_with('%Y%m%d-%H%M%S')
        mock_ovs_log.dump_ovs_logs.assert_has_calls(log_calls)
Ejemplo n.º 4
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
Ejemplo n.º 5
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