def test_TarSimple(self): os.system('tar cf "%s" .' % self.test_file) with open(self.test_file, 'rb') as in_fp, open( self.test_filed, 'wb') as out_fp: tarzan.filter_tar( in_fp, out_fp, self.blockstore_directory, 'test_password') self.basic_tarzan_comparison()
def test_TarBig(self): self.make_big_dir() os.system('tar cf "%s" -C "%s" .' % (self.test_file, self.big_dir)) with open(self.test_file, 'rb') as in_fp, open( self.test_filed, 'wb') as out_fp: tarzan.filter_tar( in_fp, out_fp, self.blockstore_directory, 'test_password') self.basic_tarzan_comparison()
def test_LongFilenames(self): self.make_big_dir() long_filename = '1234567890' * 23 self.long_dir = os.path.join(self.temp_dir, 'long_dir') os.mkdir(self.long_dir) dest_dir = self.long_dir for x in range(10): dest_dir = os.path.join(dest_dir, long_filename) os.mkdir(dest_dir) with open(os.path.join(dest_dir, long_filename), 'w') as fp: fp.write('Hello') os.system('tar cf "%s" -C "%s" .' % (self.test_file, self.long_dir)) with open(self.test_file, 'rb') as in_fp, open( self.test_filed, 'wb') as out_fp: tarzan.filter_tar( in_fp, out_fp, self.blockstore_directory, 'test_password') self.basic_tarzan_comparison()
def test_TarPipeEmpty(self): os.system('tar cfT "%s" /dev/null' % self.test_file) with open(self.test_file, 'rb') as in_fp, open( self.test_filed, 'wb') as out_fp: tarzan.filter_tar( in_fp, out_fp, self.blockstore_directory, 'test_password') with self.assertRaises(tarzan.InvalidTarzanInputError): with open(self.test_filed, 'rb') as in_fp: tarzan.list_tarzan( in_fp, self.dev_null, self.blockstore_directory, 'bad_password') output_file = StringIO() with open(self.test_filed, 'rb') as in_fp: tarzan.list_tarzan( in_fp, output_file, self.blockstore_directory, 'test_password') self.assertEqual(output_file.getvalue(), '') self.compare_source_and_decrypted()