示例#1
0
    def testHuntNotificationIsParsedCorrectly(self):
        n = self.InitFromObj_(
            rdf_objects.UserNotification.Type.TYPE_HUNT_STOPPED,
            rdf_objects.ObjectReference(
                reference_type=rdf_objects.ObjectReference.Type.HUNT,
                hunt=rdf_objects.HuntReference(hunt_id="H:123456")))

        self.assertEqual(n.reference.type, "HUNT")
        self.assertEqual(n.reference.hunt.hunt_id, "H:123456")
示例#2
0
    def Run(self):
        with test_lib.FakeTime(42):
            ref = rdf_hunts.FlowLikeObjectReference(
                object_type="HUNT_REFERENCE",
                hunt_reference=rdf_objects.HuntReference(hunt_id="H:332211"))
            with self.CreateHunt(description="the hunt",
                                 original_object=ref) as hunt_obj:
                hunt_urn = hunt_obj.urn

                hunt_stats = hunt_obj.context.usage_stats
                hunt_stats.user_cpu_stats.sum = 5000
                hunt_stats.network_bytes_sent_stats.sum = 1000000

        self.Check(
            "GetHunt",
            args=hunt_plugin.ApiGetHuntArgs(hunt_id=hunt_urn.Basename()),
            replace={hunt_urn.Basename(): "H:123456"})
示例#3
0
 def ObjectReference(self):
   return rdf_objects.ObjectReference(
       reference_type=rdf_objects.ObjectReference.Type.HUNT,
       hunt=rdf_objects.HuntReference(hunt_id=utils.SmartStr(self.hunt_id)))
示例#4
0
 def FromHuntId(cls, hunt_id):
   res = FlowLikeObjectReference()
   res.object_type = "HUNT_REFERENCE"
   res.hunt_reference = rdf_objects.HuntReference(hunt_id=hunt_id)
   return res