diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-10-06 10:24:02 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-10-06 10:55:33 +0200 |
commit | c84dc6aa1c523e8125ff6194ae944a465ebcd78b (patch) | |
tree | ffde3bcfb0dcec19ad82815ffe4c77b9f9e206a8 /tests | |
parent | ea9b1cc3409f39c545505bbcddb7a20fda114c0e (diff) | |
download | nextcloud-server-c84dc6aa1c523e8125ff6194ae944a465ebcd78b.tar.gz nextcloud-server-c84dc6aa1c523e8125ff6194ae944a465ebcd78b.zip |
Properly catch password policy hint for personal page password changes
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/ChangePasswordControllerTest.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php index 8dd4ca8db95..869ef98b514 100644 --- a/tests/Core/Controller/ChangePasswordControllerTest.php +++ b/tests/Core/Controller/ChangePasswordControllerTest.php @@ -21,6 +21,7 @@ */ namespace Tests\Core\Controller; +use OC\HintException; use OC\Settings\Controller\ChangePasswordController; use OC\User\Session; use OCP\App\IAppManager; @@ -94,6 +95,30 @@ class ChangePasswordControllerTest extends \Test\TestCase { $this->assertEquals($expects, $res->getData()); } + public function testChangePersonalPasswordCommonPassword() { + $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $this->userManager->expects($this->once()) + ->method('checkPassword') + ->with($this->userId, 'old') + ->willReturn($user); + + $user->expects($this->once()) + ->method('setPassword') + ->with('new') + ->will($this->throwException(new HintException('Common password'))); + + $expects = [ + 'status' => 'error', + 'data' => [ + 'message' => 'Common password', + ], + ]; + + $res = $this->controller->changePersonalPassword('old', 'new'); + + $this->assertEquals($expects, $res->getData()); + } + public function testChangePersonalPasswordNoNewPassword() { $user = $this->getMockBuilder('OCP\IUser')->getMock(); $this->userManager->expects($this->once()) |