Exemple #1
0
    def setUp(self):
        super(ApiGetHuntContextHandlerTest, self).setUp()
        self.handler = hunt_plugin.ApiGetHuntContextHandler()

        # Set up mock hunt and context.
        with self.CreateHunt(description="the hunt") as hunt:
            # Assign for easier access.
            self.hunt = hunt
            self.context = self.hunt.state.context

            # Add custom properties for the tests.
            self.context.Register("string_prop", "some test value")
            self.context.Register("time_prop", rdfvalue.RDFDatetime().Now())
            self.context.Register("int_prop", 42)
            self.context.Register("valid_float_prop", 42.0)
            self.context.Register("invalid_float_prop", 42.5)
            self.context.Register("bool_prop", True)
            self.context.Register("none_prop", None)
            self.context.Register("non_proto_prop", object())
            self.context.Register(
                "proto_prop",
                hunt_plugin.ApiGetHuntContextArgs(hunt_id=hunt.urn.Basename()))
 def GetHuntContext(self, args, token=None):
     return api_hunt.ApiGetHuntContextHandler()