TYPO3 CMS  TYPO3_7-6
EvaluatorTest.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 
19 
24 {
28  protected $subject;
29 
33  protected function setUp()
34  {
35  $this->subject = $this->getMock(Evaluator::class, ['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  $hashingMethod = substr($saltedPassword, 0, 3);
51  $this->assertTrue($isSet);
52  $this->assertNotEquals($originalPassword, $saltedPassword);
53  $this->assertTrue($hashingMethod === '$1$' || $hashingMethod === '$2$' || $hashingMethod === '$2a' || $hashingMethod === '$P$');
54  }
55 
60  {
61  $isSet = null;
62  $originalPassword = '5f4dcc3b5aa765d61d8327deb882cf99';
63  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
64  $this->assertTrue($isSet);
65  $this->assertNotEquals($originalPassword, $saltedPassword);
66  $this->assertTrue(GeneralUtility::isFirstPartOfStr($saltedPassword, 'M$'));
67  }
68 
73  {
74  $isSet = null;
75  $originalPassword = 'M$P$CibIRipvLfaPlaaeH8ifu9g21BrPjp.';
76  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
77  $this->assertNull($isSet);
78  $this->assertSame($originalPassword, $saltedPassword);
79  }
80 }
static isFirstPartOfStr($str, $partStr)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']