def parse_config(self): default_config = os.path.join(os.path.dirname(__file__), "config.conf") options = DotDict() options.configfile = default_config options.esservers = list( getConfig('esservers', 'http://localhost:9200', options.configfile).split(',')) options.alertExchange = getConfig('alertexchange', 'alerts', options.configfile) options.queueName = getConfig('alertqueuename', 'alertBot', options.configfile) options.alerttopic = getConfig('alerttopic', 'mozdef.*', options.configfile) options.mquser = getConfig('mquser', 'guest', options.configfile) options.mqalertserver = getConfig('mqalertserver', 'localhost', options.configfile) options.mqpassword = getConfig('mqpassword', 'guest', options.configfile) options.mqport = getConfig('mqport', 5672, options.configfile) options.mqack = getConfig('mqack', True, options.configfile) self.options = options
def parse_config_file(): global CONFIG_FILE_CONTENTS try: CONFIG_FILE_CONTENTS except NameError: default_config = os.path.join(os.path.dirname(__file__), "config.conf") options = DotDict() options.configfile = default_config options.esservers = list( getConfig('esservers', 'http://localhost:9200', options.configfile).split(',')) options.alertExchange = getConfig('alertexchange', 'alerts', options.configfile) options.queueName = getConfig('alertqueuename', 'alertBot', options.configfile) options.alerttopic = getConfig('alerttopic', 'mozdef.*', options.configfile) options.mquser = getConfig('mquser', 'guest', options.configfile) options.mqalertserver = getConfig('mqalertserver', 'localhost', options.configfile) options.mqpassword = getConfig('mqpassword', 'guest', options.configfile) options.mqport = getConfig('mqport', 5672, options.configfile) options.mqack = getConfig('mqack', True, options.configfile) CONFIG_FILE_CONTENTS = options return CONFIG_FILE_CONTENTS
def setup(self): sample_config = DotDict() sample_config.configfile = os.path.join(os.path.dirname(__file__), '../../loginput/index.conf') OptionParser.parse_args = mock.Mock(return_value=(sample_config, {})) from loginput import index self.application = index.application super(LoginputTestSuite, self).setup()
import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), "../")) from http_test_suite import HTTPTestSuite sys.path.append(os.path.join(os.path.dirname(__file__), "../../lib")) from utilities.dot_dict import DotDict import mock from configlib import OptionParser sample_config = DotDict() sample_config.configfile = os.path.join(os.path.dirname(__file__), '../../rest/index.conf') OptionParser.parse_args = mock.Mock(return_value=(sample_config, {})) sys.path.append(os.path.join(os.path.dirname(__file__), "../../")) class RestTestSuite(HTTPTestSuite): def setup(self): from rest import index self.application = index.application super(RestTestSuite, self).setup()