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);
133 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
139 $handler->setTargetRefId(99999);
140 $handler->setTargetObjId(99998);
141 $handler->setTargetType(
'xxx');
142 $handler->setTriggerRefId(99997);
143 $handler->setTriggerObjId(99996);
144 $handler->setTriggerType(
'yyy');
145 $handler->setReferenceHandlingType(0);
146 $handler->enableAutomaticValidation(
false);
147 $suc = $handler->storeCondition();
148 $this->assertEquals($suc,
true);
150 $suc = $handler->checkExists();
151 $this->assertEquals($suc,
false);
153 $suc = $handler->delete(99999);
154 $this->assertEquals($suc,
true);
157 $handler->deleteByObjId(-1);
158 $handler->deleteCondition(-1);
169 include_once
'./Services/AccessControl/classes/class.ilAccessHandler.php';
172 $handler->setResults(
array(1,2,3));
173 $handler->storeCache();
174 $handler->readCache();
175 $res = $handler->getResults();
189 global $rbacreview, $rbacadmin;
191 $rbacadmin->assignUser(10,15);
193 $this->assertTrue($rbacreview->isAssigned(15,10));
196 $rbacadmin->assignUser(10,15);
209 global $rbacreview, $rbacadmin;
211 $rbacadmin->deassignUser(10,15);
213 $this->assertFalse($rbacreview->isAssigned(15,10));
225 global $rbacreview, $rbacadmin;
227 $rbacadmin->grantPermission(10,
array(10,20,30),60);
229 $this->assertEquals($rbacreview->getActiveOperationsOfRole(60,10),
array(10,20,30));
243 global $rbacreview, $rbacadmin,
$ilDB;
245 $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';");
249 while(
$row = $ilDB->fetchAssoc($req))
254 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
255 $ilDB->fetchAssoc($req);
256 $role1 = $ilDB->fetchAssoc($req)[
"obj_id"];
257 $role2 = $ilDB->fetchAssoc($req)[
"obj_id"];
258 $role3 = $ilDB->fetchAssoc($req)[
"obj_id"];
261 $opt1 = $rbacreview->getActiveOperationsOfRole(
$ref_id,$role1);
262 $opt2 = $rbacreview->getActiveOperationsOfRole(
$ref_id,$role2);
263 $opt3 = $rbacreview->getActiveOperationsOfRole(
$ref_id,$role3);
265 $rbacadmin->grantPermission($role1,
array(1,2,3,4,5),
$ref_id);
266 $rbacadmin->grantPermission($role2,
array(1,2,3,4,5),
$ref_id);
269 $rbacadmin->revokePermission(
$ref_id);
270 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role1));
271 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role2));
274 $rbacadmin->grantPermission($role1,
array(1,2,3,4,5),
$ref_id);
276 $rbacadmin->revokePermission(
$ref_id, $role1);
277 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role1));
280 $rbacadmin->grantPermission($role2,
array(1,2,3,4,5),
$ref_id);
281 $rbacadmin->grantPermission($role3,
array(1,2,3,4,5),
$ref_id);
284 $rbacadmin->revokePermission(
$ref_id,0,
false);
285 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role2));
286 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role3));
288 $rbacadmin->grantPermission($role3,
array(1,2,3,4,5),
$ref_id);
290 $rbacadmin->revokePermission(
$ref_id, $role3,
false);
291 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role3));
294 $rbacadmin->grantPermission($role1, $opt1,
$ref_id);
295 $rbacadmin->grantPermission($role2, $opt2,
$ref_id);
296 $rbacadmin->grantPermission($role3, $opt3,
$ref_id);
309 global $rbacreview, $rbacadmin, $tree,
$ilDB;
310 $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';");
314 while(
$row = $ilDB->fetchAssoc($req))
319 $childs = $tree->getChildIds(
$ref_id);
321 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
322 $ilDB->fetchAssoc($req);
323 $role = $ilDB->fetchAssoc($req)[
"obj_id"];
327 foreach($childs as $id)
329 $ops[$id] = $rbacreview->getActiveOperationsOfRole($id,$role);
330 $rbacadmin->grantPermission($role,
array(1,2,3,4,5),$id);
334 $rbacadmin->revokeSubtreePermissions(
$ref_id,$role);
336 foreach($childs as $id)
338 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id,$role));
339 $rbacadmin->grantPermission($role, $ops[$id],$id);
353 global $rbacreview, $rbacadmin;
354 $list =
array(1001, 1003, 1005, 1007);
356 foreach($list as $id)
358 $rbacadmin->grantPermission(123,
array(1,2,3,4,5),$id);
361 $rbacadmin->revokePermissionList($list, 123);
363 foreach($list as $id)
365 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id,123));
378 global $rbacreview, $rbacadmin;
379 $rbacadmin->deleteTemplate(1010);
381 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15),1100);
382 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25),1100);
385 $dest = $rbacreview->getAllOperationsOfRole(1010,1100);
390 $this->assertEquals($assert, $dest);
392 $rbacadmin->deleteTemplate(1010);
405 global $rbacreview, $rbacadmin;
406 $rbacadmin->deleteTemplate(1010);
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);
413 $this->assertEmpty($rbacreview->getAllOperationsOfRole(1010,1100));
415 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15),1100);
416 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25),1100);
418 $rbacadmin->deleteRolePermission(1010,1100,
"a");
421 $dest = $rbacreview->getAllOperationsOfRole(1010,1100);
425 $this->assertEquals($assert, $dest);
427 $rbacadmin->deleteTemplate(1010);
440 global $rbacreview, $rbacadmin;
441 $rbacadmin->deleteTemplate(1010);
442 $rbacadmin->deleteTemplate(2020);
444 $rbacadmin->setRolePermission(1010,
"blub",
array(10,11),1100);
445 $rbacadmin->setRolePermission(2020,
"bulb",
array(20,22),2200);
447 $rbacadmin->copyRoleTemplatePermissions(1010,1100,2200,2020);
449 $one = $rbacreview->getAllOperationsOfRole(1010,1100);
450 $two = $rbacreview->getAllOperationsOfRole(2020,2200);
453 $this->assertEquals($one, $two);
454 $rbacadmin->deleteTemplate(1010);
455 $rbacadmin->deleteTemplate(2020);
471 global $rbacreview, $rbacadmin,
$ilDB;
473 $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';");
477 while(
$row = $ilDB->fetchAssoc($req))
479 $seas =
$row[
"ref_id"];
482 $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';");
486 while(
$row = $ilDB->fetchAssoc($req))
488 $mail =
$row[
"ref_id"];
491 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
492 $ilDB->fetchAssoc($req);
493 $role = $ilDB->fetchAssoc($req)[
"obj_id"];
496 $opt_mail = $rbacreview->getActiveOperationsOfRole($mail, $role);
497 $opt_seas = $rbacreview->getActiveOperationsOfRole($seas, $role);
498 $opt_temp_seas = $rbacreview->getAllOperationsOfRole($role, $seas);
499 $opt_temp_mail = $rbacreview->getAllOperationsOfRole($role, $mail);
502 $rbacadmin->setRolePermission($role,
"mail",
array(1,2,3,4,5),$mail);
503 $rbacadmin->grantPermission($role,
array(1,2,3,4,5), $mail);
504 $rbacadmin->setRolePermission($role,
"seas",
array(5,6,7,8,9),$seas);
505 $rbacadmin->grantPermission($role,
array(5,6,7,8,9), $seas);
507 $rbacadmin->copyRolePermissions($role,$seas,$mail, $role);
508 $this->assertEquals($rbacreview->getActiveOperationsOfRole($seas, $role),
509 $rbacreview->getActiveOperationsOfRole($mail, $role));
512 $rbacadmin->grantPermission($role,$opt_seas,$seas);
513 $rbacadmin->grantPermission($role,$opt_mail,$mail);
515 $rbacadmin->deleteRolePermission($role,$mail);
516 $rbacadmin->deleteRolePermission($role,$seas);
518 foreach($opt_temp_seas as $type => $opt)
520 $rbacadmin->setRolePermission($role, $type, $opt,$seas);
523 foreach($opt_temp_mail as $type => $opt)
525 $rbacadmin->setRolePermission($role, $type, $opt,$mail);
540 global $rbacreview, $rbacadmin;
541 $rbacadmin->deleteTemplate(1010);
542 $rbacadmin->deleteTemplate(2020);
543 $rbacadmin->deleteTemplate(3030);
545 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15),1100);
546 $rbacadmin->setRolePermission(2020,
"a",
array(11,12,13,16),2200);
548 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25),1100);
549 $rbacadmin->setRolePermission(2020,
"b",
array(20,23,24,26),2200);
551 $rbacadmin->setRolePermission(3030,
"c",
array(30,33),3300);
552 $rbacadmin->setRolePermission(3030,
"a",
array(30,33),3300);
553 $rbacadmin->setRolePermission(3030,
"b",
array(30,33),3300);
555 $rbacadmin->copyRolePermissionIntersection(1010,1100,2020,2200,3300,3030);
558 $dest = $rbacreview->getAllOperationsOfRole(3030,3300);
564 $this->assertEquals($intersect, $dest);
566 $rbacadmin->deleteTemplate(1010);
567 $rbacadmin->deleteTemplate(2020);
568 $rbacadmin->deleteTemplate(3030);
582 global $rbacreview, $rbacadmin;
583 $rbacadmin->deleteTemplate(1010);
584 $rbacadmin->deleteTemplate(2020);
585 $rbacadmin->deleteTemplate(3030);
587 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15),1100);
588 $rbacadmin->setRolePermission(2020,
"a",
array(11,12,13,16),2200);
590 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25),1100);
591 $rbacadmin->setRolePermission(2020,
"b",
array(20,23,24,26),2200);
593 $rbacadmin->setRolePermission(1010,
"c",
array(30,33,34,35),1100);
595 $rbacadmin->copyRolePermissionUnion(1010,1100,2020,2200,3030,3300);
597 $union =
array(
"a" =>
array(10,11,12,13,15,16),
"b" =>
array(20,22,23,24,25,26),
"c" =>
array(30,33,34,35));
598 $dest = $rbacreview->getAllOperationsOfRole(3030,3300);
604 $this->assertEquals($union, $dest);
606 $rbacadmin->deleteTemplate(1010);
607 $rbacadmin->deleteTemplate(2020);
608 $rbacadmin->deleteTemplate(3030);
621 global $rbacreview, $rbacadmin;
622 $rbacadmin->deleteTemplate(1010);
623 $rbacadmin->deleteTemplate(2020);
625 $rbacadmin->setRolePermission(1010,
"a",
array(10,11,13,15),1100);
626 $rbacadmin->setRolePermission(2020,
"a",
array(11,12,13,16),2200);
628 $rbacadmin->setRolePermission(1010,
"b",
array(20,22,23,25),1100);
629 $rbacadmin->setRolePermission(2020,
"b",
array(20,23,24,26),2200);
631 $rbacadmin->setRolePermission(2020,
"c",
array(30,33,34,35),2200);
633 $rbacadmin->copyRolePermissionSubtract(1010,1100,2020,2200);
636 $dest = $rbacreview->getAllOperationsOfRole(2020,2200);
642 $this->assertEquals($subtract, $dest);
644 $rbacadmin->deleteTemplate(1010);
645 $rbacadmin->deleteTemplate(2020);
657 global $rbacreview, $rbacadmin;
659 $rbacadmin->assignOperationToObject(1001,10);
660 $rbacadmin->assignOperationToObject(1001,20);
662 $this->assertEquals($rbacreview->getOperationsOnType(1001),
array(10,20));
673 global $rbacreview, $rbacadmin;
674 $rbacadmin->deassignOperationFromObject(1001,10);
676 $this->assertEquals($rbacreview->getOperationsOnType(1001),
array(20));
678 $rbacadmin->deassignOperationFromObject(1001,20);
680 $this->assertEmpty($rbacreview->getOperationsOnType(1001));
testRbacPA()
test rbac_pa IL_Init
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.
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.
testRbacUA()
test rbac_ua IL_Init
testAssignOperationToObject()
Test assignOperationToObject Method DB: rbac_ta.
Unit tests for tree table needsInstalledILIAS.
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.