-
Notifications
You must be signed in to change notification settings - Fork 638
/
AbstractUserAuthenticationTest.php
84 lines (72 loc) · 2.3 KB
/
AbstractUserAuthenticationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Tests\Functional\Authentication;
use TYPO3\CMS\Core\Session\UserSession;
use TYPO3\CMS\Core\Tests\Functional\Authentication\Fixtures\AnyUserAuthentication;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class AbstractUserAuthenticationTest extends FunctionalTestCase
{
/**
* @var string
*/
private $sessionId;
/**
* @var AnyUserAuthentication
*/
private $subject;
/**
* @var UserSession
*/
private $userSession;
protected function setUp(): void
{
parent::setUp();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
$this->sessionId = bin2hex(random_bytes(20));
$this->userSession = UserSession::createNonFixated($this->sessionId);
$this->subject = new AnyUserAuthentication($this->userSession);
}
protected function tearDown(): void
{
unset($this->sessionId, $this->userSession, $this->subject);
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
parent::tearDown();
}
/**
* @test
*/
public function pushModuleDataDoesNotRevealPlainSessionId(): void
{
$this->subject->pushModuleData(self::class, true);
self::assertNotContains($this->sessionId, $this->subject->uc['moduleSessionID']);
}
/**
* @test
*/
public function getModuleDataResolvesHashedSessionId(): void
{
$this->subject->pushModuleData(self::class, true);
self::assertTrue($this->subject->getModuleData(self::class));
}
/**
* @test
*/
public function getModuleDataFallsBackToPlainSessionId(): void
{
$this->subject->uc['moduleData'][self::class] = true;
$this->subject->uc['moduleSessionID'][self::class] = $this->sessionId;
self::assertTrue($this->subject->getModuleData(self::class));
}
}