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 Run(self): with test_lib.FakeTime(42): self.CreateUser("approver") with self.CreateHunt(description="foo") as hunt_obj: hunt_id = hunt_obj.urn.Basename() def ReplaceHuntAndApprovalIds(): approvals = self.ListHuntApprovals() return {approvals[0].id: "approval:112233", hunt_id: "H:123456"} with test_lib.FakeTime(126): self.Check("CreateHuntApproval", args=user_plugin.ApiCreateHuntApprovalArgs( hunt_id=hunt_id, approval=user_plugin.ApiHuntApproval( reason="really important reason!", notified_users=["approver1", "approver2"], email_cc_addresses=["*****@*****.**"])), replace=ReplaceHuntAndApprovalIds)