def test_scanLogs_argument_instanceId_of_invalid_type_should_raise_TypeError(self): """ Test scanLogs(self, instanceId, limit=None, fromRowId=None, reverse=False) """ sfdb = SpiderFootDb(self.default_options, False) limit = None from_row_id = None reverse = None invalid_types = [None, list(), dict(), int()] for invalid_type in invalid_types: with self.subTest(invalid_type=invalid_type): with self.assertRaises(TypeError): sfdb.scanLogs(invalid_type, limit, from_row_id, reverse)
def scanlog(self, id, limit=None, rowId=None, reverse=None): """Scan log data Args: id: TBD limit: TBD rowId: TBD reverse: TBD """ cherrypy.response.headers['Content-Type'] = "application/json; charset=utf-8" dbh = SpiderFootDb(self.config) retdata = [] try: data = dbh.scanLogs(id, limit, rowId, reverse) except Exception: return json.dumps(retdata).encode('utf-8') for row in data: generated = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(row[0] / 1000)) retdata.append([generated, row[1], row[2], html.escape(row[3]), row[4]]) return json.dumps(retdata).encode('utf-8')
def scanlog(self, id, limit=None, rowId=None, reverse=None): """Scan log data Args: id: TBD limit: TBD rowId: TBD reverse: TBD Returns: str: JSON """ dbh = SpiderFootDb(self.config) retdata = [] try: data = dbh.scanLogs(id, limit, rowId, reverse) except Exception: return retdata for row in data: generated = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(row[0] / 1000)) retdata.append([generated, row[1], row[2], html.escape(row[3]), row[4]]) return retdata
def test_scanLogs_should_return_a_list(self): """ Test scanLogs(self, instanceId, limit=None, fromRowId=None, reverse=False) """ sfdb = SpiderFootDb(self.default_options, False) instance_id = "example instance id" scan_logs = sfdb.scanLogs(instance_id, None, None, None) self.assertIsInstance(scan_logs, list) self.assertEqual('TBD', 'TBD')