]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add unit tests for empty token
authorLukas Reschke <lukas@owncloud.com>
Sun, 1 Feb 2015 16:34:03 +0000 (17:34 +0100)
committerLukas Reschke <lukas@owncloud.com>
Sun, 1 Feb 2015 16:34:03 +0000 (17:34 +0100)
core/lostpassword/controller/lostcontroller.php
tests/core/lostpassword/controller/lostcontrollertest.php

index 5297e9a9a2a4a60951d11086c40e5edce0248df4..c039c578b593f2966aa6e4808a040aa1c3cf1b02 100644 (file)
@@ -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));
                }
 
index 2ed7692a32f7b1ae8970943f8ffb591092e77dc4..3f3cda2b0c7d3bf1fbe63e34f5931241c4af6403 100644 (file)
@@ -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);
+       }
+
 }