Beispiel #1
0
 def testCopyPathToFileLimitLength(self):
     request = rdfvalue.CopyPathToFileRequest(offset=0,
                                              length=23,
                                              src_path=self.pathspec,
                                              dest_dir=self.temp_dir,
                                              gzip_output=False)
     result = self.RunAction("CopyPathToFile", request)[0]
     output = open(result.dest_path.path).read()
     self.assertEqual(len(output), 23)
Beispiel #2
0
 def testCopyPathToFile(self):
     request = rdfvalue.CopyPathToFileRequest(offset=0,
                                              length=0,
                                              src_path=self.pathspec,
                                              dest_dir=self.temp_dir,
                                              gzip_output=False)
     result = self.RunAction("CopyPathToFile", request)[0]
     hash_out = hashlib.sha1(open(result.dest_path.path).read()).hexdigest()
     self.assertEqual(self.hash_in, hash_out)
Beispiel #3
0
 def testCopyPathToFileLifetimeLimit(self):
     request = rdfvalue.CopyPathToFileRequest(offset=0,
                                              length=23,
                                              src_path=self.pathspec,
                                              dest_dir=self.temp_dir,
                                              gzip_output=False,
                                              lifetime=0.1)
     result = self.RunAction("CopyPathToFile", request)[0]
     self.assertTrue(os.path.exists(result.dest_path.path))
     time.sleep(1)
     self.assertFalse(os.path.exists(result.dest_path.path))
Beispiel #4
0
    def testCopyPathToFileOffsetandLimit(self):

        with open(self.path_in) as f:
            f.seek(38)
            out = f.read(25)
            hash_in = hashlib.sha1(out).hexdigest()

        request = rdfvalue.CopyPathToFileRequest(offset=38,
                                                 length=25,
                                                 src_path=self.pathspec,
                                                 dest_dir=self.temp_dir,
                                                 gzip_output=False)
        result = self.RunAction("CopyPathToFile", request)[0]
        output = open(result.dest_path.path).read()
        self.assertEqual(len(output), 25)
        hash_out = hashlib.sha1(output).hexdigest()
        self.assertEqual(hash_in, hash_out)