‪TYPO3CMS  ‪main
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 
20 use PHPUnit\Framework\Attributes\Test;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪BackendUserAuthenticatorTest extends FunctionalTestCase
27 {
29 
30  protected const ‪LANGUAGE_PRESETS = [
31  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
32  ];
33 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  $this->importCsvDataSet(__DIR__ . '/../Fixtures/pages.csv');
38  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
39  $this->setUpBackendUser(1);
41  'acme-com',
42  $this->‪buildSiteConfiguration(1, 'https://acme.com/'),
43  [
44  $this->‪buildDefaultLanguageConfiguration('EN', '/'),
45  ]
46  );
47  }
48 
49  #[Test]
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 
58  #[Test]
60  {
61  $response = $this->executeFrontendSubRequest(
62  (new InternalRequest())->withPageId(1),
63  (new InternalRequestContext())->withBackendUserId(1)
64  );
65  self::assertEquals('no-cache, no-store', $response->getHeaders()['Cache-Control'][0]);
66  self::assertEquals('no-cache', $response->getHeaders()['Pragma'][0]);
67  self::assertEquals(0, $response->getHeaders()['Expires'][0]);
68  }
69 }
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: BackendUserAuthenticatorTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:37
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest
Definition: BackendUserAuthenticatorTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:50
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware
Definition: BackendUserAuthenticatorTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:98
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\nonAuthenticatedRequestDoesNotSendHeaders
‪nonAuthenticatedRequestDoesNotSendHeaders()
Definition: BackendUserAuthenticatorTest.php:49
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\setUp
‪setUp()
Definition: BackendUserAuthenticatorTest.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\Middleware\BackendUserAuthenticatorTest\authenticatedRequestIncludesInvalidCacheHeaders
‪authenticatedRequestIncludesInvalidCacheHeaders()
Definition: BackendUserAuthenticatorTest.php:58