‪TYPO3CMS  10.4
SiteRequestTest.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\Framework\DataHandling\Scenario\DataHandlerFactory;
23 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
24 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
25 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
26 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
27 
32 {
36  private ‪$siteTitle = 'A Company that Manufactures Everything Inc';
37 
42 
43  public static function ‪setUpBeforeClass(): void
44  {
45  parent::setUpBeforeClass();
46  static::initializeDatabaseSnapshot();
47  }
48 
49  public static function ‪tearDownAfterClass(): void
50  {
51  static::destroyDatabaseSnapshot();
52  parent::tearDownAfterClass();
53  }
54 
55  protected function ‪setUp(): void
56  {
57  parent::setUp();
58 
59  // these settings are forwarded to the frontend sub-request as well
60  $this->internalRequestContext = (new InternalRequestContext())
61  ->withGlobalSettings(['TYPO3_CONF_VARS' => static::TYPO3_CONF_VARS]);
62 
63  $this->withDatabaseSnapshot(function () {
64  $this->‪setUpDatabase();
65  });
66  }
67 
68  protected function ‪setUpDatabase()
69  {
70  $backendUser = $this->setUpBackendUserFromFixture(1);
72 
73  $scenarioFile = __DIR__ . '/Fixtures/PlainScenario.yaml';
74  $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
75  $writer = DataHandlerWriter::withBackendUser($backendUser);
76  $writer->invokeFactory($factory);
77  static::failIfArrayIsNotEmpty(
78  $writer->getErrors()
79  );
80 
81  $this->setUpFrontendRootPage(
82  1000,
83  [
84  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript',
85  'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/JsonRenderer.typoscript',
86  ],
87  [
88  'title' => 'ACME Root',
89  'sitetitle' => $this->siteTitle,
90  ]
91  );
92  }
93 
94  protected function ‪tearDown(): void
95  {
96  unset($this->internalRequestContext);
97  parent::tearDown();
98  }
99 
103  public function ‪shortcutsAreRedirectedDataProvider(): array
104  {
105  $domainPaths = [
106  // @todo Implicit strict mode handling when calling non-existent site
107  // '/',
108  // 'https://localhost/',
109  'https://website.local/',
110  ];
111 
112  $queries = [
113  '',
114  ];
115 
116  return $this->wrapInArray(
117  $this->keysFromValues(
118  ‪PermutationUtility::meltStringItems([$domainPaths, $queries])
119  )
120  );
121  }
122 
129  public function ‪shortcutsAreRedirectedToFirstSubPage(string $uri)
130  {
132  'website-local',
133  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
134  [
135  $this->‪buildDefaultLanguageConfiguration('EN', '/en-en/'),
136  ]
137  );
138 
139  $expectedStatusCode = 307;
140  $expectedHeaders = ['location' => ['https://website.local/en-en/']];
141 
142  $response = $this->executeFrontendRequest(
143  new InternalRequest($uri),
144  $this->internalRequestContext
145  );
146  self::assertSame($expectedStatusCode, $response->getStatusCode());
147  self::assertSame($expectedHeaders, $response->getHeaders());
148  }
149 
156  public function ‪shortcutsAreRedirectedAndRenderFirstSubPage(string $uri)
157  {
159  'website-local',
160  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
161  [
162  $this->‪buildDefaultLanguageConfiguration('EN', '/en-en/'),
163  ]
164  );
165 
166  $expectedStatusCode = 200;
167  $expectedPageTitle = 'EN: Welcome';
168 
169  $response = $this->executeFrontendRequest(
170  new InternalRequest($uri),
171  $this->internalRequestContext,
172  true
173  );
174  $responseStructure = ResponseContent::fromString(
175  (string)$response->getBody()
176  );
177 
178  self::assertSame(
179  $expectedStatusCode,
180  $response->getStatusCode()
181  );
182  self::assertSame(
183  $this->siteTitle,
184  $responseStructure->getScopePath('template/sitetitle')
185  );
186  self::assertSame(
187  $expectedPageTitle,
188  $responseStructure->getScopePath('page/title')
189  );
190  }
191 
195  public function ‪pageIsRenderedWithPathsDataProvider(): array
196  {
197  $domainPaths = [
198  // @todo currently base needs to be defined with domain
199  // '/',
200  'https://website.local/',
201  ];
202 
203  $languagePaths = [
204  'en-en/',
205  'fr-fr/',
206  'fr-ca/',
207  '简/',
208  ];
209 
210  $queries = [
211  '?id=1100',
212  ];
213 
214  return array_map(
215  function (string $uri) {
216  if (strpos($uri, '/fr-fr/') !== false) {
217  $expectedPageTitle = 'FR: Welcome';
218  } elseif (strpos($uri, '/fr-ca/') !== false) {
219  $expectedPageTitle = 'FR-CA: Welcome';
220  } elseif (strpos($uri, '/简/') !== false) {
221  $expectedPageTitle = 'ZH-CN: Welcome';
222  } else {
223  $expectedPageTitle = 'EN: Welcome';
224  }
225  return [$uri, $expectedPageTitle];
226  },
227  $this->keysFromValues(
228  ‪PermutationUtility::meltStringItems([$domainPaths, $languagePaths, $queries])
229  )
230  );
231  }
232 
240  public function ‪pageIsRenderedWithPaths(string $uri, string $expectedPageTitle)
241  {
243  'website-local',
244  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
245  [
246  $this->‪buildDefaultLanguageConfiguration('EN', '/en-en/'),
247  $this->‪buildLanguageConfiguration('FR', '/fr-fr/', ['EN']),
248  $this->‪buildLanguageConfiguration('FR-CA', '/fr-ca/', ['FR', 'EN']),
249  $this->‪buildLanguageConfiguration('ZH', '/简/', ['EN']),
250  ]
251  );
252 
253  $response = $this->executeFrontendRequest(
254  new InternalRequest($uri),
255  $this->internalRequestContext
256  );
257  $responseStructure = ResponseContent::fromString(
258  (string)$response->getBody()
259  );
260 
261  self::assertSame(
262  200,
263  $response->getStatusCode()
264  );
265  self::assertSame(
266  $expectedPageTitle,
267  $responseStructure->getScopePath('page/title')
268  );
269  }
270 
272  {
273  $domainPaths = [
274  // @todo currently base needs to be defined with domain
275  // '/',
276  'https://website.local/',
277  ];
278 
279  $languagePaths = [
280  '简/',
281  'fr-fr/',
282  'fr-ca/',
283  ];
284 
285  $queries = [
286  '?id=1110',
287  ];
288 
289  return array_map(
290  static function (string $uri) {
291  if (strpos($uri, '/fr-fr/') !== false) {
292  $expectedPageTitle = 'FR: Welcome ZH Default';
293  } elseif (strpos($uri, '/fr-ca/') !== false) {
294  $expectedPageTitle = 'FR-CA: Welcome ZH Default';
295  } else {
296  $expectedPageTitle = 'ZH-CN: Welcome Default';
297  }
298  return [$uri, $expectedPageTitle];
299  },
300  $this->keysFromValues(
301  ‪PermutationUtility::meltStringItems([$domainPaths, $languagePaths, $queries])
302  )
303  );
304  }
305 
310  public function ‪pageIsRenderedWithPathsAndChineseDefaultLanguage(string $uri, string $expectedPageTitle): void
311  {
313  'website-local',
314  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
315  [
316  $this->‪buildDefaultLanguageConfiguration('ZH-CN', '/简/'),
317  $this->‪buildLanguageConfiguration('FR', '/fr-fr/', ['EN']),
318  $this->‪buildLanguageConfiguration('FR-CA', '/fr-ca/', ['FR', 'EN']),
319  ]
320  );
321 
322  $response = $this->executeFrontendRequest(
323  new InternalRequest($uri),
324  $this->internalRequestContext
325  );
326  $responseStructure = ResponseContent::fromString(
327  (string)$response->getBody()
328  );
329 
330  self::assertSame(
331  200,
332  $response->getStatusCode()
333  );
334  self::assertSame(
335  $expectedPageTitle,
336  $responseStructure->getScopePath('page/title')
337  );
338  }
339 
341  {
342  return [
343  ['https://website.local/简/简/?id=1110', 'ZH-CN: Welcome Default'],
344  ];
345  }
346 
351  public function ‪pageIsRenderedWithPathsAndChineseBase(string $uri, string $expectedPageTitle): void
352  {
354  'website-local',
355  $this->‪buildSiteConfiguration(1000, 'https://website.local/简/'),
356  [
357  $this->‪buildDefaultLanguageConfiguration('ZH-CN', '/简/'),
358  ]
359  );
360 
361  $response = $this->executeFrontendRequest(
362  new InternalRequest($uri),
363  $this->internalRequestContext
364  );
365  $responseStructure = ResponseContent::fromString(
366  (string)$response->getBody()
367  );
368 
369  self::assertSame(
370  200,
371  $response->getStatusCode()
372  );
373  self::assertSame(
374  $this->siteTitle,
375  $responseStructure->getScopePath('template/sitetitle')
376  );
377  self::assertSame(
378  $expectedPageTitle,
379  $responseStructure->getScopePath('page/title')
380  );
381  }
382 
386  public function ‪pageIsRenderedWithDomainsDataProvider(): array
387  {
388  $domainPaths = [
389  // @todo: This turns into a redirect to the default language (".us") making this function obsolete
390  // 'https://website.local/',
391  'https://website.us/',
392  'https://website.fr/',
393  // Explicitly testing umlaut domains
394  'https://wäbsite.ca/',
395  // Explicitly testing chinese character domains
396  'https://website.简/',
397  // @todo Implicit strict mode handling when calling non-existent site
398  // 'https://website.other/',
399  ];
400 
401  $queries = [
402  '?id=1100',
403  ];
404 
405  return array_map(
406  function (string $uri) {
407  if (strpos($uri, '.fr/') !== false) {
408  $expectedPageTitle = 'FR: Welcome';
409  } elseif (strpos($uri, '.ca/') !== false) {
410  $expectedPageTitle = 'FR-CA: Welcome';
411  } elseif (strpos($uri, '.简/') !== false) {
412  $expectedPageTitle = 'ZH-CN: Welcome';
413  } else {
414  $expectedPageTitle = 'EN: Welcome';
415  }
416  return [$uri, $expectedPageTitle];
417  },
418  $this->keysFromValues(
419  ‪PermutationUtility::meltStringItems([$domainPaths, $queries])
420  )
421  );
422  }
423 
431  public function ‪pageIsRenderedWithDomains(string $uri, string $expectedPageTitle)
432  {
434  'website-local',
435  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
436  [
437  $this->‪buildDefaultLanguageConfiguration('EN', 'https://website.us/'),
438  $this->‪buildLanguageConfiguration('FR', 'https://website.fr/', ['EN']),
439  $this->‪buildLanguageConfiguration('FR-CA', 'https://wäbsite.ca/', ['FR', 'EN']),
440  $this->‪buildLanguageConfiguration('ZH', 'https://website.简/', ['EN']),
441  ]
442  );
443 
444  $response = $this->executeFrontendRequest(
445  new InternalRequest($uri),
446  $this->internalRequestContext
447  );
448  $responseStructure = ResponseContent::fromString(
449  (string)$response->getBody()
450  );
451 
452  self::assertSame(
453  200,
454  $response->getStatusCode()
455  );
456  self::assertSame(
457  $this->siteTitle,
458  $responseStructure->getScopePath('template/sitetitle')
459  );
460  self::assertSame(
461  $expectedPageTitle,
462  $responseStructure->getScopePath('page/title')
463  );
464  }
465 
469  public function ‪restrictedPageIsRenderedDataProvider(): array
470  {
471  $instructions = [
472  // frontend user 1
473  ['https://website.local/?id=1510', 1, 'Whitepapers'],
474  ['https://website.local/?id=1511', 1, 'Products'],
475  ['https://website.local/?id=1512', 1, 'Solutions'],
476  // frontend user 2
477  ['https://website.local/?id=1510', 2, 'Whitepapers'],
478  ['https://website.local/?id=1511', 2, 'Products'],
479  ['https://website.local/?id=1515', 2, 'Research'],
480  ['https://website.local/?id=1520', 2, 'Forecasts'],
481  ['https://website.local/?id=1521', 2, 'Current Year'],
482  // frontend user 3
483  ['https://website.local/?id=1510', 3, 'Whitepapers'],
484  ['https://website.local/?id=1511', 3, 'Products'],
485  ['https://website.local/?id=1512', 3, 'Solutions'],
486  ['https://website.local/?id=1515', 3, 'Research'],
487  ['https://website.local/?id=1520', 3, 'Forecasts'],
488  ['https://website.local/?id=1521', 3, 'Current Year'],
489  ];
490 
491  return $this->keysFromTemplate($instructions, '%1$s (user:%2$s)');
492  }
493 
502  public function ‪restrictedPageIsRendered(string $uri, int $frontendUserId, string $expectedPageTitle)
503  {
505  'website-local',
506  $this->‪buildSiteConfiguration(1000, 'https://website.local/')
507  );
508 
509  $response = $this->executeFrontendRequest(
510  new InternalRequest($uri),
511  $this->internalRequestContext
512  ->withFrontendUserId($frontendUserId)
513  );
514  $responseStructure = ResponseContent::fromString(
515  (string)$response->getBody()
516  );
517 
518  self::assertSame(
519  200,
520  $response->getStatusCode()
521  );
522  self::assertSame(
523  $this->siteTitle,
524  $responseStructure->getScopePath('template/sitetitle')
525  );
526  self::assertSame(
527  $expectedPageTitle,
528  $responseStructure->getScopePath('page/title')
529  );
530  }
531 
536  {
537  $instructions = [
538  // no frontend user given
539  ['https://website.local/?id=1510', 0],
540  ['https://website.local/?id=1511', 0],
541  ['https://website.local/?id=1512', 0],
542  ['https://website.local/?id=1515', 0],
543  ['https://website.local/?id=1520', 0],
544  ['https://website.local/?id=1521', 0],
545  ['https://website.local/?id=2021', 0],
546  // frontend user 1
547  ['https://website.local/?id=1515', 1],
548  ['https://website.local/?id=1520', 1],
549  ['https://website.local/?id=1521', 1],
550  ['https://website.local/?id=2021', 1],
551  // frontend user 2
552  ['https://website.local/?id=1512', 2],
553  ['https://website.local/?id=2021', 2],
554  ];
555 
556  return $this->keysFromTemplate($instructions, '%1$s (user:%2$s)');
557  }
558 
567  {
569  'website-local',
570  $this->‪buildSiteConfiguration(1000, 'https://website.local/')
571  );
572 
573  $response = $this->executeFrontendRequest(
574  new InternalRequest($uri),
575  $this->internalRequestContext
576  ->withFrontendUserId($frontendUserId)
577  );
578 
579  self::assertSame(
580  403,
581  $response->getStatusCode()
582  );
583  self::assertThat(
584  (string)$response->getBody(),
585  self::logicalOr(
586  self::stringContains('Reason: ID was not an accessible page'),
587  self::stringContains('Reason: Subsection was found and not accessible')
588  )
589  );
590  }
591 
601  {
602  self::markTestSkipped('Skipped until PageContentErrorHandler::handlePageError does not use HTTP anymore');
603 
605  'website-local',
606  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
607  [],
608  $this->‪buildErrorHandlingConfiguration('Page', [403])
609  );
610 
611  $response = $this->executeFrontendRequest(
612  new InternalRequest($uri),
613  $this->internalRequestContext
614  ->withFrontendUserId($frontendUserId)
615  );
616 
617  self::assertSame(
618  403,
619  $response->getStatusCode()
620  );
621  }
622 
631  {
633  'website-local',
634  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
635  [],
636  $this->‪buildErrorHandlingConfiguration('PHP', [403])
637  );
638 
639  $response = $this->executeFrontendRequest(
640  new InternalRequest($uri),
641  $this->internalRequestContext
642  ->withFrontendUserId($frontendUserId)
643  );
644  $json = json_decode((string)$response->getBody(), true);
645 
646  self::assertSame(
647  403,
648  $response->getStatusCode()
649  );
650  self::assertThat(
651  $json['message'] ?? null,
652  self::logicalOr(
653  self::identicalTo('ID was not an accessible page'),
654  self::identicalTo('Subsection was found and not accessible')
655  )
656  );
657  }
658 
663  {
664  $instructions = [
665  // frontend user 4
666  ['https://website.local/?id=2021', 4, 'FEGroups Restricted'],
667  ];
668 
669  return $this->keysFromTemplate($instructions, '%1$s (user:%2$s)');
670  }
671 
680  public function ‪restrictedPageWithParentSysFolderIsRendered(string $uri, int $frontendUserId, string $expectedPageTitle): void
681  {
683  'website-local',
684  $this->‪buildSiteConfiguration(1000, 'https://website.local/')
685  );
686 
687  $response = $this->executeFrontendRequest(
688  new InternalRequest($uri),
689  $this->internalRequestContext
690  ->withFrontendUserId($frontendUserId)
691  );
692  $responseStructure = ResponseContent::fromString(
693  (string)$response->getBody()
694  );
695 
696  self::assertSame(
697  200,
698  $response->getStatusCode()
699  );
700  self::assertSame(
701  $expectedPageTitle,
702  $responseStructure->getScopePath('page/title')
703  );
704  }
705 
710  {
711  $instructions = [
712  // no frontend user given
713  ['https://website.local/?id=2021', 0],
714  // frontend user 1
715  ['https://website.local/?id=2021', 1],
716  // frontend user 2
717  ['https://website.local/?id=2021', 2],
718  // frontend user 3
719  ['https://website.local/?id=2021', 3],
720  ];
721 
722  return $this->keysFromTemplate($instructions, '%1$s (user:%2$s)');
723  }
724 
733  {
735  'website-local',
736  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
737  [],
738  $this->‪buildErrorHandlingConfiguration('Fluid', [403])
739  );
740 
741  $response = $this->executeFrontendRequest(
742  new InternalRequest($uri),
743  $this->internalRequestContext
744  ->withFrontendUserId($frontendUserId)
745  );
746 
747  self::assertSame(
748  403,
749  $response->getStatusCode()
750  );
751  self::assertStringContainsString(
752  'reasons: code,fe_group',
753  (string)$response->getBody()
754  );
755  self::assertThat(
756  (string)$response->getBody(),
757  self::logicalOr(
758  self::stringContains('message: ID was not an accessible page'),
759  self::stringContains('message: Subsection was found and not accessible')
760  )
761  );
762  }
763 
773  {
774  self::markTestSkipped('Skipped until PageContentErrorHandler::handlePageError does not use HTTP anymore');
775 
777  'website-local',
778  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
779  [],
780  $this->‪buildErrorHandlingConfiguration('Page', [403])
781  );
782 
783  $response = $this->executeFrontendRequest(
784  new InternalRequest($uri),
785  $this->internalRequestContext
786  ->withFrontendUserId($frontendUserId)
787  );
788 
789  self::assertSame(
790  403,
791  $response->getStatusCode()
792  );
793  }
794 
803  {
805  'website-local',
806  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
807  [],
808  $this->‪buildErrorHandlingConfiguration('PHP', [403])
809  );
810 
811  $response = $this->executeFrontendRequest(
812  new InternalRequest($uri),
813  $this->internalRequestContext
814  ->withFrontendUserId($frontendUserId)
815  );
816  $json = json_decode((string)$response->getBody(), true);
817 
818  self::assertSame(
819  403,
820  $response->getStatusCode()
821  );
822  self::assertThat(
823  $json['message'] ?? null,
824  self::logicalOr(
825  self::identicalTo('ID was not an accessible page'),
826  self::identicalTo('Subsection was found and not accessible')
827  )
828  );
829  }
830 
835  {
836  $instructions = [
837  // hidden page, always 404
838  ['https://website.local/?id=1800', 0],
839  ['https://website.local/?id=1800', 1],
840  // hidden fe group restricted and fegroup generally okay
841  ['https://website.local/?id=2022', 4],
842  ];
843 
844  return $this->keysFromTemplate($instructions, '%1$s (user:%2$s)');
845  }
846 
851  public function ‪hiddenPageSends404ResponseRegardlessOfVisitorGroup(string $uri, int $frontendUserId)
852  {
854  'website-local',
855  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
856  [],
857  $this->‪buildErrorHandlingConfiguration('PHP', [404])
858  );
859 
860  $response = $this->executeFrontendRequest(
861  new InternalRequest($uri),
862  $this->internalRequestContext
863  ->withFrontendUserId($frontendUserId)
864  );
865  $json = json_decode((string)$response->getBody(), true);
866 
867  self::assertSame(
868  404,
869  $response->getStatusCode()
870  );
871  self::assertThat(
872  $json['message'] ?? null,
873  self::identicalTo('The requested page does not exist!')
874  );
875  }
876 
881  {
882  $domainPaths = [
883  'https://website.local/',
884  ];
885 
886  $queries = [
887  '?',
888  '?id=1000',
889  '?id=1100',
890  ];
891 
892  $customQueries = [
893  '&testing[value]=1',
894  '&testing[value]=1&cHash=',
895  '&testing[value]=1&cHash=WRONG',
896  ];
897 
898  return $this->wrapInArray(
899  $this->keysFromValues(
900  ‪PermutationUtility::meltStringItems([$domainPaths, $queries, $customQueries])
901  )
902  );
903  }
904 
912  {
914  'website-local',
915  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
916  [],
917  $this->‪buildErrorHandlingConfiguration('Fluid', [404])
918  );
919 
920  $response = $this->executeFrontendRequest(
921  new InternalRequest($uri),
922  $this->internalRequestContext
923  );
924 
925  self::assertSame(
926  404,
927  $response->getStatusCode()
928  );
929  self::assertThat(
930  (string)$response->getBody(),
931  self::logicalOr(
932  self::stringContains('message: Request parameters could not be validated (&amp;cHash empty)'),
933  self::stringContains('message: Request parameters could not be validated (&amp;cHash comparison failed)')
934  )
935  );
936  }
937 
946  {
947  self::markTestSkipped('Skipped until PageContentErrorHandler::handlePageError does not use HTTP anymore');
948 
950  'website-local',
951  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
952  [],
953  $this->‪buildErrorHandlingConfiguration('Page', [404])
954  );
955 
956  $response = $this->executeFrontendRequest(
957  new InternalRequest($uri),
958  $this->internalRequestContext
959  );
960 
961  self::assertSame(
962  404,
963  $response->getStatusCode()
964  );
965  }
966 
974  {
976  'website-local',
977  $this->‪buildSiteConfiguration(1000, 'https://website.local/'),
978  [],
979  $this->‪buildErrorHandlingConfiguration('PHP', [404])
980  );
981 
982  $response = $this->executeFrontendRequest(
983  new InternalRequest($uri),
984  $this->internalRequestContext
985  );
986  $json = json_decode((string)$response->getBody(), true);
987 
988  self::assertSame(
989  404,
990  $response->getStatusCode()
991  );
992  self::assertThat(
993  $json['message'] ?? null,
994  self::logicalOr(
995  self::identicalTo('Request parameters could not be validated (&cHash empty)'),
996  self::identicalTo('Request parameters could not be validated (&cHash comparison failed)')
997  )
998  );
999  }
1000 
1004  public function ‪pageIsRenderedWithValidCacheHashDataProvider(): array
1005  {
1006  $domainPaths = [
1007  // @todo Implicit strict mode handling when calling non-existent site
1008  // '/',
1009  // 'https://localhost/',
1010  'https://website.local/',
1011  ];
1012 
1013  // cHash has been calculated with encryption key set to
1014  // '4408d27a916d51e624b69af3554f516dbab61037a9f7b9fd6f81b4d3bedeccb6'
1015  $queries = [
1016  // @todo Currently fails since cHash is verified after(!) redirect to page 1100
1017  // '?&cHash=7d1f13fa91159dac7feb3c824936b39d&id=1000',
1018  '?&cHash=f42b850e435f0cedd366f5db749fc1af&id=1100',
1019  ];
1020 
1021  $customQueries = [
1022  '&testing[value]=1',
1023  ];
1024 
1025  $dataSet = $this->wrapInArray(
1026  $this->keysFromValues(
1027  ‪PermutationUtility::meltStringItems([$domainPaths, $queries, $customQueries])
1028  )
1029  );
1030 
1031  return $dataSet;
1032  }
1033 
1040  public function ‪pageIsRenderedWithValidCacheHash($uri)
1041  {
1043  'website-local',
1044  $this->‪buildSiteConfiguration(1000, 'https://website.local/')
1045  );
1046 
1047  $response = $this->executeFrontendRequest(
1048  new InternalRequest($uri),
1049  $this->internalRequestContext
1050  );
1051  $responseStructure = ResponseContent::fromString(
1052  (string)$response->getBody()
1053  );
1054  self::assertSame(
1055  '1',
1056  $responseStructure->getScopePath('getpost/testing.value')
1057  );
1058  }
1059 
1064  {
1065  return [
1066  [
1067  'https://website.local/',
1068  'https://website.local/en-welcome'
1069  ],
1070  [
1071  'https://website.local/?id=1000',
1072  'https://website.local/en-welcome'
1073  ],
1074  [
1075  'https://website.local/?type=0',
1076  'https://website.local/en-welcome?type=0'
1077  ],
1078  [
1079  'https://website.local/?id=1000&type=0',
1080  'https://website.local/en-welcome?type=0'
1081  ],
1082  [
1083  'https://website.local/index.php',
1084  'https://website.local/en-welcome'
1085  ],
1086  [
1087  'https://website.local/index.php?id=1000',
1088  'https://website.local/en-welcome'
1089  ],
1090  [
1091  'https://website.local/index.php?type=0',
1092  'https://website.local/en-welcome?type=0'
1093  ],
1094  [
1095  'https://website.local/index.php?id=1000&type=0',
1096  'https://website.local/en-welcome?type=0'
1097  ],
1098  ];
1099  }
1100 
1108  public function ‪checkIfIndexPhpReturnsShortcutRedirectWithPageIdAndTypeNumProvided(string $uri, string $expectedHeaderLocation)
1109  {
1111  'website-local',
1112  $this->‪buildSiteConfiguration(1000, 'https://website.local/')
1113  );
1114 
1115  $expectedStatusCode = 307;
1116  $expectedHeaders = ['location' => [$expectedHeaderLocation]];
1117 
1118  $response = $this->executeFrontendRequest(
1119  new InternalRequest($uri),
1120  $this->internalRequestContext
1121  );
1122 
1123  self::assertSame($expectedStatusCode, $response->getStatusCode());
1124  self::assertSame($expectedHeaders, $response->getHeaders());
1125  }
1126 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageRequestSendsNotFoundResponseWithInvalidCacheHashWithHavingFluidErrorHandling
‪pageRequestSendsNotFoundResponseWithInvalidCacheHashWithHavingFluidErrorHandling(string $uri)
Definition: SiteRequestTest.php:909
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorWithHavingFluidErrorHandling
‪restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorWithHavingFluidErrorHandling(string $uri, int $frontendUserId)
Definition: SiteRequestTest.php:730
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\hiddenPageSends404ResponseRegardlessOfVisitorGroupDataProvider
‪array hiddenPageSends404ResponseRegardlessOfVisitorGroupDataProvider()
Definition: SiteRequestTest.php:832
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithValidCacheHash
‪pageIsRenderedWithValidCacheHash($uri)
Definition: SiteRequestTest.php:1038
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\$internalRequestContext
‪InternalRequestContext $internalRequestContext
Definition: SiteRequestTest.php:39
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildErrorHandlingConfiguration
‪array buildErrorHandlingConfiguration(string $handler, array $codes)
Definition: SiteBasedTestTrait.php:184
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageRenderingStopsWithInvalidCacheHashDataProvider
‪array pageRenderingStopsWithInvalidCacheHashDataProvider()
Definition: SiteRequestTest.php:878
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\setUpBeforeClass
‪static setUpBeforeClass()
Definition: SiteRequestTest.php:41
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\shortcutsAreRedirectedAndRenderFirstSubPage
‪shortcutsAreRedirectedAndRenderFirstSubPage(string $uri)
Definition: SiteRequestTest.php:154
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPageErrorHandling
‪restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPageErrorHandling(string $uri, int $frontendUserId)
Definition: SiteRequestTest.php:770
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorDataProvider
‪array restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorDataProvider()
Definition: SiteRequestTest.php:707
‪TYPO3\CMS\Core\Utility\PermutationUtility\meltStringItems
‪static array meltStringItems(array $payload, string $previousResult='')
Definition: PermutationUtility.php:36
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorDataProvider
‪array restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorDataProvider()
Definition: SiteRequestTest.php:533
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest
Definition: SiteRequestTest.php:32
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithValidCacheHashDataProvider
‪array pageIsRenderedWithValidCacheHashDataProvider()
Definition: SiteRequestTest.php:1002
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithPathsAndChineseDefaultLanguage
‪pageIsRenderedWithPathsAndChineseDefaultLanguage(string $uri, string $expectedPageTitle)
Definition: SiteRequestTest.php:308
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildLanguageConfiguration
‪array buildLanguageConfiguration(string $identifier, string $base, array $fallbackIdentifiers=[], string $fallbackType=null)
Definition: SiteBasedTestTrait.php:142
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithDomains
‪pageIsRenderedWithDomains(string $uri, string $expectedPageTitle)
Definition: SiteRequestTest.php:429
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase
Definition: AbstractTestCase.php:29
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPhpErrorHandling
‪restrictedPageWithParentSysFolderSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPhpErrorHandling(string $uri, int $frontendUserId)
Definition: SiteRequestTest.php:800
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\setUp
‪setUp()
Definition: SiteRequestTest.php:53
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithPathsAndChineseBaseDataProvider
‪pageIsRenderedWithPathsAndChineseBaseDataProvider()
Definition: SiteRequestTest.php:338
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageIsRendered
‪restrictedPageIsRendered(string $uri, int $frontendUserId, string $expectedPageTitle)
Definition: SiteRequestTest.php:500
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithPathsAndChineseDefaultLanguageDataProvider
‪pageIsRenderedWithPathsAndChineseDefaultLanguageDataProvider()
Definition: SiteRequestTest.php:269
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageRequestSendsNotFoundResponseWithInvalidCacheHashWithHavingPhpErrorHandling
‪pageRequestSendsNotFoundResponseWithInvalidCacheHashWithHavingPhpErrorHandling(string $uri)
Definition: SiteRequestTest.php:971
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:124
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:617
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithPaths
‪pageIsRenderedWithPaths(string $uri, string $expectedPageTitle)
Definition: SiteRequestTest.php:238
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\tearDown
‪tearDown()
Definition: SiteRequestTest.php:92
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\hiddenPageSends404ResponseRegardlessOfVisitorGroup
‪hiddenPageSends404ResponseRegardlessOfVisitorGroup(string $uri, int $frontendUserId)
Definition: SiteRequestTest.php:849
‪TYPO3\CMS\Core\Utility\PermutationUtility
Definition: PermutationUtility.php:24
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\$siteTitle
‪string $siteTitle
Definition: SiteRequestTest.php:35
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\checkIfIndexPhpReturnsShortcutRedirectWithPageIdAndTypeNumProvidedDataProvider
‪array checkIfIndexPhpReturnsShortcutRedirectWithPageIdAndTypeNumProvidedDataProvider()
Definition: SiteRequestTest.php:1061
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithPathsDataProvider
‪array pageIsRenderedWithPathsDataProvider()
Definition: SiteRequestTest.php:193
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling
Definition: AbstractTestCase.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\setUpDatabase
‪setUpDatabase()
Definition: SiteRequestTest.php:66
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\checkIfIndexPhpReturnsShortcutRedirectWithPageIdAndTypeNumProvided
‪checkIfIndexPhpReturnsShortcutRedirectWithPageIdAndTypeNumProvided(string $uri, string $expectedHeaderLocation)
Definition: SiteRequestTest.php:1106
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorWithoutHavingErrorHandling
‪restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorWithoutHavingErrorHandling(string $uri, int $frontendUserId)
Definition: SiteRequestTest.php:564
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageIsRenderedDataProvider
‪array restrictedPageIsRenderedDataProvider()
Definition: SiteRequestTest.php:467
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPageErrorHandling
‪restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPageErrorHandling(string $uri, int $frontendUserId)
Definition: SiteRequestTest.php:598
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageWithParentSysFolderIsRenderedDataProvider
‪array restrictedPageWithParentSysFolderIsRenderedDataProvider()
Definition: SiteRequestTest.php:660
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageRequestSendsNotFoundResponseWithInvalidCacheHashWithHavingPageErrorHandling
‪pageRequestSendsNotFoundResponseWithInvalidCacheHashWithHavingPageErrorHandling(string $uri)
Definition: SiteRequestTest.php:943
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:109
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\shortcutsAreRedirectedToFirstSubPage
‪shortcutsAreRedirectedToFirstSubPage(string $uri)
Definition: SiteRequestTest.php:127
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\shortcutsAreRedirectedDataProvider
‪array shortcutsAreRedirectedDataProvider()
Definition: SiteRequestTest.php:101
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageWithParentSysFolderIsRendered
‪restrictedPageWithParentSysFolderIsRendered(string $uri, int $frontendUserId, string $expectedPageTitle)
Definition: SiteRequestTest.php:678
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPhpErrorHandling
‪restrictedPageSendsForbiddenResponseWithUnauthorizedVisitorWithHavingPhpErrorHandling(string $uri, int $frontendUserId)
Definition: SiteRequestTest.php:628
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\tearDownAfterClass
‪static tearDownAfterClass()
Definition: SiteRequestTest.php:47
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithPathsAndChineseBase
‪pageIsRenderedWithPathsAndChineseBase(string $uri, string $expectedPageTitle)
Definition: SiteRequestTest.php:349
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\SiteRequestTest\pageIsRenderedWithDomainsDataProvider
‪array pageIsRenderedWithDomainsDataProvider()
Definition: SiteRequestTest.php:384