|
|
|
@ -54,6 +54,9 @@ class SettingsControllerTest extends TestCase { |
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject */ |
|
|
|
private $sessionMock; |
|
|
|
|
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject */ |
|
|
|
private $ocSessionMock; |
|
|
|
|
|
|
|
protected function setUp() { |
|
|
|
|
|
|
|
parent::setUp(); |
|
|
|
@ -91,9 +94,11 @@ class SettingsControllerTest extends TestCase { |
|
|
|
]) |
|
|
|
->getMock(); |
|
|
|
|
|
|
|
$this->ocSessionMock = $this->getMockBuilder('\OCP\ISession')->disableOriginalConstructor()->getMock(); |
|
|
|
|
|
|
|
$this->userSessionMock->expects($this->any()) |
|
|
|
->method('getUID') |
|
|
|
->willReturn('testUser'); |
|
|
|
->willReturn('testUserUid'); |
|
|
|
|
|
|
|
$this->userSessionMock->expects($this->any()) |
|
|
|
->method($this->anything()) |
|
|
|
@ -110,7 +115,8 @@ class SettingsControllerTest extends TestCase { |
|
|
|
$this->userSessionMock, |
|
|
|
$this->keyManagerMock, |
|
|
|
$this->cryptMock, |
|
|
|
$this->sessionMock |
|
|
|
$this->sessionMock, |
|
|
|
$this->ocSessionMock |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ -122,8 +128,10 @@ class SettingsControllerTest extends TestCase { |
|
|
|
$oldPassword = 'old'; |
|
|
|
$newPassword = 'new'; |
|
|
|
|
|
|
|
$this->userSessionMock->expects($this->once())->method('getUID')->willReturn('uid'); |
|
|
|
|
|
|
|
$this->userManagerMock |
|
|
|
->expects($this->once()) |
|
|
|
->expects($this->exactly(2)) |
|
|
|
->method('checkPassword') |
|
|
|
->willReturn(false); |
|
|
|
|
|
|
|
@ -171,16 +179,22 @@ class SettingsControllerTest extends TestCase { |
|
|
|
$oldPassword = 'old'; |
|
|
|
$newPassword = 'new'; |
|
|
|
|
|
|
|
$this->userSessionMock |
|
|
|
->expects($this->once()) |
|
|
|
->method('getUID') |
|
|
|
->willReturn('testUser'); |
|
|
|
$this->ocSessionMock->expects($this->once()) |
|
|
|
->method('get')->with('loginname')->willReturn('testUser'); |
|
|
|
|
|
|
|
$this->userManagerMock |
|
|
|
->expects($this->once()) |
|
|
|
->expects($this->at(0)) |
|
|
|
->method('checkPassword') |
|
|
|
->with('testUserUid', 'new') |
|
|
|
->willReturn(false); |
|
|
|
$this->userManagerMock |
|
|
|
->expects($this->at(1)) |
|
|
|
->method('checkPassword') |
|
|
|
->with('testUser', 'new') |
|
|
|
->willReturn(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->cryptMock |
|
|
|
->expects($this->once()) |
|
|
|
->method('decryptPrivateKey') |
|
|
|
@ -200,7 +214,7 @@ class SettingsControllerTest extends TestCase { |
|
|
|
$this->keyManagerMock |
|
|
|
->expects($this->once()) |
|
|
|
->method('setPrivateKey') |
|
|
|
->with($this->equalTo('testUser'), $this->equalTo('header.encryptedKey')); |
|
|
|
->with($this->equalTo('testUserUid'), $this->equalTo('header.encryptedKey')); |
|
|
|
|
|
|
|
$this->sessionMock |
|
|
|
->expects($this->once()) |
|
|
|
|