示例#1
0
    def setUp(self):
        super(MultiRepackTest, self).setUp()
        self.pool_obj = mock.MagicMock()
        self.pool_patcher = mock.patch.object(multiprocessing,
                                              "Pool",
                                              return_value=self.pool_obj)
        self.mock_pool = self.pool_patcher.start()

        config_dir = test_lib.TempDirPath()
        self.label1_config = os.path.join(config_dir, "label1.yaml")
        self.label2_config = os.path.join(config_dir, "label2.yaml")
        open(self.label1_config, mode="wb").write("Client.labels: [label1]")
        open(self.label2_config, mode="wb").write("Client.labels: [label2]")
        self.template_dir = test_lib.TempDirPath()
        self.deb_template = os.path.join(self.template_dir,
                                         "grr_3.1.0.2_amd64.deb.zip")
        self.exe_template = os.path.join(self.template_dir,
                                         "GRR_3.1.0.2_i386.exe.zip")
        self.xar_template = os.path.join(self.template_dir,
                                         "grr_3.1.0.2_amd64.xar.zip")
        open(self.deb_template, mode="wb").write("linux")
        open(self.exe_template, mode="wb").write("windows")
        open(self.xar_template, mode="wb").write("darwin")

        self.output_dir = test_lib.TempDirPath()
示例#2
0
    def setUpClass(cls):
        super(GRRHTTPServerTest, cls).setUpClass()

        cls.config_overrider = test_lib.ConfigOverrider({
            "Rekall.profile_server":
            rekall_test_lib.TestRekallRepositoryProfileServer.__name__,
            "FileUploadFileStore.root_dir":
            test_lib.TempDirPath()
        })
        cls.config_overrider.Start()

        # Frontend must be initialized to register all the stats counters.
        frontend_lib.FrontendInit().RunOnce()

        # Bring up a local server for testing.
        port = portpicker.PickUnusedPort()
        ip = utils.ResolveHostnameToIP("localhost", port)
        cls.httpd = frontend.GRRHTTPServer((ip, port),
                                           frontend.GRRHTTPServerHandler)

        if ipaddr.IPAddress(ip).version == 6:
            cls.address_family = socket.AF_INET6
            cls.base_url = "http://[%s]:%d/" % (ip, port)
        else:
            cls.address_family = socket.AF_INET
            cls.base_url = "http://%s:%d/" % (ip, port)

        cls.httpd_thread = threading.Thread(target=cls.httpd.serve_forever)
        cls.httpd_thread.daemon = True
        cls.httpd_thread.start()
示例#3
0
def InitGRRWithTestSources(artifacts_data):
  artifact_registry.REGISTRY.ClearSources()
  artifact_registry.REGISTRY.ClearRegistry()

  artifacts_temp_dir = test_lib.TempDirPath()
  with open(os.path.join(artifacts_temp_dir, "test_artifacts.yaml"), "w") as fd:
    fd.write(artifacts_data)

  artifact_registry.REGISTRY.AddDirSources([artifacts_temp_dir])

  def CleanUp():
    shutil.rmtree(artifacts_temp_dir)

  return CleanUp
示例#4
0
 def setUp(self):
     self.temp_dir = test_lib.TempDirPath()
示例#5
0
 def setUp(self):
     super(DirHierarchyTestMixin, self).setUp()
     self.tempdir = test_lib.TempDirPath()