‪TYPO3CMS  11.5
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->importCsvDataSet(__DIR__ . '/../../../../core/Tests/Functional/Fixtures/pages.csv');
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->executeFrontendSubRequest((new InternalRequest())->withPageId(1));
53  self::assertArrayNotHasKey('Cache-Control', $response->getHeaders());
54  self::assertArrayNotHasKey('Pragma', $response->getHeaders());
55  self::assertArrayNotHasKey('Expires', $response->getHeaders());
56  }
57 
62  {
63  $response = $this->executeFrontendSubRequest(
64  (new InternalRequest())->withPageId(1),
65  (new InternalRequestContext())->withBackendUserId(1)
66  );
67  self::assertEquals('no-cache, no-store', $response->getHeaders()['Cache-Control'][0]);
68  self::assertEquals('no-cache', $response->getHeaders()['Pragma'][0]);
69  self::assertEquals(0, $response->getHeaders()['Expires'][0]);
70  }
71 }
‪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:126
‪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:111
‪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:60