diff options
author | Joas Schilling <coding@schilljs.com> | 2017-08-18 13:03:40 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-08-18 13:21:53 +0200 |
commit | d5c6d56170aa4432db930a92436b7c997d5003fd (patch) | |
tree | 6bf8789074378123d37d3139775b772c2923dfbc /tests/Core/Controller | |
parent | 231cffffb9084ed1b7779f40ec07ad617ec71a30 (diff) | |
download | nextcloud-server-d5c6d56170aa4432db930a92436b7c997d5003fd.tar.gz nextcloud-server-d5c6d56170aa4432db930a92436b7c997d5003fd.zip |
No password reset for disabled users
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/Core/Controller')
-rw-r--r-- | tests/Core/Controller/LostControllerTest.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index ef419e40b40..0bdc11f8a2f 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -84,6 +84,9 @@ class LostControllerTest extends \Test\TestCase { $this->existingUser->expects($this->any()) ->method('getUID') ->willReturn('ExistingUser'); + $this->existingUser->expects($this->any()) + ->method('isEnabled') + ->willReturn(true); $this->config = $this->createMock(IConfig::class); $this->config->expects($this->any()) @@ -684,8 +687,34 @@ class LostControllerTest extends \Test\TestCase { $this->assertSame($expectedResponse, $response); } + public function testSetPasswordForDisabledUser() { + $user = $this->createMock(IUser::class); + $user->expects($this->any()) + ->method('isEnabled') + ->willReturn(false); + $user->expects($this->never()) + ->method('setPassword'); + + $this->config->method('getUserValue') + ->with('ValidTokenUser', 'core', 'lostpassword', null) + ->willReturn('encryptedData'); + $this->userManager->method('get') + ->with('DisabledUser') + ->willReturn($this->existingUser); + + $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'DisabledUser', 'NewPassword', true); + $expectedResponse = [ + 'status' => 'error', + 'msg' => 'Couldn\'t reset password because the token is invalid' + ]; + $this->assertSame($expectedResponse, $response); + } + public function testSendEmailNoEmail() { $user = $this->createMock(IUser::class); + $user->expects($this->any()) + ->method('isEnabled') + ->willReturn(true); $this->userManager->method('userExists') ->with('ExistingUser') ->willReturn(true); |