‪TYPO3CMS  10.4
BackendUserAuthenticatorTest.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\Framework\Frontend\InternalRequest;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 class ‪BackendUserAuthenticatorTest extends FunctionalTestCase
26 {
28 
29  protected const ‪LANGUAGE_PRESETS = [
30  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8', 'iso' => 'en', 'hrefLang' => 'en-US', 'direction' => ''],
31  ];
32 
33  protected function ‪setUp(): void
34  {
35  parent::setUp();
36  $this->importDataSet('EXT:core/Tests/Functional/Fixtures/pages.xml');
37  $this->setUpBackendUserFromFixture(1);
39  'acme-com',
40  $this->‪buildSiteConfiguration(1, 'https://acme.com/'),
41  [
42  $this->‪buildDefaultLanguageConfiguration('EN', '/'),
43  ]
44  );
45  }
46 
50  public function ‪nonAuthenticatedRequestDoesNotSendHeaders(): void
51  {
52  $response = $this->executeFrontendRequest(
53  (new InternalRequest())->withPageId(1),
54  (new InternalRequestContext())
55  );
56  self::assertArrayNotHasKey('Cache-Control', $response->getHeaders());
57  self::assertArrayNotHasKey('Pragma', $response->getHeaders());
58  self::assertArrayNotHasKey('Expires', $response->getHeaders());
59  }
60 
65  {
66  $response = $this->executeFrontendRequest(
67  (new InternalRequest())->withPageId(1),
68  (new InternalRequestContext())
69  ->withBackendUserId(1)
70  );
71  self::assertEquals('no-cache, must-revalidate', $response->getHeaders()['Cache-Control'][0]);
72  self::assertEquals('no-cache', $response->getHeaders()['Pragma'][0]);
73  self::assertEquals(0, $response->getHeaders()['Expires'][0]);
74  }
75 }
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: BackendUserAuthenticatorTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:36
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest
Definition: BackendUserAuthenticatorTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:124
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware
Definition: BackendUserAuthenticatorTest.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\nonAuthenticatedRequestDoesNotSendHeaders
‪nonAuthenticatedRequestDoesNotSendHeaders()
Definition: BackendUserAuthenticatorTest.php:49
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:109
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\setUp
‪setUp()
Definition: BackendUserAuthenticatorTest.php:32
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\authenticatedRequestIncludesInvalidCacheHeaders
‪authenticatedRequestIncludesInvalidCacheHeaders()
Definition: BackendUserAuthenticatorTest.php:63