summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-05-30 14:03:47 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2017-07-06 11:47:11 +0200
commit1a55ace97c3671ec0bed91301aed4ca29456a43f (patch)
treea2001ba55dde8f939edbd0ff77b171c5f6f97631 /tests
parentd668e17769cfe4ccf82794fa75a3f80995b8e43b (diff)
downloadnextcloud-server-1a55ace97c3671ec0bed91301aed4ca29456a43f.tar.gz
nextcloud-server-1a55ace97c3671ec0bed91301aed4ca29456a43f.zip
no warning on password change if no encryption module uses per-user keys
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/Controller/UsersControllerTest.php36
1 files changed, 32 insertions, 4 deletions
diff --git a/tests/Settings/Controller/UsersControllerTest.php b/tests/Settings/Controller/UsersControllerTest.php
index 0780f5219c0..cd08c834147 100644
--- a/tests/Settings/Controller/UsersControllerTest.php
+++ b/tests/Settings/Controller/UsersControllerTest.php
@@ -20,6 +20,8 @@ use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\Files\Config\IUserMountCache;
+use OCP\Encryption\IEncryptionModule;
+use OCP\Encryption\IManager;
use OCP\IAvatar;
use OCP\IAvatarManager;
use OCP\IConfig;
@@ -82,6 +84,10 @@ class UsersControllerTest extends \Test\TestCase {
private $securityManager;
/** @var IUserMountCache |\PHPUnit_Framework_MockObject_MockObject */
private $userMountCache;
+ /** @var IManager | \PHPUnit_Framework_MockObject_MockObject */
+ private $encryptionManager;
+ /** @var IEncryptionModule | \PHPUnit_Framework_MockObject_MockObject */
+ private $encryptionModule;
protected function setUp() {
parent::setUp();
@@ -104,6 +110,7 @@ class UsersControllerTest extends \Test\TestCase {
$this->crypto = $this->createMock(ICrypto::class);
$this->securityManager = $this->getMockBuilder(\OC\Security\IdentityProof\Manager::class)->disableOriginalConstructor()->getMock();
$this->jobList = $this->createMock(IJobList::class);
+ $this->encryptionManager = $this->createMock(IManager::class);
$this->l = $this->createMock(IL10N::class);
$this->l->method('t')
->will($this->returnCallback(function ($text, $parameters = []) {
@@ -111,6 +118,10 @@ class UsersControllerTest extends \Test\TestCase {
}));
$this->userMountCache = $this->createMock(IUserMountCache::class);
+ $this->encryptionModule = $this->createMock(IEncryptionModule::class);
+ $this->encryptionManager->expects($this->any())->method('getEncryptionModules')
+ ->willReturn(['encryptionModule' => ['callback' => function() { return $this->encryptionModule;}]]);
+
/*
* Set default avatar behaviour for whole test suite
*/
@@ -154,8 +165,8 @@ class UsersControllerTest extends \Test\TestCase {
$this->crypto,
$this->securityManager,
$this->jobList,
- $this->userMountCache
-
+ $this->userMountCache,
+ $this->encryptionManager
);
} else {
return $this->getMockBuilder(UsersController::class)
@@ -182,6 +193,7 @@ class UsersControllerTest extends \Test\TestCase {
$this->securityManager,
$this->jobList,
$this->userMountCache,
+ $this->encryptionManager
]
)->setMethods($mockedMethods)->getMock();
}
@@ -1689,9 +1701,17 @@ class UsersControllerTest extends \Test\TestCase {
$this->assertEquals($expectedResult, $result);
}
- public function testRestoreNotPossibleWithoutAdminRestore() {
+ /**
+ * @dataProvider dataTestRestoreNotPossibleWithoutAdminRestore
+ *
+ * @param bool $masterKeyEnabled
+ */
+ public function testRestoreNotPossibleWithoutAdminRestore($masterKeyEnabled) {
list($user, $expectedResult) = $this->mockUser();
+ // without the master key enabled we use per-user keys
+ $this->encryptionModule->expects($this->once())->method('needDetailedAccessList')->willReturn(!$masterKeyEnabled);
+
$this->appManager
->method('isEnabledForUser')
->with(
@@ -1699,7 +1719,8 @@ class UsersControllerTest extends \Test\TestCase {
)
->will($this->returnValue(true));
- $expectedResult['isRestoreDisabled'] = true;
+ // without the master key enabled we use per-user keys -> restore is disabled
+ $expectedResult['isRestoreDisabled'] = !$masterKeyEnabled;
$subadmin = $this->getMockBuilder('\OC\SubAdmin')
->disableOriginalConstructor()
@@ -1718,6 +1739,13 @@ class UsersControllerTest extends \Test\TestCase {
$this->assertEquals($expectedResult, $result);
}
+ public function dataTestRestoreNotPossibleWithoutAdminRestore() {
+ return [
+ [true],
+ [false]
+ ];
+ }
+
public function testRestoreNotPossibleWithoutUserRestore() {
list($user, $expectedResult) = $this->mockUser();