def write_to_lookup_table_command(): lookup_table_name = demisto.args()['lookupTableName'] headers = check_type(demisto.args()['headers'], list) records = check_type(demisto.args()['records'], list) creds = get_writer_creds() engine_config = SenderConfigSSL(address=(WRITER_RELAY, 443), key=creds['key'].name, cert=creds['crt'].name, chain=creds['chain'].name) try: con = Sender(config=engine_config, timeout=60) lookup = Lookup(name=lookup_table_name, historic_tag=None, con=con) # Order sensitive list pHeaders = json.dumps(headers) lookup.send_control('START', pHeaders, 'INC') for r in records: lookup.send_data_line(key=r['key'], fields=r['values']) lookup.send_control('END', pHeaders, 'INC') finally: con.flush_buffer() con.socket.shutdown(0) entry = { 'Type': entryTypes['note'], 'Contents': { 'recordsWritten': records }, 'ContentsFormat': formats['json'], 'ReadableContentsFormat': formats['markdown'], 'EntryContext': { 'Devo.RecordsWritten': records } } md = tableToMarkdown('Entries to load into Devo', records) entry['HumanReadable'] = md return [entry]
def test_ssl_zip_send(self): """ Test that tries to send a message through a ssl connection """ try: engine_config = SenderConfigSSL(address=self.server, port=self.port, key=self.key, cert=self.cert, chain=self.chain) con = Sender(engine_config) for i in range(0, self.default_numbers_sendings): con.send(tag=self.my_bapp, msg=b'Test SSL msg_ python_sdk_ fork', zip=True) con.flush_buffer() con.close() except Exception as error: self.fail("Problems with test: %s" % error)
def test_ssl_zip_send(self): """ Test that tries to send a message through a ssl connection """ try: engine_config = SenderConfigSSL(address=(self.server, self.port), key=self.key, cert=self.cert, chain=self.chain) con = Sender(engine_config, timeout=15) for i in range(self.default_numbers_sendings): con.send(tag=self.my_bapp, msg=self.test_msg.encode("utf-8"), zip=True) con.flush_buffer() if len(con.socket.recv(1000)) == 0: raise Exception('Not msg sent!') con.close() except Exception as error: self.fail("Problems with test: %s" % str(error))
def test_multiline_send(self): """ Test that tries to send a multiple line message through a ssl connection """ try: engine_config = SenderConfigSSL(address=(self.server, self.port), key=self.key, cert=self.cert, chain=self.chain) con = Sender(engine_config) with open(self.test_file, 'r') as file: content = file.read() con.send(tag=self.my_app, msg=content, multiline=True) con.flush_buffer() if len(con.socket.recv(5000)) == 0: raise Exception('Not msg sent!') con.close() except Exception as error: self.fail("Problems with test: %s" % error)