def test_verify_config_no_section(self): ops = {} try: verify_config(ops) except ValueError as e: assert e.args[ 0] == "[fn_mcafee_opendxl] section is not set in the config file"
def test_verify_config_no_incident_mapping(self): ops = ConfigClass().ops ops["fn_mcafee_opendxl"]["incident_mapping"] = None try: verify_config(ops) except ValueError as e: assert e.args[ 0] == "incident_mapping is not set. You must set this path to run this service"
def test_verify_config_no_topic_listener(self): ops = ConfigClass().ops ops["fn_mcafee_opendxl"]["topic_listener_on"] = None try: verify_config(ops) except ValueError as e: assert e.args[ 0] == "topic_listener_on is not set. You must set this value to run this service"
def test_verify_config_no_config_client(self): f = ConfigClass().ops f["fn_mcafee_opendxl"]["dxlclient_config"] = None try: verify_config(f) except ValueError as e: assert e.args[ 0] == "dxlclient_config is not set. You must set this path to run this service"
def test_verify_config_good(self): ops = ConfigClass().ops config = verify_config(ops) expected = { "config_client": ops["fn_mcafee_opendxl"]["dxlclient_config"], "topic_listener_on": ops["fn_mcafee_opendxl"]["topic_listener_on"], "custom_template_dir": None, "opts": ops } assert expected == config
def __init__(self, opts): super(DxlComponentSubscriber, self).__init__(opts) self.config = verify_config(opts) add_methods_to_global() # Create and connect DXL client config_client_file = self.config.get("config_client") dxl_config = DxlClientConfig.create_dxl_config_from_file( config_client_file) self.client = DxlClient(dxl_config) self.client.connect() # This gets run once to tell the subscriber to listen on defined topics self.main()