TYPO3 CMS  TYPO3_8-7
AbstractExceptionHandlerTest.php
Go to the documentation of this file.
1 <?php
2 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 
20 
24 class AbstractExceptionHandlerTest extends UnitTestCase
25 {
31  public function exampleUrlsForTokenAnonymization(): array
32  {
33  return [
34  'url with valid token' => [
35  'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36',
36  'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--'
37  ],
38  'url with valid token in the middle' => [
39  'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36&param=asdf',
40  'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--&param=asdf'
41  ],
42  'url with invalid token' => [
43  'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8/e',
44  'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8/e',
45  ],
46  'url with empty token' => [
47  'http://localhost/typo3/index.php?M=foo&moduleToken=',
48  'http://localhost/typo3/index.php?M=foo&moduleToken=',
49  ],
50  'url with no token' => [
51  'http://localhost/typo3/index.php?M=foo',
52  'http://localhost/typo3/index.php?M=foo',
53  ],
54  ];
55  }
56 
63  public function anonymizeTokenReturnsCorrectModifiedUrl(string $originalUrl, string $expectedUrl)
64  {
65  $mock = $this->getAccessibleMockForAbstractClass(AbstractExceptionHandler::class, ['dummy']);
66  $anonymizedUrl = $mock->_call('anonymizeToken', $originalUrl);
67  $this->assertSame($expectedUrl, $anonymizedUrl);
68  }
69 }
anonymizeTokenReturnsCorrectModifiedUrl(string $originalUrl, string $expectedUrl)