TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
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 
24 {
28  protected $subject;
29 
33  protected function setUp()
34  {
35  $this->subject = $this->getMockBuilder(Evaluator::class)
36  ->setMethods(['dummy'])
37  ->getMock();
38 
39  // Make sure SaltedPasswordsUtility::isUsageEnabled() returns TRUE
40  unset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['saltedpasswords']);
41  $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'rsa';
42  }
43 
48  {
49  $isSet = null;
50  $originalPassword = 'password';
51  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
52  $hashingMethod = substr($saltedPassword, 0, 3);
53  $this->assertTrue($isSet);
54  $this->assertNotEquals($originalPassword, $saltedPassword);
55  $this->assertTrue($hashingMethod === '$1$' || $hashingMethod === '$2$' || $hashingMethod === '$2a' || $hashingMethod === '$P$');
56  }
57 
62  {
63  $isSet = null;
64  $originalPassword = '5f4dcc3b5aa765d61d8327deb882cf99';
65  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
66  $this->assertTrue($isSet);
67  $this->assertNotEquals($originalPassword, $saltedPassword);
68  $this->assertTrue(GeneralUtility::isFirstPartOfStr($saltedPassword, 'M$'));
69  }
70 
75  {
76  $isSet = null;
77  $originalPassword = 'M$P$CibIRipvLfaPlaaeH8ifu9g21BrPjp.';
78  $saltedPassword = $this->subject->evaluateFieldValue($originalPassword, '', $isSet);
79  $this->assertNull($isSet);
80  $this->assertSame($originalPassword, $saltedPassword);
81  }
82 }
static isFirstPartOfStr($str, $partStr)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']