35 $this->confCache = array(
36 'encryptionKey' =>
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey']
38 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey'] =
't3lib_cacheHashTest';
39 $this->fixture = $this->getMock(
'TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator', array(
'foo'));
40 $this->fixture->setConfiguration(array(
41 'excludedParameters' => array(
'exclude1',
'exclude2'),
42 'cachedParametersWhiteList' => array(),
43 'requireCacheHashPresenceParameters' => array(
'req1',
'req2'),
44 'excludedParametersIfEmpty' => array(),
45 'includePageId' => TRUE,
46 'excludeAllEmptyParameters' => FALSE
55 $this->assertEquals($expected, $this->fixture->calculateCacheHash($params));
63 'Empty parameters should not return a hash' => array(
67 'Trivial key value combination should generate hash' => array(
69 'encryptionKey' =>
't3lib_cacheHashTest',
72 '5cfdcf826275558b3613dd51714a0a17' 74 'Multiple parameters should generate hash' => array(
78 'encryptionKey' =>
't3lib_cacheHashTest' 80 '0f40b089cdad149aea99e9bf4badaa93' 90 $actual = $this->fixture->getRelevantParameters($params);
91 $this->assertEquals($expected, array_keys($actual));
99 'Empty list should be passed through' => array(
'', array()),
100 'Simple parameter should be passed through and the encryptionKey should be added' => array(
102 array(
'encryptionKey',
'id',
'key')
104 'Simple parameter should be passed through' => array(
105 'key1=v&key2=v&id=42',
106 array(
'encryptionKey',
'id',
'key1',
'key2')
108 'System and exclude parameters should be omitted' => array(
109 'id=1&type=3&exclude1=x&no_cache=1',
112 'System and exclude parameters (except id) should be omitted, others should stay' => array(
113 'id=1&type=3&key=x&no_cache=1',
114 array(
'encryptionKey',
'id',
'key')
116 'System and exclude parameters should be omitted and id is not required to be specified' => array(
117 '&type=3&no_cache=1',
128 $this->assertEquals($expected, $this->fixture->generateForParameters($params));
137 $this->fixture->generateForParameters(
'&key=x');
144 $knowHash =
'fac112f7e662c83c19b57142c3a921f5';
146 'Empty parameters should not return an hash' => array(
'&id=42',
''),
147 'Querystring has no relevant parameters so we should not have a cacheHash' => array(
'&exclude1=val',
''),
148 'Querystring has only system parameters so we should not have a cacheHash' => array(
'&id=42&type=val',
''),
149 'Trivial key value combination should generate hash' => array(
'&id=42&key=value', $knowHash),
150 'Only the relevant parts should be taken into account' => array(
'&id=42&key=value&exclude1=val', $knowHash),
151 'Only the relevant parts should be taken into account(exclude2 before key)' => array(
'&id=42&exclude2=val&key=value', $knowHash),
152 'System parameters should not be taken into account (except id)' => array(
'&id=42&type=23&key=value', $knowHash),
153 'Admin panel parameters should not be taken into account' => array(
'&id=42&TSFE_ADMIN_PANEL[display]=7&key=value', $knowHash),
154 'Trivial hash for sorted parameters should be right' => array(
'&id=42&a=v&b=v',
'52c8a1299e20324f90377c43153c4987'),
155 'Parameters should be sorted before cHash is created' => array(
'&id=42&b=v&a=v',
'52c8a1299e20324f90377c43153c4987'),
156 'Empty argument names are filtered out before cHash calculation' => array(
'&id=42&b=v&a=v&=dummy',
'52c8a1299e20324f90377c43153c4987')
165 $this->assertEquals($expected, $this->fixture->doParametersRequireCacheHash($params));
173 'Empty parameter strings should not require anything.' => array(
'', FALSE),
174 'Normal parameters aren\'t required.' => array(
'key=value', FALSE),
175 'Configured "req1" to be required.' => array(
'req1=value', TRUE),
176 'Configured "req1" to be required, should also work in combined context' => array(
'&key=value&req1=value', TRUE),
177 'Configured "req1" to be required, should also work in combined context (key at the end)' => array(
'req1=value&key=value', TRUE)
189 $method = new \ReflectionMethod(
'TYPO3\\CMS\\Frontend\\Page\\CacheHashCalculator',
'setCachedParametersWhiteList');
190 $method->setAccessible(TRUE);
191 $method->invoke($this->fixture, array(
'whitep1',
'whitep2'));
192 $this->assertEquals($expected, $this->fixture->generateForParameters($params));
199 $oneParamHash =
'eae50a13101afd53a9d2c543230eb5bb';
200 $twoParamHash =
'701e2d2f1becc9d1b71d327e5cb1c3ed';
202 'Even with the whitelist enabled, empty parameters should not return an hash.' => array(
'',
''),
203 'Whitelisted parameters should have a hash.' => array(
'&id=42&whitep1=value', $oneParamHash),
204 'Blacklisted parameter should not influence hash.' => array(
'&id=42&whitep1=value&black=value', $oneParamHash),
205 'Multiple whitelisted parameters should work' => array(
'&id=42&whitep1=value&whitep2=value', $twoParamHash),
206 'The order should not influce the hash.' => array(
'&id=42&whitep2=value&black=value&whitep1=value', $twoParamHash)
215 $this->fixture->setConfiguration($settings);
216 $actual = $this->fixture->getRelevantParameters($params);
217 $this->assertEquals($expected, array_keys($actual));
225 'The default configuration does not allow to skip an empty key.' => array(
226 '&id=42&key1=v&key2=&key3=',
227 array(
'excludedParametersIfEmpty' => array(),
'excludeAllEmptyParameters' => FALSE),
228 array(
'encryptionKey',
'id',
'key1',
'key2',
'key3')
230 'Due to the empty value, "key2" should be skipped(with equals sign' => array(
231 '&id=42&key1=v&key2=&key3=',
232 array(
'excludedParametersIfEmpty' => array(
'key2'),
'excludeAllEmptyParameters' => FALSE),
233 array(
'encryptionKey',
'id',
'key1',
'key3')
235 'Due to the empty value, "key2" should be skipped(without equals sign)' => array(
236 '&id=42&key1=v&key2&key3',
237 array(
'excludedParametersIfEmpty' => array(
'key2'),
'excludeAllEmptyParameters' => FALSE),
238 array(
'encryptionKey',
'id',
'key1',
'key3')
240 'Due to the empty value, "key2" and "key3" should be skipped' => array(
241 '&id=42&key1=v&key2=&key3=',
242 array(
'excludedParametersIfEmpty' => array(),
'excludeAllEmptyParameters' => TRUE),
243 array(
'encryptionKey',
'id',
'key1')
generateForParametersThrowsExceptionWhenIdIsNotSpecified()
canSkipParametersWithEmptyValues($params, $settings, $expected)
canWhitelistParameters($params, $expected)
canGenerateForParametersDataProvider()
canWhitelistParametersDataProvider()
cacheHashCalculationWorks($params, $expected)
canGenerateForParameters($params, $expected)
parametersRequireCacheHashWorks($params, $expected)
canSkipParametersWithEmptyValuesDataProvider()
getRelevantParametersWorks($params, $expected)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
parametersRequireCacheHashDataProvider()
getRelevantParametersDataprovider()
cacheHashCalculationDataProvider()