summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-17 10:52:40 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-04-17 13:26:38 +0200
commit195a48b2b85ee324b98cda88a8e17546b33b895d (patch)
tree7becd87b31fee37db33399e778caa749fdfdc6b5 /apps/encryption/tests
parentf32d97750c33942db53a56d1deceacb2ed3e779b (diff)
downloadnextcloud-server-195a48b2b85ee324b98cda88a8e17546b33b895d.tar.gz
nextcloud-server-195a48b2b85ee324b98cda88a8e17546b33b895d.zip
fix change password if no user is logged in, occ call
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r--apps/encryption/tests/hooks/UserHooksTest.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/apps/encryption/tests/hooks/UserHooksTest.php b/apps/encryption/tests/hooks/UserHooksTest.php
index 1d76e3ba1a2..bcfb33e86cb 100644
--- a/apps/encryption/tests/hooks/UserHooksTest.php
+++ b/apps/encryption/tests/hooks/UserHooksTest.php
@@ -143,6 +143,35 @@ class UserHooksTest extends TestCase {
$this->assertNull($this->instance->setPassphrase($this->params));
}
+ public function testSetPasswordNoUser() {
+ $this->sessionMock->expects($this->once())
+ ->method('getPrivateKey')
+ ->willReturn(true);
+
+ $userSessionMock = $this->getMockBuilder('OCP\IUserSession')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $userSessionMock->expects($this->any())->method('getUser')->will($this->returnValue(null));
+
+ $this->recoveryMock->expects($this->once())
+ ->method('isRecoveryEnabledForUser')
+ ->with('testUser')
+ ->willReturn(false);
+
+ $userHooks = new UserHooks($this->keyManagerMock,
+ $this->loggerMock,
+ $this->userSetupMock,
+ $userSessionMock,
+ $this->utilMock,
+ $this->sessionMock,
+ $this->cryptMock,
+ $this->recoveryMock
+ );
+
+ $this->assertNull($userHooks->setPassphrase($this->params));
+ }
+
public function testPostPasswordReset() {
$this->keyManagerMock->expects($this->once())
->method('replaceUserKeys')
@@ -157,7 +186,7 @@ class UserHooksTest extends TestCase {
protected function setUp() {
parent::setUp();
- $loggerMock = $this->getMock('OCP\ILogger');
+ $this->loggerMock = $this->getMock('OCP\ILogger');
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')
->disableOriginalConstructor()
->getMock();
@@ -203,7 +232,7 @@ class UserHooksTest extends TestCase {
$this->recoveryMock = $recoveryMock;
$this->utilMock = $utilMock;
$this->instance = new UserHooks($this->keyManagerMock,
- $loggerMock,
+ $this->loggerMock,
$this->userSetupMock,
$this->userSessionMock,
$this->utilMock,