summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-11-12 13:33:41 +0100
committerVincent Petry <pvince81@owncloud.com>2014-11-20 16:43:44 +0100
commit391ece46e3c92f0e1e0cc25ce110943a25df3b0c (patch)
tree4b9770775507c8cf29ddf7f0f0b9ec1f80b72ba6 /apps/files_encryption/tests
parent604bf61e10793553c90248e9e917f5fc1b54d2b5 (diff)
downloadnextcloud-server-391ece46e3c92f0e1e0cc25ce110943a25df3b0c.tar.gz
nextcloud-server-391ece46e3c92f0e1e0cc25ce110943a25df3b0c.zip
Fix file upload to ext storage when recovery key is enabled
Fixes an issue when uploading files to external storage when recovery keys are enabled The Util class only works with real users, so instantiating it with the virtual recovery key user or public key user can cause issues.
Diffstat (limited to 'apps/files_encryption/tests')
-rwxr-xr-xapps/files_encryption/tests/util.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index bbf6efae5b9..b8057202a07 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -550,6 +550,43 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
}
/**
+ * Tests that filterShareReadyUsers() returns the correct list of
+ * users that are ready or not ready for encryption
+ */
+ public function testFilterShareReadyUsers() {
+ $appConfig = \OC::$server->getAppConfig();
+
+ $publicShareKeyId = $appConfig->getValue('files_encryption', 'publicShareKeyId');
+ $recoveryKeyId = $appConfig->getValue('files_encryption', 'recoveryKeyId');
+
+ $usersToTest = array(
+ 'readyUser',
+ 'notReadyUser',
+ 'nonExistingUser',
+ $publicShareKeyId,
+ $recoveryKeyId,
+ );
+ \Test_Encryption_Util::loginHelper('readyUser', true);
+ \Test_Encryption_Util::loginHelper('notReadyUser', true);
+ // delete encryption dir to make it not ready
+ $this->view->unlink('notReadyUser/files_encryption/');
+
+ // login as user1
+ \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
+
+ $result = $this->util->filterShareReadyUsers($usersToTest);
+ $this->assertEquals(
+ array('readyUser', $publicShareKeyId, $recoveryKeyId),
+ $result['ready']
+ );
+ $this->assertEquals(
+ array('notReadyUser', 'nonExistingUser'),
+ $result['unready']
+ );
+ \OC_User::deleteUser('readyUser');
+ }
+
+ /**
* @param string $user
* @param bool $create
* @param bool $password