def RequestHuntApproval(self, hunt_id, requestor=None, reason=None, email_cc_address=None, approver="approver"): """Request hunt approval for a given hunt.""" if not requestor: requestor = self.token.username if not reason: reason = self.token.reason self.CreateUser(requestor) self.CreateUser(approver) args = api_user.ApiCreateHuntApprovalArgs( hunt_id=hunt_id, approval=api_user.ApiHuntApproval( reason=reason, notified_users=[approver], email_cc_addresses=([email_cc_address] if email_cc_address else []))) handler = api_user.ApiCreateHuntApprovalHandler() result = handler.Handle( args, token=access_control.ACLToken(username=requestor)) return result.id
def setUp(self): super(ApiCreateHuntApprovalHandlerTest, self).setUp() self.SetUpApprovalTest() with self.CreateHunt(description="foo") as hunt_obj: hunt_id = hunt_obj.urn.Basename() self.handler = user_plugin.ApiCreateHuntApprovalHandler() self.args = user_plugin.ApiCreateHuntApprovalArgs(hunt_id=hunt_id) self.args.approval.reason = self.token.reason self.args.approval.notified_users = ["approver"] self.args.approval.email_cc_addresses = ["*****@*****.**"]
def CreateHuntApproval(self, args, token=None): return api_user.ApiCreateHuntApprovalHandler()