Ejemplo n.º 1
0
    def testGetArtifactsFail(self):
        sysinfo_recipe = sysinfo.SysinfoRecipe('failsysinfo')
        #pylint: disable=protected-access
        sysinfo_recipe._platform = 'darwin'
        sysinfo_recipe._SYSTEM_PROFILER_CMD = [
            'echo', '-n', self._SYSTEM_PROFILER_FAIL_STRING
        ]
        artifacts = sysinfo_recipe.GetArtifacts()
        self.assertEqual(len(artifacts), 1)

        artifact = artifacts[0]
        self.assertIsInstance(artifact, base.ProcessOutputArtifact)
        self.assertEqual(artifact.name, 'system_info.txt')
        self.assertEqual(artifact.remote_path, 'system_info.txt')
        artifact_content = artifact.OpenStream().read()
        self.assertEqual(artifact_content, self._SYSTEM_PROFILER_FAIL_STRING)
Ejemplo n.º 2
0
    def testGetArtifacts(self):
        sysinfo_recipe = sysinfo.SysinfoRecipe('sysinfo')
        #pylint: disable=protected-access
        sysinfo_recipe._platform = 'linux'
        sysinfo_recipe._DMI_DECODE_CMD = [
            'echo', '-n', self._DMIDECODE_OUTPUT_STRING
        ]
        artifacts = sysinfo_recipe.GetArtifacts()
        self.assertEqual(len(artifacts), 1)

        artifact = artifacts[0]
        self.assertIsInstance(artifact, base.ProcessOutputArtifact)
        self.assertEqual(artifact.name, 'system_info.txt')
        self.assertEqual(artifact.remote_path, 'system_info.txt')
        artifact_content = artifact.OpenStream().read()
        self.assertEqual(artifact_content, self._DMIDECODE_OUTPUT_STRING)
Ejemplo n.º 3
0
    def testGetArtifacts(self):
        sysinfo_recipe = sysinfo.SysinfoRecipe('sysinfo')
        # pylint: disable=protected-access
        sysinfo_recipe._platform = 'linux'
        # pylint: disable=line-too-long
        with mock.patch(
                'auto_forensicate.recipes.base.ProcessOutputArtifact._RunCommand'
        ) as patched_run:
            patched_run.return_value = self._DMIDECODE_OUTPUT_STRING
            artifacts = sysinfo_recipe.GetArtifacts()
            self.assertEqual(len(artifacts), 2)

            artifact = artifacts[0]
            self.assertIsInstance(artifact, base.ProcessOutputArtifact)
            self.assertEqual(artifact.name, 'system_info.txt')
            self.assertEqual(artifact.remote_path, 'system_info.txt')
            artifact_content = artifact.OpenStream().read()
            self.assertEqual(artifact_content, self._DMIDECODE_OUTPUT_STRING)