def testNoLogsIfBtimeSupported(self, db: abstract_db.Database): client_id = self.client_id db.WriteClientMetadata(client_id, fleetspeak_enabled=True) snapshot = rdf_objects.ClientSnapshot() snapshot.client_id = client_id snapshot.knowledge_base.os = "Linux" snapshot.startup_info.client_info.timeline_btime_support = True db.WriteClientSnapshot(snapshot) with temp.AutoTempDirPath() as tempdir: args = rdf_timeline.TimelineArgs(root=tempdir.encode("utf-8")) flow_id = flow_test_lib.TestFlowHelper( timeline_flow.TimelineFlow.__name__, action_mocks.ActionMock(timeline_action.Timeline), client_id=client_id, creator=self.test_username, args=args) flow_test_lib.FinishAllFlowsOnClient(client_id) log_entries = db.ReadFlowLogEntries(client_id, flow_id, offset=0, count=1) self.assertEmpty(log_entries)
def testLogsWarningIfBtimeNotSupported(self, db: abstract_db.Database): client_id = self.client_id db.WriteClientMetadata(client_id, fleetspeak_enabled=True) snapshot = rdf_objects.ClientSnapshot() snapshot.client_id = client_id snapshot.knowledge_base.os = "Linux" snapshot.startup_info.client_info.timeline_btime_support = False db.WriteClientSnapshot(snapshot) with temp.AutoTempDirPath() as tempdir: args = rdf_timeline.TimelineArgs(root=tempdir.encode("utf-8")) flow_id = flow_test_lib.TestFlowHelper( timeline_flow.TimelineFlow.__name__, action_mocks.ActionMock(timeline_action.Timeline), client_id=client_id, token=self.token, args=args) flow_test_lib.FinishAllFlowsOnClient(client_id) log_entries = db.ReadFlowLogEntries(client_id, flow_id, offset=0, count=1) self.assertLen(log_entries, 1) self.assertRegex(log_entries[0].message, "birth time is not supported")
def testLogWithoutFormatArgs(self, db: abstract_db.Database) -> None: client_id = db_test_utils.InitializeClient(db) flow = rdf_flow_objects.Flow() flow.client_id = client_id flow.flow_id = self._FLOW_ID db.WriteFlowObject(flow) flow = FlowBaseTest.Flow(flow) flow.Log("foo %s %s") logs = db.ReadFlowLogEntries(client_id, self._FLOW_ID, offset=0, count=1024) self.assertLen(logs, 1) self.assertEqual(logs[0].message, "foo %s %s")
def testLogWithFormatArgs(self, db: abstract_db.Database) -> None: client_id = db_test_utils.InitializeClient(db) flow_id = "FEDCBA9876543210" flow = rdf_flow_objects.Flow() flow.client_id = client_id flow.flow_id = flow_id db.WriteFlowObject(flow) flow = FlowBaseTest.Flow(flow) flow.Log("foo %s %s", "bar", 42) logs = db.ReadFlowLogEntries(client_id, flow_id, offset=0, count=1024) self.assertLen(logs, 1) self.assertEqual(logs[0].message, "foo bar 42")