39 'Simple Case - Empty' => array(
43 'Simple Case - Single Value' => array(
47 'Simple Case - Two Values' => array(
48 array(
'field1',
'field2'),
55 array(
'field1',
'field[subfield1]',
'field[subfield2]'),
64 'recursion with duplicated field name' => array(
65 array(
'field1',
'field[subfield1]',
'field[subfield2]',
'field1'),
74 'Recursion with un-named fields at the end (...[]). There, they should be made explicit by increasing the counter' => array(
75 array(
'field1',
'field[subfield1][]',
'field[subfield1][]',
'field[subfield2]'),
98 'Overriding form fields (string overridden by array) - 1' => array(
99 array(
'field1',
'field2',
'field2[bla]',
'field2[blubb]'),
101 'Overriding form fields (string overridden by array) - 2' => array(
102 array(
'field1',
'field2[bla]',
'field2[bla][blubb][blubb]'),
104 'Overriding form fields (array overridden by string) - 1' => array(
105 array(
'field1',
'field2[bla]',
'field2[blubb]',
'field2'),
107 'Overriding form fields (array overridden by string) - 2' => array(
108 array(
'field1',
'field2[bla][blubb][blubb]',
'field2[bla]'),
110 'Empty [] not as last argument' => array(
111 array(
'field1',
'field2[][bla]'),
122 $requestHashService = $this->getMock(
'TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService', array(
'serializeAndHashFormFieldArray'));
123 $requestHashService->expects($this->once())->method(
'serializeAndHashFormFieldArray')->with($expected);
124 $requestHashService->generateTrustedPropertiesToken($input);
133 $requestHashService = $this->getMock(
'TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService', array(
'serializeAndHashFormFieldArray'));
134 $requestHashService->generateTrustedPropertiesToken($input);
141 $formFieldArray = array(
149 $hashService = $this->getMock($this->
buildAccessibleProxy(
'TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService'), array(
'appendHmac'));
150 $hashService->expects($this->once())->method(
'appendHmac')->with(serialize($formFieldArray))->will($this->returnValue(serialize($formFieldArray) . $mockHash));
152 $requestHashService = $this->getMock($this->
buildAccessibleProxy(
'TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService'), array(
'dummy'));
153 $requestHashService->_set(
'hashService', $hashService);
155 $expected = serialize($formFieldArray) . $mockHash;
156 $actual = $requestHashService->_call(
'serializeAndHashFormFieldArray', $formFieldArray);
157 $this->assertEquals($expected, $actual);
164 $request = $this->getMockBuilder(
'TYPO3\CMS\Extbase\Mvc\Request')->setMethods(array(
'getInternalArgument'))->disableOriginalConstructor()->getMock();
165 $request->expects($this->any())->method(
'getInternalArgument')->with(
'__trustedProperties')->will($this->returnValue(NULL));
166 $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
168 $requestHashService = new \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService;
169 $requestHashService->initializePropertyMappingConfigurationFromRequest($request, $arguments);
176 $trustedProperties = array(
186 $trustedProperties = array(
187 'nonExistingArgument' => 1
190 $this->assertFalse($arguments->hasArgument(
'nonExistingArgument'));
197 $trustedProperties = array(
206 $propertyMappingConfiguration = $arguments->getArgument(
'foo')->getPropertyMappingConfiguration();
207 $this->assertTrue($propertyMappingConfiguration->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED),
'ConfigurationValue is not CONFIGURATION_MODIFICATION_ALLOWED at line ' . __LINE__);
208 $this->assertNull($propertyMappingConfiguration->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED),
'ConfigurationValue is not NULL at line ' . __LINE__);
209 $this->assertFalse($propertyMappingConfiguration->shouldMap(
'someProperty'),
'Value is not FALSE at line ' . __LINE__);
211 $this->assertTrue($propertyMappingConfiguration->forProperty(
'nested')->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED),
'ConfigurationValue is not CONFIGURATION_MODIFICATION_ALLOWED at line ' . __LINE__);
212 $this->assertNull($propertyMappingConfiguration->forProperty(
'nested')->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED),
'ConfigurationValue is not NULL at line ' . __LINE__);
213 $this->assertFalse($propertyMappingConfiguration->forProperty(
'nested')->shouldMap(
'someProperty'),
'Value is not FALSE at line ' . __LINE__);
220 $trustedProperties = array(
226 $propertyMappingConfiguration = $arguments->getArgument(
'foo')->getPropertyMappingConfiguration();
227 $this->assertNull($propertyMappingConfiguration->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
228 $this->assertTrue($propertyMappingConfiguration->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
229 $this->assertFalse($propertyMappingConfiguration->shouldMap(
'someProperty'));
231 $this->assertNull($propertyMappingConfiguration->forProperty(
'bar')->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
232 $this->assertTrue($propertyMappingConfiguration->forProperty(
'bar')->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
233 $this->assertFalse($propertyMappingConfiguration->forProperty(
'bar')->shouldMap(
'someProperty'));
240 $trustedProperties = array(
246 $propertyMappingConfiguration = $arguments->getArgument(
'foo')->getPropertyMappingConfiguration();
247 $this->assertFalse($propertyMappingConfiguration->shouldMap(
'someProperty'));
248 $this->assertTrue($propertyMappingConfiguration->shouldMap(
'bar'));
255 $trustedProperties = array(
263 $propertyMappingConfiguration = $arguments->getArgument(
'foo')->getPropertyMappingConfiguration();
264 $this->assertFalse($propertyMappingConfiguration->shouldMap(
'someProperty'));
265 $this->assertTrue($propertyMappingConfiguration->shouldMap(
'bar'));
266 $this->assertTrue($propertyMappingConfiguration->forProperty(
'bar')->shouldMap(
'foo'));
277 $request = $this->getMockBuilder(
'TYPO3\CMS\Extbase\Mvc\Request')->setMethods(array(
'getInternalArgument'))->disableOriginalConstructor()->getMock();
278 $request->expects($this->any())->method(
'getInternalArgument')->with(
'__trustedProperties')->will($this->returnValue(
'fooTrustedProperties'));
280 $mockHashService = $this->getMock(
'TYPO3\CMS\Extbase\Security\Cryptography\HashService', array(
'validateAndStripHmac'));
281 $mockHashService->expects($this->once())->method(
'validateAndStripHmac')->with(
'fooTrustedProperties')->will($this->returnValue(serialize($trustedProperties)));
283 $requestHashService = $this->
getAccessibleMock(
'TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService', array(
'dummy'));
284 $requestHashService->_set(
'hashService', $mockHashService);
286 $mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
287 $mockArgument = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getName'), array(),
'', FALSE);
289 $propertyMappingConfiguration = new \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfiguration();
291 $mockArgument->_set(
'propertyMappingConfiguration', $propertyMappingConfiguration);
292 $mockArgument->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
293 $mockObjectManager->expects($this->once())->method(
'get')->with(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument')->will($this->returnValue($mockArgument));
295 $arguments = $this->
getAccessibleMock(
'TYPO3\CMS\Extbase\Mvc\Controller\Arguments', array(
'dummy'));
296 $arguments->_set(
'objectManager', $mockObjectManager);
297 $arguments->addNewArgument(
'foo');
299 $requestHashService->initializePropertyMappingConfigurationFromRequest($request, $arguments);
initializePropertyMappingConfigurationReturnsEarlyIfArgumentIsUnknown()
initializePropertyMappingConfigurationDoesNothingIfTrustedPropertiesAreNotSet()
generateTrustedPropertiesTokenThrowsExceptionInWrongCases($input)
initializePropertyMappingConfigurationSetsModificationAllowedIfIdentityPropertyIsSet()
initializePropertyMappingConfigurationSetsAllowedFields()
dataProviderForgenerateTrustedPropertiesToken()
initializePropertyMappingConfiguration(array $trustedProperties)
serializeAndHashFormFieldArrayWorks()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
generateTrustedPropertiesTokenGeneratesTheCorrectHashesInNormalOperation($input, $expected)
initializePropertyMappingConfigurationReturnsEarlyIfNoTrustedPropertiesAreSet()
buildAccessibleProxy($className)
initializePropertyMappingConfigurationSetsAllowedFieldsRecursively()
initializePropertyMappingConfigurationSetsCreationAllowedIfIdentityPropertyIsNotSet()
dataProviderForgenerateTrustedPropertiesTokenWithUnallowedValues()