summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-12-18 16:39:34 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2014-02-27 18:02:05 +0100
commit7ced22ccc67de4d5b44e507c2083b6357a762075 (patch)
treec3aed8aee4cb56d40c298578eb0d4cda0f68c9ac /apps/files_encryption
parent6455722f2962457a010264be31b212c14e5fca43 (diff)
downloadnextcloud-server-7ced22ccc67de4d5b44e507c2083b6357a762075.tar.gz
nextcloud-server-7ced22ccc67de4d5b44e507c2083b6357a762075.zip
test for isEncryptedPath()
Diffstat (limited to 'apps/files_encryption')
-rwxr-xr-xapps/files_encryption/tests/util.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index af422a3c52b..863ea73b22c 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -136,6 +136,41 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
/**
* @medium
+ * @brief test detection of encrypted files
+ */
+ function testIsEncryptedPath() {
+
+ $util = new Encryption\Util($this->view, $this->userId);
+
+ self::loginHelper($this->userId);
+
+ $unencryptedFile = '/tmpUnencrypted-' . time() . '.txt';
+ $encryptedFile = '/tmpEncrypted-' . time() . '.txt';
+
+ // Disable encryption proxy to write a unencrypted file
+ $proxyStatus = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
+
+ $this->view->file_put_contents($this->userId . '/files/' . $unencryptedFile, $this->dataShort);
+
+ // Re-enable proxy - our work is done
+ \OC_FileProxy::$enabled = $proxyStatus;
+
+ // write a encrypted file
+ $this->view->file_put_contents($this->userId . '/files/' . $encryptedFile, $this->dataShort);
+
+ // test if both files are detected correctly
+ $this->assertFalse($util->isEncryptedPath($this->userId . '/files/' . $unencryptedFile));
+ $this->assertTrue($util->isEncryptedPath($this->userId . '/files/' . $encryptedFile));
+
+ // cleanup
+ $this->view->unlink($this->userId . '/files/' . $unencryptedFile, $this->dataShort);
+ $this->view->unlink($this->userId . '/files/' . $encryptedFile, $this->dataShort);
+
+ }
+
+ /**
+ * @medium
* @brief test setup of encryption directories
*/
function testSetupServerSide() {