예제 #1
0
 public function testIsSetPasswordWithoutTokenFailing()
 {
     $this->container['Config']->expects($this->once())->method('getUserValue')->with('ValidTokenUser', 'owncloud', 'lostpassword', null)->will($this->returnValue(null));
     $response = $this->lostController->setPassword('', 'ValidTokenUser', 'NewPassword', true);
     $expectedResponse = ['status' => 'error', 'msg' => 'Couldn\'t reset password because the token is invalid'];
     $this->assertSame($expectedResponse, $response);
 }
예제 #2
0
 public function testSetPasswordSuccessful()
 {
     $this->container['Config']->expects($this->once())->method('getUserValue')->with('ValidTokenUser', 'owncloud', 'lostpassword')->will($this->returnValue('TheOnlyAndOnlyOneTokenToResetThePassword'));
     $user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
     $user->expects($this->once())->method('setPassword')->with('NewPassword')->will($this->returnValue(true));
     $this->container['UserManager']->expects($this->once())->method('get')->with('ValidTokenUser')->will($this->returnValue($user));
     $this->container['Config']->expects($this->once())->method('deleteUserValue')->with('ValidTokenUser', 'owncloud', 'lostpassword');
     $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
     $expectedResponse = array('status' => 'success');
     $this->assertSame($expectedResponse, $response);
 }