Added encrypt/decrypt multivolume test
authorDaniel Garcia Moreno <danigm@wadobo.com>
Tue, 16 Jul 2013 06:21:29 +0000 (08:21 +0200)
committerDaniel Garcia Moreno <danigm@wadobo.com>
Tue, 16 Jul 2013 06:21:29 +0000 (08:21 +0200)
testing/test_encryption.py

index 08af199..69b51da 100644 (file)
@@ -20,6 +20,7 @@ from deltatar.tarfile import TarFile, GNU_FORMAT
 
 import filesplit
 from . import BaseTest
+from . import new_volume_handler
 
 
 class EncryptionTest(BaseTest):
@@ -171,3 +172,44 @@ class EncryptionTest(BaseTest):
         for key, value in hash.iteritems():
             assert os.path.exists(key)
             assert value == self.md5sum(key)
+
+    def test_multivol_file_decrypt(self):
+        '''
+        Test multivol tarball with encryption.
+        '''
+
+        # create sample data
+        hash = dict()
+        hash["big"] = self.create_file("big", 50000)
+        hash["big2"] = self.create_file("big2", 10200)
+        hash["small"] = self.create_file("small", 100)
+        hash["small2"] = self.create_file("small2", 354)
+
+        # create the tar file with volumes
+        tarobj = TarFile.open("sample.tar.gz.aes",
+                              mode="w#gz.aes",
+                              password='key',
+                              concat_compression=True,
+                              max_volume_size=20000,
+                              new_volume_handler=new_volume_handler)
+
+        for k in hash:
+            tarobj.add(k)
+        tarobj.close()
+
+        assert os.path.exists("sample.tar.gz.aes")
+        for k in hash:
+            os.unlink(k)
+
+        # extract
+        tarobj = TarFile.open("sample.tar.gz.aes",
+                              mode="r#gz.aes",
+                              password="key",
+                              new_volume_handler=new_volume_handler)
+        tarobj.extractall()
+        tarobj.close()
+
+        # check output
+        for key, value in hash.iteritems():
+            assert os.path.exists(key)
+            assert value == self.md5sum(key)