def Run(self): if data_store.RelationalDBEnabled(): client_obj = self.SetupTestClientObject(0) client_id = client_obj.client_id else: client_id = self.SetupClient(0).Basename() client_mocks = { client_id: flow_test_lib.CrashClientMock(client_id, self.token) } if data_store.RelationalDBEnabled(): hunt_id = self.CreateHunt(description="the hunt") hunt.StartHunt(hunt_id) else: with test_lib.FakeTime(42): with self.CreateHunt(description="the hunt") as hunt_obj: hunt_obj.Run() hunt_id = hunt_obj.urn.Basename() with test_lib.FakeTime(45): self.AssignTasksToClients([client_id]) hunt_test_lib.TestHuntHelperWithMultipleMocks( client_mocks, False, self.token) if data_store.RelationalDBEnabled(): crash = data_store.REL_DB.ReadHuntFlows( hunt_id, 0, 1, filter_condition=db.HuntFlowsCondition.CRASHED_FLOWS_ONLY, )[0].client_crash_info else: crashes = implementation.GRRHunt.CrashCollectionForHID( hunt_obj.urn) crash = list(crashes)[0] replace = { hunt_id: "H:123456", unicode(crash.session_id): "aff4:/hunts/H:123456/C.1000000000000000/H:11223344" } self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs(hunt_id=hunt_id), replace=replace) self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs(hunt_id=hunt_id, count=1), replace=replace) self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs(hunt_id=hunt_id, offset=1, count=1), replace=replace)
def Run(self): client_id = self.SetupClient(0) client_mocks = { client_id: flow_test_lib.CrashClientMock(client_id, self.token) } hunt_id = self.CreateHunt(description="the hunt", creator=self.token.username) hunt.StartHunt(hunt_id) with test_lib.FakeTime(45): self.AssignTasksToClients([client_id]) hunt_test_lib.TestHuntHelperWithMultipleMocks( client_mocks, self.token) crash = data_store.REL_DB.ReadHuntFlows( hunt_id, 0, 1, filter_condition=db.HuntFlowsCondition.CRASHED_FLOWS_ONLY, )[0].client_crash_info replace = { hunt_id: "H:123456", str(crash.session_id): "aff4:/hunts/H:123456/C.1000000000000000/H:11223344" } self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs(hunt_id=hunt_id), replace=replace) self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs(hunt_id=hunt_id, count=1), replace=replace) self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs(hunt_id=hunt_id, offset=1, count=1), replace=replace)
def Run(self): if data_store.RelationalDBReadEnabled(): client_obj = self.SetupTestClientObject(0) client_id = client_obj.client_id else: client_id = self.SetupClient(0).Basename() client_mocks = { client_id: flow_test_lib.CrashClientMock(client_id, self.token) } with test_lib.FakeTime(42): with self.CreateHunt(description="the hunt") as hunt_obj: hunt_obj.Run() with test_lib.FakeTime(45): self.AssignTasksToClients([client_id]) hunt_test_lib.TestHuntHelperWithMultipleMocks( client_mocks, False, self.token) crashes = implementation.GRRHunt.CrashCollectionForHID(hunt_obj.urn) crash = list(crashes)[0] session_id = crash.session_id.Basename() replace = { hunt_obj.urn.Basename(): "H:123456", session_id: "H:11223344" } self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs( hunt_id=hunt_obj.urn.Basename()), replace=replace) self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs( hunt_id=hunt_obj.urn.Basename(), count=1), replace=replace) self.Check("ListHuntCrashes", args=hunt_plugin.ApiListHuntCrashesArgs( hunt_id=hunt_obj.urn.Basename(), offset=1, count=1), replace=replace)