Add unit tests for empty token
This commit is contained in:
parent
35afb0d22e
commit
ba29ea178f
|
@ -141,7 +141,7 @@ class LostController extends Controller {
|
|||
* @return array
|
||||
*/
|
||||
public function setPassword($token, $userId, $password, $proceed) {
|
||||
if ($this->isDataEncrypted && !$proceed){
|
||||
if ($this->isDataEncrypted && !$proceed) {
|
||||
return $this->error('', array('encryption' => true));
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
|
|||
$this->container['Config']
|
||||
->expects($this->once())
|
||||
->method('getUserValue')
|
||||
->with('InvalidTokenUser', 'owncloud', 'lostpassword')
|
||||
->with('InvalidTokenUser', 'owncloud', 'lostpassword', null)
|
||||
->will($this->returnValue('TheOnlyAndOnlyOneTokenToResetThePassword'));
|
||||
|
||||
// With an invalid token
|
||||
|
@ -178,7 +178,7 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
|
|||
$this->container['Config']
|
||||
->expects($this->once())
|
||||
->method('getUserValue')
|
||||
->with('ValidTokenUser', 'owncloud', 'lostpassword')
|
||||
->with('ValidTokenUser', 'owncloud', 'lostpassword', null)
|
||||
->will($this->returnValue('TheOnlyAndOnlyOneTokenToResetThePassword'));
|
||||
$user = $this->getMockBuilder('\OCP\IUser')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
|
@ -200,4 +200,17 @@ class LostControllerTest extends \PHPUnit_Framework_TestCase {
|
|||
$expectedResponse = array('status' => 'success');
|
||||
$this->assertSame($expectedResponse, $response);
|
||||
}
|
||||
|
||||
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' => ''];
|
||||
$this->assertSame($expectedResponse, $response);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue