From 02d16c4cc9abfe92e8a2827a7cd4bb26c7b6a679 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Tue, 13 Jan 2015 23:29:41 -0500 Subject: tests/crypto_test.py: added new test function to test split_and_encrypt and decrypt_and_glue functions. --- tests/crypto_test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/crypto_test.py b/tests/crypto_test.py index 0e446b2..5070927 100644 --- a/tests/crypto_test.py +++ b/tests/crypto_test.py @@ -18,9 +18,11 @@ import yaml +from filecmp import cmp from glob import glob from nose.tools import * from os import path, remove +from shutil import copyfile from combox.config import get_nodedirs from combox.crypto import * @@ -86,3 +88,22 @@ def test_split_encryption(): f_content_glued = glue_data(f_parts) assert f_content == f_content_glued + +def test_convenience_crypto(): + """ + Tests convenience crypto function(s) - split_and_encrypt, decrypt and glue. + """ + + # splits file into shards, writes encrypted shards to respective + # node directories. + split_and_encrypt(TEST_FILE, config) + + # create a copy of TEST_FILE (for later comparision) + TEST_FILE_COPY = "%s.copy" % TEST_FILE + copyfile(TEST_FILE, TEST_FILE_COPY) + + # reads encrypted shards from node directories, glues them and + # writes decrypted back to combox directory. + decrypt_and_glue(TEST_FILE, config) + + assert cmp(TEST_FILE, TEST_FILE_COPY, False) -- cgit v1.2.3