summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-06-15 23:11:33 +0200
committerRobin Appelman <icewind@owncloud.com>2012-06-15 23:11:33 +0200
commit19bfe214010e4cc3730d9718def20b88d379fed5 (patch)
tree228404711690a4a635cba9c99ee3a0c7cce71409 /apps/files_encryption
parentcb833e45c230effac2194ae79e48a5d710c4d064 (diff)
downloadnextcloud-server-19bfe214010e4cc3730d9718def20b88d379fed5.tar.gz
nextcloud-server-19bfe214010e4cc3730d9718def20b88d379fed5.zip
add binary test case for encryption
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/tests/binarybin0 -> 9734 bytes
-rw-r--r--apps/files_encryption/tests/proxy.php40
2 files changed, 36 insertions, 4 deletions
diff --git a/apps/files_encryption/tests/binary b/apps/files_encryption/tests/binary
new file mode 100644
index 00000000000..79bc99479da
--- /dev/null
+++ b/apps/files_encryption/tests/binary
Binary files differ
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php
index f36b2193430..5616e2091a9 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -7,8 +7,13 @@
*/
class Test_CryptProxy extends UnitTestCase {
+ private $oldConfig;
public function setUp(){
+ $this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true');
+ OCP\Config::setAppValue('files_encryption','enable_encryption','true');
+
+
//set testing key
$_SESSION['enckey']=md5(time());
@@ -29,10 +34,11 @@ class Test_CryptProxy extends UnitTestCase {
$rootView->mkdir('/'.OC_User::getUser().'/files');
}
+ public function tearDown(){
+ OCP\Config::setAppValue('files_encryption','enable_encryption',$this->oldConfig);
+ }
+
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';
$original=file_get_contents($file);
@@ -46,16 +52,42 @@ class Test_CryptProxy extends UnitTestCase {
$this->assertNotEqual($original,$stored);
$this->assertEqual($original,$fromFile);
+ }
+
+ public function testView(){
+ $file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
+ $original=file_get_contents($file);
+
$rootView=new OC_FilesystemView('');
$view=new OC_FilesystemView('/'.OC_User::getUser());
$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');
$this->assertEqual($original,$fromFile);
$fromFile=$view->file_get_contents('files/file');
$this->assertEqual($original,$fromFile);
+ }
+
+ public function testBinary(){
+ $file=__DIR__.'/binary';
+ $original=file_get_contents($file);
+
+ OC_Filesystem::file_put_contents('/file',$original);
- OCP\Config::setAppValue('files_encryption','enable_encryption',$oldConfig);
+ 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);
}
}