def Run(self): with test_lib.FakeTime(42): hunt_id = self.CreateHunt(description="the hunt") self.Check("DeleteHunt", args=hunt_plugin.ApiDeleteHuntArgs(hunt_id=hunt_id), replace={hunt_id: "H:123456"})
def setUp(self): super(ApiDeleteHuntHandlerTest, self).setUp() self.handler = hunt_plugin.ApiDeleteHuntHandler() self.hunt_id = self.CreateHunt(description="the hunt") self.args = hunt_plugin.ApiDeleteHuntArgs(hunt_id=self.hunt_id)
def testDeleteHuntIsAccessCheckedIfUserIsNotCreator(self): hunt_id = self.CreateHunt(creator=self.context.username) args = api_hunt.ApiDeleteHuntArgs(hunt_id=hunt_id) self.CheckMethodIsAccessChecked( self.router.DeleteHunt, "CheckHuntAccess", args=args, context=api_call_context.ApiCallContext("foo"))
def testDeleteHuntIsAccessCheckedIfUserIsNotCreator(self): hunt = self.CreateHunt() args = api_hunt.ApiDeleteHuntArgs(hunt_id=hunt.urn.Basename()) self.CheckMethodIsAccessChecked( self.router.DeleteHunt, "CheckHuntAccess", args=args, token=access_control.ACLToken(username="******"))
def Run(self): with test_lib.FakeTime(42): if data_store.RelationalDBEnabled(): hunt_id = self.CreateHunt(description="the hunt") else: hunt_obj = self.CreateHunt(description="the hunt") hunt_id = hunt_obj.urn.Basename() self.Check("DeleteHunt", args=hunt_plugin.ApiDeleteHuntArgs(hunt_id=hunt_id), replace={hunt_id: "H:123456"})
def setUp(self): super(ApiDeleteHuntHandlerTest, self).setUp() self.handler = hunt_plugin.ApiDeleteHuntHandler() if data_store.RelationalDBEnabled(): self.hunt_id = self.CreateHunt(description="the hunt") else: self.hunt_obj = self.CreateHunt(description="the hunt") self.hunt_id = self.hunt_obj.urn.Basename() self.args = hunt_plugin.ApiDeleteHuntArgs(hunt_id=self.hunt_id)
def testRaisesIfHuntNotFound(self): with self.assertRaises(hunt_plugin.HuntNotFoundError): self.handler.Handle( hunt_plugin.ApiDeleteHuntArgs(hunt_id="H:123456"), token=self.token)
def testDeleteHuntIsNotAccessCheckedIfUserIsCreator(self): hunt_id = self.CreateHunt(creator=self.context.username) args = api_hunt.ApiDeleteHuntArgs(hunt_id=hunt_id) self.CheckMethodIsNotAccessChecked(self.router.DeleteHunt, args=args)
def testDeleteHuntRaisesIfHuntNotFound(self): args = api_hunt.ApiDeleteHuntArgs(hunt_id="H:123456") with self.assertRaises(api_call_handler_base.ResourceNotFoundError): self.router.DeleteHunt(args, context=self.context)
def testDeleteHuntIsNotAccessCheckedIfUserIsCreator(self): hunt = self.CreateHunt() args = api_hunt.ApiDeleteHuntArgs(hunt_id=hunt.urn.Basename()) self.CheckMethodIsNotAccessChecked(self.router.DeleteHunt, args=args)