‪TYPO3CMS  9.5
SaltedPasswordServiceTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
24 class ‪SaltedPasswordServiceTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
25 {
26 
32  protected ‪$xmlDatabaseFixtures = [
33  'typo3/sysext/core/Tests/Functional/Crypto/PasswordHashing/Fixtures/be_users.xml'
34  ];
35 
39  protected ‪$subject;
40 
44  protected function ‪setUp()
45  {
46  parent::setUp();
47  foreach ($this->xmlDatabaseFixtures as $fixture) {
48  $this->importDataSet($fixture);
49  }
50  $this->subject = GeneralUtility::makeInstance(SaltedPasswordService::class);
51  }
52 
59  {
60  $newPassword = ['password' => '008c5926ca861023c1d2a36653fd88e2'];
61 
62  $this->subject->pObj = new \stdClass();
63  $this->subject->pObj->user_table = 'be_users';
64 
65  $this->callInaccessibleMethod($this->subject, 'updatePassword', 3, $newPassword);
66 
67  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
68 
69  $currentPassword = $queryBuilder
70  ->select('password')
71  ->from('be_users')
72  ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(3, \PDO::PARAM_INT)))
73  ->execute()
74  ->fetchColumn();
75 
76  $this->assertEquals($newPassword['password'], $currentPassword);
77  }
78 }
‪TYPO3\CMS\Core\Tests\Functional\Crypto\PasswordHashing\SaltedPasswordServiceTest\setUp
‪setUp()
Definition: SaltedPasswordServiceTest.php:42
‪TYPO3\CMS\Core\Tests\Functional\Crypto\PasswordHashing\SaltedPasswordServiceTest\$xmlDatabaseFixtures
‪array $xmlDatabaseFixtures
Definition: SaltedPasswordServiceTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\Crypto\PasswordHashing\SaltedPasswordServiceTest
Definition: SaltedPasswordServiceTest.php:25
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordService
Definition: SaltedPasswordService.php:29
‪TYPO3\CMS\Core\Tests\Functional\Crypto\PasswordHashing\SaltedPasswordServiceTest\checkIfServiceUpdatesBackendUserPassword
‪checkIfServiceUpdatesBackendUserPassword()
Definition: SaltedPasswordServiceTest.php:56
‪TYPO3\CMS\Core\Tests\Functional\Crypto\PasswordHashing
Definition: SaltedPasswordServiceTest.php:2
‪TYPO3\CMS\Core\Tests\Functional\Crypto\PasswordHashing\SaltedPasswordServiceTest\$subject
‪SaltedPasswordService $subject
Definition: SaltedPasswordServiceTest.php:37
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45