TYPO3  7.6
EvaluatorTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Saltedpasswords\Tests\Unit\Evaluation;
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 
19 
23 class EvaluatorTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
24 {
28  protected $subject;
29 
33  protected function setUp()
34  {
35  $this->subject = $this->getMock(Evaluator::class, array('dummy'));
36 
37  // Make sure SaltedPasswordsUtility::isUsageEnabled() returns TRUE
38  unset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['saltedpasswords']);
39  $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'rsa';
40  }
41 
46  {
47  $isSet = null;
48  $originalPassword = 'password';
49  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
50  $this->assertTrue($isSet);
51  $this->assertNotEquals($originalPassword, $saltedPassword);
52  $this->assertTrue(GeneralUtility::inList('$1$,$2$,$2a,$P$', substr($saltedPassword, 0, 3)));
53  }
54 
59  {
60  $isSet = null;
61  $originalPassword = '5f4dcc3b5aa765d61d8327deb882cf99';
62  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
63  $this->assertTrue($isSet);
64  $this->assertNotEquals($originalPassword, $saltedPassword);
65  $this->assertTrue(GeneralUtility::isFirstPartOfStr($saltedPassword, 'M$'));
66  }
67 
72  {
73  $isSet = null;
74  $originalPassword = 'M$P$CibIRipvLfaPlaaeH8ifu9g21BrPjp.';
75  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
76  $this->assertSame(null, $isSet);
77  $this->assertSame($originalPassword, $saltedPassword);
78  }
79 }