summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2016-04-20 17:05:35 +0200
committerBjörn Schießle <schiessle@owncloud.com>2016-04-20 17:05:35 +0200
commit6cfe339765da4bcd3fc86be22ee3a26b43c257d6 (patch)
treea83395b9109be4ab3504d948aa4474df271283fc
parentc01ad6d895c2c508ea7eecdb157273b8638f4375 (diff)
parent813392f0e7dcd46e0122ea786be21757f3a24799 (diff)
downloadnextcloud-server-6cfe339765da4bcd3fc86be22ee3a26b43c257d6.tar.gz
nextcloud-server-6cfe339765da4bcd3fc86be22ee3a26b43c257d6.zip
Merge pull request #24101 from owncloud/fix_23632_8.1
[stable8.1] init users mount point before recovery
-rw-r--r--apps/encryption/hooks/userhooks.php11
-rw-r--r--apps/encryption/tests/hooks/UserHooksTest.php47
2 files changed, 48 insertions, 10 deletions
diff --git a/apps/encryption/hooks/userhooks.php b/apps/encryption/hooks/userhooks.php
index b7a40a6d735..f1fd5d394d3 100644
--- a/apps/encryption/hooks/userhooks.php
+++ b/apps/encryption/hooks/userhooks.php
@@ -24,6 +24,7 @@
namespace OCA\Encryption\Hooks;
+use OC\Files\Filesystem;
use OCP\IUserManager;
use OCP\Util as OCUtil;
use OCA\Encryption\Hooks\Contracts\IHook;
@@ -244,6 +245,7 @@ class UserHooks implements IHook {
// used to decrypt it has changed
} else { // admin changed the password for a different user, create new keys and re-encrypt file keys
$user = $params['uid'];
+ $this->initMountPoints($user);
$recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null;
// we generate new keys if...
@@ -283,6 +285,15 @@ class UserHooks implements IHook {
}
}
+ /**
+ * init mount points for given user
+ *
+ * @param string $user
+ * @throws \OC\User\NoUserException
+ */
+ protected function initMountPoints($user) {
+ Filesystem::initMountPoints($user);
+ }
/**
diff --git a/apps/encryption/tests/hooks/UserHooksTest.php b/apps/encryption/tests/hooks/UserHooksTest.php
index 86a4ba57893..086fb8ba27d 100644
--- a/apps/encryption/tests/hooks/UserHooksTest.php
+++ b/apps/encryption/tests/hooks/UserHooksTest.php
@@ -30,6 +30,12 @@ use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Hooks\UserHooks;
use Test\TestCase;
+/**
+ * Class UserHooksTest
+ *
+ * @group DB
+ * @package OCA\Encryption\Tests\Hooks
+ */
class UserHooksTest extends TestCase {
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -191,6 +197,23 @@ class UserHooksTest extends TestCase {
->willReturnOnConsecutiveCalls(true, false);
+ $this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks')
+ ->setConstructorArgs(
+ [
+ $this->keyManagerMock,
+ $this->userManagerMock,
+ $this->loggerMock,
+ $this->userSetupMock,
+ $this->userSessionMock,
+ $this->utilMock,
+ $this->sessionMock,
+ $this->cryptMock,
+ $this->recoveryMock
+ ]
+ )->setMethods(['initMountPoints'])->getMock();
+
+ $this->instance->expects($this->exactly(3))->method('initMountPoints');
+
// Test first if statement
$this->assertNull($this->instance->setPassphrase($this->params));
@@ -237,16 +260,20 @@ class UserHooksTest extends TestCase {
->with('testUser')
->willReturn(false);
- $userHooks = new UserHooks($this->keyManagerMock,
- $this->userManagerMock,
- $this->loggerMock,
- $this->userSetupMock,
- $userSessionMock,
- $this->utilMock,
- $this->sessionMock,
- $this->cryptMock,
- $this->recoveryMock
- );
+ $userHooks = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks')
+ ->setConstructorArgs(
+ [
+ $this->keyManagerMock,
+ $this->userManagerMock,
+ $this->loggerMock,
+ $this->userSetupMock,
+ $userSessionMock,
+ $this->utilMock,
+ $this->sessionMock,
+ $this->cryptMock,
+ $this->recoveryMock
+ ]
+ )->setMethods(['initMountPoints'])->getMock();
$this->assertNull($userHooks->setPassphrase($this->params));
}