def __init__(self, context, config, print_output): """RuleProcessorTester initializer Args: print_output (bool): Whether this processor test should print results to stdout. This is set to false when the alert processor is explicitly being testing alone, and set to true for rule processor tests and end-to-end tests. Warnings and errors captrued during rule processor testing will still be written to stdout regardless of this setting. """ # Create the RuleProcessor. Passing a mocked context object with fake # values and False for suppressing sending of alerts to alert processor self.processor = StreamAlert(context) self.cli_config = config # Use a list of status_messages to store pass/fail/warning info self.status_messages = [] self.total_tests = 0 self.all_tests_passed = True self.print_output = print_output # Configure mocks for Firehose and DDB helpers.setup_mock_firehose_delivery_streams(config) helpers.setup_mock_dynamodb_ioc_table(config) # Create a cache map of parsers to parser classes self.parsers = {} # Patch the tmp shredding as to not slow down testing patch( 'stream_alert.rule_processor.payload.S3Payload._shred_temp_directory' ).start() # Patch random_bool to always return true patch('helpers.base.random_bool', return_value=True).start()
def __init__(self, context, config, print_output): """RuleProcessorTester initializer Args: print_output (bool): Whether this processor test should print results to stdout. This is set to false when the alert processor is explicitly being testing alone, and set to true for rule processor tests and end-to-end tests. Warnings and errors captrued during rule processor testing will still be written to stdout regardless of this setting. """ helpers.setup_mock_dynamodb_ioc_table(config) # Create the RuleProcessor. Passing a mocked context object with fake # values and False for suppressing sending of alerts to alert processor self.processor = StreamAlert(context, False) self.cli_config = config # Use a list of status_messages to store pass/fail/warning info self.status_messages = [] self.total_tests = 0 self.all_tests_passed = True self.print_output = print_output helpers.setup_mock_firehose_delivery_streams(config)