def Run(self): hunt_urn = rdfvalue.RDFURN("aff4:/hunts/H:123456") results = implementation.GRRHunt.ResultCollectionForHID(hunt_urn) with data_store.DB.GetMutationPool() as pool: result = rdf_flows.GrrMessage( payload=rdfvalue.RDFString("blah1"), age=rdfvalue.RDFDatetime().FromSecondsFromEpoch(1)) results.Add(result, timestamp=result.age + rdfvalue.Duration("1s"), mutation_pool=pool) result = rdf_flows.GrrMessage( payload=rdfvalue.RDFString("blah2-foo"), age=rdfvalue.RDFDatetime().FromSecondsFromEpoch(42)) results.Add(result, timestamp=result.age + rdfvalue.Duration("1s"), mutation_pool=pool) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456")) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456", count=1)) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456", offset=1, count=1)) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456", filter="foo"))
def Run(self): hunt_urn = rdfvalue.RDFURN("aff4:/hunts/H:123456") results_urn = hunt_urn.Add("Results") with aff4.FACTORY.Create(results_urn, aff4_type=hunt_results.HuntResultCollection, token=self.token) as results: result = rdf_flows.GrrMessage( payload=rdfvalue.RDFString("blah1"), age=rdfvalue.RDFDatetime().FromSecondsFromEpoch(1)) results.Add(result, timestamp=result.age + rdfvalue.Duration("1s")) result = rdf_flows.GrrMessage( payload=rdfvalue.RDFString("blah2-foo"), age=rdfvalue.RDFDatetime().FromSecondsFromEpoch(42)) results.Add(result, timestamp=result.age + rdfvalue.Duration("1s")) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456")) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456", count=1)) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456", offset=1, count=1)) self.Check("ListHuntResults", args=hunt_plugin.ApiListHuntResultsArgs(hunt_id="H:123456", filter="foo"))