‪TYPO3CMS  10.4
AbstractUserAuthenticationTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
23 class ‪AbstractUserAuthenticationTest extends FunctionalTestCase
24 {
28  private ‪$sessionId;
29 
33  private ‪$subject;
34 
35  protected function ‪setUp(): void
36  {
37  parent::setUp();
38  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
39  ‪$GLOBALS['TYPO3_CONF_VARS']['ANY']['lockIP'] = 0;
40  ‪$GLOBALS['TYPO3_CONF_VARS']['ANY']['lockIPv6'] = 0;
41  $this->sessionId = bin2hex(random_bytes(20));
42  $this->subject = new ‪AnyUserAuthentication($this->sessionId);
43  }
44 
45  protected function ‪tearDown(): void
46  {
47  unset($this->sessionId, $this->subject);
48  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
49  parent::tearDown();
50  }
51 
55  public function ‪pushModuleDataDoesNotRevealPlainSessionId(): void
56  {
57  $this->subject->pushModuleData(self::class, true);
58  self::assertNotContains($this->sessionId, $this->subject->uc['moduleSessionID']);
59  }
60 
64  public function ‪getModuleDataResolvesHashedSessionId(): void
65  {
66  $this->subject->pushModuleData(self::class, true);
67  self::assertTrue($this->subject->getModuleData(self::class));
68  }
69 
73  public function ‪getModuleDataFallsBackToPlainSessionId(): void
74  {
75  $this->subject->uc['moduleData'][self::class] = true;
76  $this->subject->uc['moduleSessionID'][self::class] = ‪$this->sessionId;
77  self::assertTrue($this->subject->getModuleData(self::class));
78  }
79 }
‪TYPO3\CMS\Core\Tests\Functional\Authentication\Fixtures\AnyUserAuthentication
Definition: AnyUserAuthentication.php:23
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\$sessionId
‪string $sessionId
Definition: AbstractUserAuthenticationTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\getModuleDataResolvesHashedSessionId
‪getModuleDataResolvesHashedSessionId()
Definition: AbstractUserAuthenticationTest.php:62
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest
Definition: AbstractUserAuthenticationTest.php:24
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\setUp
‪setUp()
Definition: AbstractUserAuthenticationTest.php:33
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\getModuleDataFallsBackToPlainSessionId
‪getModuleDataFallsBackToPlainSessionId()
Definition: AbstractUserAuthenticationTest.php:71
‪TYPO3\CMS\Core\Tests\Functional\Authentication
Definition: AbstractUserAuthenticationTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\pushModuleDataDoesNotRevealPlainSessionId
‪pushModuleDataDoesNotRevealPlainSessionId()
Definition: AbstractUserAuthenticationTest.php:53
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\tearDown
‪tearDown()
Definition: AbstractUserAuthenticationTest.php:43
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\$subject
‪AnyUserAuthentication $subject
Definition: AbstractUserAuthenticationTest.php:31