def testArtifactWithBasicDependency(self): """Test that an artifact providing the dependency is added to the list.""" InitGRRWithTestSources( self, """ name: Artifact0 doc: An artifact without dependencies. supported_os: [Linux] provides: ["users.desktop"] --- name: Artifact1 doc: An artifact that depends on Artifact0. sources: - type: FILE attributes: paths: - '/sample/path' - '/%%users.desktop%%/' supported_os: [Linux] """) artifact_arranger = collectors.ArtifactArranger( os_name="Linux", artifacts_name_list=["Artifact1"]) artifact_list = artifact_arranger.GetArtifactsInProperOrder() self.assertEqual(artifact_list, ["Artifact0", "Artifact1"])
def testArtifactWithDependencyChain(self): """Test an artifact that depends on artifacts with more dependencies.""" InitGRRWithTestSources( self, """ name: Artifact0 doc: An artifact without dependencies. sources: supported_os: [Linux] provides: ["users.desktop"] --- name: Artifact1 doc: An artifact that depends on Artifact0. sources: - type: FILE attributes: paths: - '/%%users.desktop%%/' provides: ["users.homedir"] supported_os: [Linux] --- name: Artifact2 doc: An artifact that depends on Artifact0 and Artifact1. sources: - type: FILE attributes: paths: - '/%%users.homedir%%/' - '/%%users.desktop%%/' supported_os: [Linux] provides: ["os"] --- name: Artifact3 doc: An artifact that depends on Artifact2. sources: - type: FILE attributes: paths: - '/%%os%%/' supported_os: [Linux] """) artifact_arranger = collectors.ArtifactArranger( os_name="Linux", artifacts_name_list=["Artifact3"]) artifact_list = artifact_arranger.GetArtifactsInProperOrder() self.assertEqual(artifact_list, ["Artifact0", "Artifact1", "Artifact2", "Artifact3"])
def testArtifactWithoutDependency(self): """Test that artifact list without dependencies does not change.""" self.cleanup = InitGRRWithTestSources(""" name: Artifact0 doc: An artifact without dependencies. sources: - type: FILE attributes: paths: - '/sample/path' supported_os: [Linux] """) artifact_arranger = collectors.ArtifactArranger( os_name="Linux", artifacts_name_list=["Artifact0"]) artifact_list = artifact_arranger.GetArtifactsInProperOrder() self.assertEqual(artifact_list, ["Artifact0"])