grr/server/grr_response_server/artifact_test.py
def testGetKBDependencies(self):
    """Test that KB dependencies are calculated correctly."""
    artifact_registry.REGISTRY.ClearSources()
    try:
      test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                         "artifacts", "test_artifacts.json")
      artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)

      with test_lib.ConfigOverrider({
          "Artifacts.knowledge_base": [
              "DepsParent", "DepsDesktop", "DepsHomedir", "DepsWindir",
              "DepsWindirRegex", "DepsControlSet", "FakeArtifact"
          ],
          "Artifacts.knowledge_base_additions": ["DepsHomedir2"],
          "Artifacts.knowledge_base_skip": ["DepsWindir"],
          "Artifacts.knowledge_base_heavyweight": ["FakeArtifact"]
      }):
        args = artifact.KnowledgeBaseInitializationArgs(lightweight=True)
        kb_init = aff4_flows.KnowledgeBaseInitializationFlow(
            None, token=self.token)
        kb_init.args = args
        kb_init.state["all_deps"] = set()
        kb_init.state["awaiting_deps_artifacts"] = []
        kb_init.state["knowledge_base"] = rdf_client.KnowledgeBase(os="Windows")
        no_deps = kb_init.GetFirstFlowsForCollection()

        self.assertCountEqual(no_deps, ["DepsControlSet", "DepsHomedir2"])
        self.assertCountEqual(kb_init.state.all_deps, [
            "users.homedir", "users.desktop", "users.username",
            "environ_windir", "current_control_set"
        ])
        self.assertCountEqual(
            kb_init.state.awaiting_deps_artifacts,
            ["DepsParent", "DepsDesktop", "DepsHomedir", "DepsWindirRegex"])
    finally:
      artifact.ArtifactLoader().RunOnce()
Test that KB dependencies are calculated correctly.
Test that KB dependencies are calculated correctly.
Test that KB dependencies are calculated correctly .
def testGetKBDependencies(self):
    artifact_registry.REGISTRY.ClearSources()
    try:
      test_artifacts_file = os.path.join(config.CONFIG["Test.data_dir"],
                                         "artifacts", "test_artifacts.json")
      artifact_registry.REGISTRY.AddFileSource(test_artifacts_file)
      with test_lib.ConfigOverrider({
          "Artifacts.knowledge_base": [
              "DepsParent", "DepsDesktop", "DepsHomedir", "DepsWindir",
              "DepsWindirRegex", "DepsControlSet", "FakeArtifact"
          ],
          "Artifacts.knowledge_base_additions": ["DepsHomedir2"],
          "Artifacts.knowledge_base_skip": ["DepsWindir"],
          "Artifacts.knowledge_base_heavyweight": ["FakeArtifact"]
      }):
        args = artifact.KnowledgeBaseInitializationArgs(lightweight=True)
        kb_init = aff4_flows.KnowledgeBaseInitializationFlow(
            None, token=self.token)
        kb_init.args = args
        kb_init.state["all_deps"] = set()
        kb_init.state["awaiting_deps_artifacts"] = []
        kb_init.state["knowledge_base"] = rdf_client.KnowledgeBase(os="Windows")
        no_deps = kb_init.GetFirstFlowsForCollection()
        self.assertCountEqual(no_deps, ["DepsControlSet", "DepsHomedir2"])
        self.assertCountEqual(kb_init.state.all_deps, [
            "users.homedir", "users.desktop", "users.username",
            "environ_windir", "current_control_set"
        ])
        self.assertCountEqual(
            kb_init.state.awaiting_deps_artifacts,
            ["DepsParent", "DepsDesktop", "DepsHomedir", "DepsWindirRegex"])
    finally:
      artifact.ArtifactLoader().RunOnce()
def testGetKBDependencies ( self ) : artifact_registry . REGISTRY . ClearSources ( ) try : test_artifacts_file = os . path . join ( config . CONFIG [ "Test.data_dir" ] , "artifacts" , "test_artifacts.json" ) artifact_registry . REGISTRY . AddFileSource ( test_artifacts_file ) with test_lib . ConfigOverrider ( { "Artifacts.knowledge_base" : [ "DepsParent" , "DepsDesktop" , "DepsHomedir" , "DepsWindir" , "DepsWindirRegex" , "DepsControlSet" , "FakeArtifact" ] , "Artifacts.knowledge_base_additions" : [ "DepsHomedir2" ] , "Artifacts.knowledge_base_skip" : [ "DepsWindir" ] , "Artifacts.knowledge_base_heavyweight" : [ "FakeArtifact" ] } ) : args = artifact . KnowledgeBaseInitializationArgs ( lightweight = True ) kb_init = aff4_flows . KnowledgeBaseInitializationFlow ( None , token = self . token ) kb_init . args = args kb_init . state [ "all_deps" ] = set ( ) kb_init . state [ "awaiting_deps_artifacts" ] = [ ] kb_init . state [ "knowledge_base" ] = rdf_client . KnowledgeBase ( os = "Windows" ) no_deps = kb_init . GetFirstFlowsForCollection ( ) self . assertCountEqual ( no_deps , [ "DepsControlSet" , "DepsHomedir2" ] ) self . assertCountEqual ( kb_init . state . all_deps , [ "users.homedir" , "users.desktop" , "users.username" , "environ_windir" , "current_control_set" ] ) self . assertCountEqual ( kb_init . state . awaiting_deps_artifacts , [ "DepsParent" , "DepsDesktop" , "DepsHomedir" , "DepsWindirRegex" ] ) finally : artifact . ArtifactLoader ( ) . RunOnce ( )
Test that KB dependencies are calculated correctly.
Test that KB dependencies are calculated correctly .
"""Test that KB dependencies are calculated correctly."""
self