33 'renameFile' => FALSE,
35 'deleteFile' => FALSE,
38 'readFolder' => FALSE,
39 'writeFolder' => FALSE,
40 'copyFolder' => FALSE,
41 'moveFolder' => FALSE,
42 'renameFolder' => FALSE,
43 'deleteFolder' => FALSE,
44 'recursivedeleteFolder' => FALSE
49 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'] = array();
64 $formProtection = $this->getMock(
65 'TYPO3\\CMS\\Core\\FormProtection\\BackendFormProtection',
71 $formProtection->expects($this->once())->method(
'clean');
74 'TYPO3\\CMS\\Core\\FormProtection\\BackendFormProtection',
79 $GLOBALS[
'BE_USER'] = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(), array(),
'', FALSE);
81 $GLOBALS[
'TYPO3_DB'] = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(),
'', FALSE);
83 $subject = $this->
getAccessibleMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(
'dummy'), array(),
'', FALSE);
84 $subject->_set(
'db',
$GLOBALS[
'TYPO3_DB']);
92 $completeConfiguration = array(
93 'value' =>
'oneValue',
94 'value.' => array(
'oneProperty' =>
'oneValue'),
95 'permissions.' => array(
97 'default.' => array(
'readAction' =>
'1'),
98 '1.' => array(
'writeAction' =>
'1'),
99 '0.' => array(
'readAction' =>
'0'),
105 'single level string' => array(
106 $completeConfiguration,
113 'default.' => array(
'readAction' =>
'1'),
114 '1.' => array(
'writeAction' =>
'1'),
115 '0.' => array(
'readAction' =>
'0'),
120 'two levels string' => array(
121 $completeConfiguration,
127 'default.' => array(
'readAction' =>
'1'),
128 '1.' => array(
'writeAction' =>
'1'),
129 '0.' => array(
'readAction' =>
'0'),
133 'three levels string' => array(
134 $completeConfiguration,
135 'permissions.file.default',
139 array(
'readAction' =>
'1'),
142 'three levels string with integer property' => array(
143 $completeConfiguration,
144 'permissions.file.1',
147 'properties' => array(
'writeAction' =>
'1'),
150 'three levels string with integer zero property' => array(
151 $completeConfiguration,
152 'permissions.file.0',
155 'properties' => array(
'readAction' =>
'0'),
158 'four levels string with integer zero property, value, no properties' => array(
159 $completeConfiguration,
160 'permissions.file.0.readAction',
163 'properties' => NULL,
166 'four levels string with integer property, value, no properties' => array(
167 $completeConfiguration,
168 'permissions.file.1.writeAction',
171 'properties' => NULL,
174 'one level, not existant string' => array(
175 $completeConfiguration,
179 'properties' => NULL,
182 'two level, not existant string' => array(
183 $completeConfiguration,
187 'properties' => NULL,
190 'two level, where second level does not exist' => array(
191 $completeConfiguration,
195 'properties' => NULL,
198 'three level, where third level does not exist' => array(
199 $completeConfiguration,
200 'permissions.file.foo',
203 'properties' => NULL,
206 'three level, where second and third level does not exist' => array(
207 $completeConfiguration,
208 'permissions.foo.bar',
211 'properties' => NULL,
214 'value and properties' => array(
215 $completeConfiguration,
218 'value' =>
'oneValue',
219 'properties' => array(
'oneProperty' =>
'oneValue'),
233 $subject = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(
'dummy'), array(),
'', FALSE);
234 $subject->userTS = $completeConfiguration;
236 $actualConfiguration = $subject->getTSConfig($objectString);
237 $this->assertSame($expectedConfiguration, $actualConfiguration);
245 'Only read permissions' => array(
262 'recursivedeleteFolder' => 0,
265 'Uploading allowed' => array(
282 'recursivedeleteFolder' => 0
285 'One value is enough' => array(
299 $subject = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(
'isAdmin'));
302 ->expects($this->any())
304 ->will($this->returnValue(FALSE));
306 $subject->userTS = array(
307 'permissions.' => array(
309 'default.' => $userTsConfiguration
314 $expectedPermissions = array_merge($this->defaultFilePermissions, $userTsConfiguration);
316 $expectedPermissions,
318 $value = (bool) $value;
322 $this->assertEquals($expectedPermissions, $subject->getFilePermissions());
329 $defaultPermissions = array(
335 'renameFile' => TRUE,
337 'deleteFile' => TRUE,
339 'readFolder' => TRUE,
340 'copyFolder' => TRUE,
341 'moveFolder' => TRUE,
342 'renameFolder' => TRUE,
343 'writeFolder' => TRUE,
344 'deleteFolder' => TRUE,
345 'recursivedeleteFolder' => TRUE
349 'Overwrites given storage permissions with default permissions' => array(
354 'recursivedeleteFolder' =>0
372 'recursivedeleteFolder' => 0
375 'Overwrites given storage 0 permissions with default permissions' => array(
380 'recursivedeleteFolder' =>0
388 'renameFile' => TRUE,
390 'deleteFile' => TRUE,
392 'readFolder' => TRUE,
393 'copyFolder' => TRUE,
394 'moveFolder' => TRUE,
395 'renameFolder' => TRUE,
396 'writeFolder' => TRUE,
397 'deleteFolder' => TRUE,
398 'recursivedeleteFolder' => FALSE
401 'Returns default permissions if no storage permissions are found' => array(
411 'renameFile' => TRUE,
413 'deleteFile' => TRUE,
415 'readFolder' => TRUE,
416 'copyFolder' => TRUE,
417 'moveFolder' => TRUE,
418 'renameFolder' => TRUE,
419 'writeFolder' => TRUE,
420 'deleteFolder' => TRUE,
421 'recursivedeleteFolder' => TRUE
436 $subject = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(
'isAdmin',
'getFilePermissions'));
437 $storageMock = $this->getMock(
'TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(),
'', FALSE);
438 $storageMock->expects($this->any())->method(
'getUid')->will($this->returnValue($storageUid));
441 ->expects($this->any())
443 ->will($this->returnValue(FALSE));
446 ->expects($this->any())
447 ->method(
'getFilePermissions')
448 ->will($this->returnValue($defaultPermissions));
450 $subject->userTS = array(
451 'permissions.' => array(
454 $storageUid .
'.' => $storagePermissions
460 $this->assertEquals($expectedPermissions, $subject->getFilePermissionsForStorage($storageMock));
471 $subject = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(
'isAdmin',
'getFilePermissions'));
472 $storageMock = $this->getMock(
'TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(),
'', FALSE);
473 $storageMock->expects($this->any())->method(
'getUid')->will($this->returnValue($storageUid));
476 ->expects($this->any())
478 ->will($this->returnValue(TRUE));
481 ->expects($this->any())
482 ->method(
'getFilePermissions')
483 ->will($this->returnValue($defaultPermissions));
485 $subject->userTS = array(
486 'permissions.' => array(
489 $storageUid .
'.' => $storagePermissions
495 $this->assertEquals($defaultPermissions, $subject->getFilePermissionsForStorage($storageMock));
503 'No permission' => array(
508 'writeFile' => FALSE,
511 'renameFile' => FALSE,
512 'unzipFile' => FALSE,
513 'deleteFile' => FALSE,
514 'addFolder' => FALSE,
515 'readFolder' => FALSE,
516 'copyFolder' => FALSE,
517 'moveFolder' => FALSE,
518 'renameFolder' => FALSE,
519 'writeFolder' => FALSE,
520 'deleteFolder' => FALSE,
521 'recursivedeleteFolder' => FALSE
524 'Standard file permissions' => array(
525 'addFile,readFile,writeFile,copyFile,moveFile,renameFile,deleteFile',
532 'renameFile' => TRUE,
533 'unzipFile' => FALSE,
534 'deleteFile' => TRUE,
535 'addFolder' => FALSE,
536 'readFolder' => FALSE,
537 'copyFolder' => FALSE,
538 'moveFolder' => FALSE,
539 'renameFolder' => FALSE,
540 'writeFolder' => FALSE,
541 'deleteFolder' => FALSE,
542 'recursivedeleteFolder' => FALSE
545 'Unzip allowed' => array(
546 'readFile,unzipFile',
550 'writeFile' => FALSE,
553 'renameFile' => FALSE,
555 'deleteFile' => FALSE,
556 'addFolder' => FALSE,
557 'readFolder' => FALSE,
558 'writeFolder' => FALSE,
559 'copyFolder' => FALSE,
560 'moveFolder' => FALSE,
561 'renameFolder' => FALSE,
562 'deleteFolder' => FALSE,
563 'recursivedeleteFolder' => FALSE
566 'Standard folder permissions' => array(
567 'addFolder,readFolder,moveFolder,renameFolder,writeFolder,deleteFolder',
571 'writeFile' => FALSE,
574 'renameFile' => FALSE,
575 'unzipFile' => FALSE,
576 'deleteFile' => FALSE,
578 'readFolder' => TRUE,
579 'writeFolder' => TRUE,
580 'copyFolder' => FALSE,
581 'moveFolder' => TRUE,
582 'renameFolder' => TRUE,
583 'deleteFolder' => TRUE,
584 'recursivedeleteFolder' => FALSE
587 'Copy folder allowed' => array(
588 'readFolder,copyFolder',
592 'writeFile' => FALSE,
595 'renameFile' => FALSE,
596 'unzipFile' => FALSE,
597 'deleteFile' => FALSE,
598 'addFolder' => FALSE,
599 'readFolder' => TRUE,
600 'writeFolder' => FALSE,
601 'copyFolder' => TRUE,
602 'moveFolder' => FALSE,
603 'renameFolder' => FALSE,
604 'deleteFolder' => FALSE,
605 'recursivedeleteFolder' => FALSE
608 'Copy folder and remove subfolders allowed' => array(
609 'readFolder,copyFolder,recursivedeleteFolder',
613 'writeFile' => FALSE,
616 'renameFile' => FALSE,
617 'unzipFile' => FALSE,
618 'deleteFile' => FALSE,
619 'addFolder' => FALSE,
620 'readFolder' => TRUE,
621 'writeFolder' => FALSE,
622 'copyFolder' => TRUE,
623 'moveFolder' => FALSE,
624 'renameFolder' => FALSE,
625 'deleteFolder' => FALSE,
626 'recursivedeleteFolder' => TRUE
637 $subject = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(
'isAdmin'));
640 ->expects($this->any())
642 ->will($this->returnValue(FALSE));
644 $subject->userTS = array();
645 $subject->groupData[
'file_permissions'] = $permissionValue;
646 $this->assertEquals($expectedPermissions, $subject->getFilePermissions());
653 $subject = $this->getMock(
'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(
'isAdmin'));
656 ->expects($this->any())
658 ->will($this->returnValue(TRUE));
660 $expectedPermissions = array(
666 'renameFile' => TRUE,
668 'deleteFile' => TRUE,
670 'readFolder' => TRUE,
671 'writeFolder' => TRUE,
672 'copyFolder' => TRUE,
673 'moveFolder' => TRUE,
674 'renameFolder' => TRUE,
675 'deleteFolder' => TRUE,
676 'recursivedeleteFolder' => TRUE
679 $this->assertEquals($expectedPermissions, $subject->getFilePermissions());
getFilePermissionsGrantsAllPermissionsToAdminUsers()
getFilePermissionsTakesUserDefaultAndStoragePermissionsIntoAccountIfUserIsNotAdminDataProvider()
getFilePermissionsTakesUserDefaultPermissionsFromRecordIntoAccountIfUserIsNotAdmin($permissionValue, $expectedPermissions)
getFilePermissionsFromStorageDataProvider()
getFilePermissionsTakesUserDefaultPermissionsFromTsConfigIntoAccountIfUserIsNotAdmin(array $userTsConfiguration)
getTSConfigReturnsCorrectArrayForGivenObjectString(array $completeConfiguration, $objectString, array $expectedConfiguration)
logoffCleansFormProtectionIfBackendUserIsLoggedIn()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
getFilePermissionsFromStorageAlwaysReturnsDefaultPermissionsForAdmins(array $defaultPermissions, $storageUid, array $storagePermissions)
getFilePermissionsTakesUserDefaultPermissionsFromRecordIntoAccountIfUserIsNotAdminDataProvider()
getFilePermissionsFromStorageOverwritesDefaultPermissions(array $defaultPermissions, $storageUid, array $storagePermissions, array $expectedPermissions)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
getTSConfigDataProvider()