1
0

LostControllerTest.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <?php
  2. /**
  3. * @author Lukas Reschke <lukas@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace Tests\Core\Controller;
  22. use OC\Core\Controller\LostController;
  23. use OC\Mail\Message;
  24. use OCP\AppFramework\Http\TemplateResponse;
  25. use OCP\AppFramework\Utility\ITimeFactory;
  26. use OCP\Encryption\IManager;
  27. use OCP\IConfig;
  28. use OCP\IL10N;
  29. use OCP\IRequest;
  30. use OCP\IURLGenerator;
  31. use OCP\IUser;
  32. use OCP\IUserManager;
  33. use OCP\Mail\IMailer;
  34. use OCP\Security\ICrypto;
  35. use OCP\Security\ISecureRandom;
  36. use PHPUnit_Framework_MockObject_MockObject;
  37. /**
  38. * Class LostControllerTest
  39. *
  40. * @package OC\Core\Controller
  41. */
  42. class LostControllerTest extends \Test\TestCase {
  43. /** @var LostController */
  44. private $lostController;
  45. /** @var IUser */
  46. private $existingUser;
  47. /** @var IURLGenerator | PHPUnit_Framework_MockObject_MockObject */
  48. private $urlGenerator;
  49. /** @var IL10N */
  50. private $l10n;
  51. /** @var IUserManager | PHPUnit_Framework_MockObject_MockObject */
  52. private $userManager;
  53. /** @var \OC_Defaults */
  54. private $defaults;
  55. /** @var IConfig | PHPUnit_Framework_MockObject_MockObject */
  56. private $config;
  57. /** @var IMailer | PHPUnit_Framework_MockObject_MockObject */
  58. private $mailer;
  59. /** @var ISecureRandom | PHPUnit_Framework_MockObject_MockObject */
  60. private $secureRandom;
  61. /** @var IManager|PHPUnit_Framework_MockObject_MockObject */
  62. private $encryptionManager;
  63. /** @var ITimeFactory | PHPUnit_Framework_MockObject_MockObject */
  64. private $timeFactory;
  65. /** @var IRequest */
  66. private $request;
  67. /** @var ICrypto|\PHPUnit_Framework_MockObject_MockObject */
  68. private $crypto;
  69. protected function setUp() {
  70. parent::setUp();
  71. $this->existingUser = $this->createMock(IUser::class);
  72. $this->existingUser->method('getEMailAddress')
  73. ->willReturn('test@example.com');
  74. $this->config = $this->createMock(IConfig::class);
  75. $this->config->method('getSystemValue')
  76. ->with('secret', null)
  77. ->willReturn('SECRET');
  78. $this->l10n = $this->createMock(IL10N::class);
  79. $this->l10n
  80. ->expects($this->any())
  81. ->method('t')
  82. ->will($this->returnCallback(function($text, $parameters = array()) {
  83. return vsprintf($text, $parameters);
  84. }));
  85. $this->defaults = $this->getMockBuilder('\OC_Defaults')
  86. ->disableOriginalConstructor()->getMock();
  87. $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
  88. ->disableOriginalConstructor()->getMock();
  89. $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
  90. ->disableOriginalConstructor()->getMock();
  91. $this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer')
  92. ->disableOriginalConstructor()->getMock();
  93. $this->secureRandom = $this->getMockBuilder('\OCP\Security\ISecureRandom')
  94. ->disableOriginalConstructor()->getMock();
  95. $this->timeFactory = $this->getMockBuilder('\OCP\AppFramework\Utility\ITimeFactory')
  96. ->disableOriginalConstructor()->getMock();
  97. $this->request = $this->getMockBuilder('OCP\IRequest')
  98. ->disableOriginalConstructor()->getMock();
  99. $this->encryptionManager = $this->getMockBuilder(IManager::class)
  100. ->disableOriginalConstructor()->getMock();
  101. $this->encryptionManager->expects($this->any())
  102. ->method('isEnabled')
  103. ->willReturn(true);
  104. $this->crypto = $this->createMock(ICrypto::class);
  105. $this->lostController = new LostController(
  106. 'Core',
  107. $this->request,
  108. $this->urlGenerator,
  109. $this->userManager,
  110. $this->defaults,
  111. $this->l10n,
  112. $this->config,
  113. $this->secureRandom,
  114. 'lostpassword-noreply@localhost',
  115. $this->encryptionManager,
  116. $this->mailer,
  117. $this->timeFactory,
  118. $this->crypto
  119. );
  120. }
  121. public function testResetFormWithNotExistingUser() {
  122. $this->userManager->method('get')
  123. ->with('NotExistingUser')
  124. ->willReturn(null);
  125. $expectedResponse = new TemplateResponse(
  126. 'core',
  127. 'error',
  128. [
  129. 'errors' => [
  130. ['error' => 'Couldn\'t reset password because the token is invalid'],
  131. ]
  132. ],
  133. 'guest'
  134. );
  135. $this->assertEquals($expectedResponse, $this->lostController->resetform('MySecretToken', 'NotExistingUser'));
  136. }
  137. public function testResetFormInvalidTokenMatch() {
  138. $this->config->method('getUserValue')
  139. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  140. ->willReturn('encryptedToken');
  141. $this->existingUser->method('getLastLogin')
  142. ->will($this->returnValue(12344));
  143. $this->userManager->method('get')
  144. ->with('ValidTokenUser')
  145. ->willReturn($this->existingUser);
  146. $this->crypto->method('decrypt')
  147. ->with(
  148. $this->equalTo('encryptedToken'),
  149. $this->equalTo('test@example.comSECRET')
  150. )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword');
  151. $response = $this->lostController->resetform('12345:MySecretToken', 'ValidTokenUser');
  152. $expectedResponse = new TemplateResponse('core',
  153. 'error',
  154. [
  155. 'errors' => [
  156. ['error' => 'Couldn\'t reset password because the token is invalid'],
  157. ]
  158. ],
  159. 'guest');
  160. $this->assertEquals($expectedResponse, $response);
  161. }
  162. public function testResetFormExpiredToken() {
  163. $this->userManager->method('get')
  164. ->with('ValidTokenUser')
  165. ->willReturn($this->existingUser);
  166. $this->config
  167. ->expects($this->once())
  168. ->method('getUserValue')
  169. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  170. ->will($this->returnValue('encryptedToken'));
  171. $this->crypto->method('decrypt')
  172. ->with(
  173. $this->equalTo('encryptedToken'),
  174. $this->equalTo('test@example.comSECRET')
  175. )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword');
  176. $this->timeFactory
  177. ->expects($this->once())
  178. ->method('getTime')
  179. ->willReturn(999999);
  180. $response = $this->lostController->resetform('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser');
  181. $expectedResponse = new TemplateResponse('core',
  182. 'error',
  183. [
  184. 'errors' => [
  185. ['error' => 'Couldn\'t reset password because the token is expired'],
  186. ]
  187. ],
  188. 'guest');
  189. $this->assertEquals($expectedResponse, $response);
  190. }
  191. public function testResetFormValidToken() {
  192. $this->existingUser->method('getLastLogin')
  193. ->willReturn(12344);
  194. $this->userManager->method('get')
  195. ->with('ValidTokenUser')
  196. ->willReturn($this->existingUser);
  197. $this->timeFactory
  198. ->expects($this->once())
  199. ->method('getTime')
  200. ->willReturn(12348);
  201. $this->config->method('getUserValue')
  202. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  203. ->willReturn('encryptedToken');
  204. $this->crypto->method('decrypt')
  205. ->with(
  206. $this->equalTo('encryptedToken'),
  207. $this->equalTo('test@example.comSECRET')
  208. )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword');
  209. $this->urlGenerator
  210. ->expects($this->once())
  211. ->method('linkToRouteAbsolute')
  212. ->with('core.lost.setPassword', array('userId' => 'ValidTokenUser', 'token' => 'TheOnlyAndOnlyOneTokenToResetThePassword'))
  213. ->will($this->returnValue('https://example.tld/index.php/lostpassword/'));
  214. $response = $this->lostController->resetform('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser');
  215. $expectedResponse = new TemplateResponse('core',
  216. 'lostpassword/resetpassword',
  217. array(
  218. 'link' => 'https://example.tld/index.php/lostpassword/',
  219. ),
  220. 'guest');
  221. $this->assertEquals($expectedResponse, $response);
  222. }
  223. public function testEmailUnsucessful() {
  224. $existingUser = 'ExistingUser';
  225. $nonExistingUser = 'NonExistingUser';
  226. $this->userManager
  227. ->expects($this->any())
  228. ->method('userExists')
  229. ->will($this->returnValueMap(array(
  230. array(true, $existingUser),
  231. array(false, $nonExistingUser)
  232. )));
  233. // With a non existing user
  234. $response = $this->lostController->email($nonExistingUser);
  235. $expectedResponse = [
  236. 'status' => 'error',
  237. 'msg' => 'Couldn\'t send reset email. Please make sure your username is correct.'
  238. ];
  239. $this->assertSame($expectedResponse, $response);
  240. // With no mail address
  241. $this->config
  242. ->expects($this->any())
  243. ->method('getUserValue')
  244. ->with($existingUser, 'settings', 'email')
  245. ->will($this->returnValue(null));
  246. $response = $this->lostController->email($existingUser);
  247. $expectedResponse = [
  248. 'status' => 'error',
  249. 'msg' => 'Couldn\'t send reset email. Please make sure your username is correct.'
  250. ];
  251. $this->assertSame($expectedResponse, $response);
  252. }
  253. public function testEmailSuccessful() {
  254. $this->secureRandom
  255. ->expects($this->once())
  256. ->method('generate')
  257. ->with('21')
  258. ->will($this->returnValue('ThisIsMaybeANotSoSecretToken!'));
  259. $this->userManager
  260. ->expects($this->once())
  261. ->method('userExists')
  262. ->with('ExistingUser')
  263. ->will($this->returnValue(true));
  264. $this->userManager
  265. ->expects($this->any())
  266. ->method('get')
  267. ->with('ExistingUser')
  268. ->willReturn($this->existingUser);
  269. $this->timeFactory
  270. ->expects($this->once())
  271. ->method('getTime')
  272. ->will($this->returnValue(12348));
  273. $this->config
  274. ->expects($this->once())
  275. ->method('setUserValue')
  276. ->with('ExistingUser', 'core', 'lostpassword', 'encryptedToken');
  277. $this->urlGenerator
  278. ->expects($this->once())
  279. ->method('linkToRouteAbsolute')
  280. ->with('core.lost.resetform', array('userId' => 'ExistingUser', 'token' => 'ThisIsMaybeANotSoSecretToken!'))
  281. ->will($this->returnValue('https://example.tld/index.php/lostpassword/'));
  282. $message = $this->getMockBuilder('\OC\Mail\Message')
  283. ->disableOriginalConstructor()->getMock();
  284. $message
  285. ->expects($this->at(0))
  286. ->method('setTo')
  287. ->with(['test@example.com' => 'ExistingUser']);
  288. $message
  289. ->expects($this->at(1))
  290. ->method('setSubject')
  291. ->with(' password reset');
  292. $message
  293. ->expects($this->at(2))
  294. ->method('setPlainBody')
  295. ->with('Use the following link to reset your password: https://example.tld/index.php/lostpassword/');
  296. $message
  297. ->expects($this->at(3))
  298. ->method('setFrom')
  299. ->with(['lostpassword-noreply@localhost' => null]);
  300. $this->mailer
  301. ->expects($this->at(0))
  302. ->method('createMessage')
  303. ->will($this->returnValue($message));
  304. $this->mailer
  305. ->expects($this->at(1))
  306. ->method('send')
  307. ->with($message);
  308. $this->config->method('getSystemValue')
  309. ->with('secret', '')
  310. ->willReturn('SECRET');
  311. $this->crypto->method('encrypt')
  312. ->with(
  313. $this->equalTo('12348:ThisIsMaybeANotSoSecretToken!'),
  314. $this->equalTo('test@example.comSECRET')
  315. )->willReturn('encryptedToken');
  316. $response = $this->lostController->email('ExistingUser');
  317. $expectedResponse = array('status' => 'success');
  318. $this->assertSame($expectedResponse, $response);
  319. }
  320. public function testEmailCantSendException() {
  321. $this->secureRandom
  322. ->expects($this->once())
  323. ->method('generate')
  324. ->with('21')
  325. ->will($this->returnValue('ThisIsMaybeANotSoSecretToken!'));
  326. $this->userManager
  327. ->expects($this->once())
  328. ->method('userExists')
  329. ->with('ExistingUser')
  330. ->will($this->returnValue(true));
  331. $this->userManager
  332. ->expects($this->any())
  333. ->method('get')
  334. ->with('ExistingUser')
  335. ->willReturn($this->existingUser);
  336. $this->config
  337. ->expects($this->once())
  338. ->method('setUserValue')
  339. ->with('ExistingUser', 'core', 'lostpassword', 'encryptedToken');
  340. $this->timeFactory
  341. ->expects($this->once())
  342. ->method('getTime')
  343. ->will($this->returnValue(12348));
  344. $this->urlGenerator
  345. ->expects($this->once())
  346. ->method('linkToRouteAbsolute')
  347. ->with('core.lost.resetform', array('userId' => 'ExistingUser', 'token' => 'ThisIsMaybeANotSoSecretToken!'))
  348. ->will($this->returnValue('https://example.tld/index.php/lostpassword/'));
  349. $message = $this->createMock(Message::class);
  350. $message
  351. ->expects($this->at(0))
  352. ->method('setTo')
  353. ->with(['test@example.com' => 'ExistingUser']);
  354. $message
  355. ->expects($this->at(1))
  356. ->method('setSubject')
  357. ->with(' password reset');
  358. $message
  359. ->expects($this->at(2))
  360. ->method('setPlainBody')
  361. ->with('Use the following link to reset your password: https://example.tld/index.php/lostpassword/');
  362. $message
  363. ->expects($this->at(3))
  364. ->method('setFrom')
  365. ->with(['lostpassword-noreply@localhost' => null]);
  366. $this->mailer
  367. ->expects($this->at(0))
  368. ->method('createMessage')
  369. ->will($this->returnValue($message));
  370. $this->mailer
  371. ->expects($this->at(1))
  372. ->method('send')
  373. ->with($message)
  374. ->will($this->throwException(new \Exception()));
  375. $this->config->method('getSystemValue')
  376. ->with('secret', '')
  377. ->willReturn('SECRET');
  378. $this->crypto->method('encrypt')
  379. ->with(
  380. $this->equalTo('12348:ThisIsMaybeANotSoSecretToken!'),
  381. $this->equalTo('test@example.comSECRET')
  382. )->willReturn('encryptedToken');
  383. $response = $this->lostController->email('ExistingUser');
  384. $expectedResponse = ['status' => 'error', 'msg' => 'Couldn\'t send reset email. Please contact your administrator.'];
  385. $this->assertSame($expectedResponse, $response);
  386. }
  387. public function testSetPasswordUnsuccessful() {
  388. $this->config->method('getUserValue')
  389. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  390. ->willReturn('encryptedData');
  391. $this->existingUser->method('getLastLogin')
  392. ->will($this->returnValue(12344));
  393. $this->existingUser->expects($this->once())
  394. ->method('setPassword')
  395. ->with('NewPassword')
  396. ->willReturn(false);
  397. $this->userManager->method('get')
  398. ->with('ValidTokenUser')
  399. ->willReturn($this->existingUser);
  400. $this->config->expects($this->never())
  401. ->method('deleteUserValue');
  402. $this->timeFactory->method('getTime')
  403. ->will($this->returnValue(12348));
  404. $this->crypto->method('decrypt')
  405. ->with(
  406. $this->equalTo('encryptedData'),
  407. $this->equalTo('test@example.comSECRET')
  408. )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword');
  409. $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
  410. $expectedResponse = array('status' => 'error', 'msg' => '');
  411. $this->assertSame($expectedResponse, $response);
  412. }
  413. public function testSetPasswordSuccessful() {
  414. $this->config->method('getUserValue')
  415. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  416. ->willReturn('encryptedData');
  417. $this->existingUser->method('getLastLogin')
  418. ->will($this->returnValue(12344));
  419. $this->existingUser->expects($this->once())
  420. ->method('setPassword')
  421. ->with('NewPassword')
  422. ->willReturn(true);
  423. $this->userManager->method('get')
  424. ->with('ValidTokenUser')
  425. ->willReturn($this->existingUser);
  426. $this->config->expects($this->once())
  427. ->method('deleteUserValue')
  428. ->with('ValidTokenUser', 'core', 'lostpassword');
  429. $this->timeFactory->method('getTime')
  430. ->will($this->returnValue(12348));
  431. $this->crypto->method('decrypt')
  432. ->with(
  433. $this->equalTo('encryptedData'),
  434. $this->equalTo('test@example.comSECRET')
  435. )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword');
  436. $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
  437. $expectedResponse = array('status' => 'success');
  438. $this->assertSame($expectedResponse, $response);
  439. }
  440. public function testSetPasswordExpiredToken() {
  441. $this->config->method('getUserValue')
  442. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  443. ->willReturn('encryptedData');
  444. $this->userManager->method('get')
  445. ->with('ValidTokenUser')
  446. ->willReturn($this->existingUser);
  447. $this->timeFactory->method('getTime')
  448. ->willReturn(55546);
  449. $this->crypto->method('decrypt')
  450. ->with(
  451. $this->equalTo('encryptedData'),
  452. $this->equalTo('test@example.comSECRET')
  453. )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword');
  454. $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
  455. $expectedResponse = [
  456. 'status' => 'error',
  457. 'msg' => 'Couldn\'t reset password because the token is expired',
  458. ];
  459. $this->assertSame($expectedResponse, $response);
  460. }
  461. public function testSetPasswordInvalidDataInDb() {
  462. $this->config->method('getUserValue')
  463. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  464. ->willReturn('invalidEncryptedData');
  465. $this->userManager
  466. ->method('get')
  467. ->with('ValidTokenUser')
  468. ->willReturn($this->existingUser);
  469. $this->crypto->method('decrypt')
  470. ->with(
  471. $this->equalTo('invalidEncryptedData'),
  472. $this->equalTo('test@example.comSECRET')
  473. )->willReturn('TheOnlyAndOnlyOneTokenToResetThePassword');
  474. $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
  475. $expectedResponse = [
  476. 'status' => 'error',
  477. 'msg' => 'Couldn\'t reset password because the token is invalid',
  478. ];
  479. $this->assertSame($expectedResponse, $response);
  480. }
  481. public function testSetPasswordExpiredTokenDueToLogin() {
  482. $this->config->method('getUserValue')
  483. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  484. ->willReturn('encryptedData');
  485. $this->existingUser->method('getLastLogin')
  486. ->will($this->returnValue(12346));
  487. $this->userManager
  488. ->method('get')
  489. ->with('ValidTokenUser')
  490. ->willReturn($this->existingUser);
  491. $this->timeFactory
  492. ->method('getTime')
  493. ->will($this->returnValue(12345));
  494. $this->crypto->method('decrypt')
  495. ->with(
  496. $this->equalTo('encryptedData'),
  497. $this->equalTo('test@example.comSECRET')
  498. )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword');
  499. $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
  500. $expectedResponse = [
  501. 'status' => 'error',
  502. 'msg' => 'Couldn\'t reset password because the token is expired',
  503. ];
  504. $this->assertSame($expectedResponse, $response);
  505. }
  506. public function testIsSetPasswordWithoutTokenFailing() {
  507. $this->config->method('getUserValue')
  508. ->with('ValidTokenUser', 'core', 'lostpassword', null)
  509. ->will($this->returnValue(null));
  510. $this->userManager->method('get')
  511. ->with('ValidTokenUser')
  512. ->willReturn($this->existingUser);
  513. $this->crypto->method('decrypt')
  514. ->with(
  515. $this->equalTo(''),
  516. $this->equalTo('test@example.comSECRET')
  517. )->willThrowException(new \Exception());
  518. $response = $this->lostController->setPassword('', 'ValidTokenUser', 'NewPassword', true);
  519. $expectedResponse = [
  520. 'status' => 'error',
  521. 'msg' => 'Couldn\'t reset password because the token is invalid'
  522. ];
  523. $this->assertSame($expectedResponse, $response);
  524. }
  525. public function testSendEmailNoEmail() {
  526. $user = $this->createMock(IUser::class);
  527. $this->userManager->method('userExists')
  528. ->with('ExistingUser')
  529. ->willReturn(true);
  530. $this->userManager->method('get')
  531. ->with('ExistingUser')
  532. ->willReturn($user);
  533. $response = $this->lostController->email('ExistingUser');
  534. $expectedResponse = ['status' => 'error', 'msg' => 'Could not send reset email because there is no email address for this username. Please contact your administrator.'];
  535. $this->assertSame($expectedResponse, $response);
  536. }
  537. public function testSetPasswordEncryptionDontProceed() {
  538. $response = $this->lostController->setPassword('myToken', 'user', 'newpass', false);
  539. $expectedResponse = ['status' => 'error', 'msg' => '', 'encryption' => true];
  540. $this->assertSame($expectedResponse, $response);
  541. }
  542. }