Beispiel #1
0
    def RequestCronJobApproval(self,
                               cron_job_id,
                               requestor=None,
                               reason=None,
                               email_cc_address=None,
                               approver="approver"):
        """Request cron job approval for a given cron job."""

        if not requestor:
            requestor = self.token.username

        if not reason:
            reason = self.token.reason

        self.CreateUser(requestor)
        self.CreateUser(approver)

        args = api_user.ApiCreateCronJobApprovalArgs(
            cron_job_id=cron_job_id,
            approval=api_user.ApiCronJobApproval(
                reason=reason,
                notified_users=[approver],
                email_cc_addresses=([email_cc_address]
                                    if email_cc_address else [])))
        handler = api_user.ApiCreateCronJobApprovalHandler()
        result = handler.Handle(
            args, token=access_control.ACLToken(username=requestor))

        return result.id
Beispiel #2
0
  def setUp(self):
    super(ApiCreateCronJobApprovalHandlerTest, self).setUp()

    self.SetUpApprovalTest()

    cron_manager = aff4_cronjobs.CronManager()
    cron_args = aff4_cronjobs.CreateCronJobFlowArgs(
        periodicity="1d", allow_overruns=False)
    self.subject_urn = cron_urn = cron_manager.ScheduleFlow(
        cron_args=cron_args, token=self.token)
    cron_id = cron_urn.Basename()

    self.handler = user_plugin.ApiCreateCronJobApprovalHandler()

    self.args = user_plugin.ApiCreateCronJobApprovalArgs(cron_job_id=cron_id)
    self.args.approval.reason = self.token.reason
    self.args.approval.notified_users = ["approver"]
    self.args.approval.email_cc_addresses = ["*****@*****.**"]
 def CreateCronJobApproval(self, args, token=None):
     return api_user.ApiCreateCronJobApprovalHandler()