‪TYPO3CMS  11.5
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 
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
24 class ‪AbstractUserAuthenticationTest extends FunctionalTestCase
25 {
29  private ‪$sessionId;
30 
34  private ‪$subject;
35 
39  private ‪$userSession;
40 
41  protected function ‪setUp(): void
42  {
43  parent::setUp();
44  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
45  $this->sessionId = bin2hex(random_bytes(20));
46  $this->userSession = ‪UserSession::createNonFixated($this->sessionId);
47  $this->subject = new ‪AnyUserAuthentication($this->userSession);
48  }
49 
50  protected function ‪tearDown(): void
51  {
52  unset($this->sessionId, $this->userSession, $this->subject);
53  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
54  parent::tearDown();
55  }
56 
60  public function ‪pushModuleDataDoesNotRevealPlainSessionId(): void
61  {
62  $this->subject->pushModuleData(self::class, true);
63  self::assertNotContains($this->sessionId, $this->subject->uc['moduleSessionID']);
64  }
65 
69  public function ‪getModuleDataResolvesHashedSessionId(): void
70  {
71  $this->subject->pushModuleData(self::class, true);
72  self::assertTrue($this->subject->getModuleData(self::class));
73  }
74 
78  public function ‪getModuleDataFallsBackToPlainSessionId(): void
79  {
80  $this->subject->uc['moduleData'][self::class] = true;
81  $this->subject->uc['moduleSessionID'][self::class] = ‪$this->sessionId;
82  self::assertTrue($this->subject->getModuleData(self::class));
83  }
84 }
‪TYPO3\CMS\Core\Tests\Functional\Authentication\Fixtures\AnyUserAuthentication
Definition: AnyUserAuthentication.php:24
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\$sessionId
‪string $sessionId
Definition: AbstractUserAuthenticationTest.php:28
‪TYPO3\CMS\Core\Session\UserSession
Definition: UserSession.php:39
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\getModuleDataResolvesHashedSessionId
‪getModuleDataResolvesHashedSessionId()
Definition: AbstractUserAuthenticationTest.php:66
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest
Definition: AbstractUserAuthenticationTest.php:25
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\setUp
‪setUp()
Definition: AbstractUserAuthenticationTest.php:38
‪TYPO3\CMS\Core\Session\UserSession\createNonFixated
‪static UserSession createNonFixated(string $identifier)
Definition: UserSession.php:247
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\getModuleDataFallsBackToPlainSessionId
‪getModuleDataFallsBackToPlainSessionId()
Definition: AbstractUserAuthenticationTest.php:75
‪TYPO3\CMS\Core\Tests\Functional\Authentication
Definition: AbstractUserAuthenticationTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\$userSession
‪UserSession $userSession
Definition: AbstractUserAuthenticationTest.php:36
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\pushModuleDataDoesNotRevealPlainSessionId
‪pushModuleDataDoesNotRevealPlainSessionId()
Definition: AbstractUserAuthenticationTest.php:57
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\tearDown
‪tearDown()
Definition: AbstractUserAuthenticationTest.php:47
‪TYPO3\CMS\Core\Tests\Functional\Authentication\AbstractUserAuthenticationTest\$subject
‪AnyUserAuthentication $subject
Definition: AbstractUserAuthenticationTest.php:32