[Pkg-owncloud-commits] [owncloud] 27/457: also encrypt files in trash bin

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:05:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 7d492fefae25ce11944ac611229eb3a949908e55
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Mon May 18 12:51:47 2015 +0200

    also encrypt files in trash bin
---
 apps/encryption/lib/crypto/encryption.php          |  5 ++++-
 .../encryption/tests/lib/crypto/encryptionTest.php | 25 ++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php
index a4abcd7..f19638d 100644
--- a/apps/encryption/lib/crypto/encryption.php
+++ b/apps/encryption/lib/crypto/encryption.php
@@ -321,7 +321,7 @@ class Encryption implements IEncryptionModule {
 	 */
 	public function shouldEncrypt($path) {
 		$parts = explode('/', $path);
-		if (count($parts) < 3) {
+		if (count($parts) < 4) {
 			return false;
 		}
 
@@ -331,6 +331,9 @@ class Encryption implements IEncryptionModule {
 		if ($parts[2] == 'files_versions') {
 			return true;
 		}
+		if ($parts[2] == 'files_trashbin') {
+			return true;
+		}
 
 		return false;
 	}
diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/lib/crypto/encryptionTest.php
index aa28a8b..960ed11 100644
--- a/apps/encryption/tests/lib/crypto/encryptionTest.php
+++ b/apps/encryption/tests/lib/crypto/encryptionTest.php
@@ -220,4 +220,29 @@ class EncryptionTest extends TestCase {
 		);
 	}
 
+	/**
+	 * by default the encryption module should encrypt regular files, files in
+	 * files_versions and files in files_trashbin
+	 *
+	 * @dataProvider dataTestShouldEncrypt
+	 */
+	public function testShouldEncrypt($path, $expected) {
+		$this->assertSame($expected,
+			$this->instance->shouldEncrypt($path)
+		);
+	}
+
+	public function dataTestShouldEncrypt() {
+		return array(
+			array('/user1/files/foo.txt', true),
+			array('/user1/files_versions/foo.txt', true),
+			array('/user1/files_trashbin/foo.txt', true),
+			array('/user1/some_folder/foo.txt', false),
+			array('/user1/foo.txt', false),
+			array('/user1/files', false),
+			array('/user1/files_trashbin', false),
+			array('/user1/files_versions', false),
+		);
+	}
+
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list