diff options
author | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-01-13 23:29:41 -0500 |
---|---|---|
committer | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-01-13 23:29:41 -0500 |
commit | 02d16c4cc9abfe92e8a2827a7cd4bb26c7b6a679 (patch) | |
tree | f111cb0525b22bd56454e7a42983249416f90d98 | |
parent | a2c64aa2d051a4392fe9490d61fa31640139afd1 (diff) |
tests/crypto_test.py: added new test function to test split_and_encrypt and decrypt_and_glue functions.
-rw-r--r-- | tests/crypto_test.py | 21 |
1 files changed, 21 insertions, 0 deletions
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) |