grr/server/grr_response_server/bin/fleetspeak_frontend_test.py
def testProcessListingOnlyFleetspeak(self):
    """Test that the ListProcesses flow works with Fleetspeak."""
    client_mock = action_mocks.ListProcessesMock([
        rdf_client.Process(
            pid=2,
            ppid=1,
            cmdline=["cmd.exe"],
            exe=r"c:\windows\cmd.exe",
            ctime=1333718907167083)
    ])
    client_mock.mock_task_queue = []

    def SendCallback(fs_msg):
      pb_msg = jobs_pb2.GrrMessage()
      fs_msg.data.Unpack(pb_msg)
      msg = rdf_flows.GrrMessage.FromSerializedString(
          pb_msg.SerializeToString())
      client_mock.mock_task_queue.append(msg)

    fake_conn = _FakeGRPCServiceClient(
        FS_SERVICE_NAME, send_callback=SendCallback)

    with fleetspeak_test_lib.ConnectionOverrider(fake_conn):
      with mock.patch.object(
          fake_conn.outgoing,
          "InsertMessage",
          wraps=fake_conn.outgoing.InsertMessage):
        session_id = flow_test_lib.TestFlowHelper(
            flow_processes.ListProcesses.__name__,
            client_mock,
            client_id=self.client_id,
            token=self.token)

        fleetspeak_connector.CONN.outgoing.InsertMessage.assert_called()

      # Check the output collection
      processes = flow_test_lib.GetFlowResults(self.client_id, session_id)
      self.assertLen(processes, 1)
      process, = processes

      self.assertEqual(process.ctime, 1333718907167083)
      self.assertEqual(process.cmdline, ["cmd.exe"])
Test that the ListProcesses flow works with Fleetspeak.
Test that the ListProcesses flow works with Fleetspeak.
Test that the ListProcesses flow works with Fleetspeak .
def testProcessListingOnlyFleetspeak(self):
    client_mock = action_mocks.ListProcessesMock([
        rdf_client.Process(
            pid=2,
            ppid=1,
            cmdline=["cmd.exe"],
            exe=r"c:\windows\cmd.exe",
            ctime=1333718907167083)
    ])
    client_mock.mock_task_queue = []
    def SendCallback(fs_msg):
      pb_msg = jobs_pb2.GrrMessage()
      fs_msg.data.Unpack(pb_msg)
      msg = rdf_flows.GrrMessage.FromSerializedString(
          pb_msg.SerializeToString())
      client_mock.mock_task_queue.append(msg)
    fake_conn = _FakeGRPCServiceClient(
        FS_SERVICE_NAME, send_callback=SendCallback)
    with fleetspeak_test_lib.ConnectionOverrider(fake_conn):
      with mock.patch.object(
          fake_conn.outgoing,
          "InsertMessage",
          wraps=fake_conn.outgoing.InsertMessage):
        session_id = flow_test_lib.TestFlowHelper(
            flow_processes.ListProcesses.__name__,
            client_mock,
            client_id=self.client_id,
            token=self.token)
        fleetspeak_connector.CONN.outgoing.InsertMessage.assert_called()
      processes = flow_test_lib.GetFlowResults(self.client_id, session_id)
      self.assertLen(processes, 1)
      process, = processes
      self.assertEqual(process.ctime, 1333718907167083)
      self.assertEqual(process.cmdline, ["cmd.exe"])
def testProcessListingOnlyFleetspeak ( self ) : client_mock = action_mocks . ListProcessesMock ( [ rdf_client . Process ( pid = 2 , ppid = 1 , cmdline = [ "cmd.exe" ] , exe = r"c:\windows\cmd.exe" , ctime = 1333718907167083 ) ] ) client_mock . mock_task_queue = [ ] def SendCallback ( fs_msg ) : pb_msg = jobs_pb2 . GrrMessage ( ) fs_msg . data . Unpack ( pb_msg ) msg = rdf_flows . GrrMessage . FromSerializedString ( pb_msg . SerializeToString ( ) ) client_mock . mock_task_queue . append ( msg ) fake_conn = _FakeGRPCServiceClient ( FS_SERVICE_NAME , send_callback = SendCallback ) with fleetspeak_test_lib . ConnectionOverrider ( fake_conn ) : with mock . patch . object ( fake_conn . outgoing , "InsertMessage" , wraps = fake_conn . outgoing . InsertMessage ) : session_id = flow_test_lib . TestFlowHelper ( flow_processes . ListProcesses . __name__ , client_mock , client_id = self . client_id , token = self . token ) fleetspeak_connector . CONN . outgoing . InsertMessage . assert_called ( ) processes = flow_test_lib . GetFlowResults ( self . client_id , session_id ) self . assertLen ( processes , 1 ) process , = processes self . assertEqual ( process . ctime , 1333718907167083 ) self . assertEqual ( process . cmdline , [ "cmd.exe" ] )
Test that the ListProcesses flow works with Fleetspeak.
Test that the ListProcesses flow works with Fleetspeak .
"""Test that the ListProcesses flow works with Fleetspeak.""" # Check the output collection
self