grr/server/grr_response_server/flows/general/administrative_test.py
def testOnlineNotificationEmail(self):
    """Tests that the mail is sent in the OnlineNotification flow."""
    client_id = self.SetupClient(0)
    self.email_messages = []

    def SendEmail(address, sender, title, message, **_):
      self.email_messages.append(
          dict(address=address, sender=sender, title=title, message=message))

    with utils.Stubber(email_alerts.EMAIL_ALERTER, "SendEmail", SendEmail):
      client_mock = action_mocks.ActionMock(admin.Echo)
      flow_test_lib.TestFlowHelper(
          administrative.OnlineNotification.__name__,
          client_mock,
          args=administrative.OnlineNotificationArgs(email="test@localhost"),
          token=self.token,
          client_id=client_id)

    self.assertLen(self.email_messages, 1)
    email_message = self.email_messages[0]

    # We expect the email to be sent.
    self.assertEqual(email_message.get("address", ""), "test@localhost")
    self.assertEqual(email_message["title"],
                     "GRR Client on Host-0.example.com became available.")
Tests that the mail is sent in the OnlineNotification flow.
Tests that the mail is sent in the OnlineNotification flow.
Tests that the mail is sent in the OnlineNotification flow .
def testOnlineNotificationEmail(self):
    client_id = self.SetupClient(0)
    self.email_messages = []
    def SendEmail(address, sender, title, message, **_):
      self.email_messages.append(
          dict(address=address, sender=sender, title=title, message=message))
    with utils.Stubber(email_alerts.EMAIL_ALERTER, "SendEmail", SendEmail):
      client_mock = action_mocks.ActionMock(admin.Echo)
      flow_test_lib.TestFlowHelper(
          administrative.OnlineNotification.__name__,
          client_mock,
          args=administrative.OnlineNotificationArgs(email="test@localhost"),
          token=self.token,
          client_id=client_id)
    self.assertLen(self.email_messages, 1)
    email_message = self.email_messages[0]
    self.assertEqual(email_message.get("address", ""), "test@localhost")
    self.assertEqual(email_message["title"],
                     "GRR Client on Host-0.example.com became available.")
def testOnlineNotificationEmail ( self ) : client_id = self . SetupClient ( 0 ) self . email_messages = [ ] def SendEmail ( address , sender , title , message , ** _ ) : self . email_messages . append ( dict ( address = address , sender = sender , title = title , message = message ) ) with utils . Stubber ( email_alerts . EMAIL_ALERTER , "SendEmail" , SendEmail ) : client_mock = action_mocks . ActionMock ( admin . Echo ) flow_test_lib . TestFlowHelper ( administrative . OnlineNotification . __name__ , client_mock , args = administrative . OnlineNotificationArgs ( email = "test@localhost" ) , token = self . token , client_id = client_id ) self . assertLen ( self . email_messages , 1 ) email_message = self . email_messages [ 0 ] self . assertEqual ( email_message . get ( "address" , "" ) , "test@localhost" ) self . assertEqual ( email_message [ "title" ] , "GRR Client on Host-0.example.com became available." )
Tests that the mail is sent in the OnlineNotification flow.
Tests that the mail is sent in the OnlineNotification flow .
"""Tests that the mail is sent in the OnlineNotification flow.""" # We expect the email to be sent.
self