]> source.dussan.org Git - nextcloud-server.git/commitdiff
add test cases for cryptstream
authorRobin Appelman <icewind@owncloud.com>
Wed, 18 Apr 2012 14:02:35 +0000 (16:02 +0200)
committerRobin Appelman <icewind@owncloud.com>
Wed, 18 Apr 2012 18:54:28 +0000 (20:54 +0200)
apps/files_encryption/lib/proxy.php
apps/files_encryption/tests/encryption.php

index c68df06f9fa22fc2735ff47afed4a91102f6d629..a0de411a7b692b468caf9074385d35375cf91c0e 100644 (file)
@@ -28,6 +28,7 @@
 class OC_FileProxy_Encryption extends OC_FileProxy{
        private static $blackList=null; //mimetypes blacklisted from encryption
        private static $metaData=array(); //metadata cache
+       private static $enableEncryption=null;
        
        /**
         * check if a file should be encrypted during write
@@ -35,6 +36,12 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
         * @return bool
         */
        private static function shouldEncrypt($path){
+               if(is_null($this->enableEncryption)){
+                       $this->enableEncryption=(OC_Appconfig::getValue('files_encryption','enabled','true')=='true');
+               }
+               if(!$this->enableEncryption){
+                       return false;
+               }
                if(is_null(self::$blackList)){
                        self::$blackList=explode(',',OC_Appconfig::getValue('files_encryption','type_blacklist','jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg'));
                }
index 140fe6b126d3823048f611b07cb362cf3af2864f..13093256717e903976a1b8d78fd3dc88f2e7a8cc 100644 (file)
@@ -15,6 +15,12 @@ class Test_Encryption extends UnitTestCase {
                $decrypted=OC_Crypt::decrypt($encrypted,$key);
                $this->assertNotEqual($encrypted,$source);
                $this->assertEqual($decrypted,$source);
+
+               $chunk=substr($source,0,8192);
+               $encrypted=OC_Crypt::encrypt($chunk,$key);
+               $this->assertEqual(strlen($chunk),strlen($encrypted));
+               $decrypted=OC_Crypt::decrypt($encrypted,$key);
+               $this->assertEqual($decrypted,$chunk);
                
                $encrypted=OC_Crypt::blockEncrypt($source,$key);
                $decrypted=OC_Crypt::blockDecrypt($encrypted,$key);