add binary test case for encryption
This commit is contained in:
parent
e3f1507374
commit
0f2600e9ea
Binary file not shown.
|
@ -7,8 +7,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Test_CryptProxy extends UnitTestCase {
|
class Test_CryptProxy extends UnitTestCase {
|
||||||
|
private $oldConfig;
|
||||||
|
|
||||||
public function setUp(){
|
public function setUp(){
|
||||||
|
$this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true');
|
||||||
|
OCP\Config::setAppValue('files_encryption','enable_encryption','true');
|
||||||
|
|
||||||
|
|
||||||
//set testing key
|
//set testing key
|
||||||
$_SESSION['enckey']=md5(time());
|
$_SESSION['enckey']=md5(time());
|
||||||
|
|
||||||
|
@ -29,10 +34,11 @@ class Test_CryptProxy extends UnitTestCase {
|
||||||
$rootView->mkdir('/'.OC_User::getUser().'/files');
|
$rootView->mkdir('/'.OC_User::getUser().'/files');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function tearDown(){
|
||||||
|
OCP\Config::setAppValue('files_encryption','enable_encryption',$this->oldConfig);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSimple(){
|
public function testSimple(){
|
||||||
$oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true');
|
|
||||||
OCP\Config::setAppValue('files_encryption','enable_encryption','true');
|
|
||||||
|
|
||||||
$file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
|
$file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
|
||||||
$original=file_get_contents($file);
|
$original=file_get_contents($file);
|
||||||
|
|
||||||
|
@ -46,16 +52,42 @@ class Test_CryptProxy extends UnitTestCase {
|
||||||
$this->assertNotEqual($original,$stored);
|
$this->assertNotEqual($original,$stored);
|
||||||
$this->assertEqual($original,$fromFile);
|
$this->assertEqual($original,$fromFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testView(){
|
||||||
|
$file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
|
||||||
|
$original=file_get_contents($file);
|
||||||
|
|
||||||
$rootView=new OC_FilesystemView('');
|
$rootView=new OC_FilesystemView('');
|
||||||
$view=new OC_FilesystemView('/'.OC_User::getUser());
|
$view=new OC_FilesystemView('/'.OC_User::getUser());
|
||||||
$userDir='/'.OC_User::getUser().'/files';
|
$userDir='/'.OC_User::getUser().'/files';
|
||||||
|
|
||||||
|
$rootView->file_put_contents($userDir.'/file',$original);
|
||||||
|
|
||||||
|
OC_FileProxy::$enabled=false;
|
||||||
|
$stored=$rootView->file_get_contents($userDir.'/file');
|
||||||
|
OC_FileProxy::$enabled=true;
|
||||||
|
|
||||||
|
$this->assertNotEqual($original,$stored);
|
||||||
$fromFile=$rootView->file_get_contents($userDir.'/file');
|
$fromFile=$rootView->file_get_contents($userDir.'/file');
|
||||||
$this->assertEqual($original,$fromFile);
|
$this->assertEqual($original,$fromFile);
|
||||||
|
|
||||||
$fromFile=$view->file_get_contents('files/file');
|
$fromFile=$view->file_get_contents('files/file');
|
||||||
$this->assertEqual($original,$fromFile);
|
$this->assertEqual($original,$fromFile);
|
||||||
|
}
|
||||||
|
|
||||||
OCP\Config::setAppValue('files_encryption','enable_encryption',$oldConfig);
|
public function testBinary(){
|
||||||
|
$file=__DIR__.'/binary';
|
||||||
|
$original=file_get_contents($file);
|
||||||
|
|
||||||
|
OC_Filesystem::file_put_contents('/file',$original);
|
||||||
|
|
||||||
|
OC_FileProxy::$enabled=false;
|
||||||
|
$stored=OC_Filesystem::file_get_contents('/file');
|
||||||
|
OC_FileProxy::$enabled=true;
|
||||||
|
|
||||||
|
$fromFile=OC_Filesystem::file_get_contents('/file');
|
||||||
|
$this->assertNotEqual($original,$stored);
|
||||||
|
$this->assertEqual($original,$fromFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue