diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-12-22 11:18:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 11:18:04 +0100 |
commit | 998f235474c542e2e4a1ad16cc91bcf62a6ec84e (patch) | |
tree | 16ed1e50660b01e8baf6d2cfd5bddfa3e0735149 /tests | |
parent | 1588dd0ee037e2f1e92e689b717815eb0d37cb20 (diff) | |
parent | 16bbd3fd7c3956b48a0f85d9479a27ccc5d9ecf2 (diff) | |
download | nextcloud-server-998f235474c542e2e4a1ad16cc91bcf62a6ec84e.tar.gz nextcloud-server-998f235474c542e2e4a1ad16cc91bcf62a6ec84e.zip |
Merge pull request #2563 from nextcloud/fix-password-reset
fix password reset if encryption is enabled
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/LostControllerTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index 605298b66cf..3e7456648e4 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -23,6 +23,7 @@ namespace Tests\Core\Controller; use OC\Core\Controller\LostController; use OC\Mail\Message; +use OCA\Encryption\Exceptions\PrivateKeyMissingException; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Encryption\IManager; @@ -590,4 +591,42 @@ class LostControllerTest extends \Test\TestCase { $this->assertSame($expectedResponse, $response); } + public function testSetPasswordEncryptionProceed() { + + /** @var LostController | PHPUnit_Framework_MockObject_MockObject $lostController */ + $lostController = $this->getMockBuilder(LostController::class) + ->setConstructorArgs( + [ + 'Core', + $this->request, + $this->urlGenerator, + $this->userManager, + $this->defaults, + $this->l10n, + $this->config, + $this->secureRandom, + 'lostpassword-noreply@localhost', + $this->encryptionManager, + $this->mailer, + $this->timeFactory, + $this->crypto + ] + )->setMethods(['checkPasswordResetToken'])->getMock(); + + $lostController->expects($this->once())->method('checkPasswordResetToken')->willReturn(true); + + $user = $this->createMock(IUser::class); + $user->method('setPassword')->willReturnCallback( + function() { + throw new PrivateKeyMissingException('user'); + } + ); + $this->userManager->method('get')->with('user')->willReturn($user); + + $response = $lostController->setPassword('myToken', 'user', 'newpass', true); + + $expectedResponse = ['status' => 'success']; + $this->assertSame($expectedResponse, $response); + } + } |