40 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
41 ilUnitUtil::performInitialisation();
52 global $rbacreview,$rbacadmin;
55 #$rbacadmin->setProtected(1,4,'y'); 56 #$prot = $rbacreview->isProtected(8,4); 57 #$this->assertEquals($prot,true); 58 #$rbacadmin->setProtected(1,4,'n'); 59 #$prot = $rbacreview->isProtected(8,4); 60 #$this->assertEquals($prot,false); 62 $rbacreview->getRoleListByObject(8);
63 $rbacreview->getAssignableRoles();
66 $ass = $rbacreview->isAssignable(4, 8);
67 $this->assertEquals($ass,
true);
69 $roles = $rbacreview->getRolesOfObject(8);
71 $obj = $rbacreview->getObjectOfRole(4);
72 $this->assertEquals(8, $obj);
81 global $rbacreview,$rbacadmin;
85 $rbacreview->assignedUsers(4);
86 $rbacreview->assignedRoles(6);
97 global $rbacreview,$rbacadmin;
99 $sess_ops = $rbacreview->getOperationsOnTypeString(
'sess');
101 $rbacadmin->assignOperationToObject($rbacreview->getTypeId(
'sess'),
'7');
105 $rbacadmin->deassignOperationFromObject($rbacreview->getTypeId(
'sess'),
'7');
106 $new_sess_ops = $rbacreview->getOperationsOnTypeString(
'sess');
107 $this->assertEquals($sess_ops, $new_sess_ops);
116 global $rbacreview,$rbacadmin;
118 $sess_ops = $rbacreview->getOperationsOnTypeString(
'cat');
120 $rbacadmin->revokePermission(1, 4);
121 $rbacadmin->grantPermission(4,
array(2,3), 1);
132 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
144 $handler->setReferenceHandlingType(0);
145 $handler->enableAutomaticValidation(
false);
147 $this->assertEquals($suc,
true);
150 $this->assertEquals($suc,
false);
153 $this->assertEquals($suc,
true);
168 include_once
'./Services/AccessControl/classes/class.ilAccessHandler.php';
188 global $rbacreview, $rbacadmin;
190 $rbacadmin->assignUser(10, 15);
192 $this->assertTrue($rbacreview->isAssigned(15, 10));
195 $rbacadmin->assignUser(10, 15);
208 global $rbacreview, $rbacadmin;
210 $rbacadmin->deassignUser(10, 15);
212 $this->assertFalse($rbacreview->isAssigned(15, 10));
224 global $rbacreview, $rbacadmin;
226 $rbacadmin->grantPermission(10,
array(10,20,30), 60);
228 $this->assertEquals($rbacreview->getActiveOperationsOfRole(60, 10),
array(10,20,30));
242 global $rbacreview, $rbacadmin,
$ilDB;
244 $req = $ilDB->query(
"SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='seas';");
248 while (
$row = $ilDB->fetchAssoc(
$req)) {
249 $ref_id =
$row[
"ref_id"];
252 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
253 $ilDB->fetchAssoc(
$req);
254 $role1 = $ilDB->fetchAssoc(
$req)[
"obj_id"];
255 $role2 = $ilDB->fetchAssoc(
$req)[
"obj_id"];
256 $role3 = $ilDB->fetchAssoc(
$req)[
"obj_id"];
259 $opt1 = $rbacreview->getActiveOperationsOfRole($ref_id, $role1);
260 $opt2 = $rbacreview->getActiveOperationsOfRole($ref_id, $role2);
261 $opt3 = $rbacreview->getActiveOperationsOfRole($ref_id, $role3);
263 $rbacadmin->grantPermission($role1,
array(1,2,3,4,5), $ref_id);
264 $rbacadmin->grantPermission($role2,
array(1,2,3,4,5), $ref_id);
267 $rbacadmin->revokePermission($ref_id);
268 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role1));
269 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role2));
272 $rbacadmin->grantPermission($role1,
array(1,2,3,4,5), $ref_id);
274 $rbacadmin->revokePermission($ref_id, $role1);
275 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role1));
278 $rbacadmin->grantPermission($role2,
array(1,2,3,4,5), $ref_id);
279 $rbacadmin->grantPermission($role3,
array(1,2,3,4,5), $ref_id);
282 $rbacadmin->revokePermission($ref_id, 0,
false);
283 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role2));
284 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role3));
286 $rbacadmin->grantPermission($role3,
array(1,2,3,4,5), $ref_id);
288 $rbacadmin->revokePermission($ref_id, $role3,
false);
289 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role3));
292 $rbacadmin->grantPermission($role1, $opt1, $ref_id);
293 $rbacadmin->grantPermission($role2, $opt2, $ref_id);
294 $rbacadmin->grantPermission($role3, $opt3, $ref_id);
307 global $rbacreview, $rbacadmin, $tree,
$ilDB;
308 $req = $ilDB->query(
"SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='adm';");
312 while (
$row = $ilDB->fetchAssoc(
$req)) {
313 $ref_id =
$row[
"ref_id"];
316 $childs = $tree->getChildIds($ref_id);
318 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
319 $ilDB->fetchAssoc(
$req);
320 $role = $ilDB->fetchAssoc(
$req)[
"obj_id"];
324 foreach ($childs as
$id) {
325 $ops[
$id] = $rbacreview->getActiveOperationsOfRole($id, $role);
326 $rbacadmin->grantPermission($role,
array(1,2,3,4,5), $id);
330 $rbacadmin->revokeSubtreePermissions($ref_id, $role);
332 foreach ($childs as $id) {
333 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id, $role));
334 $rbacadmin->grantPermission($role, $ops[$id], $id);
348 global $rbacreview, $rbacadmin;
352 $rbacadmin->grantPermission(123,
array(1,2,3,4,5), $id);
355 $rbacadmin->revokePermissionList(
$list, 123);
357 foreach (
$list as $id) {
358 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id, 123));
371 global $rbacreview, $rbacadmin;
372 $rbacadmin->deleteTemplate(1010);
374 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15), 1100);
375 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25), 1100);
378 $dest = $rbacreview->getAllOperationsOfRole(1010, 1100);
383 $this->assertEquals($assert, $dest);
385 $rbacadmin->deleteTemplate(1010);
398 global $rbacreview, $rbacadmin;
399 $rbacadmin->deleteTemplate(1010);
401 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15), 1100);
402 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25), 1100);
404 $rbacadmin->deleteRolePermission(1010, 1100);
406 $this->assertEmpty($rbacreview->getAllOperationsOfRole(1010, 1100));
408 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15), 1100);
409 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25), 1100);
411 $rbacadmin->deleteRolePermission(1010, 1100,
"a");
414 $dest = $rbacreview->getAllOperationsOfRole(1010, 1100);
418 $this->assertEquals($assert, $dest);
420 $rbacadmin->deleteTemplate(1010);
433 global $rbacreview, $rbacadmin;
434 $rbacadmin->deleteTemplate(1010);
435 $rbacadmin->deleteTemplate(2020);
437 $rbacadmin->setRolePermission(1010,
"blub",
array(10,11), 1100);
438 $rbacadmin->setRolePermission(2020,
"bulb",
array(20,22), 2200);
440 $rbacadmin->copyRoleTemplatePermissions(1010, 1100, 2200, 2020);
442 $one = $rbacreview->getAllOperationsOfRole(1010, 1100);
443 $two = $rbacreview->getAllOperationsOfRole(2020, 2200);
446 $this->assertEquals($one, $two);
447 $rbacadmin->deleteTemplate(1010);
448 $rbacadmin->deleteTemplate(2020);
464 global $rbacreview, $rbacadmin,
$ilDB;
466 $req = $ilDB->query(
"SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='seas';");
470 while (
$row = $ilDB->fetchAssoc(
$req)) {
471 $seas =
$row[
"ref_id"];
474 $req = $ilDB->query(
"SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='mail';");
478 while (
$row = $ilDB->fetchAssoc(
$req)) {
479 $mail =
$row[
"ref_id"];
482 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
483 $ilDB->fetchAssoc(
$req);
484 $role = $ilDB->fetchAssoc(
$req)[
"obj_id"];
487 $opt_mail = $rbacreview->getActiveOperationsOfRole($mail, $role);
488 $opt_seas = $rbacreview->getActiveOperationsOfRole($seas, $role);
489 $opt_temp_seas = $rbacreview->getAllOperationsOfRole($role, $seas);
490 $opt_temp_mail = $rbacreview->getAllOperationsOfRole($role, $mail);
493 $rbacadmin->setRolePermission($role,
"mail",
array(1,2,3,4,5), $mail);
494 $rbacadmin->grantPermission($role,
array(1,2,3,4,5), $mail);
495 $rbacadmin->setRolePermission($role,
"seas",
array(5,6,7,8,9), $seas);
496 $rbacadmin->grantPermission($role,
array(5,6,7,8,9), $seas);
498 $rbacadmin->copyRolePermissions($role, $seas, $mail, $role);
500 $rbacreview->getActiveOperationsOfRole($seas, $role),
501 $rbacreview->getActiveOperationsOfRole($mail, $role)
505 $rbacadmin->grantPermission($role, $opt_seas, $seas);
506 $rbacadmin->grantPermission($role, $opt_mail, $mail);
508 $rbacadmin->deleteRolePermission($role, $mail);
509 $rbacadmin->deleteRolePermission($role, $seas);
511 foreach ($opt_temp_seas as
$type => $opt) {
512 $rbacadmin->setRolePermission($role,
$type, $opt, $seas);
515 foreach ($opt_temp_mail as
$type => $opt) {
516 $rbacadmin->setRolePermission($role,
$type, $opt, $mail);
530 global $rbacreview, $rbacadmin;
531 $rbacadmin->deleteTemplate(1010);
532 $rbacadmin->deleteTemplate(2020);
533 $rbacadmin->deleteTemplate(3030);
535 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15), 1100);
536 $rbacadmin->setRolePermission(2020,
"a",
array(11,12,13,16), 2200);
538 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25), 1100);
539 $rbacadmin->setRolePermission(2020,
"b",
array(20,23,24,26), 2200);
541 $rbacadmin->setRolePermission(3030,
"c",
array(30,33), 3300);
542 $rbacadmin->setRolePermission(3030,
"a",
array(30,33), 3300);
543 $rbacadmin->setRolePermission(3030,
"b",
array(30,33), 3300);
545 $rbacadmin->copyRolePermissionIntersection(1010, 1100, 2020, 2200, 3300, 3030);
548 $dest = $rbacreview->getAllOperationsOfRole(3030, 3300);
554 $this->assertEquals($intersect, $dest);
556 $rbacadmin->deleteTemplate(1010);
557 $rbacadmin->deleteTemplate(2020);
558 $rbacadmin->deleteTemplate(3030);
572 global $rbacreview, $rbacadmin;
573 $rbacadmin->deleteTemplate(1010);
574 $rbacadmin->deleteTemplate(2020);
575 $rbacadmin->deleteTemplate(3030);
577 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15), 1100);
578 $rbacadmin->setRolePermission(2020,
"a",
array(11,12,13,16), 2200);
580 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25), 1100);
581 $rbacadmin->setRolePermission(2020,
"b",
array(20,23,24,26), 2200);
583 $rbacadmin->setRolePermission(1010,
"c",
array(30,33,34,35), 1100);
585 $rbacadmin->copyRolePermissionUnion(1010, 1100, 2020, 2200, 3030, 3300);
587 $union =
array(
"a" =>
array(10,11,12,13,15,16),
"b" =>
array(20,22,23,24,25,26),
"c" =>
array(30,33,34,35));
588 $dest = $rbacreview->getAllOperationsOfRole(3030, 3300);
594 $this->assertEquals($union, $dest);
596 $rbacadmin->deleteTemplate(1010);
597 $rbacadmin->deleteTemplate(2020);
598 $rbacadmin->deleteTemplate(3030);
611 global $rbacreview, $rbacadmin;
612 $rbacadmin->deleteTemplate(1010);
613 $rbacadmin->deleteTemplate(2020);
615 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15), 1100);
616 $rbacadmin->setRolePermission(2020,
"a",
array(11,12,13,16), 2200);
618 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25), 1100);
619 $rbacadmin->setRolePermission(2020,
"b",
array(20,23,24,26), 2200);
621 $rbacadmin->setRolePermission(2020,
"c",
array(30,33,34,35), 2200);
623 $rbacadmin->copyRolePermissionSubtract(1010, 1100, 2020, 2200);
626 $dest = $rbacreview->getAllOperationsOfRole(2020, 2200);
632 $this->assertEquals($subtract, $dest);
634 $rbacadmin->deleteTemplate(1010);
635 $rbacadmin->deleteTemplate(2020);
647 global $rbacreview, $rbacadmin;
649 $rbacadmin->assignOperationToObject(1001, 10);
650 $rbacadmin->assignOperationToObject(1001, 20);
652 $this->assertEquals($rbacreview->getOperationsOnType(1001),
array(10,20));
663 global $rbacreview, $rbacadmin;
664 $rbacadmin->deassignOperationFromObject(1001, 10);
666 $this->assertEquals($rbacreview->getOperationsOnType(1001),
array(20));
668 $rbacadmin->deassignOperationFromObject(1001, 20);
670 $this->assertEmpty($rbacreview->getOperationsOnType(1001));
testRbacPA()
test rbac_pa IL_Init
if(isset($_REQUEST['delete'])) $list
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
testGrantPermission()
Test grant Permission Method DB: rbac_pa.
testCopyRoleTemplatePermissions()
Test Copy Role Template Permission Method DB: rbac_template.
testRevokePermission()
Test revoke Permission Method DB: rbac_pa.
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive, instead it parses the serialized rbac_pa entries.
testAssignUser()
Test Assign User Method DB: rbac_ua.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
testSetRolePermission()
Test Set Role Permission Method DB: rbac_template.
testCopyRolePermissions()
Test Method DB: rbac_template DB: rbac_pa.
testRevokePermissionList()
Test revokePermissionList Method DB: rbac_pa.
Interface ilAccessHandler.
testRbacUA()
test rbac_ua IL_Init
testAssignOperationToObject()
Test assignOperationToObject Method DB: rbac_ta.
Unit tests for tree table needsInstalledILIAS.
foreach($_POST as $key=> $value) $res
testConditions()
test preconditions IL_Init
testDeassignUser()
Test deassign user Method DB: rbac_ua.
static _getDistinctTargetRefIds()
Get all target ref ids.
static _deleteTargetConditionsByRefId($a_target_ref_id)
Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on...
Create styles array
The data for the language used.
Handles conditions for accesses to different ILIAS objects.
testRbacTA()
rbac ta test IL_Init
testCopyRolePermissionUnion()
Test Copy Role Permission Union Method DB: rbac_template.
testRbacFA()
RBAC FA tests IL_Init.
static _getCondition($a_id)
testCopyRolePermissionIntersection()
Test Copy Role Permission Intersection Method DB: rbac_template.
testCopyRolePermissionSubtract()
Test Copy Role Permission Subtract Method DB: rbac_template.
testDeassignOperationFromObject()
Test deassignOperationFromObject Method ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testAssign...
testRevokeSubtreePermissions()
Test revokeSubtreePermissions Method DB: rbac_pa.
testDeleteRolePermission()
Test Delete Role Permission Method DB: rbac_template.