‪TYPO3CMS  9.5
AbstractUserAuthenticationTest.php
Go to the documentation of this file.
1 <?php
2 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 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
20 
21 class ‪AbstractUserAuthenticationTest extends FunctionalTestCase
22 {
26  private ‪$sessionId;
27 
31  private ‪$subject;
32 
33  protected function ‪setUp(): void
34  {
35  parent::setUp();
36  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
37  ‪$GLOBALS['TYPO3_CONF_VARS']['ANY']['lockIP'] = 0;
38  ‪$GLOBALS['TYPO3_CONF_VARS']['ANY']['lockIPv6'] = 0;
39  $this->sessionId = bin2hex(random_bytes(20));
40  $this->subject = new ‪AnyUserAuthentication($this->sessionId);
41  }
42 
43  protected function ‪tearDown(): void
44  {
45  unset($this->sessionId, $this->subject);
46  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
47  parent::tearDown();
48  }
49 
53  public function ‪pushModuleDataDoesNotRevealPlainSessionId(): void
54  {
55  $this->subject->pushModuleData(self::class, true);
56  self::assertNotContains($this->sessionId, $this->subject->uc['moduleSessionID']);
57  }
58 
62  public function ‪getModuleDataResolvesHashedSessionId(): void
63  {
64  $this->subject->pushModuleData(self::class, true);
65  self::assertTrue($this->subject->getModuleData(self::class));
66  }
67 
71  public function ‪getModuleDataFallsBackToPlainSessionId(): void
72  {
73  $this->subject->uc['moduleData'][self::class] = true;
74  $this->subject->uc['moduleSessionID'][self::class] = ‪$this->sessionId;
75  self::assertTrue($this->subject->getModuleData(self::class));
76  }
77 }
‪TYPO3\CMS\Core\Tests\Functional\Authentication\Fixtures\AnyUserAuthentication
Definition: AnyUserAuthentication.php:21
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\$sessionId
‪string $sessionId
Definition: AbstractUserAuthenticationTest.php:25
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\getModuleDataResolvesHashedSessionId
‪getModuleDataResolvesHashedSessionId()
Definition: AbstractUserAuthenticationTest.php:60
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest
Definition: AbstractUserAuthenticationTest.php:22
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\setUp
‪setUp()
Definition: AbstractUserAuthenticationTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\getModuleDataFallsBackToPlainSessionId
‪getModuleDataFallsBackToPlainSessionId()
Definition: AbstractUserAuthenticationTest.php:69
‪TYPO3\CMS\Core\Tests\Functional\Authentication
Definition: AbstractUserAuthenticationTest.php:3
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\pushModuleDataDoesNotRevealPlainSessionId
‪pushModuleDataDoesNotRevealPlainSessionId()
Definition: AbstractUserAuthenticationTest.php:51
‪$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:41
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\$subject
‪AnyUserAuthentication $subject
Definition: AbstractUserAuthenticationTest.php:29