grr/server/grr_response_server/flows/general/collectors_test.py
def testCmdArtifactWithParser(self):
    """Test a command artifact and parsing the response."""

    client_test_lib.Command("/bin/echo", args=["1"])

    parsers.SINGLE_RESPONSE_PARSER_FACTORY.Register("TestCmd", TestCmdParser)
    try:
      artifact_list = ["TestEchoArtifact"]

      # Run the ArtifactCollector to get the expected result.
      expected = self._RunFlow(
          aff4_flows.ArtifactCollectorFlow,
          standard.ExecuteCommand,
          artifact_list,
          apply_parsers=True)
      self.assertTrue(expected)
      expected = expected[0]
      self.assertIsInstance(expected, rdf_client.SoftwarePackage)

      # Run the ClientArtifactCollector to get the actual result.
      results = self._RunFlow(
          aff4_flows.ClientArtifactCollector,
          artifact_collector.ArtifactCollector,
          artifact_list,
          apply_parsers=True)
      self.assertLen(results, 1)
      artifact_response = results[0]
      self.assertIsInstance(artifact_response, rdf_client.SoftwarePackage)

      self.assertEqual(artifact_response, expected)
    finally:
      parsers.SINGLE_RESPONSE_PARSER_FACTORY.Unregister("TestCmd")
Test a command artifact and parsing the response.
Test a command artifact and parsing the response.
Test a command artifact and parsing the response .
def testCmdArtifactWithParser(self):
    client_test_lib.Command("/bin/echo", args=["1"])
    parsers.SINGLE_RESPONSE_PARSER_FACTORY.Register("TestCmd", TestCmdParser)
    try:
      artifact_list = ["TestEchoArtifact"]
      expected = self._RunFlow(
          aff4_flows.ArtifactCollectorFlow,
          standard.ExecuteCommand,
          artifact_list,
          apply_parsers=True)
      self.assertTrue(expected)
      expected = expected[0]
      self.assertIsInstance(expected, rdf_client.SoftwarePackage)
      results = self._RunFlow(
          aff4_flows.ClientArtifactCollector,
          artifact_collector.ArtifactCollector,
          artifact_list,
          apply_parsers=True)
      self.assertLen(results, 1)
      artifact_response = results[0]
      self.assertIsInstance(artifact_response, rdf_client.SoftwarePackage)
      self.assertEqual(artifact_response, expected)
    finally:
      parsers.SINGLE_RESPONSE_PARSER_FACTORY.Unregister("TestCmd")
def testCmdArtifactWithParser ( self ) : client_test_lib . Command ( "/bin/echo" , args = [ "1" ] ) parsers . SINGLE_RESPONSE_PARSER_FACTORY . Register ( "TestCmd" , TestCmdParser ) try : artifact_list = [ "TestEchoArtifact" ] expected = self . _RunFlow ( aff4_flows . ArtifactCollectorFlow , standard . ExecuteCommand , artifact_list , apply_parsers = True ) self . assertTrue ( expected ) expected = expected [ 0 ] self . assertIsInstance ( expected , rdf_client . SoftwarePackage ) results = self . _RunFlow ( aff4_flows . ClientArtifactCollector , artifact_collector . ArtifactCollector , artifact_list , apply_parsers = True ) self . assertLen ( results , 1 ) artifact_response = results [ 0 ] self . assertIsInstance ( artifact_response , rdf_client . SoftwarePackage ) self . assertEqual ( artifact_response , expected ) finally : parsers . SINGLE_RESPONSE_PARSER_FACTORY . Unregister ( "TestCmd" )
Test a command artifact and parsing the response.
Test a command artifact and parsing the response .
"""Test a command artifact and parsing the response.""" # Run the ArtifactCollector to get the expected result. # Run the ClientArtifactCollector to get the actual result.
self