add test cases for cryptstream
This commit is contained in:
parent
b39c3d4c4e
commit
d1ad4dc8d6
|
@ -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'));
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ class Test_Encryption extends UnitTestCase {
|
|||
$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);
|
||||
$this->assertNotEqual($encrypted,$source);
|
||||
|
|
Loading…
Reference in New Issue