示例#1
0
    def RequestClientApproval(self,
                              client_id,
                              reason=None,
                              requestor=None,
                              email_cc_address=None,
                              approver="approver"):
        """Create an approval request to be sent to approver."""
        if hasattr(client_id, "Basename"):
            client_id = client_id.Basename()

        if not requestor:
            requestor = self.token.username

        if not reason:
            reason = self.token.reason

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

        args = api_user.ApiCreateClientApprovalArgs(
            client_id=client_id,
            approval=api_user.ApiClientApproval(
                reason=reason,
                notified_users=[approver],
                email_cc_addresses=([email_cc_address]
                                    if email_cc_address else [])))
        handler = api_user.ApiCreateClientApprovalHandler()
        result = handler.Handle(
            args, token=access_control.ACLToken(username=requestor))

        return result.id
示例#2
0
  def setUp(self):
    super(ApiCreateClientApprovalHandlerTest, self).setUp()

    self.SetUpApprovalTest()

    self.subject_urn = client_id = self.SetupClient(0)

    self.handler = user_plugin.ApiCreateClientApprovalHandler()

    self.args = user_plugin.ApiCreateClientApprovalArgs(client_id=client_id)
    self.args.approval.reason = self.token.reason
    self.args.approval.notified_users = ["approver"]
    self.args.approval.email_cc_addresses = ["*****@*****.**"]
 def CreateClientApproval(self, args, token=None):
     return api_user.ApiCreateClientApprovalHandler()