diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2020-05-26 00:00:00 +0300 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2020-05-26 17:53:25 +0300 |
commit | 653162a70952be9c4bcdf9fb01df3b3f14031a20 (patch) | |
tree | ae170cda88dffb05a7f1fd08cd3f5c6e80ad10e5 /tests/Core | |
parent | 4bada5c7324d4ebf58a8ab2c8954b8e35cc883b2 (diff) |
use the loginname to verify the old password in user password changes
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests/Core')
-rw-r--r-- | tests/Core/Controller/ChangePasswordControllerTest.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php index 175628552bc..21a80b61063 100644 --- a/tests/Core/Controller/ChangePasswordControllerTest.php +++ b/tests/Core/Controller/ChangePasswordControllerTest.php @@ -36,6 +36,8 @@ use OCP\IUserManager; class ChangePasswordControllerTest extends \Test\TestCase { /** @var string */ private $userId = 'currentUser'; + /** @var string */ + private $loginName = 'ua1337'; /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ private $userManager; /** @var Session|\PHPUnit_Framework_MockObject_MockObject */ @@ -75,9 +77,13 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPasswordWrongPassword() { + $this->userSession->expects($this->once()) + ->method('getLoginName') + ->willReturn($this->loginName); + $this->userManager->expects($this->once()) ->method('checkPassword') - ->with($this->userId, 'old') + ->with($this->loginName, 'old') ->willReturn(false); $expects = new JSONResponse([ @@ -93,10 +99,14 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPasswordCommonPassword() { + $this->userSession->expects($this->once()) + ->method('getLoginName') + ->willReturn($this->loginName); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') - ->with($this->userId, 'old') + ->with($this->loginName, 'old') ->willReturn($user); $user->expects($this->once()) @@ -116,10 +126,14 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPasswordNoNewPassword() { + $this->userSession->expects($this->once()) + ->method('getLoginName') + ->willReturn($this->loginName); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') - ->with($this->userId, 'old') + ->with($this->loginName, 'old') ->willReturn($user); $expects = [ @@ -132,10 +146,14 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPasswordCantSetPassword() { + $this->userSession->expects($this->once()) + ->method('getLoginName') + ->willReturn($this->loginName); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') - ->with($this->userId, 'old') + ->with($this->loginName, 'old') ->willReturn($user); $user->expects($this->once()) @@ -152,10 +170,14 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPassword() { + $this->userSession->expects($this->once()) + ->method('getLoginName') + ->willReturn($this->loginName); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') - ->with($this->userId, 'old') + ->with($this->loginName, 'old') ->willReturn($user); $user->expects($this->once()) |