summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapps/files_encryption/tests/util.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 1b93bc36c8e..0f21ed96e45 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -281,6 +281,70 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->util->isSharedPath($path));
}
+ function testEncryptAll() {
+
+ $filename = "/encryptAll" . time() . ".txt";
+ $util = new Encryption\Util($this->view, $this->userId);
+
+ // disable encryption to upload a unencrypted file
+ \OC_App::disable('files_encryption');
+
+ $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort);
+
+ $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
+
+ $this->assertTrue(is_array($fileInfoUnencrypted));
+
+ // enable file encryption again
+ \OC_App::enable('files_encryption');
+
+ // encrypt all unencrypted files
+ $util->encryptAll('/' . $this->userId . '/' . 'files');
+
+ $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
+
+ $this->assertTrue(is_array($fileInfoEncrypted));
+
+ // check if mtime and etags unchanged
+ $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
+ $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
+
+ $this->view->unlink($this->userId . '/files/' . $filename);
+ }
+
+
+ function testDecryptAll() {
+
+ $filename = "/decryptAll" . time() . ".txt";
+ $util = new Encryption\Util($this->view, $this->userId);
+
+ $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort);
+
+ $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
+
+ print("\n File Info Encrypted\n");
+ print_r($fileInfoEncrypted);
+
+ $this->assertTrue(is_array($fileInfoEncrypted));
+
+ // encrypt all unencrypted files
+ $util->decryptAll('/' . $this->userId . '/' . 'files');
+
+ $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
+
+ print("\n File Info Unencrypted\n");
+ print_r($fileInfoUnencrypted);
+
+ $this->assertTrue(is_array($fileInfoUnencrypted));
+
+ // check if mtime and etags unchanged
+ $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
+ $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
+
+ $this->view->unlink($this->userId . '/files/' . $filename);
+
+ }
+
/**
* @large
*/