Example #1
0
 def test_encrypt_file_smp_single_file(self):
     """
     test_encrypt_file
     """
     self.do_wait_for_tasks = False
     fname = "testdata/200MB.zip"
     secret = '\xeb>M\x04\xc22\x96!\xce\xed\xbb.\xe1u\xc7\xe4\x07h<.\x87\xc9H\x89\x8aj\xb4\xb2b5}\x95'
     enc_file = encrypt_file_smp(secret, fname, print_progress, single_file=True)
     dec_file = decrypt_file_smp(secret, enc_file=enc_file, progress_callback=print_progress)
     self.assertEqual(make_sha1_hash_file(fpi=dec_file), make_sha1_hash_file(fpi=open(fname)))
Example #2
0
 def test_hash_rename(self):
     """
     test_hash_rename
     """
     self.unzip_testfiles_clean()
     fpath = "testdata/test/smalltest/test.cpp"
     file_dict = read_file_to_fdict(fpath)
     filehash = make_sha1_hash_file("blob " + str(file_dict["st_size"]) + "\0", fpath)
     os.system("mv testdata/test/smalltest/test.cpp testdata/test/smalltest/test2.cpp")
     fpath = "testdata/test/smalltest/test2.cpp"
     file_dict = read_file_to_fdict(fpath)
     filehash2 = make_sha1_hash_file("blob " + str(file_dict["st_size"]) + "\0", fpath)
     self.assertEqual(filehash, filehash2)
Example #3
0
    def test_encrypt_file_smp(self):
        """
        test_encrypt_file
        """
        self.do_wait_for_tasks = False

        #self.make_testfile("1000MB.zip", 1000)
        fname = "testdata/200MB.zip"
        secret = '\xeb>M\x04\xc22\x96!\xce\xed\xbb.\xe1u\xc7\xe4\x07h<.\x87\xc9H\x89\x8aj\xb4\xb2b5}\x95'
        enc_files = encrypt_file_smp(secret, fname, print_progress)
        dec_file = decrypt_file_smp(secret, enc_files=enc_files, progress_callback=print_progress, delete_enc_files=True)
        h1 = make_sha1_hash_file(fpi=dec_file)
        h2 = make_sha1_hash_file(fpi=open(fname))
        self.assertEqual(h1, h2)
Example #4
0
 def test_super_large_file(self):
     """
     test_super_large_file
     """
     self.reset_cb_db_clean()
     self.unzip_testfiles_clean()
     self.make_testfile("3000MB.txt", 3000)
     os.system("rm testdata/test/all_types/*")
     os.system("rm -Rf testdata/test/smalltest")
     os.system("cp testdata/3000MB.txt testdata/test/all_types/")
     localindex, self.cbmemory = sync_server(self.cbmemory, self.cboptions)
     self.assertTrue(self.files_synced())
     datadir = get_data_dir(self.cboptions)
     self.cbmemory.save(datadir)
     p = os.path.join(os.path.join(os.getcwd(), "testdata"), "test")
     org_files = get_files_dir(p, ignore_hidden=True)
     org_files = [x for x in org_files if "memory.pickle.json" not in x]
     org_files1 = [make_sha1_hash_file(fpath=x) for x in org_files]
     self.delete_hidden_configs()
     self.do_wait_for_tasks = False
     self.cboptions.remove = True
     salt, secret, self.cbmemory, localindex = index_and_encrypt(self.cbmemory, self.cboptions)
     datadir = get_data_dir(self.cboptions)
     self.cbmemory.save(datadir)
     hide_config(self.cboptions, salt, secret)
     self.assertEqual(count_files_dir(get_blob_dir(self.cboptions)), 0)
     options = self.cboptions
     options.encrypt = False
     options.decrypt = True
     options.remove = False
     secret = restore_hidden_config(options)
     datadir = get_data_dir(self.cboptions)
     memory = Memory()
     memory.load(datadir)
     decrypt_and_build_filetree(memory, options, secret)
     org_files2 = get_files_dir(p, ignore_hidden=True)
     org_files3 = [make_sha1_hash_file(fpath=x) for x in org_files2]
     self.assertEqual(set(org_files1), set(org_files3))
     os.system("rm -Rf testdata/test")
     os.system("rm testdata/3000MB.txt")